agent-afk 5.275.2 → 5.275.4

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.
@@ -1,3 +1,4 @@
1
1
  export declare const PREVIEW_BUDGET = 2000;
2
+ export declare const LABEL_OVERHEAD = 32;
2
3
  export declare function previewInput(s: string, budget?: number): string;
3
4
  export declare function buildInputPreview(input: string, budget?: number): string;
@@ -3,4 +3,5 @@ export { JournalSync, type SyncOptions } from './sync.js';
3
3
  export { JournalProvenance } from './provenance.js';
4
4
  export { createMessageJournal, isMessageJournalDisabled, type CreateMessageJournalOptions } from './writer.js';
5
5
  export { findToolResult, foldJournal, hydrateMessages, journalExists, listSubagentJournals, loadJournalFold, loadJournalMessages, readJournalRecords, type FoldResult, type JournalLocator, } from './reader.js';
6
+ export { findToolResultAsync } from './reader.async.js';
6
7
  export { forkJournal } from './fork.js';
@@ -0,0 +1,9 @@
1
+ import type { JournalBlock } from './types.js';
2
+ type ToolResultBlock = Extract<JournalBlock, {
3
+ type: 'tool_result';
4
+ }>;
5
+ export declare function findToolResultAsync(sessionId: string, toolUseId: string): Promise<{
6
+ block: ToolResultBlock;
7
+ subagentId?: string;
8
+ } | null>;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ProviderModelInfo } from '../../../provider.js';
2
+ export declare const OPENAI_COMPATIBLE_MODELS: ProviderModelInfo[];
@@ -0,0 +1,32 @@
1
+ import OpenAI from 'openai';
2
+ import type { CompactionTrigger } from '../../../../agent/trace/types.js';
3
+ import type { ProviderCompactResult, ProviderUsage } from '../../../provider.js';
4
+ import type { OpenAIJournalWiring } from './journal-wiring.js';
5
+ import type { OpenAIMessage } from '../messages.js';
6
+ import type { WireMode } from '../responses-config.js';
7
+ import type { AbortCoordinator } from '../../shared/abort-coordinator.js';
8
+ import type { TraceSink } from '../../../trace/index.js';
9
+ export interface CompactHandlerContext {
10
+ readonly client: OpenAI;
11
+ readonly wireMode: WireMode;
12
+ readonly abort: AbortCoordinator;
13
+ readonly priorTurns: OpenAIMessage[];
14
+ readonly journal: OpenAIJournalWiring;
15
+ readonly traceWriter: TraceSink | undefined;
16
+ readonly opts: {
17
+ readonly auth: {
18
+ readonly apiKey: string | null;
19
+ readonly source: string;
20
+ };
21
+ readonly config: {
22
+ readonly subagentId?: string;
23
+ };
24
+ };
25
+ readonly currentModel: string;
26
+ readonly closed: boolean;
27
+ lastUsage: ProviderUsage | null;
28
+ readonly responsesCompactionUnavailable: boolean;
29
+ markResponsesCompactionUnavailable(): void;
30
+ }
31
+ export declare function runSummarizeViaResponses(ctx: CompactHandlerContext, transcript: string, signal: AbortSignal, model: string): Promise<string>;
32
+ export declare function runCompactHistory(ctx: CompactHandlerContext, trigger: CompactionTrigger): Promise<ProviderCompactResult>;
@@ -0,0 +1,22 @@
1
+ import type { AgentConfig } from '../../../types/config-types.js';
2
+ import type { TraceSink } from '../../../trace/index.js';
3
+ import type { ProviderUserTurn } from '../../../provider.js';
4
+ import type { ToolDispatcher } from '../../anthropic-direct/tool-dispatcher.js';
5
+ import type { OpenAIAuthResolution } from '../auth.js';
6
+ import type { FastTierOptions } from './fast-tier-session.js';
7
+ export interface OpenAICompatibleQueryOptions {
8
+ auth: OpenAIAuthResolution;
9
+ baseURL?: string;
10
+ defaultHeaders?: Record<string, string>;
11
+ model: string;
12
+ synthesizedSessionId: string;
13
+ promptStream: AsyncIterable<ProviderUserTurn>;
14
+ config: AgentConfig;
15
+ toolDispatcher?: ToolDispatcher;
16
+ onPermissionMode?: (mode: string) => void;
17
+ onCwdChange?: (cwd: string) => void;
18
+ mcpManager?: import('../../../mcp/index.js').McpManager;
19
+ useResponsesApi?: boolean;
20
+ traceWriter?: TraceSink;
21
+ fastTier?: FastTierOptions;
22
+ }
@@ -0,0 +1,25 @@
1
+ import type { ProviderEvent, ProviderUserTurn } from '../../../provider.js';
2
+ import { type IterationContext, type FinishTurnContext } from './turn-iteration.js';
3
+ import type { AbortCoordinator } from '../../shared/abort-coordinator.js';
4
+ import type { ToolDispatcher } from '../../anthropic-direct/tool-dispatcher.js';
5
+ import type { TraceSink } from '../../../trace/index.js';
6
+ import type { OpenAIMessage } from '../messages.js';
7
+ import type { OpenAIJournalWiring } from './journal-wiring.js';
8
+ import type { AgentConfig } from '../../../types/config-types.js';
9
+ import type { OpenAIAuthResolution } from '../auth.js';
10
+ export interface TurnDriverContext extends IterationContext, FinishTurnContext {
11
+ readonly abort: AbortCoordinator;
12
+ readonly toolDispatcher: ToolDispatcher | undefined;
13
+ readonly traceWriter: TraceSink | undefined;
14
+ readonly opts: {
15
+ readonly config: AgentConfig;
16
+ readonly auth: OpenAIAuthResolution;
17
+ };
18
+ readonly journal: OpenAIJournalWiring;
19
+ readonly priorTurns: OpenAIMessage[];
20
+ readonly initSessionId: string;
21
+ readonly currentModel: string;
22
+ readonly currentPermissionMode: string;
23
+ readonly closed: boolean;
24
+ }
25
+ export declare function runTurnInner(ctx: TurnDriverContext, content: ProviderUserTurn['content'], controller: AbortController, turnStartTime: number, taskId: string): AsyncGenerator<ProviderEvent>;
@@ -0,0 +1,40 @@
1
+ import OpenAI from 'openai';
2
+ import type { AgentConfig } from '../../../types/config-types.js';
3
+ import type { ProviderEvent, ProviderUsage } from '../../../provider.js';
4
+ import { type OpenAIMessage } from '../messages.js';
5
+ import { type WireMode } from '../responses-config.js';
6
+ import { TOOL_USE_LOOP_CAPPED } from '../../shared/tool-loop-cap.js';
7
+ import { SOFT_DEADLINE_WIND_DOWN } from '../../shared/soft-deadline.js';
8
+ import type { OpenAIFunctionTool } from '../loop.js';
9
+ import { type IterationResult } from './stream-drive.js';
10
+ import type { FastTierSession } from './fast-tier-session.js';
11
+ import type { OpenAIJournalWiring } from './journal-wiring.js';
12
+ import type { TraceSink } from '../../../trace/index.js';
13
+ import type { OpenAIAuthResolution } from '../auth.js';
14
+ export interface IterationContext {
15
+ readonly currentModel: string;
16
+ readonly currentPermissionMode: string;
17
+ readonly closed: boolean;
18
+ readonly initSessionId: string;
19
+ readonly wireMode: WireMode;
20
+ readonly useOpenAIPricing: boolean;
21
+ readonly opts: {
22
+ readonly config: AgentConfig;
23
+ readonly auth: OpenAIAuthResolution;
24
+ };
25
+ readonly client: OpenAI;
26
+ readonly traceWriter: TraceSink | undefined;
27
+ readonly fastTier: FastTierSession;
28
+ readonly journal: OpenAIJournalWiring;
29
+ readonly priorTurns: OpenAIMessage[];
30
+ activeOpenAITools(): OpenAIFunctionTool[] | undefined;
31
+ }
32
+ export interface FinishTurnContext {
33
+ readonly initSessionId: string;
34
+ readonly journal: OpenAIJournalWiring;
35
+ readonly priorTurns: OpenAIMessage[];
36
+ lastUsage: ProviderUsage | null;
37
+ }
38
+ export declare function finishTurn(ctx: FinishTurnContext, accumulatedUsage: ProviderUsage, turnStartTime: number): Generator<ProviderEvent>;
39
+ export declare function pushUserTurn(ctx: IterationContext, content: import('../../../provider.js').ProviderUserTurn['content']): void;
40
+ export declare function runIteration(ctx: IterationContext, controller: AbortController, vision: boolean, windDown: typeof TOOL_USE_LOOP_CAPPED | typeof SOFT_DEADLINE_WIND_DOWN | null): AsyncGenerator<ProviderEvent, IterationResult | null>;
@@ -1,65 +1,58 @@
1
+ import OpenAI from 'openai';
1
2
  import type { AgentConfig } from '../../types/config-types.js';
