@spotpatch/dev-server 0.7.0 → 0.9.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.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,18 @@
1
- import { applyPreparedAgentChange, executeAgentChange, inspectAgentWorkspace, probeProviderCapability, resolveProviderCredential, revertPreparedAgentChange } from '@spotpatch/agent';
2
- import { AgentJobEvent, AgentJobSnapshot, AgentJobCreateRequest, AgentCapabilityRequest, AgentCapabilitySnapshot, AgentJobResultResponse, AgentWorkspaceHealthSnapshot, ResolvedAiOptions, ExternalHandoffFramework, ExternalHandoffCapability, ExternalHandoffPublishRequest, SpotAnnotation, ExternalHandoffPublishResult, ExternalHandoffStatusResult, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult, SpotPatchEditorPreference, ContextBudget, SpotPatchLocalePreference, DataFlowLimits, AiProviderProtocol, AiProviderAuthentication, AiExecutionOptions, AiOptions, RuntimeAiConfig, RuntimeDataFlowConfig, ResolvedAgentCheckDefinition, AgentLimits, SpotPatchRuntimeConfig } from '@spotpatch/shared';
1
+ import { applyPreparedAgentChange, executeAgentChange, inspectAgentWorkspace, probeProviderCapability, resolveProviderCredential, revertPreparedAgentChange, AskSourceGrant, ContextualAskReadSnapshot, AskSourceGrantEntry, ContextualAskExecutor } from '@spotpatch/agent';
2
+ import { AgentJobEvent, AgentJobSnapshot, AgentJobCreateRequest, AgentCapabilityRequest, AgentCapabilitySnapshot, AgentJobResultResponse, AgentWorkspaceHealthSnapshot, ResolvedAiOptions, ExternalHandoffFramework, ExternalHandoffCapability, ExternalHandoffPublishRequest, SpotAnnotation, ExternalHandoffPublishResult, ExternalHandoffStatusResult, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult, SpotPatchEditorPreference, ContextBudget, SpotPatchLocalePreference, DataFlowLimits, ContextualAskExecutorPreference, AiProviderProtocol, AiProviderAuthentication, AiExecutionOptions, AiOptions, ContextualAskOptions, RuntimeAiConfig, RuntimeDataFlowConfig, ResolvedAgentCheckDefinition, AgentLimits, SpotSelectionContext, AskJobEvent, AskJobSnapshot, ContextualAskCapability, AskJobCreateRequest, AskJobResultResponse, ContextualAskErrorCode, SpotPatchRuntimeConfig } from '@spotpatch/shared';
3
3
  import { SourceFilterEntry } from '@spotpatch/compiler';
4
4
  import { IncomingMessage, ServerResponse } from 'node:http';
5
5
 
6
+ type WorkspaceActivityKind = "ask" | "change";
7
+ interface WorkspaceActivityLease {
8
+ release(): void;
9
+ }
10
+ interface WorkspaceActivityCoordinator {
11
+ acquire(kind: WorkspaceActivityKind): WorkspaceActivityLease | undefined;
12
+ current(): WorkspaceActivityKind | undefined;
13
+ }
14
+ declare function createWorkspaceActivityCoordinator(): WorkspaceActivityCoordinator;
15
+
6
16
  type AgentJobEventListener = (event: AgentJobEvent) => void;
