@wraith-ai/core 0.1.0 → 0.1.1
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/README.md +1 -1
- package/dist/{attempt-BeB7EltG.d.mts → attempt-HgararU3.d.mts} +2 -1
- package/dist/attempt-HgararU3.d.mts.map +1 -0
- package/dist/{capabilities-BPb5HSH6.d.mts → capabilities-CNsPrkB7.d.mts} +2 -1
- package/dist/capabilities-CNsPrkB7.d.mts.map +1 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +11 -9
- package/dist/index.mjs.map +1 -0
- package/dist/{methods-CZp6XGn8.mjs → methods-7Ryz6zbd.mjs} +4 -2
- package/dist/methods-7Ryz6zbd.mjs.map +1 -0
- package/dist/{model-B6tJ9kX_.mjs → model-C16NUwXW.mjs} +2 -0
- package/dist/model-C16NUwXW.mjs.map +1 -0
- package/dist/{model-D6LQSveS.d.mts → model-_wqePNTL.d.mts} +4 -3
- package/dist/model-_wqePNTL.d.mts.map +1 -0
- package/dist/{models-dev-Y0ZikMBQ.d.mts → models-dev-DNgymZy3.d.mts} +3 -2
- package/dist/models-dev-DNgymZy3.d.mts.map +1 -0
- package/dist/{openai-codex-BhtZvNpm.mjs → openai-codex-Bz1EFPEi.mjs} +3 -1
- package/dist/openai-codex-Bz1EFPEi.mjs.map +1 -0
- package/dist/{openai-codex-Bk-iG7MZ.mjs → openai-codex-uvjhVoVy.mjs} +6 -4
- package/dist/openai-codex-uvjhVoVy.mjs.map +1 -0
- package/dist/{openai-compatible-hkXv-P74.mjs → openai-compatible-DBppnQ_N.mjs} +4 -2
- package/dist/openai-compatible-DBppnQ_N.mjs.map +1 -0
- package/dist/{openrouter-BflQBug2.mjs → openrouter-D8nTOAQo.mjs} +5 -3
- package/dist/openrouter-D8nTOAQo.mjs.map +1 -0
- package/dist/providers/openai-codex.d.mts +4 -3
- package/dist/providers/openai-codex.d.mts.map +1 -0
- package/dist/providers/openai-codex.mjs +1 -1
- package/dist/providers/openai-compatible.d.mts +3 -2
- package/dist/providers/openai-compatible.d.mts.map +1 -0
- package/dist/providers/openai-compatible.mjs +1 -1
- package/dist/providers/openrouter.d.mts +3 -2
- package/dist/providers/openrouter.d.mts.map +1 -0
- package/dist/providers/openrouter.mjs +1 -1
- package/dist/{shared-8d7RsyPH.mjs → shared-BIJaPhMm.mjs} +3 -1
- package/dist/shared-BIJaPhMm.mjs.map +1 -0
- package/dist/snapshot.d.mts +3 -2
- package/dist/snapshot.d.mts.map +1 -0
- package/dist/snapshot.mjs +4999 -4977
- package/dist/snapshot.mjs.map +1 -0
- package/dist/{turn-effort-DquDDwdE.mjs → turn-effort-C61L4JIt.mjs} +2 -0
- package/dist/turn-effort-C61L4JIt.mjs.map +1 -0
- package/package.json +3 -2
- package/src/agent/agent.ts +90 -0
- package/src/agent/attachments.ts +195 -0
- package/src/agent/classifier.ts +525 -0
- package/src/agent/compact.ts +384 -0
- package/src/agent/conversation.ts +300 -0
- package/src/agent/cost.ts +164 -0
- package/src/agent/inbox.ts +80 -0
- package/src/agent/instructions.ts +62 -0
- package/src/agent/loop.ts +675 -0
- package/src/agent/messages.ts +252 -0
- package/src/agent/on-demand.ts +58 -0
- package/src/agent/prompts.ts +35 -0
- package/src/agent/request-images.ts +94 -0
- package/src/agent/stop.ts +37 -0
- package/src/agent/title.ts +122 -0
- package/src/agent/tool-groups.ts +186 -0
- package/src/agent/tools.ts +106 -0
- package/src/app.ts +67 -0
- package/src/config/credential-file-store.ts +66 -0
- package/src/config/environment.ts +105 -0
- package/src/config/instructions.ts +157 -0
- package/src/config/load.ts +667 -0
- package/src/config/locked-file.ts +85 -0
- package/src/config/paths.ts +368 -0
- package/src/config/schema.ts +363 -0
- package/src/config/subagents.ts +156 -0
- package/src/config/trust.ts +53 -0
- package/src/config/write.ts +241 -0
- package/src/errors.ts +85 -0
- package/src/events/types.ts +258 -0
- package/src/glob.ts +161 -0
- package/src/index.ts +681 -0
- package/src/logger.ts +47 -0
- package/src/paths.ts +143 -0
- package/src/permissions/chain.ts +42 -0
- package/src/permissions/command.ts +233 -0
- package/src/permissions/layered.ts +77 -0
- package/src/permissions/match.ts +80 -0
- package/src/permissions/modes.ts +48 -0
- package/src/permissions/policy.ts +160 -0
- package/src/permissions/types.ts +159 -0
- package/src/providers/cache.ts +107 -0
- package/src/providers/capabilities.ts +77 -0
- package/src/providers/catalog-view.ts +91 -0
- package/src/providers/catalog.ts +65 -0
- package/src/providers/errors.ts +108 -0
- package/src/providers/factories/index.ts +15 -0
- package/src/providers/factories/openai-codex.ts +382 -0
- package/src/providers/factories/openai-compatible.ts +81 -0
- package/src/providers/factories/openrouter.ts +165 -0
- package/src/providers/factories/shared.ts +22 -0
- package/src/providers/model.ts +197 -0
- package/src/providers/models-dev.ts +355 -0
- package/src/providers/oauth/methods.ts +10 -0
- package/src/providers/oauth/openai-codex.ts +228 -0
- package/src/providers/oauth.ts +177 -0
- package/src/providers/openai-codex.ts +7 -0
- package/src/providers/openai-compatible.ts +2 -0
- package/src/providers/openrouter.ts +2 -0
- package/src/providers/registry.ts +464 -0
- package/src/providers/turn-effort.ts +156 -0
- package/src/providers/types.ts +83 -0
- package/src/session/backend.ts +44 -0
- package/src/session/file-store.ts +278 -0
- package/src/session/format.ts +1037 -0
- package/src/session/memory-store.ts +73 -0
- package/src/session/session.ts +153 -0
- package/src/session/store.ts +219 -0
- package/src/sign-in/attempt.ts +166 -0
- package/src/sign-in/loopback.ts +74 -0
- package/src/snapshot/data.json +8936 -0
- package/src/snapshot/index.ts +37 -0
- package/src/tools/bin.ts +364 -0
- package/src/tools/builtin.ts +48 -0
- package/src/tools/change.ts +88 -0
- package/src/tools/define.ts +267 -0
- package/src/tools/describe.ts +96 -0
- package/src/tools/fs/edit-file.ts +129 -0
- package/src/tools/fs/glob.ts +75 -0
- package/src/tools/fs/grep.ts +212 -0
- package/src/tools/fs/line-endings.ts +17 -0
- package/src/tools/fs/list-dir.ts +85 -0
- package/src/tools/fs/read-file.ts +230 -0
- package/src/tools/fs/ripgrep.ts +211 -0
- package/src/tools/fs/write-file.ts +97 -0
- package/src/tools/job.ts +252 -0
- package/src/tools/mcp/auth-store.ts +127 -0
- package/src/tools/mcp/command.ts +151 -0
- package/src/tools/mcp/config.ts +168 -0
- package/src/tools/mcp/servers.ts +463 -0
- package/src/tools/mcp/sign-in.ts +226 -0
- package/src/tools/mcp/stdio.ts +204 -0
- package/src/tools/mcp/tools.ts +173 -0
- package/src/tools/on-demand.ts +184 -0
- package/src/tools/registry.ts +935 -0
- package/src/tools/shell/bash.ts +217 -0
- package/src/tools/shell/find-bash.ts +162 -0
- package/src/tools/source.ts +35 -0
- package/src/tools/spill.ts +127 -0
- package/src/tools/subagents.ts +597 -0
- package/src/tools/tasks.ts +603 -0
- package/src/tools/to-model.ts +33 -0
- package/src/tools/web/address.ts +95 -0
- package/src/tools/web/exa.ts +163 -0
- package/src/tools/web/fetch.ts +373 -0
- package/src/tools/web/html.ts +173 -0
- package/src/tools/web/search.ts +111 -0
- package/src/tools/web/source.ts +51 -0
- package/src/units.ts +18 -0
- package/src/version.ts +23 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API of @wraith-ai/core.
|
|
3
|
+
*
|
|
4
|
+
* Everything a host (CLI, TUI, HTTP server, worker) is allowed to touch is
|
|
5
|
+
* re-exported here. Importing from deeper paths is not supported.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export { CORE_VERSION, DEV_VERSION, isDevBuild } from "./version";
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
APP_NAME,
|
|
12
|
+
CONFIG_FILE_NAME,
|
|
13
|
+
CREDENTIALS_FILE_NAME,
|
|
14
|
+
ENV_PREFIX,
|
|
15
|
+
LOCAL_CONFIG_FILE_NAME,
|
|
16
|
+
PROJECT_DIR_NAME,
|
|
17
|
+
PROMPT_FILE_NAME,
|
|
18
|
+
WRAITH,
|
|
19
|
+
type AppIdentity,
|
|
20
|
+
defineApp,
|
|
21
|
+
envVar,
|
|
22
|
+
} from "./app";
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
AgentError,
|
|
26
|
+
isAgentError,
|
|
27
|
+
serializeError,
|
|
28
|
+
type AgentErrorCode,
|
|
29
|
+
type AgentErrorOptions,
|
|
30
|
+
type SerializedError,
|
|
31
|
+
} from "./errors";
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
noopLogger,
|
|
35
|
+
withLevel,
|
|
36
|
+
type LogFields,
|
|
37
|
+
type Logger,
|
|
38
|
+
type LogLevel,
|
|
39
|
+
} from "./logger";
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
checkoutMeta,
|
|
43
|
+
inCheckout,
|
|
44
|
+
projectSlug,
|
|
45
|
+
resolveAppPaths,
|
|
46
|
+
type AppPaths,
|
|
47
|
+
type EntryKind,
|
|
48
|
+
type PathEnvironment,
|
|
49
|
+
type SessionPlace,
|
|
50
|
+
} from "./config/paths";
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
describeCheckout,
|
|
54
|
+
environmentBlock,
|
|
55
|
+
type EnvironmentOptions,
|
|
56
|
+
} from "./config/environment";
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
loadSubagents,
|
|
60
|
+
parseSubagent,
|
|
61
|
+
type LoadedSubagents,
|
|
62
|
+
type SkippedSubagentFile,
|
|
63
|
+
} from "./config/subagents";
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
configSchema,
|
|
67
|
+
credentialsSchema,
|
|
68
|
+
defaultApiKeyEnv,
|
|
69
|
+
maskSecret,
|
|
70
|
+
modelPricingSchema,
|
|
71
|
+
parseConfig,
|
|
72
|
+
reasoningEffortSchema,
|
|
73
|
+
withHostSettings,
|
|
74
|
+
DEFAULT_CLASSIFIER_DECIDES,
|
|
75
|
+
INHERIT_MODEL,
|
|
76
|
+
SERVICE_KEY_ENV,
|
|
77
|
+
type ServiceName,
|
|
78
|
+
type CacheConfig,
|
|
79
|
+
type Config,
|
|
80
|
+
type ConfigInput,
|
|
81
|
+
type Credentials,
|
|
82
|
+
type ProviderCacheConfig,
|
|
83
|
+
type ClassifierConfig,
|
|
84
|
+
type ModelPricingConfig,
|
|
85
|
+
type ModelProfile,
|
|
86
|
+
type PermissionDecision,
|
|
87
|
+
type PermissionMode,
|
|
88
|
+
type PermissionRule,
|
|
89
|
+
type ProviderConfig,
|
|
90
|
+
type ReasoningEffort,
|
|
91
|
+
} from "./config/schema";
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
inspectProject,
|
|
95
|
+
loadConfig,
|
|
96
|
+
redactConfig,
|
|
97
|
+
type ConfigOrigin,
|
|
98
|
+
type IgnoredSetting,
|
|
99
|
+
type InspectProjectOptions,
|
|
100
|
+
type LoadConfigOptions,
|
|
101
|
+
type LoadedConfig,
|
|
102
|
+
type ProjectInspection,
|
|
103
|
+
type ProjectTrust,
|
|
104
|
+
} from "./config/load";
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
loadInstructions,
|
|
108
|
+
type InstructionFile,
|
|
109
|
+
type Instructions,
|
|
110
|
+
type InstructionSource,
|
|
111
|
+
type LoadInstructionsOptions,
|
|
112
|
+
} from "./config/instructions";
|
|
113
|
+
|
|
114
|
+
export { readTrust, trustFilePath, writeTrust } from "./config/trust";
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
readConfigLayer,
|
|
118
|
+
setConfigValue,
|
|
119
|
+
targetFor,
|
|
120
|
+
withValueAt,
|
|
121
|
+
type ConfigLayer,
|
|
122
|
+
type SetConfigOptions,
|
|
123
|
+
type SetConfigValue,
|
|
124
|
+
} from "./config/write";
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
PROVIDER_SEPARATOR,
|
|
128
|
+
createProviderRegistry,
|
|
129
|
+
registryFromConfig,
|
|
130
|
+
resolveAuxiliaryModel,
|
|
131
|
+
type AuxiliaryModelOptions,
|
|
132
|
+
type ConfiguredRegistry,
|
|
133
|
+
type ProviderEntry,
|
|
134
|
+
type ProviderKeyOrigin,
|
|
135
|
+
type ProviderRegistry,
|
|
136
|
+
type RegistryFromConfigOptions,
|
|
137
|
+
type RegistryModel,
|
|
138
|
+
type ResolveOptions,
|
|
139
|
+
} from "./providers/registry";
|
|
140
|
+
|
|
141
|
+
export {
|
|
142
|
+
fromAiSdk,
|
|
143
|
+
isModel,
|
|
144
|
+
providerFrom,
|
|
145
|
+
toModel,
|
|
146
|
+
type Model,
|
|
147
|
+
type ModelOverrides,
|
|
148
|
+
type Provider,
|
|
149
|
+
type ProviderOptions,
|
|
150
|
+
type ProviderSetup,
|
|
151
|
+
} from "./providers/model";
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
DEFAULT_CACHE_OPTIONS,
|
|
155
|
+
cacheOptionsFor,
|
|
156
|
+
mergeProviderOptions,
|
|
157
|
+
withRequestFields,
|
|
158
|
+
type CacheDialect,
|
|
159
|
+
type CacheOptions,
|
|
160
|
+
type CacheSupport,
|
|
161
|
+
type CacheTtl,
|
|
162
|
+
type ProviderOptionsMap,
|
|
163
|
+
type RequestFields,
|
|
164
|
+
} from "./providers/cache";
|
|
165
|
+
|
|
166
|
+
export { parseModelCatalog, type CatalogModel } from "./providers/catalog";
|
|
167
|
+
|
|
168
|
+
export { builtinProviderFactories } from "./providers/factories/index";
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
REFRESH_MARGIN_MS,
|
|
172
|
+
REFRESH_TIMEOUT_MS,
|
|
173
|
+
credentialSource,
|
|
174
|
+
memoryCredentialStore,
|
|
175
|
+
notSignedIn,
|
|
176
|
+
type CredentialSourceOptions,
|
|
177
|
+
type CredentialStore,
|
|
178
|
+
type LoginAttempt,
|
|
179
|
+
type OAuthCredential,
|
|
180
|
+
type OAuthMethod,
|
|
181
|
+
type OAuthMethodLoader,
|
|
182
|
+
} from "./providers/oauth";
|
|
183
|
+
|
|
184
|
+
export { builtinOAuthMethods } from "./providers/oauth/methods";
|
|
185
|
+
export { fileCredentialStore } from "./config/credential-file-store";
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
capabilitiesFromTable,
|
|
189
|
+
permissiveCapabilities,
|
|
190
|
+
type ModelCapabilities,
|
|
191
|
+
type ModelInfo,
|
|
192
|
+
type ModelListing,
|
|
193
|
+
} from "./providers/capabilities";
|
|
194
|
+
|
|
195
|
+
export {
|
|
196
|
+
TURN_EFFORT_MODELS,
|
|
197
|
+
TURN_OPTIONS_KEY,
|
|
198
|
+
effortOf,
|
|
199
|
+
explicitEffort,
|
|
200
|
+
quickestEffort,
|
|
201
|
+
type ExplicitEffort,
|
|
202
|
+
} from "./providers/turn-effort";
|
|
203
|
+
|
|
204
|
+
export {
|
|
205
|
+
CAPABILITY_CACHE_VERSION,
|
|
206
|
+
DEFAULT_TTL_MS,
|
|
207
|
+
MODELS_DEV_ENDPOINT,
|
|
208
|
+
createModelsDevCapabilities,
|
|
209
|
+
parseCapabilityIndex,
|
|
210
|
+
parseModelIndex,
|
|
211
|
+
type CapabilityIndex,
|
|
212
|
+
type CapabilityStorage,
|
|
213
|
+
type ModelsDevCapabilities,
|
|
214
|
+
type ModelsDevOptions,
|
|
215
|
+
type RefreshOutcome,
|
|
216
|
+
} from "./providers/models-dev";
|
|
217
|
+
|
|
218
|
+
export {
|
|
219
|
+
CODEX_MODELS,
|
|
220
|
+
catalogTables,
|
|
221
|
+
catalogView,
|
|
222
|
+
listInView,
|
|
223
|
+
lookupInView,
|
|
224
|
+
type CatalogView,
|
|
225
|
+
} from "./providers/catalog-view";
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
findRejectedParameter,
|
|
229
|
+
mapProviderError,
|
|
230
|
+
type ProviderErrorContext,
|
|
231
|
+
} from "./providers/errors";
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
USAGE_KEYS,
|
|
235
|
+
addUsage,
|
|
236
|
+
normaliseUsage,
|
|
237
|
+
type AgentEvent,
|
|
238
|
+
type AgentEventType,
|
|
239
|
+
type CostSource,
|
|
240
|
+
FINISH_REASONS,
|
|
241
|
+
type FinishReason,
|
|
242
|
+
type Usage,
|
|
243
|
+
} from "./events/types";
|
|
244
|
+
|
|
245
|
+
export { createAgent, type Agent, type AgentOptions } from "./agent/agent";
|
|
246
|
+
|
|
247
|
+
export { run, type RunDeps, type RunInput, type RunResult } from "./agent/loop";
|
|
248
|
+
|
|
249
|
+
export { createInbox, type Inbox, type InboxQueue, type InboxRecord } from "./agent/inbox";
|
|
250
|
+
|
|
251
|
+
export {
|
|
252
|
+
createConversation,
|
|
253
|
+
type Conversation,
|
|
254
|
+
type ConversationEvent,
|
|
255
|
+
type ConversationOptions,
|
|
256
|
+
} from "./agent/conversation";
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
DEFAULT_ALLOW_EXCEPTIONS,
|
|
260
|
+
DEFAULT_BLOCK_RULES,
|
|
261
|
+
DEFAULT_ENVIRONMENT,
|
|
262
|
+
classifierSystemPrompt,
|
|
263
|
+
classifyCall,
|
|
264
|
+
createClassifierApproval,
|
|
265
|
+
projectTranscript,
|
|
266
|
+
type ClassifierAbstention,
|
|
267
|
+
type ClassifierDecision,
|
|
268
|
+
type ClassifierOptions,
|
|
269
|
+
type ClassifierOutcome,
|
|
270
|
+
type ClassifierPromptOptions,
|
|
271
|
+
type ClassifierVerdict,
|
|
272
|
+
type ClassifyInput,
|
|
273
|
+
} from "./agent/classifier";
|
|
274
|
+
|
|
275
|
+
export {
|
|
276
|
+
COMPACTION_TEMPLATE,
|
|
277
|
+
IMAGE_TOKEN_ESTIMATE,
|
|
278
|
+
applyCompaction,
|
|
279
|
+
contextUsage,
|
|
280
|
+
createCompactor,
|
|
281
|
+
defaultCompactionPolicy,
|
|
282
|
+
estimateTokens,
|
|
283
|
+
findCut,
|
|
284
|
+
renderTranscript,
|
|
285
|
+
type CompactionInput,
|
|
286
|
+
type CompactionPolicy,
|
|
287
|
+
type CompactionResult,
|
|
288
|
+
type Compactor,
|
|
289
|
+
type CompactorOptions,
|
|
290
|
+
type ContextUsage,
|
|
291
|
+
} from "./agent/compact";
|
|
292
|
+
|
|
293
|
+
export {
|
|
294
|
+
TITLE_TEMPLATE,
|
|
295
|
+
cleanTitle,
|
|
296
|
+
createTitler,
|
|
297
|
+
type TitleSuggestion,
|
|
298
|
+
type Titler,
|
|
299
|
+
type TitlerOptions,
|
|
300
|
+
} from "./agent/title";
|
|
301
|
+
|
|
302
|
+
export {
|
|
303
|
+
CACHE_READ_MULTIPLIER,
|
|
304
|
+
CACHE_WRITE_MULTIPLIER,
|
|
305
|
+
billableInputTokens,
|
|
306
|
+
costOf,
|
|
307
|
+
estimateCost,
|
|
308
|
+
priceCall,
|
|
309
|
+
providerCostMicros,
|
|
310
|
+
resolvePrices,
|
|
311
|
+
routedProvider,
|
|
312
|
+
type ModelPrices,
|
|
313
|
+
} from "./agent/cost";
|
|
314
|
+
|
|
315
|
+
export { TOOL_POLICY_GUIDANCE, composeSystemPrompt } from "./agent/prompts";
|
|
316
|
+
|
|
317
|
+
export { isOnDemandNotice, lastOnDemandNotice, onDemandNames, onDemandNotice } from "./agent/on-demand";
|
|
318
|
+
export {
|
|
319
|
+
instructionFilesOf,
|
|
320
|
+
instructionsMessage,
|
|
321
|
+
isInstructionsMessage,
|
|
322
|
+
lastInstructions,
|
|
323
|
+
} from "./agent/instructions";
|
|
324
|
+
|
|
325
|
+
export {
|
|
326
|
+
attachmentOf,
|
|
327
|
+
hostMessage,
|
|
328
|
+
isHostMessage,
|
|
329
|
+
isSummaryMessage,
|
|
330
|
+
toolResultMessage,
|
|
331
|
+
toolResultValue,
|
|
332
|
+
userInputOf,
|
|
333
|
+
userMessage,
|
|
334
|
+
withUserPrompt,
|
|
335
|
+
type ModelMessage,
|
|
336
|
+
type UserMessage,
|
|
337
|
+
} from "./agent/messages";
|
|
338
|
+
|
|
339
|
+
export {
|
|
340
|
+
IMAGE_MEDIA_TYPES,
|
|
341
|
+
MAX_IMAGE_BASE64,
|
|
342
|
+
MAX_IMAGE_SIDE,
|
|
343
|
+
checkImageSize,
|
|
344
|
+
describeImage,
|
|
345
|
+
imageFromBytes,
|
|
346
|
+
imageInfo,
|
|
347
|
+
looksLikeImage,
|
|
348
|
+
toUserInput,
|
|
349
|
+
type Attachment,
|
|
350
|
+
type ImageInfo,
|
|
351
|
+
type Prompt,
|
|
352
|
+
type UserInput,
|
|
353
|
+
} from "./agent/attachments";
|
|
354
|
+
|
|
355
|
+
export { imageLeftOut, imagesForModel, imagesNote, takesImages } from "./agent/request-images";
|
|
356
|
+
|
|
357
|
+
export {
|
|
358
|
+
anyOf,
|
|
359
|
+
hasToolCall,
|
|
360
|
+
isStepCount,
|
|
361
|
+
isTokenCount,
|
|
362
|
+
type LoopState,
|
|
363
|
+
type StopCondition,
|
|
364
|
+
} from "./agent/stop";
|
|
365
|
+
|
|
366
|
+
export {
|
|
367
|
+
emptyToolRunner,
|
|
368
|
+
type Preflight,
|
|
369
|
+
type ToolCall,
|
|
370
|
+
type ToolOutcome,
|
|
371
|
+
type ToolRunContext,
|
|
372
|
+
type ToolRunner,
|
|
373
|
+
} from "./agent/tools";
|
|
374
|
+
|
|
375
|
+
export { couldMatchInside, globToRegExp, matchGlob } from "./glob";
|
|
376
|
+
|
|
377
|
+
export {
|
|
378
|
+
defineTool,
|
|
379
|
+
// The list, not just the type: anything drawing danger levels needs to
|
|
380
|
+
// enumerate them. A host that retypes the five names goes stale in silence.
|
|
381
|
+
DANGER_LEVELS,
|
|
382
|
+
type AgentTool,
|
|
383
|
+
type AgentToolDefinition,
|
|
384
|
+
type BackgroundSpec,
|
|
385
|
+
type DangerLevel,
|
|
386
|
+
type DelegateOptions,
|
|
387
|
+
type Delegation,
|
|
388
|
+
type ResourceClaim,
|
|
389
|
+
type ToolContext,
|
|
390
|
+
type ToolTask,
|
|
391
|
+
} from "./tools/define";
|
|
392
|
+
|
|
393
|
+
export { compactChange, type FileChange, type FileEdit } from "./tools/change";
|
|
394
|
+
|
|
395
|
+
export { BUILTIN_SOURCE_ID, exposedName, type ToolSource } from "./tools/source";
|
|
396
|
+
|
|
397
|
+
export {
|
|
398
|
+
callLine,
|
|
399
|
+
describeCall,
|
|
400
|
+
describeTools,
|
|
401
|
+
isRunningResult,
|
|
402
|
+
type ToolDescriber,
|
|
403
|
+
type ToolDescription,
|
|
404
|
+
} from "./tools/describe";
|
|
405
|
+
|
|
406
|
+
export {
|
|
407
|
+
TASKS_SOURCE_ID,
|
|
408
|
+
TASK_STOP_NAME,
|
|
409
|
+
TASK_TAIL_BYTES,
|
|
410
|
+
TASK_WAIT_NAME,
|
|
411
|
+
createTaskRegistry,
|
|
412
|
+
type OpenTask,
|
|
413
|
+
type TaskInbox,
|
|
414
|
+
type TaskRegistry,
|
|
415
|
+
type TaskRegistryOptions,
|
|
416
|
+
type TaskSnapshot,
|
|
417
|
+
type TaskSpec,
|
|
418
|
+
type TaskWaitOutcome,
|
|
419
|
+
} from "./tools/tasks";
|
|
420
|
+
|
|
421
|
+
export {
|
|
422
|
+
REPORT_LIMIT_BYTES,
|
|
423
|
+
SEND_MESSAGE_NAME,
|
|
424
|
+
SUBAGENTS_SOURCE_ID,
|
|
425
|
+
SUBAGENT_NAME,
|
|
426
|
+
SUBAGENT_SESSION_SOURCE,
|
|
427
|
+
builtinSubagents,
|
|
428
|
+
createSubagents,
|
|
429
|
+
type SubagentSnapshot,
|
|
430
|
+
type SubagentType,
|
|
431
|
+
type Subagents,
|
|
432
|
+
type SubagentsOptions,
|
|
433
|
+
} from "./tools/subagents";
|
|
434
|
+
|
|
435
|
+
export {
|
|
436
|
+
builtinToolSource,
|
|
437
|
+
builtinTools,
|
|
438
|
+
type BuiltinToolOptions,
|
|
439
|
+
} from "./tools/builtin";
|
|
440
|
+
|
|
441
|
+
export {
|
|
442
|
+
WEB_SOURCE_ID,
|
|
443
|
+
webToolSource,
|
|
444
|
+
webTools,
|
|
445
|
+
type WebToolOptions,
|
|
446
|
+
} from "./tools/web/source";
|
|
447
|
+
|
|
448
|
+
export { createWebFetchTool, type WebFetchOptions } from "./tools/web/fetch";
|
|
449
|
+
|
|
450
|
+
export {
|
|
451
|
+
createWebSearchTool,
|
|
452
|
+
type WebSearch,
|
|
453
|
+
type WebSearchResult,
|
|
454
|
+
} from "./tools/web/search";
|
|
455
|
+
|
|
456
|
+
export { exaSearch, type ExaSearchOptions } from "./tools/web/exa";
|
|
457
|
+
|
|
458
|
+
export type { HostLookup } from "./tools/web/address";
|
|
459
|
+
|
|
460
|
+
export { createBashTool, type BashToolOptions } from "./tools/shell/bash";
|
|
461
|
+
|
|
462
|
+
export { createGrepTool, type GrepToolOptions } from "./tools/fs/grep";
|
|
463
|
+
|
|
464
|
+
export {
|
|
465
|
+
RIPGREP_COMMAND,
|
|
466
|
+
checkRipgrep,
|
|
467
|
+
describeRipgrep,
|
|
468
|
+
resolveRipgrep,
|
|
469
|
+
unpackedRipgrepPath,
|
|
470
|
+
withSpawnRetry,
|
|
471
|
+
type BundledRipgrep,
|
|
472
|
+
type RipgrepDeps,
|
|
473
|
+
type RipgrepLocation,
|
|
474
|
+
type RipgrepOptions,
|
|
475
|
+
type RipgrepStatus,
|
|
476
|
+
} from "./tools/fs/ripgrep";
|
|
477
|
+
|
|
478
|
+
export {
|
|
479
|
+
bashPathFromExecPath,
|
|
480
|
+
checkBash,
|
|
481
|
+
describeBash,
|
|
482
|
+
findBash,
|
|
483
|
+
type BashStatus,
|
|
484
|
+
type CheckBashDeps,
|
|
485
|
+
type FindBashDeps,
|
|
486
|
+
} from "./tools/shell/find-bash";
|
|
487
|
+
|
|
488
|
+
export {
|
|
489
|
+
ON_DEMAND_SOURCE_ID,
|
|
490
|
+
createToolRegistry,
|
|
491
|
+
type ToolRegistry,
|
|
492
|
+
type ToolRegistryEntry,
|
|
493
|
+
type ToolRegistryOptions,
|
|
494
|
+
} from "./tools/registry";
|
|
495
|
+
|
|
496
|
+
export {
|
|
497
|
+
DEFAULT_MCP_CALL_TIMEOUT_MS,
|
|
498
|
+
MCP_SERVER_NAME,
|
|
499
|
+
checkMcpServer,
|
|
500
|
+
expandVariables,
|
|
501
|
+
mcpServerSchema,
|
|
502
|
+
type McpOAuthSettings,
|
|
503
|
+
type McpServerCheck,
|
|
504
|
+
type McpServerConfig,
|
|
505
|
+
type ResolvedMcpServer,
|
|
506
|
+
} from "./tools/mcp/config";
|
|
507
|
+
|
|
508
|
+
export {
|
|
509
|
+
MCP_SOURCE_ID,
|
|
510
|
+
createMcpServers,
|
|
511
|
+
type McpServerState,
|
|
512
|
+
type McpServerStatus,
|
|
513
|
+
type McpServers,
|
|
514
|
+
type McpServersOptions,
|
|
515
|
+
type McpSignInOptions,
|
|
516
|
+
} from "./tools/mcp/servers";
|
|
517
|
+
|
|
518
|
+
export {
|
|
519
|
+
fileMcpAuthStore,
|
|
520
|
+
memoryMcpAuthStore,
|
|
521
|
+
type McpAuthEntry,
|
|
522
|
+
type McpAuthStore,
|
|
523
|
+
} from "./tools/mcp/auth-store";
|
|
524
|
+
|
|
525
|
+
export type { SignIn } from "./sign-in/attempt";
|
|
526
|
+
|
|
527
|
+
export {
|
|
528
|
+
CALL_TOOL_NAME,
|
|
529
|
+
SEARCH_TOOLS_NAME,
|
|
530
|
+
parametersOf,
|
|
531
|
+
searchCatalog,
|
|
532
|
+
type FoundTool,
|
|
533
|
+
type SearchResult,
|
|
534
|
+
} from "./tools/on-demand";
|
|
535
|
+
|
|
536
|
+
export { toModelTool, toModelTools, type ModelToolDefinition } from "./tools/to-model";
|
|
537
|
+
|
|
538
|
+
export {
|
|
539
|
+
runProcess,
|
|
540
|
+
stopRunningProcesses,
|
|
541
|
+
type ProcessResult,
|
|
542
|
+
type RunProcessOptions,
|
|
543
|
+
} from "./tools/bin";
|
|
544
|
+
export { describeJobRunner, jobRunner, type JobRunnerStatus } from "./tools/job";
|
|
545
|
+
|
|
546
|
+
export { formatDuration } from "./units";
|
|
547
|
+
|
|
548
|
+
export {
|
|
549
|
+
SPILL_LIMIT_BYTES,
|
|
550
|
+
formatBytes,
|
|
551
|
+
openSpill,
|
|
552
|
+
type Spill,
|
|
553
|
+
type SpillOptions,
|
|
554
|
+
type SpilledFile,
|
|
555
|
+
} from "./tools/spill";
|
|
556
|
+
|
|
557
|
+
export {
|
|
558
|
+
displayPath,
|
|
559
|
+
extraRootOf,
|
|
560
|
+
isInsideWorkspace,
|
|
561
|
+
pathOrRoot,
|
|
562
|
+
resolveInWorkspace,
|
|
563
|
+
toPosix,
|
|
564
|
+
workspaceRelative,
|
|
565
|
+
type ExtraRoot,
|
|
566
|
+
type PathScope,
|
|
567
|
+
} from "./paths";
|
|
568
|
+
|
|
569
|
+
export { createPermissionPolicy, type PolicyOptions } from "./permissions/policy";
|
|
570
|
+
export { createLayeredPolicy, type SessionPermissions } from "./permissions/layered";
|
|
571
|
+
|
|
572
|
+
export {
|
|
573
|
+
describeRule,
|
|
574
|
+
hostOf,
|
|
575
|
+
matchPattern,
|
|
576
|
+
ruleMatches,
|
|
577
|
+
type RuleTarget,
|
|
578
|
+
} from "./permissions/match";
|
|
579
|
+
|
|
580
|
+
export { analyzeCommand, type CommandAnalysis } from "./permissions/command";
|
|
581
|
+
|
|
582
|
+
export { chainApproval } from "./permissions/chain";
|
|
583
|
+
export {
|
|
584
|
+
approvalModes,
|
|
585
|
+
type ApprovalMode,
|
|
586
|
+
type ApprovalModeOptions,
|
|
587
|
+
type ApprovalModes,
|
|
588
|
+
} from "./permissions/modes";
|
|
589
|
+
|
|
590
|
+
export { resolveApproval } from "./permissions/types";
|
|
591
|
+
|
|
592
|
+
export type {
|
|
593
|
+
ApprovalContext,
|
|
594
|
+
ApprovalDecidedBy,
|
|
595
|
+
ApprovalDecision,
|
|
596
|
+
ApprovalHandler,
|
|
597
|
+
ApprovalOutcome,
|
|
598
|
+
ApprovalRequest,
|
|
599
|
+
ApprovalResolution,
|
|
600
|
+
PermissionPolicy,
|
|
601
|
+
PermissionPolicyConfig,
|
|
602
|
+
PermissionPolicyInput,
|
|
603
|
+
PermissionQuery,
|
|
604
|
+
PermissionVerdict,
|
|
605
|
+
WorkspaceWrites,
|
|
606
|
+
} from "./permissions/types";
|
|
607
|
+
|
|
608
|
+
export {
|
|
609
|
+
createSession,
|
|
610
|
+
resumeModel,
|
|
611
|
+
sessionModel,
|
|
612
|
+
sourceOf,
|
|
613
|
+
summarize,
|
|
614
|
+
type CreateSessionInit,
|
|
615
|
+
type ResumedModel,
|
|
616
|
+
type Session,
|
|
617
|
+
type SessionModel,
|
|
618
|
+
type SessionSummary,
|
|
619
|
+
} from "./session/session";
|
|
620
|
+
|
|
621
|
+
export {
|
|
622
|
+
createSessionStore,
|
|
623
|
+
type SessionStore,
|
|
624
|
+
type SessionStoreOptions,
|
|
625
|
+
} from "./session/store";
|
|
626
|
+
|
|
627
|
+
export type { SessionBackend, SessionEnds } from "./session/backend";
|
|
628
|
+
|
|
629
|
+
export {
|
|
630
|
+
SESSION_FORMAT_VERSION,
|
|
631
|
+
TASK_STATES,
|
|
632
|
+
TASK_STOPPERS,
|
|
633
|
+
TITLE_SOURCES,
|
|
634
|
+
advanceStats,
|
|
635
|
+
applyRecords,
|
|
636
|
+
decodeLog,
|
|
637
|
+
encodeRecord,
|
|
638
|
+
messageOf,
|
|
639
|
+
migrate,
|
|
640
|
+
migrations,
|
|
641
|
+
project,
|
|
642
|
+
statsFromCheckpoint,
|
|
643
|
+
statsOf,
|
|
644
|
+
summaryFrom,
|
|
645
|
+
summaryMessage,
|
|
646
|
+
unfinishedTasks,
|
|
647
|
+
usageOwed,
|
|
648
|
+
type LogStats,
|
|
649
|
+
type Migration,
|
|
650
|
+
type SessionRecord,
|
|
651
|
+
type SessionRecordInput,
|
|
652
|
+
type SessionRecordType,
|
|
653
|
+
type TaskState,
|
|
654
|
+
type TaskStopper,
|
|
655
|
+
type TitleSource,
|
|
656
|
+
} from "./session/format";
|
|
657
|
+
|
|
658
|
+
export {
|
|
659
|
+
createMemorySessionBackend,
|
|
660
|
+
createMemorySessionStore,
|
|
661
|
+
type MemorySessionStoreOptions,
|
|
662
|
+
} from "./session/memory-store";
|
|
663
|
+
|
|
664
|
+
export {
|
|
665
|
+
createFileSessionBackend,
|
|
666
|
+
createFileSessionStore,
|
|
667
|
+
sessionSideDir,
|
|
668
|
+
subagentSessionStore,
|
|
669
|
+
type FileSessionBackendOptions,
|
|
670
|
+
type FileSessionStoreOptions,
|
|
671
|
+
} from "./session/file-store";
|
|
672
|
+
|
|
673
|
+
export {
|
|
674
|
+
settingsFromProfile,
|
|
675
|
+
type AgentLanguageModel,
|
|
676
|
+
type ModelCallSettings,
|
|
677
|
+
type ProviderFactory,
|
|
678
|
+
type ProviderFactoryContext,
|
|
679
|
+
type ProviderFactoryLoader,
|
|
680
|
+
type ProviderInstance,
|
|
681
|
+
} from "./providers/types";
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core never writes to a terminal, so logging is a port. Hosts pass an
|
|
3
|
+
* implementation in; tests pass a recorder; the default swallows everything.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
7
|
+
|
|
8
|
+
export type LogFields = Record<string, unknown>;
|
|
9
|
+
|
|
10
|
+
export interface Logger {
|
|
11
|
+
error(message: string, fields?: LogFields): void;
|
|
12
|
+
warn(message: string, fields?: LogFields): void;
|
|
13
|
+
info(message: string, fields?: LogFields): void;
|
|
14
|
+
debug(message: string, fields?: LogFields): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const LEVEL_RANK: Record<LogLevel, number> = {
|
|
18
|
+
silent: 0,
|
|
19
|
+
error: 1,
|
|
20
|
+
warn: 2,
|
|
21
|
+
info: 3,
|
|
22
|
+
debug: 4,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const noopLogger: Logger = {
|
|
26
|
+
error: () => {},
|
|
27
|
+
warn: () => {},
|
|
28
|
+
info: () => {},
|
|
29
|
+
debug: () => {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Wraps a logger so calls below `level` are dropped before reaching it. */
|
|
33
|
+
export function withLevel(logger: Logger, level: LogLevel): Logger {
|
|
34
|
+
const threshold = LEVEL_RANK[level];
|
|
35
|
+
const gate =
|
|
36
|
+
(method: keyof Logger, rank: number) =>
|
|
37
|
+
(message: string, fields?: LogFields): void => {
|
|
38
|
+
if (rank <= threshold) logger[method](message, fields);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
error: gate("error", LEVEL_RANK.error),
|
|
43
|
+
warn: gate("warn", LEVEL_RANK.warn),
|
|
44
|
+
info: gate("info", LEVEL_RANK.info),
|
|
45
|
+
debug: gate("debug", LEVEL_RANK.debug),
|
|
46
|
+
};
|
|
47
|
+
}
|