agent-afk 5.356.0 → 5.358.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.
Files changed (100) hide show
  1. package/dist/agent/auth/credential-resolver.d.ts +2 -1
  2. package/dist/agent/auth/keychain.d.ts +1 -0
  3. package/dist/agent/dag-subagent.d.ts +1 -0
  4. package/dist/agent/lsp/client-handlers.d.ts +4 -0
  5. package/dist/agent/lsp/client.d.ts +9 -0
  6. package/dist/agent/lsp/diagnostics-store.d.ts +1 -0
  7. package/dist/agent/lsp/document-sync.d.ts +3 -1
  8. package/dist/agent/lsp/install.d.ts +10 -0
  9. package/dist/agent/lsp/pool.d.ts +1 -0
  10. package/dist/agent/lsp/query.d.ts +1 -0
  11. package/dist/agent/outcomes/compute-outcomes.d.ts +1 -0
  12. package/dist/agent/outcomes/git-range.d.ts +1 -0
  13. package/dist/agent/outcomes/outcomes-ledger.d.ts +3 -0
  14. package/dist/agent/outcomes/outcomes-v1.schema.d.ts +2 -0
  15. package/dist/agent/outcomes/schema.d.ts +1 -0
  16. package/dist/agent/prompt-experiment.d.ts +2 -0
  17. package/dist/agent/providers/anthropic-direct/build-dispatcher.d.ts +2 -0
  18. package/dist/agent/providers/anthropic-direct/provider-options.d.ts +1 -0
  19. package/dist/agent/providers/anthropic-direct/provider-query-setup.d.ts +1 -0
  20. package/dist/agent/providers/anthropic-direct/provider-runtime.d.ts +1 -0
  21. package/dist/agent/providers/anthropic-direct/query/client-setup.d.ts +2 -0
  22. package/dist/agent/providers/anthropic-direct/query/closed-router-rotate.d.ts +10 -0
  23. package/dist/agent/providers/anthropic-direct/query/compact-handler.d.ts +1 -1
  24. package/dist/agent/providers/anthropic-direct/query/prompt-assembly.d.ts +1 -0
  25. package/dist/agent/providers/anthropic-direct/query/usage-limit-park-loop.d.ts +5 -0
  26. package/dist/agent/providers/anthropic-direct/query/usage-limit-pause.d.ts +4 -4
  27. package/dist/agent/providers/anthropic-direct/query-maintenance.d.ts +1 -1
  28. package/dist/agent/providers/anthropic-direct/query-options.d.ts +1 -0
  29. package/dist/agent/providers/anthropic-direct/query-runtime.d.ts +2 -1
  30. package/dist/agent/providers/anthropic-direct/query-turn-driver.d.ts +2 -1
  31. package/dist/agent/providers/anthropic-direct/usage-headers-writer.d.ts +31 -0
  32. package/dist/agent/providers/index.d.ts +1 -0
  33. package/dist/agent/providers/openai-compatible/compact.d.ts +1 -1
  34. package/dist/agent/providers/openai-compatible/index.dispatcher-opts.d.ts +4 -2
  35. package/dist/agent/providers/openai-compatible/index.options.d.ts +1 -0
  36. package/dist/agent/providers/openai-compatible/query/compact-handler.d.ts +1 -1
  37. package/dist/agent/providers/openai-compatible/system-prompt-wiring.d.ts +1 -0
  38. package/dist/agent/providers/shared/compaction.d.ts +1 -0
  39. package/dist/agent/providers/shared/compaction.summarizer-input.d.ts +4 -1
  40. package/dist/agent/providers/shared/lsp-install-eligibility.d.ts +2 -0
  41. package/dist/agent/providers/shared/tool-grant.d.ts +1 -0
  42. package/dist/agent/session/ledger-lifecycle.d.ts +2 -0
  43. package/dist/agent/session/provider-lifecycle.d.ts +2 -1
  44. package/dist/agent/session/wire-executors.d.ts +2 -1
  45. package/dist/agent/subagent/identity-preamble.d.ts +1 -1
  46. package/dist/agent/subagent/identity-preamble.worktree.d.ts +3 -0
  47. package/dist/agent/tool-category.d.ts +2 -1
  48. package/dist/agent/tools/compose-input-parse.d.ts +1 -0
  49. package/dist/agent/tools/dispatcher.d.ts +4 -2
  50. package/dist/agent/tools/dispatcher.handler-context.d.ts +4 -0
  51. package/dist/agent/tools/dispatcher.ledger.d.ts +6 -1
  52. package/dist/agent/tools/dispatcher.options.d.ts +2 -0
  53. package/dist/agent/tools/dispatcher.pre-dispatch-gates.bash.d.ts +6 -0
  54. package/dist/agent/tools/dispatcher.pre-dispatch-gates.d.ts +1 -0
  55. package/dist/agent/tools/handlers/grep.pipe-retry.d.ts +2 -2
  56. package/dist/agent/tools/handlers/lsp-diagnostics.d.ts +2 -2
  57. package/dist/agent/tools/handlers/lsp-install-consent.d.ts +3 -0
  58. package/dist/agent/tools/handlers/lsp-refactor-actions.d.ts +21 -0
  59. package/dist/agent/tools/handlers/lsp-refactor-input.d.ts +16 -0
  60. package/dist/agent/tools/handlers/lsp-refactor-symbols.d.ts +10 -0
  61. package/dist/agent/tools/handlers/lsp-refactor.d.ts +4 -0
  62. package/dist/agent/tools/handlers/lsp-server.d.ts +15 -0
  63. package/dist/agent/tools/handlers/lsp-symbols.d.ts +2 -1
  64. package/dist/agent/tools/handlers/lsp-workspace-edit-parse.d.ts +19 -0
  65. package/dist/agent/tools/handlers/lsp-workspace-edit.d.ts +18 -0
  66. package/dist/agent/tools/handlers/patch-apply-engine.d.ts +1 -1
  67. package/dist/agent/tools/handlers/patch-apply-guard.d.ts +2 -0
  68. package/dist/agent/tools/handlers/worktree.create-note.d.ts +1 -0
  69. package/dist/agent/tools/nesting.d.ts +1 -0
  70. package/dist/agent/tools/readonly-bash.destructive-git.d.ts +8 -0
  71. package/dist/agent/tools/readonly-bash.destructive-git.heredoc.d.ts +7 -0
  72. package/dist/agent/tools/readonly-bash.destructive-git.nested.d.ts +5 -0
  73. package/dist/agent/tools/readonly-bash.tokenizer.d.ts +5 -0
  74. package/dist/agent/tools/subagent/input-parse.d.ts +1 -0
  75. package/dist/agent/tools/subagent-executor.execute-once.helpers.d.ts +1 -1
  76. package/dist/agent/tools/types.d.ts +1 -0
  77. package/dist/agent/trace/cost.d.ts +0 -1
  78. package/dist/agent/trace/emit.d.ts +2 -1
  79. package/dist/agent/trace/events.compaction.d.ts +2 -0
  80. package/dist/agent/trace/events.d.ts +2 -0
  81. package/dist/agent/trace/types.compaction.d.ts +36 -0
  82. package/dist/agent/trace/types.d.ts +2 -34
  83. package/dist/agent/trace/writer.d.ts +2 -1
  84. package/dist/agent/types/config-types.d.ts +1 -0
  85. package/dist/agent/worktree/isolated-slug.d.ts +11 -0
  86. package/dist/agent/worktree/worktree-scratch.d.ts +13 -0
  87. package/dist/agent/worktree/worktree-sweep.classify.d.ts +1 -0
  88. package/dist/bundled-plugins/awa-bundled/skills/diagnose/SKILL.md +1 -1
  89. package/dist/bundled-plugins/awa-bundled/skills/refactor/SKILL.md +1 -1
  90. package/dist/bundled-plugins/awa-bundled/skills/ship/SKILL.md +17 -8
  91. package/dist/cli/slash/plugin-skills/state.d.ts +1 -0
  92. package/dist/cli.mjs +681 -659
  93. package/dist/config/env.d.ts +29 -0
  94. package/dist/config/env.misc.d.ts +14 -0
  95. package/dist/config/env.prompt-experiment.d.ts +15 -0
  96. package/dist/index.mjs +496 -474
  97. package/dist/paths.d.ts +1 -0
  98. package/dist/remote/remote-subagent-handle.d.ts +5 -2
  99. package/dist/telegram.mjs +538 -517
  100. package/package.json +1 -1