7
17
  interface AgentJobManager {
8
18
  apply(jobId: string): Promise<AgentJobSnapshot>;
@@ -32,6 +42,7 @@ interface CreateAgentJobManagerOptions {
32
42
  readonly environment?: Readonly<Record<string, string | undefined>>;
33
43
  readonly fetch?: typeof globalThis.fetch;
34
44
  readonly root: string;
45
+ readonly coordinator?: WorkspaceActivityCoordinator;
35
46
  }
36
47
  declare function createAgentJobManager(options: CreateAgentJobManagerOptions): AgentJobManager;
37
48
 
@@ -93,6 +104,11 @@ interface SpotPatchOptions {
93
104
  readonly ai?: SpotPatchAiOptions;
94
105
  readonly dataFlow?: false | SpotPatchDataFlowOptions;
95
106
  readonly externalAgent?: boolean;
107
+ readonly contextualAsk?: ContextualAskOptions;
108
+ }
109
+ interface ResolvedContextualAskOptions {
110
+ readonly enabled: boolean;
111
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
96
112
  }
97
113
  interface ResolvedSpotPatchOptions {
98
114
  readonly enabled: boolean;
@@ -111,6 +127,7 @@ interface ResolvedSpotPatchOptions {
111
127
  readonly externalAgent: Readonly<{
112
128
  enabled: boolean;
113
129
  }>;
130
+ readonly contextualAsk: ResolvedContextualAskOptions;
114
131
  }
115
132
  interface ResolvedSpotPatchDataFlowOptions {
116
133
  readonly enabled: boolean;
@@ -155,11 +172,15 @@ declare const DEFAULT_OPTIONS: Readonly<{
155
172
  readonly graphMaxCallsites: 100;
156
173
  readonly analysisTimeoutMs: 2000;
157
174
  readonly reportMaxFields: 100;
175
+ readonly sourceMaxComponents: 256;
158
176
  }>;
159
177
  }>;
160
178
  externalAgent: Readonly<{
161
179
  enabled: false;
162
180
  }>;
181
+ contextualAsk: Readonly<{
182
+ enabled: false;
183
+ }>;
163
184
  }>;
164
185
  declare function createRuntimeAiConfig(options: false | ResolvedAiOptions): RuntimeAiConfig;
165
186
  declare function createRuntimeDataFlowConfig(options: ResolvedSpotPatchDataFlowOptions): RuntimeDataFlowConfig;
@@ -216,8 +237,9 @@ type SourceIdFactory = () => string;
216
237
 
217
238
  interface SourceRegistry {
218
239
  register(absolutePath: string): string;
219
- registerDataFlowComponents(absolutePath: string, sourceVersion: string, components: readonly DataFlowComponentAnchorInput[]): void;
240
+ registerDataFlowComponents(absolutePath: string, sourceVersion: string, components: readonly DataFlowComponentAnchorInput[]): string;
220
241
  resolve(fileId: string): string | undefined;
242
+ findRegisteredId(absolutePath: string): string | undefined;
221
243
  resolveDataFlowComponent(componentSourceId: string): DataFlowComponentAnchor | undefined;
222
244
  clear(): void;
223
245
  }
@@ -235,6 +257,75 @@ interface SourceRegistryOptions {
235
257
  }
236
258
  declare function createSourceRegistry(options?: SourceRegistryOptions): SourceRegistry;
237
259
 
260
+ interface CapturedAskReadSnapshot {
261
+ readonly grant: AskSourceGrant;
262
+ readonly snapshot: ContextualAskReadSnapshot;
263
+ dispose(): void;
264
+ isStale(): Promise<boolean>;
265
+ projectCitation(handleId: string, startLine: number, endLine: number): AskSourceGrantEntry & Readonly<{
266
+ startLine: number;
267
+ endLine: number;
268
+ }>;
269
+ }
270
+ interface CaptureAskReadSnapshotOptions {
271
+ readonly root: string;
272
+ readonly registry: SourceRegistry;
273
+ readonly selection: SpotSelectionContext;
274
+ readonly signal?: AbortSignal;
275
+ readonly createHandleId?: () => string;
276
+ }
277
+ declare function captureAskReadSnapshot(options: CaptureAskReadSnapshotOptions): Promise<CapturedAskReadSnapshot>;
278
+
279
+ type ContextualAskJobEventListener = (event: AskJobEvent) => void;
280
+ interface ContextualAskManager {
281
+ cancel(jobId: string): AskJobSnapshot;
282
+ capability(signal: AbortSignal): Promise<ContextualAskCapability>;
283
+ close(): Promise<void>;
284
+ create(request: AskJobCreateRequest): Promise<AskJobSnapshot>;
285
+ events(jobId: string, afterSequence?: number): readonly AskJobEvent[];
286
+ result(jobId: string): Promise<AskJobResultResponse>;
287
+ snapshot(jobId: string): AskJobSnapshot;
288
+ subscribe(jobId: string, listener: ContextualAskJobEventListener): () => void;
289
+ }
290
+ interface ContextualAskManagerDependencies {
291
+ readonly captureSnapshot: typeof captureAskReadSnapshot;
292
+ readonly createId: () => string;
293
+ readonly now: () => Date;
294
+ }
295
+ interface CreateContextualAskManagerOptions {
296
+ readonly coordinator: WorkspaceActivityCoordinator;
297
+ readonly enabled: boolean;
298
+ readonly executors?: readonly ContextualAskExecutor[];
299
+ readonly registry: SourceRegistry;
300
+ readonly root: string;
301
+ readonly dependencies?: Partial<ContextualAskManagerDependencies>;
302
+ }
303
+ declare function createContextualAskManager(options: CreateContextualAskManagerOptions): ContextualAskManager;
304
+
305
+ declare class ContextualAskError extends Error {
306
+ readonly code: ContextualAskErrorCode;
307
+ constructor(code: ContextualAskErrorCode, options?: Readonly<{
308
+ cause?: unknown;
309
+ }>);
310
+ }
311
+
312
+ interface CreateConfiguredKeyAskExecutorsOptions {
313
+ readonly ai: ResolvedAiOptions;
314
+ readonly environment: Readonly<Record<string, string | undefined>>;
315
+ readonly fetch?: typeof globalThis.fetch;
316
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
317
+ }
318
+ /** Builds one isolated read-only Ask executor per configured Provider/model pair. */
319
+ declare function createConfiguredKeyAskExecutors(options: CreateConfiguredKeyAskExecutorsOptions): readonly ContextualAskExecutor[];
320
+
321
+ interface ComposeContextualAskExecutorsOptions {
322
+ readonly configuredKey: readonly ContextualAskExecutor[];
323
+ readonly managedCodex: ContextualAskExecutor;
324
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
325
+ }
326
+ /** Orders independent executor implementations without coupling dev-server to Codex. */
327
+ declare function composeContextualAskExecutors(options: ComposeContextualAskExecutorsOptions): readonly ContextualAskExecutor[];
328
+
238
329
  interface SpotPatchSession {
239
330
  readonly id: string;
240
331
  readonly token: string;
@@ -264,6 +355,7 @@ interface SpotPatchServerLogger {
264
355
  }
265
356
  interface CreateMiddlewareOptions {
266
357
  readonly agentManager?: AgentJobManager;
358
+ readonly contextualAskManager?: ContextualAskManager;
267
359
  readonly bootstrap?: RuntimeBootstrapOptions;
268
360
  readonly editorLauncher?: EditorLauncher;
269
361
  readonly externalAgentControl?: ExternalAgentControlPort;
@@ -280,6 +372,18 @@ declare function readJsonRequestBody(request: IncomingMessage, maximumBytes?: nu
280
372
 
281
373
  declare function isLoopbackHostname(hostname: string): boolean;
282
374
 
375
+ type ContextualAskRoute = Readonly<{
376
+ kind: "capability";
377
+ }> | Readonly<{
378
+ kind: "create";
379
+ }> | Readonly<{
380
+ kind: "job";
381
+ action: "events" | "result" | "cancel";
382
+ jobId: string;
383
+ }>;
384
+ declare function matchContextualAskPath(pathname: string): ContextualAskRoute | undefined;
385
+ declare function handleContextualAskRequest(request: IncomingMessage, response: ServerResponse, route: ContextualAskRoute, manager: ContextualAskManager | undefined, logger?: SpotPatchServerLogger): Promise<void>;
386
+
283
387
  interface SourceRegistrationServiceOptions {
284
388
  readonly internalSecret: string;
285
389
  readonly options: ResolvedSpotPatchOptions;
@@ -310,6 +414,7 @@ interface SerializedSpotPatchOptions {
310
414
  readonly budget: Readonly<ContextBudget>;
311
415
  readonly debug: boolean;
312
416
  readonly dataFlow: false | SpotPatchDataFlowOptions;
417
+ readonly contextualAsk: ContextualAskOptions;
313
418
  readonly editor: SpotPatchEditorPreference;
314
419
  readonly enabled: boolean;
315
420
  readonly externalAgent: boolean;
@@ -323,4 +428,4 @@ interface SerializedSpotPatchOptions {
323
428
  declare function serializeResolvedSpotPatchOptions(options: ResolvedSpotPatchOptions): SerializedSpotPatchOptions;
324
429
  declare function parseSerializedSpotPatchOptions(value: unknown): ResolvedSpotPatchOptions;
325
430
 
326
- export { type AgentJobEventListener, type AgentJobManager, type CreateAgentJobManagerOptions, type CreateExternalHandoffServiceOptions, type CreateMiddlewareOptions, DEFAULT_EXCLUDE, DEFAULT_OPTIONS, type DiscoverProjectValidationCheckOptions, type EnvironmentAiConfiguration, type ExternalAgentControlPort, type ExternalHandoffService, type FilterEntry, type IntegrationFileChange, type IntegrationPlan, type ResolveManagedExecutionValidationOptions, type ResolveProjectOptionsInput, type ResolveProjectValidationChecksOptions, type ResolvedManagedExecutionValidation, type ResolvedRuntimeBootstrapOptions, type ResolvedSpotPatchDataFlowOptions, type ResolvedSpotPatchOptions, type RuntimeBootstrapOptions, type SerializedFilterEntry, type SerializedSpotPatchOptions, type SimpleAiOptions, type SourceRegistrationHandler, type SourceRegistrationService, type SourceRegistrationServiceOptions, type SourceRegistry, type SpotPatchAiOptions, type SpotPatchDataFlowOptions, type SpotPatchMiddleware, type SpotPatchNext, type SpotPatchOptions, type SpotPatchServerLogger, type SpotPatchSession, applyIntegrationPlan, createAgentJobManager, createExternalHandoffService, createIntegrationFileChange, createRuntimeAiConfig, createRuntimeDataFlowConfig, createSession, createSourceRegistrationService, createSourceRegistry, createSpotPatchMiddleware, discoverProjectValidationCheck, integrationPathExists, isLoopbackHostname, parseSerializedSpotPatchOptions, readIntegrationFile, readJsonRequestBody, readRuntimeBootstrap, resolveCredentialEnvironment, resolveEnvironmentAiConfiguration, resolveManagedExecutionValidation, resolveOptions, resolveProjectOptions, resolveProjectValidationChecks, resolveRuntimeBootstrapOptions, serializeResolvedSpotPatchOptions };
431
+ export { type AgentJobEventListener, type AgentJobManager, type CaptureAskReadSnapshotOptions, type CapturedAskReadSnapshot, type ComposeContextualAskExecutorsOptions, ContextualAskError, type ContextualAskJobEventListener, type ContextualAskManager, type ContextualAskRoute, type CreateAgentJobManagerOptions, type CreateConfiguredKeyAskExecutorsOptions, type CreateContextualAskManagerOptions, type CreateExternalHandoffServiceOptions, type CreateMiddlewareOptions, DEFAULT_EXCLUDE, DEFAULT_OPTIONS, type DiscoverProjectValidationCheckOptions, type EnvironmentAiConfiguration, type ExternalAgentControlPort, type ExternalHandoffService, type FilterEntry, type IntegrationFileChange, type IntegrationPlan, type ResolveManagedExecutionValidationOptions, type ResolveProjectOptionsInput, type ResolveProjectValidationChecksOptions, type ResolvedContextualAskOptions, type ResolvedManagedExecutionValidation, type ResolvedRuntimeBootstrapOptions, type ResolvedSpotPatchDataFlowOptions, type ResolvedSpotPatchOptions, type RuntimeBootstrapOptions, type SerializedFilterEntry, type SerializedSpotPatchOptions, type SimpleAiOptions, type SourceRegistrationHandler, type SourceRegistrationService, type SourceRegistrationServiceOptions, type SourceRegistry, type SpotPatchAiOptions, type SpotPatchDataFlowOptions, type SpotPatchMiddleware, type SpotPatchNext, type SpotPatchOptions, type SpotPatchServerLogger, type SpotPatchSession, type WorkspaceActivityCoordinator, type WorkspaceActivityKind, type WorkspaceActivityLease, applyIntegrationPlan, captureAskReadSnapshot, composeContextualAskExecutors, createAgentJobManager, createConfiguredKeyAskExecutors, createContextualAskManager, createExternalHandoffService, createIntegrationFileChange, createRuntimeAiConfig, createRuntimeDataFlowConfig, createSession, createSourceRegistrationService, createSourceRegistry, createSpotPatchMiddleware, createWorkspaceActivityCoordinator, discoverProjectValidationCheck, handleContextualAskRequest, integrationPathExists, isLoopbackHostname, matchContextualAskPath, parseSerializedSpotPatchOptions, readIntegrationFile, readJsonRequestBody, readRuntimeBootstrap, resolveCredentialEnvironment, resolveEnvironmentAiConfiguration, resolveManagedExecutionValidation, resolveOptions, resolveProjectOptions, resolveProjectValidationChecks, resolveRuntimeBootstrapOptions, serializeResolvedSpotPatchOptions };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,18 @@
1
- import { applyPreparedAgentChange, executeAgentChange, inspectAgentWorkspace, probeProviderCapability, resolveProviderCredential, revertPreparedAgentChange } from '@spotpatch/agent';
2
- import { AgentJobEvent, AgentJobSnapshot, AgentJobCreateRequest, AgentCapabilityRequest, AgentCapabilitySnapshot, AgentJobResultResponse, AgentWorkspaceHealthSnapshot, ResolvedAiOptions, ExternalHandoffFramework, ExternalHandoffCapability, ExternalHandoffPublishRequest, SpotAnnotation, ExternalHandoffPublishResult, ExternalHandoffStatusResult, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult, SpotPatchEditorPreference, ContextBudget, SpotPatchLocalePreference, DataFlowLimits, AiProviderProtocol, AiProviderAuthentication, AiExecutionOptions, AiOptions, RuntimeAiConfig, RuntimeDataFlowConfig, ResolvedAgentCheckDefinition, AgentLimits, SpotPatchRuntimeConfig } from '@spotpatch/shared';
1
+ import { applyPreparedAgentChange, executeAgentChange, inspectAgentWorkspace, probeProviderCapability, resolveProviderCredential, revertPreparedAgentChange, AskSourceGrant, ContextualAskReadSnapshot, AskSourceGrantEntry, ContextualAskExecutor } from '@spotpatch/agent';
2
+ import { AgentJobEvent, AgentJobSnapshot, AgentJobCreateRequest, AgentCapabilityRequest, AgentCapabilitySnapshot, AgentJobResultResponse, AgentWorkspaceHealthSnapshot, ResolvedAiOptions, ExternalHandoffFramework, ExternalHandoffCapability, ExternalHandoffPublishRequest, SpotAnnotation, ExternalHandoffPublishResult, ExternalHandoffStatusResult, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult, SpotPatchEditorPreference, ContextBudget, SpotPatchLocalePreference, DataFlowLimits, ContextualAskExecutorPreference, AiProviderProtocol, AiProviderAuthentication, AiExecutionOptions, AiOptions, ContextualAskOptions, RuntimeAiConfig, RuntimeDataFlowConfig, ResolvedAgentCheckDefinition, AgentLimits, SpotSelectionContext, AskJobEvent, AskJobSnapshot, ContextualAskCapability, AskJobCreateRequest, AskJobResultResponse, ContextualAskErrorCode, SpotPatchRuntimeConfig } from '@spotpatch/shared';
3
3
  import { SourceFilterEntry } from '@spotpatch/compiler';
4
4
  import { IncomingMessage, ServerResponse } from 'node:http';
5
5
 
6
+ type WorkspaceActivityKind = "ask" | "change";
7
+ interface WorkspaceActivityLease {
8
+ release(): void;
9
+ }
10
+ interface WorkspaceActivityCoordinator {
11
+ acquire(kind: WorkspaceActivityKind): WorkspaceActivityLease | undefined;
12
+ current(): WorkspaceActivityKind | undefined;
13
+ }
14
+ declare function createWorkspaceActivityCoordinator(): WorkspaceActivityCoordinator;
15
+
6
16
  type AgentJobEventListener = (event: AgentJobEvent) => void;
7
17
  interface AgentJobManager {
8
18
  apply(jobId: string): Promise<AgentJobSnapshot>;
@@ -32,6 +42,7 @@ interface CreateAgentJobManagerOptions {
32
42
  readonly environment?: Readonly<Record<string, string | undefined>>;
33
43
  readonly fetch?: typeof globalThis.fetch;
34
44
  readonly root: string;
45
+ readonly coordinator?: WorkspaceActivityCoordinator;
35
46
  }
36
47
  declare function createAgentJobManager(options: CreateAgentJobManagerOptions): AgentJobManager;
37
48
 
@@ -93,6 +104,11 @@ interface SpotPatchOptions {
93
104
  readonly ai?: SpotPatchAiOptions;
94
105
  readonly dataFlow?: false | SpotPatchDataFlowOptions;
95
106
  readonly externalAgent?: boolean;
107
+ readonly contextualAsk?: ContextualAskOptions;
108
+ }
109
+ interface ResolvedContextualAskOptions {
110
+ readonly enabled: boolean;
111
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
96
112
  }
97
113
  interface ResolvedSpotPatchOptions {
98
114
  readonly enabled: boolean;
@@ -111,6 +127,7 @@ interface ResolvedSpotPatchOptions {
111
127
  readonly externalAgent: Readonly<{
112
128
  enabled: boolean;
113
129
  }>;
130
+ readonly contextualAsk: ResolvedContextualAskOptions;
114
131
  }
115
132
  interface ResolvedSpotPatchDataFlowOptions {
116
133
  readonly enabled: boolean;
@@ -155,11 +172,15 @@ declare const DEFAULT_OPTIONS: Readonly<{
155
172
  readonly graphMaxCallsites: 100;
156
173
  readonly analysisTimeoutMs: 2000;
157
174
  readonly reportMaxFields: 100;
175
+ readonly sourceMaxComponents: 256;
158
176
  }>;
159
177
  }>;
160
178
  externalAgent: Readonly<{
161
179
  enabled: false;
162
180
  }>;
181
+ contextualAsk: Readonly<{
182
+ enabled: false;
183
+ }>;
163
184
  }>;
164
185
  declare function createRuntimeAiConfig(options: false | ResolvedAiOptions): RuntimeAiConfig;
165
186
  declare function createRuntimeDataFlowConfig(options: ResolvedSpotPatchDataFlowOptions): RuntimeDataFlowConfig;
@@ -216,8 +237,9 @@ type SourceIdFactory = () => string;
216
237
 
217
238
  interface SourceRegistry {
218
239
  register(absolutePath: string): string;
219
- registerDataFlowComponents(absolutePath: string, sourceVersion: string, components: readonly DataFlowComponentAnchorInput[]): void;
240
+ registerDataFlowComponents(absolutePath: string, sourceVersion: string, components: readonly DataFlowComponentAnchorInput[]): string;
220
241
  resolve(fileId: string): string | undefined;
242
+ findRegisteredId(absolutePath: string): string | undefined;
221
243
  resolveDataFlowComponent(componentSourceId: string): DataFlowComponentAnchor | undefined;
222
244
  clear(): void;
223
245
  }
@@ -235,6 +257,75 @@ interface SourceRegistryOptions {
235
257
  }
236
258
  declare function createSourceRegistry(options?: SourceRegistryOptions): SourceRegistry;
237
259
 
260
+ interface CapturedAskReadSnapshot {
261
+ readonly grant: AskSourceGrant;
262
+ readonly snapshot: ContextualAskReadSnapshot;
263
+ dispose(): void;
264
+ isStale(): Promise<boolean>;
265
+ projectCitation(handleId: string, startLine: number, endLine: number): AskSourceGrantEntry & Readonly<{
266
+ startLine: number;
267
+ endLine: number;
268
+ }>;
269
+ }
270
+ interface CaptureAskReadSnapshotOptions {
271
+ readonly root: string;
272
+ readonly registry: SourceRegistry;
273
+ readonly selection: SpotSelectionContext;
274
+ readonly signal?: AbortSignal;
275
+ readonly createHandleId?: () => string;
276
+ }
277
+ declare function captureAskReadSnapshot(options: CaptureAskReadSnapshotOptions): Promise<CapturedAskReadSnapshot>;
278
+
279
+ type ContextualAskJobEventListener = (event: AskJobEvent) => void;
280
+ interface ContextualAskManager {
281
+ cancel(jobId: string): AskJobSnapshot;
282
+ capability(signal: AbortSignal): Promise<ContextualAskCapability>;
283
+ close(): Promise<void>;
284
+ create(request: AskJobCreateRequest): Promise<AskJobSnapshot>;
285
+ events(jobId: string, afterSequence?: number): readonly AskJobEvent[];
286
+ result(jobId: string): Promise<AskJobResultResponse>;
287
+ snapshot(jobId: string): AskJobSnapshot;
288
+ subscribe(jobId: string, listener: ContextualAskJobEventListener): () => void;
289
+ }
290
+ interface ContextualAskManagerDependencies {
291
+ readonly captureSnapshot: typeof captureAskReadSnapshot;
292
+ readonly createId: () => string;
293
+ readonly now: () => Date;
294
+ }
295
+ interface CreateContextualAskManagerOptions {
296
+ readonly coordinator: WorkspaceActivityCoordinator;
297
+ readonly enabled: boolean;
298
+ readonly executors?: readonly ContextualAskExecutor[];
299
+ readonly registry: SourceRegistry;
300
+ readonly root: string;
301
+ readonly dependencies?: Partial<ContextualAskManagerDependencies>;
302
+ }
303
+ declare function createContextualAskManager(options: CreateContextualAskManagerOptions): ContextualAskManager;
304
+
305
+ declare class ContextualAskError extends Error {
306
+ readonly code: ContextualAskErrorCode;
307
+ constructor(code: ContextualAskErrorCode, options?: Readonly<{
308
+ cause?: unknown;
309
+ }>);
310
+ }
311
+
312
+ interface CreateConfiguredKeyAskExecutorsOptions {
313
+ readonly ai: ResolvedAiOptions;
314
+ readonly environment: Readonly<Record<string, string | undefined>>;
315
+ readonly fetch?: typeof globalThis.fetch;
316
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
317
+ }
318
+ /** Builds one isolated read-only Ask executor per configured Provider/model pair. */
319
+ declare function createConfiguredKeyAskExecutors(options: CreateConfiguredKeyAskExecutorsOptions): readonly ContextualAskExecutor[];
320
+
321
+ interface ComposeContextualAskExecutorsOptions {
322
+ readonly configuredKey: readonly ContextualAskExecutor[];
323
+ readonly managedCodex: ContextualAskExecutor;
324
+ readonly defaultExecutor?: ContextualAskExecutorPreference;
325
+ }
326
+ /** Orders independent executor implementations without coupling dev-server to Codex. */
327
+ declare function composeContextualAskExecutors(options: ComposeContextualAskExecutorsOptions): readonly ContextualAskExecutor[];
328
+
238
329
  interface SpotPatchSession {
239
330
  readonly id: string;
240
331
  readonly token: string;
@@ -264,6 +355,7 @@ interface SpotPatchServerLogger {
264
355
  }
265
356
  interface CreateMiddlewareOptions {
266
357
  readonly agentManager?: AgentJobManager;
358
+ readonly contextualAskManager?: ContextualAskManager;
267
359
  readonly bootstrap?: RuntimeBootstrapOptions;
268
360
  readonly editorLauncher?: EditorLauncher;
269
361
  readonly externalAgentControl?: ExternalAgentControlPort;
@@ -280,6 +372,18 @@ declare function readJsonRequestBody(request: IncomingMessage, maximumBytes?: nu
280
372
 
281
373
  declare function isLoopbackHostname(hostname: string): boolean;
282
374
 
375
+ type ContextualAskRoute = Readonly<{
376
+ kind: "capability";
377
+ }> | Readonly<{
378
+ kind: "create";
379
+ }> | Readonly<{
380
+ kind: "job";
381
+ action: "events" | "result" | "cancel";
382
+ jobId: string;
383
+ }>;
384
+ declare function matchContextualAskPath(pathname: string): ContextualAskRoute | undefined;
385
+ declare function handleContextualAskRequest(request: IncomingMessage, response: ServerResponse, route: ContextualAskRoute, manager: ContextualAskManager | undefined, logger?: SpotPatchServerLogger): Promise<void>;
386
+
283
387
  interface SourceRegistrationServiceOptions {
284
388
  readonly internalSecret: string;
285
389
  readonly options: ResolvedSpotPatchOptions;
@@ -310,6 +414,7 @@ interface SerializedSpotPatchOptions {
310
414
  readonly budget: Readonly<ContextBudget>;
311
415
  readonly debug: boolean;
312
416
  readonly dataFlow: false | SpotPatchDataFlowOptions;
417
+ readonly contextualAsk: ContextualAskOptions;
313
418
  readonly editor: SpotPatchEditorPreference;
314
419
  readonly enabled: boolean;
315
420
  readonly externalAgent: boolean;
@@ -323,4 +428,4 @@ interface SerializedSpotPatchOptions {
323
428
  declare function serializeResolvedSpotPatchOptions(options: ResolvedSpotPatchOptions): SerializedSpotPatchOptions;
324
429
  declare function parseSerializedSpotPatchOptions(value: unknown): ResolvedSpotPatchOptions;
325
430
 
326
- export { type AgentJobEventListener, type AgentJobManager, type CreateAgentJobManagerOptions, type CreateExternalHandoffServiceOptions, type CreateMiddlewareOptions, DEFAULT_EXCLUDE, DEFAULT_OPTIONS, type DiscoverProjectValidationCheckOptions, type EnvironmentAiConfiguration, type ExternalAgentControlPort, type ExternalHandoffService, type FilterEntry, type IntegrationFileChange, type IntegrationPlan, type ResolveManagedExecutionValidationOptions, type ResolveProjectOptionsInput, type ResolveProjectValidationChecksOptions, type ResolvedManagedExecutionValidation, type ResolvedRuntimeBootstrapOptions, type ResolvedSpotPatchDataFlowOptions, type ResolvedSpotPatchOptions, type RuntimeBootstrapOptions, type SerializedFilterEntry, type SerializedSpotPatchOptions, type SimpleAiOptions, type SourceRegistrationHandler, type SourceRegistrationService, type SourceRegistrationServiceOptions, type SourceRegistry, type SpotPatchAiOptions, type SpotPatchDataFlowOptions, type SpotPatchMiddleware, type SpotPatchNext, type SpotPatchOptions, type SpotPatchServerLogger, type SpotPatchSession, applyIntegrationPlan, createAgentJobManager, createExternalHandoffService, createIntegrationFileChange, createRuntimeAiConfig, createRuntimeDataFlowConfig, createSession, createSourceRegistrationService, createSourceRegistry, createSpotPatchMiddleware, discoverProjectValidationCheck, integrationPathExists, isLoopbackHostname, parseSerializedSpotPatchOptions, readIntegrationFile, readJsonRequestBody, readRuntimeBootstrap, resolveCredentialEnvironment, resolveEnvironmentAiConfiguration, resolveManagedExecutionValidation, resolveOptions, resolveProjectOptions, resolveProjectValidationChecks, resolveRuntimeBootstrapOptions, serializeResolvedSpotPatchOptions };
431
+ export { type AgentJobEventListener, type AgentJobManager, type CaptureAskReadSnapshotOptions, type CapturedAskReadSnapshot, type ComposeContextualAskExecutorsOptions, ContextualAskError, type ContextualAskJobEventListener, type ContextualAskManager, type ContextualAskRoute, type CreateAgentJobManagerOptions, type CreateConfiguredKeyAskExecutorsOptions, type CreateContextualAskManagerOptions, type CreateExternalHandoffServiceOptions, type CreateMiddlewareOptions, DEFAULT_EXCLUDE, DEFAULT_OPTIONS, type DiscoverProjectValidationCheckOptions, type EnvironmentAiConfiguration, type ExternalAgentControlPort, type ExternalHandoffService, type FilterEntry, type IntegrationFileChange, type IntegrationPlan, type ResolveManagedExecutionValidationOptions, type ResolveProjectOptionsInput, type ResolveProjectValidationChecksOptions, type ResolvedContextualAskOptions, type ResolvedManagedExecutionValidation, type ResolvedRuntimeBootstrapOptions, type ResolvedSpotPatchDataFlowOptions, type ResolvedSpotPatchOptions, type RuntimeBootstrapOptions, type SerializedFilterEntry, type SerializedSpotPatchOptions, type SimpleAiOptions, type SourceRegistrationHandler, type SourceRegistrationService, type SourceRegistrationServiceOptions, type SourceRegistry, type SpotPatchAiOptions, type SpotPatchDataFlowOptions, type SpotPatchMiddleware, type SpotPatchNext, type SpotPatchOptions, type SpotPatchServerLogger, type SpotPatchSession, type WorkspaceActivityCoordinator, type WorkspaceActivityKind, type WorkspaceActivityLease, applyIntegrationPlan, captureAskReadSnapshot, composeContextualAskExecutors, createAgentJobManager, createConfiguredKeyAskExecutors, createContextualAskManager, createExternalHandoffService, createIntegrationFileChange, createRuntimeAiConfig, createRuntimeDataFlowConfig, createSession, createSourceRegistrationService, createSourceRegistry, createSpotPatchMiddleware, createWorkspaceActivityCoordinator, discoverProjectValidationCheck, handleContextualAskRequest, integrationPathExists, isLoopbackHostname, matchContextualAskPath, parseSerializedSpotPatchOptions, readIntegrationFile, readJsonRequestBody, readRuntimeBootstrap, resolveCredentialEnvironment, resolveEnvironmentAiConfiguration, resolveManagedExecutionValidation, resolveOptions, resolveProjectOptions, resolveProjectValidationChecks, resolveRuntimeBootstrapOptions, serializeResolvedSpotPatchOptions };