@letta-ai/letta-code 0.10.0 → 0.10.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/letta.js +736 -710
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -3233,7 +3233,7 @@ var package_default;
|
|
|
3233
3233
|
var init_package = __esm(() => {
|
|
3234
3234
|
package_default = {
|
|
3235
3235
|
name: "@letta-ai/letta-code",
|
|
3236
|
-
version: "0.10.
|
|
3236
|
+
version: "0.10.1",
|
|
3237
3237
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
3238
3238
|
type: "module",
|
|
3239
3239
|
bin: {
|
|
@@ -27952,6 +27952,9 @@ var init_colors = __esm(() => {
|
|
|
27952
27952
|
normal: "white",
|
|
27953
27953
|
dim: "gray",
|
|
27954
27954
|
bold: "white"
|
|
27955
|
+
},
|
|
27956
|
+
footer: {
|
|
27957
|
+
agentName: brandColors.primaryAccent
|
|
27955
27958
|
}
|
|
27956
27959
|
};
|
|
27957
27960
|
});
|
|
@@ -29033,8 +29036,8 @@ var init_models2 = __esm(() => {
|
|
|
29033
29036
|
{
|
|
29034
29037
|
id: "sonnet-4.5",
|
|
29035
29038
|
handle: "anthropic/claude-sonnet-4-5-20250929",
|
|
29036
|
-
label: "
|
|
29037
|
-
description: "The recommended default model
|
|
29039
|
+
label: "Sonnet 4.5",
|
|
29040
|
+
description: "The recommended default model",
|
|
29038
29041
|
isDefault: true,
|
|
29039
29042
|
isFeatured: true,
|
|
29040
29043
|
updateArgs: {
|
|
@@ -29046,8 +29049,8 @@ var init_models2 = __esm(() => {
|
|
|
29046
29049
|
{
|
|
29047
29050
|
id: "sonnet-4.5-no-reasoning",
|
|
29048
29051
|
handle: "anthropic/claude-sonnet-4-5-20250929",
|
|
29049
|
-
label: "
|
|
29050
|
-
description: "Sonnet 4.5 with
|
|
29052
|
+
label: "Sonnet 4.5",
|
|
29053
|
+
description: "Sonnet 4.5 with no reasoning (faster)",
|
|
29051
29054
|
updateArgs: {
|
|
29052
29055
|
enable_reasoner: false,
|
|
29053
29056
|
context_window: 180000,
|
|
@@ -29057,8 +29060,8 @@ var init_models2 = __esm(() => {
|
|
|
29057
29060
|
{
|
|
29058
29061
|
id: "opus",
|
|
29059
29062
|
handle: "anthropic/claude-opus-4-5-20251101",
|
|
29060
|
-
label: "
|
|
29061
|
-
description: "Anthropic's
|
|
29063
|
+
label: "Opus 4.5",
|
|
29064
|
+
description: "Anthropic's best model",
|
|
29062
29065
|
isFeatured: true,
|
|
29063
29066
|
updateArgs: {
|
|
29064
29067
|
context_window: 180000,
|
|
@@ -29069,7 +29072,7 @@ var init_models2 = __esm(() => {
|
|
|
29069
29072
|
{
|
|
29070
29073
|
id: "haiku",
|
|
29071
29074
|
handle: "anthropic/claude-haiku-4-5-20251001",
|
|
29072
|
-
label: "
|
|
29075
|
+
label: "Haiku 4.5",
|
|
29073
29076
|
description: "Anthropic's fastest model",
|
|
29074
29077
|
isFeatured: true,
|
|
29075
29078
|
updateArgs: {
|
|
@@ -29080,7 +29083,7 @@ var init_models2 = __esm(() => {
|
|
|
29080
29083
|
{
|
|
29081
29084
|
id: "sonnet-4.5-pro-max",
|
|
29082
29085
|
handle: "claude-pro-max/claude-sonnet-4-5-20250929",
|
|
29083
|
-
label: "
|
|
29086
|
+
label: "Sonnet 4.5",
|
|
29084
29087
|
description: "Sonnet 4.5 via Claude Pro/Max Plan",
|
|
29085
29088
|
updateArgs: {
|
|
29086
29089
|
context_window: 180000,
|
|
@@ -29091,8 +29094,8 @@ var init_models2 = __esm(() => {
|
|
|
29091
29094
|
{
|
|
29092
29095
|
id: "sonnet-4.5-no-reasoning-pro-max",
|
|
29093
29096
|
handle: "claude-pro-max/claude-sonnet-4-5-20250929",
|
|
29094
|
-
label: "
|
|
29095
|
-
description: "Sonnet 4.5 via Claude Pro/Max Plan
|
|
29097
|
+
label: "Sonnet 4.5",
|
|
29098
|
+
description: "Sonnet 4.5 (no reasoning) via Claude Pro/Max Plan",
|
|
29096
29099
|
updateArgs: {
|
|
29097
29100
|
enable_reasoner: false,
|
|
29098
29101
|
context_window: 180000,
|
|
@@ -29102,7 +29105,7 @@ var init_models2 = __esm(() => {
|
|
|
29102
29105
|
{
|
|
29103
29106
|
id: "opus-pro-max",
|
|
29104
29107
|
handle: "claude-pro-max/claude-opus-4-5-20251101",
|
|
29105
|
-
label: "
|
|
29108
|
+
label: "Opus 4.5",
|
|
29106
29109
|
description: "Opus 4.5 via Claude Pro/Max Plan",
|
|
29107
29110
|
updateArgs: {
|
|
29108
29111
|
context_window: 180000,
|
|
@@ -29113,7 +29116,7 @@ var init_models2 = __esm(() => {
|
|
|
29113
29116
|
{
|
|
29114
29117
|
id: "haiku-pro-max",
|
|
29115
29118
|
handle: "claude-pro-max/claude-haiku-4-5-20251001",
|
|
29116
|
-
label: "
|
|
29119
|
+
label: "Haiku 4.5",
|
|
29117
29120
|
description: "Haiku 4.5 via Claude Pro/Max Plan",
|
|
29118
29121
|
updateArgs: {
|
|
29119
29122
|
context_window: 180000,
|
|
@@ -29124,7 +29127,7 @@ var init_models2 = __esm(() => {
|
|
|
29124
29127
|
id: "gpt-5-codex",
|
|
29125
29128
|
handle: "openai/gpt-5-codex",
|
|
29126
29129
|
label: "GPT-5-Codex",
|
|
29127
|
-
description: "
|
|
29130
|
+
description: "GPT-5 variant (med reasoning) optimized for coding",
|
|
29128
29131
|
updateArgs: {
|
|
29129
29132
|
reasoning_effort: "medium",
|
|
29130
29133
|
verbosity: "medium",
|
|
@@ -29135,8 +29138,8 @@ var init_models2 = __esm(() => {
|
|
|
29135
29138
|
{
|
|
29136
29139
|
id: "gpt-5.2-none",
|
|
29137
29140
|
handle: "openai/gpt-5.2",
|
|
29138
|
-
label: "GPT-5.2
|
|
29139
|
-
description: "
|
|
29141
|
+
label: "GPT-5.2",
|
|
29142
|
+
description: "Latest general-purpose GPT (no reasoning)",
|
|
29140
29143
|
updateArgs: {
|
|
29141
29144
|
reasoning_effort: "none",
|
|
29142
29145
|
verbosity: "medium",
|
|
@@ -29147,8 +29150,8 @@ var init_models2 = __esm(() => {
|
|
|
29147
29150
|
{
|
|
29148
29151
|
id: "gpt-5.2-low",
|
|
29149
29152
|
handle: "openai/gpt-5.2",
|
|
29150
|
-
label: "GPT-5.2
|
|
29151
|
-
description: "
|
|
29153
|
+
label: "GPT-5.2",
|
|
29154
|
+
description: "Latest general-purpose GPT (low reasoning)",
|
|
29152
29155
|
updateArgs: {
|
|
29153
29156
|
reasoning_effort: "low",
|
|
29154
29157
|
verbosity: "medium",
|
|
@@ -29159,8 +29162,8 @@ var init_models2 = __esm(() => {
|
|
|
29159
29162
|
{
|
|
29160
29163
|
id: "gpt-5.2-medium",
|
|
29161
29164
|
handle: "openai/gpt-5.2",
|
|
29162
|
-
label: "GPT-5.2
|
|
29163
|
-
description: "
|
|
29165
|
+
label: "GPT-5.2",
|
|
29166
|
+
description: "Latest general-purpose GPT (med reasoning)",
|
|
29164
29167
|
isFeatured: true,
|
|
29165
29168
|
updateArgs: {
|
|
29166
29169
|
reasoning_effort: "medium",
|
|
@@ -29172,8 +29175,8 @@ var init_models2 = __esm(() => {
|
|
|
29172
29175
|
{
|
|
29173
29176
|
id: "gpt-5.2-high",
|
|
29174
29177
|
handle: "openai/gpt-5.2",
|
|
29175
|
-
label: "GPT-5.2
|
|
29176
|
-
description: "
|
|
29178
|
+
label: "GPT-5.2",
|
|
29179
|
+
description: "Latest general-purpose GPT (high reasoning)",
|
|
29177
29180
|
updateArgs: {
|
|
29178
29181
|
reasoning_effort: "high",
|
|
29179
29182
|
verbosity: "medium",
|
|
@@ -29184,8 +29187,8 @@ var init_models2 = __esm(() => {
|
|
|
29184
29187
|
{
|
|
29185
29188
|
id: "gpt-5.2-xhigh",
|
|
29186
29189
|
handle: "openai/gpt-5.2",
|
|
29187
|
-
label: "GPT-5.2
|
|
29188
|
-
description: "
|
|
29190
|
+
label: "GPT-5.2",
|
|
29191
|
+
description: "Latest general-purpose GPT (max reasoning)",
|
|
29189
29192
|
updateArgs: {
|
|
29190
29193
|
reasoning_effort: "xhigh",
|
|
29191
29194
|
verbosity: "medium",
|
|
@@ -29196,8 +29199,8 @@ var init_models2 = __esm(() => {
|
|
|
29196
29199
|
{
|
|
29197
29200
|
id: "gpt-5.1-none",
|
|
29198
29201
|
handle: "openai/gpt-5.1",
|
|
29199
|
-
label: "GPT-5.1
|
|
29200
|
-
description: "
|
|
29202
|
+
label: "GPT-5.1",
|
|
29203
|
+
description: "Legacy GPT-5.1 (no reasoning)",
|
|
29201
29204
|
updateArgs: {
|
|
29202
29205
|
reasoning_effort: "none",
|
|
29203
29206
|
verbosity: "medium",
|
|
@@ -29208,8 +29211,8 @@ var init_models2 = __esm(() => {
|
|
|
29208
29211
|
{
|
|
29209
29212
|
id: "gpt-5.1-low",
|
|
29210
29213
|
handle: "openai/gpt-5.1",
|
|
29211
|
-
label: "GPT-5.1
|
|
29212
|
-
description: "
|
|
29214
|
+
label: "GPT-5.1",
|
|
29215
|
+
description: "Legacy GPT-5.1 (low reasoning)",
|
|
29213
29216
|
updateArgs: {
|
|
29214
29217
|
reasoning_effort: "low",
|
|
29215
29218
|
verbosity: "medium",
|
|
@@ -29220,8 +29223,8 @@ var init_models2 = __esm(() => {
|
|
|
29220
29223
|
{
|
|
29221
29224
|
id: "gpt-5.1-medium",
|
|
29222
29225
|
handle: "openai/gpt-5.1",
|
|
29223
|
-
label: "GPT-5.1
|
|
29224
|
-
description: "
|
|
29226
|
+
label: "GPT-5.1",
|
|
29227
|
+
description: "Legacy GPT-5.1 (med reasoning)",
|
|
29225
29228
|
updateArgs: {
|
|
29226
29229
|
reasoning_effort: "medium",
|
|
29227
29230
|
verbosity: "medium",
|
|
@@ -29232,8 +29235,8 @@ var init_models2 = __esm(() => {
|
|
|
29232
29235
|
{
|
|
29233
29236
|
id: "gpt-5.1-high",
|
|
29234
29237
|
handle: "openai/gpt-5.1",
|
|
29235
|
-
label: "GPT-5.1
|
|
29236
|
-
description: "
|
|
29238
|
+
label: "GPT-5.1",
|
|
29239
|
+
description: "Legacy GPT-5.1 (high reasoning)",
|
|
29237
29240
|
updateArgs: {
|
|
29238
29241
|
reasoning_effort: "high",
|
|
29239
29242
|
verbosity: "medium",
|
|
@@ -29244,8 +29247,8 @@ var init_models2 = __esm(() => {
|
|
|
29244
29247
|
{
|
|
29245
29248
|
id: "gpt-5.1-codex-none",
|
|
29246
29249
|
handle: "openai/gpt-5.1-codex",
|
|
29247
|
-
label: "GPT-5.1-Codex
|
|
29248
|
-
description: "GPT-5.1
|
|
29250
|
+
label: "GPT-5.1-Codex",
|
|
29251
|
+
description: "GPT-5.1 variant (no reasoning) optimized for coding",
|
|
29249
29252
|
updateArgs: {
|
|
29250
29253
|
reasoning_effort: "none",
|
|
29251
29254
|
verbosity: "medium",
|
|
@@ -29256,8 +29259,8 @@ var init_models2 = __esm(() => {
|
|
|
29256
29259
|
{
|
|
29257
29260
|
id: "gpt-5.1-codex-medium",
|
|
29258
29261
|
handle: "openai/gpt-5.1-codex",
|
|
29259
|
-
label: "GPT-5.1-Codex
|
|
29260
|
-
description: "GPT-5.1
|
|
29262
|
+
label: "GPT-5.1-Codex",
|
|
29263
|
+
description: "GPT-5.1 variant (med reasoning) optimized for coding",
|
|
29261
29264
|
isFeatured: true,
|
|
29262
29265
|
updateArgs: {
|
|
29263
29266
|
reasoning_effort: "medium",
|
|
@@ -29269,8 +29272,8 @@ var init_models2 = __esm(() => {
|
|
|
29269
29272
|
{
|
|
29270
29273
|
id: "gpt-5.1-codex-high",
|
|
29271
29274
|
handle: "openai/gpt-5.1-codex",
|
|
29272
|
-
label: "GPT-5.1-Codex
|
|
29273
|
-
description: "GPT-5.1
|
|
29275
|
+
label: "GPT-5.1-Codex",
|
|
29276
|
+
description: "GPT-5.1 variant (max reasoning) optimized for coding",
|
|
29274
29277
|
updateArgs: {
|
|
29275
29278
|
reasoning_effort: "high",
|
|
29276
29279
|
verbosity: "medium",
|
|
@@ -29281,8 +29284,8 @@ var init_models2 = __esm(() => {
|
|
|
29281
29284
|
{
|
|
29282
29285
|
id: "gpt-5.1-codex-max-medium",
|
|
29283
29286
|
handle: "openai/gpt-5.1-codex-max",
|
|
29284
|
-
label: "GPT-5.1-Codex
|
|
29285
|
-
description: "GPT-5.1-Codex
|
|
29287
|
+
label: "GPT-5.1-Codex-Max",
|
|
29288
|
+
description: "GPT-5.1-Codex 'Max' variant (med reasoning)",
|
|
29286
29289
|
updateArgs: {
|
|
29287
29290
|
reasoning_effort: "medium",
|
|
29288
29291
|
verbosity: "medium",
|
|
@@ -29293,8 +29296,8 @@ var init_models2 = __esm(() => {
|
|
|
29293
29296
|
{
|
|
29294
29297
|
id: "gpt-5.1-codex-max-high",
|
|
29295
29298
|
handle: "openai/gpt-5.1-codex-max",
|
|
29296
|
-
label: "GPT-5.1-Codex
|
|
29297
|
-
description: "GPT-5.1-Codex
|
|
29299
|
+
label: "GPT-5.1-Codex-Max",
|
|
29300
|
+
description: "GPT-5.1-Codex 'Max' variant (high reasoning)",
|
|
29298
29301
|
updateArgs: {
|
|
29299
29302
|
reasoning_effort: "high",
|
|
29300
29303
|
verbosity: "medium",
|
|
@@ -29305,8 +29308,8 @@ var init_models2 = __esm(() => {
|
|
|
29305
29308
|
{
|
|
29306
29309
|
id: "gpt-5.1-codex-max-x-high",
|
|
29307
29310
|
handle: "openai/gpt-5.1-codex-max",
|
|
29308
|
-
label: "GPT-5.1-Codex
|
|
29309
|
-
description: "GPT-5.1-Codex
|
|
29311
|
+
label: "GPT-5.1-Codex-Max",
|
|
29312
|
+
description: "GPT-5.1-Codex 'Max' variant (extra-high reasoning)",
|
|
29310
29313
|
updateArgs: {
|
|
29311
29314
|
reasoning_effort: "xhigh",
|
|
29312
29315
|
verbosity: "medium",
|
|
@@ -29317,8 +29320,8 @@ var init_models2 = __esm(() => {
|
|
|
29317
29320
|
{
|
|
29318
29321
|
id: "gpt-5-minimal",
|
|
29319
29322
|
handle: "openai/gpt-5",
|
|
29320
|
-
label: "GPT-5
|
|
29321
|
-
description: "
|
|
29323
|
+
label: "GPT-5",
|
|
29324
|
+
description: "Legacy GPT-5 (minimal reasoning)",
|
|
29322
29325
|
updateArgs: {
|
|
29323
29326
|
reasoning_effort: "minimal",
|
|
29324
29327
|
verbosity: "medium",
|
|
@@ -29328,8 +29331,8 @@ var init_models2 = __esm(() => {
|
|
|
29328
29331
|
{
|
|
29329
29332
|
id: "gpt-5-low",
|
|
29330
29333
|
handle: "openai/gpt-5",
|
|
29331
|
-
label: "GPT-5
|
|
29332
|
-
description: "
|
|
29334
|
+
label: "GPT-5",
|
|
29335
|
+
description: "Legacy GPT-5 (low reasoning)",
|
|
29333
29336
|
updateArgs: {
|
|
29334
29337
|
reasoning_effort: "low",
|
|
29335
29338
|
verbosity: "medium",
|
|
@@ -29339,8 +29342,8 @@ var init_models2 = __esm(() => {
|
|
|
29339
29342
|
{
|
|
29340
29343
|
id: "gpt-5-medium",
|
|
29341
29344
|
handle: "openai/gpt-5",
|
|
29342
|
-
label: "GPT-5
|
|
29343
|
-
description: "
|
|
29345
|
+
label: "GPT-5",
|
|
29346
|
+
description: "Legacy GPT-5 (med reasoning)",
|
|
29344
29347
|
updateArgs: {
|
|
29345
29348
|
reasoning_effort: "medium",
|
|
29346
29349
|
verbosity: "medium",
|
|
@@ -29350,8 +29353,8 @@ var init_models2 = __esm(() => {
|
|
|
29350
29353
|
{
|
|
29351
29354
|
id: "gpt-5-high",
|
|
29352
29355
|
handle: "openai/gpt-5",
|
|
29353
|
-
label: "GPT-5
|
|
29354
|
-
description: "
|
|
29356
|
+
label: "GPT-5",
|
|
29357
|
+
description: "Legacy GPT-5 (high reasoning)",
|
|
29355
29358
|
updateArgs: {
|
|
29356
29359
|
reasoning_effort: "high",
|
|
29357
29360
|
verbosity: "medium",
|
|
@@ -29361,8 +29364,8 @@ var init_models2 = __esm(() => {
|
|
|
29361
29364
|
{
|
|
29362
29365
|
id: "gpt-5-mini-medium",
|
|
29363
29366
|
handle: "openai/gpt-5-mini-2025-08-07",
|
|
29364
|
-
label: "GPT-5-Mini
|
|
29365
|
-
description: "
|
|
29367
|
+
label: "GPT-5-Mini",
|
|
29368
|
+
description: "GPT-5-Mini (medium reasoning)",
|
|
29366
29369
|
updateArgs: {
|
|
29367
29370
|
reasoning_effort: "medium",
|
|
29368
29371
|
verbosity: "medium",
|
|
@@ -29372,8 +29375,8 @@ var init_models2 = __esm(() => {
|
|
|
29372
29375
|
{
|
|
29373
29376
|
id: "gpt-5-nano-medium",
|
|
29374
29377
|
handle: "openai/gpt-5-nano-2025-08-07",
|
|
29375
|
-
label: "GPT-5-Nano
|
|
29376
|
-
description: "
|
|
29378
|
+
label: "GPT-5-Nano",
|
|
29379
|
+
description: "GPT-5-Nano (medium reasoning)",
|
|
29377
29380
|
updateArgs: {
|
|
29378
29381
|
reasoning_effort: "medium",
|
|
29379
29382
|
verbosity: "medium",
|
|
@@ -29384,7 +29387,7 @@ var init_models2 = __esm(() => {
|
|
|
29384
29387
|
id: "glm-4.6",
|
|
29385
29388
|
handle: "zai/glm-4.6",
|
|
29386
29389
|
label: "GLM-4.6",
|
|
29387
|
-
description: "Zai's
|
|
29390
|
+
description: "Zai's legacy model",
|
|
29388
29391
|
updateArgs: {
|
|
29389
29392
|
context_window: 200000
|
|
29390
29393
|
}
|
|
@@ -29498,8 +29501,8 @@ var init_models2 = __esm(() => {
|
|
|
29498
29501
|
{
|
|
29499
29502
|
id: "gemini-3-vertex",
|
|
29500
29503
|
handle: "google_vertex/gemini-3-pro-preview",
|
|
29501
|
-
label: "Gemini 3 Pro
|
|
29502
|
-
description: "Google's smartest Gemini 3 Pro model
|
|
29504
|
+
label: "Gemini 3 Pro",
|
|
29505
|
+
description: "Google's smartest Gemini 3 Pro model (via Vertex AI)",
|
|
29503
29506
|
updateArgs: { context_window: 180000, temperature: 1 }
|
|
29504
29507
|
}
|
|
29505
29508
|
];
|
|
@@ -29513,6 +29516,7 @@ __export(exports_model, {
|
|
|
29513
29516
|
models: () => models,
|
|
29514
29517
|
getModelUpdateArgs: () => getModelUpdateArgs,
|
|
29515
29518
|
getModelInfo: () => getModelInfo,
|
|
29519
|
+
getModelDisplayName: () => getModelDisplayName,
|
|
29516
29520
|
getDefaultModel: () => getDefaultModel,
|
|
29517
29521
|
formatAvailableModels: () => formatAvailableModels
|
|
29518
29522
|
});
|
|
@@ -29554,6 +29558,10 @@ function getModelUpdateArgs(modelIdentifier) {
|
|
|
29554
29558
|
const modelInfo = getModelInfo(modelIdentifier);
|
|
29555
29559
|
return modelInfo?.updateArgs;
|
|
29556
29560
|
}
|
|
29561
|
+
function getModelDisplayName(handle) {
|
|
29562
|
+
const model = models.find((m) => m.handle === handle);
|
|
29563
|
+
return model?.label ?? null;
|
|
29564
|
+
}
|
|
29557
29565
|
function resolveModelByLlmConfig(llmConfigModel) {
|
|
29558
29566
|
const match = models.find((m) => m.handle.endsWith(`/${llmConfigModel}`));
|
|
29559
29567
|
if (match)
|
|
@@ -33427,9 +33435,462 @@ Start with updating your todo list if applicable`
|
|
|
33427
33435
|
};
|
|
33428
33436
|
}
|
|
33429
33437
|
|
|
33438
|
+
// src/tools/impl/Glob.ts
|
|
33439
|
+
import { execFile } from "node:child_process";
|
|
33440
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
33441
|
+
import * as path5 from "node:path";
|
|
33442
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33443
|
+
import { promisify } from "node:util";
|
|
33444
|
+
function getRipgrepPath() {
|
|
33445
|
+
try {
|
|
33446
|
+
const __filename2 = fileURLToPath2(import.meta.url);
|
|
33447
|
+
const require2 = createRequire3(__filename2);
|
|
33448
|
+
const rgPackage = require2("@vscode/ripgrep");
|
|
33449
|
+
return rgPackage.rgPath;
|
|
33450
|
+
} catch (_error) {
|
|
33451
|
+
return "rg";
|
|
33452
|
+
}
|
|
33453
|
+
}
|
|
33454
|
+
function applyFileLimit(files) {
|
|
33455
|
+
const totalFiles = files.length;
|
|
33456
|
+
if (totalFiles <= LIMITS.GLOB_MAX_FILES) {
|
|
33457
|
+
return { files };
|
|
33458
|
+
}
|
|
33459
|
+
const truncatedFiles = files.slice(0, LIMITS.GLOB_MAX_FILES);
|
|
33460
|
+
truncatedFiles.push(`
|
|
33461
|
+
[Output truncated: showing ${LIMITS.GLOB_MAX_FILES.toLocaleString()} of ${totalFiles.toLocaleString()} files.]`);
|
|
33462
|
+
return {
|
|
33463
|
+
files: truncatedFiles,
|
|
33464
|
+
truncated: true,
|
|
33465
|
+
totalFiles
|
|
33466
|
+
};
|
|
33467
|
+
}
|
|
33468
|
+
async function glob(args) {
|
|
33469
|
+
validateRequiredParams(args, ["pattern"], "Glob");
|
|
33470
|
+
const { pattern, path: searchPath } = args;
|
|
33471
|
+
if (!pattern) {
|
|
33472
|
+
throw new Error("Glob tool missing required parameter: pattern");
|
|
33473
|
+
}
|
|
33474
|
+
const userCwd = process.env.USER_CWD || process.cwd();
|
|
33475
|
+
const baseDir = searchPath ? path5.isAbsolute(searchPath) ? searchPath : path5.resolve(userCwd, searchPath) : userCwd;
|
|
33476
|
+
const rgArgs = [
|
|
33477
|
+
"--files",
|
|
33478
|
+
"--hidden",
|
|
33479
|
+
"--follow",
|
|
33480
|
+
"--no-messages",
|
|
33481
|
+
"--glob",
|
|
33482
|
+
pattern,
|
|
33483
|
+
baseDir
|
|
33484
|
+
];
|
|
33485
|
+
try {
|
|
33486
|
+
const { stdout } = await execFileAsync(rgPath, rgArgs, {
|
|
33487
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
33488
|
+
cwd: userCwd
|
|
33489
|
+
});
|
|
33490
|
+
const files = stdout.trim().split(`
|
|
33491
|
+
`).filter(Boolean).sort();
|
|
33492
|
+
return applyFileLimit(files);
|
|
33493
|
+
} catch (error) {
|
|
33494
|
+
const err = error;
|
|
33495
|
+
if (err.code === 1 || err.code === "1") {
|
|
33496
|
+
return { files: [] };
|
|
33497
|
+
}
|
|
33498
|
+
if (err.stdout?.trim()) {
|
|
33499
|
+
const files = err.stdout.trim().split(`
|
|
33500
|
+
`).filter(Boolean).sort();
|
|
33501
|
+
return applyFileLimit(files);
|
|
33502
|
+
}
|
|
33503
|
+
throw new Error(`Glob failed: ${err.message || "Unknown error"}`);
|
|
33504
|
+
}
|
|
33505
|
+
}
|
|
33506
|
+
var execFileAsync, rgPath;
|
|
33507
|
+
var init_Glob2 = __esm(() => {
|
|
33508
|
+
init_truncation();
|
|
33509
|
+
execFileAsync = promisify(execFile);
|
|
33510
|
+
rgPath = getRipgrepPath();
|
|
33511
|
+
});
|
|
33512
|
+
|
|
33513
|
+
// src/tools/impl/GlobGemini.ts
|
|
33514
|
+
async function glob_gemini(args) {
|
|
33515
|
+
const lettaArgs = {
|
|
33516
|
+
pattern: args.pattern,
|
|
33517
|
+
path: args.dir_path
|
|
33518
|
+
};
|
|
33519
|
+
const result = await glob(lettaArgs);
|
|
33520
|
+
const message = result.files.join(`
|
|
33521
|
+
`);
|
|
33522
|
+
return { message };
|
|
33523
|
+
}
|
|
33524
|
+
var init_GlobGemini2 = __esm(() => {
|
|
33525
|
+
init_Glob2();
|
|
33526
|
+
});
|
|
33527
|
+
|
|
33528
|
+
// src/tools/impl/Grep.ts
|
|
33529
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
33530
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
33531
|
+
import * as path6 from "node:path";
|
|
33532
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
33533
|
+
import { promisify as promisify2 } from "node:util";
|
|
33534
|
+
function getRipgrepPath2() {
|
|
33535
|
+
try {
|
|
33536
|
+
const __filename2 = fileURLToPath3(import.meta.url);
|
|
33537
|
+
const require2 = createRequire4(__filename2);
|
|
33538
|
+
const rgPackage = require2("@vscode/ripgrep");
|
|
33539
|
+
return rgPackage.rgPath;
|
|
33540
|
+
} catch (_error) {
|
|
33541
|
+
return "rg";
|
|
33542
|
+
}
|
|
33543
|
+
}
|
|
33544
|
+
function applyOffsetAndLimit(items, offset, limit2) {
|
|
33545
|
+
const sliced = items.slice(offset);
|
|
33546
|
+
if (limit2 > 0) {
|
|
33547
|
+
return sliced.slice(0, limit2);
|
|
33548
|
+
}
|
|
33549
|
+
return sliced;
|
|
33550
|
+
}
|
|
33551
|
+
async function grep(args) {
|
|
33552
|
+
validateRequiredParams(args, ["pattern"], "Grep");
|
|
33553
|
+
const {
|
|
33554
|
+
pattern,
|
|
33555
|
+
path: searchPath,
|
|
33556
|
+
glob: glob2,
|
|
33557
|
+
output_mode = "files_with_matches",
|
|
33558
|
+
"-B": before,
|
|
33559
|
+
"-A": after,
|
|
33560
|
+
"-C": context2,
|
|
33561
|
+
"-n": lineNumbers = true,
|
|
33562
|
+
"-i": ignoreCase,
|
|
33563
|
+
type: fileType,
|
|
33564
|
+
head_limit = 100,
|
|
33565
|
+
offset = 0,
|
|
33566
|
+
multiline
|
|
33567
|
+
} = args;
|
|
33568
|
+
const userCwd = process.env.USER_CWD || process.cwd();
|
|
33569
|
+
const rgArgs = [];
|
|
33570
|
+
if (output_mode === "files_with_matches")
|
|
33571
|
+
rgArgs.push("-l");
|
|
33572
|
+
else if (output_mode === "count")
|
|
33573
|
+
rgArgs.push("-c");
|
|
33574
|
+
if (output_mode === "content") {
|
|
33575
|
+
if (context2 !== undefined)
|
|
33576
|
+
rgArgs.push("-C", context2.toString());
|
|
33577
|
+
else {
|
|
33578
|
+
if (before !== undefined)
|
|
33579
|
+
rgArgs.push("-B", before.toString());
|
|
33580
|
+
if (after !== undefined)
|
|
33581
|
+
rgArgs.push("-A", after.toString());
|
|
33582
|
+
}
|
|
33583
|
+
if (lineNumbers)
|
|
33584
|
+
rgArgs.push("-n");
|
|
33585
|
+
}
|
|
33586
|
+
if (ignoreCase)
|
|
33587
|
+
rgArgs.push("-i");
|
|
33588
|
+
if (fileType)
|
|
33589
|
+
rgArgs.push("--type", fileType);
|
|
33590
|
+
if (glob2)
|
|
33591
|
+
rgArgs.push("--glob", glob2);
|
|
33592
|
+
if (multiline)
|
|
33593
|
+
rgArgs.push("-U", "--multiline-dotall");
|
|
33594
|
+
rgArgs.push(pattern);
|
|
33595
|
+
if (searchPath)
|
|
33596
|
+
rgArgs.push(path6.isAbsolute(searchPath) ? searchPath : path6.resolve(userCwd, searchPath));
|
|
33597
|
+
else
|
|
33598
|
+
rgArgs.push(userCwd);
|
|
33599
|
+
try {
|
|
33600
|
+
const { stdout } = await execFileAsync2(rgPath2, rgArgs, {
|
|
33601
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
33602
|
+
cwd: userCwd
|
|
33603
|
+
});
|
|
33604
|
+
if (output_mode === "files_with_matches") {
|
|
33605
|
+
const allFiles = stdout.trim().split(`
|
|
33606
|
+
`).filter(Boolean);
|
|
33607
|
+
const files = applyOffsetAndLimit(allFiles, offset, head_limit);
|
|
33608
|
+
const fileCount = files.length;
|
|
33609
|
+
const totalCount = allFiles.length;
|
|
33610
|
+
if (totalCount === 0)
|
|
33611
|
+
return { output: "No files found", files: 0 };
|
|
33612
|
+
const fileList = files.join(`
|
|
33613
|
+
`);
|
|
33614
|
+
const fullOutput = `Found ${totalCount} file${totalCount !== 1 ? "s" : ""}${fileCount < totalCount ? ` (showing ${fileCount})` : ""}
|
|
33615
|
+
${fileList}`;
|
|
33616
|
+
const { content: truncatedOutput } = truncateByChars(fullOutput, LIMITS.GREP_OUTPUT_CHARS, "Grep");
|
|
33617
|
+
return {
|
|
33618
|
+
output: truncatedOutput,
|
|
33619
|
+
files: totalCount
|
|
33620
|
+
};
|
|
33621
|
+
} else if (output_mode === "count") {
|
|
33622
|
+
const allLines = stdout.trim().split(`
|
|
33623
|
+
`).filter(Boolean);
|
|
33624
|
+
const lines = applyOffsetAndLimit(allLines, offset, head_limit);
|
|
33625
|
+
let totalMatches = 0;
|
|
33626
|
+
let filesWithMatches = 0;
|
|
33627
|
+
for (const line of allLines) {
|
|
33628
|
+
const parts = line.split(":");
|
|
33629
|
+
if (parts.length >= 2) {
|
|
33630
|
+
const lastPart = parts[parts.length - 1];
|
|
33631
|
+
if (!lastPart)
|
|
33632
|
+
continue;
|
|
33633
|
+
const count = parseInt(lastPart, 10);
|
|
33634
|
+
if (!Number.isNaN(count) && count > 0) {
|
|
33635
|
+
totalMatches += count;
|
|
33636
|
+
filesWithMatches++;
|
|
33637
|
+
}
|
|
33638
|
+
}
|
|
33639
|
+
}
|
|
33640
|
+
if (totalMatches === 0)
|
|
33641
|
+
return {
|
|
33642
|
+
output: `0
|
|
33643
|
+
|
|
33644
|
+
Found 0 total occurrences across 0 files.`,
|
|
33645
|
+
matches: 0,
|
|
33646
|
+
files: 0
|
|
33647
|
+
};
|
|
33648
|
+
const countOutput = lines.join(`
|
|
33649
|
+
`);
|
|
33650
|
+
return {
|
|
33651
|
+
output: `${countOutput}
|
|
33652
|
+
|
|
33653
|
+
Found ${totalMatches} total occurrence${totalMatches !== 1 ? "s" : ""} across ${filesWithMatches} file${filesWithMatches !== 1 ? "s" : ""}.`,
|
|
33654
|
+
matches: totalMatches,
|
|
33655
|
+
files: filesWithMatches
|
|
33656
|
+
};
|
|
33657
|
+
} else {
|
|
33658
|
+
if (!stdout || stdout.trim() === "")
|
|
33659
|
+
return { output: "No matches found", matches: 0 };
|
|
33660
|
+
const allLines = stdout.split(`
|
|
33661
|
+
`);
|
|
33662
|
+
const lines = applyOffsetAndLimit(allLines, offset, head_limit);
|
|
33663
|
+
const content = lines.join(`
|
|
33664
|
+
`);
|
|
33665
|
+
const { content: truncatedOutput } = truncateByChars(content, LIMITS.GREP_OUTPUT_CHARS, "Grep");
|
|
33666
|
+
return {
|
|
33667
|
+
output: truncatedOutput,
|
|
33668
|
+
matches: allLines.filter(Boolean).length
|
|
33669
|
+
};
|
|
33670
|
+
}
|
|
33671
|
+
} catch (error) {
|
|
33672
|
+
const err = error;
|
|
33673
|
+
const code = typeof err.code === "number" ? err.code : undefined;
|
|
33674
|
+
const _stdout = typeof err.stdout === "string" ? err.stdout : "";
|
|
33675
|
+
const message = typeof err.message === "string" ? err.message : "Unknown error";
|
|
33676
|
+
if (code === 1) {
|
|
33677
|
+
if (output_mode === "files_with_matches")
|
|
33678
|
+
return { output: "No files found", files: 0 };
|
|
33679
|
+
if (output_mode === "count")
|
|
33680
|
+
return {
|
|
33681
|
+
output: `0
|
|
33682
|
+
|
|
33683
|
+
Found 0 total occurrences across 0 files.`,
|
|
33684
|
+
matches: 0,
|
|
33685
|
+
files: 0
|
|
33686
|
+
};
|
|
33687
|
+
return { output: "No matches found", matches: 0 };
|
|
33688
|
+
}
|
|
33689
|
+
throw new Error(`Grep failed: ${message}`);
|
|
33690
|
+
}
|
|
33691
|
+
}
|
|
33692
|
+
var execFileAsync2, rgPath2;
|
|
33693
|
+
var init_Grep2 = __esm(() => {
|
|
33694
|
+
init_truncation();
|
|
33695
|
+
execFileAsync2 = promisify2(execFile2);
|
|
33696
|
+
rgPath2 = getRipgrepPath2();
|
|
33697
|
+
});
|
|
33698
|
+
|
|
33699
|
+
// src/tools/impl/GrepFiles.ts
|
|
33700
|
+
async function grep_files(args) {
|
|
33701
|
+
validateRequiredParams(args, ["pattern"], "grep_files");
|
|
33702
|
+
const { pattern, include, path: path7, limit: limit2 = DEFAULT_LIMIT } = args;
|
|
33703
|
+
const grepArgs = {
|
|
33704
|
+
pattern,
|
|
33705
|
+
path: path7,
|
|
33706
|
+
glob: include,
|
|
33707
|
+
output_mode: "files_with_matches"
|
|
33708
|
+
};
|
|
33709
|
+
const result = await grep(grepArgs);
|
|
33710
|
+
const totalFiles = result.files ?? 0;
|
|
33711
|
+
if (result.output && limit2 > 0 && totalFiles > limit2) {
|
|
33712
|
+
const lines = result.output.split(`
|
|
33713
|
+
`).filter((line) => line.trim() !== "");
|
|
33714
|
+
const filePaths = lines.slice(1);
|
|
33715
|
+
const truncatedFiles = filePaths.slice(0, limit2);
|
|
33716
|
+
const truncatedOutput = `Found ${limit2} file${limit2 !== 1 ? "s" : ""} (truncated from ${totalFiles})
|
|
33717
|
+
${truncatedFiles.join(`
|
|
33718
|
+
`)}`;
|
|
33719
|
+
return {
|
|
33720
|
+
output: truncatedOutput,
|
|
33721
|
+
files: limit2,
|
|
33722
|
+
truncated: true
|
|
33723
|
+
};
|
|
33724
|
+
}
|
|
33725
|
+
return {
|
|
33726
|
+
output: result.output,
|
|
33727
|
+
files: totalFiles,
|
|
33728
|
+
truncated: false
|
|
33729
|
+
};
|
|
33730
|
+
}
|
|
33731
|
+
var DEFAULT_LIMIT = 100;
|
|
33732
|
+
var init_GrepFiles2 = __esm(() => {
|
|
33733
|
+
init_Grep2();
|
|
33734
|
+
});
|
|
33735
|
+
|
|
33736
|
+
// src/tools/impl/KillBash.ts
|
|
33737
|
+
async function kill_bash(args) {
|
|
33738
|
+
validateRequiredParams(args, ["shell_id"], "KillBash");
|
|
33739
|
+
const { shell_id } = args;
|
|
33740
|
+
const proc = backgroundProcesses.get(shell_id);
|
|
33741
|
+
if (!proc)
|
|
33742
|
+
return { killed: false };
|
|
33743
|
+
try {
|
|
33744
|
+
proc.process.kill("SIGTERM");
|
|
33745
|
+
backgroundProcesses.delete(shell_id);
|
|
33746
|
+
return { killed: true };
|
|
33747
|
+
} catch {
|
|
33748
|
+
return { killed: false };
|
|
33749
|
+
}
|
|
33750
|
+
}
|
|
33751
|
+
var init_KillBash2 = __esm(() => {
|
|
33752
|
+
init_process_manager();
|
|
33753
|
+
});
|
|
33754
|
+
|
|
33755
|
+
// src/tools/impl/ListDirCodex.ts
|
|
33756
|
+
import { promises as fs4 } from "node:fs";
|
|
33757
|
+
import * as path7 from "node:path";
|
|
33758
|
+
async function list_dir(args) {
|
|
33759
|
+
validateRequiredParams(args, ["dir_path"], "list_dir");
|
|
33760
|
+
const { dir_path, offset = 1, limit: limit2 = 25, depth = 2 } = args;
|
|
33761
|
+
const userCwd = process.env.USER_CWD || process.cwd();
|
|
33762
|
+
const resolvedPath = path7.isAbsolute(dir_path) ? dir_path : path7.resolve(userCwd, dir_path);
|
|
33763
|
+
if (offset < 1) {
|
|
33764
|
+
throw new Error("offset must be a 1-indexed entry number");
|
|
33765
|
+
}
|
|
33766
|
+
if (limit2 < 1) {
|
|
33767
|
+
throw new Error("limit must be greater than zero");
|
|
33768
|
+
}
|
|
33769
|
+
if (depth < 1) {
|
|
33770
|
+
throw new Error("depth must be greater than zero");
|
|
33771
|
+
}
|
|
33772
|
+
const entries = await listDirSlice(resolvedPath, offset, limit2, depth);
|
|
33773
|
+
const output = [`Absolute path: ${resolvedPath}`, ...entries];
|
|
33774
|
+
return { content: output.join(`
|
|
33775
|
+
`) };
|
|
33776
|
+
}
|
|
33777
|
+
async function listDirSlice(dirPath, offset, limit2, maxDepth) {
|
|
33778
|
+
const entries = [];
|
|
33779
|
+
await collectEntries(dirPath, "", maxDepth, entries);
|
|
33780
|
+
if (entries.length === 0) {
|
|
33781
|
+
return [];
|
|
33782
|
+
}
|
|
33783
|
+
const startIndex = offset - 1;
|
|
33784
|
+
if (startIndex >= entries.length) {
|
|
33785
|
+
throw new Error("offset exceeds directory entry count");
|
|
33786
|
+
}
|
|
33787
|
+
const remainingEntries = entries.length - startIndex;
|
|
33788
|
+
const cappedLimit = Math.min(limit2, remainingEntries);
|
|
33789
|
+
const endIndex = startIndex + cappedLimit;
|
|
33790
|
+
const selectedEntries = entries.slice(startIndex, endIndex);
|
|
33791
|
+
selectedEntries.sort((a, b) => a.name.localeCompare(b.name));
|
|
33792
|
+
const formatted = [];
|
|
33793
|
+
for (const entry of selectedEntries) {
|
|
33794
|
+
formatted.push(formatEntryLine(entry));
|
|
33795
|
+
}
|
|
33796
|
+
if (endIndex < entries.length) {
|
|
33797
|
+
formatted.push(`More than ${cappedLimit} entries found`);
|
|
33798
|
+
}
|
|
33799
|
+
return formatted;
|
|
33800
|
+
}
|
|
33801
|
+
async function collectEntries(dirPath, relativePrefix, remainingDepth, entries) {
|
|
33802
|
+
const queue = [
|
|
33803
|
+
{ absPath: dirPath, prefix: relativePrefix, depth: remainingDepth }
|
|
33804
|
+
];
|
|
33805
|
+
while (queue.length > 0) {
|
|
33806
|
+
const current = queue.shift();
|
|
33807
|
+
if (!current)
|
|
33808
|
+
break;
|
|
33809
|
+
const { absPath, prefix, depth } = current;
|
|
33810
|
+
const dirEntries = [];
|
|
33811
|
+
try {
|
|
33812
|
+
const items = await fs4.readdir(absPath, { withFileTypes: true });
|
|
33813
|
+
for (const item of items) {
|
|
33814
|
+
const itemAbsPath = path7.join(absPath, item.name);
|
|
33815
|
+
const relativePath = prefix ? path7.join(prefix, item.name) : item.name;
|
|
33816
|
+
const displayName = formatEntryComponent(item.name);
|
|
33817
|
+
const displayDepth = prefix ? prefix.split(path7.sep).length : 0;
|
|
33818
|
+
const sortKey = formatEntryName(relativePath);
|
|
33819
|
+
let kind;
|
|
33820
|
+
if (item.isSymbolicLink()) {
|
|
33821
|
+
kind = "symlink";
|
|
33822
|
+
} else if (item.isDirectory()) {
|
|
33823
|
+
kind = "directory";
|
|
33824
|
+
} else if (item.isFile()) {
|
|
33825
|
+
kind = "file";
|
|
33826
|
+
} else {
|
|
33827
|
+
kind = "other";
|
|
33828
|
+
}
|
|
33829
|
+
dirEntries.push({
|
|
33830
|
+
absPath: itemAbsPath,
|
|
33831
|
+
relativePath,
|
|
33832
|
+
kind,
|
|
33833
|
+
entry: {
|
|
33834
|
+
name: sortKey,
|
|
33835
|
+
displayName,
|
|
33836
|
+
depth: displayDepth,
|
|
33837
|
+
kind
|
|
33838
|
+
}
|
|
33839
|
+
});
|
|
33840
|
+
}
|
|
33841
|
+
} catch (err) {
|
|
33842
|
+
throw new Error(`failed to read directory: ${err}`);
|
|
33843
|
+
}
|
|
33844
|
+
dirEntries.sort((a, b) => a.entry.name.localeCompare(b.entry.name));
|
|
33845
|
+
for (const item of dirEntries) {
|
|
33846
|
+
if (item.kind === "directory" && depth > 1) {
|
|
33847
|
+
queue.push({
|
|
33848
|
+
absPath: item.absPath,
|
|
33849
|
+
prefix: item.relativePath,
|
|
33850
|
+
depth: depth - 1
|
|
33851
|
+
});
|
|
33852
|
+
}
|
|
33853
|
+
entries.push(item.entry);
|
|
33854
|
+
}
|
|
33855
|
+
}
|
|
33856
|
+
}
|
|
33857
|
+
function formatEntryName(filePath) {
|
|
33858
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
33859
|
+
if (normalized.length > MAX_ENTRY_LENGTH) {
|
|
33860
|
+
return normalized.substring(0, MAX_ENTRY_LENGTH);
|
|
33861
|
+
}
|
|
33862
|
+
return normalized;
|
|
33863
|
+
}
|
|
33864
|
+
function formatEntryComponent(name) {
|
|
33865
|
+
if (name.length > MAX_ENTRY_LENGTH) {
|
|
33866
|
+
return name.substring(0, MAX_ENTRY_LENGTH);
|
|
33867
|
+
}
|
|
33868
|
+
return name;
|
|
33869
|
+
}
|
|
33870
|
+
function formatEntryLine(entry) {
|
|
33871
|
+
const indent = " ".repeat(entry.depth * INDENTATION_SPACES);
|
|
33872
|
+
let name = entry.displayName;
|
|
33873
|
+
switch (entry.kind) {
|
|
33874
|
+
case "directory":
|
|
33875
|
+
name += "/";
|
|
33876
|
+
break;
|
|
33877
|
+
case "symlink":
|
|
33878
|
+
name += "@";
|
|
33879
|
+
break;
|
|
33880
|
+
case "other":
|
|
33881
|
+
name += "?";
|
|
33882
|
+
break;
|
|
33883
|
+
default:
|
|
33884
|
+
break;
|
|
33885
|
+
}
|
|
33886
|
+
return `${indent}${name}`;
|
|
33887
|
+
}
|
|
33888
|
+
var MAX_ENTRY_LENGTH = 500, INDENTATION_SPACES = 2;
|
|
33889
|
+
var init_ListDirCodex2 = () => {};
|
|
33890
|
+
|
|
33430
33891
|
// node_modules/picomatch/lib/constants.js
|
|
33431
33892
|
var require_constants2 = __commonJS((exports, module) => {
|
|
33432
|
-
var
|
|
33893
|
+
var path8 = __require("path");
|
|
33433
33894
|
var WIN_SLASH = "\\\\/";
|
|
33434
33895
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
33435
33896
|
var DOT_LITERAL = "\\.";
|
|
@@ -33551,7 +34012,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
33551
34012
|
CHAR_UNDERSCORE: 95,
|
|
33552
34013
|
CHAR_VERTICAL_LINE: 124,
|
|
33553
34014
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
33554
|
-
SEP:
|
|
34015
|
+
SEP: path8.sep,
|
|
33555
34016
|
extglobChars(chars) {
|
|
33556
34017
|
return {
|
|
33557
34018
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -33569,7 +34030,7 @@ var require_constants2 = __commonJS((exports, module) => {
|
|
|
33569
34030
|
|
|
33570
34031
|
// node_modules/picomatch/lib/utils.js
|
|
33571
34032
|
var require_utils = __commonJS((exports) => {
|
|
33572
|
-
var
|
|
34033
|
+
var path8 = __require("path");
|
|
33573
34034
|
var win32 = process.platform === "win32";
|
|
33574
34035
|
var {
|
|
33575
34036
|
REGEX_BACKSLASH,
|
|
@@ -33598,7 +34059,7 @@ var require_utils = __commonJS((exports) => {
|
|
|
33598
34059
|
if (options && typeof options.windows === "boolean") {
|
|
33599
34060
|
return options.windows;
|
|
33600
34061
|
}
|
|
33601
|
-
return win32 === true ||
|
|
34062
|
+
return win32 === true || path8.sep === "\\";
|
|
33602
34063
|
};
|
|
33603
34064
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
33604
34065
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -33856,7 +34317,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
33856
34317
|
}
|
|
33857
34318
|
let base2 = str;
|
|
33858
34319
|
let prefix = "";
|
|
33859
|
-
let
|
|
34320
|
+
let glob2 = "";
|
|
33860
34321
|
if (start > 0) {
|
|
33861
34322
|
prefix = str.slice(0, start);
|
|
33862
34323
|
str = str.slice(start);
|
|
@@ -33864,10 +34325,10 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
33864
34325
|
}
|
|
33865
34326
|
if (base2 && isGlob === true && lastIndex > 0) {
|
|
33866
34327
|
base2 = str.slice(0, lastIndex);
|
|
33867
|
-
|
|
34328
|
+
glob2 = str.slice(lastIndex);
|
|
33868
34329
|
} else if (isGlob === true) {
|
|
33869
34330
|
base2 = "";
|
|
33870
|
-
|
|
34331
|
+
glob2 = str;
|
|
33871
34332
|
} else {
|
|
33872
34333
|
base2 = str;
|
|
33873
34334
|
}
|
|
@@ -33877,8 +34338,8 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
33877
34338
|
}
|
|
33878
34339
|
}
|
|
33879
34340
|
if (opts.unescape === true) {
|
|
33880
|
-
if (
|
|
33881
|
-
|
|
34341
|
+
if (glob2)
|
|
34342
|
+
glob2 = utils.removeBackslashes(glob2);
|
|
33882
34343
|
if (base2 && backslashes === true) {
|
|
33883
34344
|
base2 = utils.removeBackslashes(base2);
|
|
33884
34345
|
}
|
|
@@ -33888,7 +34349,7 @@ var require_scan = __commonJS((exports, module) => {
|
|
|
33888
34349
|
input,
|
|
33889
34350
|
start,
|
|
33890
34351
|
base: base2,
|
|
33891
|
-
glob,
|
|
34352
|
+
glob: glob2,
|
|
33892
34353
|
isBrace,
|
|
33893
34354
|
isBracket,
|
|
33894
34355
|
isGlob,
|
|
@@ -34722,15 +35183,15 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
34722
35183
|
|
|
34723
35184
|
// node_modules/picomatch/lib/picomatch.js
|
|
34724
35185
|
var require_picomatch = __commonJS((exports, module) => {
|
|
34725
|
-
var
|
|
35186
|
+
var path8 = __require("path");
|
|
34726
35187
|
var scan = require_scan();
|
|
34727
35188
|
var parse = require_parse();
|
|
34728
35189
|
var utils = require_utils();
|
|
34729
35190
|
var constants2 = require_constants2();
|
|
34730
35191
|
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
34731
|
-
var picomatch = (
|
|
34732
|
-
if (Array.isArray(
|
|
34733
|
-
const fns =
|
|
35192
|
+
var picomatch = (glob2, options, returnState = false) => {
|
|
35193
|
+
if (Array.isArray(glob2)) {
|
|
35194
|
+
const fns = glob2.map((input) => picomatch(input, options, returnState));
|
|
34734
35195
|
const arrayMatcher = (str) => {
|
|
34735
35196
|
for (const isMatch of fns) {
|
|
34736
35197
|
const state2 = isMatch(str);
|
|
@@ -34741,13 +35202,13 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34741
35202
|
};
|
|
34742
35203
|
return arrayMatcher;
|
|
34743
35204
|
}
|
|
34744
|
-
const isState = isObject(
|
|
34745
|
-
if (
|
|
35205
|
+
const isState = isObject(glob2) && glob2.tokens && glob2.input;
|
|
35206
|
+
if (glob2 === "" || typeof glob2 !== "string" && !isState) {
|
|
34746
35207
|
throw new TypeError("Expected pattern to be a non-empty string");
|
|
34747
35208
|
}
|
|
34748
35209
|
const opts = options || {};
|
|
34749
35210
|
const posix = utils.isWindows(options);
|
|
34750
|
-
const regex2 = isState ? picomatch.compileRe(
|
|
35211
|
+
const regex2 = isState ? picomatch.compileRe(glob2, options) : picomatch.makeRe(glob2, options, false, true);
|
|
34751
35212
|
const state = regex2.state;
|
|
34752
35213
|
delete regex2.state;
|
|
34753
35214
|
let isIgnored = () => false;
|
|
@@ -34756,8 +35217,8 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34756
35217
|
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
34757
35218
|
}
|
|
34758
35219
|
const matcher = (input, returnObject = false) => {
|
|
34759
|
-
const { isMatch, match, output } = picomatch.test(input, regex2, options, { glob, posix });
|
|
34760
|
-
const result = { glob, state, regex: regex2, posix, input, output, match, isMatch };
|
|
35220
|
+
const { isMatch, match, output } = picomatch.test(input, regex2, options, { glob: glob2, posix });
|
|
35221
|
+
const result = { glob: glob2, state, regex: regex2, posix, input, output, match, isMatch };
|
|
34761
35222
|
if (typeof opts.onResult === "function") {
|
|
34762
35223
|
opts.onResult(result);
|
|
34763
35224
|
}
|
|
@@ -34782,7 +35243,7 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34782
35243
|
}
|
|
34783
35244
|
return matcher;
|
|
34784
35245
|
};
|
|
34785
|
-
picomatch.test = (input, regex2, options, { glob, posix } = {}) => {
|
|
35246
|
+
picomatch.test = (input, regex2, options, { glob: glob2, posix } = {}) => {
|
|
34786
35247
|
if (typeof input !== "string") {
|
|
34787
35248
|
throw new TypeError("Expected input to be a string");
|
|
34788
35249
|
}
|
|
@@ -34791,11 +35252,11 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34791
35252
|
}
|
|
34792
35253
|
const opts = options || {};
|
|
34793
35254
|
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
34794
|
-
let match = input ===
|
|
35255
|
+
let match = input === glob2;
|
|
34795
35256
|
let output = match && format ? format(input) : input;
|
|
34796
35257
|
if (match === false) {
|
|
34797
35258
|
output = format ? format(input) : input;
|
|
34798
|
-
match = output ===
|
|
35259
|
+
match = output === glob2;
|
|
34799
35260
|
}
|
|
34800
35261
|
if (match === false || opts.capture === true) {
|
|
34801
35262
|
if (opts.matchBase === true || opts.basename === true) {
|
|
@@ -34806,9 +35267,9 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34806
35267
|
}
|
|
34807
35268
|
return { isMatch: Boolean(match), match, output };
|
|
34808
35269
|
};
|
|
34809
|
-
picomatch.matchBase = (input,
|
|
34810
|
-
const regex2 =
|
|
34811
|
-
return regex2.test(
|
|
35270
|
+
picomatch.matchBase = (input, glob2, options, posix = utils.isWindows(options)) => {
|
|
35271
|
+
const regex2 = glob2 instanceof RegExp ? glob2 : picomatch.makeRe(glob2, options);
|
|
35272
|
+
return regex2.test(path8.basename(input));
|
|
34812
35273
|
};
|
|
34813
35274
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
34814
35275
|
picomatch.parse = (pattern, options) => {
|
|
@@ -34861,466 +35322,6 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
34861
35322
|
module.exports = picomatch;
|
|
34862
35323
|
});
|
|
34863
35324
|
|
|
34864
|
-
// src/tools/impl/Glob.ts
|
|
34865
|
-
import { promises as fs4 } from "node:fs";
|
|
34866
|
-
import * as path5 from "node:path";
|
|
34867
|
-
function applyFileLimit(files) {
|
|
34868
|
-
const totalFiles = files.length;
|
|
34869
|
-
if (totalFiles <= LIMITS.GLOB_MAX_FILES) {
|
|
34870
|
-
return { files };
|
|
34871
|
-
}
|
|
34872
|
-
const truncatedFiles = files.slice(0, LIMITS.GLOB_MAX_FILES);
|
|
34873
|
-
truncatedFiles.push(`
|
|
34874
|
-
[Output truncated: showing ${LIMITS.GLOB_MAX_FILES.toLocaleString()} of ${totalFiles.toLocaleString()} files.]`);
|
|
34875
|
-
return {
|
|
34876
|
-
files: truncatedFiles,
|
|
34877
|
-
truncated: true,
|
|
34878
|
-
totalFiles
|
|
34879
|
-
};
|
|
34880
|
-
}
|
|
34881
|
-
async function walkDirectory(dir) {
|
|
34882
|
-
const files = [];
|
|
34883
|
-
try {
|
|
34884
|
-
const entries = await fs4.readdir(dir, { withFileTypes: true });
|
|
34885
|
-
for (const entry of entries) {
|
|
34886
|
-
const fullPath = path5.join(dir, entry.name);
|
|
34887
|
-
if (entry.isDirectory()) {
|
|
34888
|
-
if (entry.name === "node_modules" || entry.name === ".git")
|
|
34889
|
-
continue;
|
|
34890
|
-
const subFiles = await walkDirectory(fullPath);
|
|
34891
|
-
files.push(...subFiles);
|
|
34892
|
-
} else if (entry.isFile()) {
|
|
34893
|
-
files.push(fullPath);
|
|
34894
|
-
}
|
|
34895
|
-
}
|
|
34896
|
-
} catch (error) {
|
|
34897
|
-
const err = error;
|
|
34898
|
-
if (err.code !== "EACCES" && err.code !== "EPERM")
|
|
34899
|
-
throw err;
|
|
34900
|
-
}
|
|
34901
|
-
return files;
|
|
34902
|
-
}
|
|
34903
|
-
async function glob(args) {
|
|
34904
|
-
validateRequiredParams(args, ["pattern"], "Glob");
|
|
34905
|
-
const { pattern, path: searchPath } = args;
|
|
34906
|
-
const userCwd = process.env.USER_CWD || process.cwd();
|
|
34907
|
-
let baseDir;
|
|
34908
|
-
if (searchPath)
|
|
34909
|
-
baseDir = path5.isAbsolute(searchPath) ? searchPath : path5.resolve(userCwd, searchPath);
|
|
34910
|
-
else
|
|
34911
|
-
baseDir = userCwd;
|
|
34912
|
-
try {
|
|
34913
|
-
const stats = await fs4.stat(baseDir);
|
|
34914
|
-
if (!stats.isDirectory())
|
|
34915
|
-
throw new Error(`Path is not a directory: ${baseDir}`);
|
|
34916
|
-
} catch (error) {
|
|
34917
|
-
const err = error;
|
|
34918
|
-
if (err.code === "ENOENT")
|
|
34919
|
-
throw new Error(`Directory does not exist: ${baseDir}`);
|
|
34920
|
-
throw err;
|
|
34921
|
-
}
|
|
34922
|
-
const allFiles = await walkDirectory(baseDir);
|
|
34923
|
-
let matcher;
|
|
34924
|
-
if (pattern.startsWith("**/")) {
|
|
34925
|
-
const subPattern = pattern.slice(3);
|
|
34926
|
-
matcher = import_picomatch.default(subPattern);
|
|
34927
|
-
const matchedFiles = allFiles.filter((file) => matcher(path5.basename(file)));
|
|
34928
|
-
return applyFileLimit(matchedFiles.sort());
|
|
34929
|
-
} else if (pattern.includes("**")) {
|
|
34930
|
-
const fullPattern = path5.join(baseDir, pattern);
|
|
34931
|
-
matcher = import_picomatch.default(fullPattern, { dot: true });
|
|
34932
|
-
const matchedFiles = allFiles.filter((file) => matcher(file));
|
|
34933
|
-
return applyFileLimit(matchedFiles.sort());
|
|
34934
|
-
} else {
|
|
34935
|
-
matcher = import_picomatch.default(pattern, { dot: true });
|
|
34936
|
-
const matchedFiles = allFiles.filter((file) => matcher(path5.relative(baseDir, file)));
|
|
34937
|
-
return applyFileLimit(matchedFiles.sort());
|
|
34938
|
-
}
|
|
34939
|
-
}
|
|
34940
|
-
var import_picomatch;
|
|
34941
|
-
var init_Glob2 = __esm(() => {
|
|
34942
|
-
init_truncation();
|
|
34943
|
-
import_picomatch = __toESM(require_picomatch(), 1);
|
|
34944
|
-
});
|
|
34945
|
-
|
|
34946
|
-
// src/tools/impl/GlobGemini.ts
|
|
34947
|
-
async function glob_gemini(args) {
|
|
34948
|
-
const lettaArgs = {
|
|
34949
|
-
pattern: args.pattern,
|
|
34950
|
-
path: args.dir_path
|
|
34951
|
-
};
|
|
34952
|
-
const result = await glob(lettaArgs);
|
|
34953
|
-
const message = result.files.join(`
|
|
34954
|
-
`);
|
|
34955
|
-
return { message };
|
|
34956
|
-
}
|
|
34957
|
-
var init_GlobGemini2 = __esm(() => {
|
|
34958
|
-
init_Glob2();
|
|
34959
|
-
});
|
|
34960
|
-
|
|
34961
|
-
// src/tools/impl/Grep.ts
|
|
34962
|
-
import { execFile } from "node:child_process";
|
|
34963
|
-
import { createRequire as createRequire3 } from "node:module";
|
|
34964
|
-
import * as path6 from "node:path";
|
|
34965
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34966
|
-
import { promisify } from "node:util";
|
|
34967
|
-
function getRipgrepPath() {
|
|
34968
|
-
try {
|
|
34969
|
-
const __filename2 = fileURLToPath2(import.meta.url);
|
|
34970
|
-
const require2 = createRequire3(__filename2);
|
|
34971
|
-
const rgPackage = require2("@vscode/ripgrep");
|
|
34972
|
-
return rgPackage.rgPath;
|
|
34973
|
-
} catch (_error) {
|
|
34974
|
-
return "rg";
|
|
34975
|
-
}
|
|
34976
|
-
}
|
|
34977
|
-
function applyOffsetAndLimit(items, offset, limit2) {
|
|
34978
|
-
const sliced = items.slice(offset);
|
|
34979
|
-
if (limit2 > 0) {
|
|
34980
|
-
return sliced.slice(0, limit2);
|
|
34981
|
-
}
|
|
34982
|
-
return sliced;
|
|
34983
|
-
}
|
|
34984
|
-
async function grep(args) {
|
|
34985
|
-
validateRequiredParams(args, ["pattern"], "Grep");
|
|
34986
|
-
const {
|
|
34987
|
-
pattern,
|
|
34988
|
-
path: searchPath,
|
|
34989
|
-
glob: glob2,
|
|
34990
|
-
output_mode = "files_with_matches",
|
|
34991
|
-
"-B": before,
|
|
34992
|
-
"-A": after,
|
|
34993
|
-
"-C": context2,
|
|
34994
|
-
"-n": lineNumbers = true,
|
|
34995
|
-
"-i": ignoreCase,
|
|
34996
|
-
type: fileType,
|
|
34997
|
-
head_limit = 100,
|
|
34998
|
-
offset = 0,
|
|
34999
|
-
multiline
|
|
35000
|
-
} = args;
|
|
35001
|
-
const userCwd = process.env.USER_CWD || process.cwd();
|
|
35002
|
-
const rgArgs = [];
|
|
35003
|
-
if (output_mode === "files_with_matches")
|
|
35004
|
-
rgArgs.push("-l");
|
|
35005
|
-
else if (output_mode === "count")
|
|
35006
|
-
rgArgs.push("-c");
|
|
35007
|
-
if (output_mode === "content") {
|
|
35008
|
-
if (context2 !== undefined)
|
|
35009
|
-
rgArgs.push("-C", context2.toString());
|
|
35010
|
-
else {
|
|
35011
|
-
if (before !== undefined)
|
|
35012
|
-
rgArgs.push("-B", before.toString());
|
|
35013
|
-
if (after !== undefined)
|
|
35014
|
-
rgArgs.push("-A", after.toString());
|
|
35015
|
-
}
|
|
35016
|
-
if (lineNumbers)
|
|
35017
|
-
rgArgs.push("-n");
|
|
35018
|
-
}
|
|
35019
|
-
if (ignoreCase)
|
|
35020
|
-
rgArgs.push("-i");
|
|
35021
|
-
if (fileType)
|
|
35022
|
-
rgArgs.push("--type", fileType);
|
|
35023
|
-
if (glob2)
|
|
35024
|
-
rgArgs.push("--glob", glob2);
|
|
35025
|
-
if (multiline)
|
|
35026
|
-
rgArgs.push("-U", "--multiline-dotall");
|
|
35027
|
-
rgArgs.push(pattern);
|
|
35028
|
-
if (searchPath)
|
|
35029
|
-
rgArgs.push(path6.isAbsolute(searchPath) ? searchPath : path6.resolve(userCwd, searchPath));
|
|
35030
|
-
else
|
|
35031
|
-
rgArgs.push(userCwd);
|
|
35032
|
-
try {
|
|
35033
|
-
const { stdout } = await execFileAsync(rgPath, rgArgs, {
|
|
35034
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
35035
|
-
cwd: userCwd
|
|
35036
|
-
});
|
|
35037
|
-
if (output_mode === "files_with_matches") {
|
|
35038
|
-
const allFiles = stdout.trim().split(`
|
|
35039
|
-
`).filter(Boolean);
|
|
35040
|
-
const files = applyOffsetAndLimit(allFiles, offset, head_limit);
|
|
35041
|
-
const fileCount = files.length;
|
|
35042
|
-
const totalCount = allFiles.length;
|
|
35043
|
-
if (totalCount === 0)
|
|
35044
|
-
return { output: "No files found", files: 0 };
|
|
35045
|
-
const fileList = files.join(`
|
|
35046
|
-
`);
|
|
35047
|
-
const fullOutput = `Found ${totalCount} file${totalCount !== 1 ? "s" : ""}${fileCount < totalCount ? ` (showing ${fileCount})` : ""}
|
|
35048
|
-
${fileList}`;
|
|
35049
|
-
const { content: truncatedOutput } = truncateByChars(fullOutput, LIMITS.GREP_OUTPUT_CHARS, "Grep");
|
|
35050
|
-
return {
|
|
35051
|
-
output: truncatedOutput,
|
|
35052
|
-
files: totalCount
|
|
35053
|
-
};
|
|
35054
|
-
} else if (output_mode === "count") {
|
|
35055
|
-
const allLines = stdout.trim().split(`
|
|
35056
|
-
`).filter(Boolean);
|
|
35057
|
-
const lines = applyOffsetAndLimit(allLines, offset, head_limit);
|
|
35058
|
-
let totalMatches = 0;
|
|
35059
|
-
let filesWithMatches = 0;
|
|
35060
|
-
for (const line of allLines) {
|
|
35061
|
-
const parts = line.split(":");
|
|
35062
|
-
if (parts.length >= 2) {
|
|
35063
|
-
const lastPart = parts[parts.length - 1];
|
|
35064
|
-
if (!lastPart)
|
|
35065
|
-
continue;
|
|
35066
|
-
const count = parseInt(lastPart, 10);
|
|
35067
|
-
if (!Number.isNaN(count) && count > 0) {
|
|
35068
|
-
totalMatches += count;
|
|
35069
|
-
filesWithMatches++;
|
|
35070
|
-
}
|
|
35071
|
-
}
|
|
35072
|
-
}
|
|
35073
|
-
if (totalMatches === 0)
|
|
35074
|
-
return {
|
|
35075
|
-
output: `0
|
|
35076
|
-
|
|
35077
|
-
Found 0 total occurrences across 0 files.`,
|
|
35078
|
-
matches: 0,
|
|
35079
|
-
files: 0
|
|
35080
|
-
};
|
|
35081
|
-
const countOutput = lines.join(`
|
|
35082
|
-
`);
|
|
35083
|
-
return {
|
|
35084
|
-
output: `${countOutput}
|
|
35085
|
-
|
|
35086
|
-
Found ${totalMatches} total occurrence${totalMatches !== 1 ? "s" : ""} across ${filesWithMatches} file${filesWithMatches !== 1 ? "s" : ""}.`,
|
|
35087
|
-
matches: totalMatches,
|
|
35088
|
-
files: filesWithMatches
|
|
35089
|
-
};
|
|
35090
|
-
} else {
|
|
35091
|
-
if (!stdout || stdout.trim() === "")
|
|
35092
|
-
return { output: "No matches found", matches: 0 };
|
|
35093
|
-
const allLines = stdout.split(`
|
|
35094
|
-
`);
|
|
35095
|
-
const lines = applyOffsetAndLimit(allLines, offset, head_limit);
|
|
35096
|
-
const content = lines.join(`
|
|
35097
|
-
`);
|
|
35098
|
-
const { content: truncatedOutput } = truncateByChars(content, LIMITS.GREP_OUTPUT_CHARS, "Grep");
|
|
35099
|
-
return {
|
|
35100
|
-
output: truncatedOutput,
|
|
35101
|
-
matches: allLines.filter(Boolean).length
|
|
35102
|
-
};
|
|
35103
|
-
}
|
|
35104
|
-
} catch (error) {
|
|
35105
|
-
const err = error;
|
|
35106
|
-
const code = typeof err.code === "number" ? err.code : undefined;
|
|
35107
|
-
const _stdout = typeof err.stdout === "string" ? err.stdout : "";
|
|
35108
|
-
const message = typeof err.message === "string" ? err.message : "Unknown error";
|
|
35109
|
-
if (code === 1) {
|
|
35110
|
-
if (output_mode === "files_with_matches")
|
|
35111
|
-
return { output: "No files found", files: 0 };
|
|
35112
|
-
if (output_mode === "count")
|
|
35113
|
-
return {
|
|
35114
|
-
output: `0
|
|
35115
|
-
|
|
35116
|
-
Found 0 total occurrences across 0 files.`,
|
|
35117
|
-
matches: 0,
|
|
35118
|
-
files: 0
|
|
35119
|
-
};
|
|
35120
|
-
return { output: "No matches found", matches: 0 };
|
|
35121
|
-
}
|
|
35122
|
-
throw new Error(`Grep failed: ${message}`);
|
|
35123
|
-
}
|
|
35124
|
-
}
|
|
35125
|
-
var execFileAsync, rgPath;
|
|
35126
|
-
var init_Grep2 = __esm(() => {
|
|
35127
|
-
init_truncation();
|
|
35128
|
-
execFileAsync = promisify(execFile);
|
|
35129
|
-
rgPath = getRipgrepPath();
|
|
35130
|
-
});
|
|
35131
|
-
|
|
35132
|
-
// src/tools/impl/GrepFiles.ts
|
|
35133
|
-
async function grep_files(args) {
|
|
35134
|
-
validateRequiredParams(args, ["pattern"], "grep_files");
|
|
35135
|
-
const { pattern, include, path: path7, limit: limit2 = DEFAULT_LIMIT } = args;
|
|
35136
|
-
const grepArgs = {
|
|
35137
|
-
pattern,
|
|
35138
|
-
path: path7,
|
|
35139
|
-
glob: include,
|
|
35140
|
-
output_mode: "files_with_matches"
|
|
35141
|
-
};
|
|
35142
|
-
const result = await grep(grepArgs);
|
|
35143
|
-
const totalFiles = result.files ?? 0;
|
|
35144
|
-
if (result.output && limit2 > 0 && totalFiles > limit2) {
|
|
35145
|
-
const lines = result.output.split(`
|
|
35146
|
-
`).filter((line) => line.trim() !== "");
|
|
35147
|
-
const filePaths = lines.slice(1);
|
|
35148
|
-
const truncatedFiles = filePaths.slice(0, limit2);
|
|
35149
|
-
const truncatedOutput = `Found ${limit2} file${limit2 !== 1 ? "s" : ""} (truncated from ${totalFiles})
|
|
35150
|
-
${truncatedFiles.join(`
|
|
35151
|
-
`)}`;
|
|
35152
|
-
return {
|
|
35153
|
-
output: truncatedOutput,
|
|
35154
|
-
files: limit2,
|
|
35155
|
-
truncated: true
|
|
35156
|
-
};
|
|
35157
|
-
}
|
|
35158
|
-
return {
|
|
35159
|
-
output: result.output,
|
|
35160
|
-
files: totalFiles,
|
|
35161
|
-
truncated: false
|
|
35162
|
-
};
|
|
35163
|
-
}
|
|
35164
|
-
var DEFAULT_LIMIT = 100;
|
|
35165
|
-
var init_GrepFiles2 = __esm(() => {
|
|
35166
|
-
init_Grep2();
|
|
35167
|
-
});
|
|
35168
|
-
|
|
35169
|
-
// src/tools/impl/KillBash.ts
|
|
35170
|
-
async function kill_bash(args) {
|
|
35171
|
-
validateRequiredParams(args, ["shell_id"], "KillBash");
|
|
35172
|
-
const { shell_id } = args;
|
|
35173
|
-
const proc = backgroundProcesses.get(shell_id);
|
|
35174
|
-
if (!proc)
|
|
35175
|
-
return { killed: false };
|
|
35176
|
-
try {
|
|
35177
|
-
proc.process.kill("SIGTERM");
|
|
35178
|
-
backgroundProcesses.delete(shell_id);
|
|
35179
|
-
return { killed: true };
|
|
35180
|
-
} catch {
|
|
35181
|
-
return { killed: false };
|
|
35182
|
-
}
|
|
35183
|
-
}
|
|
35184
|
-
var init_KillBash2 = __esm(() => {
|
|
35185
|
-
init_process_manager();
|
|
35186
|
-
});
|
|
35187
|
-
|
|
35188
|
-
// src/tools/impl/ListDirCodex.ts
|
|
35189
|
-
import { promises as fs5 } from "node:fs";
|
|
35190
|
-
import * as path7 from "node:path";
|
|
35191
|
-
async function list_dir(args) {
|
|
35192
|
-
validateRequiredParams(args, ["dir_path"], "list_dir");
|
|
35193
|
-
const { dir_path, offset = 1, limit: limit2 = 25, depth = 2 } = args;
|
|
35194
|
-
const userCwd = process.env.USER_CWD || process.cwd();
|
|
35195
|
-
const resolvedPath = path7.isAbsolute(dir_path) ? dir_path : path7.resolve(userCwd, dir_path);
|
|
35196
|
-
if (offset < 1) {
|
|
35197
|
-
throw new Error("offset must be a 1-indexed entry number");
|
|
35198
|
-
}
|
|
35199
|
-
if (limit2 < 1) {
|
|
35200
|
-
throw new Error("limit must be greater than zero");
|
|
35201
|
-
}
|
|
35202
|
-
if (depth < 1) {
|
|
35203
|
-
throw new Error("depth must be greater than zero");
|
|
35204
|
-
}
|
|
35205
|
-
const entries = await listDirSlice(resolvedPath, offset, limit2, depth);
|
|
35206
|
-
const output = [`Absolute path: ${resolvedPath}`, ...entries];
|
|
35207
|
-
return { content: output.join(`
|
|
35208
|
-
`) };
|
|
35209
|
-
}
|
|
35210
|
-
async function listDirSlice(dirPath, offset, limit2, maxDepth) {
|
|
35211
|
-
const entries = [];
|
|
35212
|
-
await collectEntries(dirPath, "", maxDepth, entries);
|
|
35213
|
-
if (entries.length === 0) {
|
|
35214
|
-
return [];
|
|
35215
|
-
}
|
|
35216
|
-
const startIndex = offset - 1;
|
|
35217
|
-
if (startIndex >= entries.length) {
|
|
35218
|
-
throw new Error("offset exceeds directory entry count");
|
|
35219
|
-
}
|
|
35220
|
-
const remainingEntries = entries.length - startIndex;
|
|
35221
|
-
const cappedLimit = Math.min(limit2, remainingEntries);
|
|
35222
|
-
const endIndex = startIndex + cappedLimit;
|
|
35223
|
-
const selectedEntries = entries.slice(startIndex, endIndex);
|
|
35224
|
-
selectedEntries.sort((a, b) => a.name.localeCompare(b.name));
|
|
35225
|
-
const formatted = [];
|
|
35226
|
-
for (const entry of selectedEntries) {
|
|
35227
|
-
formatted.push(formatEntryLine(entry));
|
|
35228
|
-
}
|
|
35229
|
-
if (endIndex < entries.length) {
|
|
35230
|
-
formatted.push(`More than ${cappedLimit} entries found`);
|
|
35231
|
-
}
|
|
35232
|
-
return formatted;
|
|
35233
|
-
}
|
|
35234
|
-
async function collectEntries(dirPath, relativePrefix, remainingDepth, entries) {
|
|
35235
|
-
const queue = [
|
|
35236
|
-
{ absPath: dirPath, prefix: relativePrefix, depth: remainingDepth }
|
|
35237
|
-
];
|
|
35238
|
-
while (queue.length > 0) {
|
|
35239
|
-
const current = queue.shift();
|
|
35240
|
-
if (!current)
|
|
35241
|
-
break;
|
|
35242
|
-
const { absPath, prefix, depth } = current;
|
|
35243
|
-
const dirEntries = [];
|
|
35244
|
-
try {
|
|
35245
|
-
const items = await fs5.readdir(absPath, { withFileTypes: true });
|
|
35246
|
-
for (const item of items) {
|
|
35247
|
-
const itemAbsPath = path7.join(absPath, item.name);
|
|
35248
|
-
const relativePath = prefix ? path7.join(prefix, item.name) : item.name;
|
|
35249
|
-
const displayName = formatEntryComponent(item.name);
|
|
35250
|
-
const displayDepth = prefix ? prefix.split(path7.sep).length : 0;
|
|
35251
|
-
const sortKey = formatEntryName(relativePath);
|
|
35252
|
-
let kind;
|
|
35253
|
-
if (item.isSymbolicLink()) {
|
|
35254
|
-
kind = "symlink";
|
|
35255
|
-
} else if (item.isDirectory()) {
|
|
35256
|
-
kind = "directory";
|
|
35257
|
-
} else if (item.isFile()) {
|
|
35258
|
-
kind = "file";
|
|
35259
|
-
} else {
|
|
35260
|
-
kind = "other";
|
|
35261
|
-
}
|
|
35262
|
-
dirEntries.push({
|
|
35263
|
-
absPath: itemAbsPath,
|
|
35264
|
-
relativePath,
|
|
35265
|
-
kind,
|
|
35266
|
-
entry: {
|
|
35267
|
-
name: sortKey,
|
|
35268
|
-
displayName,
|
|
35269
|
-
depth: displayDepth,
|
|
35270
|
-
kind
|
|
35271
|
-
}
|
|
35272
|
-
});
|
|
35273
|
-
}
|
|
35274
|
-
} catch (err) {
|
|
35275
|
-
throw new Error(`failed to read directory: ${err}`);
|
|
35276
|
-
}
|
|
35277
|
-
dirEntries.sort((a, b) => a.entry.name.localeCompare(b.entry.name));
|
|
35278
|
-
for (const item of dirEntries) {
|
|
35279
|
-
if (item.kind === "directory" && depth > 1) {
|
|
35280
|
-
queue.push({
|
|
35281
|
-
absPath: item.absPath,
|
|
35282
|
-
prefix: item.relativePath,
|
|
35283
|
-
depth: depth - 1
|
|
35284
|
-
});
|
|
35285
|
-
}
|
|
35286
|
-
entries.push(item.entry);
|
|
35287
|
-
}
|
|
35288
|
-
}
|
|
35289
|
-
}
|
|
35290
|
-
function formatEntryName(filePath) {
|
|
35291
|
-
const normalized = filePath.replace(/\\/g, "/");
|
|
35292
|
-
if (normalized.length > MAX_ENTRY_LENGTH) {
|
|
35293
|
-
return normalized.substring(0, MAX_ENTRY_LENGTH);
|
|
35294
|
-
}
|
|
35295
|
-
return normalized;
|
|
35296
|
-
}
|
|
35297
|
-
function formatEntryComponent(name) {
|
|
35298
|
-
if (name.length > MAX_ENTRY_LENGTH) {
|
|
35299
|
-
return name.substring(0, MAX_ENTRY_LENGTH);
|
|
35300
|
-
}
|
|
35301
|
-
return name;
|
|
35302
|
-
}
|
|
35303
|
-
function formatEntryLine(entry) {
|
|
35304
|
-
const indent = " ".repeat(entry.depth * INDENTATION_SPACES);
|
|
35305
|
-
let name = entry.displayName;
|
|
35306
|
-
switch (entry.kind) {
|
|
35307
|
-
case "directory":
|
|
35308
|
-
name += "/";
|
|
35309
|
-
break;
|
|
35310
|
-
case "symlink":
|
|
35311
|
-
name += "@";
|
|
35312
|
-
break;
|
|
35313
|
-
case "other":
|
|
35314
|
-
name += "?";
|
|
35315
|
-
break;
|
|
35316
|
-
default:
|
|
35317
|
-
break;
|
|
35318
|
-
}
|
|
35319
|
-
return `${indent}${name}`;
|
|
35320
|
-
}
|
|
35321
|
-
var MAX_ENTRY_LENGTH = 500, INDENTATION_SPACES = 2;
|
|
35322
|
-
var init_ListDirCodex2 = () => {};
|
|
35323
|
-
|
|
35324
35325
|
// src/tools/schemas/LS.json
|
|
35325
35326
|
var LS_default2;
|
|
35326
35327
|
var init_LS2 = __esm(() => {
|
|
@@ -35347,7 +35348,7 @@ var init_LS2 = __esm(() => {
|
|
|
35347
35348
|
|
|
35348
35349
|
// src/tools/impl/LS.ts
|
|
35349
35350
|
import { readdir as readdir2, stat } from "node:fs/promises";
|
|
35350
|
-
import { join as
|
|
35351
|
+
import { join as join6, resolve as resolve6 } from "node:path";
|
|
35351
35352
|
async function ls(args) {
|
|
35352
35353
|
validateRequiredParams(args, ["path"], "LS");
|
|
35353
35354
|
validateParamTypes(args, LS_default2, "LS");
|
|
@@ -35355,9 +35356,9 @@ async function ls(args) {
|
|
|
35355
35356
|
const dirPath = resolve6(inputPath);
|
|
35356
35357
|
try {
|
|
35357
35358
|
const items = await readdir2(dirPath);
|
|
35358
|
-
const filteredItems = items.filter((item) => !ignore.some((pattern) =>
|
|
35359
|
+
const filteredItems = items.filter((item) => !ignore.some((pattern) => import_picomatch.default.isMatch(item, pattern)));
|
|
35359
35360
|
const fileInfos = await Promise.all(filteredItems.map(async (item) => {
|
|
35360
|
-
const fullPath =
|
|
35361
|
+
const fullPath = join6(dirPath, item);
|
|
35361
35362
|
try {
|
|
35362
35363
|
const stats = await stat(fullPath);
|
|
35363
35364
|
return {
|
|
@@ -35415,11 +35416,11 @@ function formatTree(basePath, items, truncated, totalEntries) {
|
|
|
35415
35416
|
return lines.join(`
|
|
35416
35417
|
`);
|
|
35417
35418
|
}
|
|
35418
|
-
var
|
|
35419
|
+
var import_picomatch;
|
|
35419
35420
|
var init_LS3 = __esm(() => {
|
|
35420
35421
|
init_LS2();
|
|
35421
35422
|
init_truncation();
|
|
35422
|
-
|
|
35423
|
+
import_picomatch = __toESM(require_picomatch(), 1);
|
|
35423
35424
|
});
|
|
35424
35425
|
|
|
35425
35426
|
// src/tools/impl/ListDirectoryGemini.ts
|
|
@@ -35438,7 +35439,7 @@ var init_ListDirectoryGemini2 = __esm(() => {
|
|
|
35438
35439
|
});
|
|
35439
35440
|
|
|
35440
35441
|
// src/tools/impl/MultiEdit.ts
|
|
35441
|
-
import { promises as
|
|
35442
|
+
import { promises as fs5 } from "node:fs";
|
|
35442
35443
|
import * as path8 from "node:path";
|
|
35443
35444
|
async function multi_edit(args) {
|
|
35444
35445
|
validateRequiredParams(args, ["file_path", "edits"], "MultiEdit");
|
|
@@ -35457,7 +35458,7 @@ async function multi_edit(args) {
|
|
|
35457
35458
|
throw new Error(`Edit ${i + 1}: No changes to make: old_string and new_string are exactly the same.`);
|
|
35458
35459
|
}
|
|
35459
35460
|
try {
|
|
35460
|
-
const rawContent = await
|
|
35461
|
+
const rawContent = await fs5.readFile(resolvedPath, "utf-8");
|
|
35461
35462
|
let content = rawContent.replace(/\r\n/g, `
|
|
35462
35463
|
`);
|
|
35463
35464
|
const appliedEdits = [];
|
|
@@ -35483,7 +35484,7 @@ String: ${old_string}`);
|
|
|
35483
35484
|
}
|
|
35484
35485
|
appliedEdits.push(`Replaced "${old_string.substring(0, 50)}${old_string.length > 50 ? "..." : ""}" with "${new_string.substring(0, 50)}${new_string.length > 50 ? "..." : ""}"`);
|
|
35485
35486
|
}
|
|
35486
|
-
await
|
|
35487
|
+
await fs5.writeFile(resolvedPath, content, "utf-8");
|
|
35487
35488
|
const editList = appliedEdits.map((edit2, i) => `${i + 1}. ${edit2}`).join(`
|
|
35488
35489
|
`);
|
|
35489
35490
|
return {
|
|
@@ -35510,11 +35511,11 @@ ${editList}`,
|
|
|
35510
35511
|
var init_MultiEdit2 = () => {};
|
|
35511
35512
|
|
|
35512
35513
|
// src/tools/impl/Read.ts
|
|
35513
|
-
import { promises as
|
|
35514
|
+
import { promises as fs6 } from "node:fs";
|
|
35514
35515
|
import * as path9 from "node:path";
|
|
35515
35516
|
async function isBinaryFile(filePath) {
|
|
35516
35517
|
try {
|
|
35517
|
-
const fd = await
|
|
35518
|
+
const fd = await fs6.open(filePath, "r");
|
|
35518
35519
|
try {
|
|
35519
35520
|
const stats = await fd.stat();
|
|
35520
35521
|
const bufferSize = Math.min(8192, stats.size);
|
|
@@ -35598,7 +35599,7 @@ async function read(args) {
|
|
|
35598
35599
|
const userCwd = process.env.USER_CWD || process.cwd();
|
|
35599
35600
|
const resolvedPath = path9.isAbsolute(file_path) ? file_path : path9.resolve(userCwd, file_path);
|
|
35600
35601
|
try {
|
|
35601
|
-
const stats = await
|
|
35602
|
+
const stats = await fs6.stat(resolvedPath);
|
|
35602
35603
|
if (stats.isDirectory())
|
|
35603
35604
|
throw new Error(`Path is a directory, not a file: ${resolvedPath}`);
|
|
35604
35605
|
const maxSize = 10 * 1024 * 1024;
|
|
@@ -35606,7 +35607,7 @@ async function read(args) {
|
|
|
35606
35607
|
throw new Error(`File too large: ${stats.size} bytes (max ${maxSize} bytes)`);
|
|
35607
35608
|
if (await isBinaryFile(resolvedPath))
|
|
35608
35609
|
throw new Error(`Cannot read binary file: ${resolvedPath}`);
|
|
35609
|
-
const content = await
|
|
35610
|
+
const content = await fs6.readFile(resolvedPath, "utf-8");
|
|
35610
35611
|
if (content.trim() === "") {
|
|
35611
35612
|
return {
|
|
35612
35613
|
content: `<system-reminder>
|
|
@@ -35635,7 +35636,7 @@ var init_Read2 = __esm(() => {
|
|
|
35635
35636
|
});
|
|
35636
35637
|
|
|
35637
35638
|
// src/tools/impl/ReadFileCodex.ts
|
|
35638
|
-
import { promises as
|
|
35639
|
+
import { promises as fs7 } from "node:fs";
|
|
35639
35640
|
async function read_file(args) {
|
|
35640
35641
|
validateRequiredParams(args, ["file_path"], "read_file");
|
|
35641
35642
|
const {
|
|
@@ -35661,7 +35662,7 @@ async function read_file(args) {
|
|
|
35661
35662
|
`) };
|
|
35662
35663
|
}
|
|
35663
35664
|
async function readSliceMode(filePath, offset, limit2) {
|
|
35664
|
-
const content = await
|
|
35665
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
35665
35666
|
const allLines = content.split(/\r?\n/);
|
|
35666
35667
|
const collected = [];
|
|
35667
35668
|
for (let i = offset - 1;i < allLines.length && collected.length < limit2; i++) {
|
|
@@ -35688,7 +35689,7 @@ async function readIndentationMode(filePath, offset, limit2, options) {
|
|
|
35688
35689
|
if (maxLines < 1) {
|
|
35689
35690
|
throw new Error("max_lines must be greater than zero");
|
|
35690
35691
|
}
|
|
35691
|
-
const content = await
|
|
35692
|
+
const content = await fs7.readFile(filePath, "utf8");
|
|
35692
35693
|
const rawLines = content.split(/\r?\n/);
|
|
35693
35694
|
if (rawLines.length === 0 || anchorLine > rawLines.length) {
|
|
35694
35695
|
throw new Error("anchor_line exceeds file length");
|
|
@@ -39027,7 +39028,7 @@ var init_esm4 = __esm(() => {
|
|
|
39027
39028
|
|
|
39028
39029
|
// node_modules/path-scurry/dist/esm/index.js
|
|
39029
39030
|
import { posix, win32 } from "node:path";
|
|
39030
|
-
import { fileURLToPath as
|
|
39031
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
39031
39032
|
import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps } from "fs";
|
|
39032
39033
|
import * as actualFS from "node:fs";
|
|
39033
39034
|
import { lstat, readdir as readdir3, readlink, realpath } from "node:fs/promises";
|
|
@@ -39793,10 +39794,10 @@ var init_esm5 = __esm(() => {
|
|
|
39793
39794
|
#children;
|
|
39794
39795
|
nocase;
|
|
39795
39796
|
#fs;
|
|
39796
|
-
constructor(cwd2 = process.cwd(), pathImpl, sep3, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
39797
|
-
this.#fs = fsFromOption(
|
|
39797
|
+
constructor(cwd2 = process.cwd(), pathImpl, sep3, { nocase, childrenCacheSize = 16 * 1024, fs: fs8 = defaultFS } = {}) {
|
|
39798
|
+
this.#fs = fsFromOption(fs8);
|
|
39798
39799
|
if (cwd2 instanceof URL || cwd2.startsWith("file://")) {
|
|
39799
|
-
cwd2 =
|
|
39800
|
+
cwd2 = fileURLToPath4(cwd2);
|
|
39800
39801
|
}
|
|
39801
39802
|
const cwdPath = pathImpl.resolve(cwd2);
|
|
39802
39803
|
this.roots = Object.create(null);
|
|
@@ -40269,8 +40270,8 @@ var init_esm5 = __esm(() => {
|
|
|
40269
40270
|
parseRootPath(dir) {
|
|
40270
40271
|
return win32.parse(dir).root.toUpperCase();
|
|
40271
40272
|
}
|
|
40272
|
-
newRoot(
|
|
40273
|
-
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
40273
|
+
newRoot(fs8) {
|
|
40274
|
+
return new PathWin32(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
|
|
40274
40275
|
}
|
|
40275
40276
|
isAbsolute(p) {
|
|
40276
40277
|
return p.startsWith("/") || p.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(p);
|
|
@@ -40286,8 +40287,8 @@ var init_esm5 = __esm(() => {
|
|
|
40286
40287
|
parseRootPath(_dir) {
|
|
40287
40288
|
return "/";
|
|
40288
40289
|
}
|
|
40289
|
-
newRoot(
|
|
40290
|
-
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
40290
|
+
newRoot(fs8) {
|
|
40291
|
+
return new PathPosix(this.rootPath, IFDIR, undefined, this.roots, this.nocase, this.childrenCache(), { fs: fs8 });
|
|
40291
40292
|
}
|
|
40292
40293
|
isAbsolute(p) {
|
|
40293
40294
|
return p.startsWith("/");
|
|
@@ -40481,10 +40482,10 @@ class Ignore {
|
|
|
40481
40482
|
ignored(p) {
|
|
40482
40483
|
const fullpath = p.fullpath();
|
|
40483
40484
|
const fullpaths = `${fullpath}/`;
|
|
40484
|
-
const
|
|
40485
|
-
const relatives = `${
|
|
40485
|
+
const relative = p.relative() || ".";
|
|
40486
|
+
const relatives = `${relative}/`;
|
|
40486
40487
|
for (const m of this.relative) {
|
|
40487
|
-
if (m.match(
|
|
40488
|
+
if (m.match(relative) || m.match(relatives))
|
|
40488
40489
|
return true;
|
|
40489
40490
|
}
|
|
40490
40491
|
for (const m of this.absolute) {
|
|
@@ -40495,9 +40496,9 @@ class Ignore {
|
|
|
40495
40496
|
}
|
|
40496
40497
|
childrenIgnored(p) {
|
|
40497
40498
|
const fullpath = p.fullpath() + "/";
|
|
40498
|
-
const
|
|
40499
|
+
const relative = (p.relative() || ".") + "/";
|
|
40499
40500
|
for (const m of this.relativeChildren) {
|
|
40500
|
-
if (m.match(
|
|
40501
|
+
if (m.match(relative))
|
|
40501
40502
|
return true;
|
|
40502
40503
|
}
|
|
40503
40504
|
for (const m of this.absoluteChildren) {
|
|
@@ -41065,7 +41066,7 @@ var init_walker = __esm(() => {
|
|
|
41065
41066
|
});
|
|
41066
41067
|
|
|
41067
41068
|
// node_modules/glob/dist/esm/glob.js
|
|
41068
|
-
import { fileURLToPath as
|
|
41069
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
41069
41070
|
var defaultPlatform3, Glob;
|
|
41070
41071
|
var init_glob = __esm(() => {
|
|
41071
41072
|
init_esm2();
|
|
@@ -41114,7 +41115,7 @@ var init_glob = __esm(() => {
|
|
|
41114
41115
|
if (!opts.cwd) {
|
|
41115
41116
|
this.cwd = "";
|
|
41116
41117
|
} else if (opts.cwd instanceof URL || opts.cwd.startsWith("file://")) {
|
|
41117
|
-
opts.cwd =
|
|
41118
|
+
opts.cwd = fileURLToPath5(opts.cwd);
|
|
41118
41119
|
}
|
|
41119
41120
|
this.cwd = opts.cwd || "";
|
|
41120
41121
|
this.root = opts.root;
|
|
@@ -41780,14 +41781,14 @@ __export(exports_skills, {
|
|
|
41780
41781
|
});
|
|
41781
41782
|
import { existsSync as existsSync5 } from "node:fs";
|
|
41782
41783
|
import { readdir as readdir4, readFile as readFile3 } from "node:fs/promises";
|
|
41783
|
-
import { dirname as dirname4, join as
|
|
41784
|
-
import { fileURLToPath as
|
|
41784
|
+
import { dirname as dirname4, join as join7 } from "node:path";
|
|
41785
|
+
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
41785
41786
|
function getBundledSkillsPath() {
|
|
41786
|
-
const thisDir = dirname4(
|
|
41787
|
+
const thisDir = dirname4(fileURLToPath6(import.meta.url));
|
|
41787
41788
|
if (thisDir.includes("src/agent") || thisDir.includes("src\\agent")) {
|
|
41788
|
-
return
|
|
41789
|
+
return join7(thisDir, "../skills/builtin");
|
|
41789
41790
|
}
|
|
41790
|
-
return
|
|
41791
|
+
return join7(thisDir, "skills");
|
|
41791
41792
|
}
|
|
41792
41793
|
async function getBundledSkills() {
|
|
41793
41794
|
const bundledPath = getBundledSkillsPath();
|
|
@@ -41810,7 +41811,7 @@ async function discoverSkillsFromDir(skillsPath, source) {
|
|
|
41810
41811
|
}
|
|
41811
41812
|
return { skills, errors };
|
|
41812
41813
|
}
|
|
41813
|
-
async function discoverSkills(projectSkillsPath =
|
|
41814
|
+
async function discoverSkills(projectSkillsPath = join7(process.cwd(), SKILLS_DIR)) {
|
|
41814
41815
|
const allErrors = [];
|
|
41815
41816
|
const skillsById = new Map;
|
|
41816
41817
|
const bundledSkills = await getBundledSkills();
|
|
@@ -41836,7 +41837,7 @@ async function findSkillFiles(currentPath, rootPath, skills, errors, source) {
|
|
|
41836
41837
|
try {
|
|
41837
41838
|
const entries = await readdir4(currentPath, { withFileTypes: true });
|
|
41838
41839
|
for (const entry of entries) {
|
|
41839
|
-
const fullPath =
|
|
41840
|
+
const fullPath = join7(currentPath, entry.name);
|
|
41840
41841
|
if (entry.isDirectory()) {
|
|
41841
41842
|
await findSkillFiles(fullPath, rootPath, skills, errors, source);
|
|
41842
41843
|
} else if (entry.isFile() && entry.name.toUpperCase() === "SKILL.MD") {
|
|
@@ -42022,12 +42023,12 @@ function formatSkillsForMemory(skills, skillsDirectory) {
|
|
|
42022
42023
|
}
|
|
42023
42024
|
var SKILLS_DIR = ".skills", GLOBAL_SKILLS_DIR, SKILLS_BLOCK_CHAR_LIMIT = 20000;
|
|
42024
42025
|
var init_skills2 = __esm(() => {
|
|
42025
|
-
GLOBAL_SKILLS_DIR =
|
|
42026
|
+
GLOBAL_SKILLS_DIR = join7(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
|
|
42026
42027
|
});
|
|
42027
42028
|
|
|
42028
42029
|
// src/tools/impl/Skill.ts
|
|
42029
42030
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
42030
|
-
import { join as
|
|
42031
|
+
import { join as join8 } from "node:path";
|
|
42031
42032
|
function parseLoadedSkills(value) {
|
|
42032
42033
|
const skillMap = new Map;
|
|
42033
42034
|
const skillHeaderRegex = /# Skill: ([^\n]+)/g;
|
|
@@ -42092,17 +42093,17 @@ async function readSkillContent(skillId, skillsDir) {
|
|
|
42092
42093
|
return await readFile4(bundledSkill.path, "utf-8");
|
|
42093
42094
|
} catch {}
|
|
42094
42095
|
}
|
|
42095
|
-
const globalSkillPath =
|
|
42096
|
+
const globalSkillPath = join8(GLOBAL_SKILLS_DIR, skillId, "SKILL.md");
|
|
42096
42097
|
try {
|
|
42097
42098
|
return await readFile4(globalSkillPath, "utf-8");
|
|
42098
42099
|
} catch {}
|
|
42099
|
-
const skillPath =
|
|
42100
|
+
const skillPath = join8(skillsDir, skillId, "SKILL.md");
|
|
42100
42101
|
try {
|
|
42101
42102
|
return await readFile4(skillPath, "utf-8");
|
|
42102
42103
|
} catch (primaryError) {
|
|
42103
42104
|
try {
|
|
42104
|
-
const bundledSkillsDir =
|
|
42105
|
-
const bundledSkillPath =
|
|
42105
|
+
const bundledSkillsDir = join8(process.cwd(), "skills", "skills");
|
|
42106
|
+
const bundledSkillPath = join8(bundledSkillsDir, skillId, "SKILL.md");
|
|
42106
42107
|
return await readFile4(bundledSkillPath, "utf-8");
|
|
42107
42108
|
} catch {
|
|
42108
42109
|
throw primaryError;
|
|
@@ -42122,7 +42123,7 @@ async function getResolvedSkillsDir(client, agentId) {
|
|
|
42122
42123
|
} catch {}
|
|
42123
42124
|
}
|
|
42124
42125
|
if (!skillsDir) {
|
|
42125
|
-
skillsDir =
|
|
42126
|
+
skillsDir = join8(process.cwd(), SKILLS_DIR);
|
|
42126
42127
|
}
|
|
42127
42128
|
return skillsDir;
|
|
42128
42129
|
}
|
|
@@ -42868,7 +42869,7 @@ async function update_plan(_args) {
|
|
|
42868
42869
|
}
|
|
42869
42870
|
|
|
42870
42871
|
// src/tools/impl/Write.ts
|
|
42871
|
-
import { promises as
|
|
42872
|
+
import { promises as fs8 } from "node:fs";
|
|
42872
42873
|
import * as path13 from "node:path";
|
|
42873
42874
|
async function write(args) {
|
|
42874
42875
|
validateRequiredParams(args, ["file_path", "content"], "Write");
|
|
@@ -42877,9 +42878,9 @@ async function write(args) {
|
|
|
42877
42878
|
const resolvedPath = path13.isAbsolute(file_path) ? file_path : path13.resolve(userCwd, file_path);
|
|
42878
42879
|
try {
|
|
42879
42880
|
const dir = path13.dirname(resolvedPath);
|
|
42880
|
-
await
|
|
42881
|
+
await fs8.mkdir(dir, { recursive: true });
|
|
42881
42882
|
try {
|
|
42882
|
-
const stats = await
|
|
42883
|
+
const stats = await fs8.stat(resolvedPath);
|
|
42883
42884
|
if (stats.isDirectory())
|
|
42884
42885
|
throw new Error(`Path is a directory, not a file: ${resolvedPath}`);
|
|
42885
42886
|
} catch (error) {
|
|
@@ -42887,7 +42888,7 @@ async function write(args) {
|
|
|
42887
42888
|
if (err.code !== "ENOENT")
|
|
42888
42889
|
throw err;
|
|
42889
42890
|
}
|
|
42890
|
-
await
|
|
42891
|
+
await fs8.writeFile(resolvedPath, content, "utf-8");
|
|
42891
42892
|
return {
|
|
42892
42893
|
message: `Successfully wrote ${content.length} characters to ${resolvedPath}`
|
|
42893
42894
|
};
|
|
@@ -46007,7 +46008,7 @@ __export(exports_loader, {
|
|
|
46007
46008
|
loadPermissions: () => loadPermissions
|
|
46008
46009
|
});
|
|
46009
46010
|
import { homedir as homedir5 } from "node:os";
|
|
46010
|
-
import { join as
|
|
46011
|
+
import { join as join9 } from "node:path";
|
|
46011
46012
|
async function loadPermissions(workingDirectory = process.cwd()) {
|
|
46012
46013
|
const merged = {
|
|
46013
46014
|
allow: [],
|
|
@@ -46016,9 +46017,9 @@ async function loadPermissions(workingDirectory = process.cwd()) {
|
|
|
46016
46017
|
additionalDirectories: []
|
|
46017
46018
|
};
|
|
46018
46019
|
const sources = [
|
|
46019
|
-
|
|
46020
|
-
|
|
46021
|
-
|
|
46020
|
+
join9(homedir5(), ".letta", "settings.json"),
|
|
46021
|
+
join9(workingDirectory, ".letta", "settings.json"),
|
|
46022
|
+
join9(workingDirectory, ".letta", "settings.local.json")
|
|
46022
46023
|
];
|
|
46023
46024
|
for (const settingsPath of sources) {
|
|
46024
46025
|
try {
|
|
@@ -46054,13 +46055,13 @@ async function savePermissionRule(rule, ruleType, scope, workingDirectory = proc
|
|
|
46054
46055
|
let settingsPath;
|
|
46055
46056
|
switch (scope) {
|
|
46056
46057
|
case "user":
|
|
46057
|
-
settingsPath =
|
|
46058
|
+
settingsPath = join9(homedir5(), ".letta", "settings.json");
|
|
46058
46059
|
break;
|
|
46059
46060
|
case "project":
|
|
46060
|
-
settingsPath =
|
|
46061
|
+
settingsPath = join9(workingDirectory, ".letta", "settings.json");
|
|
46061
46062
|
break;
|
|
46062
46063
|
case "local":
|
|
46063
|
-
settingsPath =
|
|
46064
|
+
settingsPath = join9(workingDirectory, ".letta", "settings.local.json");
|
|
46064
46065
|
break;
|
|
46065
46066
|
}
|
|
46066
46067
|
let settings = {};
|
|
@@ -46085,7 +46086,7 @@ async function savePermissionRule(rule, ruleType, scope, workingDirectory = proc
|
|
|
46085
46086
|
}
|
|
46086
46087
|
}
|
|
46087
46088
|
async function ensureLocalSettingsIgnored(workingDirectory) {
|
|
46088
|
-
const gitignorePath =
|
|
46089
|
+
const gitignorePath = join9(workingDirectory, ".gitignore");
|
|
46089
46090
|
const pattern = ".letta/settings.local.json";
|
|
46090
46091
|
try {
|
|
46091
46092
|
let content = "";
|
|
@@ -47134,14 +47135,14 @@ __export(exports_skills2, {
|
|
|
47134
47135
|
});
|
|
47135
47136
|
import { existsSync as existsSync6 } from "node:fs";
|
|
47136
47137
|
import { readdir as readdir5, readFile as readFile5 } from "node:fs/promises";
|
|
47137
|
-
import { dirname as dirname7, join as
|
|
47138
|
-
import { fileURLToPath as
|
|
47138
|
+
import { dirname as dirname7, join as join10 } from "node:path";
|
|
47139
|
+
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
47139
47140
|
function getBundledSkillsPath2() {
|
|
47140
|
-
const thisDir = dirname7(
|
|
47141
|
+
const thisDir = dirname7(fileURLToPath7(import.meta.url));
|
|
47141
47142
|
if (thisDir.includes("src/agent") || thisDir.includes("src\\agent")) {
|
|
47142
|
-
return
|
|
47143
|
+
return join10(thisDir, "../skills/builtin");
|
|
47143
47144
|
}
|
|
47144
|
-
return
|
|
47145
|
+
return join10(thisDir, "skills");
|
|
47145
47146
|
}
|
|
47146
47147
|
async function getBundledSkills2() {
|
|
47147
47148
|
const bundledPath = getBundledSkillsPath2();
|
|
@@ -47164,7 +47165,7 @@ async function discoverSkillsFromDir2(skillsPath, source) {
|
|
|
47164
47165
|
}
|
|
47165
47166
|
return { skills, errors };
|
|
47166
47167
|
}
|
|
47167
|
-
async function discoverSkills2(projectSkillsPath =
|
|
47168
|
+
async function discoverSkills2(projectSkillsPath = join10(process.cwd(), SKILLS_DIR2)) {
|
|
47168
47169
|
const allErrors = [];
|
|
47169
47170
|
const skillsById = new Map;
|
|
47170
47171
|
const bundledSkills = await getBundledSkills2();
|
|
@@ -47190,7 +47191,7 @@ async function findSkillFiles2(currentPath, rootPath, skills, errors, source) {
|
|
|
47190
47191
|
try {
|
|
47191
47192
|
const entries = await readdir5(currentPath, { withFileTypes: true });
|
|
47192
47193
|
for (const entry of entries) {
|
|
47193
|
-
const fullPath =
|
|
47194
|
+
const fullPath = join10(currentPath, entry.name);
|
|
47194
47195
|
if (entry.isDirectory()) {
|
|
47195
47196
|
await findSkillFiles2(fullPath, rootPath, skills, errors, source);
|
|
47196
47197
|
} else if (entry.isFile() && entry.name.toUpperCase() === "SKILL.MD") {
|
|
@@ -47376,7 +47377,7 @@ function formatSkillsForMemory2(skills, skillsDirectory) {
|
|
|
47376
47377
|
}
|
|
47377
47378
|
var SKILLS_DIR2 = ".skills", GLOBAL_SKILLS_DIR2, SKILLS_BLOCK_CHAR_LIMIT2 = 20000;
|
|
47378
47379
|
var init_skills3 = __esm(() => {
|
|
47379
|
-
GLOBAL_SKILLS_DIR2 =
|
|
47380
|
+
GLOBAL_SKILLS_DIR2 = join10(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
|
|
47380
47381
|
});
|
|
47381
47382
|
|
|
47382
47383
|
// src/utils/fs.ts
|
|
@@ -47432,7 +47433,7 @@ __export(exports_auto_update, {
|
|
|
47432
47433
|
});
|
|
47433
47434
|
import { exec as exec2 } from "node:child_process";
|
|
47434
47435
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
47435
|
-
import { promisify as
|
|
47436
|
+
import { promisify as promisify3 } from "node:util";
|
|
47436
47437
|
function debugLog(...args) {
|
|
47437
47438
|
if (DEBUG) {
|
|
47438
47439
|
console.error("[auto-update]", ...args);
|
|
@@ -47544,7 +47545,7 @@ async function manualUpdate() {
|
|
|
47544
47545
|
var execAsync, DEBUG;
|
|
47545
47546
|
var init_auto_update = __esm(() => {
|
|
47546
47547
|
init_version();
|
|
47547
|
-
execAsync =
|
|
47548
|
+
execAsync = promisify3(exec2);
|
|
47548
47549
|
DEBUG = process.env.LETTA_DEBUG_AUTOUPDATE === "1";
|
|
47549
47550
|
});
|
|
47550
47551
|
|
|
@@ -47677,7 +47678,7 @@ __export(exports_subagents2, {
|
|
|
47677
47678
|
});
|
|
47678
47679
|
import { existsSync as existsSync8 } from "node:fs";
|
|
47679
47680
|
import { readdir as readdir6, readFile as readFile7 } from "node:fs/promises";
|
|
47680
|
-
import { join as
|
|
47681
|
+
import { join as join11 } from "node:path";
|
|
47681
47682
|
function isValidName2(name) {
|
|
47682
47683
|
return /^[a-z][a-z0-9-]*$/.test(name);
|
|
47683
47684
|
}
|
|
@@ -47767,7 +47768,7 @@ async function discoverSubagentsFromDir2(agentsDir, seenNames, subagents, errors
|
|
|
47767
47768
|
if (!entry.isFile() || !entry.name.endsWith(".md")) {
|
|
47768
47769
|
continue;
|
|
47769
47770
|
}
|
|
47770
|
-
const filePath =
|
|
47771
|
+
const filePath = join11(agentsDir, entry.name);
|
|
47771
47772
|
try {
|
|
47772
47773
|
const config = await parseSubagentFile2(filePath);
|
|
47773
47774
|
if (config) {
|
|
@@ -47799,7 +47800,7 @@ async function discoverSubagents2(workingDirectory = process.cwd()) {
|
|
|
47799
47800
|
const subagents = [];
|
|
47800
47801
|
const seenNames = new Set;
|
|
47801
47802
|
await discoverSubagentsFromDir2(GLOBAL_AGENTS_DIR2, seenNames, subagents, errors);
|
|
47802
|
-
const projectAgentsDir =
|
|
47803
|
+
const projectAgentsDir = join11(workingDirectory, AGENTS_DIR2);
|
|
47803
47804
|
await discoverSubagentsFromDir2(projectAgentsDir, seenNames, subagents, errors);
|
|
47804
47805
|
return { subagents, errors };
|
|
47805
47806
|
}
|
|
@@ -47830,7 +47831,7 @@ var init_subagents2 = __esm(() => {
|
|
|
47830
47831
|
init_general_purpose();
|
|
47831
47832
|
init_plan();
|
|
47832
47833
|
BUILTIN_SOURCES2 = [explore_default, general_purpose_default, plan_default];
|
|
47833
|
-
GLOBAL_AGENTS_DIR2 =
|
|
47834
|
+
GLOBAL_AGENTS_DIR2 = join11(process.env.HOME || process.env.USERPROFILE || "~", ".letta/agents");
|
|
47834
47835
|
VALID_MEMORY_BLOCKS2 = new Set(MEMORY_BLOCK_LABELS);
|
|
47835
47836
|
cache4 = {
|
|
47836
47837
|
builtins: null,
|
|
@@ -47840,10 +47841,10 @@ var init_subagents2 = __esm(() => {
|
|
|
47840
47841
|
});
|
|
47841
47842
|
|
|
47842
47843
|
// node_modules/is-docker/index.js
|
|
47843
|
-
import
|
|
47844
|
+
import fs9 from "node:fs";
|
|
47844
47845
|
function hasDockerEnv() {
|
|
47845
47846
|
try {
|
|
47846
|
-
|
|
47847
|
+
fs9.statSync("/.dockerenv");
|
|
47847
47848
|
return true;
|
|
47848
47849
|
} catch {
|
|
47849
47850
|
return false;
|
|
@@ -47851,7 +47852,7 @@ function hasDockerEnv() {
|
|
|
47851
47852
|
}
|
|
47852
47853
|
function hasDockerCGroup() {
|
|
47853
47854
|
try {
|
|
47854
|
-
return
|
|
47855
|
+
return fs9.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
47855
47856
|
} catch {
|
|
47856
47857
|
return false;
|
|
47857
47858
|
}
|
|
@@ -47866,7 +47867,7 @@ var isDockerCached;
|
|
|
47866
47867
|
var init_is_docker = () => {};
|
|
47867
47868
|
|
|
47868
47869
|
// node_modules/is-inside-container/index.js
|
|
47869
|
-
import
|
|
47870
|
+
import fs10 from "node:fs";
|
|
47870
47871
|
function isInsideContainer() {
|
|
47871
47872
|
if (cachedResult === undefined) {
|
|
47872
47873
|
cachedResult = hasContainerEnv() || isDocker();
|
|
@@ -47875,7 +47876,7 @@ function isInsideContainer() {
|
|
|
47875
47876
|
}
|
|
47876
47877
|
var cachedResult, hasContainerEnv = () => {
|
|
47877
47878
|
try {
|
|
47878
|
-
|
|
47879
|
+
fs10.statSync("/run/.containerenv");
|
|
47879
47880
|
return true;
|
|
47880
47881
|
} catch {
|
|
47881
47882
|
return false;
|
|
@@ -47888,7 +47889,7 @@ var init_is_inside_container = __esm(() => {
|
|
|
47888
47889
|
// node_modules/is-wsl/index.js
|
|
47889
47890
|
import process13 from "node:process";
|
|
47890
47891
|
import os2 from "node:os";
|
|
47891
|
-
import
|
|
47892
|
+
import fs11 from "node:fs";
|
|
47892
47893
|
var isWsl = () => {
|
|
47893
47894
|
if (process13.platform !== "linux") {
|
|
47894
47895
|
return false;
|
|
@@ -47900,7 +47901,7 @@ var isWsl = () => {
|
|
|
47900
47901
|
return true;
|
|
47901
47902
|
}
|
|
47902
47903
|
try {
|
|
47903
|
-
return
|
|
47904
|
+
return fs11.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
47904
47905
|
} catch {
|
|
47905
47906
|
return false;
|
|
47906
47907
|
}
|
|
@@ -47912,7 +47913,7 @@ var init_is_wsl = __esm(() => {
|
|
|
47912
47913
|
|
|
47913
47914
|
// node_modules/wsl-utils/index.js
|
|
47914
47915
|
import process14 from "node:process";
|
|
47915
|
-
import
|
|
47916
|
+
import fs12, { constants as fsConstants } from "node:fs/promises";
|
|
47916
47917
|
var wslDrivesMountPoint, powerShellPathFromWsl = async () => {
|
|
47917
47918
|
const mountPoint = await wslDrivesMountPoint();
|
|
47918
47919
|
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
@@ -47935,13 +47936,13 @@ var init_wsl_utils = __esm(() => {
|
|
|
47935
47936
|
const configFilePath = "/etc/wsl.conf";
|
|
47936
47937
|
let isConfigFileExists = false;
|
|
47937
47938
|
try {
|
|
47938
|
-
await
|
|
47939
|
+
await fs12.access(configFilePath, fsConstants.F_OK);
|
|
47939
47940
|
isConfigFileExists = true;
|
|
47940
47941
|
} catch {}
|
|
47941
47942
|
if (!isConfigFileExists) {
|
|
47942
47943
|
return defaultMountPoint;
|
|
47943
47944
|
}
|
|
47944
|
-
const configContent = await
|
|
47945
|
+
const configContent = await fs12.readFile(configFilePath, { encoding: "utf8" });
|
|
47945
47946
|
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
47946
47947
|
if (!configMountPoint) {
|
|
47947
47948
|
return defaultMountPoint;
|
|
@@ -47972,26 +47973,26 @@ function defineLazyProperty(object, propertyName, valueGetter) {
|
|
|
47972
47973
|
}
|
|
47973
47974
|
|
|
47974
47975
|
// node_modules/default-browser-id/index.js
|
|
47975
|
-
import { promisify as
|
|
47976
|
+
import { promisify as promisify4 } from "node:util";
|
|
47976
47977
|
import process15 from "node:process";
|
|
47977
|
-
import { execFile as
|
|
47978
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
47978
47979
|
async function defaultBrowserId() {
|
|
47979
47980
|
if (process15.platform !== "darwin") {
|
|
47980
47981
|
throw new Error("macOS only");
|
|
47981
47982
|
}
|
|
47982
|
-
const { stdout } = await
|
|
47983
|
+
const { stdout } = await execFileAsync3("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
47983
47984
|
const match3 = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
47984
47985
|
return match3?.groups.id ?? "com.apple.Safari";
|
|
47985
47986
|
}
|
|
47986
|
-
var
|
|
47987
|
+
var execFileAsync3;
|
|
47987
47988
|
var init_default_browser_id = __esm(() => {
|
|
47988
|
-
|
|
47989
|
+
execFileAsync3 = promisify4(execFile3);
|
|
47989
47990
|
});
|
|
47990
47991
|
|
|
47991
47992
|
// node_modules/run-applescript/index.js
|
|
47992
47993
|
import process16 from "node:process";
|
|
47993
|
-
import { promisify as
|
|
47994
|
-
import { execFile as
|
|
47994
|
+
import { promisify as promisify5 } from "node:util";
|
|
47995
|
+
import { execFile as execFile4, execFileSync } from "node:child_process";
|
|
47995
47996
|
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
47996
47997
|
if (process16.platform !== "darwin") {
|
|
47997
47998
|
throw new Error("macOS only");
|
|
@@ -48001,12 +48002,12 @@ async function runAppleScript(script, { humanReadableOutput = true, signal } = {
|
|
|
48001
48002
|
if (signal) {
|
|
48002
48003
|
execOptions.signal = signal;
|
|
48003
48004
|
}
|
|
48004
|
-
const { stdout } = await
|
|
48005
|
+
const { stdout } = await execFileAsync4("osascript", ["-e", script, outputArguments], execOptions);
|
|
48005
48006
|
return stdout.trim();
|
|
48006
48007
|
}
|
|
48007
|
-
var
|
|
48008
|
+
var execFileAsync4;
|
|
48008
48009
|
var init_run_applescript = __esm(() => {
|
|
48009
|
-
|
|
48010
|
+
execFileAsync4 = promisify5(execFile4);
|
|
48010
48011
|
});
|
|
48011
48012
|
|
|
48012
48013
|
// node_modules/bundle-name/index.js
|
|
@@ -48019,9 +48020,9 @@ var init_bundle_name = __esm(() => {
|
|
|
48019
48020
|
});
|
|
48020
48021
|
|
|
48021
48022
|
// node_modules/default-browser/windows.js
|
|
48022
|
-
import { promisify as
|
|
48023
|
-
import { execFile as
|
|
48024
|
-
async function defaultBrowser(_execFileAsync =
|
|
48023
|
+
import { promisify as promisify6 } from "node:util";
|
|
48024
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
48025
|
+
async function defaultBrowser(_execFileAsync = execFileAsync5) {
|
|
48025
48026
|
const { stdout } = await _execFileAsync("reg", [
|
|
48026
48027
|
"QUERY",
|
|
48027
48028
|
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
@@ -48039,9 +48040,9 @@ async function defaultBrowser(_execFileAsync = execFileAsync4) {
|
|
|
48039
48040
|
}
|
|
48040
48041
|
return browser;
|
|
48041
48042
|
}
|
|
48042
|
-
var
|
|
48043
|
+
var execFileAsync5, windowsBrowserProgIds, UnknownBrowserError;
|
|
48043
48044
|
var init_windows = __esm(() => {
|
|
48044
|
-
|
|
48045
|
+
execFileAsync5 = promisify6(execFile5);
|
|
48045
48046
|
windowsBrowserProgIds = {
|
|
48046
48047
|
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
48047
48048
|
MSEdgeDHTML: { name: "Edge", id: "com.microsoft.edge" },
|
|
@@ -48058,9 +48059,9 @@ var init_windows = __esm(() => {
|
|
|
48058
48059
|
});
|
|
48059
48060
|
|
|
48060
48061
|
// node_modules/default-browser/index.js
|
|
48061
|
-
import { promisify as
|
|
48062
|
+
import { promisify as promisify7 } from "node:util";
|
|
48062
48063
|
import process17 from "node:process";
|
|
48063
|
-
import { execFile as
|
|
48064
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
48064
48065
|
async function defaultBrowser2() {
|
|
48065
48066
|
if (process17.platform === "darwin") {
|
|
48066
48067
|
const id = await defaultBrowserId();
|
|
@@ -48068,7 +48069,7 @@ async function defaultBrowser2() {
|
|
|
48068
48069
|
return { name, id };
|
|
48069
48070
|
}
|
|
48070
48071
|
if (process17.platform === "linux") {
|
|
48071
|
-
const { stdout } = await
|
|
48072
|
+
const { stdout } = await execFileAsync6("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
48072
48073
|
const id = stdout.trim();
|
|
48073
48074
|
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
48074
48075
|
return { name, id };
|
|
@@ -48078,12 +48079,12 @@ async function defaultBrowser2() {
|
|
|
48078
48079
|
}
|
|
48079
48080
|
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
48080
48081
|
}
|
|
48081
|
-
var
|
|
48082
|
+
var execFileAsync6, titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
48082
48083
|
var init_default_browser = __esm(() => {
|
|
48083
48084
|
init_default_browser_id();
|
|
48084
48085
|
init_bundle_name();
|
|
48085
48086
|
init_windows();
|
|
48086
|
-
|
|
48087
|
+
execFileAsync6 = promisify7(execFile6);
|
|
48087
48088
|
});
|
|
48088
48089
|
|
|
48089
48090
|
// node_modules/open/index.js
|
|
@@ -48096,15 +48097,15 @@ __export(exports_open, {
|
|
|
48096
48097
|
import process18 from "node:process";
|
|
48097
48098
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
48098
48099
|
import path15 from "node:path";
|
|
48099
|
-
import { fileURLToPath as
|
|
48100
|
-
import { promisify as
|
|
48100
|
+
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
48101
|
+
import { promisify as promisify8 } from "node:util";
|
|
48101
48102
|
import childProcess from "node:child_process";
|
|
48102
|
-
import
|
|
48103
|
+
import fs13, { constants as fsConstants2 } from "node:fs/promises";
|
|
48103
48104
|
async function getWindowsDefaultBrowserFromWsl() {
|
|
48104
48105
|
const powershellPath = await powerShellPath();
|
|
48105
48106
|
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
48106
48107
|
const encodedCommand = Buffer3.from(rawCommand, "utf16le").toString("base64");
|
|
48107
|
-
const { stdout } = await
|
|
48108
|
+
const { stdout } = await execFile7(powershellPath, [
|
|
48108
48109
|
"-NoProfile",
|
|
48109
48110
|
"-NonInteractive",
|
|
48110
48111
|
"-ExecutionPolicy",
|
|
@@ -48140,7 +48141,7 @@ function detectPlatformBinary({ [platform2]: platformBinary }, { wsl }) {
|
|
|
48140
48141
|
}
|
|
48141
48142
|
return detectArchBinary(platformBinary);
|
|
48142
48143
|
}
|
|
48143
|
-
var
|
|
48144
|
+
var execFile7, __dirname2, localXdgOpenPath, platform2, arch, pTryEach = async (array, mapper) => {
|
|
48144
48145
|
let latestError;
|
|
48145
48146
|
for (const item of array) {
|
|
48146
48147
|
try {
|
|
@@ -48256,7 +48257,7 @@ var execFile6, __dirname2, localXdgOpenPath, platform2, arch, pTryEach = async (
|
|
|
48256
48257
|
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
48257
48258
|
let exeLocalXdgOpen = false;
|
|
48258
48259
|
try {
|
|
48259
|
-
await
|
|
48260
|
+
await fs13.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
48260
48261
|
exeLocalXdgOpen = true;
|
|
48261
48262
|
} catch {}
|
|
48262
48263
|
const useSystemXdgOpen = process18.versions.electron ?? (platform2 === "android" || isBundled || !exeLocalXdgOpen);
|
|
@@ -48319,8 +48320,8 @@ var init_open = __esm(() => {
|
|
|
48319
48320
|
init_wsl_utils();
|
|
48320
48321
|
init_default_browser();
|
|
48321
48322
|
init_is_inside_container();
|
|
48322
|
-
|
|
48323
|
-
__dirname2 = path15.dirname(
|
|
48323
|
+
execFile7 = promisify8(childProcess.execFile);
|
|
48324
|
+
__dirname2 = path15.dirname(fileURLToPath8(import.meta.url));
|
|
48324
48325
|
localXdgOpenPath = path15.join(__dirname2, "xdg-open");
|
|
48325
48326
|
({ platform: platform2, arch } = process18);
|
|
48326
48327
|
apps = {};
|
|
@@ -49588,7 +49589,7 @@ var SLEEPTIME_MEMORY_PERSONA = `I am a sleep-time memory management agent. I obs
|
|
|
49588
49589
|
- Continue using memory policies that don't serve the user's actual needs`;
|
|
49589
49590
|
|
|
49590
49591
|
// src/agent/create.ts
|
|
49591
|
-
import { join as
|
|
49592
|
+
import { join as join12 } from "node:path";
|
|
49592
49593
|
async function createAgent(name = DEFAULT_AGENT_NAME, model, embeddingModel = "openai/text-embedding-3-small", updateArgs, skillsDirectory, parallelToolCalls = true, enableSleeptime = false, systemPromptId, initBlocks, baseTools) {
|
|
49593
49594
|
let modelHandle;
|
|
49594
49595
|
if (model) {
|
|
@@ -49640,7 +49641,7 @@ async function createAgent(name = DEFAULT_AGENT_NAME, model, embeddingModel = "o
|
|
|
49640
49641
|
}
|
|
49641
49642
|
}
|
|
49642
49643
|
const filteredMemoryBlocks = allowedBlockLabels && allowedBlockLabels.size > 0 ? defaultMemoryBlocks.filter((b) => allowedBlockLabels.has(b.label)) : defaultMemoryBlocks;
|
|
49643
|
-
const resolvedSkillsDirectory = skillsDirectory ||
|
|
49644
|
+
const resolvedSkillsDirectory = skillsDirectory || join12(process.cwd(), SKILLS_DIR);
|
|
49644
49645
|
try {
|
|
49645
49646
|
const { skills, errors } = await discoverSkills(resolvedSkillsDirectory);
|
|
49646
49647
|
if (errors.length > 0) {
|
|
@@ -50895,8 +50896,8 @@ async function handleHeadlessCommand(argv, model, skillsDirectory) {
|
|
|
50895
50896
|
await initializeLoadedSkillsFlag2();
|
|
50896
50897
|
try {
|
|
50897
50898
|
const { discoverSkills: discoverSkills3, formatSkillsForMemory: formatSkillsForMemory3, SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills2(), exports_skills));
|
|
50898
|
-
const { join:
|
|
50899
|
-
const resolvedSkillsDirectory = skillsDirectory ||
|
|
50899
|
+
const { join: join13 } = await import("node:path");
|
|
50900
|
+
const resolvedSkillsDirectory = skillsDirectory || join13(process.cwd(), SKILLS_DIR3);
|
|
50900
50901
|
const { skills, errors } = await discoverSkills3(resolvedSkillsDirectory);
|
|
50901
50902
|
if (errors.length > 0) {
|
|
50902
50903
|
console.warn("Errors encountered during skill discovery:");
|
|
@@ -51497,9 +51498,9 @@ var init_available_models = __esm(() => {
|
|
|
51497
51498
|
});
|
|
51498
51499
|
|
|
51499
51500
|
// src/settings.ts
|
|
51500
|
-
import { join as
|
|
51501
|
+
import { join as join13 } from "node:path";
|
|
51501
51502
|
function getProjectSettingsPath() {
|
|
51502
|
-
return
|
|
51503
|
+
return join13(process.cwd(), ".letta", "settings.local.json");
|
|
51503
51504
|
}
|
|
51504
51505
|
async function loadProjectSettings() {
|
|
51505
51506
|
const settingsPath = getProjectSettingsPath();
|
|
@@ -51517,7 +51518,7 @@ async function loadProjectSettings() {
|
|
|
51517
51518
|
}
|
|
51518
51519
|
async function saveProjectSettings(settings) {
|
|
51519
51520
|
const settingsPath = getProjectSettingsPath();
|
|
51520
|
-
const dirPath =
|
|
51521
|
+
const dirPath = join13(process.cwd(), ".letta");
|
|
51521
51522
|
try {
|
|
51522
51523
|
if (!exists(dirPath)) {
|
|
51523
51524
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -52941,7 +52942,7 @@ var init_libesm = __esm(() => {
|
|
|
52941
52942
|
});
|
|
52942
52943
|
|
|
52943
52944
|
// src/cli/helpers/diff.ts
|
|
52944
|
-
import { basename
|
|
52945
|
+
import { basename } from "node:path";
|
|
52945
52946
|
function readFileOrNull(p) {
|
|
52946
52947
|
try {
|
|
52947
52948
|
return __require("node:fs").readFileSync(p, "utf-8");
|
|
@@ -52965,7 +52966,7 @@ function applyAllOccurrences(content, oldStr, newStr) {
|
|
|
52965
52966
|
return { ok: true, out: content.split(oldStr).join(newStr) };
|
|
52966
52967
|
}
|
|
52967
52968
|
function computeAdvancedDiff(input, opts) {
|
|
52968
|
-
const fileName =
|
|
52969
|
+
const fileName = basename(input.filePath || "");
|
|
52969
52970
|
const fileContent = opts?.oldStrOverride !== undefined ? opts.oldStrOverride : readFileOrNull(input.filePath);
|
|
52970
52971
|
if (fileContent === null && input.kind !== "write") {
|
|
52971
52972
|
return { mode: "fallback", reason: "File not readable" };
|
|
@@ -53031,7 +53032,7 @@ function computeAdvancedDiff(input, opts) {
|
|
|
53031
53032
|
return { mode: "advanced", fileName, oldStr, newStr, hunks };
|
|
53032
53033
|
}
|
|
53033
53034
|
function parsePatchToAdvancedDiff(patchLines, filePath) {
|
|
53034
|
-
const fileName =
|
|
53035
|
+
const fileName = basename(filePath);
|
|
53035
53036
|
const hunks = [];
|
|
53036
53037
|
let currentHunk = null;
|
|
53037
53038
|
let oldLine = 1;
|
|
@@ -53207,10 +53208,10 @@ function isShellTool(name) {
|
|
|
53207
53208
|
}
|
|
53208
53209
|
|
|
53209
53210
|
// src/cli/helpers/formatArgsDisplay.ts
|
|
53210
|
-
import { relative
|
|
53211
|
+
import { relative } from "node:path";
|
|
53211
53212
|
function formatDisplayPath(filePath) {
|
|
53212
53213
|
const cwd2 = process.cwd();
|
|
53213
|
-
const relativePath =
|
|
53214
|
+
const relativePath = relative(cwd2, filePath);
|
|
53214
53215
|
if (relativePath.startsWith("..")) {
|
|
53215
53216
|
return filePath;
|
|
53216
53217
|
}
|
|
@@ -53572,10 +53573,10 @@ var init_pasteRegistry = __esm(() => {
|
|
|
53572
53573
|
});
|
|
53573
53574
|
|
|
53574
53575
|
// src/cli/components/DiffRenderer.tsx
|
|
53575
|
-
import { relative as
|
|
53576
|
+
import { relative as relative2 } from "node:path";
|
|
53576
53577
|
function formatDisplayPath2(filePath) {
|
|
53577
53578
|
const cwd2 = process.cwd();
|
|
53578
|
-
const relativePath =
|
|
53579
|
+
const relativePath = relative2(cwd2, filePath);
|
|
53579
53580
|
if (relativePath.startsWith("..")) {
|
|
53580
53581
|
return filePath;
|
|
53581
53582
|
}
|
|
@@ -53942,10 +53943,10 @@ var init_DiffRenderer = __esm(async () => {
|
|
|
53942
53943
|
});
|
|
53943
53944
|
|
|
53944
53945
|
// src/cli/components/AdvancedDiffRenderer.tsx
|
|
53945
|
-
import { relative as
|
|
53946
|
+
import { relative as relative3 } from "node:path";
|
|
53946
53947
|
function formatRelativePath(filePath) {
|
|
53947
53948
|
const cwd2 = process.cwd();
|
|
53948
|
-
const relativePath =
|
|
53949
|
+
const relativePath = relative3(cwd2, filePath);
|
|
53949
53950
|
return relativePath.startsWith("..") ? relativePath : `./${relativePath}`;
|
|
53950
53951
|
}
|
|
53951
53952
|
function padLeft(n, width) {
|
|
@@ -54134,7 +54135,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
54134
54135
|
}, undefined, true, undefined, this);
|
|
54135
54136
|
}
|
|
54136
54137
|
const { hunks } = result;
|
|
54137
|
-
const
|
|
54138
|
+
const relative4 = formatRelativePath(props.filePath);
|
|
54138
54139
|
const enableWord = props.kind !== "multi_edit";
|
|
54139
54140
|
const rows = [];
|
|
54140
54141
|
for (const h of hunks) {
|
|
@@ -54212,7 +54213,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
54212
54213
|
}
|
|
54213
54214
|
const maxDisplayNo = rows.reduce((m, r) => Math.max(m, r.displayNo), 1);
|
|
54214
54215
|
const gutterWidth = String(maxDisplayNo).length;
|
|
54215
|
-
const header = props.kind === "write" ? `Wrote changes to ${
|
|
54216
|
+
const header = props.kind === "write" ? `Wrote changes to ${relative4}` : `Updated ${relative4}`;
|
|
54216
54217
|
if (rows.length === 0) {
|
|
54217
54218
|
const noChangesGutter = 4;
|
|
54218
54219
|
return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Box_default, {
|
|
@@ -54261,7 +54262,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
54261
54262
|
"No changes to ",
|
|
54262
54263
|
/* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
|
|
54263
54264
|
bold: true,
|
|
54264
|
-
children:
|
|
54265
|
+
children: relative4
|
|
54265
54266
|
}, undefined, false, undefined, this),
|
|
54266
54267
|
" (file content identical)"
|
|
54267
54268
|
]
|
|
@@ -54511,7 +54512,7 @@ var init_build4 = __esm(async () => {
|
|
|
54511
54512
|
// src/cli/helpers/clipboard.ts
|
|
54512
54513
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
54513
54514
|
import { existsSync as existsSync9, readFileSync as readFileSync2, statSync } from "node:fs";
|
|
54514
|
-
import { basename as
|
|
54515
|
+
import { basename as basename2, extname, isAbsolute as isAbsolute10, resolve as resolve16 } from "node:path";
|
|
54515
54516
|
function countLines2(text) {
|
|
54516
54517
|
return (text.match(/\r\n|\r|\n/g) || []).length + 1;
|
|
54517
54518
|
}
|
|
@@ -54568,7 +54569,7 @@ function translatePasteForImages(paste) {
|
|
|
54568
54569
|
const id = allocateImage({
|
|
54569
54570
|
data: b64,
|
|
54570
54571
|
mediaType: mt,
|
|
54571
|
-
filename:
|
|
54572
|
+
filename: basename2(filePath)
|
|
54572
54573
|
});
|
|
54573
54574
|
s = `[Image #${id}]`;
|
|
54574
54575
|
}
|
|
@@ -55165,13 +55166,13 @@ var import_react30, jsx_dev_runtime8, OptionsRenderer, DynamicPreview = ({
|
|
|
55165
55166
|
if (typeof inputVal === "string") {
|
|
55166
55167
|
const operations = parsePatchOperations(inputVal);
|
|
55167
55168
|
if (operations.length > 0) {
|
|
55168
|
-
const { relative:
|
|
55169
|
+
const { relative: relative4 } = __require("node:path");
|
|
55169
55170
|
const cwd2 = process.cwd();
|
|
55170
55171
|
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
55171
55172
|
flexDirection: "column",
|
|
55172
55173
|
paddingLeft: 2,
|
|
55173
55174
|
children: operations.map((op, idx) => {
|
|
55174
|
-
const relPath =
|
|
55175
|
+
const relPath = relative4(cwd2, op.path);
|
|
55175
55176
|
const displayPath = relPath.startsWith("..") ? op.path : relPath;
|
|
55176
55177
|
const diffKey = toolCallId ? `${toolCallId}:${op.path}` : undefined;
|
|
55177
55178
|
const opDiff = diffKey ? allDiffs.get(diffKey) : undefined;
|
|
@@ -55687,9 +55688,9 @@ var init_ApprovalDialogRich = __esm(async () => {
|
|
|
55687
55688
|
const filePath = parsedArgs.file_path;
|
|
55688
55689
|
if (filePath) {
|
|
55689
55690
|
const { existsSync: existsSync10 } = __require("node:fs");
|
|
55690
|
-
const { relative:
|
|
55691
|
+
const { relative: relative4 } = __require("node:path");
|
|
55691
55692
|
const cwd2 = process.cwd();
|
|
55692
|
-
const relPath =
|
|
55693
|
+
const relPath = relative4(cwd2, filePath);
|
|
55693
55694
|
const displayPath = relPath.startsWith("..") ? filePath : relPath;
|
|
55694
55695
|
try {
|
|
55695
55696
|
if (existsSync10(filePath)) {
|
|
@@ -55702,10 +55703,10 @@ var init_ApprovalDialogRich = __esm(async () => {
|
|
|
55702
55703
|
if ((t === "apply_patch" || t === "applypatch") && parsedArgs.input) {
|
|
55703
55704
|
const operations = parsePatchOperations(parsedArgs.input);
|
|
55704
55705
|
if (operations.length > 0) {
|
|
55705
|
-
const { relative:
|
|
55706
|
+
const { relative: relative4 } = __require("node:path");
|
|
55706
55707
|
const cwd2 = process.cwd();
|
|
55707
55708
|
const paths = operations.map((op) => {
|
|
55708
|
-
const relPath =
|
|
55709
|
+
const relPath = relative4(cwd2, op.path);
|
|
55709
55710
|
return relPath.startsWith("..") ? op.path : relPath;
|
|
55710
55711
|
});
|
|
55711
55712
|
if (paths.length === 1) {
|
|
@@ -56795,7 +56796,7 @@ var init_registry = __esm(() => {
|
|
|
56795
56796
|
}
|
|
56796
56797
|
},
|
|
56797
56798
|
"/clear": {
|
|
56798
|
-
desc: "Clear conversation history",
|
|
56799
|
+
desc: "Clear conversation history (keep memory)",
|
|
56799
56800
|
order: 17,
|
|
56800
56801
|
handler: () => {
|
|
56801
56802
|
return "Clearing messages...";
|
|
@@ -56987,7 +56988,7 @@ __export(exports_custom, {
|
|
|
56987
56988
|
});
|
|
56988
56989
|
import { existsSync as existsSync10 } from "node:fs";
|
|
56989
56990
|
import { readdir as readdir7, readFile as readFile8 } from "node:fs/promises";
|
|
56990
|
-
import { basename as
|
|
56991
|
+
import { basename as basename3, dirname as dirname9, join as join14 } from "node:path";
|
|
56991
56992
|
async function getCustomCommands() {
|
|
56992
56993
|
if (cachedCommands !== null) {
|
|
56993
56994
|
return cachedCommands;
|
|
@@ -56998,7 +56999,7 @@ async function getCustomCommands() {
|
|
|
56998
56999
|
function refreshCustomCommands() {
|
|
56999
57000
|
cachedCommands = null;
|
|
57000
57001
|
}
|
|
57001
|
-
async function discoverCustomCommands(projectPath =
|
|
57002
|
+
async function discoverCustomCommands(projectPath = join14(process.cwd(), COMMANDS_DIR)) {
|
|
57002
57003
|
const commandsById = new Map;
|
|
57003
57004
|
const userCommands = await discoverFromDirectory(GLOBAL_COMMANDS_DIR, "user");
|
|
57004
57005
|
for (const cmd of userCommands) {
|
|
@@ -57030,7 +57031,7 @@ async function findCommandFiles(currentPath, rootPath, commands2, source) {
|
|
|
57030
57031
|
try {
|
|
57031
57032
|
const entries = await readdir7(currentPath, { withFileTypes: true });
|
|
57032
57033
|
for (const entry of entries) {
|
|
57033
|
-
const fullPath =
|
|
57034
|
+
const fullPath = join14(currentPath, entry.name);
|
|
57034
57035
|
if (entry.isDirectory()) {
|
|
57035
57036
|
await findCommandFiles(fullPath, rootPath, commands2, source);
|
|
57036
57037
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -57047,7 +57048,7 @@ async function findCommandFiles(currentPath, rootPath, commands2, source) {
|
|
|
57047
57048
|
async function parseCommandFile(filePath, rootPath, source) {
|
|
57048
57049
|
const content = await readFile8(filePath, "utf-8");
|
|
57049
57050
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
57050
|
-
const id =
|
|
57051
|
+
const id = basename3(filePath, ".md");
|
|
57051
57052
|
const relativePath = dirname9(filePath).slice(rootPath.length);
|
|
57052
57053
|
const namespace = relativePath.replace(/^[/\\]/, "") || undefined;
|
|
57053
57054
|
let description = getStringField(frontmatter, "description");
|
|
@@ -57115,7 +57116,7 @@ async function findCustomCommand(commandName) {
|
|
|
57115
57116
|
}
|
|
57116
57117
|
var COMMANDS_DIR = ".commands", GLOBAL_COMMANDS_DIR, cachedCommands = null;
|
|
57117
57118
|
var init_custom = __esm(() => {
|
|
57118
|
-
GLOBAL_COMMANDS_DIR =
|
|
57119
|
+
GLOBAL_COMMANDS_DIR = join14(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
|
|
57119
57120
|
});
|
|
57120
57121
|
|
|
57121
57122
|
// src/cli/components/HelpDialog.tsx
|
|
@@ -60275,7 +60276,6 @@ function AgentInfoBar({
|
|
|
60275
60276
|
borderStyle: "round",
|
|
60276
60277
|
borderColor: colors.command.border,
|
|
60277
60278
|
paddingX: 1,
|
|
60278
|
-
marginBottom: 1,
|
|
60279
60279
|
children: [
|
|
60280
60280
|
/* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
|
|
60281
60281
|
children: [
|
|
@@ -60354,7 +60354,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
60354
60354
|
|
|
60355
60355
|
// src/cli/helpers/fileSearch.ts
|
|
60356
60356
|
import { readdirSync as readdirSync2, statSync as statSync2 } from "node:fs";
|
|
60357
|
-
import { join as
|
|
60357
|
+
import { join as join15, resolve as resolve17 } from "node:path";
|
|
60358
60358
|
function searchDirectoryRecursive(dir, pattern, maxResults = 200, results = []) {
|
|
60359
60359
|
if (results.length >= maxResults) {
|
|
60360
60360
|
return results;
|
|
@@ -60366,7 +60366,7 @@ function searchDirectoryRecursive(dir, pattern, maxResults = 200, results = [])
|
|
|
60366
60366
|
continue;
|
|
60367
60367
|
}
|
|
60368
60368
|
try {
|
|
60369
|
-
const fullPath =
|
|
60369
|
+
const fullPath = join15(dir, entry);
|
|
60370
60370
|
const stats = statSync2(fullPath);
|
|
60371
60371
|
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
60372
60372
|
const matches = pattern.length === 0 || relativePath.toLowerCase().includes(pattern.toLowerCase());
|
|
@@ -60418,7 +60418,7 @@ async function searchFiles(query, deep = false) {
|
|
|
60418
60418
|
const matchingEntries = searchPattern.length === 0 ? entries : entries.filter((entry) => entry.toLowerCase().includes(searchPattern.toLowerCase()));
|
|
60419
60419
|
for (const entry of matchingEntries.slice(0, 50)) {
|
|
60420
60420
|
try {
|
|
60421
|
-
const fullPath =
|
|
60421
|
+
const fullPath = join15(searchDir, entry);
|
|
60422
60422
|
const stats = statSync2(fullPath);
|
|
60423
60423
|
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
60424
60424
|
results.push({
|
|
@@ -60871,6 +60871,13 @@ function SlashCommandAutocomplete({
|
|
|
60871
60871
|
}, undefined, false, undefined, this)
|
|
60872
60872
|
}, undefined, false, undefined, this)
|
|
60873
60873
|
]
|
|
60874
|
+
}, undefined, true, undefined, this),
|
|
60875
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
60876
|
+
dimColor: true,
|
|
60877
|
+
children: [
|
|
60878
|
+
"Version: Letta Code v",
|
|
60879
|
+
getVersion()
|
|
60880
|
+
]
|
|
60874
60881
|
}, undefined, true, undefined, this)
|
|
60875
60882
|
]
|
|
60876
60883
|
}, undefined, true, undefined, this);
|
|
@@ -60878,6 +60885,7 @@ function SlashCommandAutocomplete({
|
|
|
60878
60885
|
var import_react43, jsx_dev_runtime22, VISIBLE_COMMANDS = 8, _allCommands;
|
|
60879
60886
|
var init_SlashCommandAutocomplete = __esm(async () => {
|
|
60880
60887
|
init_settings_manager();
|
|
60888
|
+
init_version();
|
|
60881
60889
|
init_registry();
|
|
60882
60890
|
init_colors();
|
|
60883
60891
|
await __promiseAll([
|
|
@@ -61572,13 +61580,19 @@ function Input({
|
|
|
61572
61580
|
]
|
|
61573
61581
|
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime26.jsxDEV(Text, {
|
|
61574
61582
|
dimColor: true,
|
|
61575
|
-
children: "Press / for commands
|
|
61583
|
+
children: "Press / for commands"
|
|
61576
61584
|
}, undefined, false, undefined, this),
|
|
61577
61585
|
/* @__PURE__ */ jsx_dev_runtime26.jsxDEV(Text, {
|
|
61578
|
-
dimColor: true,
|
|
61579
61586
|
children: [
|
|
61580
|
-
|
|
61581
|
-
|
|
61587
|
+
/* @__PURE__ */ jsx_dev_runtime26.jsxDEV(Text, {
|
|
61588
|
+
color: colors.footer.agentName,
|
|
61589
|
+
children: agentName || "Unnamed"
|
|
61590
|
+
}, undefined, false, undefined, this),
|
|
61591
|
+
/* @__PURE__ */ jsx_dev_runtime26.jsxDEV(Text, {
|
|
61592
|
+
dimColor: currentModelProvider !== ANTHROPIC_PROVIDER_NAME,
|
|
61593
|
+
color: currentModelProvider === ANTHROPIC_PROVIDER_NAME ? "#FFC787" : undefined,
|
|
61594
|
+
children: ` [${currentModel ?? "unknown"}]`
|
|
61595
|
+
}, undefined, false, undefined, this)
|
|
61582
61596
|
]
|
|
61583
61597
|
}, undefined, true, undefined, this)
|
|
61584
61598
|
]
|
|
@@ -61588,7 +61602,7 @@ function Input({
|
|
|
61588
61602
|
]
|
|
61589
61603
|
}, undefined, true, undefined, this);
|
|
61590
61604
|
}
|
|
61591
|
-
var import_react46, jsx_dev_runtime26, Spinner2,
|
|
61605
|
+
var import_react46, jsx_dev_runtime26, Spinner2, ESC_CLEAR_WINDOW_MS = 2500;
|
|
61592
61606
|
var init_InputRich = __esm(async () => {
|
|
61593
61607
|
init_source();
|
|
61594
61608
|
init_oauth();
|
|
@@ -61596,7 +61610,6 @@ var init_InputRich = __esm(async () => {
|
|
|
61596
61610
|
init_mode();
|
|
61597
61611
|
init_anthropic_provider();
|
|
61598
61612
|
init_settings_manager();
|
|
61599
|
-
init_version();
|
|
61600
61613
|
init_useTerminalWidth();
|
|
61601
61614
|
init_colors();
|
|
61602
61615
|
await __promiseAll([
|
|
@@ -61610,7 +61623,6 @@ var init_InputRich = __esm(async () => {
|
|
|
61610
61623
|
import_react46 = __toESM(require_react(), 1);
|
|
61611
61624
|
jsx_dev_runtime26 = __toESM(require_jsx_dev_runtime(), 1);
|
|
61612
61625
|
Spinner2 = build_default2;
|
|
61613
|
-
appVersion = getVersion();
|
|
61614
61626
|
stdin.setMaxListeners(20);
|
|
61615
61627
|
EventEmitter4.defaultMaxListeners = 20;
|
|
61616
61628
|
});
|
|
@@ -62999,9 +63011,10 @@ function ModelSelector({
|
|
|
62999
63011
|
const supportedModels = import_react50.useMemo(() => {
|
|
63000
63012
|
if (availableHandles === undefined)
|
|
63001
63013
|
return [];
|
|
63002
|
-
|
|
63003
|
-
|
|
63004
|
-
|
|
63014
|
+
const available = availableHandles === null ? typedModels : typedModels.filter((m) => availableHandles.has(m.handle));
|
|
63015
|
+
const featured = available.filter((m) => m.isFeatured);
|
|
63016
|
+
const nonFeatured = available.filter((m) => !m.isFeatured);
|
|
63017
|
+
return [...featured, ...nonFeatured];
|
|
63005
63018
|
}, [typedModels, availableHandles]);
|
|
63006
63019
|
const otherModelHandles = import_react50.useMemo(() => {
|
|
63007
63020
|
const filtered = allApiHandles.filter((handle) => !staticModelHandles.has(handle));
|
|
@@ -63113,7 +63126,7 @@ function ModelSelector({
|
|
|
63113
63126
|
}, { isActive: true });
|
|
63114
63127
|
const getCategoryLabel = (cat) => {
|
|
63115
63128
|
if (cat === "supported")
|
|
63116
|
-
return `
|
|
63129
|
+
return `Recommended (${supportedModels.length})`;
|
|
63117
63130
|
return `All Available Models (${otherModelHandles.length})`;
|
|
63118
63131
|
};
|
|
63119
63132
|
return /* @__PURE__ */ jsx_dev_runtime30.jsxDEV(Box_default, {
|
|
@@ -63142,6 +63155,7 @@ function ModelSelector({
|
|
|
63142
63155
|
}, undefined, false, undefined, this),
|
|
63143
63156
|
/* @__PURE__ */ jsx_dev_runtime30.jsxDEV(Text, {
|
|
63144
63157
|
bold: cat === category,
|
|
63158
|
+
dimColor: cat !== category,
|
|
63145
63159
|
color: cat === category ? colors.selector.itemHighlighted : undefined,
|
|
63146
63160
|
children: getCategoryLabel(cat)
|
|
63147
63161
|
}, undefined, false, undefined, this)
|
|
@@ -63220,11 +63234,10 @@ function ModelSelector({
|
|
|
63220
63234
|
children: [
|
|
63221
63235
|
/* @__PURE__ */ jsx_dev_runtime30.jsxDEV(Text, {
|
|
63222
63236
|
bold: isSelected,
|
|
63223
|
-
color: isSelected ? colors.selector.itemHighlighted : undefined,
|
|
63237
|
+
color: isSelected ? colors.selector.itemHighlighted : isCurrent ? colors.selector.itemCurrent : undefined,
|
|
63224
63238
|
children: [
|
|
63225
63239
|
model.label,
|
|
63226
63240
|
isCurrent && /* @__PURE__ */ jsx_dev_runtime30.jsxDEV(Text, {
|
|
63227
|
-
color: colors.selector.itemCurrent,
|
|
63228
63241
|
children: " (current)"
|
|
63229
63242
|
}, undefined, false, undefined, this)
|
|
63230
63243
|
]
|
|
@@ -68639,7 +68652,7 @@ function App2({
|
|
|
68639
68652
|
const [agentDescription, setAgentDescription] = import_react69.useState(null);
|
|
68640
68653
|
const [agentLastRunAt, setAgentLastRunAt] = import_react69.useState(null);
|
|
68641
68654
|
const currentModelLabel = llmConfig?.model_endpoint_type && llmConfig?.model ? `${llmConfig.model_endpoint_type}/${llmConfig.model}` : llmConfig?.model ?? null;
|
|
68642
|
-
const currentModelDisplay = currentModelLabel
|
|
68655
|
+
const currentModelDisplay = currentModelLabel ? getModelDisplayName(currentModelLabel) ?? currentModelLabel.split("/").pop() : null;
|
|
68643
68656
|
const currentModelProvider = llmConfig?.provider_name ?? null;
|
|
68644
68657
|
const [tokenStreamingEnabled, setTokenStreamingEnabled] = import_react69.useState(tokenStreaming);
|
|
68645
68658
|
const [tokenCount, setTokenCount] = import_react69.useState(0);
|
|
@@ -68840,6 +68853,13 @@ function App2({
|
|
|
68840
68853
|
setAgentDescription(agent.description ?? null);
|
|
68841
68854
|
const lastRunCompletion = agent.last_run_completion;
|
|
68842
68855
|
setAgentLastRunAt(lastRunCompletion ?? null);
|
|
68856
|
+
const agentModelHandle = agent.llm_config.model_endpoint_type && agent.llm_config.model ? `${agent.llm_config.model_endpoint_type}/${agent.llm_config.model}` : agent.llm_config.model;
|
|
68857
|
+
const modelInfo = getModelInfo(agentModelHandle || "");
|
|
68858
|
+
if (modelInfo) {
|
|
68859
|
+
setCurrentModelId(modelInfo.id);
|
|
68860
|
+
} else {
|
|
68861
|
+
setCurrentModelId(agentModelHandle || null);
|
|
68862
|
+
}
|
|
68843
68863
|
const { detectToolsetFromAgent: detectToolsetFromAgent2 } = await Promise.resolve().then(() => (init_toolset(), exports_toolset));
|
|
68844
68864
|
const detected = await detectToolsetFromAgent2(client, agentId);
|
|
68845
68865
|
if (detected) {
|
|
@@ -72200,6 +72220,7 @@ var init_App2 = __esm(async () => {
|
|
|
72200
72220
|
init_context();
|
|
72201
72221
|
init_create();
|
|
72202
72222
|
init_message();
|
|
72223
|
+
init_model();
|
|
72203
72224
|
init_mode();
|
|
72204
72225
|
init_settings();
|
|
72205
72226
|
init_settings_manager();
|
|
@@ -72664,7 +72685,7 @@ var exports_create = {};
|
|
|
72664
72685
|
__export(exports_create, {
|
|
72665
72686
|
createAgent: () => createAgent2
|
|
72666
72687
|
});
|
|
72667
|
-
import { join as
|
|
72688
|
+
import { join as join16 } from "node:path";
|
|
72668
72689
|
async function createAgent2(name = DEFAULT_AGENT_NAME, model, embeddingModel = "openai/text-embedding-3-small", updateArgs, skillsDirectory, parallelToolCalls = true, enableSleeptime = false, systemPromptId, initBlocks, baseTools) {
|
|
72669
72690
|
let modelHandle;
|
|
72670
72691
|
if (model) {
|
|
@@ -72716,7 +72737,7 @@ async function createAgent2(name = DEFAULT_AGENT_NAME, model, embeddingModel = "
|
|
|
72716
72737
|
}
|
|
72717
72738
|
}
|
|
72718
72739
|
const filteredMemoryBlocks = allowedBlockLabels && allowedBlockLabels.size > 0 ? defaultMemoryBlocks.filter((b) => allowedBlockLabels.has(b.label)) : defaultMemoryBlocks;
|
|
72719
|
-
const resolvedSkillsDirectory = skillsDirectory ||
|
|
72740
|
+
const resolvedSkillsDirectory = skillsDirectory || join16(process.cwd(), SKILLS_DIR);
|
|
72720
72741
|
try {
|
|
72721
72742
|
const { skills, errors } = await discoverSkills(resolvedSkillsDirectory);
|
|
72722
72743
|
if (errors.length > 0) {
|
|
@@ -72820,6 +72841,7 @@ __export(exports_model2, {
|
|
|
72820
72841
|
models: () => models2,
|
|
72821
72842
|
getModelUpdateArgs: () => getModelUpdateArgs2,
|
|
72822
72843
|
getModelInfo: () => getModelInfo2,
|
|
72844
|
+
getModelDisplayName: () => getModelDisplayName2,
|
|
72823
72845
|
getDefaultModel: () => getDefaultModel2,
|
|
72824
72846
|
formatAvailableModels: () => formatAvailableModels2
|
|
72825
72847
|
});
|
|
@@ -72861,6 +72883,10 @@ function getModelUpdateArgs2(modelIdentifier) {
|
|
|
72861
72883
|
const modelInfo = getModelInfo2(modelIdentifier);
|
|
72862
72884
|
return modelInfo?.updateArgs;
|
|
72863
72885
|
}
|
|
72886
|
+
function getModelDisplayName2(handle) {
|
|
72887
|
+
const model = models2.find((m) => m.handle === handle);
|
|
72888
|
+
return model?.label ?? null;
|
|
72889
|
+
}
|
|
72864
72890
|
function resolveModelByLlmConfig2(llmConfigModel) {
|
|
72865
72891
|
const match3 = models2.find((m) => m.handle.endsWith(`/${llmConfigModel}`));
|
|
72866
72892
|
if (match3)
|
|
@@ -74187,12 +74213,12 @@ EXAMPLES
|
|
|
74187
74213
|
console.log(usage);
|
|
74188
74214
|
}
|
|
74189
74215
|
async function printInfo() {
|
|
74190
|
-
const { join:
|
|
74216
|
+
const { join: join17 } = await import("path");
|
|
74191
74217
|
const { getVersion: getVersion3 } = await Promise.resolve().then(() => (init_version2(), exports_version));
|
|
74192
74218
|
const { SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills3(), exports_skills2));
|
|
74193
74219
|
const { exists: exists3 } = await Promise.resolve().then(() => (init_fs2(), exports_fs));
|
|
74194
74220
|
const cwd2 = process.cwd();
|
|
74195
|
-
const skillsDir =
|
|
74221
|
+
const skillsDir = join17(cwd2, SKILLS_DIR3);
|
|
74196
74222
|
const skillsExist = exists3(skillsDir);
|
|
74197
74223
|
await settingsManager2.loadLocalProjectSettings(cwd2);
|
|
74198
74224
|
const localPinned = settingsManager2.getLocalPinnedAgents(cwd2);
|
|
@@ -74731,8 +74757,8 @@ Error: ${message}`);
|
|
|
74731
74757
|
await initializeLoadedSkillsFlag();
|
|
74732
74758
|
try {
|
|
74733
74759
|
const { discoverSkills: discoverSkills3, formatSkillsForMemory: formatSkillsForMemory3, SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills3(), exports_skills2));
|
|
74734
|
-
const { join:
|
|
74735
|
-
const resolvedSkillsDirectory = skillsDirectory2 ||
|
|
74760
|
+
const { join: join17 } = await import("path");
|
|
74761
|
+
const resolvedSkillsDirectory = skillsDirectory2 || join17(process.cwd(), SKILLS_DIR3);
|
|
74736
74762
|
const { skills, errors } = await discoverSkills3(resolvedSkillsDirectory);
|
|
74737
74763
|
if (errors.length > 0) {
|
|
74738
74764
|
console.warn("Errors encountered during skill discovery:");
|
|
@@ -74871,4 +74897,4 @@ Error during initialization: ${message}`);
|
|
|
74871
74897
|
}
|
|
74872
74898
|
main();
|
|
74873
74899
|
|
|
74874
|
-
//# debugId=
|
|
74900
|
+
//# debugId=8134ECE87ABE785364756E2164756E21
|