agent-afk 5.326.2 → 5.327.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 (38) hide show
  1. package/dist/agent/daemon/handoff-wiring.d.ts +1 -0
  2. package/dist/agent/dag-subagent.d.ts +1 -0
  3. package/dist/agent/journal/types.d.ts +8 -1
  4. package/dist/agent/outcomes/schema.d.ts +1 -1
  5. package/dist/agent/provider.d.ts +6 -0
  6. package/dist/agent/providers/anthropic-direct/provider-runtime.d.ts +2 -1
  7. package/dist/agent/providers/openai-compatible/complete-wire.d.ts +2 -0
  8. package/dist/agent/providers/openai-compatible/index.d.ts +2 -1
  9. package/dist/agent/providers/shared/model-rejected-error.d.ts +12 -0
  10. package/dist/agent/providers/xai/index.d.ts +2 -1
  11. package/dist/agent/subagent/fork-model-fallback.d.ts +15 -0
  12. package/dist/agent/subagent/fork-types.d.ts +4 -0
  13. package/dist/agent/subagent/handle.d.ts +3 -1
  14. package/dist/agent/subagent/handle.model-fallback.d.ts +14 -0
  15. package/dist/agent/subagent/resolve-child-model.d.ts +11 -0
  16. package/dist/agent/tools/skill-executor/fork-dispatch.d.ts +2 -0
  17. package/dist/agent/tools/subagent/child-config.d.ts +4 -0
  18. package/dist/agent/tools/subagent/child-config.helpers.d.ts +4 -0
  19. package/dist/agent/tools/subagent/root-validation.d.ts +8 -0
  20. package/dist/agent/tools/subagent-executor.execute-once.helpers.d.ts +9 -2
  21. package/dist/agent/trace/events.d.ts +2 -0
  22. package/dist/agent/trace/events.session-phase.d.ts +2 -0
  23. package/dist/agent/trace/types.session-phase.d.ts +1 -1
  24. package/dist/cli/commands/interactive/surface-setup.suggest-record.d.ts +3 -0
  25. package/dist/cli/input/suggest-prompt-state.d.ts +2 -1
  26. package/dist/cli/input/suggest-prompt.d.ts +2 -2
  27. package/dist/cli/input/suggest-reply.d.ts +10 -0
  28. package/dist/cli/input/suggest-tier2.d.ts +3 -1
  29. package/dist/cli/input/suggest-types.d.ts +7 -2
  30. package/dist/cli/input/suggest.d.ts +1 -1
  31. package/dist/cli/slash/commands/handoffs.d.ts +4 -0
  32. package/dist/cli/terminal-compositor.ghost.record.d.ts +5 -0
  33. package/dist/cli.mjs +489 -485
  34. package/dist/index.mjs +224 -222
  35. package/dist/skills/mint/_phases/model-fallback.d.ts +3 -0
  36. package/dist/telegram.mjs +245 -243
  37. package/dist/web-server/routes.handoffs.d.ts +2 -1
  38. package/package.json +1 -1
@@ -17,5 +17,6 @@ export interface RecoveryResult {
17
17
  expired: number;
18
18
  }
19
19
  export declare function recoverPendingHandoffs(handoffsDir?: string, queueDir?: string, bot?: Telegraf): Promise<RecoveryResult>;
20
+ export declare const MAX_ANSWER_BYTES: number;
20
21
  export declare function answerHandoff(taskId: string, answer: unknown, source: string, handoffsDir?: string, responderIdentity?: string): Promise<boolean>;
21
22
  export declare function cleanupHandoff(taskId: string, handoffsDir?: string): Promise<void>;
