@github/copilot 0.0.333-5 → 0.0.333-7

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/sdk/index.d.ts ADDED
@@ -0,0 +1,1855 @@
1
+ import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import * as z from 'zod';
4
+
5
+ export declare class Agent {
6
+ static name: string;
7
+ static description: string;
8
+ protected options: AgentOptions;
9
+ protected logger: RunnerLogger;
10
+ protected workingDir: string;
11
+ protected session: Session;
12
+ constructor(options: AgentOptions);
13
+ /**
14
+ * Execute the agent with the given prompt.
15
+ * This method runs the full agentic loop with the execution engine.
16
+ *
17
+ * @param prompt - The user's prompt/instruction
18
+ * @returns AsyncGenerator of SDKEvent objects
19
+ */
20
+ query(prompt: string): AsyncGenerator<SDKEvent>;
21
+ /**
22
+ * Build agent model string from provider config
23
+ */
24
+ private buildAgentModelString;
25
+ /**
26
+ * Apply tool filtering based on allowedTools/disabledTools
27
+ */
28
+ private applyToolFiltering;
29
+ /**
30
+ * Translate internal Event objects to SDK events
31
+ */
32
+ private translateEvent;
33
+ }
34
+
35
+ export declare interface AgentOptions {
36
+ modelProvider: ModelProvider;
37
+ session?: Session;
38
+ abortController?: AbortController;
39
+ allowedTools?: string[];
40
+ disabledTools?: string[];
41
+ requestPermission?: (permissionRequest: PermissionRequest) => Promise<PermissionRequestResult>;
42
+ mcpServers?: Record<string, MCPServerConfig>;
43
+ hooks?: QueryHooks;
44
+ logger?: RunnerLogger;
45
+ workingDirectory?: string;
46
+ env?: Record<string, string>;
47
+ additionalDirectories?: string[];
48
+ }
49
+
50
+ /**
51
+ * Base interface for all hook inputs
52
+ */
53
+ export declare interface BaseHookInput {
54
+ timestamp: number;
55
+ cwd: string;
56
+ }
57
+
58
+ export declare abstract class BaseLogger implements RunnerLogger {
59
+ protected logLevel?: LogLevel;
60
+ protected debugEnvironmentVariables?: string[];
61
+ private secretFilter;
62
+ constructor(logLevel?: LogLevel, debugEnvironmentVariables?: string[]);
63
+ filterSecrets(messageOrError: string | Error): string | Error;
64
+ /**
65
+ * Returns true if the log level is not set, or the log level is set and the level is enabled.
66
+ */
67
+ shouldLog(level: LogLevel): boolean;
68
+ isDebug(): boolean;
69
+ abstract log(message: string): void;
70
+ abstract info(message: string): void;
71
+ abstract debug(message: string): void;
72
+ abstract notice(message: string | Error): void;
73
+ abstract warning(message: string | Error): void;
74
+ abstract error(message: string | Error): void;
75
+ abstract startGroup(name: string, level?: LogLevel): void;
76
+ abstract endGroup(level?: LogLevel): void;
77
+ }
78
+
79
+ export declare abstract class BaseSession implements Session {
80
+ readonly id: string;
81
+ readonly startTime: Date;
82
+ readonly selectedModel?: string;
83
+ protected logger: RunnerLogger;
84
+ constructor({ id, startTime, selectedModel }?: Partial<SessionMetadata>, logger?: RunnerLogger);
85
+ abstract getChatMessages(): Promise<ChatCompletionMessageParam[]>;
86
+ abstract addChatMessage(message: ChatCompletionMessageParam): Promise<void>;
87
+ abstract onAbort(): Promise<void>;
88
+ }
89
+
90
+ declare type BinaryResult = {
91
+ data: string;
92
+ mimeType: string;
93
+ type: string;
94
+ };
95
+
96
+ declare type Command = {
97
+ readonly identifier: string;
98
+ readonly readOnly: boolean;
99
+ };
100
+
101
+ export declare class CompoundLogger implements RunnerLogger {
102
+ readonly loggers: RunnerLogger[];
103
+ constructor(loggers: RunnerLogger[]);
104
+ isDebug(): boolean;
105
+ debug(message: string): void;
106
+ log(message: string): void;
107
+ info(message: string): void;
108
+ notice(message: string | Error): void;
109
+ warning(message: string | Error): void;
110
+ error(message: string | Error): void;
111
+ startGroup(name: string, level?: LogLevel): void;
112
+ endGroup(level?: LogLevel): void;
113
+ }
114
+
115
+ export declare class ConsoleLogger extends BaseLogger implements RunnerLogger {
116
+ constructor(logLevel?: LogLevel, debugEnvironmentVariables?: string[]);
117
+ log(message: string): void;
118
+ debug(message: string): void;
119
+ info(message: string): void;
120
+ notice(message: string | Error): void;
121
+ warning(message: string | Error): void;
122
+ error(message: string | Error): void;
123
+ startGroup(name: string, level?: LogLevel): void;
124
+ endGroup(level?: LogLevel): void;
125
+ }
126
+
127
+ declare enum ContentFilterMode {
128
+ None = "none",
129
+ Markdown = "markdown",
130
+ HiddenCharacters = "hidden_characters"
131
+ }
132
+
133
+ /**
134
+ * Adapter that wraps the CLI SessionManager to implement the SDK Session interface
135
+ */
136
+ export declare class CopilotCLISession extends BaseSession {
137
+ private cliSessionManager;
138
+ constructor(cliSessionManager: SessionManager_2, logger?: RunnerLogger);
139
+ getChatMessages(): Promise<ChatCompletionMessageParam[]>;
140
+ addChatMessage(message: ChatCompletionMessageParam): Promise<void>;
141
+ onAbort(): Promise<void>;
142
+ /**
143
+ * Save this session immediately
144
+ */
145
+ save(): Promise<void>;
146
+ }
147
+
148
+ /**
149
+ * Adapter that wraps the CLI SessionManager to implement the SDK SessionManager interface
150
+ */
151
+ export declare class CopilotCLISessionManager implements SessionManager {
152
+ private logger;
153
+ constructor(options?: SessionManagerOptions);
154
+ createSession(): Promise<CopilotCLISession>;
155
+ getLastSession(): Promise<CopilotCLISession>;
156
+ getSession(id: string): Promise<CopilotCLISession>;
157
+ listSessions(): Promise<SessionMetadata[]>;
158
+ saveSession(session: CopilotCLISession): Promise<void>;
159
+ deleteSession(_session: CopilotCLISession): Promise<void>;
160
+ }
161
+
162
+ export declare type ErrorOccurredHook = (input: ErrorOccurredHookInput) => Promise<ErrorOccurredHookOutput | void>;
163
+
164
+ /**
165
+ * Error occurred hook types
166
+ */
167
+ export declare interface ErrorOccurredHookInput extends BaseHookInput {
168
+ error: Error;
169
+ errorContext: "model_call" | "tool_execution" | "system" | "user_input";
170
+ recoverable: boolean;
171
+ }
172
+
173
+ export declare interface ErrorOccurredHookOutput {
174
+ suppressOutput?: boolean;
175
+ errorHandling?: "retry" | "skip" | "abort";
176
+ retryCount?: number;
177
+ userNotification?: string;
178
+ }
179
+
180
+ export declare function executeHooks<TInput extends BaseHookInput, TOutput>(hooks: ((input: TInput) => Promise<TOutput | void>)[] | undefined, input: TInput, logger: RunnerLogger): Promise<void | TOutput>;
181
+
182
+ export declare class FileLogger extends BaseLogger implements RunnerLogger {
183
+ private readonly filePath;
184
+ /** Promise that resolves when pending writes are complete. Used to serialize
185
+ * writes and for testing. */
186
+ writeQueue: Promise<void>;
187
+ constructor(filePath: string, logLevel?: LogLevel, debugEnvironmentVariables?: string[]);
188
+ log(message: string): void;
189
+ debug(message: string): void;
190
+ info(message: string): void;
191
+ notice(message: string | Error): void;
192
+ warning(message: string | Error): void;
193
+ error(message: string | Error): void;
194
+ startGroup(name: string, level?: LogLevel): void;
195
+ endGroup(level?: LogLevel): void;
196
+ write(category: string, message: string): void;
197
+ private performWrite;
198
+ }
199
+
200
+ /**
201
+ * Returns true if the DEBUG or COPILOT_AGENT_DEBUG environment variable is set to 1 or true (case-insensitive).
202
+ * If additionalVariables are provided, they are also checked.
203
+ * @param additionalVariables Additional environment variables to check for debug logging.
204
+ */
205
+ export declare function isDebugEnvironment(...additionalVariables: string[]): boolean;
206
+
207
+ export declare enum LogLevel {
208
+ None = 0,
209
+ Error = 1,// 1
210
+ Warning = 2,// 2
211
+ Info = 4,// 4
212
+ Debug = 8,// 8
213
+ All = 15,
214
+ Default = 7
215
+ }
216
+
217
+ declare interface MCPInMemoryServerConfig extends MCPServerConfigBase {
218
+ type: "memory";
219
+ serverInstance: McpServer;
220
+ }
221
+
222
+ declare interface MCPLocalServerConfig extends MCPServerConfigBase {
223
+ type?: "local" | "stdio";
224
+ command: string;
225
+ args: string[];
226
+ /**
227
+ * An object of the environment variables to pass to the server. Key is whats sent to the MCP Server. Value is whats read from the actions environment. Empty means no env vars passed.
228
+ */
229
+ env?: Record<string, string>;
230
+ }
231
+
232
+ /**
233
+ * A permission request for invoking an MCP tool.
234
+ */
235
+ declare type MCPPermissionRequest = {
236
+ readonly kind: "mcp";
237
+ /** The name of the MCP Server being targeted e.g. "github-mcp-server" */
238
+ readonly serverName: string;
239
+ /** The name of the tool being targeted e.g. "list_issues" */
240
+ readonly toolName: string;
241
+ /** The title of the tool being targeted e.g. "List Issues" */
242
+ readonly toolTitle: string;
243
+ /**
244
+ * The _hopefully_ JSON arguments that will be passed to the MCP tool.
245
+ *
246
+ * This should be an object, but it's not parsed before this point so we can't guarantee that.
247
+ * */
248
+ readonly args: unknown;
249
+ /**
250
+ * Whether the tool is read-only (e.g. a `view` operation) or not (e.g. an `edit` operation).
251
+ */
252
+ readonly readOnly: boolean;
253
+ };
254
+
255
+ declare interface MCPRemoteServerConfig extends MCPServerConfigBase {
256
+ type: "http" | "sse";
257
+ /**
258
+ * URL of the remote server
259
+ * NOTE: this has to be converted to a URL object before giving to transport.
260
+ * TransportFactory will handle this conversion.
261
+ */
262
+ url: string;
263
+ /**
264
+ * Optional. HTTP headers to include in requests to the remote server.
265
+ * This can be used for authentication or other purposes.
266
+ * For example, you might include an Authorization header.
267
+ */
268
+ headers?: Record<string, string>;
269
+ }
270
+
271
+ declare type MCPServerConfig = MCPLocalServerConfig | MCPRemoteServerConfig | MCPInMemoryServerConfig;
272
+
273
+ declare interface MCPServerConfigBase {
274
+ /**
275
+ * List of tools to include from this server. [] means none. "*" means all.
276
+ */
277
+ tools: string[];
278
+ /**
279
+ * Indicates "remote" or "local" server type.
280
+ * If not specified, defaults to "local".
281
+ */
282
+ type?: string;
283
+ /**
284
+ * Optional. Denotes if this is a MCP server we have defined to be used when
285
+ * the user has not provided their own MCP server config.
286
+ *
287
+ * Marked optional as configs coming from users will/should not have this set. Defaults to `false`.
288
+ */
289
+ isDefaultServer?: boolean;
290
+ /**
291
+ * Optional. Either a content filter mode for all tools from this server, or a map of tool name to content filter mode for the tool with that name.
292
+ * If not specified, defaults to "hidden_characters"
293
+ */
294
+ filterMapping?: Record<string, ContentFilterMode> | ContentFilterMode;
295
+ }
296
+
297
+ export declare interface ModelProvider {
298
+ type: "openai" | "anthropic" | "copilot";
299
+ model: string;
300
+ apiKey?: string;
301
+ }
302
+
303
+ export declare class NoopLogger extends BaseLogger implements RunnerLogger {
304
+ constructor();
305
+ debug(_message: string): void;
306
+ log(_message: string): void;
307
+ info(_message: string): void;
308
+ notice(_message: string | Error): void;
309
+ warning(_message: string | Error): void;
310
+ error(_message: string | Error): void;
311
+ startGroup(_name: string, _level?: LogLevel): void;
312
+ endGroup(_level?: LogLevel): void;
313
+ }
314
+
315
+ declare type OnTimelineEntriesChange = (entries: TimelineEntry[]) => void;
316
+
317
+ /**
318
+ * A permission request which will be used to check tool or path usage against config and/or request user approval.
319
+ */
320
+ declare type PermissionRequest = ShellPermissionRequest | WritePermissionRequest | MCPPermissionRequest;
321
+
322
+ /**
323
+ * The result of requesting permissions.
324
+ */
325
+ declare type PermissionRequestResult = {
326
+ readonly kind: "approved";
327
+ } | {
328
+ readonly kind: "denied-by-rules";
329
+ rules: ReadonlyArray<Rule>;
330
+ } | {
331
+ readonly kind: "denied-no-approval-rule-and-could-not-request-from-user";
332
+ } | {
333
+ readonly kind: "denied-interactively-by-user";
334
+ };
335
+
336
+ /**
337
+ * This is just a type to warn that there's a good chance it's not a real path, because
338
+ * it was _very_ heuristically parsed out of a command.
339
+ */
340
+ declare type PossiblePath = string;
341
+
342
+ export declare type PostToolUseHook = (input: PostToolUseHookInput) => Promise<PostToolUseHookOutput | void>;
343
+
344
+ /**
345
+ * Post-tool use hook types
346
+ */
347
+ export declare interface PostToolUseHookInput extends BaseHookInput {
348
+ toolName: string;
349
+ toolArgs: unknown;
350
+ toolResult: ToolResultExpanded;
351
+ }
352
+
353
+ export declare interface PostToolUseHookOutput {
354
+ modifiedResult?: ToolResultExpanded;
355
+ additionalContext?: string;
356
+ suppressOutput?: boolean;
357
+ }
358
+
359
+ export declare type PreToolUseHook = (input: PreToolUseHookInput) => Promise<PreToolUseHookOutput | void>;
360
+
361
+ /**
362
+ * Pre-tool use hook types
363
+ */
364
+ export declare interface PreToolUseHookInput extends BaseHookInput {
365
+ toolName: string;
366
+ toolArgs: unknown;
367
+ }
368
+
369
+ export declare interface PreToolUseHookOutput {
370
+ permissionDecision?: "allow" | "deny" | "ask";
371
+ permissionDecisionReason?: string;
372
+ modifiedArgs?: unknown;
373
+ additionalContext?: string;
374
+ suppressOutput?: boolean;
375
+ }
376
+
377
+ /**
378
+ * Functional query API that provides a Claude Code-inspired interface.
379
+ * This is a thin wrapper around the Agent class for simple use cases.
380
+ *
381
+ * @param options - Query configuration options
382
+ * @returns AsyncGenerator of SDKEvent objects
383
+ */
384
+ export declare function query(options: QueryOptions): AsyncIterable<SDKEvent>;
385
+
386
+ /**
387
+ * Hook system with arrays of specific hook callbacks
388
+ */
389
+ export declare interface QueryHooks {
390
+ preToolUse?: PreToolUseHook[];
391
+ postToolUse?: PostToolUseHook[];
392
+ userPromptSubmitted?: UserPromptSubmittedHook[];
393
+ sessionStart?: SessionStartHook[];
394
+ sessionEnd?: SessionEndHook[];
395
+ errorOccurred?: ErrorOccurredHook[];
396
+ }
397
+
398
+ export declare type QueryOptions = AgentOptions & {
399
+ prompt: string;
400
+ };
401
+
402
+ /**
403
+ * A Rule defines a pattern for matching permission requests.
404
+ *
405
+ * It is unfortunately generically named because it is intended to match across
406
+ * different types of tool uses, e.g. `Shell(touch)` or `GitHubMCP(list_issues)`,
407
+ * `view(.env-secrets)`
408
+ */
409
+ declare type Rule = {
410
+ /**
411
+ * The kind of rule that should be matched e.g. `Shell` or `GitHubMCP`.
412
+ */
413
+ readonly kind: string;
414
+ /**
415
+ * If null, matches all arguments to the kind.
416
+ */
417
+ readonly argument: string | null;
418
+ };
419
+
420
+ export declare interface RunnerLogger {
421
+ /**
422
+ * Log a message ignoring the configured log level.
423
+ * This is useful for logging messages that should always be logged, regardless of the log level.
424
+ * @param message The message to log.
425
+ */
426
+ log(message: string): void;
427
+ /**
428
+ * Returns true if the environment is set to debug.
429
+ * Note: This is not the same as the log level being set to debug.
430
+ */
431
+ isDebug(): boolean;
432
+ /**
433
+ * Log a debug message. This is only logged if the log level is set to debug.
434
+ * @param message The message to log.
435
+ */
436
+ debug(message: string): void;
437
+ /**
438
+ * Log an info message. This is only logged if the log level is set to info or debug.
439
+ * @param message The message to log.
440
+ */
441
+ info(message: string): void;
442
+ /**
443
+ * Log a notice message. This is only logged if the log level is set to warning, info, or debug,
444
+ * but logs using the logger's info method.
445
+ * This is useful for logging messages that are not errors, but are important enough to log on
446
+ * less verbose log levels.
447
+ * @param message The message to log.
448
+ */
449
+ notice(message: string | Error): void;
450
+ /**
451
+ * Log a warning message. This is only logged if the log level is set to warning, info, or debug
452
+ * @param message The message to log.
453
+ */
454
+ warning(message: string | Error): void;
455
+ /**
456
+ * Log an error message. This is only logged if the log level is set to error, warning, info, or debug
457
+ * @param message The message to log.
458
+ */
459
+ error(message: string | Error): void;
460
+ /**
461
+ * Log a message that starts a new group.
462
+ * @param name The name of the group.
463
+ * @param level The log level of the group. Defaults to info.
464
+ */
465
+ startGroup(name: string, level?: LogLevel): void;
466
+ /**
467
+ * Log a message that ends the current group.
468
+ * @param level The log level of the group. Defaults to info.
469
+ */
470
+ endGroup(level?: LogLevel): void;
471
+ }
472
+
473
+ /**
474
+ * SDK Event types that agents emit
475
+ */
476
+ export declare type SDKEvent = {
477
+ type: "thinking";
478
+ content: string;
479
+ } | {
480
+ type: "message";
481
+ content: string;
482
+ role: "assistant" | "user";
483
+ } | {
484
+ type: "tool_use";
485
+ toolName: string;
486
+ args: unknown;
487
+ toolCallId?: string;
488
+ } | {
489
+ type: "tool_result";
490
+ toolName: string;
491
+ result: ToolResultExpanded;
492
+ toolCallId?: string;
493
+ } | {
494
+ type: "error";
495
+ error: Error;
496
+ } | {
497
+ type: "complete";
498
+ finalMessage?: string;
499
+ };
500
+
501
+ /**
502
+ * Session interface for managing conversation state
503
+ */
504
+ export declare interface Session extends SessionMetadata {
505
+ /**
506
+ * Get all chat messages in the session (for model context)
507
+ */
508
+ getChatMessages(): Promise<ChatCompletionMessageParam[]>;
509
+ /**
510
+ * Add a chat message to the session
511
+ */
512
+ addChatMessage(message: ChatCompletionMessageParam): Promise<void>;
513
+ /**
514
+ * Handle abortion/interruption of operations (e.g., complete orphaned tool calls)
515
+ */
516
+ onAbort(): Promise<void>;
517
+ }
518
+
519
+ export declare type SessionEndHook = (input: SessionEndHookInput) => Promise<SessionEndHookOutput | void>;
520
+
521
+ /**
522
+ * Session end hook types
523
+ */
524
+ export declare interface SessionEndHookInput extends BaseHookInput {
525
+ reason: "complete" | "error" | "abort" | "timeout" | "user_exit";
526
+ finalMessage?: string;
527
+ error?: Error;
528
+ }
529
+
530
+ export declare interface SessionEndHookOutput {
531
+ suppressOutput?: boolean;
532
+ cleanupActions?: string[];
533
+ sessionSummary?: string;
534
+ }
535
+
536
+ declare type SessionInitMode = {
537
+ kind: "new";
538
+ } | {
539
+ kind: "resume-last";
540
+ } | {
541
+ kind: "resume";
542
+ sessionId: string;
543
+ } | {
544
+ kind: "resume-with-picker";
545
+ };
546
+
547
+ /**
548
+ * SessionManager interface for managing multiple sessions
549
+ */
550
+ export declare interface SessionManager<TSession extends Session = Session> {
551
+ /**
552
+ * Create a new session
553
+ */
554
+ createSession(): Promise<TSession>;
555
+ /**
556
+ * Get the last (most recent) session
557
+ */
558
+ getLastSession(): Promise<TSession>;
559
+ /**
560
+ * Get a specific session by ID
561
+ */
562
+ getSession(id: string): Promise<TSession>;
563
+ /**
564
+ * List all available sessions
565
+ */
566
+ listSessions(): Promise<SessionMetadata[]>;
567
+ /**
568
+ * Save session state immediately
569
+ */
570
+ saveSession(session: TSession): Promise<void>;
571
+ /**
572
+ * Delete a session
573
+ * @param options Options including session to delete
574
+ */
575
+ deleteSession(session: TSession): Promise<void>;
576
+ }
577
+
578
+ declare class SessionManager_2 {
579
+ private currentSession;
580
+ private onTimelineEntriesChangeCallback;
581
+ private debounceSave;
582
+ private logger;
583
+ private needsSessionPicker;
584
+ private autoSaveEnabled;
585
+ static create(initMode: SessionInitMode): Promise<SessionManager_2>;
586
+ /**
587
+ * Check if there are multiple sessions available for resuming.
588
+ * @returns true if there are multiple sessions, false otherwise
589
+ */
590
+ static hasMultipleSessions(): Promise<boolean>;
591
+ constructor();
592
+ /**
593
+ * Set the logger for the session manager.
594
+ * @param logger The logger to use for logging.
595
+ */
596
+ setLogger(logger: RunnerLogger): void;
597
+ /**
598
+ * Get the current logger for the session manager.
599
+ * @returns The current logger.
600
+ */
601
+ getLogger(): RunnerLogger;
602
+ /**
603
+ * Check if the session manager is waiting for session picker.
604
+ * @returns true if session picker is needed
605
+ */
606
+ isWaitingForSessionPicker(): boolean;
607
+ /**
608
+ * Clear the session picker flag and load a specific session.
609
+ * @param sessionId The session ID to load
610
+ */
611
+ selectSession(sessionId: string): Promise<void>;
612
+ /**
613
+ * Set a callback to be notified when the timeline entries change
614
+ * @param callback The callback to be called with the new timeline entries
615
+ */
616
+ setOnTimelineEntriesChangeCallback(callback: OnTimelineEntriesChange | null): void;
617
+ /**
618
+ * Notify listeners of changes to the timeline entries. It passes a copy
619
+ * of the timeline entries array.
620
+ */
621
+ private notifyTimelineEntriesChange;
622
+ /**
623
+ * Enable auto-saving of the session after a new timeline entry or chat
624
+ * message is added to it.
625
+ */
626
+ enableAutoSave(): void;
627
+ /**
628
+ * Force save the current session immediately, bypassing any debouncing or auto-save logic.
629
+ */
630
+ forceSave(): Promise<void>;
631
+ /** Schedule a save of the current session. Debounced. */
632
+ private scheduleSave;
633
+ /**
634
+ * Get the timeline entries for the current session
635
+ * @returns An array of timeline entries
636
+ */
637
+ getTimelineEntries(): (({
638
+ type: "copilot";
639
+ text: string;
640
+ } | {
641
+ type: "error";
642
+ text: string;
643
+ } | {
644
+ type: "info";
645
+ text: string;
646
+ } | {
647
+ type: "user";
648
+ text: string;
649
+ expandedText?: string | undefined;
650
+ mentions?: {
651
+ type: "file" | "image" | "directory" | "unresolved";
652
+ displayText: string;
653
+ fullPath: string;
654
+ startIndex: number;
655
+ }[] | undefined;
656
+ imageAttachments?: {
657
+ type: "image_url";
658
+ image_url: {
659
+ url: string;
660
+ };
661
+ }[] | undefined;
662
+ } | {
663
+ name: string;
664
+ type: "tool_call_requested";
665
+ callId: string;
666
+ intentionSummary: string | null;
667
+ toolTitle?: string | undefined;
668
+ arguments?: unknown;
669
+ partialOutput?: string | undefined;
670
+ isHidden?: boolean | undefined;
671
+ isAlwaysExpanded?: boolean | undefined;
672
+ showNoContent?: boolean | undefined;
673
+ } | {
674
+ result: {
675
+ log: string;
676
+ type: "success";
677
+ markdown?: boolean | undefined;
678
+ } | {
679
+ log: string;
680
+ type: "failure";
681
+ markdown?: boolean | undefined;
682
+ } | {
683
+ type: "rejected";
684
+ markdown?: boolean | undefined;
685
+ } | {
686
+ log: string;
687
+ type: "denied";
688
+ markdown?: boolean | undefined;
689
+ };
690
+ name: string;
691
+ type: "tool_call_completed";
692
+ callId: string;
693
+ intentionSummary: string | null;
694
+ toolTitle?: string | undefined;
695
+ arguments?: unknown;
696
+ isHidden?: boolean | undefined;
697
+ isAlwaysExpanded?: boolean | undefined;
698
+ showNoContent?: boolean | undefined;
699
+ }) & {
700
+ id: string;
701
+ timestamp: Date;
702
+ })[];
703
+ /**
704
+ * Load a history session from disk.
705
+ * @param filename The name of the file to load
706
+ */
707
+ private loadHistorySession;
708
+ /**
709
+ * Save the current session to disk
710
+ * @param session The session to save
711
+ */
712
+ private saveHistorySession;
713
+ /**
714
+ * Get the ID of the current session.
715
+ * @returns The ID of the current session.
716
+ */
717
+ getCurrentSessionId(): string;
718
+ /**
719
+ * Get the start time of the current session.
720
+ * @returns The start time of the current session.
721
+ */
722
+ getCurrentSessionStartTime(): Date;
723
+ /**
724
+ * Get the selected model for the current session.
725
+ * @returns The selected model or undefined if not set.
726
+ */
727
+ getSelectedModel(): string | undefined;
728
+ /**
729
+ * Set the selected model for the current session.
730
+ * @param model The model to set.
731
+ */
732
+ setSelectedModel(model: SupportedModel): void;
733
+ /**
734
+ * Add a new timeline entry to the current session.
735
+ * @param entry The timeline entry to add.
736
+ */
737
+ addTimelineEntry(entry: TimelineEntryWithoutID): void;
738
+ /**
739
+ * Clear the conversation history and timeline entries for the current session.
740
+ * This removes all chat messages and timeline entries, effectively starting fresh
741
+ * while keeping the same session ID.
742
+ */
743
+ clearHistory(): void;
744
+ /**
745
+ * Add a new chat message to the current session.
746
+ * @param message The chat message to add.
747
+ */
748
+ addChatMessage(message: ChatCompletionMessageParam): void;
749
+ /**
750
+ * Get the chat context messages from the current session. These are used
751
+ * to feed the LLM with relevant context before the user's prompt.
752
+ * Excludes system messages but includes all other message types (user, assistant, tool, function, developer).
753
+ * @param maxEntries The maximum number of entries to return.
754
+ * @returns An array of chat context messages.
755
+ */
756
+ getChatContextMessages(): ChatCompletionMessageParam[];
757
+ /**
758
+ * Handle aborted operations by completing any pending tool calls with cancellation messages.
759
+ * This provides consistent behavior whether interrupted by kill vs Esc/Ctrl+C.
760
+ */
761
+ handleAbortedOperation(): void;
762
+ /**
763
+ * Handles orphaned tool calls by adding cancelled tool result messages.
764
+ * This prevents LLM errors when tool calls are interrupted and left incomplete.
765
+ * Since interruptions happen during tool execution, we only need to check the end of the conversation.
766
+ * Looks backwards through consecutive assistant messages with tool calls to handle multiple orphaned requests.
767
+ * @param messages The messages to process
768
+ * @returns Messages with cancelled tool results added for any orphaned tool calls
769
+ */
770
+ private completeOrphanedToolCalls;
771
+ /**
772
+ * Update the timeline entry for a tool call. This is used to update an existing
773
+ * tool call entry with the result of that tool call.
774
+ * @param result The result of the tool call.
775
+ */
776
+ updateToolCallTimelineEntryResult(result: ToolCallResult): void;
777
+ /**
778
+ * Update the timeline entry for a tool call. This is used to update an existing
779
+ * tool call entry with the partial output of that tool call.
780
+ * @param callId The ID of the tool call.
781
+ * @param output The partial output of the tool call.
782
+ */
783
+ updateToolCallTimelineEntryPartialOutput(callId: string, output: string): void;
784
+ /**
785
+ * Resume a specific session by session ID or filename, otherwise errors.
786
+ * @param sessionId The session ID (UUID) or filename part to resume. Supports partial matching.
787
+ */
788
+ private resumeSpecificSession;
789
+ /**
790
+ * Resume the last session, if one exists. Otherwise errors.
791
+ */
792
+ private resumeLastSession;
793
+ /** Generates a new history session with a random ID. */
794
+ private generateSession;
795
+ /** Generates a new session ID. */
796
+ private generateSessionId;
797
+ }
798
+
799
+ export declare interface SessionManagerOptions {
800
+ /**
801
+ * Logger instance for the session manager
802
+ */
803
+ logger?: RunnerLogger;
804
+ }
805
+
806
+ export declare interface SessionMetadata {
807
+ readonly id: string;
808
+ readonly startTime: Date;
809
+ readonly selectedModel?: string;
810
+ }
811
+
812
+ export declare type SessionStartHook = (input: SessionStartHookInput) => Promise<SessionStartHookOutput | void>;
813
+
814
+ /**
815
+ * Session start hook types
816
+ */
817
+ export declare interface SessionStartHookInput extends BaseHookInput {
818
+ source: "startup" | "resume" | "new";
819
+ initialPrompt?: string;
820
+ }
821
+
822
+ export declare interface SessionStartHookOutput {
823
+ additionalContext?: string;
824
+ modifiedConfig?: Record<string, unknown>;
825
+ }
826
+
827
+ /**
828
+ * A permission request for executing shell commands.
829
+ */
830
+ declare type ShellPermissionRequest = {
831
+ readonly kind: "shell";
832
+ /** The full command that the user is being asked to approve, e.g. `echo foo && find -exec ... && git push` */
833
+ readonly fullCommandText: string;
834
+ /** A concise summary of the user's intention, e.g. "Echo foo and find a file and then run git push" */
835
+ readonly intention: string;
836
+ /**
837
+ * The commands that are being invoked in the shell invocation.
838
+ *
839
+ * As a special case, which might be better represented in the type system, if there were no parsed commands
840
+ * e.g. `export VAR=value`, then this will have a single entry with identifier equal to the fullCommandText.
841
+ */
842
+ readonly commands: ReadonlyArray<Command>;
843
+ /**
844
+ * Possible file paths that the command might access.
845
+ *
846
+ * This is entirely heuristic, so it's pretty untrustworthy.
847
+ */
848
+ readonly possiblePaths: ReadonlyArray<PossiblePath>;
849
+ /**
850
+ * Indicates whether any command in the script has redirection to write to a file.
851
+ */
852
+ readonly hasWriteFileRedirection: boolean;
853
+ /**
854
+ * If there are complicated constructs, then persistent approval is not supported.
855
+ * e.g. `cat $(echo "foo")` should not be persistently approvable because it's hard
856
+ * for the user to understand the implications.
857
+ */
858
+ readonly canOfferSessionApproval: boolean;
859
+ };
860
+
861
+ /** List of supported models in order of precedence to be used as the default */
862
+ declare const SUPPORTED_MODELS: readonly ["claude-sonnet-4.5", "claude-sonnet-4", "gpt-5"];
863
+
864
+ declare type SupportedModel = (typeof SUPPORTED_MODELS)[number];
865
+
866
+ /**
867
+ * Telemetry emitted by the runtime contains properties and metrics. These are non-sensitive pieces
868
+ * of information. There are also restricted properties that must be used to store sensitive information.
869
+ */
870
+ declare type Telemetry = {
871
+ /**
872
+ * Telemetry properties can be used to store string props.
873
+ * WARNING: Do not put sensitive data here. Use restrictedProperties for that.
874
+ */
875
+ properties: Record<string, string | undefined>;
876
+ /**
877
+ * Restricted telemetry properties must be used to store sensitive string props. These props will only be available on the restricted kusto topics.
878
+ * Nonnullable so it is harder to overlook.
879
+ */
880
+ restrictedProperties: Record<string, string | undefined>;
881
+ /**
882
+ * The name of the telemetry event associated with the emitted runtime event.
883
+ */
884
+ metrics: Record<string, number | undefined>;
885
+ };
886
+
887
+ declare type TimelineEntry = z.infer<typeof TimelineEntrySchema>;
888
+
889
+ declare const TimelineEntrySchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
890
+ type: z.ZodLiteral<"copilot">;
891
+ text: z.ZodString;
892
+ }, "strip", z.ZodTypeAny, {
893
+ type: "copilot";
894
+ text: string;
895
+ }, {
896
+ type: "copilot";
897
+ text: string;
898
+ }>, z.ZodObject<{
899
+ type: z.ZodLiteral<"error">;
900
+ text: z.ZodString;
901
+ }, "strip", z.ZodTypeAny, {
902
+ type: "error";
903
+ text: string;
904
+ }, {
905
+ type: "error";
906
+ text: string;
907
+ }>, z.ZodObject<{
908
+ type: z.ZodLiteral<"info">;
909
+ text: z.ZodString;
910
+ }, "strip", z.ZodTypeAny, {
911
+ type: "info";
912
+ text: string;
913
+ }, {
914
+ type: "info";
915
+ text: string;
916
+ }>, z.ZodObject<{
917
+ type: z.ZodLiteral<"user">;
918
+ text: z.ZodString;
919
+ expandedText: z.ZodOptional<z.ZodString>;
920
+ mentions: z.ZodOptional<z.ZodArray<z.ZodObject<{
921
+ displayText: z.ZodString;
922
+ fullPath: z.ZodString;
923
+ type: z.ZodEnum<["file", "directory", "unresolved", "image"]>;
924
+ startIndex: z.ZodNumber;
925
+ }, "strip", z.ZodTypeAny, {
926
+ type: "file" | "image" | "directory" | "unresolved";
927
+ displayText: string;
928
+ fullPath: string;
929
+ startIndex: number;
930
+ }, {
931
+ type: "file" | "image" | "directory" | "unresolved";
932
+ displayText: string;
933
+ fullPath: string;
934
+ startIndex: number;
935
+ }>, "many">>;
936
+ imageAttachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
937
+ type: z.ZodLiteral<"image_url">;
938
+ image_url: z.ZodObject<{
939
+ url: z.ZodString;
940
+ }, "strip", z.ZodTypeAny, {
941
+ url: string;
942
+ }, {
943
+ url: string;
944
+ }>;
945
+ }, "strip", z.ZodTypeAny, {
946
+ type: "image_url";
947
+ image_url: {
948
+ url: string;
949
+ };
950
+ }, {
951
+ type: "image_url";
952
+ image_url: {
953
+ url: string;
954
+ };
955
+ }>, "many">>;
956
+ }, "strip", z.ZodTypeAny, {
957
+ type: "user";
958
+ text: string;
959
+ expandedText?: string | undefined;
960
+ mentions?: {
961
+ type: "file" | "image" | "directory" | "unresolved";
962
+ displayText: string;
963
+ fullPath: string;
964
+ startIndex: number;
965
+ }[] | undefined;
966
+ imageAttachments?: {
967
+ type: "image_url";
968
+ image_url: {
969
+ url: string;
970
+ };
971
+ }[] | undefined;
972
+ }, {
973
+ type: "user";
974
+ text: string;
975
+ expandedText?: string | undefined;
976
+ mentions?: {
977
+ type: "file" | "image" | "directory" | "unresolved";
978
+ displayText: string;
979
+ fullPath: string;
980
+ startIndex: number;
981
+ }[] | undefined;
982
+ imageAttachments?: {
983
+ type: "image_url";
984
+ image_url: {
985
+ url: string;
986
+ };
987
+ }[] | undefined;
988
+ }>, z.ZodObject<{
989
+ type: z.ZodLiteral<"tool_call_requested">;
990
+ callId: z.ZodString;
991
+ name: z.ZodString;
992
+ toolTitle: z.ZodOptional<z.ZodString>;
993
+ intentionSummary: z.ZodNullable<z.ZodString>;
994
+ arguments: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
995
+ command: z.ZodString;
996
+ description: z.ZodString;
997
+ timeout: z.ZodOptional<z.ZodNumber>;
998
+ sessionId: z.ZodOptional<z.ZodString>;
999
+ async: z.ZodOptional<z.ZodBoolean>;
1000
+ }, "strip", z.ZodTypeAny, {
1001
+ command: string;
1002
+ description: string;
1003
+ sessionId?: string | undefined;
1004
+ timeout?: number | undefined;
1005
+ async?: boolean | undefined;
1006
+ }, {
1007
+ command: string;
1008
+ description: string;
1009
+ sessionId?: string | undefined;
1010
+ timeout?: number | undefined;
1011
+ async?: boolean | undefined;
1012
+ }>, z.ZodObject<{
1013
+ sessionId: z.ZodString;
1014
+ input: z.ZodString;
1015
+ delay: z.ZodOptional<z.ZodNumber>;
1016
+ }, "strip", z.ZodTypeAny, {
1017
+ input: string;
1018
+ sessionId: string;
1019
+ delay?: number | undefined;
1020
+ }, {
1021
+ input: string;
1022
+ sessionId: string;
1023
+ delay?: number | undefined;
1024
+ }>, z.ZodObject<{
1025
+ sessionId: z.ZodString;
1026
+ delay: z.ZodNumber;
1027
+ }, "strip", z.ZodTypeAny, {
1028
+ sessionId: string;
1029
+ delay: number;
1030
+ }, {
1031
+ sessionId: string;
1032
+ delay: number;
1033
+ }>, z.ZodObject<{
1034
+ sessionId: z.ZodString;
1035
+ }, "strip", z.ZodTypeAny, {
1036
+ sessionId: string;
1037
+ }, {
1038
+ sessionId: string;
1039
+ }>]>, z.ZodDiscriminatedUnion<"command", [z.ZodObject<{
1040
+ command: z.ZodLiteral<"view">;
1041
+ path: z.ZodString;
1042
+ view_range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1043
+ }, "strip", z.ZodTypeAny, {
1044
+ path: string;
1045
+ command: "view";
1046
+ view_range?: [number, number] | undefined;
1047
+ }, {
1048
+ path: string;
1049
+ command: "view";
1050
+ view_range?: [number, number] | undefined;
1051
+ }>, z.ZodObject<{
1052
+ command: z.ZodLiteral<"create">;
1053
+ path: z.ZodString;
1054
+ file_text: z.ZodString;
1055
+ }, "strip", z.ZodTypeAny, {
1056
+ path: string;
1057
+ command: "create";
1058
+ file_text: string;
1059
+ }, {
1060
+ path: string;
1061
+ command: "create";
1062
+ file_text: string;
1063
+ }>, z.ZodObject<{
1064
+ command: z.ZodLiteral<"str_replace">;
1065
+ path: z.ZodString;
1066
+ new_str: z.ZodOptional<z.ZodString>;
1067
+ old_str: z.ZodString;
1068
+ }, "strip", z.ZodTypeAny, {
1069
+ path: string;
1070
+ command: "str_replace";
1071
+ old_str: string;
1072
+ new_str?: string | undefined;
1073
+ }, {
1074
+ path: string;
1075
+ command: "str_replace";
1076
+ old_str: string;
1077
+ new_str?: string | undefined;
1078
+ }>, z.ZodObject<{
1079
+ command: z.ZodLiteral<"insert">;
1080
+ path: z.ZodString;
1081
+ insert_line: z.ZodNumber;
1082
+ new_str: z.ZodString;
1083
+ }, "strip", z.ZodTypeAny, {
1084
+ path: string;
1085
+ command: "insert";
1086
+ new_str: string;
1087
+ insert_line: number;
1088
+ }, {
1089
+ path: string;
1090
+ command: "insert";
1091
+ new_str: string;
1092
+ insert_line: number;
1093
+ }>]>, z.ZodUnknown]>;
1094
+ partialOutput: z.ZodOptional<z.ZodString>;
1095
+ isHidden: z.ZodOptional<z.ZodBoolean>;
1096
+ isAlwaysExpanded: z.ZodOptional<z.ZodBoolean>;
1097
+ showNoContent: z.ZodOptional<z.ZodBoolean>;
1098
+ }, "strip", z.ZodTypeAny, {
1099
+ name: string;
1100
+ type: "tool_call_requested";
1101
+ callId: string;
1102
+ intentionSummary: string | null;
1103
+ toolTitle?: string | undefined;
1104
+ arguments?: unknown;
1105
+ partialOutput?: string | undefined;
1106
+ isHidden?: boolean | undefined;
1107
+ isAlwaysExpanded?: boolean | undefined;
1108
+ showNoContent?: boolean | undefined;
1109
+ }, {
1110
+ name: string;
1111
+ type: "tool_call_requested";
1112
+ callId: string;
1113
+ intentionSummary: string | null;
1114
+ toolTitle?: string | undefined;
1115
+ arguments?: unknown;
1116
+ partialOutput?: string | undefined;
1117
+ isHidden?: boolean | undefined;
1118
+ isAlwaysExpanded?: boolean | undefined;
1119
+ showNoContent?: boolean | undefined;
1120
+ }>, z.ZodObject<{
1121
+ type: z.ZodLiteral<"tool_call_completed">;
1122
+ callId: z.ZodString;
1123
+ name: z.ZodString;
1124
+ toolTitle: z.ZodOptional<z.ZodString>;
1125
+ intentionSummary: z.ZodNullable<z.ZodString>;
1126
+ result: z.ZodUnion<[z.ZodObject<{
1127
+ type: z.ZodLiteral<"success">;
1128
+ log: z.ZodString;
1129
+ markdown: z.ZodOptional<z.ZodBoolean>;
1130
+ }, "strip", z.ZodTypeAny, {
1131
+ log: string;
1132
+ type: "success";
1133
+ markdown?: boolean | undefined;
1134
+ }, {
1135
+ log: string;
1136
+ type: "success";
1137
+ markdown?: boolean | undefined;
1138
+ }>, z.ZodObject<{
1139
+ type: z.ZodLiteral<"failure">;
1140
+ log: z.ZodString;
1141
+ markdown: z.ZodOptional<z.ZodBoolean>;
1142
+ }, "strip", z.ZodTypeAny, {
1143
+ log: string;
1144
+ type: "failure";
1145
+ markdown?: boolean | undefined;
1146
+ }, {
1147
+ log: string;
1148
+ type: "failure";
1149
+ markdown?: boolean | undefined;
1150
+ }>, z.ZodObject<{
1151
+ type: z.ZodLiteral<"rejected">;
1152
+ markdown: z.ZodOptional<z.ZodBoolean>;
1153
+ }, "strip", z.ZodTypeAny, {
1154
+ type: "rejected";
1155
+ markdown?: boolean | undefined;
1156
+ }, {
1157
+ type: "rejected";
1158
+ markdown?: boolean | undefined;
1159
+ }>, z.ZodObject<{
1160
+ type: z.ZodLiteral<"denied">;
1161
+ log: z.ZodString;
1162
+ markdown: z.ZodOptional<z.ZodBoolean>;
1163
+ }, "strip", z.ZodTypeAny, {
1164
+ log: string;
1165
+ type: "denied";
1166
+ markdown?: boolean | undefined;
1167
+ }, {
1168
+ log: string;
1169
+ type: "denied";
1170
+ markdown?: boolean | undefined;
1171
+ }>]>;
1172
+ arguments: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
1173
+ command: z.ZodString;
1174
+ description: z.ZodString;
1175
+ timeout: z.ZodOptional<z.ZodNumber>;
1176
+ sessionId: z.ZodOptional<z.ZodString>;
1177
+ async: z.ZodOptional<z.ZodBoolean>;
1178
+ }, "strip", z.ZodTypeAny, {
1179
+ command: string;
1180
+ description: string;
1181
+ sessionId?: string | undefined;
1182
+ timeout?: number | undefined;
1183
+ async?: boolean | undefined;
1184
+ }, {
1185
+ command: string;
1186
+ description: string;
1187
+ sessionId?: string | undefined;
1188
+ timeout?: number | undefined;
1189
+ async?: boolean | undefined;
1190
+ }>, z.ZodObject<{
1191
+ sessionId: z.ZodString;
1192
+ input: z.ZodString;
1193
+ delay: z.ZodOptional<z.ZodNumber>;
1194
+ }, "strip", z.ZodTypeAny, {
1195
+ input: string;
1196
+ sessionId: string;
1197
+ delay?: number | undefined;
1198
+ }, {
1199
+ input: string;
1200
+ sessionId: string;
1201
+ delay?: number | undefined;
1202
+ }>, z.ZodObject<{
1203
+ sessionId: z.ZodString;
1204
+ delay: z.ZodNumber;
1205
+ }, "strip", z.ZodTypeAny, {
1206
+ sessionId: string;
1207
+ delay: number;
1208
+ }, {
1209
+ sessionId: string;
1210
+ delay: number;
1211
+ }>, z.ZodObject<{
1212
+ sessionId: z.ZodString;
1213
+ }, "strip", z.ZodTypeAny, {
1214
+ sessionId: string;
1215
+ }, {
1216
+ sessionId: string;
1217
+ }>]>, z.ZodDiscriminatedUnion<"command", [z.ZodObject<{
1218
+ command: z.ZodLiteral<"view">;
1219
+ path: z.ZodString;
1220
+ view_range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1221
+ }, "strip", z.ZodTypeAny, {
1222
+ path: string;
1223
+ command: "view";
1224
+ view_range?: [number, number] | undefined;
1225
+ }, {
1226
+ path: string;
1227
+ command: "view";
1228
+ view_range?: [number, number] | undefined;
1229
+ }>, z.ZodObject<{
1230
+ command: z.ZodLiteral<"create">;
1231
+ path: z.ZodString;
1232
+ file_text: z.ZodString;
1233
+ }, "strip", z.ZodTypeAny, {
1234
+ path: string;
1235
+ command: "create";
1236
+ file_text: string;
1237
+ }, {
1238
+ path: string;
1239
+ command: "create";
1240
+ file_text: string;
1241
+ }>, z.ZodObject<{
1242
+ command: z.ZodLiteral<"str_replace">;
1243
+ path: z.ZodString;
1244
+ new_str: z.ZodOptional<z.ZodString>;
1245
+ old_str: z.ZodString;
1246
+ }, "strip", z.ZodTypeAny, {
1247
+ path: string;
1248
+ command: "str_replace";
1249
+ old_str: string;
1250
+ new_str?: string | undefined;
1251
+ }, {
1252
+ path: string;
1253
+ command: "str_replace";
1254
+ old_str: string;
1255
+ new_str?: string | undefined;
1256
+ }>, z.ZodObject<{
1257
+ command: z.ZodLiteral<"insert">;
1258
+ path: z.ZodString;
1259
+ insert_line: z.ZodNumber;
1260
+ new_str: z.ZodString;
1261
+ }, "strip", z.ZodTypeAny, {
1262
+ path: string;
1263
+ command: "insert";
1264
+ new_str: string;
1265
+ insert_line: number;
1266
+ }, {
1267
+ path: string;
1268
+ command: "insert";
1269
+ new_str: string;
1270
+ insert_line: number;
1271
+ }>]>, z.ZodUnknown]>;
1272
+ isHidden: z.ZodOptional<z.ZodBoolean>;
1273
+ isAlwaysExpanded: z.ZodOptional<z.ZodBoolean>;
1274
+ showNoContent: z.ZodOptional<z.ZodBoolean>;
1275
+ }, "strip", z.ZodTypeAny, {
1276
+ result: {
1277
+ log: string;
1278
+ type: "success";
1279
+ markdown?: boolean | undefined;
1280
+ } | {
1281
+ log: string;
1282
+ type: "failure";
1283
+ markdown?: boolean | undefined;
1284
+ } | {
1285
+ type: "rejected";
1286
+ markdown?: boolean | undefined;
1287
+ } | {
1288
+ log: string;
1289
+ type: "denied";
1290
+ markdown?: boolean | undefined;
1291
+ };
1292
+ name: string;
1293
+ type: "tool_call_completed";
1294
+ callId: string;
1295
+ intentionSummary: string | null;
1296
+ toolTitle?: string | undefined;
1297
+ arguments?: unknown;
1298
+ isHidden?: boolean | undefined;
1299
+ isAlwaysExpanded?: boolean | undefined;
1300
+ showNoContent?: boolean | undefined;
1301
+ }, {
1302
+ result: {
1303
+ log: string;
1304
+ type: "success";
1305
+ markdown?: boolean | undefined;
1306
+ } | {
1307
+ log: string;
1308
+ type: "failure";
1309
+ markdown?: boolean | undefined;
1310
+ } | {
1311
+ type: "rejected";
1312
+ markdown?: boolean | undefined;
1313
+ } | {
1314
+ log: string;
1315
+ type: "denied";
1316
+ markdown?: boolean | undefined;
1317
+ };
1318
+ name: string;
1319
+ type: "tool_call_completed";
1320
+ callId: string;
1321
+ intentionSummary: string | null;
1322
+ toolTitle?: string | undefined;
1323
+ arguments?: unknown;
1324
+ isHidden?: boolean | undefined;
1325
+ isAlwaysExpanded?: boolean | undefined;
1326
+ showNoContent?: boolean | undefined;
1327
+ }>]>, z.ZodObject<{
1328
+ id: z.ZodString;
1329
+ timestamp: z.ZodDate;
1330
+ }, "strip", z.ZodTypeAny, {
1331
+ id: string;
1332
+ timestamp: Date;
1333
+ }, {
1334
+ id: string;
1335
+ timestamp: Date;
1336
+ }>>;
1337
+
1338
+ declare type TimelineEntryWithoutID = z.infer<typeof TimelineEntryWithoutIDSchema>;
1339
+
1340
+ declare const TimelineEntryWithoutIDSchema: z.ZodUnion<[z.ZodObject<{
1341
+ type: z.ZodLiteral<"copilot">;
1342
+ text: z.ZodString;
1343
+ }, "strip", z.ZodTypeAny, {
1344
+ type: "copilot";
1345
+ text: string;
1346
+ }, {
1347
+ type: "copilot";
1348
+ text: string;
1349
+ }>, z.ZodObject<{
1350
+ type: z.ZodLiteral<"error">;
1351
+ text: z.ZodString;
1352
+ }, "strip", z.ZodTypeAny, {
1353
+ type: "error";
1354
+ text: string;
1355
+ }, {
1356
+ type: "error";
1357
+ text: string;
1358
+ }>, z.ZodObject<{
1359
+ type: z.ZodLiteral<"info">;
1360
+ text: z.ZodString;
1361
+ }, "strip", z.ZodTypeAny, {
1362
+ type: "info";
1363
+ text: string;
1364
+ }, {
1365
+ type: "info";
1366
+ text: string;
1367
+ }>, z.ZodObject<{
1368
+ type: z.ZodLiteral<"user">;
1369
+ text: z.ZodString;
1370
+ expandedText: z.ZodOptional<z.ZodString>;
1371
+ mentions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1372
+ displayText: z.ZodString;
1373
+ fullPath: z.ZodString;
1374
+ type: z.ZodEnum<["file", "directory", "unresolved", "image"]>;
1375
+ startIndex: z.ZodNumber;
1376
+ }, "strip", z.ZodTypeAny, {
1377
+ type: "file" | "image" | "directory" | "unresolved";
1378
+ displayText: string;
1379
+ fullPath: string;
1380
+ startIndex: number;
1381
+ }, {
1382
+ type: "file" | "image" | "directory" | "unresolved";
1383
+ displayText: string;
1384
+ fullPath: string;
1385
+ startIndex: number;
1386
+ }>, "many">>;
1387
+ imageAttachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
1388
+ type: z.ZodLiteral<"image_url">;
1389
+ image_url: z.ZodObject<{
1390
+ url: z.ZodString;
1391
+ }, "strip", z.ZodTypeAny, {
1392
+ url: string;
1393
+ }, {
1394
+ url: string;
1395
+ }>;
1396
+ }, "strip", z.ZodTypeAny, {
1397
+ type: "image_url";
1398
+ image_url: {
1399
+ url: string;
1400
+ };
1401
+ }, {
1402
+ type: "image_url";
1403
+ image_url: {
1404
+ url: string;
1405
+ };
1406
+ }>, "many">>;
1407
+ }, "strip", z.ZodTypeAny, {
1408
+ type: "user";
1409
+ text: string;
1410
+ expandedText?: string | undefined;
1411
+ mentions?: {
1412
+ type: "file" | "image" | "directory" | "unresolved";
1413
+ displayText: string;
1414
+ fullPath: string;
1415
+ startIndex: number;
1416
+ }[] | undefined;
1417
+ imageAttachments?: {
1418
+ type: "image_url";
1419
+ image_url: {
1420
+ url: string;
1421
+ };
1422
+ }[] | undefined;
1423
+ }, {
1424
+ type: "user";
1425
+ text: string;
1426
+ expandedText?: string | undefined;
1427
+ mentions?: {
1428
+ type: "file" | "image" | "directory" | "unresolved";
1429
+ displayText: string;
1430
+ fullPath: string;
1431
+ startIndex: number;
1432
+ }[] | undefined;
1433
+ imageAttachments?: {
1434
+ type: "image_url";
1435
+ image_url: {
1436
+ url: string;
1437
+ };
1438
+ }[] | undefined;
1439
+ }>, z.ZodObject<{
1440
+ type: z.ZodLiteral<"tool_call_requested">;
1441
+ callId: z.ZodString;
1442
+ name: z.ZodString;
1443
+ toolTitle: z.ZodOptional<z.ZodString>;
1444
+ intentionSummary: z.ZodNullable<z.ZodString>;
1445
+ arguments: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
1446
+ command: z.ZodString;
1447
+ description: z.ZodString;
1448
+ timeout: z.ZodOptional<z.ZodNumber>;
1449
+ sessionId: z.ZodOptional<z.ZodString>;
1450
+ async: z.ZodOptional<z.ZodBoolean>;
1451
+ }, "strip", z.ZodTypeAny, {
1452
+ command: string;
1453
+ description: string;
1454
+ sessionId?: string | undefined;
1455
+ timeout?: number | undefined;
1456
+ async?: boolean | undefined;
1457
+ }, {
1458
+ command: string;
1459
+ description: string;
1460
+ sessionId?: string | undefined;
1461
+ timeout?: number | undefined;
1462
+ async?: boolean | undefined;
1463
+ }>, z.ZodObject<{
1464
+ sessionId: z.ZodString;
1465
+ input: z.ZodString;
1466
+ delay: z.ZodOptional<z.ZodNumber>;
1467
+ }, "strip", z.ZodTypeAny, {
1468
+ input: string;
1469
+ sessionId: string;
1470
+ delay?: number | undefined;
1471
+ }, {
1472
+ input: string;
1473
+ sessionId: string;
1474
+ delay?: number | undefined;
1475
+ }>, z.ZodObject<{
1476
+ sessionId: z.ZodString;
1477
+ delay: z.ZodNumber;
1478
+ }, "strip", z.ZodTypeAny, {
1479
+ sessionId: string;
1480
+ delay: number;
1481
+ }, {
1482
+ sessionId: string;
1483
+ delay: number;
1484
+ }>, z.ZodObject<{
1485
+ sessionId: z.ZodString;
1486
+ }, "strip", z.ZodTypeAny, {
1487
+ sessionId: string;
1488
+ }, {
1489
+ sessionId: string;
1490
+ }>]>, z.ZodDiscriminatedUnion<"command", [z.ZodObject<{
1491
+ command: z.ZodLiteral<"view">;
1492
+ path: z.ZodString;
1493
+ view_range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1494
+ }, "strip", z.ZodTypeAny, {
1495
+ path: string;
1496
+ command: "view";
1497
+ view_range?: [number, number] | undefined;
1498
+ }, {
1499
+ path: string;
1500
+ command: "view";
1501
+ view_range?: [number, number] | undefined;
1502
+ }>, z.ZodObject<{
1503
+ command: z.ZodLiteral<"create">;
1504
+ path: z.ZodString;
1505
+ file_text: z.ZodString;
1506
+ }, "strip", z.ZodTypeAny, {
1507
+ path: string;
1508
+ command: "create";
1509
+ file_text: string;
1510
+ }, {
1511
+ path: string;
1512
+ command: "create";
1513
+ file_text: string;
1514
+ }>, z.ZodObject<{
1515
+ command: z.ZodLiteral<"str_replace">;
1516
+ path: z.ZodString;
1517
+ new_str: z.ZodOptional<z.ZodString>;
1518
+ old_str: z.ZodString;
1519
+ }, "strip", z.ZodTypeAny, {
1520
+ path: string;
1521
+ command: "str_replace";
1522
+ old_str: string;
1523
+ new_str?: string | undefined;
1524
+ }, {
1525
+ path: string;
1526
+ command: "str_replace";
1527
+ old_str: string;
1528
+ new_str?: string | undefined;
1529
+ }>, z.ZodObject<{
1530
+ command: z.ZodLiteral<"insert">;
1531
+ path: z.ZodString;
1532
+ insert_line: z.ZodNumber;
1533
+ new_str: z.ZodString;
1534
+ }, "strip", z.ZodTypeAny, {
1535
+ path: string;
1536
+ command: "insert";
1537
+ new_str: string;
1538
+ insert_line: number;
1539
+ }, {
1540
+ path: string;
1541
+ command: "insert";
1542
+ new_str: string;
1543
+ insert_line: number;
1544
+ }>]>, z.ZodUnknown]>;
1545
+ partialOutput: z.ZodOptional<z.ZodString>;
1546
+ isHidden: z.ZodOptional<z.ZodBoolean>;
1547
+ isAlwaysExpanded: z.ZodOptional<z.ZodBoolean>;
1548
+ showNoContent: z.ZodOptional<z.ZodBoolean>;
1549
+ }, "strip", z.ZodTypeAny, {
1550
+ name: string;
1551
+ type: "tool_call_requested";
1552
+ callId: string;
1553
+ intentionSummary: string | null;
1554
+ toolTitle?: string | undefined;
1555
+ arguments?: unknown;
1556
+ partialOutput?: string | undefined;
1557
+ isHidden?: boolean | undefined;
1558
+ isAlwaysExpanded?: boolean | undefined;
1559
+ showNoContent?: boolean | undefined;
1560
+ }, {
1561
+ name: string;
1562
+ type: "tool_call_requested";
1563
+ callId: string;
1564
+ intentionSummary: string | null;
1565
+ toolTitle?: string | undefined;
1566
+ arguments?: unknown;
1567
+ partialOutput?: string | undefined;
1568
+ isHidden?: boolean | undefined;
1569
+ isAlwaysExpanded?: boolean | undefined;
1570
+ showNoContent?: boolean | undefined;
1571
+ }>, z.ZodObject<{
1572
+ type: z.ZodLiteral<"tool_call_completed">;
1573
+ callId: z.ZodString;
1574
+ name: z.ZodString;
1575
+ toolTitle: z.ZodOptional<z.ZodString>;
1576
+ intentionSummary: z.ZodNullable<z.ZodString>;
1577
+ result: z.ZodUnion<[z.ZodObject<{
1578
+ type: z.ZodLiteral<"success">;
1579
+ log: z.ZodString;
1580
+ markdown: z.ZodOptional<z.ZodBoolean>;
1581
+ }, "strip", z.ZodTypeAny, {
1582
+ log: string;
1583
+ type: "success";
1584
+ markdown?: boolean | undefined;
1585
+ }, {
1586
+ log: string;
1587
+ type: "success";
1588
+ markdown?: boolean | undefined;
1589
+ }>, z.ZodObject<{
1590
+ type: z.ZodLiteral<"failure">;
1591
+ log: z.ZodString;
1592
+ markdown: z.ZodOptional<z.ZodBoolean>;
1593
+ }, "strip", z.ZodTypeAny, {
1594
+ log: string;
1595
+ type: "failure";
1596
+ markdown?: boolean | undefined;
1597
+ }, {
1598
+ log: string;
1599
+ type: "failure";
1600
+ markdown?: boolean | undefined;
1601
+ }>, z.ZodObject<{
1602
+ type: z.ZodLiteral<"rejected">;
1603
+ markdown: z.ZodOptional<z.ZodBoolean>;
1604
+ }, "strip", z.ZodTypeAny, {
1605
+ type: "rejected";
1606
+ markdown?: boolean | undefined;
1607
+ }, {
1608
+ type: "rejected";
1609
+ markdown?: boolean | undefined;
1610
+ }>, z.ZodObject<{
1611
+ type: z.ZodLiteral<"denied">;
1612
+ log: z.ZodString;
1613
+ markdown: z.ZodOptional<z.ZodBoolean>;
1614
+ }, "strip", z.ZodTypeAny, {
1615
+ log: string;
1616
+ type: "denied";
1617
+ markdown?: boolean | undefined;
1618
+ }, {
1619
+ log: string;
1620
+ type: "denied";
1621
+ markdown?: boolean | undefined;
1622
+ }>]>;
1623
+ arguments: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
1624
+ command: z.ZodString;
1625
+ description: z.ZodString;
1626
+ timeout: z.ZodOptional<z.ZodNumber>;
1627
+ sessionId: z.ZodOptional<z.ZodString>;
1628
+ async: z.ZodOptional<z.ZodBoolean>;
1629
+ }, "strip", z.ZodTypeAny, {
1630
+ command: string;
1631
+ description: string;
1632
+ sessionId?: string | undefined;
1633
+ timeout?: number | undefined;
1634
+ async?: boolean | undefined;
1635
+ }, {
1636
+ command: string;
1637
+ description: string;
1638
+ sessionId?: string | undefined;
1639
+ timeout?: number | undefined;
1640
+ async?: boolean | undefined;
1641
+ }>, z.ZodObject<{
1642
+ sessionId: z.ZodString;
1643
+ input: z.ZodString;
1644
+ delay: z.ZodOptional<z.ZodNumber>;
1645
+ }, "strip", z.ZodTypeAny, {
1646
+ input: string;
1647
+ sessionId: string;
1648
+ delay?: number | undefined;
1649
+ }, {
1650
+ input: string;
1651
+ sessionId: string;
1652
+ delay?: number | undefined;
1653
+ }>, z.ZodObject<{
1654
+ sessionId: z.ZodString;
1655
+ delay: z.ZodNumber;
1656
+ }, "strip", z.ZodTypeAny, {
1657
+ sessionId: string;
1658
+ delay: number;
1659
+ }, {
1660
+ sessionId: string;
1661
+ delay: number;
1662
+ }>, z.ZodObject<{
1663
+ sessionId: z.ZodString;
1664
+ }, "strip", z.ZodTypeAny, {
1665
+ sessionId: string;
1666
+ }, {
1667
+ sessionId: string;
1668
+ }>]>, z.ZodDiscriminatedUnion<"command", [z.ZodObject<{
1669
+ command: z.ZodLiteral<"view">;
1670
+ path: z.ZodString;
1671
+ view_range: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
1672
+ }, "strip", z.ZodTypeAny, {
1673
+ path: string;
1674
+ command: "view";
1675
+ view_range?: [number, number] | undefined;
1676
+ }, {
1677
+ path: string;
1678
+ command: "view";
1679
+ view_range?: [number, number] | undefined;
1680
+ }>, z.ZodObject<{
1681
+ command: z.ZodLiteral<"create">;
1682
+ path: z.ZodString;
1683
+ file_text: z.ZodString;
1684
+ }, "strip", z.ZodTypeAny, {
1685
+ path: string;
1686
+ command: "create";
1687
+ file_text: string;
1688
+ }, {
1689
+ path: string;
1690
+ command: "create";
1691
+ file_text: string;
1692
+ }>, z.ZodObject<{
1693
+ command: z.ZodLiteral<"str_replace">;
1694
+ path: z.ZodString;
1695
+ new_str: z.ZodOptional<z.ZodString>;
1696
+ old_str: z.ZodString;
1697
+ }, "strip", z.ZodTypeAny, {
1698
+ path: string;
1699
+ command: "str_replace";
1700
+ old_str: string;
1701
+ new_str?: string | undefined;
1702
+ }, {
1703
+ path: string;
1704
+ command: "str_replace";
1705
+ old_str: string;
1706
+ new_str?: string | undefined;
1707
+ }>, z.ZodObject<{
1708
+ command: z.ZodLiteral<"insert">;
1709
+ path: z.ZodString;
1710
+ insert_line: z.ZodNumber;
1711
+ new_str: z.ZodString;
1712
+ }, "strip", z.ZodTypeAny, {
1713
+ path: string;
1714
+ command: "insert";
1715
+ new_str: string;
1716
+ insert_line: number;
1717
+ }, {
1718
+ path: string;
1719
+ command: "insert";
1720
+ new_str: string;
1721
+ insert_line: number;
1722
+ }>]>, z.ZodUnknown]>;
1723
+ isHidden: z.ZodOptional<z.ZodBoolean>;
1724
+ isAlwaysExpanded: z.ZodOptional<z.ZodBoolean>;
1725
+ showNoContent: z.ZodOptional<z.ZodBoolean>;
1726
+ }, "strip", z.ZodTypeAny, {
1727
+ result: {
1728
+ log: string;
1729
+ type: "success";
1730
+ markdown?: boolean | undefined;
1731
+ } | {
1732
+ log: string;
1733
+ type: "failure";
1734
+ markdown?: boolean | undefined;
1735
+ } | {
1736
+ type: "rejected";
1737
+ markdown?: boolean | undefined;
1738
+ } | {
1739
+ log: string;
1740
+ type: "denied";
1741
+ markdown?: boolean | undefined;
1742
+ };
1743
+ name: string;
1744
+ type: "tool_call_completed";
1745
+ callId: string;
1746
+ intentionSummary: string | null;
1747
+ toolTitle?: string | undefined;
1748
+ arguments?: unknown;
1749
+ isHidden?: boolean | undefined;
1750
+ isAlwaysExpanded?: boolean | undefined;
1751
+ showNoContent?: boolean | undefined;
1752
+ }, {
1753
+ result: {
1754
+ log: string;
1755
+ type: "success";
1756
+ markdown?: boolean | undefined;
1757
+ } | {
1758
+ log: string;
1759
+ type: "failure";
1760
+ markdown?: boolean | undefined;
1761
+ } | {
1762
+ type: "rejected";
1763
+ markdown?: boolean | undefined;
1764
+ } | {
1765
+ log: string;
1766
+ type: "denied";
1767
+ markdown?: boolean | undefined;
1768
+ };
1769
+ name: string;
1770
+ type: "tool_call_completed";
1771
+ callId: string;
1772
+ intentionSummary: string | null;
1773
+ toolTitle?: string | undefined;
1774
+ arguments?: unknown;
1775
+ isHidden?: boolean | undefined;
1776
+ isAlwaysExpanded?: boolean | undefined;
1777
+ showNoContent?: boolean | undefined;
1778
+ }>]>;
1779
+
1780
+ declare type ToolCallResult = {
1781
+ callId: string;
1782
+ resultType: "success" | "failure" | "rejected" | "denied";
1783
+ log: string;
1784
+ markdown?: boolean;
1785
+ };
1786
+
1787
+ declare type ToolResultExpanded<TelemetryT extends Telemetry = Telemetry> = {
1788
+ /**
1789
+ * The result to be given back to the LLM.
1790
+ *
1791
+ * If @see sessionLog is omitted, then this will be used as the session log.
1792
+ */
1793
+ textResultForLlm: string;
1794
+ /**
1795
+ * The result to be given back to the LLM. It can be either base64 encoded image or audio content.
1796
+ */
1797
+ binaryResultForLlm?: BinaryResult[];
1798
+ /**
1799
+ * Whether or not the result should be considered a success, failure, or previously interrupted.
1800
+ * - `success`: The tool executed successfully and produced a valid result.
1801
+ * - `failure`: The tool encountered an error or did not produce a valid result.
1802
+ * - `rejected`: The tool call was rejected either because the user didn't want this call, or a previous dependent one.
1803
+ * - `denied`: The tool call was denied because the permissions service said no.
1804
+ */
1805
+ resultType: "success" | "failure" | "rejected" | "denied";
1806
+ /**
1807
+ * If there was any sort of error that caused the tool to fail, then a string representation of the error. Typically
1808
+ * only set if {@link resultType} is `'failure'`.
1809
+ */
1810
+ error?: string;
1811
+ /**
1812
+ * Specific telemetry for the tool. Will be sent back to the server by the agent.
1813
+ */
1814
+ toolTelemetry: {
1815
+ properties?: TelemetryT["properties"];
1816
+ restrictedProperties?: TelemetryT["restrictedProperties"];
1817
+ metrics?: TelemetryT["metrics"];
1818
+ };
1819
+ /**
1820
+ * Well-formatted (typically Markdown) string that can be used to display the input/output of the tool invoked.
1821
+ *
1822
+ * (Optional) If omitted, the text result for the LLM will be used as the session log.
1823
+ */
1824
+ sessionLog?: string;
1825
+ };
1826
+
1827
+ export declare type UserPromptSubmittedHook = (input: UserPromptSubmittedHookInput) => Promise<UserPromptSubmittedHookOutput | void>;
1828
+
1829
+ /**
1830
+ * User prompt submitted hook types
1831
+ */
1832
+ export declare interface UserPromptSubmittedHookInput extends BaseHookInput {
1833
+ prompt: string;
1834
+ }
1835
+
1836
+ export declare interface UserPromptSubmittedHookOutput {
1837
+ modifiedPrompt?: string;
1838
+ additionalContext?: string;
1839
+ suppressOutput?: boolean;
1840
+ }
1841
+
1842
+ /**
1843
+ * A permission request for writing to new or existing files.
1844
+ */
1845
+ declare type WritePermissionRequest = {
1846
+ readonly kind: "write";
1847
+ /** The intention of the edit operation, e.g. "Edit file" or "Create file" */
1848
+ readonly intention: string;
1849
+ /** The name of the file being edited */
1850
+ readonly fileName: string;
1851
+ /** The diff of the changes being made */
1852
+ readonly diff: string;
1853
+ };
1854
+
1855
+ export { }