agent-afk 5.270.1 → 5.270.3

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 CHANGED
@@ -30,7 +30,7 @@ afk chat "hello" # first real conversation
30
30
 
31
31
  That's it. You're in.
32
32
 
33
- **Using pnpm?** `pnpm add -g agent-afk` works, but pnpm 10 blocks build scripts by default and silently skips `postinstall` (see [#2199](https://github.com/griffinwork40/agent-afk/issues/2199)). Run `pnpm approve-builds -g` after install to approve the hook, or use `npm install -g agent-afk` instead. If a launchd/systemd-supervised `afk daemon` is already running and pnpm skipped the hook, restart it manually with `afk service restart daemon`.
33
+ **Using pnpm?** `pnpm add -g agent-afk` works, but pnpm 10 blocks build scripts by default and skips `postinstall` (with an easy-to-miss warning — see [#2199](https://github.com/griffinwork40/agent-afk/issues/2199)). Run `pnpm approve-builds -g` after install to approve the hook, or use `npm install -g agent-afk` instead. If an `afk daemon` is already running and pnpm skipped the hook, restart it manually with `afk service restart daemon` — on macOS the hook restarts the daemon automatically when it runs, but on Linux you must always run this command after an upgrade even when the hook ran.
34
34
 
35
35
  **Try without installing:** `npx agent-afk chat "hello"` runs a one-shot turn with zero global install.
36
36
 
@@ -1,5 +1,5 @@
1
1
  export declare const DEFAULT_SESSIONSTART_COOLDOWN_MS: number;
2
- export type SessionStartSkipReason = 'cooldown';
2
+ export type SessionStartSkipReason = 'cooldown' | 'overlap';
3
3
  export interface GateDecision {
4
4
  fire: boolean;
5
5
  skipReason?: SessionStartSkipReason;
@@ -52,6 +52,7 @@ export declare class CronScheduler {
52
52
  private pullPollTimer;
53
53
  private isDequeuing;
54
54
  private readonly queueDir;
55
+ private readonly inFlightTaskIds;
55
56
  constructor(options?: SchedulerOptions);
56
57
  register(task: ScheduledTask): void;
57
58
  unregister(taskId: string): void;
@@ -62,7 +63,6 @@ export declare class CronScheduler {
62
63
  startPullLoop(): void;
63
64
  private pullTick;
64
65
  private runOnce;
65
- private recordSkip;
66
66
  private spawnSession;
67
67
  private telemetryPath;
68
68
  private ensureTelemetrySink;
@@ -0,0 +1,5 @@
1
+ import type { ScheduledTask } from './triggers.js';
2
+ import type { GateDecision } from './gates.js';
3
+ import type { TelemetryRecord, TelemetryTrigger } from './scheduler.js';
4
+ export declare function makeOverlapSkipRecord(task: ScheduledTask, trigger: TelemetryTrigger, nowMs: number): TelemetryRecord;
5
+ export declare function makeSessionStartSkipRecord(task: ScheduledTask, decision: GateDecision, nowMs: number): TelemetryRecord;
@@ -1,7 +1,10 @@
1
- import { type SessionFacet, type StoredSessionInput } from './schema.js';
1
+ import { type SessionFacet, type StoredSessionInput, type SubagentToolSummary, type ToolEventInput } from './schema.js';
2
2
  export interface DeriveOptions {
3
3
  sourceSessionPath?: string;
4
4
  sourceSessionMtimeMs?: number;
5
5
  derivedAt?: Date;
6
+ journalEvents?: ToolEventInput[];
7
+ subagentBreakdown?: SubagentToolSummary[];
6
8
  }
9
+ export declare function dedupeToolEvents(events: ToolEventInput[]): ToolEventInput[];
7
10
  export declare function deriveSessionFacet(session: StoredSessionInput, options?: DeriveOptions): SessionFacet;
@@ -1,4 +1,4 @@
1
- export { FACET_VERSION, SessionFacetSchema, StoredSessionInputSchema, FacetOutcomeSchema, SubagentPersistenceSchema, SubagentInvocationSchema, WorldChangesSchema, TokenBreakdownSchema, ParallelDispatchStatsSchema, YieldTrackingSchema, type SessionFacet, type StoredSessionInput, type ToolEventInput, type FacetOutcome, type SubagentInvocation, type WorldChanges, type TokenBreakdown, type ParallelDispatchStats, type YieldTracking, } from './schema.js';
1
+ export { FACET_VERSION, SessionFacetSchema, StoredSessionInputSchema, FacetOutcomeSchema, SubagentPersistenceSchema, SubagentInvocationSchema, SubagentToolSummarySchema, WorldChangesSchema, TokenBreakdownSchema, ParallelDispatchStatsSchema, YieldTrackingSchema, type SessionFacet, type StoredSessionInput, type ToolEventInput, type FacetOutcome, type SubagentInvocation, type SubagentToolSummary, type WorldChanges, type TokenBreakdown, type ParallelDispatchStats, type YieldTracking, } from './schema.js';
2
2
  export { deriveSessionFacet, type DeriveOptions } from './derive.js';
3
3
  export { getOrDeriveFacet, loadStoredSession, listSessionIds, type FacetStoreOptions, } from './store.js';
4
4
  export { createFacetSessionEndHook } from './session-end-hook.js';
@@ -0,0 +1,7 @@
1
+ import type { SubagentToolSummary, ToolEventInput } from './schema.js';
2
+ import type { JournalRecord } from '../journal/types.js';
3
+ export interface JournalAdapterOptions {
4
+ resultTextCap?: number;
5
+ }
6
+ export declare function journalRecordsToToolEvents(records: readonly JournalRecord[], options?: JournalAdapterOptions): ToolEventInput[];
7
+ export declare function summarizeSubagentJournal(subagentId: string, records: readonly JournalRecord[]): SubagentToolSummary;
@@ -0,0 +1,4 @@
1
+ import type { ParallelDispatchStats, ToolEventInput } from './schema.js';
2
+ export declare function computeParallelDispatch(turns: Array<{
3
+ toolEvents?: ToolEventInput[];
4
+ }>): ParallelDispatchStats;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const FACET_VERSION = 5;
2
+ export declare const FACET_VERSION = 6;
3
3
  export declare const ToolEventInputSchema: z.ZodObject<{
4
4
  toolName: z.ZodString;
5
5
  toolUseId: z.ZodOptional<z.ZodString>;
@@ -101,6 +101,13 @@ export declare const YieldTrackingSchema: z.ZodObject<{
101
101
  pr_merged: z.ZodNullable<z.ZodBoolean>;
102
102
  }, z.core.$strip>;
103
103
  export type YieldTracking = z.infer<typeof YieldTrackingSchema>;
104
+ export declare const SubagentToolSummarySchema: z.ZodObject<{
105
+ subagent_id: z.ZodString;
106
+ tool_calls: z.ZodNumber;
107
+ tool_errors: z.ZodNumber;
108
+ tool_counts: z.ZodRecord<z.ZodString, z.ZodNumber>;
109
+ }, z.core.$strip>;
110
+ export type SubagentToolSummary = z.infer<typeof SubagentToolSummarySchema>;
104
111
  export declare const SessionFacetSchema: z.ZodObject<{
105
112
  facet_version: z.ZodNumber;
106
113
  session_id: z.ZodString;
@@ -178,6 +185,12 @@ export declare const SessionFacetSchema: z.ZodObject<{
178
185
  }, z.core.$strip>;
179
186
  decisions: z.ZodArray<z.ZodString>;
180
187
  evidence_pointers: z.ZodArray<z.ZodString>;
188
+ subagent_breakdown: z.ZodOptional<z.ZodArray<z.ZodObject<{
189
+ subagent_id: z.ZodString;
190
+ tool_calls: z.ZodNumber;
191
+ tool_errors: z.ZodNumber;
192
+ tool_counts: z.ZodRecord<z.ZodString, z.ZodNumber>;
193
+ }, z.core.$strip>>>;
181
194
  }, z.core.$loose>;
182
195
  export type SessionFacet = z.infer<typeof SessionFacetSchema>;
183
196
  export type SubagentInvocation = z.infer<typeof SubagentInvocationSchema>;
@@ -16,6 +16,15 @@ export interface OpenAIMessage {
16
16
  content: string | OpenAIContentPart[];
17
17
  tool_call_id?: string;
18
18
  reasoning_content?: string;
19
+ tool_calls?: OpenAIToolCall[];
20
+ }
21
+ export interface OpenAIToolCall {
22
+ id: string;
23
+ type: 'function' | string;
24
+ function: {
25
+ name: string;
26
+ arguments: string;
27
+ };
19
28
  }
20
29
  export declare function imageOmittedNotice(model: string | undefined, count: number): string;
21
30
  export declare function flattenUserContent(content: ProviderUserTurn['content'], model?: string): string;
@@ -0,0 +1,2 @@
1
+ import type { OpenAIMessage } from '../messages.js';
2
+ export declare function repairOrphanToolCalls(messages: OpenAIMessage[]): OpenAIMessage[];