-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathindex.ts
More file actions
408 lines (406 loc) · 9.78 KB
/
Copy pathindex.ts
File metadata and controls
408 lines (406 loc) · 9.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
// Core session management
export { type Args, parseArgs } from "./cli/args.ts";
// Config paths
export {
CONFIG_DIR_NAME,
getAgentDir,
getDocsPath,
getExamplesPath,
getPackageDir,
getReadmePath,
VERSION,
} from "./config.ts";
export {
AgentSession,
type AgentSessionConfig,
type AgentSessionEvent,
type AgentSessionEventListener,
type ModelCycleResult,
type ParsedSkillBlock,
type PromptOptions,
parseSkillBlock,
type SessionStats,
} from "./core/agent-session.ts";
export { readStoredCredential } from "./core/auth-storage.ts";
// Compaction
export {
type BranchPreparation,
type BranchSummaryResult,
type CollectEntriesResult,
type CompactionResult,
type CutPointResult,
calculateContextTokens,
collectEntriesForBranchSummary,
compact,
DEFAULT_COMPACTION_SETTINGS,
estimateTokens,
type FileOperations,
findCutPoint,
findTurnStartIndex,
type GenerateBranchSummaryOptions,
generateBranchSummary,
generateSummary,
generateSummaryWithUsage,
getLastAssistantUsage,
prepareBranchEntries,
serializeConversation,
shouldCompact,
} from "./core/compaction/index.ts";
export { createEventBus, type EventBus, type EventBusController } from "./core/event-bus.ts";
// Extension system
export type {
AgentEndEvent,
AgentSettledEvent,
AgentStartEvent,
AgentToolResult,
AgentToolUpdateCallback,
AppKeybinding,
AutocompleteProviderFactory,
BashToolCallEvent,
BeforeAgentStartEvent,
BeforeAgentStartEventResult,
BeforeProviderHeadersEvent,
BeforeProviderRequestEvent,
BeforeProviderRequestEventResult,
BuildSystemPromptOptions,
CompactOptions,
ContextEvent,
ContextUsage,
CustomToolCallEvent,
EditToolCallEvent,
EntryRenderer,
EntryRenderOptions,
ExecOptions,
ExecResult,
Extension,
ExtensionActions,
ExtensionAPI,
ExtensionCommandContext,
ExtensionCommandContextActions,
ExtensionContext,
ExtensionContextActions,
ExtensionError,
ExtensionEvent,
ExtensionFactory,
ExtensionFlag,
ExtensionHandler,
ExtensionRuntime,
ExtensionShortcut,
ExtensionUIContext,
ExtensionUIDialogOptions,
ExtensionWidgetOptions,
FindToolCallEvent,
GrepToolCallEvent,
InlineExtension,
InputEvent,
InputEventResult,
InputSource,
KeybindingsManager,
LoadExtensionsResult,
LsToolCallEvent,
MessageEndEvent,
MessageRenderer,
MessageRenderOptions,
MessageStartEvent,
MessageUpdateEvent,
ProjectTrustContext,
ProjectTrustEvent,
ProjectTrustEventDecision,
ProjectTrustEventResult,
ProjectTrustHandler,
ProviderConfig,
ProviderModelConfig,
ReadToolCallEvent,
RegisteredCommand,
RegisteredTool,
ResolvedCommand,
SessionBeforeCompactEvent,
SessionBeforeForkEvent,
SessionBeforeSwitchEvent,
SessionBeforeTreeEvent,
SessionCompactEvent,
SessionInfoChangedEvent,
SessionShutdownEvent,
SessionStartEvent,
SessionTreeEvent,
SlashCommandInfo,
SlashCommandSource,
SourceInfo,
TerminalInputHandler,
ToolCallEvent,
ToolCallEventResult,
ToolDefinition,
ToolExecutionEndEvent,
ToolExecutionMode,
ToolExecutionStartEvent,
ToolExecutionUpdateEvent,
ToolInfo,
ToolRenderResultOptions,
ToolResultEvent,
TurnEndEvent,
TurnStartEvent,
UserBashEvent,
UserBashEventResult,
WidgetPlacement,
WorkingIndicatorOptions,
WriteToolCallEvent,
} from "./core/extensions/index.ts";
export {
createExtensionRuntime,
defineTool,
discoverAndLoadExtensions,
ExtensionRunner,
isBashToolResult,
isEditToolResult,
isFindToolResult,
isGrepToolResult,
isLsToolResult,
isReadToolResult,
isToolCallEventType,
isWriteToolResult,
wrapRegisteredTool,
wrapRegisteredTools,
} from "./core/extensions/index.ts";
// Footer data provider (git branch + extension statuses - data not otherwise available to extensions)
export type { ReadonlyFooterDataProvider } from "./core/footer-data-provider.ts";
export { convertToLlm } from "./core/messages.ts";
export { ModelRegistry } from "./core/model-registry.ts";
export {
type ModelScopeDiagnostic,
type ResolveCliModelResult,
type ResolveModelScopeResult,
resolveCliModel,
resolveModelScopeWithDiagnostics,
type ScopedModel,
} from "./core/model-resolver.ts";
export {
type CreateModelRuntimeOptions,
ModelRuntime,
type ModelRuntimeAuthOverrides,
} from "./core/model-runtime.ts";
export type {
PackageManager,
PathMetadata,
ProgressCallback,
ProgressEvent,
ResolvedPaths,
ResolvedResource,
} from "./core/package-manager.ts";
export { DefaultPackageManager } from "./core/package-manager.ts";
export type { ResourceCollision, ResourceDiagnostic, ResourceLoader } from "./core/resource-loader.ts";
export { DefaultResourceLoader, loadProjectContextFiles } from "./core/resource-loader.ts";
// SDK for programmatic usage
export {
AgentSessionRuntime,
type AgentSessionRuntimeDiagnostic,
type AgentSessionServices,
type CreateAgentSessionFromServicesOptions,
type CreateAgentSessionOptions,
type CreateAgentSessionResult,
type CreateAgentSessionRuntimeFactory,
type CreateAgentSessionRuntimeResult,
type CreateAgentSessionServicesOptions,
// Factory
createAgentSession,
createAgentSessionFromServices,
createAgentSessionRuntime,
createAgentSessionServices,
createBashTool,
// Tool factories (for custom cwd)
createCodingTools,
createEditTool,
createFindTool,
createGrepTool,
createLsTool,
createReadOnlyTools,
createReadTool,
createWriteTool,
type PromptTemplate,
} from "./core/sdk.ts";
export {
type BranchSummaryEntry,
buildContextEntries,
buildSessionContext,
type CompactionEntry,
CURRENT_SESSION_VERSION,
type CustomEntry,
type CustomMessageEntry,
type FileEntry,
getLatestCompactionEntry,
type ModelChangeEntry,
migrateSessionEntries,
type NewSessionOptions,
parseSessionEntries,
type SessionContext,
type SessionEntry,
type SessionEntryBase,
type SessionHeader,
type SessionInfo,
type SessionInfoEntry,
SessionManager,
type SessionMessageEntry,
type SessionTreeNode,
sessionEntryToContextMessages,
type ThinkingLevelChangeEntry,
} from "./core/session-manager.ts";
export {
type CompactionSettings,
type DefaultProjectTrust,
type ImageSettings,
type PackageSource,
type RetrySettings,
SettingsManager,
type SettingsManagerCreateOptions,
} from "./core/settings-manager.ts";
// Skills
export {
formatSkillsForPrompt,
type LoadSkillsFromDirOptions,
type LoadSkillsResult,
loadSkills,
loadSkillsFromDir,
type Skill,
type SkillFrontmatter,
} from "./core/skills.ts";
export { createSyntheticSourceInfo } from "./core/source-info.ts";
export { type EditDiffResult, generateDiffString, generateUnifiedPatch } from "./core/tools/edit-diff.ts";
// Tools
export {
type BashOperations,
type BashSpawnContext,
type BashSpawnHook,
type BashToolDetails,
type BashToolInput,
type BashToolOptions,
createBashToolDefinition,
createEditToolDefinition,
createFindToolDefinition,
createGrepToolDefinition,
createLocalBashOperations,
createLsToolDefinition,
createReadToolDefinition,
createWriteToolDefinition,
DEFAULT_MAX_BYTES,
DEFAULT_MAX_LINES,
type EditOperations,
type EditToolDetails,
type EditToolInput,
type EditToolOptions,
type FindOperations,
type FindToolDetails,
type FindToolInput,
type FindToolOptions,
formatSize,
type GrepOperations,
type GrepToolDetails,
type GrepToolInput,
type GrepToolOptions,
type LsOperations,
type LsToolDetails,
type LsToolInput,
type LsToolOptions,
type ReadOperations,
type ReadToolDetails,
type ReadToolInput,
type ReadToolOptions,
type ToolsOptions,
type TruncationOptions,
type TruncationResult,
truncateHead,
truncateLine,
truncateTail,
type WriteOperations,
type WriteToolInput,
type WriteToolOptions,
withFileMutationQueue,
} from "./core/tools/index.ts";
export {
hasTrustRequiringProjectResources,
type ProjectTrustDecision,
ProjectTrustStore,
type ProjectTrustStoreEntry,
type ProjectTrustUpdate,
} from "./core/trust-manager.ts";
export type { DiscoSkillRole } from "./disco/modes/skill-policy.ts";
export {
DEFAULT_DISCO_AGENT_MODE,
type DiscoAgentMode,
formatDiscoAgentMode,
isDiscoAgentMode,
resolveDiscoAgentMode,
} from "./disco/modes/types.ts";
// Main entry point
export { type MainOptions, main } from "./main.ts";
// Run modes for programmatic SDK usage
export {
InteractiveMode,
type InteractiveModeOptions,
type ModelInfo,
type PrintModeOptions,
RpcClient,
type RpcClientOptions,
type RpcCommand,
type RpcEventListener,
type RpcExtensionUIRequest,
type RpcExtensionUIResponse,
type RpcResponse,
type RpcSessionState,
runPrintMode,
runRpcMode,
} from "./modes/index.ts";
// UI components for extensions
export {
AssistantMessageComponent,
BashExecutionComponent,
BorderedLoader,
BranchSummaryMessageComponent,
CompactionSummaryMessageComponent,
CustomEditor,
CustomMessageComponent,
DynamicBorder,
ExtensionEditorComponent,
ExtensionInputComponent,
ExtensionSelectorComponent,
FooterComponent,
keyHint,
keyText,
LoginDialogComponent,
ModelSelectorComponent,
OAuthSelectorComponent,
type RenderDiffOptions,
rawKeyHint,
renderDiff,
SessionSelectorComponent,
type SettingsCallbacks,
type SettingsConfig,
SettingsSelectorComponent,
ShowImagesSelectorComponent,
SkillInvocationMessageComponent,
ThemeSelectorComponent,
ThinkingSelectorComponent,
ToolExecutionComponent,
type ToolExecutionOptions,
TreeSelectorComponent,
truncateToVisualLines,
UserMessageComponent,
UserMessageSelectorComponent,
type VisualTruncateResult,
} from "./modes/interactive/components/index.ts";
// Theme utilities for custom tools and extensions
export {
getLanguageFromPath,
getMarkdownTheme,
getSelectListTheme,
getSettingsListTheme,
highlightCode,
initTheme,
Theme,
type ThemeColor,
} from "./modes/interactive/theme/theme.ts";
// Clipboard utilities
export { copyToClipboard } from "./utils/clipboard.ts";
export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts";
export { convertToPng } from "./utils/image-convert.ts";
export { formatDimensionNote, type ResizedImage, resizeImage } from "./utils/image-resize.ts";
// Shell utilities
export { getShellConfig } from "./utils/shell.ts";