@@ -27,6 +27,7 @@ export interface SubagentDAGNode {
27
27
  maxToolUseIterations?: number;
28
28
  maxTurns?: number;
29
29
  provider?: ModelProvider;
30
+ modelFallback?: import('./subagent/fork-types.js').ForkSubagentOptions['modelFallback'];
30
31
  depth?: number;
31
32
  maxDepth?: number;
32
33
  resolvedAttachments?: ImageBlockAttachment[];
@@ -83,7 +83,14 @@ export interface JournalAdoption {
83
83
  readonly count: number;
84
84
  }
85
85
  export type JournalTruncateReason = 'resync' | 'compact' | 'rewind' | 'clear' | 'repair' | 'provider_switch';
86
- export type JournalMarkLabel = 'compact' | 'rewind' | 'clear' | 'resume' | 'fork' | 'model_switch';
86
+ export type JournalMarkLabel = 'compact' | 'rewind' | 'clear' | 'resume' | 'fork' | 'model_switch' | 'suggestion';
87
+ export type JournalSuggestionDetail = {
88
+ event: 'generated' | 'accepted' | 'word_accepted' | 'dismissed';
89
+ source: 'completion' | 'prompt';
90
+ text: string;
91
+ buffer?: string;
92
+ model?: string;
93
+ };
87
94
  interface RecordBase {
88
95
  v: typeof JOURNAL_VERSION;
89
96
  ts: number;
@@ -57,8 +57,8 @@ export declare const VerifiedOutcomeSchema: z.ZodObject<{
57
57
  blocked: "blocked";
58
58
  done: "done";
59
59
  none: "none";
60
- asking: "asking";
61
60
  interrupted: "interrupted";
61
+ asking: "asking";
62
62
  }>;
63
63
  artifacts: z.ZodObject<{
64
64
  commits: z.ZodArray<z.ZodString>;
@@ -2,6 +2,7 @@ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
2
2
  import type { AgentConfig } from './types/config-types.js';
3
3
  import type { ToolFailureClass } from './trace/types.js';
4
4
  import type { UsageLimitProvider } from '../utils/errors.js';
5
+ import type { OneShotStopReason } from './providers/anthropic-direct/oneshot.js';
5
6
  export interface ProviderSessionInfo {
6
7
  sessionId: string;
7
8
  model?: string;
@@ -313,10 +314,15 @@ export interface ProviderCompleteArgs {
313
314
  apiKey?: string;
314
315
  baseUrl?: string;
315
316
  }
317
+ export interface ProviderCompleteResult {
318
+ text: string;
319
+ stopReason: OneShotStopReason;
320
+ }
316
321
  export interface ModelProvider {
317
322
  readonly name: string;
318
323
  query(args: ProviderQueryArgs): ProviderQuery;
319
324
  complete?(args: ProviderCompleteArgs): Promise<string>;
325
+ completeWithStop?(args: ProviderCompleteArgs): Promise<ProviderCompleteResult>;
320
326
  close?(): void | Promise<void>;
321
327
  grantsTool?(toolName: string): boolean;
322
328
  }
@@ -1,4 +1,4 @@
1
- import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs } from '../../provider.js';
1
+ import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs, ProviderCompleteResult } from '../../provider.js';
2
2
  export { resolveEffort, resolveMaxTokens, resolveThinkingParam } from './resolve-params.js';
3
3
  import { type AnthropicDirectProviderOptions } from './provider-options.js';
4
4
  export { __setAnthropicClientFactory, type AnthropicClientFactory, type AnthropicDirectProviderOptions, } from './provider-options.js';
@@ -43,6 +43,7 @@ export declare class AnthropicDirectProvider implements ModelProvider {
43
43
  grantsTool(toolName: string): boolean;
44
44
  close(): void;
45
45
  complete(args: ProviderCompleteArgs): Promise<string>;
46
+ completeWithStop(args: ProviderCompleteArgs): Promise<ProviderCompleteResult>;
46
47
  addReadRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
47
48
  addWriteRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
48
49
  revokeRoot(absPath: string, source?: 'slash' | 'tool', sessionId?: string): void;
@@ -1,6 +1,7 @@
1
1
  import OpenAI from 'openai';
2
2
  import { type AuthResolverDeps } from './auth.js';
3
3
  import { type OpenAIOneShotInput } from './oneshot.js';
4
+ import type { ProviderCompleteResult } from '../../provider.js';
4
5
  export type { OpenAIOneShotInput } from './oneshot.js';
5
6
  export interface CompleteWireClientOptions {
6
7
  apiKey: string;
@@ -11,3 +12,4 @@ export interface CompleteWireClientOptions {
11
12
  }
12
13
  export type CompleteWireClientFactory = (opts: CompleteWireClientOptions) => OpenAI;
13
14
  export declare function completeWithWire(input: OpenAIOneShotInput, clientFactory?: CompleteWireClientFactory, authDeps?: AuthResolverDeps): Promise<string>;
15
+ export declare function completeWithWireWithStop(input: OpenAIOneShotInput, clientFactory?: CompleteWireClientFactory, authDeps?: AuthResolverDeps): Promise<ProviderCompleteResult>;
@@ -1,4 +1,4 @@
1
- import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs } from '../../provider.js';
1
+ import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs, ProviderCompleteResult } from '../../provider.js';
2
2
  import { type OpenAICompatibleProviderOptions } from './index.options.js';
3
3
  export type { OpenAICompatibleProviderOptions } from './index.options.js';
4
4
  export declare class OpenAICompatibleProvider implements ModelProvider {
@@ -39,6 +39,7 @@ export declare class OpenAICompatibleProvider implements ModelProvider {
39
39
  grantsTool(toolName: string): boolean;
40
40
  close(): void;
41
41
  complete(args: ProviderCompleteArgs): Promise<string>;
42
+ completeWithStop(args: ProviderCompleteArgs): Promise<ProviderCompleteResult>;
42
43
  }
43
44
  export declare const openaiCompatibleProvider: ModelProvider;
44
45
  export { resolveOpenAIAuth, formatAuthDiagnostic, type OpenAIAuthResolution, type OpenAIAuthSource, } from './auth.js';
@@ -0,0 +1,12 @@
1
+ export declare const MODEL_REJECTED_CODE: "model_rejected";
2
+ export declare class ModelRejectedError extends Error {
3
+ readonly model: string;
4
+ readonly status: number | undefined;
5
+ readonly provider: string;
6
+ readonly code: "model_rejected";
7
+ constructor(message: string, model: string, status: number | undefined, provider: string, options?: {
8
+ cause?: unknown;
9
+ });
10
+ }
11
+ export declare function isModelRejectedError(err: unknown): err is ModelRejectedError;
12
+ export declare function classifyModelRejection(err: unknown, model: string, provider: string): ModelRejectedError | undefined;
@@ -1,4 +1,4 @@
1
- import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs } from '../../provider.js';
1
+ import type { ModelProvider, ProviderQuery, ProviderQueryArgs, ProviderCompleteArgs, ProviderCompleteResult } from '../../provider.js';
2
2
  import type { OpenAICompatibleProviderOptions } from '../openai-compatible/index.js';
3
3
  import { OpenAICompatibleProvider } from '../openai-compatible/index.js';
4
4
  import { type XaiAuthForceMode, type XaiAuthResolverDeps } from './auth.js';
@@ -33,6 +33,7 @@ export declare class XaiProvider implements ModelProvider {
33
33
  get _innerForTesting(): OpenAICompatibleProvider;
34
34
  close(): void;
35
35
  complete(args: ProviderCompleteArgs): Promise<string>;
36
+ completeWithStop(args: ProviderCompleteArgs): Promise<ProviderCompleteResult>;
36
37
  }
37
38
  export { resolveXaiAuth, formatXaiAuthDiagnostic, formatXaiHttpAuthError, type XaiAuthResolution, type XaiAuthSource, } from './auth.js';
38
39
  export { resolveXaiEndpoint, DEFAULT_XAI_API_BASE_URL, DEFAULT_XAI_OAUTH_BASE_URL, type XaiAuthMode, } from './endpoints.js';
@@ -0,0 +1,15 @@
1
+ import type { AgentConfig } from '../types.js';
2
+ import type { BundledProviderName } from '../providers/index.js';
3
+ import type { ForkSubagentOptions } from './fork-types.js';
4
+ import type { WorkspaceStore } from '../workspace/workspace-store.js';
5
+ import type { HandleModelFallback } from './handle.model-fallback.js';
6
+ export interface BuildForkModelFallbackArgs<T> {
7
+ options: ForkSubagentOptions<T>;
8
+ childConfig: AgentConfig;
9
+ id: string;
10
+ parentApiKey: string | undefined;
11
+ parentBaseUrl: string | undefined;
12
+ parentProvider: BundledProviderName | undefined;
13
+ workspaceStore: WorkspaceStore | undefined;
14
+ }
15
+ export declare function buildForkModelFallback<T>(args: BuildForkModelFallbackArgs<T>): HandleModelFallback | undefined;
@@ -30,6 +30,10 @@ export interface ForkSubagentOptions<T = unknown> {
30
30
  progressEvents?: boolean;
31
31
  phaseRole?: PhaseRole;
32
32
  nestedAgentAllowlist?: readonly string[];
33
+ modelFallback?: {
34
+ model: string;
35
+ buildProvider?: (model: string) => import('../provider.js').ModelProvider;
36
+ };
33
37
  }
34
38
  export interface ParentCredential {
35
39
  key: string | (() => string | undefined);
@@ -9,6 +9,7 @@ import type { TraceSink } from '../trace/index.js';
9
9
  import { PauseAwareCeiling } from './pause-ceiling.js';
10
10
  import type { WorkspaceEntry, WorkspaceStore } from '../workspace/workspace-store.js';
11
11
  import { type SubagentResult, type SubagentStatus, type SubagentTrace } from './result.js';
12
+ import { type HandleModelFallback } from './handle.model-fallback.js';
12
13
  import { type RunBillingContext } from './handle.billing.js';
13
14
  export type { SubagentProgressMeta };
14
15
  export interface SubagentHandle<T = unknown> {
@@ -29,7 +30,7 @@ export interface SubagentHandle<T = unknown> {
29
30
  }
30
31
  export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
31
32
  readonly id: string;
32
- readonly session: IAgentSession;
33
+ session: IAgentSession;
33
34
  readonly _controller: AbortController;
34
35
  private readonly abortGraph;
35
36
  readonly _outputSchema: ZodType<T> | undefined;
@@ -63,6 +64,7 @@ export declare class SubagentHandleImpl<T> implements SubagentHandle<T> {
63
64
  get pendingBillingStreams(): Promise<void>[];
64
65
  get _runBilling(): BillingUsage | undefined;
65
66
  set _runBilling(value: BillingUsage | undefined);
67
+ _modelFallback?: HandleModelFallback;
66
68
  _logWriter?: {
67
69
  write(event: OutputEvent): void;
68
70
  close(): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
2
+ import type { IAgentSession, Message } from '../types.js';
3
+ import type { SubagentProgressSink } from '../types/session-types.js';
4
+ import type { RunBillingContext } from './handle.billing.js';
5
+ import type { SubagentHandleImpl } from './handle.js';
6
+ export interface HandleModelFallback {
7
+ fromModel: string;
8
+ toModel: string;
9
+ createSession: () => IAgentSession;
10
+ }
11
+ export declare const MODEL_FALLBACK_WARNING_PREFIX = "[model-fallback]";
12
+ export declare function hasZeroProgress<T>(handle: SubagentHandleImpl<T>): boolean;
13
+ export declare function buildModelFallbackWarning(fromModel: string, toModel: string, reason: string): string;
14
+ export declare function streamWithModelFallback<T>(handle: SubagentHandleImpl<T>, prompt: string | ContentBlockParam[], sinkOverride: SubagentProgressSink | undefined, billingContext: RunBillingContext): Promise<Message>;
@@ -4,4 +4,15 @@ export interface ResolveChildModelOpts {
4
4
  defaultSubagentModel?: string;
5
5
  defaultModel?: string;
6
6
  }
7
+ export type ChildModelSource = 'callSite' | 'namedAgent' | 'default' | 'parent' | 'floor';
8
+ export interface ResolvedChildModel {
9
+ model: string;
10
+ source: ChildModelSource;
11
+ }
7
12
  export declare function resolveChildModel(opts: ResolveChildModelOpts): string;
13
+ export declare function resolveChildModel(opts: ResolveChildModelOpts, extra: {
14
+ withSource: true;
15
+ }): ResolvedChildModel;
16
+ export declare function defaultTierModelFallback(resolved: ResolvedChildModel, parentModel: string | undefined): {
17
+ model: string;
18
+ } | undefined;
@@ -1,6 +1,7 @@
1
1
  import { SubagentManager } from '../../subagent.js';
2
2
  import type { ToolCall, ToolResult } from '../types.js';
3
3
  import type { AgentConfig } from '../../types/config-types.js';
4
+ import type { ForkSubagentOptions } from '../../subagent/fork-types.js';
4
5
  import { type JournalParentHolder } from './fork-child-config.js';
5
6
  import type { SkillExecutorInternals } from './types.js';
6
7
  export declare function executeForkedRegistrySkill(internals: SkillExecutorInternals, skill: {
@@ -20,6 +21,7 @@ export declare function runForkedSkillToResult(internals: SkillExecutorInternals
20
21
  idPrefix: string;
21
22
  parentId: string;
22
23
  args: string | undefined;
24
+ modelFallback?: ForkSubagentOptions['modelFallback'];
23
25
  noOutputError: string;
24
26
  errorPrefix: string;
25
27
  }): Promise<ToolResult>;
@@ -1,3 +1,5 @@
1
+ import { type ChildModelSource } from '../../subagent/resolve-child-model.js';
2
+ import type { ForkSubagentOptions } from '../../subagent/fork-types.js';
1
3
  import { SubagentManager } from '../../subagent.js';
2
4
  import type { ReadScopeInputs } from '../../subagent-read-scope.js';
3
5
  import type { ModelProvider } from '../../provider.js';
@@ -52,5 +54,7 @@ export interface BuildChildConfigResult {
52
54
  childWriteCapable: boolean;
53
55
  childSideEffectFree: boolean;
54
56
  nestedAgentAllowlist: readonly string[] | undefined;
57
+ childModelSource: ChildModelSource;
58
+ modelFallback: ForkSubagentOptions['modelFallback'];
55
59
  }
56
60
  export declare function buildChildConfig(args: BuildChildConfigArgs): BuildChildConfigResult;
@@ -1,3 +1,5 @@
1
+ import type { ModelProvider } from '../../provider.js';
2
+ import { type ChildModelSource } from '../../subagent/resolve-child-model.js';
1
3
  import { resolveAgentToolAccess } from '../../agents/index.js';
2
4
  import { SubagentManager } from '../../subagent.js';
3
5
  import type { RegisteredAgent, AgentRegistry } from '../../agents/index.js';
@@ -9,6 +11,7 @@ import type { BuildChildConfigArgs, ChildParentSession } from './child-config.js
9
11
  export interface ResolvedChildModel {
10
12
  childModel: string;
11
13
  childIsOpenAI: boolean;
14
+ childModelSource: ChildModelSource;
12
15
  }
13
16
  export declare function resolveChildModelAndProvider(parsed: Pick<AgentInput, 'model'>, namedAgent: RegisteredAgent | undefined, defaultSubagentModel: AgentModelInput, parentModel: AgentModelInput | undefined): ResolvedChildModel;
14
17
  export interface ResolvedChildToolAccess {
@@ -29,6 +32,7 @@ export declare function buildBaseChildConfig(parsed: Pick<AgentInput, 'cwd' | 'w
29
32
  export interface WireChildNestingResult {
30
33
  childParentSession: ChildParentSession | undefined;
31
34
  childManager: SubagentManager | undefined;
35
+ rebuildProvider?: (model: string) => ModelProvider;
32
36
  }
33
37
  interface WireChildNestingArgs {
34
38
  args: BuildChildConfigArgs;
@@ -1,2 +1,10 @@
1
1
  export declare function isTooBroadRoot(candidate: string): boolean;
2
2
  export declare function ungatedSensitiveRoot(candidate: string): string | undefined;
3
+ export type RootField = 'cwd' | 'readRoots' | 'writeRoots';
4
+ export type RootValidationCaller = {
5
+ kind: 'agent';
6
+ } | {
7
+ kind: 'compose';
8
+ nodeId: string;
9
+ };
10
+ export declare function validateRootPath(value: unknown, field: RootField, caller: RootValidationCaller): string;
@@ -1,6 +1,7 @@
1
1
  import { SubagentManager } from '../subagent.js';
2
2
  import type { AgentInput } from './subagent/input-parse.js';
3
3
  import type { StreamCutProbe } from '../subagent/stream-cut-retry.js';
4
+ import type { ForkSubagentOptions } from '../subagent/fork-types.js';
4
5
  import { type InboundAttachmentReader } from '../content/attachment-registry.js';
5
6
  import type { SpawnReceipt } from './delegation-budget.js';
6
7
  import type { ContentBlockParam } from '@anthropic-ai/sdk/resources';
@@ -18,17 +19,22 @@ export interface IsolationWorktreeResult {
18
19
  setupNotice?: string;
19
20
  }
20
21
  export interface SetupIsolationWorktreeArgs {
21
- parsed: AgentInput;
22
+ parsed: Pick<AgentInput, 'prompt' | 'mode' | 'agent_type' | 'id_prefix'>;
22
23
  currentCwd: string | undefined;
23
24
  isolationCounterRef: {
24
25
  value: number;
25
26
  };
26
- childConfig: AgentConfig;
27
+ childConfig: Pick<AgentConfig, 'cwd'>;
28
+ dagNodeId?: string;
27
29
  childWriteCapable: boolean;
28
30
  probe: StreamCutProbe | undefined;
29
31
  budgetReceipt: SpawnReceipt | undefined;
30
32
  signal?: AbortSignal;
31
33
  }
34
+ export declare function setupIsolationWorktree(args: SetupIsolationWorktreeArgs & {
35
+ dagNodeId: string;
36
+ childWriteCapable: true;
37
+ }): Promise<IsolationWorktreeResult>;
32
38
  export declare function setupIsolationWorktree(args: SetupIsolationWorktreeArgs): Promise<IsolationWorktreeResult | {
33
39
  skipped: true;
34
40
  } | {
@@ -57,6 +63,7 @@ export interface ForkAndCheckCancelArgs {
57
63
  depth: number;
58
64
  updateCurrentWaveUnit: (callId: string, status: 'running' | 'done' | 'failed', error?: string, cwd?: string) => void;
59
65
  callId: string;
66
+ modelFallback?: ForkSubagentOptions['modelFallback'];
60
67
  }
61
68
  export type ForkResult = {
62
69
  handle: Awaited<ReturnType<SubagentManager['forkSubagent']>>;
@@ -751,6 +751,7 @@ export declare const TraceEventInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject
751
751
  compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
752
752
  hook_block_repeat_tripped: "hook_block_repeat_tripped";
753
753
  billing_settled: "billing_settled";
754
+ subagent_model_fallback: "subagent_model_fallback";
754
755
  }>;
755
756
  durationMs: z.ZodOptional<z.ZodNumber>;
756
757
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
@@ -1229,6 +1230,7 @@ export declare const TraceEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1229
1230
  compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
1230
1231
  hook_block_repeat_tripped: "hook_block_repeat_tripped";
1231
1232
  billing_settled: "billing_settled";
1233
+ subagent_model_fallback: "subagent_model_fallback";
1232
1234
  }>;
1233
1235
  durationMs: z.ZodOptional<z.ZodNumber>;
1234
1236
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
@@ -50,6 +50,7 @@ export declare const SessionPhaseNameSchema: z.ZodEnum<{
50
50
  compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
51
51
  hook_block_repeat_tripped: "hook_block_repeat_tripped";
52
52
  billing_settled: "billing_settled";
53
+ subagent_model_fallback: "subagent_model_fallback";
53
54
  }>;
54
55
  export declare const SessionPhasePayloadSchema: z.ZodObject<{
55
56
  phase: z.ZodEnum<{
@@ -103,6 +104,7 @@ export declare const SessionPhasePayloadSchema: z.ZodObject<{
103
104
  compose_leaf_tools_stripped: "compose_leaf_tools_stripped";
104
105
  hook_block_repeat_tripped: "hook_block_repeat_tripped";
105
106
  billing_settled: "billing_settled";
107
+ subagent_model_fallback: "subagent_model_fallback";
106
108
  }>;
107
109
  durationMs: z.ZodOptional<z.ZodNumber>;
108
110
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
@@ -1,4 +1,4 @@
1
- export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'context_pressure_wind_down' | 'catalog_model_upgrade' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'connection_retry_exhausted' | 'connection_failure' | 'connection_recovered' | 'connection_budget_exhausted' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'thinking_block_dropped' | 'background_process_started' | 'background_process_settled' | 'compose_recovery_decision' | 'compose_leaf_tools_stripped' | 'hook_block_repeat_tripped' | 'billing_settled';
1
+ export type SessionPhaseName = 'bootstrap_start' | 'bootstrap_done' | 'session_init_start' | 'session_init_done' | 'mcp_connect_start' | 'mcp_connect_done' | 'mcp_server_start' | 'mcp_server_done' | 'loop_start' | 'loop_end' | 'model_ttfb' | 'context_pressure_wind_down' | 'catalog_model_upgrade' | 'interrupt_halt' | 'rate_limit' | 'ttfb_timeout' | 'usage_limit_pause' | 'usage_limit_resume' | 'overload_pause' | 'overload_resume' | 'idle_watchdog_fired' | 'pause_extension_granted' | 'suspected_loop' | 'compaction_disabled' | 'boot_warning' | 'workspace_subscribed' | 'workspace_delivery' | 'gate_shape' | 'session_id_assigned' | 'many_image_degraded' | 'stream_accepted_after_drop' | 'connection_retry' | 'connection_retry_exhausted' | 'connection_failure' | 'connection_recovered' | 'connection_budget_exhausted' | 'usage_notice' | 'tool_degraded' | 'strategy_nudge_fired' | 'stop_inject_dropped' | 'stop_hook_continuation' | 'stop_hook_cap_reached' | 'orphan_repair' | 'thinking_block_dropped' | 'background_process_started' | 'background_process_settled' | 'compose_recovery_decision' | 'compose_leaf_tools_stripped' | 'hook_block_repeat_tripped' | 'billing_settled' | 'subagent_model_fallback';
2
2
  export interface SessionPhasePayload {
3
3
  phase: SessionPhaseName;
4
4
  durationMs?: number;
@@ -0,0 +1,3 @@
1
+ import type { SessionRef } from '../../../agent/session-ref.js';
2
+ import type { SuggestionRecorder } from '../../input/suggest.js';
3
+ export declare function buildSuggestionJournalRecorder(session: SessionRef): SuggestionRecorder;
@@ -1,10 +1,11 @@
1
- import type { CompleteFn, SuggestContext } from './suggest-types.js';
1
+ import type { CompleteFn, SuggestContext, SuggestionRecorder } from './suggest-types.js';
2
2
  export interface PromptSuggestionStateDeps {
3
3
  pickModel(ctx: SuggestContext): string;
4
4
  resolveComplete(model: string, ctx: SuggestContext): CompleteFn | null;
5
5
  timeoutMs: number;
6
6
  scrub(s: string): string;
7
7
  onError?: (err: unknown) => void;
8
+ onRecord?: SuggestionRecorder;
8
9
  }
9
10
  export interface PromptSuggestionState {
10
11
  prime(ctx: SuggestContext): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { CompleteRequest, SuggestContext } from './suggest-types.js';
1
+ import type { CompleteFn, CompleteRequest, SuggestContext } from './suggest-types.js';
2
2
  export { extractOutcome } from './suggest-prompt.context.js';
3
3
  export declare function buildPromptSuggestionSystem(): string;
4
4
  export declare function buildPromptSuggestionUser(ctx: SuggestContext): string;
@@ -8,7 +8,7 @@ export declare function isValidPromptSuggestion(reply: string): boolean;
8
8
  export declare function normalizePromptSuggestion(raw: string): string | null;
9
9
  export type PromptCompleteRequest = CompleteRequest;
10
10
  export interface PromptSuggestionDeps {
11
- resolveComplete(model: string): ((req: PromptCompleteRequest) => Promise<string>) | null;
11
+ resolveComplete(model: string): CompleteFn | null;
12
12
  model: string;
13
13
  timeoutMs: number;
14
14
  scrub(s: string): string;
@@ -0,0 +1,10 @@
1
+ import type { ProviderCompleteResult } from '../../agent/provider.js';
2
+ export interface NormalizedReply {
3
+ text: string;
4
+ truncated: boolean;
5
+ }
6
+ export declare function normalizeReply(raw: string | ProviderCompleteResult): NormalizedReply;
7
+ export declare function trailingWord(buffer: string): string;
8
+ export declare function joinContinuation(buffer: string, reply: string): string | null;
9
+ export declare function dropPartialWord(text: string): string;
10
+ export declare function trimTruncatedLine(buffer: string, line: string): string | null;
@@ -1,8 +1,9 @@
1
- import type { CompleteFn } from './suggest-types.js';
1
+ import type { CompleteFn, SuggestionRecorder } from './suggest-types.js';
2
2
  import type { SuggestContext } from './suggest.js';
3
3
  export declare const MIN_LLM_CHARS = 3;
4
4
  export declare const DEBOUNCE_MS = 250;
5
5
  export declare const TIMEOUT_MS = 1500;
6
+ export declare const LLM_MAX_TOKENS = 32;
6
7
  export declare function buildSystem(): string;
7
8
  export declare function buildUser(buffer: string, ctx: SuggestContext): string;
8
9
  export interface Tier2Deps {
@@ -11,6 +12,7 @@ export interface Tier2Deps {
11
12
  debounceMs: number;
12
13
  timeoutMs: number;
13
14
  onError?: (err: unknown) => void;
15
+ onRecord?: SuggestionRecorder;
14
16
  }
15
17
  export interface Tier2Runner {
16
18
  request(buffer: string, ctx: SuggestContext): Promise<string | null>;
@@ -1,4 +1,5 @@
1
- import type { ModelProvider } from '../../agent/provider.js';
1
+ import type { JournalSuggestionDetail } from '../../agent/journal/types.js';
2
+ import type { ModelProvider, ProviderCompleteResult } from '../../agent/provider.js';
2
3
  import type { ProviderRouteHints } from '../../agent/providers/index.js';
3
4
  export interface SuggestContext {
4
5
  model: string;
@@ -24,7 +25,7 @@ export interface CompleteRequest {
24
25
  forceChatgptOAuth?: boolean;
25
26
  baseUrl?: string;
26
27
  }
27
- export type CompleteFn = (req: CompleteRequest) => Promise<string>;
28
+ export type CompleteFn = (req: CompleteRequest) => Promise<string | ProviderCompleteResult>;
28
29
  export interface SuggestEngineOptions {
29
30
  completeFn?: CompleteFn;
30
31
  resolveProviderFn?: (model: string | undefined, hints: ProviderRouteHints | undefined) => ModelProvider;
@@ -32,12 +33,16 @@ export interface SuggestEngineOptions {
32
33
  debounceMs?: number;
33
34
  timeoutMs?: number;
34
35
  onError?: (err: unknown) => void;
36
+ onRecord?: SuggestionRecorder;
35
37
  }
38
+ export type SuggestionRecord = JournalSuggestionDetail;
39
+ export type SuggestionRecorder = (record: SuggestionRecord) => void;
36
40
  export interface SuggestEngine {
37
41
  getDeterministicGhost(buffer: string, ctx: SuggestContext): string | null;
38
42
  getGhost(buffer: string, ctx: SuggestContext): Promise<string | null>;
39
43
  primePromptSuggestion(ctx: SuggestContext): Promise<void>;
40
44
  peekPromptSuggestion(): string | null;
41
45
  clearPromptSuggestion(): void;
46
+ recordOutcome?(record: SuggestionRecord): void;
42
47
  dispose(): void;
43
48
  }
@@ -1,5 +1,5 @@
1
1
  import type { SuggestEngine, SuggestEngineOptions } from './suggest-types.js';
2
- export type { CompleteFn, CompleteRequest, SuggestContext, SuggestEngine, SuggestEngineOptions, } from './suggest-types.js';
2
+ export type { CompleteFn, CompleteRequest, SuggestContext, SuggestEngine, SuggestEngineOptions, SuggestionRecord, SuggestionRecorder, } from './suggest-types.js';
3
3
  export { stripGhostControlChars } from './suggest-sanitize.js';
4
4
  export { pickModel } from './suggest-provider.js';
5
5
  export { getDeterministicGhost } from './suggest-tier1.js';
@@ -0,0 +1,4 @@
1
+ import type { SlashCommand } from '../types.js';
2
+ export declare const handoffsCmd: SlashCommand;
3
+ export declare const handoffsAnswerCmd: SlashCommand;
4
+ export declare const handoffsCommands: readonly SlashCommand[];
@@ -0,0 +1,5 @@
1
+ import type { AutocompleteHost } from './terminal-compositor.autocomplete.js';
2
+ export type GhostSource = 'completion' | 'prompt' | null;
3
+ export declare function noteGhostSource(self: AutocompleteHost, ghost: string, source: GhostSource): void;
4
+ export declare function recordGhostAccept(self: AutocompleteHost, ghost: string, full: boolean): void;
5
+ export declare function recordPromptDismiss(self: AutocompleteHost, text: string): void;