agent-afk 5.15.10 → 5.15.12
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/background-registry.d.ts +1 -0
- package/dist/agent/subagent.d.ts +2 -0
- package/dist/agent/tools/child-credential.d.ts +2 -0
- package/dist/agent/tools/system-prompt.d.ts +4 -1
- package/dist/agent/trace/events.d.ts +37 -0
- package/dist/agent/trace/types.d.ts +7 -1
- package/dist/cli/commands/interactive/afk-push.d.ts +1 -0
- package/dist/cli/commands/interactive/bg-result-notifier.d.ts +18 -0
- package/dist/cli/commands/interactive/footer-subsystems.d.ts +2 -0
- package/dist/cli/commands/interactive/shared.d.ts +1 -0
- package/dist/cli.mjs +494 -489
- package/dist/config/env.d.ts +1 -0
- package/dist/index.mjs +202 -204
- package/dist/telegram.mjs +239 -241
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ afk chat "hello"
|
|
|
55
55
|
|
|
56
56
|
> **Agent AFK Pro:** Autonomous skill-generation (`/forge`) and the calibrated skill-qualification rubric (`/qualify`) are reserved for Agent AFK Pro and are not part of the open-source build.
|
|
57
57
|
- **Cross-session memory** — Claude remembers preferences, decisions, and procedures across runs. See [Memory](#memory) below.
|
|
58
|
-
- **Background subagent jobs** — dispatch a subagent with `mode:'background'`; `/bgsub` lists running and completed jobs, `/bgsub:join <id>`
|
|
58
|
+
- **Background subagent jobs** — dispatch a subagent with `mode:'background'`; results auto-deliver into the model's context when they finish. `/bgsub` lists running and completed jobs, `/bgsub:join <id>` replays a result manually.
|
|
59
59
|
|
|
60
60
|
## Four surfaces, one session manager
|
|
61
61
|
|
|
@@ -45,6 +45,7 @@ export declare class BackgroundAgentRegistry extends EventEmitter<BackgroundRegi
|
|
|
45
45
|
get(jobId: string): BackgroundJob | undefined;
|
|
46
46
|
list(): readonly BackgroundJob[];
|
|
47
47
|
join(jobId: string): Promise<SubagentResult>;
|
|
48
|
+
markDelivered(jobId: string): void;
|
|
48
49
|
cancelJob(jobId: string): Promise<boolean>;
|
|
49
50
|
cancelAll(): Promise<void>;
|
|
50
51
|
appendTranscript(jobId: string, chunk: string): void;
|
package/dist/agent/subagent.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface SubagentManagerOptions {
|
|
|
32
32
|
progressSink?: SubagentProgressSink;
|
|
33
33
|
apiKey?: string;
|
|
34
34
|
baseUrl?: string;
|
|
35
|
+
parentModel?: string;
|
|
35
36
|
cwd?: string;
|
|
36
37
|
traceWriter?: TraceWriter;
|
|
37
38
|
surface?: Surface;
|
|
@@ -44,6 +45,7 @@ export declare class SubagentManager {
|
|
|
44
45
|
private readonly progressSink;
|
|
45
46
|
private readonly parentApiKey;
|
|
46
47
|
private readonly parentBaseUrl;
|
|
48
|
+
private readonly parentProvider;
|
|
47
49
|
private parentCwd;
|
|
48
50
|
private readonly parentTraceWriter;
|
|
49
51
|
private readonly parentSurface;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BundledProviderName } from '../providers/index.js';
|
|
1
2
|
export declare function isAnthropicCredential(key: string | undefined): key is string;
|
|
2
3
|
export declare function applyParentCredentialFallback(args: {
|
|
3
4
|
childModel: string;
|
|
@@ -8,4 +9,5 @@ export declare function applyManagerApiKeyFallback(args: {
|
|
|
8
9
|
childModel: string | undefined;
|
|
9
10
|
configApiKey: string | undefined;
|
|
10
11
|
parentApiKey: string | undefined;
|
|
12
|
+
parentProvider?: BundledProviderName | undefined;
|
|
11
13
|
}): string | undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export declare const TOOL_SYSTEM_PROMPT_BASE = "You have access to tools for working with the filesystem and running commands. Follow these conventions:\n\n- Use read_file before editing to verify the exact content you want to change.\n- Prefer edit_file over write_file for modifying existing files \u2014 write_file is for new files or complete rewrites.\n- Quote file paths that contain spaces with double quotes.\n- Do not run destructive shell commands (rm -rf, git reset --hard, etc.) unless the user explicitly asks.\n- Use glob and grep to discover files before reading individual files.\n- When bash output is very long, it may be truncated. If you need the full output, redirect to a file and read it.\n- Use absolute paths for file operations.\n- Prefer `agent` (and `skill`) for multi-file investigation, verification, parallel hypotheses, and any work that would otherwise consume large amounts of inline context. The main session is the coordinator; subagents are the investigators.";
|
|
2
2
|
export declare const SLASH_COMMAND_ROUTING_PROMPT = "When you see a `<command-name>` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch that same skill again. Instead, treat the `<command-message>` as the skill name and `<command-args>` as its arguments, then follow the instructions in the body block immediately following the tag. You MAY still invoke the skill tool to dispatch OTHER skills that are not the one already loaded.";
|
|
3
3
|
export declare const BASH_PASSTHROUGH_PROMPT = "When a user message contains a `<bash-passthrough>` block, it represents a shell command the **user ran directly** in the REPL using the `!` prefix (e.g. `!ls` or `!&pnpm test`). This is distinct from the `bash` tool you invoke yourself:\n\n- `<bash-passthrough>` = human-initiated shell run, output injected into your context automatically\n- `bash` tool result = model-initiated command you explicitly called\n\nAttributes on the opening tag:\n- `mode=\"foreground\"` \u2014 user waited for the command to finish before the next prompt\n- `mode=\"background\"` \u2014 command ran detached (`!&` prefix); output arrives after it completes\n- `exit=\"N\"` \u2014 shell exit code (0 = success)\n- `reason=\"...\"` \u2014 error category when nonzero: `nonzero-exit`, `abort` (Ctrl+C), `timeout`, `overflow`, `spawn-failed`, `signal-killed`\n- `duration=\"1.3s\"` \u2014 wall-clock runtime\n- `truncated=\"true\"` \u2014 output was capped; full output not available\n\nThe `<command>` child contains the literal command the user typed (XML-escaped). The `<output>` child contains ANSI-stripped, XML-escaped captured stdout/stderr.";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const BG_SUBAGENT_RESULT_PROMPT = "When a user message contains a `<background-subagent-result>` block, it is the completed output of a background subagent you previously dispatched with the `agent` tool (`mode: \"background\"`) or that the user backgrounded with Ctrl+B. It was delivered automatically \u2014 no join was needed. Attributes: `jobId`, `status` (`completed`/`failed`), `model`, `duration`. The `<task>` child echoes the dispatch prompt's first 80 chars; `<output>` carries the subagent's final message (XML-escaped, truncated at 16KB with a marker naming `/bgsub:join <jobId>` for the full text). Treat the output as the subagent's compressed findings \u2014 reason over it as you would a foreground `agent` result.";
|
|
5
|
+
export declare const TOOL_SYSTEM_PROMPT = "You have access to tools for working with the filesystem and running commands. Follow these conventions:\n\n- Use read_file before editing to verify the exact content you want to change.\n- Prefer edit_file over write_file for modifying existing files \u2014 write_file is for new files or complete rewrites.\n- Quote file paths that contain spaces with double quotes.\n- Do not run destructive shell commands (rm -rf, git reset --hard, etc.) unless the user explicitly asks.\n- Use glob and grep to discover files before reading individual files.\n- When bash output is very long, it may be truncated. If you need the full output, redirect to a file and read it.\n- Use absolute paths for file operations.\n- Prefer `agent` (and `skill`) for multi-file investigation, verification, parallel hypotheses, and any work that would otherwise consume large amounts of inline context. The main session is the coordinator; subagents are the investigators.\n\nWhen you see a `<command-name>` tag in the current conversation turn, the skill has ALREADY been loaded by the user typing a slash command. Do NOT re-invoke the skill tool to dispatch that same skill again. Instead, treat the `<command-message>` as the skill name and `<command-args>` as its arguments, then follow the instructions in the body block immediately following the tag. You MAY still invoke the skill tool to dispatch OTHER skills that are not the one already loaded.\n\nWhen a user message contains a `<bash-passthrough>` block, it represents a shell command the **user ran directly** in the REPL using the `!` prefix (e.g. `!ls` or `!&pnpm test`). This is distinct from the `bash` tool you invoke yourself:\n\n- `<bash-passthrough>` = human-initiated shell run, output injected into your context automatically\n- `bash` tool result = model-initiated command you explicitly called\n\nAttributes on the opening tag:\n- `mode=\"foreground\"` \u2014 user waited for the command to finish before the next prompt\n- `mode=\"background\"` \u2014 command ran detached (`!&` prefix); output arrives after it completes\n- `exit=\"N\"` \u2014 shell exit code (0 = success)\n- `reason=\"...\"` \u2014 error category when nonzero: `nonzero-exit`, `abort` (Ctrl+C), `timeout`, `overflow`, `spawn-failed`, `signal-killed`\n- `duration=\"1.3s\"` \u2014 wall-clock runtime\n- `truncated=\"true\"` \u2014 output was capped; full output not available\n\nThe `<command>` child contains the literal command the user typed (XML-escaped). The `<output>` child contains ANSI-stripped, XML-escaped captured stdout/stderr.\n\nWhen a user message contains a `<background-subagent-result>` block, it is the completed output of a background subagent you previously dispatched with the `agent` tool (`mode: \"background\"`) or that the user backgrounded with Ctrl+B. It was delivered automatically \u2014 no join was needed. Attributes: `jobId`, `status` (`completed`/`failed`), `model`, `duration`. The `<task>` child echoes the dispatch prompt's first 80 chars; `<output>` carries the subagent's final message (XML-escaped, truncated at 16KB with a marker naming `/bgsub:join <jobId>` for the full text). Treat the output as the subagent's compressed findings \u2014 reason over it as you would a foreground `agent` result.";
|
|
5
6
|
export declare const MEMORY_SYSTEM_PROMPT = "# Cross-Session Memory\n\nYou have three tools for persisting knowledge across sessions: memory_search, memory_update, and procedure_write.\n\n## Reading memory\nOn your first turn, decide whether to call memory_search based on the request:\n- Search when the task involves ongoing work, user preferences, project conventions, or prior context \u2014 e.g. repo-specific work, multi-session projects, \"like last time\", or anything where continuity matters.\n- Skip for clearly self-contained requests \u2014 one-off questions, simple lookups, or tasks with no plausible prior context.\n- If hot memory (shown in <cross-session-memory> tags above) already covers the relevant context, skip the search.\n- Search at most once per session for general context. Search again only if new information surfaces a specific topic worth querying.\n\nUse FTS5 syntax: \"exact phrase\", term1 AND term2, prefix*.\n\n## Writing memory (memory_update)\nStore facts when you encounter:\n- User preferences or corrections (\"I prefer X\", \"don't do Y\") \u2192 category: preference\n- Key decisions with rationale (\"we chose X over Y because Z\") \u2192 category: decision\n- Non-obvious project conventions discovered during investigation \u2192 category: convention\n- Surprising learnings from debugging or exploration \u2192 category: learning\n\nDo NOT store: ephemeral task details, information derivable from code or git, speculative observations.\n\n### Hot memory vs. fact archive\n- target \"fact\" \u2192 searchable SQLite archive. **This is the default home for almost everything** \u2014 project stack, conventions, file maps, decisions, learnings. It is unbounded and searchable. When in doubt, it's a fact.\n- target \"hot\" \u2192 HOT.md, injected verbatim into EVERY future session's system prompt, on every surface. Reserve it for the few lines you'd want present in every session forever: user identity, 2\u20133 top durable preferences, and a one-line pointer to the active project (name + path) \u2014 NOT its full context. Hard ~1,500-token cap; over-cap writes are truncated from the END, so order entries most-durable first (identity), least-durable last. If something doesn't need to be in every prompt, it's a fact, not hot.\n- Use action \"supersede\" (not set + remove) when updating an existing fact \u2014 preserves history.\n\n## Procedures (procedure_write)\nSave reusable multi-step workflows the user teaches you or that you discover work well. Name in kebab-case. Searchable via memory_search.";
|
|
6
7
|
export declare const MEMORY_SYSTEM_PROMPT_READONLY = "# Cross-Session Memory (read-only)\n\nYou have one tool for recalling knowledge from prior sessions: memory_search. Writes (memory_update, procedure_write) are not available in this child session \u2014 only the parent can persist new memory.\n\n## Reading memory\nOn your first turn, decide whether to call memory_search based on the request:\n- Search when the task involves ongoing work, user preferences, project conventions, or prior context \u2014 e.g. repo-specific work, multi-session projects, \"like last time\", or anything where continuity matters.\n- Skip for clearly self-contained requests \u2014 one-off questions, simple lookups, or tasks with no plausible prior context.\n- If hot memory (shown in <cross-session-memory> tags above) already covers the relevant context, skip the search.\n- Search at most once per session for general context. Search again only if new information surfaces a specific topic worth querying.\n\nUse FTS5 syntax: \"exact phrase\", term1 AND term2, prefix*.";
|
|
8
|
+
export declare function resolveToolSystemPrompt(isSkillDispatch: boolean | undefined): string;
|
|
9
|
+
export declare function resolveMemorySystemPrompt(readOnly: boolean | undefined): string;
|
|
@@ -191,6 +191,16 @@ export declare const BackgroundAgentJoinedPayloadSchema: z.ZodObject<{
|
|
|
191
191
|
cancelled: "cancelled";
|
|
192
192
|
}>;
|
|
193
193
|
}, z.core.$strip>;
|
|
194
|
+
export declare const BackgroundAgentDeliveredPayloadSchema: z.ZodObject<{
|
|
195
|
+
transition: z.ZodLiteral<"delivered">;
|
|
196
|
+
jobId: z.ZodString;
|
|
197
|
+
subagentId: z.ZodString;
|
|
198
|
+
jobStatus: z.ZodEnum<{
|
|
199
|
+
completed: "completed";
|
|
200
|
+
failed: "failed";
|
|
201
|
+
cancelled: "cancelled";
|
|
202
|
+
}>;
|
|
203
|
+
}, z.core.$strip>;
|
|
194
204
|
export declare const BackgroundAgentPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
195
205
|
transition: z.ZodLiteral<"started">;
|
|
196
206
|
jobId: z.ZodString;
|
|
@@ -227,6 +237,15 @@ export declare const BackgroundAgentPayloadSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
227
237
|
failed: "failed";
|
|
228
238
|
cancelled: "cancelled";
|
|
229
239
|
}>;
|
|
240
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
241
|
+
transition: z.ZodLiteral<"delivered">;
|
|
242
|
+
jobId: z.ZodString;
|
|
243
|
+
subagentId: z.ZodString;
|
|
244
|
+
jobStatus: z.ZodEnum<{
|
|
245
|
+
completed: "completed";
|
|
246
|
+
failed: "failed";
|
|
247
|
+
cancelled: "cancelled";
|
|
248
|
+
}>;
|
|
230
249
|
}, z.core.$strip>], "transition">;
|
|
231
250
|
export declare const BudgetPayloadSchema: z.ZodObject<{
|
|
232
251
|
kind: z.ZodLiteral<"monetary">;
|
|
@@ -597,6 +616,15 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
597
616
|
failed: "failed";
|
|
598
617
|
cancelled: "cancelled";
|
|
599
618
|
}>;
|
|
619
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
620
|
+
transition: z.ZodLiteral<"delivered">;
|
|
621
|
+
jobId: z.ZodString;
|
|
622
|
+
subagentId: z.ZodString;
|
|
623
|
+
jobStatus: z.ZodEnum<{
|
|
624
|
+
completed: "completed";
|
|
625
|
+
failed: "failed";
|
|
626
|
+
cancelled: "cancelled";
|
|
627
|
+
}>;
|
|
600
628
|
}, z.core.$strip>], "transition">;
|
|
601
629
|
}, z.core.$strip>, z.ZodObject<{
|
|
602
630
|
kind: z.ZodLiteral<"budget">;
|
|
@@ -881,6 +909,15 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
881
909
|
failed: "failed";
|
|
882
910
|
cancelled: "cancelled";
|
|
883
911
|
}>;
|
|
912
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
913
|
+
transition: z.ZodLiteral<"delivered">;
|
|
914
|
+
jobId: z.ZodString;
|
|
915
|
+
subagentId: z.ZodString;
|
|
916
|
+
jobStatus: z.ZodEnum<{
|
|
917
|
+
completed: "completed";
|
|
918
|
+
failed: "failed";
|
|
919
|
+
cancelled: "cancelled";
|
|
920
|
+
}>;
|
|
884
921
|
}, z.core.$strip>], "transition">;
|
|
885
922
|
}, z.core.$strip>, z.ZodObject<{
|
|
886
923
|
ts: z.ZodString;
|
|
@@ -95,7 +95,13 @@ export interface BackgroundAgentJoinedPayload {
|
|
|
95
95
|
subagentId: string;
|
|
96
96
|
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
97
97
|
}
|
|
98
|
-
export
|
|
98
|
+
export interface BackgroundAgentDeliveredPayload {
|
|
99
|
+
transition: 'delivered';
|
|
100
|
+
jobId: string;
|
|
101
|
+
subagentId: string;
|
|
102
|
+
jobStatus: 'completed' | 'failed' | 'cancelled';
|
|
103
|
+
}
|
|
104
|
+
export type BackgroundAgentPayload = BackgroundAgentStartedPayload | BackgroundAgentCompletedPayload | BackgroundAgentFailedPayload | BackgroundAgentCancelledPayload | BackgroundAgentJoinedPayload | BackgroundAgentDeliveredPayload;
|
|
99
105
|
export interface BudgetPayload {
|
|
100
106
|
kind: 'monetary';
|
|
101
107
|
runningCostUsd: number;
|
|
@@ -2,6 +2,7 @@ import { pushIfConfigured } from '../../../telegram/push.js';
|
|
|
2
2
|
import type { ToolEvent } from '../../slash/types.js';
|
|
3
3
|
import type { TerminalState } from './terminal-state.js';
|
|
4
4
|
export declare const MAX_PUSHES_PER_SESSION = 20;
|
|
5
|
+
export declare const MAX_RAW_BODY_FALLBACK_CHARS = 500;
|
|
5
6
|
export declare const DONE_EVIDENCE_TOOLS: ReadonlySet<string>;
|
|
6
7
|
export declare function doneHasCorroboratingEvidence(toolEvents: readonly ToolEvent[]): boolean;
|
|
7
8
|
export declare function formatTerminalStateForTelegram(state: TerminalState, opts?: {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BackgroundAgentRegistry, BackgroundJob } from '../../../agent/background-registry.js';
|
|
2
|
+
export declare const MAX_INJECTION_BYTES: number;
|
|
3
|
+
export interface PendingBgAgentNotification {
|
|
4
|
+
job: BackgroundJob;
|
|
5
|
+
}
|
|
6
|
+
export declare function buildBgResultInjection(job: BackgroundJob): string;
|
|
7
|
+
export declare function isAutoDeliverEnabled(raw: string | undefined): boolean;
|
|
8
|
+
export declare class BgResultNotifier {
|
|
9
|
+
private readonly registry;
|
|
10
|
+
private pendingInjections;
|
|
11
|
+
private pendingNotifications;
|
|
12
|
+
private readonly onSettled;
|
|
13
|
+
constructor(registry: BackgroundAgentRegistry);
|
|
14
|
+
drainInjections(): string;
|
|
15
|
+
drainNotifications(): readonly PendingBgAgentNotification[];
|
|
16
|
+
reset(): void;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
@@ -4,6 +4,7 @@ import { createVerdictLedger } from './verdict-ledger.js';
|
|
|
4
4
|
import { BackgroundStatusBar } from '../../background-status-bar.js';
|
|
5
5
|
import { LoopStageBar } from './loop-stage.js';
|
|
6
6
|
import { ShellPassthrough } from './shell-passthrough.js';
|
|
7
|
+
import { BgResultNotifier } from './bg-result-notifier.js';
|
|
7
8
|
import type { TurnState } from './repl-loop-shared.js';
|
|
8
9
|
export interface FooterSubsystems {
|
|
9
10
|
contextPane: ReturnType<typeof createContextPane>;
|
|
@@ -11,5 +12,6 @@ export interface FooterSubsystems {
|
|
|
11
12
|
loopStageBar: LoopStageBar;
|
|
12
13
|
verdictLedger: ReturnType<typeof createVerdictLedger>;
|
|
13
14
|
shellPassthrough: ShellPassthrough;
|
|
15
|
+
bgResultNotifier: BgResultNotifier;
|
|
14
16
|
}
|
|
15
17
|
export declare function setupFooterSubsystems(ctx: InteractiveCtx, turnState: TurnState): FooterSubsystems;
|
|
@@ -58,6 +58,7 @@ export interface InteractiveCtx {
|
|
|
58
58
|
getInFlight?: () => boolean;
|
|
59
59
|
requestResume?: (target: ResolvedResumeTarget) => Promise<ResumeSwapResult>;
|
|
60
60
|
clearVerdictLedger?: () => void;
|
|
61
|
+
clearBgResultBuffer?: () => void;
|
|
61
62
|
preArmAnchorRow?: number;
|
|
62
63
|
inputSurfaceRef?: {
|
|
63
64
|
current: import('../../input/input-surface.js').InputSurface | null;
|