2
3
  import type { TraceSink } from '../../trace/index.js';
3
- import type { ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderContextUsage, ProviderRewindResult, ProviderModelInfo, ProviderCommandInfo, ProviderAgentInfo, ProviderMcpServerStatus, ProviderAccountInfo, ProviderCompactResult } from '../../provider.js';
4
- import { type OpenAIAuthResolution, type AuthResolverDeps } from './auth.js';
4
+ import type { ProviderQuery, ProviderEvent, ProviderUserTurn, ProviderContextUsage, ProviderRewindResult, ProviderModelInfo, ProviderCommandInfo, ProviderAgentInfo, ProviderMcpServerStatus, ProviderAccountInfo, ProviderUsage, ProviderCompactResult } from '../../provider.js';
5
+ import { type AuthResolverDeps } from './auth.js';
6
+ import { type OpenAIMessage } from './messages.js';
7
+ import { type OpenAIFunctionTool } from './loop.js';
8
+ import { type WireMode } from './responses-config.js';
5
9
  import type { ToolDispatcher } from '../anthropic-direct/tool-dispatcher.js';
10
+ import { AbortCoordinator } from '../shared/abort-coordinator.js';
6
11
  import { OpenAIJournalWiring } from './query/journal-wiring.js';
7
12
  import { resolveReasoningEffort } from './query/model-params.js';