@@ -37,8 +37,10 @@ export interface SessionToolDispatcherOptions {
37
37
  subagentId?: string;
38
38
  sessionGrantManager?: GrantManager;
39
39
  isNonInteractive?: boolean;
40
+ lspInstallAllowed?: boolean;
40
41
  traceWriter?: TraceSink;
41
42
  readOnlyBash?: boolean;
43
+ blockDestructiveGit?: boolean;
42
44
  maxOutputBytes?: number;
43
45
  spawnedPidRegistry?: SpawnedPidRegistry;
44
46
  userAttention?: UserAttention;
@@ -0,0 +1,6 @@
1
+ import type { PreDispatchGateDeps } from './dispatcher.pre-dispatch-gates.js';
2
+ import type { ToolCall } from '../providers/anthropic-direct/types.js';
3
+ export type BashGateFlags = Pick<PreDispatchGateDeps, 'readOnlyBash' | 'blockDestructiveGit'>;
4
+ export declare function checkDestructiveGitBash(call: ToolCall, flags: BashGateFlags): string | undefined;
5
+ export declare function checkReadOnlyBash(call: ToolCall, flags: BashGateFlags): string | undefined;
6
+ export declare function bashCommandDenialReason(call: ToolCall, flags: BashGateFlags): string | undefined;
@@ -25,6 +25,7 @@ export interface PreDispatchGateDeps {
25
25
  permissions: ToolPermissionConfig | undefined;
26
26
  canUseTool: CanUseTool | undefined;
27
27
  readOnlyBash: boolean;
28
+ blockDestructiveGit: boolean;
28
29
  repeatFailureGuard: RepeatFailureGuard;
29
30
  sessionId: string | undefined;
30
31
  parentSessionId: string | undefined;
@@ -2,5 +2,5 @@ import type { SpawnOptions } from 'child_process';
2
2
  import { type GrepSettleResult } from './_rg-exit2.js';
3
3
  export declare function hasUnescapedBackslashPipe(pattern: string): boolean;
4
4
  export declare function rewriteBackslashPipe(pattern: string): string;
5
- export declare function runPipeRetry(originalPattern: string, rgPath: string, rgArgs: string[], spawnOptions: SpawnOptions, searchPath: string, signal: AbortSignal, scanCapBytes: number): Promise<GrepSettleResult>;
6
- export declare function handlePipeRetry(originalPattern: string, rgPath: string, rgArgs: string[], effectiveCwd: string | undefined, searchPath: string, signal: AbortSignal, scanCapBytes: number, settle: (result: GrepSettleResult) => void): void;
5
+ export declare function runPipeRetry(originalPattern: string, rewrittenPattern: string, rgPath: string, rgArgs: string[], spawnOptions: SpawnOptions, searchPath: string, signal: AbortSignal, scanCapBytes: number): Promise<GrepSettleResult>;
6
+ export declare function handlePipeRetry(originalPattern: string, rewrittenPattern: string, rgPath: string, rgArgs: string[], effectiveCwd: string | undefined, searchPath: string, signal: AbortSignal, scanCapBytes: number, settle: (result: GrepSettleResult) => void): void;
@@ -5,6 +5,6 @@ export interface LspDiagnostic {
5
5
  col: number;
6
6
  }
7
7
  export declare function isLspDiagnosticsEnabled(): boolean;
8
- export declare function queryLspDiagnostics(filePath: string, serverCmd?: readonly string[], signal?: AbortSignal): Promise<LspDiagnostic[]>;
8
+ export declare function queryLspDiagnostics(filePath: string, serverCmd?: readonly string[], sessionRoot?: string, signal?: AbortSignal): Promise<LspDiagnostic[]>;
9
9
  export declare function formatDiagnostics(filePath: string, diags: LspDiagnostic[]): string;
10
- export declare function appendLspDiagnostics(filePath: string, serverCmd?: readonly string[], signal?: AbortSignal): Promise<string>;
10
+ export declare function appendLspDiagnostics(filePath: string, serverCmd?: readonly string[], sessionRoot?: string, signal?: AbortSignal): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { InstallContext } from '../../lsp/server-spec.js';
2
+ import type { ToolHandlerContext } from '../types.js';
3
+ export declare function lspInstallContext(context?: ToolHandlerContext, signal?: AbortSignal): InstallContext;
@@ -0,0 +1,21 @@
1
+ import type { QueryContext } from '../../lsp/query.js';
2
+ import type { ToolHandlerContext, ToolResult } from '../types.js';
3
+ import type { LspRefactorInput } from './lsp-refactor-input.js';
4
+ export interface RefactorEnvironment {
5
+ context?: ToolHandlerContext;
6
+ cwd: string;
7
+ signal?: AbortSignal;
8
+ expectedContents: ReadonlyMap<string, string>;
9
+ requestStartedAt: number;
10
+ }
11
+ export declare function requestSnapshot(client: Pick<QueryContext['client'], 'documentContents'>): Promise<Pick<RefactorEnvironment, 'expectedContents' | 'requestStartedAt'>>;
12
+ export declare function editOptions(ctx: QueryContext, env: RefactorEnvironment): {
13
+ client: import("../../lsp/client.js").LspClient;
14
+ documentVersion: (uri: string) => number | undefined;
15
+ context?: ToolHandlerContext;
16
+ cwd: string;
17
+ signal?: AbortSignal;
18
+ expectedContents: ReadonlyMap<string, string>;
19
+ requestStartedAt: number;
20
+ };
21
+ export declare function codeActions(input: LspRefactorInput, ctx: QueryContext, env: RefactorEnvironment): Promise<ToolResult>;
@@ -0,0 +1,16 @@
1
+ export declare const REFACTOR_COMMANDS: readonly ["rename", "document_symbols", "workspace_symbols", "code_actions"];
2
+ export type RefactorCommand = typeof REFACTOR_COMMANDS[number];
3
+ export interface LspRefactorInput {
4
+ subcommand: RefactorCommand;
5
+ file_path?: string;
6
+ line?: number;
7
+ col?: number;
8
+ end_line?: number;
9
+ end_col?: number;
10
+ new_name?: string;
11
+ query?: string;
12
+ apply?: boolean;
13
+ action_index?: number;
14
+ action_title?: string;
15
+ }
16
+ export declare function validateRefactorInput(input: LspRefactorInput): string | undefined;
@@ -0,0 +1,10 @@
1
+ import type { ToolHandlerContext } from '../types.js';
2
+ export declare function record(value: unknown): Record<string, unknown> | undefined;
3
+ export declare function symbolRows(raw: unknown, uri: string | undefined, context?: ToolHandlerContext, cwd?: string): {
4
+ name: string;
5
+ kind: number;
6
+ file_path: string;
7
+ line: number;
8
+ col: number;
9
+ depth: number;
10
+ }[];
@@ -0,0 +1,4 @@
1
+ import type { ToolHandlerContext, ToolResult } from '../types.js';
2
+ import { type LspRefactorInput } from './lsp-refactor-input.js';
3
+ export type { LspRefactorInput } from './lsp-refactor-input.js';
4
+ export declare function handleLspRefactor(input: LspRefactorInput, context?: ToolHandlerContext, cwd?: string, serverCmd?: readonly string[], signal?: AbortSignal): Promise<ToolResult>;
@@ -0,0 +1,15 @@
1
+ import type { InstallContext, ServerSpec } from '../../lsp/server-spec.js';
2
+ export interface LspServerOptions {
3
+ sessionRoot?: string;
4
+ serverCmd?: readonly string[];
5
+ installContext?: InstallContext;
6
+ }
7
+ export type LspServerResult = {
8
+ kind: 'resolved';
9
+ spec: ServerSpec;
10
+ root: string;
11
+ } | {
12
+ kind: 'unavailable';
13
+ error: string;
14
+ };
15
+ export declare function resolveLspServer(filePath: string, options?: LspServerOptions): Promise<LspServerResult>;
@@ -1,5 +1,6 @@
1
1
  import type { ToolHandlerContext } from '../types.js';
2
2
  import { DEFAULT_LSP_CMD } from '../../lsp/typescript-default.js';
3
+ import type { InstallContext } from '../../lsp/server-spec.js';
3
4
  export interface LspLocation {
4
5
  filePath: string;
5
6
  line: number;
@@ -13,7 +14,7 @@ export type SymbolSubcommand = 'definition' | 'references';
13
14
  export { DEFAULT_LSP_CMD };
14
15
  export declare function parseLocation(raw: unknown): LspLocation | null;
15
16
  export declare function isLspSymbolsEnabled(): boolean;
16
- export declare function queryLspSymbol(filePath: string, subcommand: SymbolSubcommand, line: number, col: number, rootDir?: string, serverCmd?: readonly string[], signal?: AbortSignal): Promise<LspSymbolResult>;
17
+ export declare function queryLspSymbol(filePath: string, subcommand: SymbolSubcommand, line: number, col: number, rootDir?: string, serverCmd?: readonly string[], signal?: AbortSignal, installContext?: InstallContext): Promise<LspSymbolResult>;
17
18
  export declare function formatSymbolResult(filePath: string, subcommand: SymbolSubcommand, line: number, col: number, result: LspSymbolResult): string;
18
19
  export declare function handleCodeSymbols(input: {
19
20
  file_path: string;
@@ -0,0 +1,19 @@
1
+ interface Position {
2
+ line: number;
3
+ character: number;
4
+ }
5
+ interface TextEdit {
6
+ range: {
7
+ start: Position;
8
+ end: Position;
9
+ };
10
+ newText: string;
11
+ }
12
+ export interface WorkspaceDocument {
13
+ uri: string;
14
+ version?: number | null;
15
+ edits: TextEdit[];
16
+ }
17
+ export declare function workspaceDocuments(value: unknown): WorkspaceDocument[];
18
+ export declare function applyTextEdits(text: string, edits: readonly TextEdit[]): string;
19
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { LspClient } from '../../lsp/client.js';
2
+ import type { ToolHandlerContext, ToolResult } from '../types.js';
3
+ import { type PatchFileChange } from './patch-validate.js';
4
+ export interface WorkspaceEditOptions {
5
+ cwd: string;
6
+ context?: ToolHandlerContext;
7
+ signal?: AbortSignal;
8
+ dryRun?: boolean;
9
+ client?: Pick<LspClient, 'syncFile'>;
10
+ documentVersion?: (uri: string) => number | undefined;
11
+ expectedContents: ReadonlyMap<string, string>;
12
+ requestStartedAt: number;
13
+ writtenContents?: ReadonlyMap<string, string>;
14
+ onApplied?: (written: ReadonlyMap<string, string>) => void;
15
+ }
16
+ export declare function fileClockNow(): Promise<number>;
17
+ export declare function convertWorkspaceEdit(edit: unknown, options: WorkspaceEditOptions): Promise<PatchFileChange[]>;
18
+ export declare function applyWorkspaceEdit(edit: unknown, options: WorkspaceEditOptions): Promise<ToolResult>;
@@ -11,4 +11,4 @@ export interface PatchApplyResult {
11
11
  }>;
12
12
  errors: ValidationError[];
13
13
  }
14
- export declare function applyPatch(changes: PatchFileChange[], fileContents: Map<string, string | null>, resolveBase: string | undefined, dryRun: boolean): Promise<PatchApplyResult>;
14
+ export declare function applyPatch(changes: PatchFileChange[], fileContents: Map<string, string | null>, resolveBase: string | undefined, dryRun: boolean, guard?: (path: string) => Promise<void>): Promise<PatchApplyResult>;
@@ -0,0 +1,2 @@
1
+ import type { ToolHandlerContext } from '../types.js';
2
+ export declare function capturePatchGuard(contents: Map<string, string | null>, context: ToolHandlerContext | undefined, cwd?: string): Promise<(path: string) => Promise<void>>;
@@ -1,3 +1,4 @@
1
1
  import type { ManagedWorktreeInfo } from './worktree-managed.js';
2
2
  export declare function detectInstallCommand(worktreePath: string): Promise<string>;
3
+ export declare function scratchDirNote(worktreePath: string): string;
3
4
  export declare function buildCreateNote(info: ManagedWorktreeInfo): Promise<string>;
@@ -32,6 +32,7 @@ export declare const DEFAULT_READ_ONLY_SKILLS: ReadonlySet<string>;
32
32
  export interface CreateChildProviderFactoryOptions {
33
33
  openaiBaseUrl?: string;
34
34
  workspaceStore?: WorkspaceStore;
35
+ blockDestructiveGit?: boolean;
35
36
  }
36
37
  export declare function createChildProviderFactory(opts?: CreateChildProviderFactoryOptions): (args: ChildProviderFactoryArgs) => ModelProvider;
37
38
  export declare function buildReadOnlyReconProvider(model: AgentModelInput | undefined, openaiBaseUrl?: string, allowedTools?: readonly string[], workspaceStore?: WorkspaceStore): ModelProvider;
@@ -0,0 +1,8 @@
1
+ export declare const DESTRUCTIVE_GIT_SUBCMDS: Set<string>;
2
+ type Verdict = {
3
+ destructive: boolean;
4
+ reason?: string;
5
+ };
6
+ export declare function destructiveGitSegmentReason(argv: readonly string[], depth?: number): string | null;
7
+ export declare function classifyDestructiveGit(command: string, depth?: number): Verdict;
8
+ export {};
@@ -0,0 +1,7 @@
1
+ type View = {
2
+ command: string;
3
+ scripts: string[];
4
+ uncertain?: string;
5
+ };
6
+ export declare function destructiveGitHeredocView(command: string): View;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const SHELL_INTERPS: Set<string>;
2
+ export declare const INTERP_WRAPPERS: Set<string>;
3
+ export declare function interpreterCommandStrings(tokens: readonly string[]): string[];
4
+ export declare function evalPayloads(tokens: readonly string[]): string[];
5
+ export declare function substitutionRewrites(command: string): string[];
@@ -5,7 +5,12 @@ export interface CmdSegment {
5
5
  export declare function baseName(cmd: string): string;
6
6
  export declare function tokenizeSegments(command: string): string[][];
7
7
  export declare function resolveSegment(rawTokens: readonly string[], vars: Map<string, string>): CmdSegment | null;
8
+ export declare function gitSubcommand(argv: readonly string[]): {
9
+ sub: string | undefined;
10
+ rest: readonly string[];
11
+ };
8
12
  export declare function gitSegmentReason(argv: readonly string[]): string | null;
9
13
  export declare function curlSegmentMutating(seg: CmdSegment): boolean;
14
+ export { DESTRUCTIVE_GIT_SUBCMDS, destructiveGitSegmentReason, classifyDestructiveGit } from './readonly-bash.destructive-git.js';
10
15
  export declare function tokenizedSegmentReason(command: string): string | null;
11
16
  export declare function segmentMutationReason(segments: readonly (readonly string[])[]): string | null;
@@ -14,6 +14,7 @@ export interface AgentInput {
14
14
  writeRoots?: string[];
15
15
  readRoots?: string[];
16
16
  isolation?: 'worktree';
17
+ task_slug?: string;
17
18
  progress_events?: boolean;
18
19
  host?: string;
19
20
  continuation_chain_id?: string;
@@ -19,7 +19,7 @@ export interface IsolationWorktreeResult {
19
19
  setupNotice?: string;
20
20
  }
21
21
  export interface SetupIsolationWorktreeArgs {
22
- parsed: Pick<AgentInput, 'prompt' | 'mode' | 'agent_type' | 'id_prefix'>;
22
+ parsed: Pick<AgentInput, 'prompt' | 'mode' | 'agent_type' | 'id_prefix' | 'task_slug'>;
23
23
  currentCwd: string | undefined;
24
24
  isolationCounterRef: {
25
25
  value: number;
@@ -19,6 +19,7 @@ export interface ToolHandlerContext {
19
19
  traceWriter?: TraceSink;
20
20
  toolUseId?: string;
21
21
  sessionId?: string;
22
+ lspInstallAllowed?: boolean;
22
23
  spawnedPidRegistry?: SpawnedPidRegistry;
23
24
  onBashOutputTail?: (tail: string | undefined) => void;
24
25
  userAttention?: UserAttention;
@@ -27,7 +27,6 @@ export declare class SessionCostAccumulator {
27
27
  private lastClosureCost;
28
28
  private lastClosureTurns;
29
29
  private lastRootClosure;
30
- private rootClosureCount;
31
30
  private lastClosureSubagentId;
32
31
  private rootCycleSum;
33
32
  private rootCycleTurnCount;
@@ -1,4 +1,5 @@
1
- import type { AbortPayload, BackgroundAgentPayload, BrowserEventPayload, BudgetPayload, ClaimPayload, ClosurePayload, CompactionPayloadInput, HookDecisionPayload, HookSummaryPayload, PeerMessagePayload, QueuedUserMessagePayload, SessionPhasePayload, SubagentLifecyclePayload, ToolCallPayload } from './types.js';
1
+ import type { AbortPayload, BackgroundAgentPayload, BrowserEventPayload, BudgetPayload, ClaimPayload, ClosurePayload, HookDecisionPayload, HookSummaryPayload, PeerMessagePayload, QueuedUserMessagePayload, SessionPhasePayload, SubagentLifecyclePayload, ToolCallPayload } from './types.js';
2
+ import type { CompactionPayloadInput } from './types.compaction.js';
2
3
  import type { TraceSink } from './writer.js';
3
4
  export declare const emitToolCall: (w: TraceSink | undefined, p: ToolCallPayload) => Promise<void>;
4
5
  export declare const emitHookDecision: (w: TraceSink | undefined, p: HookDecisionPayload) => Promise<void>;
@@ -22,6 +22,7 @@ export declare const CompactionPayloadInputSchema: z.ZodObject<{
22
22
  messagesBefore: z.ZodNumber;
23
23
  messagesAfter: z.ZodNumber;
24
24
  tokensSavedEstimate: z.ZodOptional<z.ZodNumber>;
25
+ summarizerInputCharsDropped: z.ZodOptional<z.ZodNumber>;
25
26
  summarizationTokens: z.ZodOptional<z.ZodObject<{
26
27
  input: z.ZodNumber;
27
28
  output: z.ZodNumber;
@@ -44,6 +45,7 @@ export declare const CompactionPayloadPersistedSchema: z.ZodObject<{
44
45
  messagesBefore: z.ZodNumber;
45
46
  messagesAfter: z.ZodNumber;
46
47
  tokensSavedEstimate: z.ZodOptional<z.ZodNumber>;
48
+ summarizerInputCharsDropped: z.ZodOptional<z.ZodNumber>;
47
49
  summarizationTokens: z.ZodOptional<z.ZodObject<{
48
50
  input: z.ZodNumber;
49
51
  output: z.ZodNumber;
@@ -589,6 +589,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
589
589
  messagesBefore: z.ZodNumber;
590
590
  messagesAfter: z.ZodNumber;
591
591
  tokensSavedEstimate: z.ZodOptional<z.ZodNumber>;
592
+ summarizerInputCharsDropped: z.ZodOptional<z.ZodNumber>;
592
593
  summarizationTokens: z.ZodOptional<z.ZodObject<{
593
594
  input: z.ZodNumber;
594
595
  output: z.ZodNumber;
@@ -1071,6 +1072,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1071
1072
  messagesBefore: z.ZodNumber;
1072
1073
  messagesAfter: z.ZodNumber;
1073
1074
  tokensSavedEstimate: z.ZodOptional<z.ZodNumber>;
1075
+ summarizerInputCharsDropped: z.ZodOptional<z.ZodNumber>;
1074
1076
  summarizationTokens: z.ZodOptional<z.ZodObject<{
1075
1077
  input: z.ZodNumber;
1076
1078
  output: z.ZodNumber;
@@ -0,0 +1,36 @@
1
+ export type CompactionTrigger = 'manual' | 'token_threshold' | 'turn_count';
2
+ export interface CompactionPayloadInput {
3
+ trigger: CompactionTrigger;
4
+ preCompactionMessages: unknown[];
5
+ summary: string;
6
+ keptTailCount: number;
7
+ keepLastNConfig: number;
8
+ messagesBefore: number;
9
+ messagesAfter: number;
10
+ tokensSavedEstimate?: number;
11
+ summarizationTokens?: {
12
+ input: number;
13
+ output: number;
14
+ };
15
+ summarizerInputCharsDropped?: number;
16
+ }
17
+ export interface CompactionSidecarRef {
18
+ path: string;
19
+ sizeBytes: number;
20
+ sha256: string;
21
+ }
22
+ export interface CompactionPayloadPersisted {
23
+ trigger: CompactionTrigger;
24
+ preCompactionMessagesRef: CompactionSidecarRef;
25
+ summary: string;
26
+ keptTailCount: number;
27
+ keepLastNConfig: number;
28
+ messagesBefore: number;
29
+ messagesAfter: number;
30
+ tokensSavedEstimate?: number;
31
+ summarizationTokens?: {
32
+ input: number;
33
+ output: number;
34
+ };
35
+ summarizerInputCharsDropped?: number;
36
+ }
@@ -110,40 +110,8 @@ export interface AbortPayload {
110
110
  cascadedTo: readonly string[];
111
111
  reason?: string;
112
112
  }
113
- export type CompactionTrigger = 'manual' | 'token_threshold' | 'turn_count';
114
- export interface CompactionPayloadInput {
115
- trigger: CompactionTrigger;
116
- preCompactionMessages: unknown[];
117
- summary: string;
118
- keptTailCount: number;
119
- keepLastNConfig: number;
120
- messagesBefore: number;
121
- messagesAfter: number;
122
- tokensSavedEstimate?: number;
123
- summarizationTokens?: {
124
- input: number;
125
- output: number;
126
- };
127
- }
128
- export interface CompactionSidecarRef {
129
- path: string;
130
- sizeBytes: number;
131
- sha256: string;
132
- }
133
- export interface CompactionPayloadPersisted {
134
- trigger: CompactionTrigger;
135
- preCompactionMessagesRef: CompactionSidecarRef;
136
- summary: string;
137
- keptTailCount: number;
138
- keepLastNConfig: number;
139
- messagesBefore: number;
140
- messagesAfter: number;
141
- tokensSavedEstimate?: number;
142
- summarizationTokens?: {
143
- input: number;
144
- output: number;
145
- };
146
- }
113
+ import type { CompactionPayloadInput, CompactionPayloadPersisted } from './types.compaction.js';
114
+ export type { CompactionTrigger, CompactionPayloadInput, CompactionPayloadPersisted, CompactionSidecarRef, } from './types.compaction.js';
147
115
  export type ClosureReason = 'model_end_turn' | 'truncated' | 'iteration_cap' | 'abort' | 'timeout' | 'budget_exceeded' | 'hook_blocked' | 'max_turns_exceeded';
148
116
  export interface ClosurePayload {
149
117
  reason: ClosureReason;
@@ -1,4 +1,5 @@
1
- import type { CompactionPayloadInput, SessionSealedPayload, TraceEvent, TraceEventInput } from './types.js';
1
+ import type { CompactionPayloadInput } from './types.compaction.js';
2
+ import type { SessionSealedPayload, TraceEvent, TraceEventInput } from './types.js';
2
3
  export interface TraceSink {
3
4
  write(event: TraceEventInput): Promise<void>;
4
5
  getTracePath(): string;
@@ -117,6 +117,7 @@ export interface AgentConfig {
117
117
  skillDispatchName?: string;
118
118
  isUnnamedWorker?: boolean;
119
119
  isNonInteractive?: boolean;
120
+ lspInstallAllowed?: boolean;
120
121
  autoCompact?: boolean | {
121
122
  threshold: number;
122
123
  };
@@ -0,0 +1,11 @@
1
+ export declare const ISOLATED_SLUG_SUFFIX_LENGTH = 6;
2
+ export declare const MAX_TASK_SLUG_LENGTH = 48;
3
+ export declare function randomSlugSuffix(bytes?: (n: number) => Buffer): string;
4
+ export declare function cleanTaskSlug(raw: string): string;
5
+ export interface BuildIsolatedSlugArgs {
6
+ taskSlug?: string | undefined;
7
+ idPrefix: string | undefined;
8
+ counter: number;
9
+ suffix?: string;
10
+ }
11
+ export declare function buildIsolatedSlug(args: BuildIsolatedSlugArgs): string;
@@ -0,0 +1,13 @@
1
+ export declare const AFK_SCRATCH_DIR = ".afk-scratch";
2
+ export declare const AFK_SCRATCH_EXCLUDE_PATTERN = "/.afk-scratch/";
3
+ export declare const AFK_META_FILE = ".afk-worktree-meta.json";
4
+ export declare const AFK_META_EXCLUDE_PATTERN = "/.afk-worktree-meta.json";
5
+ export type ScratchGitRunner = (file: string, args: string[]) => Promise<{
6
+ stdout: string;
7
+ stderr: string;
8
+ }>;
9
+ export declare function isScratchDisposable(worktreePath: string): Promise<boolean>;
10
+ export declare function missingAfkExcludes(content: string): string[];
11
+ export declare function excludeHasScratchEntry(content: string): boolean;
12
+ export declare function excludeHasMetaEntry(content: string): boolean;
13
+ export declare function ensureAfkExcludes(execFile: ScratchGitRunner, anyPath: string): Promise<boolean>;
@@ -6,6 +6,7 @@ export interface WorktreeMeta {
6
6
  createdAt: string;
7
7
  baseSha?: string;
8
8
  baseBranch?: string;
9
+ scratchDisposable?: boolean;
9
10
  preservedReason?: 'dirty' | 'commits-ahead' | 'ignored-local-state';
10
11
  preservedAt?: string;
11
12
  commitsAheadAtPreserve?: number;
@@ -14,6 +14,6 @@ Gather context: read the failing test or bug description, relevant error output,
14
14
  - Git history agent: `id_prefix: "git history"`
15
15
  - Each hypothesis-testing agent: `id_prefix: "hypothesis: <one-phrase cause>"` (e.g. `"hypothesis: null deref in parser"`)
16
16
 
17
- For each hypothesis, dispatch a sub-agent with `isolation: "worktree"` to apply a minimal speculative fix, run the test or verification command, and then run the broader related test suite to check for regressions. Run all hypothesis-testing agents in parallel. Collect results: which fixes passed, which didn't, and any regressions surfaced by the broader suite.
17
+ For each hypothesis, dispatch a sub-agent with `isolation: "worktree"` (and a `task_slug` naming the hypothesis, e.g. `hyp-null-deref-parser`, so its branch is readable) to apply a minimal speculative fix, run the test or verification command, and then run the broader related test suite to check for regressions. Run all hypothesis-testing agents in parallel. Collect results: which fixes passed, which didn't, and any regressions surfaced by the broader suite.
18
18
 
19
19
  Report the validated root cause (the hypothesis whose fix passed), the speculative fix diff, and regression status from the broader test run. If no hypothesis passes, synthesize what was learned and form a second round of hypotheses. If the user approves the fix, apply it to the main worktree.
@@ -90,7 +90,7 @@ Dispatch one sub-agent per site in this layer, all in parallel, each in a worktr
90
90
  - `test_output`: truncated stdout of the targeted test run (last 20 lines)
91
91
  - `failure_reason`: populated only if `status == "red"` — the first failing assertion + the file:line where it fired
92
92
  - non_goals: Do not change any file other than the one in your site descriptor. Do not run the full test suite.
93
- - IMPORTANT: this sub-agent MAY call `edit_file` and run bash commands; `isolation: "worktree"` is required.
93
+ - IMPORTANT: this sub-agent MAY call `edit_file` and run bash commands; `isolation: "worktree"` is required. Set `task_slug` to a short kebab name for the site (e.g. `refactor-l2-auth-client`) so the worktree branch is readable.
94
94
 
95
95
  **Layer gate — hard stop before proceeding to the next layer:**
96
96
  - All sites in this layer `status == "green"` → proceed to the next layer.
@@ -62,13 +62,21 @@ Before committing, review the **file list** to stage — don't sweep in untracke
62
62
  Stage only the confirmed files, then write the commit message to a temp file with your file-writing tool — **NOT** a shell heredoc — and commit with `-F`:
63
63
 
64
64
  ```
65
- # 1. Write the subject + body to a temp file (e.g. .git/COMMIT_BODY.txt) using
66
- # your file-writing tool. The content never passes through the shell.
67
- # 2. Commit from that file:
68
- git commit -F .git/COMMIT_BODY.txt
65
+ # 1. Pick the scratch dir <SCRATCH>. It must not be the working tree itself:
66
+ # - Your cwd is under `.afk-worktrees/` (an afk-managed worktree):
67
+ # <worktree-root>/.afk-scratch
68
+ # git ignores it, you can always write there, and it is deleted with
69
+ # the worktree.
70
+ # - Any other checkout: the path printed by
71
+ # git rev-parse --absolute-git-dir
72
+ # Do NOT assume `.git/`: in a linked worktree `.git` is a FILE.
73
+ # 2. Write the subject + body to <SCRATCH>/COMMIT_BODY.txt with your
74
+ # file-writing tool. The content never passes through the shell.
75
+ # 3. Commit from that file:
76
+ git commit -F <SCRATCH>/COMMIT_BODY.txt
69
77
  ```
70
78
 
71
- Going through a file keeps backticks, `$(...)`, and quotes in the message literal. **Never** assemble the message inline as `git commit -m "$(cat <<'EOF' … EOF)"` — a backtick or `$(` in the body is parsed by the shell *before* `git` runs, so the commit fails or records a mangled message. `.git/` is never staged, so the temp file can't sneak into the commit (in a linked worktree `.git` is a file, not a dir — write to the path printed by `git rev-parse --git-dir` instead).
79
+ Going through a file keeps backticks, `$(...)`, and quotes in the message literal. **Never** assemble the message inline as `git commit -m "$(cat <<'EOF' … EOF)"` — a backtick or `$(` in the body is parsed by the shell *before* `git` runs, so the commit fails or records a mangled message. Neither location is tracked or shown by `git status`, so the temp file can't sneak into the commit or leave the tree dirty. Never drop it anywhere else in an afk-managed worktree (for example `pr-body.txt` at the root): an untracked file there stops the worktree from being cleaned up.
72
80
 
73
81
  Never `--amend` (creates a new commit each time). Never bypass hooks (`--no-verify`).
74
82
 
@@ -146,12 +154,13 @@ Structure:
146
154
  Write the PR body (from Phase 7) to a temp file with your file-writing tool — **NOT** a shell heredoc — then pass it with `--body-file`:
147
155
 
148
156
  ```
149
- # 1. Write the Phase 7 PR body to a temp file (e.g. .git/PR_BODY.md) using your
150
- # file-writing tool. The body never passes through the shell.
157
+ # 1. Write the Phase 7 PR body to <SCRATCH>/PR_BODY.md (the same <SCRATCH>
158
+ # you picked in Phase 4) with your file-writing tool.
159
+ # The body never passes through the shell.
151
160
  # 2. Open the PR from that file:
152
161
  gh pr create \
153
162
  --title "<subject line of the commit>" \
154
- --body-file .git/PR_BODY.md \
163
+ --body-file <SCRATCH>/PR_BODY.md \
155
164
  --base <default-branch> \
156
165
  [--draft]
157
166
  ```
@@ -23,4 +23,5 @@ export declare function setState(next: PluginSkillsState): void;
23
23
  export declare function setInitBarrier(promise: Promise<void>): void;
24
24
  export declare function isPluginInitPending(): boolean;
25
25
  export declare function awaitPluginInit(timeoutMs: number): Promise<void>;
26
+ export declare function isRegistrySource(source: SkillManifestEntry['source'] | undefined): boolean;
26
27
  export declare function bareName(name: string): string;