8
- import { type FastTierOptions } from './query/fast-tier-session.js';
13
+ import { FastTierSession, type FastTierOptions } from './query/fast-tier-session.js';
14
+ import { type TurnDriverContext } from './query/turn-driver.js';
15
+ import { type CompactHandlerContext } from './query/compact-handler.js';
16
+ import type { OpenAICompatibleQueryOptions } from './query/query-options.js';
17
+ export type { OpenAICompatibleQueryOptions } from './query/query-options.js';
9
18
  export { __setRetryBaseDelay } from './query/retry.js';
10
19
  export { __setOpenAIClientFactory } from './query/client.js';
11
20
  export type { OpenAIClientFactory } from './query/client.js';
12
21
  export { isOSeriesModel, mapEffortForOpenAI } from './query/model-params.js';
13
22
  export { resolveReasoningEffort };
14
- export interface OpenAICompatibleQueryOptions {
15
- auth: OpenAIAuthResolution;
16
- baseURL?: string;
17
- defaultHeaders?: Record<string, string>;
18
- model: string;
19
- synthesizedSessionId: string;
20
- promptStream: AsyncIterable<ProviderUserTurn>;
21
- config: AgentConfig;
22
- toolDispatcher?: ToolDispatcher;
23
- onPermissionMode?: (mode: string) => void;
24
- onCwdChange?: (cwd: string) => void;
25
- mcpManager?: import('../../mcp/index.js').McpManager;
26
- useResponsesApi?: boolean;
27
- traceWriter?: TraceSink;
28
- fastTier?: FastTierOptions;
29
- }
30
- export declare class OpenAICompatibleQuery implements ProviderQuery {
31
- private readonly client;
32
- private readonly opts;
33
- private readonly initSessionId;
34
- private readonly toolDispatcher;
23
+ export declare class OpenAICompatibleQuery implements ProviderQuery, TurnDriverContext, CompactHandlerContext {
24
+ readonly client: OpenAI;
25
+ readonly opts: OpenAICompatibleQueryOptions;
26
+ readonly initSessionId: string;
27
+ readonly toolDispatcher: ToolDispatcher | undefined;
35
28
  private readonly onPermissionMode?;
36
29
  private readonly onCwdChange?;
37
30
  private readonly openAITools;
38
- private readonly wireMode;
39
- private readonly useOpenAIPricing;
40
- private readonly traceWriter;
41
- private readonly fastTier;
42
- private priorTurns;
43
- private readonly journal;
44
- private currentModel;
45
- private currentPermissionMode;
46
- private responsesCompactionUnavailable;
47
- private readonly abort;
48
- private closed;
49
- private lastUsage;
31
+ readonly wireMode: WireMode;
32
+ readonly useOpenAIPricing: boolean;
33
+ readonly traceWriter: TraceSink | undefined;
34
+ readonly fastTier: FastTierSession;
35
+ readonly priorTurns: OpenAIMessage[];
36
+ readonly journal: OpenAIJournalWiring;
37
+ private _currentModel;
38
+ private _currentPermissionMode;
39
+ get currentModel(): string;
40
+ get currentPermissionMode(): string;
41
+ private _responsesCompactionUnavailable;
42
+ get responsesCompactionUnavailable(): boolean;
43
+ markResponsesCompactionUnavailable(): void;
44
+ readonly abort: AbortCoordinator;
45
+ private _closed;
46
+ get closed(): boolean;
47
+ lastUsage: ProviderUsage | null;
50
48
  private readonly autoCompactThreshold;
51
49
  constructor(opts: OpenAICompatibleQueryOptions);
52
- private activeOpenAITools;
50
+ activeOpenAITools(): OpenAIFunctionTool[] | undefined;
53
51
  [Symbol.asyncIterator](): AsyncIterator<ProviderEvent>;
54
52
  private runTurn;
55
- private _runTurnInner;
56
- private finishTurn;
57
- private runIteration;
58
- private dispatchAndAppend;
59
53
  interrupt(reason?: import('../../abort-reason.js').ProviderAbortReason): Promise<void>;
60
54
  compact(): Promise<ProviderCompactResult>;
61
55
  private compactHistory;
62
- private summarizeViaResponses;
63
56
  setModel(model?: string): Promise<void>;
64
57
  setPermissionMode(mode: string): Promise<void>;
65
58
  setCwd(cwd: string): void;
@@ -0,0 +1,2 @@
1
+ export declare const PREVIEW_INPUT_CAP = 2048;
2
+ export declare function capPreviewInput(text: string): string;