@orbit-build/cli 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.js +1743 -583
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21006,11 +21006,11 @@ ${lanes.join("\n")}
|
|
|
21006
21006
|
let hasReadNonFileDiagnostics = false;
|
|
21007
21007
|
return {
|
|
21008
21008
|
add,
|
|
21009
|
-
lookup,
|
|
21009
|
+
lookup: lookup2,
|
|
21010
21010
|
getGlobalDiagnostics,
|
|
21011
21011
|
getDiagnostics: getDiagnostics2
|
|
21012
21012
|
};
|
|
21013
|
-
function
|
|
21013
|
+
function lookup2(diagnostic) {
|
|
21014
21014
|
let diagnostics;
|
|
21015
21015
|
if (diagnostic.file) {
|
|
21016
21016
|
diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
|
|
@@ -24801,7 +24801,7 @@ ${lanes.join("\n")}
|
|
|
24801
24801
|
error: error2,
|
|
24802
24802
|
getSymbolOfDeclaration,
|
|
24803
24803
|
globals,
|
|
24804
|
-
lookup,
|
|
24804
|
+
lookup: lookup2,
|
|
24805
24805
|
setRequiresScopeChangeCache = returnUndefined,
|
|
24806
24806
|
getRequiresScopeChangeCache = returnUndefined,
|
|
24807
24807
|
onPropertyWithInvalidInitializer = returnFalse,
|
|
@@ -24833,7 +24833,7 @@ ${lanes.join("\n")}
|
|
|
24833
24833
|
location = location.parent;
|
|
24834
24834
|
}
|
|
24835
24835
|
if (canHaveLocals(location) && location.locals && !isGlobalSourceFile(location)) {
|
|
24836
|
-
if (result =
|
|
24836
|
+
if (result = lookup2(location.locals, name, meaning)) {
|
|
24837
24837
|
let useResult = true;
|
|
24838
24838
|
if (isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
|
|
24839
24839
|
if (meaning & result.flags & 788968 && lastLocation.kind !== 321) {
|
|
@@ -24889,7 +24889,7 @@ ${lanes.join("\n")}
|
|
|
24889
24889
|
break;
|
|
24890
24890
|
}
|
|
24891
24891
|
}
|
|
24892
|
-
if (name !== "default" && (result =
|
|
24892
|
+
if (name !== "default" && (result = lookup2(
|
|
24893
24893
|
moduleExports,
|
|
24894
24894
|
name,
|
|
24895
24895
|
meaning & 2623475
|
|
@@ -24903,7 +24903,7 @@ ${lanes.join("\n")}
|
|
|
24903
24903
|
}
|
|
24904
24904
|
break;
|
|
24905
24905
|
case 267:
|
|
24906
|
-
if (result =
|
|
24906
|
+
if (result = lookup2(
|
|
24907
24907
|
((_c = getSymbolOfDeclaration(location)) == null ? void 0 : _c.exports) || emptySymbols,
|
|
24908
24908
|
name,
|
|
24909
24909
|
meaning & 8
|
|
@@ -24925,7 +24925,7 @@ ${lanes.join("\n")}
|
|
|
24925
24925
|
if (!isStatic(location)) {
|
|
24926
24926
|
const ctor = findConstructorDeclaration(location.parent);
|
|
24927
24927
|
if (ctor && ctor.locals) {
|
|
24928
|
-
if (
|
|
24928
|
+
if (lookup2(
|
|
24929
24929
|
ctor.locals,
|
|
24930
24930
|
name,
|
|
24931
24931
|
meaning & 111551
|
|
@@ -24940,7 +24940,7 @@ ${lanes.join("\n")}
|
|
|
24940
24940
|
case 264:
|
|
24941
24941
|
case 232:
|
|
24942
24942
|
case 265:
|
|
24943
|
-
if (result =
|
|
24943
|
+
if (result = lookup2(
|
|
24944
24944
|
getSymbolOfDeclaration(location).members || emptySymbols,
|
|
24945
24945
|
name,
|
|
24946
24946
|
meaning & 788968
|
|
@@ -24969,7 +24969,7 @@ ${lanes.join("\n")}
|
|
|
24969
24969
|
case 234:
|
|
24970
24970
|
if (lastLocation === location.expression && location.parent.token === 96) {
|
|
24971
24971
|
const container = location.parent.parent;
|
|
24972
|
-
if (isClassLike(container) && (result =
|
|
24972
|
+
if (isClassLike(container) && (result = lookup2(
|
|
24973
24973
|
getSymbolOfDeclaration(container).members,
|
|
24974
24974
|
name,
|
|
24975
24975
|
meaning & 788968
|
|
@@ -24993,7 +24993,7 @@ ${lanes.join("\n")}
|
|
|
24993
24993
|
case 168:
|
|
24994
24994
|
grandparent = location.parent.parent;
|
|
24995
24995
|
if (isClassLike(grandparent) || grandparent.kind === 265) {
|
|
24996
|
-
if (result =
|
|
24996
|
+
if (result = lookup2(
|
|
24997
24997
|
getSymbolOfDeclaration(grandparent).members,
|
|
24998
24998
|
name,
|
|
24999
24999
|
meaning & 788968
|
|
@@ -25097,7 +25097,7 @@ ${lanes.join("\n")}
|
|
|
25097
25097
|
}
|
|
25098
25098
|
}
|
|
25099
25099
|
if (!excludeGlobals) {
|
|
25100
|
-
result =
|
|
25100
|
+
result = lookup2(globals, name, meaning);
|
|
25101
25101
|
}
|
|
25102
25102
|
}
|
|
25103
25103
|
if (!result) {
|
|
@@ -50127,14 +50127,14 @@ ${lanes.join("\n")}
|
|
|
50127
50127
|
const secondaryExtensions = extensions & ~(1 | 4);
|
|
50128
50128
|
if (priorityExtensions) {
|
|
50129
50129
|
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_preferred_extensions_Colon_0, formatExtensions(priorityExtensions));
|
|
50130
|
-
const result =
|
|
50130
|
+
const result = lookup2(priorityExtensions);
|
|
50131
50131
|
if (result) return result;
|
|
50132
50132
|
}
|
|
50133
50133
|
if (secondaryExtensions && !typesScopeOnly) {
|
|
50134
50134
|
traceIfEnabled(state, Diagnostics.Searching_all_ancestor_node_modules_directories_for_fallback_extensions_Colon_0, formatExtensions(secondaryExtensions));
|
|
50135
|
-
return
|
|
50135
|
+
return lookup2(secondaryExtensions);
|
|
50136
50136
|
}
|
|
50137
|
-
function
|
|
50137
|
+
function lookup2(extensions2) {
|
|
50138
50138
|
return forEachAncestorDirectoryStoppingAtGlobalCache(
|
|
50139
50139
|
state.host,
|
|
50140
50140
|
normalizeSlashes(directory),
|
|
@@ -217863,7 +217863,7 @@ var DeepSeekAnthropicProvider = class {
|
|
|
217863
217863
|
tools = input.tools?.map((tool) => ({
|
|
217864
217864
|
name: tool.name,
|
|
217865
217865
|
description: tool.description,
|
|
217866
|
-
input_schema: zodToJsonSchema(tool.inputSchema)
|
|
217866
|
+
input_schema: tool.inputJsonSchema ?? zodToJsonSchema(tool.inputSchema)
|
|
217867
217867
|
}));
|
|
217868
217868
|
maxTokens = normalizeAnthropicMaxTokens(
|
|
217869
217869
|
input.maxTokens,
|
|
@@ -218744,7 +218744,7 @@ var DeepSeekOpenAIProvider = class {
|
|
|
218744
218744
|
function: {
|
|
218745
218745
|
name: tool.name,
|
|
218746
218746
|
description: tool.description,
|
|
218747
|
-
parameters: zodToJsonSchema(tool.inputSchema)
|
|
218747
|
+
parameters: tool.inputJsonSchema ?? zodToJsonSchema(tool.inputSchema)
|
|
218748
218748
|
}
|
|
218749
218749
|
}));
|
|
218750
218750
|
} catch (error) {
|
|
@@ -221009,10 +221009,10 @@ import {
|
|
|
221009
221009
|
renameSync as renameSync7,
|
|
221010
221010
|
writeFileSync as writeFileSync9
|
|
221011
221011
|
} from "fs";
|
|
221012
|
-
import { createHash as
|
|
221012
|
+
import { createHash as createHash6 } from "crypto";
|
|
221013
221013
|
import { dirname as dirname6, join as join12 } from "path";
|
|
221014
|
-
import { z as
|
|
221015
|
-
import { z as
|
|
221014
|
+
import { z as z29 } from "zod";
|
|
221015
|
+
import { z as z210 } from "zod";
|
|
221016
221016
|
|
|
221017
221017
|
// ../tools/dist/index.js
|
|
221018
221018
|
import { z as z13 } from "zod";
|
|
@@ -222635,8 +222635,12 @@ import glob4 from "fast-glob";
|
|
|
222635
222635
|
import { z as z15 } from "zod";
|
|
222636
222636
|
import { existsSync as existsSync32, readFileSync as readFileSync62 } from "fs";
|
|
222637
222637
|
import { z as z16 } from "zod";
|
|
222638
|
+
import { lookup } from "dns/promises";
|
|
222639
|
+
import { isIP } from "net";
|
|
222638
222640
|
import { z as z17 } from "zod";
|
|
222641
|
+
import { z as z18 } from "zod";
|
|
222639
222642
|
import { existsSync as existsSync42, readFileSync as readFileSync72, statSync } from "fs";
|
|
222643
|
+
import { z as z19 } from "zod";
|
|
222640
222644
|
var ToolRegistry = class {
|
|
222641
222645
|
tools = /* @__PURE__ */ new Map();
|
|
222642
222646
|
register(tool) {
|
|
@@ -222655,19 +222659,20 @@ var ToolRegistry = class {
|
|
|
222655
222659
|
return this.list().map((t) => ({
|
|
222656
222660
|
name: t.name,
|
|
222657
222661
|
description: t.description,
|
|
222658
|
-
inputSchema: t.inputSchema
|
|
222662
|
+
inputSchema: t.inputSchema,
|
|
222663
|
+
inputJsonSchema: t.inputJsonSchema
|
|
222659
222664
|
}));
|
|
222660
222665
|
}
|
|
222661
222666
|
};
|
|
222662
222667
|
var toolRegistry = new ToolRegistry();
|
|
222663
222668
|
var ReadFileInputSchema = z13.object({
|
|
222664
|
-
path: z13.string(),
|
|
222665
|
-
startLine: z13.number().optional(),
|
|
222666
|
-
endLine: z13.number().optional()
|
|
222669
|
+
path: z13.string().min(1).max(4096),
|
|
222670
|
+
startLine: z13.number().int().positive().optional(),
|
|
222671
|
+
endLine: z13.number().int().positive().optional()
|
|
222667
222672
|
});
|
|
222668
222673
|
var ReadFileTool = class {
|
|
222669
222674
|
name = "read_file";
|
|
222670
|
-
description = "Read content from a file inside the project. Defaults to
|
|
222675
|
+
description = "Read content from a file inside the project. Defaults to at most 400 lines and bounds oversized output for the model context.";
|
|
222671
222676
|
inputSchema = ReadFileInputSchema;
|
|
222672
222677
|
risk = "read";
|
|
222673
222678
|
async execute(input, ctx) {
|
|
@@ -222678,23 +222683,25 @@ var ReadFileTool = class {
|
|
|
222678
222683
|
const start = input.startLine !== void 0 ? Math.max(1, input.startLine) : 1;
|
|
222679
222684
|
const end = input.endLine !== void 0 ? Math.min(lines.length, input.endLine) : Math.min(lines.length, start + 399);
|
|
222680
222685
|
const slicedLines = lines.slice(start - 1, end);
|
|
222681
|
-
const
|
|
222686
|
+
const rawDisplayContent = slicedLines.join("\n");
|
|
222687
|
+
const displayContent = rawDisplayContent.length > 12e4 ? `${rawDisplayContent.slice(0, 119940)}
|
|
222688
|
+
... [truncated by read_file]` : rawDisplayContent;
|
|
222682
222689
|
return {
|
|
222683
222690
|
ok: true,
|
|
222684
222691
|
data: displayContent,
|
|
222685
222692
|
display: `Read lines ${start}-${end} of ${input.path}`
|
|
222686
222693
|
};
|
|
222687
|
-
} catch (
|
|
222694
|
+
} catch (error) {
|
|
222688
222695
|
return {
|
|
222689
222696
|
ok: false,
|
|
222690
|
-
error:
|
|
222697
|
+
error: error instanceof Error ? error.message : String(error)
|
|
222691
222698
|
};
|
|
222692
222699
|
}
|
|
222693
222700
|
}
|
|
222694
222701
|
};
|
|
222695
222702
|
var WriteFileInputSchema = z23.object({
|
|
222696
|
-
path: z23.string(),
|
|
222697
|
-
content: z23.string()
|
|
222703
|
+
path: z23.string().trim().min(1).max(4096),
|
|
222704
|
+
content: z23.string().max(5e6)
|
|
222698
222705
|
});
|
|
222699
222706
|
var WriteFileTool = class {
|
|
222700
222707
|
name = "write_file";
|
|
@@ -222710,10 +222717,10 @@ var WriteFileTool = class {
|
|
|
222710
222717
|
ok: true,
|
|
222711
222718
|
display: `Wrote file to ${input.path}`
|
|
222712
222719
|
};
|
|
222713
|
-
} catch (
|
|
222720
|
+
} catch (error) {
|
|
222714
222721
|
return {
|
|
222715
222722
|
ok: false,
|
|
222716
|
-
error:
|
|
222723
|
+
error: error instanceof Error ? error.message : String(error)
|
|
222717
222724
|
};
|
|
222718
222725
|
}
|
|
222719
222726
|
}
|
|
@@ -222766,6 +222773,7 @@ var EditFileTool = class {
|
|
|
222766
222773
|
const N2 = fileLines.length;
|
|
222767
222774
|
let matchedIndex = null;
|
|
222768
222775
|
let occurrences = 0;
|
|
222776
|
+
const matchedIndices = [];
|
|
222769
222777
|
if (M3 > 0 && N2 >= M3) {
|
|
222770
222778
|
for (let i = 0; i <= N2 - M3; i++) {
|
|
222771
222779
|
let match = true;
|
|
@@ -222778,6 +222786,7 @@ var EditFileTool = class {
|
|
|
222778
222786
|
if (match) {
|
|
222779
222787
|
occurrences++;
|
|
222780
222788
|
matchedIndex = i;
|
|
222789
|
+
matchedIndices.push(i);
|
|
222781
222790
|
}
|
|
222782
222791
|
}
|
|
222783
222792
|
}
|
|
@@ -222811,6 +222820,28 @@ var EditFileTool = class {
|
|
|
222811
222820
|
error: `Found multiple whitespace-insensitive occurrences of oldText in "${input.path}". Please provide more surrounding lines.`
|
|
222812
222821
|
};
|
|
222813
222822
|
}
|
|
222823
|
+
if (occurrences > 1 && input.replaceAll) {
|
|
222824
|
+
for (const index of matchedIndices.reverse()) {
|
|
222825
|
+
const matchedFileLines = fileLines.slice(index, index + M3);
|
|
222826
|
+
const adjustedNewLines = adjustIndentation(
|
|
222827
|
+
newLines,
|
|
222828
|
+
matchedFileLines,
|
|
222829
|
+
oldLines
|
|
222830
|
+
);
|
|
222831
|
+
fileLines.splice(index, M3, ...adjustedNewLines);
|
|
222832
|
+
}
|
|
222833
|
+
const writeError = await this.checkAndWrite(
|
|
222834
|
+
input.path,
|
|
222835
|
+
safePath,
|
|
222836
|
+
fileLines.join("\n"),
|
|
222837
|
+
originalContent
|
|
222838
|
+
);
|
|
222839
|
+
if (writeError) return writeError;
|
|
222840
|
+
return {
|
|
222841
|
+
ok: true,
|
|
222842
|
+
display: `Successfully replaced ${occurrences} whitespace-insensitive matches in ${input.path}`
|
|
222843
|
+
};
|
|
222844
|
+
}
|
|
222814
222845
|
if (M3 > 0 && N2 >= M3) {
|
|
222815
222846
|
let bestIndex = -1;
|
|
222816
222847
|
let bestSim = 0;
|
|
@@ -223223,12 +223254,13 @@ ${oldText}
|
|
|
223223
223254
|
return null;
|
|
223224
223255
|
}
|
|
223225
223256
|
var ListFilesInputSchema = z42.object({
|
|
223226
|
-
path: z42.string().optional(),
|
|
223227
|
-
depth: z42.number().optional()
|
|
223257
|
+
path: z42.string().max(4096).optional(),
|
|
223258
|
+
depth: z42.number().int().min(1).max(100).optional(),
|
|
223259
|
+
maxResults: z42.number().int().min(1).max(5e3).optional()
|
|
223228
223260
|
});
|
|
223229
223261
|
var ListFilesTool = class {
|
|
223230
223262
|
name = "list_files";
|
|
223231
|
-
description = "List
|
|
223263
|
+
description = "List files recursively in the project directory with bounded depth/results, ignoring dependencies and build output folders.";
|
|
223232
223264
|
inputSchema = ListFilesInputSchema;
|
|
223233
223265
|
risk = "read";
|
|
223234
223266
|
async execute(input, ctx) {
|
|
@@ -223247,25 +223279,28 @@ var ListFilesTool = class {
|
|
|
223247
223279
|
dot: true,
|
|
223248
223280
|
suppressErrors: true
|
|
223249
223281
|
});
|
|
223282
|
+
const maxResults = input.maxResults ?? 1e3;
|
|
223283
|
+
const boundedFiles = files.slice(0, maxResults);
|
|
223250
223284
|
return {
|
|
223251
223285
|
ok: true,
|
|
223252
|
-
data:
|
|
223253
|
-
display: `Listed ${files.length} files in ${input.path || "project root"}`
|
|
223286
|
+
data: boundedFiles,
|
|
223287
|
+
display: `Listed ${boundedFiles.length}${files.length > boundedFiles.length ? ` of ${files.length}` : ""} files in ${input.path || "project root"}`
|
|
223254
223288
|
};
|
|
223255
|
-
} catch (
|
|
223289
|
+
} catch (error) {
|
|
223256
223290
|
return {
|
|
223257
223291
|
ok: false,
|
|
223258
|
-
error:
|
|
223292
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223259
223293
|
};
|
|
223260
223294
|
}
|
|
223261
223295
|
}
|
|
223262
223296
|
};
|
|
223263
223297
|
var GlobInputSchema = z52.object({
|
|
223264
|
-
pattern: z52.string()
|
|
223298
|
+
pattern: z52.string().min(1).max(4096),
|
|
223299
|
+
maxResults: z52.number().int().min(1).max(5e3).optional()
|
|
223265
223300
|
});
|
|
223266
223301
|
var GlobTool = class {
|
|
223267
223302
|
name = "glob";
|
|
223268
|
-
description = "Find files matching a glob pattern inside the project workspace.";
|
|
223303
|
+
description = "Find files matching a glob pattern inside the project workspace, with a configurable bounded result count.";
|
|
223269
223304
|
inputSchema = GlobInputSchema;
|
|
223270
223305
|
risk = "read";
|
|
223271
223306
|
async execute(input, ctx) {
|
|
@@ -223282,24 +223317,26 @@ var GlobTool = class {
|
|
|
223282
223317
|
dot: true,
|
|
223283
223318
|
suppressErrors: true
|
|
223284
223319
|
});
|
|
223320
|
+
const maxResults = input.maxResults ?? 500;
|
|
223321
|
+
const boundedFiles = files.slice(0, maxResults);
|
|
223285
223322
|
return {
|
|
223286
223323
|
ok: true,
|
|
223287
|
-
data:
|
|
223288
|
-
display: `Glob matches for "${input.pattern}":
|
|
223324
|
+
data: boundedFiles,
|
|
223325
|
+
display: `Glob matches for "${input.pattern}": returned ${boundedFiles.length}${files.length > boundedFiles.length ? ` of ${files.length}` : ""} files`
|
|
223289
223326
|
};
|
|
223290
|
-
} catch (
|
|
223327
|
+
} catch (error) {
|
|
223291
223328
|
return {
|
|
223292
223329
|
ok: false,
|
|
223293
|
-
error:
|
|
223330
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223294
223331
|
};
|
|
223295
223332
|
}
|
|
223296
223333
|
}
|
|
223297
223334
|
};
|
|
223298
223335
|
var GrepInputSchema = z62.object({
|
|
223299
|
-
pattern: z62.string(),
|
|
223300
|
-
path: z62.string().optional(),
|
|
223301
|
-
include: z62.string().optional(),
|
|
223302
|
-
maxResults: z62.number().optional()
|
|
223336
|
+
pattern: z62.string().min(1).max(4096),
|
|
223337
|
+
path: z62.string().max(4096).optional(),
|
|
223338
|
+
include: z62.string().max(4096).optional(),
|
|
223339
|
+
maxResults: z62.number().int().min(1).max(1e3).optional()
|
|
223303
223340
|
});
|
|
223304
223341
|
var GrepTool = class {
|
|
223305
223342
|
name = "grep";
|
|
@@ -223307,7 +223344,7 @@ var GrepTool = class {
|
|
|
223307
223344
|
inputSchema = GrepInputSchema;
|
|
223308
223345
|
risk = "read";
|
|
223309
223346
|
async execute(input, ctx) {
|
|
223310
|
-
const max = input.maxResults
|
|
223347
|
+
const max = input.maxResults ?? 100;
|
|
223311
223348
|
const searchDir = input.path ? resolveSafePath(ctx.cwd, input.path) : ctx.cwd;
|
|
223312
223349
|
try {
|
|
223313
223350
|
const args = [
|
|
@@ -223320,7 +223357,15 @@ var GrepTool = class {
|
|
|
223320
223357
|
args.push("--glob", input.include);
|
|
223321
223358
|
}
|
|
223322
223359
|
args.push(searchDir);
|
|
223323
|
-
const
|
|
223360
|
+
const result = await execa("rg", args, {
|
|
223361
|
+
reject: false,
|
|
223362
|
+
signal: ctx.abortSignal,
|
|
223363
|
+
maxBuffer: 2 * 1024 * 1024
|
|
223364
|
+
});
|
|
223365
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) {
|
|
223366
|
+
throw new Error(result.stderr || `ripgrep exited ${result.exitCode}`);
|
|
223367
|
+
}
|
|
223368
|
+
const stdout = result.stdout;
|
|
223324
223369
|
const matches = [];
|
|
223325
223370
|
const lines = stdout.split("\n");
|
|
223326
223371
|
for (const line of lines) {
|
|
@@ -223345,10 +223390,13 @@ var GrepTool = class {
|
|
|
223345
223390
|
display: `Grep for "${input.pattern}" using ripgrep: found ${matches.length} matches`
|
|
223346
223391
|
};
|
|
223347
223392
|
} catch {
|
|
223348
|
-
|
|
223393
|
+
if (ctx.abortSignal?.aborted) {
|
|
223394
|
+
return { ok: false, error: "Grep was cancelled by the user." };
|
|
223395
|
+
}
|
|
223396
|
+
return this.jsFallback(input, searchDir, ctx.cwd, max, ctx.abortSignal);
|
|
223349
223397
|
}
|
|
223350
223398
|
}
|
|
223351
|
-
async jsFallback(input, searchDir, cwd, max) {
|
|
223399
|
+
async jsFallback(input, searchDir, cwd, max, abortSignal) {
|
|
223352
223400
|
try {
|
|
223353
223401
|
const globPattern = input.include || "**/*";
|
|
223354
223402
|
const files = await glob3(globPattern, {
|
|
@@ -223365,6 +223413,9 @@ var GrepTool = class {
|
|
|
223365
223413
|
});
|
|
223366
223414
|
const matches = [];
|
|
223367
223415
|
for (const file of files) {
|
|
223416
|
+
if (abortSignal?.aborted) {
|
|
223417
|
+
return { ok: false, error: "Grep was cancelled by the user." };
|
|
223418
|
+
}
|
|
223368
223419
|
if (matches.length >= max) break;
|
|
223369
223420
|
const content = readFileSync32(file, "utf8");
|
|
223370
223421
|
if (!content.includes(input.pattern)) continue;
|
|
@@ -223386,17 +223437,17 @@ var GrepTool = class {
|
|
|
223386
223437
|
data: matches,
|
|
223387
223438
|
display: `Grep for "${input.pattern}" using JS fallback: found ${matches.length} matches`
|
|
223388
223439
|
};
|
|
223389
|
-
} catch (
|
|
223440
|
+
} catch (error) {
|
|
223390
223441
|
return {
|
|
223391
223442
|
ok: false,
|
|
223392
|
-
error: `Grep failed: Ripgrep was unavailable and fallback search failed: ${
|
|
223443
|
+
error: `Grep failed: Ripgrep was unavailable and fallback search failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223393
223444
|
};
|
|
223394
223445
|
}
|
|
223395
223446
|
}
|
|
223396
223447
|
};
|
|
223397
223448
|
var BashInputSchema = z72.object({
|
|
223398
|
-
command: z72.string(),
|
|
223399
|
-
timeoutMs: z72.number().optional()
|
|
223449
|
+
command: z72.string().min(1).max(1e5),
|
|
223450
|
+
timeoutMs: z72.number().int().positive().optional()
|
|
223400
223451
|
});
|
|
223401
223452
|
var BashTool = class {
|
|
223402
223453
|
name = "bash";
|
|
@@ -223431,13 +223482,17 @@ ${displayStderr}` : "",
|
|
|
223431
223482
|
return {
|
|
223432
223483
|
ok: exitCode === 0,
|
|
223433
223484
|
data: {
|
|
223434
|
-
stdout,
|
|
223435
|
-
stderr,
|
|
223485
|
+
stdout: displayStdout,
|
|
223486
|
+
stderr: displayStderr,
|
|
223436
223487
|
exitCode
|
|
223437
223488
|
},
|
|
223438
223489
|
display,
|
|
223439
223490
|
error: exitCode === 0 ? void 0 : `Command exited with non-zero status ${exitCode}.`,
|
|
223440
|
-
metadata: {
|
|
223491
|
+
metadata: {
|
|
223492
|
+
truncated,
|
|
223493
|
+
stdoutChars: stdout.length,
|
|
223494
|
+
stderrChars: stderr.length
|
|
223495
|
+
}
|
|
223441
223496
|
};
|
|
223442
223497
|
} catch (error) {
|
|
223443
223498
|
if (error instanceof Error && error.name === "AbortError" || ctx.abortSignal?.aborted) {
|
|
@@ -223454,7 +223509,7 @@ ${displayStderr}` : "",
|
|
|
223454
223509
|
}
|
|
223455
223510
|
};
|
|
223456
223511
|
var RunTestsInputSchema = z82.object({
|
|
223457
|
-
command: z82.string().optional()
|
|
223512
|
+
command: z82.string().trim().min(1).max(1e5).optional()
|
|
223458
223513
|
});
|
|
223459
223514
|
var RunTestsTool = class {
|
|
223460
223515
|
name = "run_tests";
|
|
@@ -223481,9 +223536,10 @@ var RunTestsTool = class {
|
|
|
223481
223536
|
const exitCode = result.exitCode ?? 0;
|
|
223482
223537
|
const displayStdout = LogTruncator.truncate(stdout, 150, 2e4);
|
|
223483
223538
|
const displayStderr = LogTruncator.truncate(stderr, 150, 2e4);
|
|
223539
|
+
const truncated = displayStdout.length !== stdout.length || displayStderr.length !== stderr.length;
|
|
223484
223540
|
return {
|
|
223485
223541
|
ok: exitCode === 0,
|
|
223486
|
-
data: { stdout, stderr, exitCode },
|
|
223542
|
+
data: { stdout: displayStdout, stderr: displayStderr, exitCode },
|
|
223487
223543
|
display: `Ran tests using command "${testCommand}":
|
|
223488
223544
|
|
|
223489
223545
|
Stdout:
|
|
@@ -223493,7 +223549,12 @@ Stderr:
|
|
|
223493
223549
|
${displayStderr}
|
|
223494
223550
|
|
|
223495
223551
|
Exit code: ${exitCode}`,
|
|
223496
|
-
error: exitCode !== 0 ? `Tests failed with exit code ${exitCode}` : void 0
|
|
223552
|
+
error: exitCode !== 0 ? `Tests failed with exit code ${exitCode}` : void 0,
|
|
223553
|
+
metadata: {
|
|
223554
|
+
truncated,
|
|
223555
|
+
stdoutChars: stdout.length,
|
|
223556
|
+
stderrChars: stderr.length
|
|
223557
|
+
}
|
|
223497
223558
|
};
|
|
223498
223559
|
} catch (error) {
|
|
223499
223560
|
if (error instanceof Error && error.name === "AbortError" || ctx.abortSignal?.aborted) {
|
|
@@ -223553,16 +223614,24 @@ var GitDiffTool = class {
|
|
|
223553
223614
|
if (input.staged) {
|
|
223554
223615
|
args.push("--staged");
|
|
223555
223616
|
}
|
|
223556
|
-
const { stdout } = await execa("git", args, {
|
|
223617
|
+
const { stdout } = await execa("git", args, {
|
|
223618
|
+
cwd: ctx.cwd,
|
|
223619
|
+
signal: ctx.abortSignal
|
|
223620
|
+
});
|
|
223621
|
+
const bounded = LogTruncator.truncate(stdout, 300, 4e4);
|
|
223557
223622
|
return {
|
|
223558
223623
|
ok: true,
|
|
223559
|
-
data:
|
|
223560
|
-
display:
|
|
223624
|
+
data: bounded,
|
|
223625
|
+
display: bounded || "No changes detected in git workspace.",
|
|
223626
|
+
metadata: {
|
|
223627
|
+
truncated: bounded.length !== stdout.length,
|
|
223628
|
+
outputChars: stdout.length
|
|
223629
|
+
}
|
|
223561
223630
|
};
|
|
223562
|
-
} catch (
|
|
223631
|
+
} catch (error) {
|
|
223563
223632
|
return {
|
|
223564
223633
|
ok: false,
|
|
223565
|
-
error: `Git diff failed: ${
|
|
223634
|
+
error: `Git diff failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223566
223635
|
};
|
|
223567
223636
|
}
|
|
223568
223637
|
}
|
|
@@ -223573,26 +223642,27 @@ var GitStatusTool = class {
|
|
|
223573
223642
|
description = "Show working tree status of git files (short format).";
|
|
223574
223643
|
inputSchema = GitStatusInputSchema;
|
|
223575
223644
|
risk = "read";
|
|
223576
|
-
async execute(
|
|
223645
|
+
async execute(_input, ctx) {
|
|
223577
223646
|
try {
|
|
223578
223647
|
const { stdout } = await execa("git", ["status", "--short"], {
|
|
223579
|
-
cwd: ctx.cwd
|
|
223648
|
+
cwd: ctx.cwd,
|
|
223649
|
+
signal: ctx.abortSignal
|
|
223580
223650
|
});
|
|
223581
223651
|
return {
|
|
223582
223652
|
ok: true,
|
|
223583
223653
|
data: stdout,
|
|
223584
223654
|
display: stdout ? stdout : "Working tree clean."
|
|
223585
223655
|
};
|
|
223586
|
-
} catch (
|
|
223656
|
+
} catch (error) {
|
|
223587
223657
|
return {
|
|
223588
223658
|
ok: false,
|
|
223589
|
-
error: `Git status failed: ${
|
|
223659
|
+
error: `Git status failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223590
223660
|
};
|
|
223591
223661
|
}
|
|
223592
223662
|
}
|
|
223593
223663
|
};
|
|
223594
223664
|
var GitCommitInputSchema = z112.object({
|
|
223595
|
-
message: z112.string().optional()
|
|
223665
|
+
message: z112.string().trim().min(1).max(1e3).optional()
|
|
223596
223666
|
});
|
|
223597
223667
|
var GitCommitTool = class {
|
|
223598
223668
|
name = "git_commit";
|
|
@@ -223603,7 +223673,8 @@ var GitCommitTool = class {
|
|
|
223603
223673
|
try {
|
|
223604
223674
|
const commitMessage = input.message || "chore: update workspace";
|
|
223605
223675
|
const { stdout } = await execa("git", ["commit", "-m", commitMessage], {
|
|
223606
|
-
cwd: ctx.cwd
|
|
223676
|
+
cwd: ctx.cwd,
|
|
223677
|
+
signal: ctx.abortSignal
|
|
223607
223678
|
});
|
|
223608
223679
|
return {
|
|
223609
223680
|
ok: true,
|
|
@@ -223611,16 +223682,16 @@ var GitCommitTool = class {
|
|
|
223611
223682
|
display: `Staged changes committed:
|
|
223612
223683
|
${stdout}`
|
|
223613
223684
|
};
|
|
223614
|
-
} catch (
|
|
223685
|
+
} catch (error) {
|
|
223615
223686
|
return {
|
|
223616
223687
|
ok: false,
|
|
223617
|
-
error: `Git commit failed: ${
|
|
223688
|
+
error: `Git commit failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223618
223689
|
};
|
|
223619
223690
|
}
|
|
223620
223691
|
}
|
|
223621
223692
|
};
|
|
223622
223693
|
var GitRestoreInputSchema = z122.object({
|
|
223623
|
-
paths: z122.array(z122.string())
|
|
223694
|
+
paths: z122.array(z122.string().trim().min(1).max(4096)).min(1).max(200)
|
|
223624
223695
|
});
|
|
223625
223696
|
var GitRestoreTool = class {
|
|
223626
223697
|
name = "git_restore";
|
|
@@ -223630,17 +223701,18 @@ var GitRestoreTool = class {
|
|
|
223630
223701
|
async execute(input, ctx) {
|
|
223631
223702
|
try {
|
|
223632
223703
|
const { stdout } = await execa("git", ["restore", ...input.paths], {
|
|
223633
|
-
cwd: ctx.cwd
|
|
223704
|
+
cwd: ctx.cwd,
|
|
223705
|
+
signal: ctx.abortSignal
|
|
223634
223706
|
});
|
|
223635
223707
|
return {
|
|
223636
223708
|
ok: true,
|
|
223637
223709
|
data: stdout,
|
|
223638
223710
|
display: `Restored files: ${input.paths.join(", ")}`
|
|
223639
223711
|
};
|
|
223640
|
-
} catch (
|
|
223712
|
+
} catch (error) {
|
|
223641
223713
|
return {
|
|
223642
223714
|
ok: false,
|
|
223643
|
-
error: `Git restore failed: ${
|
|
223715
|
+
error: `Git restore failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223644
223716
|
};
|
|
223645
223717
|
}
|
|
223646
223718
|
}
|
|
@@ -223651,7 +223723,7 @@ var DetectProjectTool = class {
|
|
|
223651
223723
|
description = "Detect project profile including programming languages, frameworks, package manager, test/lint/build scripts, and main entry files.";
|
|
223652
223724
|
inputSchema = DetectProjectInputSchema;
|
|
223653
223725
|
risk = "read";
|
|
223654
|
-
async execute(
|
|
223726
|
+
async execute(_input, ctx) {
|
|
223655
223727
|
try {
|
|
223656
223728
|
const root = ctx.cwd;
|
|
223657
223729
|
const languages = [];
|
|
@@ -223745,10 +223817,10 @@ var DetectProjectTool = class {
|
|
|
223745
223817
|
data,
|
|
223746
223818
|
display: `Detected Project: ${data.detectedLanguages.join(", ")} project. Frameworks: ${data.frameworks.join(", ") || "None"}. PM: ${data.packageManager || "None"}`
|
|
223747
223819
|
};
|
|
223748
|
-
} catch (
|
|
223820
|
+
} catch (error) {
|
|
223749
223821
|
return {
|
|
223750
223822
|
ok: false,
|
|
223751
|
-
error:
|
|
223823
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223752
223824
|
};
|
|
223753
223825
|
}
|
|
223754
223826
|
}
|
|
@@ -223759,7 +223831,7 @@ var InspectProjectTool = class {
|
|
|
223759
223831
|
description = "Inspect project directory structure, returning a tree summary of top-level folders and files.";
|
|
223760
223832
|
inputSchema = InspectProjectInputSchema;
|
|
223761
223833
|
risk = "read";
|
|
223762
|
-
async execute(
|
|
223834
|
+
async execute(_input, ctx) {
|
|
223763
223835
|
try {
|
|
223764
223836
|
const files = await glob4("**/*", {
|
|
223765
223837
|
cwd: ctx.cwd,
|
|
@@ -223790,10 +223862,10 @@ ${treeLines.slice(0, 200).join("\n")}${treeLines.length > 200 ? "\n... [TRUNCATE
|
|
|
223790
223862
|
data: display,
|
|
223791
223863
|
display
|
|
223792
223864
|
};
|
|
223793
|
-
} catch (
|
|
223865
|
+
} catch (error) {
|
|
223794
223866
|
return {
|
|
223795
223867
|
ok: false,
|
|
223796
|
-
error:
|
|
223868
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223797
223869
|
};
|
|
223798
223870
|
}
|
|
223799
223871
|
}
|
|
@@ -223866,12 +223938,15 @@ var SearchSymbolsTool = class {
|
|
|
223866
223938
|
}
|
|
223867
223939
|
}
|
|
223868
223940
|
results.sort((a3, b3) => a3.name.localeCompare(b3.name));
|
|
223869
|
-
const
|
|
223870
|
-
|
|
223941
|
+
const totalMatches = results.length;
|
|
223942
|
+
const boundedResults = results.slice(0, 200);
|
|
223943
|
+
const display = boundedResults.length > 0 ? `Found ${totalMatches} matching symbol(s), returning ${boundedResults.length}:
|
|
223944
|
+
` + boundedResults.map((r2) => `- [${r2.type}] ${r2.name} in ${r2.filePath}:${r2.line}`).join("\n") : `No symbols matching "${input.query}" found.`;
|
|
223871
223945
|
return {
|
|
223872
223946
|
ok: true,
|
|
223873
|
-
data:
|
|
223874
|
-
display
|
|
223947
|
+
data: boundedResults,
|
|
223948
|
+
display,
|
|
223949
|
+
metadata: { truncated: totalMatches > boundedResults.length }
|
|
223875
223950
|
};
|
|
223876
223951
|
} catch (error) {
|
|
223877
223952
|
return {
|
|
@@ -223882,7 +223957,7 @@ var SearchSymbolsTool = class {
|
|
|
223882
223957
|
}
|
|
223883
223958
|
};
|
|
223884
223959
|
var WebSearchInputSchema = z16.object({
|
|
223885
|
-
query: z16.string().describe(
|
|
223960
|
+
query: z16.string().trim().min(1).max(2048).describe(
|
|
223886
223961
|
"Search query. Resolve relative dates using the Runtime Context current date before adding date terms; do not add stale years from model memory."
|
|
223887
223962
|
),
|
|
223888
223963
|
maxResults: z16.number().int().min(1).max(20).describe("Maximum number of search results to return, from 1 to 20.").optional()
|
|
@@ -224575,8 +224650,198 @@ var WebSearchTool = class {
|
|
|
224575
224650
|
};
|
|
224576
224651
|
}
|
|
224577
224652
|
};
|
|
224578
|
-
var
|
|
224579
|
-
|
|
224653
|
+
var WEB_FETCH_MAX_BYTES = 1024 * 1024;
|
|
224654
|
+
var WEB_FETCH_MAX_REDIRECTS = 5;
|
|
224655
|
+
var WebFetchInputSchema = z17.object({
|
|
224656
|
+
url: z17.string().url().max(8192).describe(
|
|
224657
|
+
"Public HTTP(S) URL to read. Local and private network targets are blocked."
|
|
224658
|
+
),
|
|
224659
|
+
maxChars: z17.number().int().min(1e3).max(5e4).describe("Maximum readable characters to return.").optional()
|
|
224660
|
+
});
|
|
224661
|
+
async function defaultAddressResolver(hostname) {
|
|
224662
|
+
return (await lookup(hostname, { all: true, verbatim: true })).map(
|
|
224663
|
+
(entry) => entry.address
|
|
224664
|
+
);
|
|
224665
|
+
}
|
|
224666
|
+
var WebFetchTool = class {
|
|
224667
|
+
constructor(fetchImplementation = globalThis.fetch, resolveAddresses = defaultAddressResolver) {
|
|
224668
|
+
this.fetchImplementation = fetchImplementation;
|
|
224669
|
+
this.resolveAddresses = resolveAddresses;
|
|
224670
|
+
}
|
|
224671
|
+
fetchImplementation;
|
|
224672
|
+
resolveAddresses;
|
|
224673
|
+
name = "web_fetch";
|
|
224674
|
+
description = "Read the bounded text content of a public HTTP(S) page after web_search identifies a useful source. Blocks credentials, localhost/private networks, binary responses, and unsafe redirects.";
|
|
224675
|
+
inputSchema = WebFetchInputSchema;
|
|
224676
|
+
risk = "network";
|
|
224677
|
+
async execute(input, context) {
|
|
224678
|
+
const controller = new AbortController();
|
|
224679
|
+
const onAbort = () => controller.abort();
|
|
224680
|
+
if (context.abortSignal?.aborted) {
|
|
224681
|
+
return { ok: false, error: "Web fetch was cancelled before it started." };
|
|
224682
|
+
}
|
|
224683
|
+
context.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
224684
|
+
const timeoutMs = Math.max(
|
|
224685
|
+
1e3,
|
|
224686
|
+
Math.min(3e4, context.config?.tools?.webSearch?.timeoutMs ?? 8e3)
|
|
224687
|
+
);
|
|
224688
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
224689
|
+
try {
|
|
224690
|
+
let currentUrl = await assertPublicHttpUrl(
|
|
224691
|
+
input.url,
|
|
224692
|
+
this.resolveAddresses
|
|
224693
|
+
);
|
|
224694
|
+
for (let redirect = 0; redirect <= WEB_FETCH_MAX_REDIRECTS; redirect += 1) {
|
|
224695
|
+
const response = await this.fetchImplementation(currentUrl, {
|
|
224696
|
+
method: "GET",
|
|
224697
|
+
redirect: "manual",
|
|
224698
|
+
signal: controller.signal,
|
|
224699
|
+
headers: {
|
|
224700
|
+
Accept: "text/html, text/plain, application/json, application/xml;q=0.9, text/xml;q=0.9",
|
|
224701
|
+
"User-Agent": "Orbit/0.1 (+https://github.com/Hephaestus-DevKit/Orbit)"
|
|
224702
|
+
}
|
|
224703
|
+
});
|
|
224704
|
+
if (isRedirectStatus(response.status)) {
|
|
224705
|
+
const location = response.headers.get("location");
|
|
224706
|
+
if (!location) {
|
|
224707
|
+
return {
|
|
224708
|
+
ok: false,
|
|
224709
|
+
error: "Web fetch received a redirect without a Location header."
|
|
224710
|
+
};
|
|
224711
|
+
}
|
|
224712
|
+
if (redirect === WEB_FETCH_MAX_REDIRECTS) {
|
|
224713
|
+
return {
|
|
224714
|
+
ok: false,
|
|
224715
|
+
error: "Web fetch exceeded the redirect limit."
|
|
224716
|
+
};
|
|
224717
|
+
}
|
|
224718
|
+
currentUrl = await assertPublicHttpUrl(
|
|
224719
|
+
new URL(location, currentUrl).toString(),
|
|
224720
|
+
this.resolveAddresses
|
|
224721
|
+
);
|
|
224722
|
+
continue;
|
|
224723
|
+
}
|
|
224724
|
+
if (!response.ok) {
|
|
224725
|
+
return {
|
|
224726
|
+
ok: false,
|
|
224727
|
+
error: `Web fetch failed with HTTP ${response.status} ${response.statusText}`.trim()
|
|
224728
|
+
};
|
|
224729
|
+
}
|
|
224730
|
+
const contentType = response.headers.get("content-type") || "text/plain";
|
|
224731
|
+
if (!isReadableContentType(contentType)) {
|
|
224732
|
+
return {
|
|
224733
|
+
ok: false,
|
|
224734
|
+
error: `Web fetch rejected non-text content type "${contentType.slice(0, 200)}".`
|
|
224735
|
+
};
|
|
224736
|
+
}
|
|
224737
|
+
const rawText = await readBoundedResponseText(response);
|
|
224738
|
+
const text = contentType.toLowerCase().includes("text/html") ? htmlToReadableText(rawText) : rawText.trim();
|
|
224739
|
+
const maxChars = input.maxChars ?? 24e3;
|
|
224740
|
+
const bounded = text.length > maxChars ? `${text.slice(0, Math.max(0, maxChars - 35)).trimEnd()}
|
|
224741
|
+
... [truncated by web_fetch]` : text;
|
|
224742
|
+
const output = `Source: ${currentUrl}
|
|
224743
|
+
Content-Type: ${contentType}
|
|
224744
|
+
|
|
224745
|
+
${bounded || "[No readable text content]"}`;
|
|
224746
|
+
return {
|
|
224747
|
+
ok: true,
|
|
224748
|
+
data: output,
|
|
224749
|
+
display: `Fetched ${currentUrl} (${bounded.length} readable characters).`
|
|
224750
|
+
};
|
|
224751
|
+
}
|
|
224752
|
+
return { ok: false, error: "Web fetch exceeded the redirect limit." };
|
|
224753
|
+
} catch (error) {
|
|
224754
|
+
const message = controller.signal.aborted ? context.abortSignal?.aborted ? "Web fetch was cancelled by the user." : `Web fetch timed out after ${timeoutMs}ms.` : `Web fetch failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
224755
|
+
return { ok: false, error: redactSecrets(message).slice(0, 2e3) };
|
|
224756
|
+
} finally {
|
|
224757
|
+
clearTimeout(timeout);
|
|
224758
|
+
context.abortSignal?.removeEventListener("abort", onAbort);
|
|
224759
|
+
}
|
|
224760
|
+
}
|
|
224761
|
+
};
|
|
224762
|
+
async function assertPublicHttpUrl(rawUrl, resolveAddresses = defaultAddressResolver) {
|
|
224763
|
+
const url = new URL(rawUrl);
|
|
224764
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
224765
|
+
throw new Error("Only http:// and https:// URLs are supported.");
|
|
224766
|
+
}
|
|
224767
|
+
if (url.username || url.password) {
|
|
224768
|
+
throw new Error("URLs containing credentials are not allowed.");
|
|
224769
|
+
}
|
|
224770
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
224771
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost") || hostname.endsWith(".local") || hostname.endsWith(".internal") || hostname.endsWith(".home.arpa")) {
|
|
224772
|
+
throw new Error("Local and private network URLs are blocked.");
|
|
224773
|
+
}
|
|
224774
|
+
if (isIP(hostname) > 0 && isPrivateOrReservedAddress(hostname)) {
|
|
224775
|
+
throw new Error(
|
|
224776
|
+
"Local, private, or reserved network addresses are blocked."
|
|
224777
|
+
);
|
|
224778
|
+
}
|
|
224779
|
+
const addresses = await resolveAddresses(hostname);
|
|
224780
|
+
if (addresses.length === 0 || addresses.some(isPrivateOrReservedAddress)) {
|
|
224781
|
+
throw new Error(
|
|
224782
|
+
"Local, private, or reserved network addresses are blocked."
|
|
224783
|
+
);
|
|
224784
|
+
}
|
|
224785
|
+
url.hash = "";
|
|
224786
|
+
return url.toString();
|
|
224787
|
+
}
|
|
224788
|
+
function isPrivateOrReservedAddress(address) {
|
|
224789
|
+
const normalized = address.toLowerCase().replace(/^\[|\]$/g, "");
|
|
224790
|
+
if (normalized.includes(":")) {
|
|
224791
|
+
if (normalized === "::1" || normalized === "::") return true;
|
|
224792
|
+
if (/^(?:fc|fd|fe[89ab])/.test(normalized)) return true;
|
|
224793
|
+
const mapped = normalized.match(/::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
224794
|
+
return mapped ? isPrivateOrReservedAddress(mapped[1]) : false;
|
|
224795
|
+
}
|
|
224796
|
+
const parts = normalized.split(".").map(Number);
|
|
224797
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part))) {
|
|
224798
|
+
return true;
|
|
224799
|
+
}
|
|
224800
|
+
const [a3, b3] = parts;
|
|
224801
|
+
return a3 === 0 || a3 === 10 || a3 === 127 || a3 === 100 && b3 >= 64 && b3 <= 127 || a3 === 169 && b3 === 254 || a3 === 172 && b3 >= 16 && b3 <= 31 || a3 === 192 && b3 === 168 || a3 === 198 && (b3 === 18 || b3 === 19) || a3 >= 224;
|
|
224802
|
+
}
|
|
224803
|
+
function isRedirectStatus(status) {
|
|
224804
|
+
return [301, 302, 303, 307, 308].includes(status);
|
|
224805
|
+
}
|
|
224806
|
+
function isReadableContentType(contentType) {
|
|
224807
|
+
return /^(?:text\/|application\/(?:json|[\w.+-]*\+json|xml|[\w.+-]*\+xml))/i.test(
|
|
224808
|
+
contentType.trim()
|
|
224809
|
+
);
|
|
224810
|
+
}
|
|
224811
|
+
async function readBoundedResponseText(response) {
|
|
224812
|
+
if (!response.body) return "";
|
|
224813
|
+
const reader = response.body.getReader();
|
|
224814
|
+
const chunks = [];
|
|
224815
|
+
let total = 0;
|
|
224816
|
+
while (true) {
|
|
224817
|
+
const next = await reader.read();
|
|
224818
|
+
if (next.done) break;
|
|
224819
|
+
const remaining = WEB_FETCH_MAX_BYTES - total;
|
|
224820
|
+
if (remaining <= 0) {
|
|
224821
|
+
await reader.cancel().catch(() => void 0);
|
|
224822
|
+
break;
|
|
224823
|
+
}
|
|
224824
|
+
const chunk = next.value.byteLength > remaining ? next.value.subarray(0, remaining) : next.value;
|
|
224825
|
+
chunks.push(chunk);
|
|
224826
|
+
total += chunk.byteLength;
|
|
224827
|
+
if (total >= WEB_FETCH_MAX_BYTES) {
|
|
224828
|
+
await reader.cancel().catch(() => void 0);
|
|
224829
|
+
break;
|
|
224830
|
+
}
|
|
224831
|
+
}
|
|
224832
|
+
const combined = new Uint8Array(total);
|
|
224833
|
+
let offset = 0;
|
|
224834
|
+
for (const chunk of chunks) {
|
|
224835
|
+
combined.set(chunk, offset);
|
|
224836
|
+
offset += chunk.byteLength;
|
|
224837
|
+
}
|
|
224838
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(combined);
|
|
224839
|
+
}
|
|
224840
|
+
function htmlToReadableText(html) {
|
|
224841
|
+
return html.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, " ").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, " ").replace(/<noscript\b[^>]*>[\s\S]*?<\/noscript>/gi, " ").replace(/<(?:br|\/p|\/div|\/li|\/h[1-6])\s*>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/ /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/gi, "'").replace(/[ \t]+/g, " ").replace(/\n\s*\n+/g, "\n\n").trim();
|
|
224842
|
+
}
|
|
224843
|
+
var FindSymbolReferencesInputSchema = z18.object({
|
|
224844
|
+
symbol: z18.string().trim().min(1).max(512).describe("The symbol name to search references for.")
|
|
224580
224845
|
});
|
|
224581
224846
|
function escapeRegExp(value) {
|
|
224582
224847
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -224605,6 +224870,7 @@ var FindSymbolReferencesTool = class {
|
|
|
224605
224870
|
};
|
|
224606
224871
|
}
|
|
224607
224872
|
const results = [];
|
|
224873
|
+
let truncated = false;
|
|
224608
224874
|
const escapedSymbol = escapeRegExp(input.symbol);
|
|
224609
224875
|
const symbolRegex = new RegExp(
|
|
224610
224876
|
`(?<![\\p{ID_Continue}$\\u200C\\u200D])${escapedSymbol}(?![\\p{ID_Continue}$\\u200C\\u200D])`,
|
|
@@ -224635,11 +224901,16 @@ var FindSymbolReferencesTool = class {
|
|
|
224635
224901
|
results.push({
|
|
224636
224902
|
file,
|
|
224637
224903
|
line: idx + 1,
|
|
224638
|
-
content: trimmed
|
|
224904
|
+
content: trimmed.slice(0, 500)
|
|
224639
224905
|
});
|
|
224906
|
+
if (results.length >= 300) {
|
|
224907
|
+
truncated = true;
|
|
224908
|
+
break;
|
|
224909
|
+
}
|
|
224640
224910
|
}
|
|
224641
224911
|
}
|
|
224642
224912
|
}
|
|
224913
|
+
if (truncated) break;
|
|
224643
224914
|
}
|
|
224644
224915
|
const display = results.length > 0 ? `Found ${results.length} references for symbol "${input.symbol}":
|
|
224645
224916
|
` + results.map(
|
|
@@ -224648,7 +224919,8 @@ var FindSymbolReferencesTool = class {
|
|
|
224648
224919
|
return {
|
|
224649
224920
|
ok: true,
|
|
224650
224921
|
data: results,
|
|
224651
|
-
display
|
|
224922
|
+
display,
|
|
224923
|
+
metadata: { truncated }
|
|
224652
224924
|
};
|
|
224653
224925
|
} catch (error) {
|
|
224654
224926
|
return {
|
|
@@ -224658,6 +224930,55 @@ var FindSymbolReferencesTool = class {
|
|
|
224658
224930
|
}
|
|
224659
224931
|
}
|
|
224660
224932
|
};
|
|
224933
|
+
var UpdatePlanInputSchema = z19.object({
|
|
224934
|
+
explanation: z19.string().trim().min(1).max(1e3).describe("Brief reason for changing the plan.").optional(),
|
|
224935
|
+
plan: z19.array(
|
|
224936
|
+
z19.object({
|
|
224937
|
+
step: z19.string().trim().min(1).max(1e3),
|
|
224938
|
+
status: z19.enum(["pending", "in_progress", "completed"])
|
|
224939
|
+
})
|
|
224940
|
+
).max(100)
|
|
224941
|
+
}).superRefine((value, ctx) => {
|
|
224942
|
+
if (value.plan.filter((item) => item.status === "in_progress").length > 1) {
|
|
224943
|
+
ctx.addIssue({
|
|
224944
|
+
code: z19.ZodIssueCode.custom,
|
|
224945
|
+
path: ["plan"],
|
|
224946
|
+
message: "At most one plan item may be in progress."
|
|
224947
|
+
});
|
|
224948
|
+
}
|
|
224949
|
+
const normalizedSteps = value.plan.map((item) => item.step.toLowerCase());
|
|
224950
|
+
if (new Set(normalizedSteps).size !== normalizedSteps.length) {
|
|
224951
|
+
ctx.addIssue({
|
|
224952
|
+
code: z19.ZodIssueCode.custom,
|
|
224953
|
+
path: ["plan"],
|
|
224954
|
+
message: "Plan steps must be unique."
|
|
224955
|
+
});
|
|
224956
|
+
}
|
|
224957
|
+
});
|
|
224958
|
+
var UpdatePlanTool = class {
|
|
224959
|
+
name = "update_plan";
|
|
224960
|
+
description = "Create or replace the current chat's durable task plan. Use for multi-step work and update statuses as work progresses. Keep at most one step in progress.";
|
|
224961
|
+
inputSchema = UpdatePlanInputSchema;
|
|
224962
|
+
risk = "write";
|
|
224963
|
+
async execute(input, context) {
|
|
224964
|
+
if (!context.services?.updatePlan) {
|
|
224965
|
+
return { ok: false, error: "Task-plan service is unavailable." };
|
|
224966
|
+
}
|
|
224967
|
+
try {
|
|
224968
|
+
const data = await context.services.updatePlan(input);
|
|
224969
|
+
return {
|
|
224970
|
+
ok: true,
|
|
224971
|
+
data,
|
|
224972
|
+
display: `Updated task plan with ${input.plan.length} step(s).`
|
|
224973
|
+
};
|
|
224974
|
+
} catch (error) {
|
|
224975
|
+
return {
|
|
224976
|
+
ok: false,
|
|
224977
|
+
error: `Unable to update task plan: ${error instanceof Error ? error.message : String(error)}`
|
|
224978
|
+
};
|
|
224979
|
+
}
|
|
224980
|
+
}
|
|
224981
|
+
};
|
|
224661
224982
|
toolRegistry.register(new ReadFileTool());
|
|
224662
224983
|
toolRegistry.register(new WriteFileTool());
|
|
224663
224984
|
toolRegistry.register(new EditFileTool());
|
|
@@ -224674,7 +224995,9 @@ toolRegistry.register(new DetectProjectTool());
|
|
|
224674
224995
|
toolRegistry.register(new InspectProjectTool());
|
|
224675
224996
|
toolRegistry.register(new SearchSymbolsTool());
|
|
224676
224997
|
toolRegistry.register(new WebSearchTool());
|
|
224998
|
+
toolRegistry.register(new WebFetchTool());
|
|
224677
224999
|
toolRegistry.register(new FindSymbolReferencesTool());
|
|
225000
|
+
toolRegistry.register(new UpdatePlanTool());
|
|
224678
225001
|
|
|
224679
225002
|
// ../sandbox/dist/index.js
|
|
224680
225003
|
import {
|
|
@@ -225077,7 +225400,7 @@ var import_typescript = __toESM(require_typescript(), 1);
|
|
|
225077
225400
|
import { existsSync as existsSync11, promises as fsPromises2 } from "fs";
|
|
225078
225401
|
import { dirname as dirname5, resolve as resolve5 } from "path";
|
|
225079
225402
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
225080
|
-
import { z as
|
|
225403
|
+
import { z as z20 } from "zod";
|
|
225081
225404
|
import { basename as basename3, join as join10 } from "path";
|
|
225082
225405
|
import { existsSync as existsSync25, promises as fsPromises3 } from "fs";
|
|
225083
225406
|
import { dirname as dirname22, resolve as resolve22 } from "path";
|
|
@@ -225093,10 +225416,13 @@ var ProjectIndexer = class {
|
|
|
225093
225416
|
cwd;
|
|
225094
225417
|
async index() {
|
|
225095
225418
|
const tool = new DetectProjectTool();
|
|
225096
|
-
const result = await tool.execute(
|
|
225097
|
-
|
|
225098
|
-
|
|
225099
|
-
|
|
225419
|
+
const result = await tool.execute(
|
|
225420
|
+
{},
|
|
225421
|
+
{
|
|
225422
|
+
cwd: this.cwd,
|
|
225423
|
+
sessionId: "indexer"
|
|
225424
|
+
}
|
|
225425
|
+
);
|
|
225100
225426
|
if (result.ok && result.data) {
|
|
225101
225427
|
return result.data;
|
|
225102
225428
|
}
|
|
@@ -225245,29 +225571,29 @@ function getOrbitCachePath(cwd, fileName) {
|
|
|
225245
225571
|
const relativePath = branchName ? join10(".orbit", "branches", branchName, fileName) : join10(".orbit", fileName);
|
|
225246
225572
|
return resolveSafePath(cwd, relativePath);
|
|
225247
225573
|
}
|
|
225248
|
-
var EmbeddingVectorSchema =
|
|
225249
|
-
var DocumentSchema =
|
|
225250
|
-
id:
|
|
225251
|
-
text:
|
|
225574
|
+
var EmbeddingVectorSchema = z20.array(z20.number().finite()).min(1).max(32768);
|
|
225575
|
+
var DocumentSchema = z20.object({
|
|
225576
|
+
id: z20.string().min(1).max(4096),
|
|
225577
|
+
text: z20.string().max(2e6),
|
|
225252
225578
|
vector: EmbeddingVectorSchema.optional(),
|
|
225253
|
-
metadata:
|
|
225254
|
-
filePath:
|
|
225255
|
-
symbolName:
|
|
225256
|
-
symbolType:
|
|
225257
|
-
startLine:
|
|
225258
|
-
endLine:
|
|
225579
|
+
metadata: z20.object({
|
|
225580
|
+
filePath: z20.string().min(1).max(4096),
|
|
225581
|
+
symbolName: z20.string().max(4096).optional(),
|
|
225582
|
+
symbolType: z20.string().max(256).optional(),
|
|
225583
|
+
startLine: z20.number().int().positive(),
|
|
225584
|
+
endLine: z20.number().int().positive()
|
|
225259
225585
|
})
|
|
225260
225586
|
});
|
|
225261
|
-
var DBHeaderSchema =
|
|
225262
|
-
modelName:
|
|
225263
|
-
dimension:
|
|
225264
|
-
updatedAt:
|
|
225587
|
+
var DBHeaderSchema = z20.object({
|
|
225588
|
+
modelName: z20.string().min(1).max(1024),
|
|
225589
|
+
dimension: z20.number().int().positive().max(32768),
|
|
225590
|
+
updatedAt: z20.string().min(1)
|
|
225265
225591
|
});
|
|
225266
|
-
var VectorStoreFileSchema =
|
|
225592
|
+
var VectorStoreFileSchema = z20.object({
|
|
225267
225593
|
header: DBHeaderSchema.nullable(),
|
|
225268
|
-
documents:
|
|
225594
|
+
documents: z20.array(DocumentSchema)
|
|
225269
225595
|
});
|
|
225270
|
-
var LegacyVectorStoreFileSchema =
|
|
225596
|
+
var LegacyVectorStoreFileSchema = z20.array(DocumentSchema);
|
|
225271
225597
|
var JSVectorStore = class {
|
|
225272
225598
|
constructor(cwd, modelName) {
|
|
225273
225599
|
this.cwd = cwd;
|
|
@@ -225286,7 +225612,7 @@ var JSVectorStore = class {
|
|
|
225286
225612
|
if (!this.loaded) {
|
|
225287
225613
|
await this.load();
|
|
225288
225614
|
}
|
|
225289
|
-
const validatedDocs =
|
|
225615
|
+
const validatedDocs = z20.array(DocumentSchema).parse(docs);
|
|
225290
225616
|
const vectorDimensions = new Set(
|
|
225291
225617
|
validatedDocs.flatMap(
|
|
225292
225618
|
(doc) => doc.vector === void 0 ? [] : [doc.vector.length]
|
|
@@ -227252,7 +227578,7 @@ function lD(e2) {
|
|
|
227252
227578
|
function v(e2, u) {
|
|
227253
227579
|
e2.isTTY && e2.setRawMode(u);
|
|
227254
227580
|
}
|
|
227255
|
-
var
|
|
227581
|
+
var z21 = /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"]]);
|
|
227256
227582
|
var xD = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
|
|
227257
227583
|
var x = class {
|
|
227258
227584
|
constructor({ render: u, input: F = $2, output: t = k, ...s }, C2 = true) {
|
|
@@ -227287,7 +227613,7 @@ var x = class {
|
|
|
227287
227613
|
this.subscribers.clear();
|
|
227288
227614
|
}
|
|
227289
227615
|
onKeypress(u, F) {
|
|
227290
|
-
if (this.state === "error" && (this.state = "active"), F?.name && !this._track &&
|
|
227616
|
+
if (this.state === "error" && (this.state = "active"), F?.name && !this._track && z21.has(F.name) && this.emit("cursor", z21.get(F.name)), F?.name && xD.has(F.name) && this.emit("cursor", F.name), u && (u.toLowerCase() === "y" || u.toLowerCase() === "n") && this.emit("confirm", u.toLowerCase() === "y"), u === " " && this.opts.placeholder && (this.value || (this.rl.write(this.opts.placeholder), this.emit("value", this.opts.placeholder))), u && this.emit("key", u.toLowerCase()), F?.name === "return") {
|
|
227291
227617
|
if (this.opts.validate) {
|
|
227292
227618
|
const t = this.opts.validate(this.value);
|
|
227293
227619
|
t && (this.error = t, this.state = "error", this.rl.write(this.value));
|
|
@@ -227498,7 +227824,7 @@ var M2 = o("\u25FB", "[ ]");
|
|
|
227498
227824
|
var U2 = o("\u25AA", "\u2022");
|
|
227499
227825
|
var B = o("\u2500", "-");
|
|
227500
227826
|
var Z2 = o("\u256E", "+");
|
|
227501
|
-
var
|
|
227827
|
+
var z25 = o("\u251C", "+");
|
|
227502
227828
|
var X2 = o("\u256F", "+");
|
|
227503
227829
|
var J2 = o("\u25CF", "\u2022");
|
|
227504
227830
|
var Y2 = o("\u25C6", "*");
|
|
@@ -228360,34 +228686,35 @@ import { promisify } from "util";
|
|
|
228360
228686
|
|
|
228361
228687
|
// ../mcp/dist/index.js
|
|
228362
228688
|
import { spawn } from "child_process";
|
|
228363
|
-
import {
|
|
228689
|
+
import { createHash as createHash4 } from "crypto";
|
|
228690
|
+
import { z as z26 } from "zod";
|
|
228364
228691
|
var MCP_REQUEST_TIMEOUT_MS = 3e4;
|
|
228365
228692
|
var MCP_STDIO_LINE_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
228366
228693
|
var MCP_STDERR_LIMIT_CHARS = 4e3;
|
|
228367
|
-
var MCPToolDefinitionSchema =
|
|
228368
|
-
name:
|
|
228369
|
-
description:
|
|
228370
|
-
inputSchema:
|
|
228694
|
+
var MCPToolDefinitionSchema = z26.object({
|
|
228695
|
+
name: z26.string().min(1).max(512),
|
|
228696
|
+
description: z26.string().max(1e4).default(""),
|
|
228697
|
+
inputSchema: z26.record(z26.unknown()).default({})
|
|
228371
228698
|
});
|
|
228372
|
-
var MCPToolsListSchema =
|
|
228373
|
-
tools:
|
|
228699
|
+
var MCPToolsListSchema = z26.object({
|
|
228700
|
+
tools: z26.array(MCPToolDefinitionSchema).max(1e4).default([])
|
|
228374
228701
|
});
|
|
228375
|
-
var MCPToolCallResultSchema =
|
|
228376
|
-
content:
|
|
228377
|
-
|
|
228378
|
-
type:
|
|
228379
|
-
text:
|
|
228702
|
+
var MCPToolCallResultSchema = z26.object({
|
|
228703
|
+
content: z26.array(
|
|
228704
|
+
z26.object({
|
|
228705
|
+
type: z26.string().max(100),
|
|
228706
|
+
text: z26.string().max(MCP_STDIO_LINE_LIMIT_BYTES).optional()
|
|
228380
228707
|
}).passthrough()
|
|
228381
228708
|
).max(1e4).default([]),
|
|
228382
|
-
isError:
|
|
228709
|
+
isError: z26.boolean().default(false)
|
|
228383
228710
|
}).passthrough();
|
|
228384
|
-
var MCPResponseSchema =
|
|
228385
|
-
jsonrpc:
|
|
228386
|
-
id:
|
|
228387
|
-
result:
|
|
228388
|
-
error:
|
|
228389
|
-
code:
|
|
228390
|
-
message:
|
|
228711
|
+
var MCPResponseSchema = z26.object({
|
|
228712
|
+
jsonrpc: z26.literal("2.0"),
|
|
228713
|
+
id: z26.number().int().positive(),
|
|
228714
|
+
result: z26.unknown().optional(),
|
|
228715
|
+
error: z26.object({
|
|
228716
|
+
code: z26.number().int(),
|
|
228717
|
+
message: z26.string().max(1e4)
|
|
228391
228718
|
}).passthrough().optional()
|
|
228392
228719
|
}).refine((message) => message.result !== void 0 || message.error, {
|
|
228393
228720
|
message: "MCP response requires a result or error."
|
|
@@ -228484,14 +228811,18 @@ var MCPClient = class {
|
|
|
228484
228811
|
}
|
|
228485
228812
|
}
|
|
228486
228813
|
/** Call one validated MCP tool with JSON-object arguments. */
|
|
228487
|
-
async callTool(originalToolName, args) {
|
|
228814
|
+
async callTool(originalToolName, args, abortSignal) {
|
|
228488
228815
|
if (!this.isConnected) {
|
|
228489
228816
|
throw new Error(`MCP client "${this.serverName}" is not connected.`);
|
|
228490
228817
|
}
|
|
228491
|
-
const result = await this.sendRequest(
|
|
228492
|
-
|
|
228493
|
-
|
|
228494
|
-
|
|
228818
|
+
const result = await this.sendRequest(
|
|
228819
|
+
"tools/call",
|
|
228820
|
+
{
|
|
228821
|
+
name: originalToolName,
|
|
228822
|
+
arguments: args
|
|
228823
|
+
},
|
|
228824
|
+
abortSignal
|
|
228825
|
+
);
|
|
228495
228826
|
return MCPToolCallResultSchema.parse(result);
|
|
228496
228827
|
}
|
|
228497
228828
|
/** Stop the child and reject outstanding requests. */
|
|
@@ -228525,8 +228856,12 @@ var MCPClient = class {
|
|
|
228525
228856
|
);
|
|
228526
228857
|
return result.tools;
|
|
228527
228858
|
}
|
|
228528
|
-
sendRequest(method, params) {
|
|
228859
|
+
sendRequest(method, params, abortSignal) {
|
|
228529
228860
|
return new Promise((resolve15, reject) => {
|
|
228861
|
+
if (abortSignal?.aborted) {
|
|
228862
|
+
reject(createAbortError(`MCP request "${method}" was cancelled.`));
|
|
228863
|
+
return;
|
|
228864
|
+
}
|
|
228530
228865
|
const stdin = this.child?.stdin;
|
|
228531
228866
|
if (!this.isConnected || !stdin || !stdin.writable) {
|
|
228532
228867
|
reject(new Error("MCP server process is not running."));
|
|
@@ -228534,14 +228869,37 @@ var MCPClient = class {
|
|
|
228534
228869
|
}
|
|
228535
228870
|
const id = this.nextRequestId++;
|
|
228536
228871
|
const timeout = setTimeout(() => {
|
|
228872
|
+
const pending = this.pendingRequests.get(id);
|
|
228537
228873
|
this.pendingRequests.delete(id);
|
|
228874
|
+
pending?.removeAbortListener?.();
|
|
228538
228875
|
reject(
|
|
228539
228876
|
new Error(
|
|
228540
228877
|
`MCP request "${method}" (id: ${id}) timed out after ${MCP_REQUEST_TIMEOUT_MS}ms.`
|
|
228541
228878
|
)
|
|
228542
228879
|
);
|
|
228543
228880
|
}, MCP_REQUEST_TIMEOUT_MS);
|
|
228544
|
-
|
|
228881
|
+
const onAbort = () => {
|
|
228882
|
+
const pending = this.pendingRequests.get(id);
|
|
228883
|
+
if (!pending) return;
|
|
228884
|
+
clearTimeout(pending.timeout);
|
|
228885
|
+
this.pendingRequests.delete(id);
|
|
228886
|
+
pending.removeAbortListener?.();
|
|
228887
|
+
this.sendNotification("notifications/cancelled", {
|
|
228888
|
+
requestId: id,
|
|
228889
|
+
reason: "Orbit tool execution cancelled"
|
|
228890
|
+
});
|
|
228891
|
+
pending.reject(
|
|
228892
|
+
createAbortError(`MCP request "${method}" was cancelled.`)
|
|
228893
|
+
);
|
|
228894
|
+
};
|
|
228895
|
+
const removeAbortListener = abortSignal ? () => abortSignal.removeEventListener("abort", onAbort) : void 0;
|
|
228896
|
+
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
228897
|
+
this.pendingRequests.set(id, {
|
|
228898
|
+
resolve: resolve15,
|
|
228899
|
+
reject,
|
|
228900
|
+
timeout,
|
|
228901
|
+
removeAbortListener
|
|
228902
|
+
});
|
|
228545
228903
|
stdin.write(
|
|
228546
228904
|
`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
228547
228905
|
`,
|
|
@@ -228551,6 +228909,7 @@ var MCPClient = class {
|
|
|
228551
228909
|
if (!pending) return;
|
|
228552
228910
|
clearTimeout(pending.timeout);
|
|
228553
228911
|
this.pendingRequests.delete(id);
|
|
228912
|
+
pending.removeAbortListener?.();
|
|
228554
228913
|
pending.reject(
|
|
228555
228914
|
new Error(`Unable to write MCP request: ${safeMessage(error)}`)
|
|
228556
228915
|
);
|
|
@@ -228593,6 +228952,7 @@ var MCPClient = class {
|
|
|
228593
228952
|
if (!pending) return;
|
|
228594
228953
|
clearTimeout(pending.timeout);
|
|
228595
228954
|
this.pendingRequests.delete(response.id);
|
|
228955
|
+
pending.removeAbortListener?.();
|
|
228596
228956
|
if (response.error) {
|
|
228597
228957
|
pending.reject(
|
|
228598
228958
|
new Error(
|
|
@@ -228607,6 +228967,7 @@ var MCPClient = class {
|
|
|
228607
228967
|
this.isConnected = false;
|
|
228608
228968
|
for (const pending of this.pendingRequests.values()) {
|
|
228609
228969
|
clearTimeout(pending.timeout);
|
|
228970
|
+
pending.removeAbortListener?.();
|
|
228610
228971
|
pending.reject(error);
|
|
228611
228972
|
}
|
|
228612
228973
|
this.pendingRequests.clear();
|
|
@@ -228619,20 +228980,26 @@ function safeMessage(error) {
|
|
|
228619
228980
|
var DynamicMCPTool = class {
|
|
228620
228981
|
constructor(serverName, toolDefinition, risk, client) {
|
|
228621
228982
|
this.client = client;
|
|
228622
|
-
this.name =
|
|
228983
|
+
this.name = createMcpToolName(serverName, toolDefinition.name);
|
|
228623
228984
|
this.description = `[MCP Tool: ${serverName}] ${toolDefinition.description}`;
|
|
228624
228985
|
this.risk = risk;
|
|
228625
228986
|
this.originalToolName = toolDefinition.name;
|
|
228987
|
+
this.inputJsonSchema = toolDefinition.inputSchema;
|
|
228626
228988
|
}
|
|
228627
228989
|
client;
|
|
228628
228990
|
name;
|
|
228629
228991
|
description;
|
|
228630
|
-
inputSchema =
|
|
228992
|
+
inputSchema = z26.record(z26.unknown());
|
|
228993
|
+
inputJsonSchema;
|
|
228631
228994
|
risk;
|
|
228632
228995
|
originalToolName;
|
|
228633
|
-
async execute(input,
|
|
228996
|
+
async execute(input, context) {
|
|
228634
228997
|
try {
|
|
228635
|
-
const response = await this.client.callTool(
|
|
228998
|
+
const response = await this.client.callTool(
|
|
228999
|
+
this.originalToolName,
|
|
229000
|
+
input,
|
|
229001
|
+
context.abortSignal
|
|
229002
|
+
);
|
|
228636
229003
|
const text = response.content.map((content) => content.text || "").filter(Boolean).join("\n");
|
|
228637
229004
|
if (response.isError) {
|
|
228638
229005
|
return {
|
|
@@ -228649,6 +229016,19 @@ var DynamicMCPTool = class {
|
|
|
228649
229016
|
}
|
|
228650
229017
|
}
|
|
228651
229018
|
};
|
|
229019
|
+
function createMcpToolName(serverName, originalToolName) {
|
|
229020
|
+
const rawName = `mcp__${serverName}__${originalToolName}`;
|
|
229021
|
+
if (/^[A-Za-z0-9_-]{1,64}$/.test(rawName)) return rawName;
|
|
229022
|
+
const normalized = rawName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
229023
|
+
const digest = createHash4("sha256").update(rawName).digest("hex").slice(0, 8);
|
|
229024
|
+
const prefix = (normalized || "mcp_tool").slice(0, 55).replace(/_+$/g, "");
|
|
229025
|
+
return `${prefix}_${digest}`;
|
|
229026
|
+
}
|
|
229027
|
+
function createAbortError(message) {
|
|
229028
|
+
const error = new Error(message);
|
|
229029
|
+
error.name = "AbortError";
|
|
229030
|
+
return error;
|
|
229031
|
+
}
|
|
228652
229032
|
|
|
228653
229033
|
// ../core/dist/index.js
|
|
228654
229034
|
import { createHash as createHash32 } from "crypto";
|
|
@@ -228752,6 +229132,13 @@ var PermissionEngine = class {
|
|
|
228752
229132
|
"multi_replace_file_content"
|
|
228753
229133
|
]);
|
|
228754
229134
|
const safeArgs = isRecord2(args) ? args : {};
|
|
229135
|
+
if (toolName === "update_plan") {
|
|
229136
|
+
return {
|
|
229137
|
+
action: "allow",
|
|
229138
|
+
reason: "Updating the current chat plan does not modify project files.",
|
|
229139
|
+
risk: "write"
|
|
229140
|
+
};
|
|
229141
|
+
}
|
|
228755
229142
|
if (readTools.has(toolName) || writeTools.has(toolName)) {
|
|
228756
229143
|
targetPath = firstString(
|
|
228757
229144
|
safeArgs.path,
|
|
@@ -228894,8 +229281,8 @@ function firstString(...values) {
|
|
|
228894
229281
|
}
|
|
228895
229282
|
|
|
228896
229283
|
// ../session/dist/index.js
|
|
228897
|
-
import { z as
|
|
228898
|
-
import { createHash as
|
|
229284
|
+
import { z as z27 } from "zod";
|
|
229285
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "crypto";
|
|
228899
229286
|
import { isAbsolute as isAbsolute4, join as join11, relative as relative2, resolve as resolve6, sep } from "path";
|
|
228900
229287
|
import {
|
|
228901
229288
|
appendFileSync,
|
|
@@ -228925,89 +229312,89 @@ import {
|
|
|
228925
229312
|
} from "fs";
|
|
228926
229313
|
import { homedir as homedir5 } from "os";
|
|
228927
229314
|
import { basename as basename4, isAbsolute as isAbsolute22, join as join25, parse as parse2, resolve as resolve23 } from "path";
|
|
228928
|
-
import { z as
|
|
228929
|
-
var SafeObjectKeySchema =
|
|
229315
|
+
import { z as z28 } from "zod";
|
|
229316
|
+
var SafeObjectKeySchema = z27.string().refine(
|
|
228930
229317
|
(key) => !["__proto__", "constructor", "prototype"].includes(key),
|
|
228931
229318
|
"Unsafe object key."
|
|
228932
229319
|
);
|
|
228933
|
-
var JsonValueSchema =
|
|
228934
|
-
() =>
|
|
228935
|
-
|
|
228936
|
-
|
|
228937
|
-
|
|
228938
|
-
|
|
228939
|
-
|
|
228940
|
-
|
|
229320
|
+
var JsonValueSchema = z27.lazy(
|
|
229321
|
+
() => z27.union([
|
|
229322
|
+
z27.string(),
|
|
229323
|
+
z27.number().finite(),
|
|
229324
|
+
z27.boolean(),
|
|
229325
|
+
z27.null(),
|
|
229326
|
+
z27.array(JsonValueSchema),
|
|
229327
|
+
z27.record(SafeObjectKeySchema, JsonValueSchema)
|
|
228941
229328
|
])
|
|
228942
229329
|
);
|
|
228943
|
-
var JsonTextSchema =
|
|
229330
|
+
var JsonTextSchema = z27.string().superRefine((value, context) => {
|
|
228944
229331
|
try {
|
|
228945
229332
|
const parsed = JSON.parse(value);
|
|
228946
229333
|
if (JsonValueSchema.safeParse(parsed).success) return;
|
|
228947
229334
|
} catch {
|
|
228948
229335
|
}
|
|
228949
229336
|
context.addIssue({
|
|
228950
|
-
code:
|
|
229337
|
+
code: z27.ZodIssueCode.custom,
|
|
228951
229338
|
message: "Expected valid, safe JSON text."
|
|
228952
229339
|
});
|
|
228953
229340
|
});
|
|
228954
|
-
var SessionIdSchema =
|
|
228955
|
-
var SessionSchema =
|
|
228956
|
-
schemaVersion:
|
|
229341
|
+
var SessionIdSchema = z27.string().regex(/^sess_[a-z]+-[a-z]+-\d{3}$/, "Invalid Orbit session id.");
|
|
229342
|
+
var SessionSchema = z27.object({
|
|
229343
|
+
schemaVersion: z27.literal(1).default(1),
|
|
228957
229344
|
id: SessionIdSchema,
|
|
228958
|
-
cwd:
|
|
228959
|
-
title:
|
|
228960
|
-
goal:
|
|
228961
|
-
status:
|
|
228962
|
-
createdAt:
|
|
228963
|
-
updatedAt:
|
|
228964
|
-
provider:
|
|
228965
|
-
model:
|
|
228966
|
-
totalInputTokens:
|
|
228967
|
-
totalOutputTokens:
|
|
228968
|
-
totalCostEstimate:
|
|
228969
|
-
totalCacheReadTokens:
|
|
228970
|
-
archivedAt:
|
|
229345
|
+
cwd: z27.string().min(1),
|
|
229346
|
+
title: z27.string(),
|
|
229347
|
+
goal: z27.string().trim().min(1).max(4e3).optional(),
|
|
229348
|
+
status: z27.enum(["active", "completed", "failed", "aborted"]),
|
|
229349
|
+
createdAt: z27.string().datetime(),
|
|
229350
|
+
updatedAt: z27.string().datetime(),
|
|
229351
|
+
provider: z27.string().min(1),
|
|
229352
|
+
model: z27.string().min(1),
|
|
229353
|
+
totalInputTokens: z27.number().int().nonnegative(),
|
|
229354
|
+
totalOutputTokens: z27.number().int().nonnegative(),
|
|
229355
|
+
totalCostEstimate: z27.number().finite().nonnegative(),
|
|
229356
|
+
totalCacheReadTokens: z27.number().int().nonnegative().optional(),
|
|
229357
|
+
archivedAt: z27.string().datetime().optional()
|
|
228971
229358
|
});
|
|
228972
|
-
var SessionEventSchema =
|
|
228973
|
-
id:
|
|
229359
|
+
var SessionEventSchema = z27.object({
|
|
229360
|
+
id: z27.string().min(1),
|
|
228974
229361
|
sessionId: SessionIdSchema,
|
|
228975
|
-
type:
|
|
229362
|
+
type: z27.string().min(1),
|
|
228976
229363
|
payload: JsonValueSchema,
|
|
228977
|
-
createdAt:
|
|
229364
|
+
createdAt: z27.string().datetime()
|
|
228978
229365
|
});
|
|
228979
|
-
var TaskPlanItemSchema =
|
|
228980
|
-
id:
|
|
228981
|
-
text:
|
|
228982
|
-
status:
|
|
228983
|
-
createdAt:
|
|
228984
|
-
updatedAt:
|
|
229366
|
+
var TaskPlanItemSchema = z27.object({
|
|
229367
|
+
id: z27.string().regex(/^step_[a-z0-9-]+$/, "Invalid task-plan item id."),
|
|
229368
|
+
text: z27.string().trim().min(1).max(1e3),
|
|
229369
|
+
status: z27.enum(["pending", "in_progress", "completed"]),
|
|
229370
|
+
createdAt: z27.string().datetime(),
|
|
229371
|
+
updatedAt: z27.string().datetime()
|
|
228985
229372
|
});
|
|
228986
|
-
var TaskPlanSchema =
|
|
228987
|
-
schemaVersion:
|
|
229373
|
+
var TaskPlanSchema = z27.object({
|
|
229374
|
+
schemaVersion: z27.literal(1).default(1),
|
|
228988
229375
|
sessionId: SessionIdSchema,
|
|
228989
|
-
goal:
|
|
228990
|
-
items:
|
|
228991
|
-
updatedAt:
|
|
229376
|
+
goal: z27.string().trim().min(1).max(4e3).optional(),
|
|
229377
|
+
items: z27.array(TaskPlanItemSchema).max(100),
|
|
229378
|
+
updatedAt: z27.string().datetime()
|
|
228992
229379
|
});
|
|
228993
|
-
var SessionMetricsSchema =
|
|
229380
|
+
var SessionMetricsSchema = z27.object({
|
|
228994
229381
|
sessionId: SessionIdSchema,
|
|
228995
|
-
eventCount:
|
|
228996
|
-
toolRuns:
|
|
228997
|
-
toolFailures:
|
|
228998
|
-
deniedTools:
|
|
228999
|
-
filesChanged:
|
|
229000
|
-
modelSwitches:
|
|
229001
|
-
routingDecisions:
|
|
229002
|
-
fastRoutes:
|
|
229003
|
-
qualityRoutes:
|
|
229004
|
-
compactions:
|
|
229005
|
-
resumedCount:
|
|
229382
|
+
eventCount: z27.number().int().nonnegative(),
|
|
229383
|
+
toolRuns: z27.number().int().nonnegative(),
|
|
229384
|
+
toolFailures: z27.number().int().nonnegative(),
|
|
229385
|
+
deniedTools: z27.number().int().nonnegative(),
|
|
229386
|
+
filesChanged: z27.number().int().nonnegative(),
|
|
229387
|
+
modelSwitches: z27.number().int().nonnegative(),
|
|
229388
|
+
routingDecisions: z27.number().int().nonnegative(),
|
|
229389
|
+
fastRoutes: z27.number().int().nonnegative(),
|
|
229390
|
+
qualityRoutes: z27.number().int().nonnegative(),
|
|
229391
|
+
compactions: z27.number().int().nonnegative(),
|
|
229392
|
+
resumedCount: z27.number().int().nonnegative()
|
|
229006
229393
|
});
|
|
229007
|
-
var RunJournalSchema =
|
|
229008
|
-
schemaVersion:
|
|
229394
|
+
var RunJournalSchema = z27.object({
|
|
229395
|
+
schemaVersion: z27.literal(1).default(1),
|
|
229009
229396
|
sessionId: SessionIdSchema,
|
|
229010
|
-
state:
|
|
229397
|
+
state: z27.enum([
|
|
229011
229398
|
"running",
|
|
229012
229399
|
"awaiting_approval",
|
|
229013
229400
|
"verifying",
|
|
@@ -229016,83 +229403,83 @@ var RunJournalSchema = z25.object({
|
|
|
229016
229403
|
"aborted",
|
|
229017
229404
|
"interrupted"
|
|
229018
229405
|
]),
|
|
229019
|
-
phase:
|
|
229020
|
-
attempt:
|
|
229021
|
-
activeToolCallId:
|
|
229022
|
-
startedAt:
|
|
229023
|
-
updatedAt:
|
|
229024
|
-
recoveryCount:
|
|
229406
|
+
phase: z27.string().trim().min(1).max(200),
|
|
229407
|
+
attempt: z27.number().int().nonnegative().default(0),
|
|
229408
|
+
activeToolCallId: z27.string().min(1).max(512).optional(),
|
|
229409
|
+
startedAt: z27.string().datetime(),
|
|
229410
|
+
updatedAt: z27.string().datetime(),
|
|
229411
|
+
recoveryCount: z27.number().int().nonnegative().default(0)
|
|
229025
229412
|
});
|
|
229026
|
-
var StoredToolCallSchema =
|
|
229027
|
-
id:
|
|
229028
|
-
name:
|
|
229413
|
+
var StoredToolCallSchema = z27.object({
|
|
229414
|
+
id: z27.string().min(1),
|
|
229415
|
+
name: z27.string().min(1),
|
|
229029
229416
|
arguments: JsonTextSchema
|
|
229030
229417
|
});
|
|
229031
|
-
var StoredToolResultSchema =
|
|
229032
|
-
toolCallId:
|
|
229033
|
-
name:
|
|
229034
|
-
content:
|
|
229035
|
-
isError:
|
|
229418
|
+
var StoredToolResultSchema = z27.object({
|
|
229419
|
+
toolCallId: z27.string().min(1),
|
|
229420
|
+
name: z27.string().min(1),
|
|
229421
|
+
content: z27.string(),
|
|
229422
|
+
isError: z27.boolean().optional()
|
|
229036
229423
|
});
|
|
229037
|
-
var StoredContentBlockSchema =
|
|
229038
|
-
|
|
229039
|
-
|
|
229040
|
-
|
|
229041
|
-
type:
|
|
229424
|
+
var StoredContentBlockSchema = z27.discriminatedUnion("type", [
|
|
229425
|
+
z27.object({ type: z27.literal("text"), text: z27.string() }),
|
|
229426
|
+
z27.object({ type: z27.literal("tool_call"), toolCall: StoredToolCallSchema }),
|
|
229427
|
+
z27.object({
|
|
229428
|
+
type: z27.literal("tool_result"),
|
|
229042
229429
|
toolResult: StoredToolResultSchema
|
|
229043
229430
|
}),
|
|
229044
|
-
|
|
229045
|
-
type:
|
|
229046
|
-
text:
|
|
229047
|
-
signature:
|
|
229431
|
+
z27.object({
|
|
229432
|
+
type: z27.literal("thinking"),
|
|
229433
|
+
text: z27.string(),
|
|
229434
|
+
signature: z27.string().optional()
|
|
229048
229435
|
})
|
|
229049
229436
|
]);
|
|
229050
|
-
var StoredHistoryMessageSchema =
|
|
229051
|
-
id:
|
|
229052
|
-
role:
|
|
229053
|
-
content:
|
|
229054
|
-
createdAt:
|
|
229055
|
-
metadata:
|
|
229437
|
+
var StoredHistoryMessageSchema = z27.object({
|
|
229438
|
+
id: z27.string().min(1),
|
|
229439
|
+
role: z27.enum(["system", "user", "assistant", "tool"]),
|
|
229440
|
+
content: z27.array(StoredContentBlockSchema),
|
|
229441
|
+
createdAt: z27.string().datetime(),
|
|
229442
|
+
metadata: z27.record(SafeObjectKeySchema, JsonValueSchema).optional()
|
|
229056
229443
|
});
|
|
229057
|
-
var StoredHistorySchema =
|
|
229058
|
-
var ToolCallRecordSchema =
|
|
229059
|
-
id:
|
|
229444
|
+
var StoredHistorySchema = z27.array(StoredHistoryMessageSchema);
|
|
229445
|
+
var ToolCallRecordSchema = z27.object({
|
|
229446
|
+
id: z27.string().min(1),
|
|
229060
229447
|
sessionId: SessionIdSchema,
|
|
229061
|
-
toolName:
|
|
229448
|
+
toolName: z27.string().min(1),
|
|
229062
229449
|
inputJson: JsonTextSchema,
|
|
229063
229450
|
outputJson: JsonTextSchema.optional(),
|
|
229064
|
-
risk:
|
|
229065
|
-
permissionDecision:
|
|
229066
|
-
status:
|
|
229067
|
-
startedAt:
|
|
229068
|
-
endedAt:
|
|
229451
|
+
risk: z27.string().min(1),
|
|
229452
|
+
permissionDecision: z27.string().min(1),
|
|
229453
|
+
status: z27.enum(["pending", "success", "failed", "denied"]),
|
|
229454
|
+
startedAt: z27.string().datetime(),
|
|
229455
|
+
endedAt: z27.string().datetime().optional()
|
|
229069
229456
|
});
|
|
229070
|
-
var FileChangeRecordSchema =
|
|
229071
|
-
id:
|
|
229457
|
+
var FileChangeRecordSchema = z27.object({
|
|
229458
|
+
id: z27.string().min(1),
|
|
229072
229459
|
sessionId: SessionIdSchema,
|
|
229073
|
-
path:
|
|
229074
|
-
beforeHash:
|
|
229075
|
-
afterHash:
|
|
229076
|
-
diff:
|
|
229077
|
-
createdAt:
|
|
229460
|
+
path: z27.string().min(1),
|
|
229461
|
+
beforeHash: z27.string().optional(),
|
|
229462
|
+
afterHash: z27.string().optional(),
|
|
229463
|
+
diff: z27.string(),
|
|
229464
|
+
createdAt: z27.string().datetime()
|
|
229078
229465
|
});
|
|
229079
|
-
var SessionTraceBundleSchema =
|
|
229080
|
-
schemaVersion:
|
|
229081
|
-
exportedAt:
|
|
229082
|
-
workspace:
|
|
229083
|
-
id:
|
|
229084
|
-
path:
|
|
229466
|
+
var SessionTraceBundleSchema = z27.object({
|
|
229467
|
+
schemaVersion: z27.literal(1),
|
|
229468
|
+
exportedAt: z27.string().datetime(),
|
|
229469
|
+
workspace: z27.object({
|
|
229470
|
+
id: z27.string().regex(/^[a-f0-9]{16}$/),
|
|
229471
|
+
path: z27.literal("<workspace>")
|
|
229085
229472
|
}),
|
|
229086
229473
|
session: SessionSchema.omit({ cwd: true }).extend({
|
|
229087
|
-
cwd:
|
|
229474
|
+
cwd: z27.literal("<workspace>")
|
|
229088
229475
|
}),
|
|
229089
229476
|
journal: RunJournalSchema.optional(),
|
|
229090
229477
|
plan: TaskPlanSchema.optional(),
|
|
229091
229478
|
metrics: SessionMetricsSchema,
|
|
229092
|
-
events:
|
|
229093
|
-
toolCalls:
|
|
229094
|
-
fileChanges:
|
|
229095
|
-
history:
|
|
229479
|
+
events: z27.array(SessionEventSchema),
|
|
229480
|
+
toolCalls: z27.array(ToolCallRecordSchema),
|
|
229481
|
+
fileChanges: z27.array(FileChangeRecordSchema),
|
|
229482
|
+
history: z27.array(JsonValueSchema).optional()
|
|
229096
229483
|
});
|
|
229097
229484
|
var CREDENTIAL_ASSIGNMENT_PATTERN = /(\b(?:api[-_]?key|authorization|credentials?|password|passwd|secret|access[-_]?token|refresh[-_]?token|auth[-_]?token|bearer[-_]?token|session[-_]?token|client[-_]?secret|private[-_]?key|cookie)\b\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;}]*)/gi;
|
|
229098
229485
|
var SENSITIVE_KEY_PATTERN2 = /(?:^|_)(?:api_key|authorization|credentials?|password|passwd|secret|access_token|refresh_token|auth_token|bearer_token|session_token|client_secret|private_key|cookie)(?:$|_)/;
|
|
@@ -229529,7 +229916,7 @@ var SessionStore = class {
|
|
|
229529
229916
|
schemaVersion: 1,
|
|
229530
229917
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
229531
229918
|
workspace: {
|
|
229532
|
-
id:
|
|
229919
|
+
id: createHash5("sha256").update(this.cwd).digest("hex").slice(0, 16),
|
|
229533
229920
|
path: "<workspace>"
|
|
229534
229921
|
},
|
|
229535
229922
|
session: {
|
|
@@ -229896,21 +230283,21 @@ var SessionManager = class {
|
|
|
229896
230283
|
var PRIVATE_DIRECTORY_MODE2 = 448;
|
|
229897
230284
|
var PRIVATE_FILE_MODE2 = 384;
|
|
229898
230285
|
var MAX_PROJECTS = 200;
|
|
229899
|
-
var ProjectRecordSchema =
|
|
229900
|
-
id:
|
|
229901
|
-
path:
|
|
229902
|
-
name:
|
|
229903
|
-
createdAt:
|
|
229904
|
-
lastOpenedAt:
|
|
229905
|
-
lastSessionId:
|
|
229906
|
-
archivedAt:
|
|
230286
|
+
var ProjectRecordSchema = z28.object({
|
|
230287
|
+
id: z28.string().regex(/^proj_[a-f0-9]{16}$/),
|
|
230288
|
+
path: z28.string().min(1).max(4096).refine((value) => !/[\u0000-\u001f\u007f]/.test(value)),
|
|
230289
|
+
name: z28.string().trim().min(1).max(200),
|
|
230290
|
+
createdAt: z28.string().datetime(),
|
|
230291
|
+
lastOpenedAt: z28.string().datetime(),
|
|
230292
|
+
lastSessionId: z28.string().min(1).optional(),
|
|
230293
|
+
archivedAt: z28.string().datetime().optional()
|
|
229907
230294
|
});
|
|
229908
|
-
var ProjectRegistrySnapshotSchema =
|
|
229909
|
-
schemaVersion:
|
|
229910
|
-
projects:
|
|
230295
|
+
var ProjectRegistrySnapshotSchema = z28.object({
|
|
230296
|
+
schemaVersion: z28.literal(1),
|
|
230297
|
+
projects: z28.array(ProjectRecordSchema).max(MAX_PROJECTS)
|
|
229911
230298
|
});
|
|
229912
|
-
var LegacyProjectRegistrySnapshotSchema =
|
|
229913
|
-
projects:
|
|
230299
|
+
var LegacyProjectRegistrySnapshotSchema = z28.object({
|
|
230300
|
+
projects: z28.array(ProjectRecordSchema).max(MAX_PROJECTS)
|
|
229914
230301
|
});
|
|
229915
230302
|
function parseProjectRegistrySnapshot(value) {
|
|
229916
230303
|
const current = ProjectRegistrySnapshotSchema.safeParse(value);
|
|
@@ -230263,25 +230650,25 @@ ${this.normalizeContextText(options.repoMapText)}` : "",
|
|
|
230263
230650
|
);
|
|
230264
230651
|
}
|
|
230265
230652
|
};
|
|
230266
|
-
var PromptCacheTelemetrySampleSchema =
|
|
230267
|
-
recordedAt:
|
|
230268
|
-
inputTokens:
|
|
230269
|
-
hitTokens:
|
|
230270
|
-
missTokens:
|
|
230271
|
-
hitRate:
|
|
230272
|
-
degraded:
|
|
230653
|
+
var PromptCacheTelemetrySampleSchema = z29.object({
|
|
230654
|
+
recordedAt: z29.string(),
|
|
230655
|
+
inputTokens: z29.number().int().nonnegative(),
|
|
230656
|
+
hitTokens: z29.number().int().nonnegative(),
|
|
230657
|
+
missTokens: z29.number().int().nonnegative(),
|
|
230658
|
+
hitRate: z29.number().min(0).max(1),
|
|
230659
|
+
degraded: z29.boolean()
|
|
230273
230660
|
});
|
|
230274
|
-
var PromptCacheSlabMetadataSchema =
|
|
230275
|
-
hash:
|
|
230276
|
-
model:
|
|
230277
|
-
tokenEstimate:
|
|
230278
|
-
lastPrimedAt:
|
|
230279
|
-
telemetry:
|
|
230661
|
+
var PromptCacheSlabMetadataSchema = z29.object({
|
|
230662
|
+
hash: z29.string().optional(),
|
|
230663
|
+
model: z29.string().optional(),
|
|
230664
|
+
tokenEstimate: z29.number().int().nonnegative().optional(),
|
|
230665
|
+
lastPrimedAt: z29.string().optional(),
|
|
230666
|
+
telemetry: z29.array(PromptCacheTelemetrySampleSchema).max(100).optional()
|
|
230280
230667
|
}).passthrough();
|
|
230281
230668
|
var PromptCacheSlabBuilder = class {
|
|
230282
230669
|
static build(input) {
|
|
230283
230670
|
const stableText = this.buildStableText(input);
|
|
230284
|
-
const hash =
|
|
230671
|
+
const hash = createHash6("sha256").update(stableText).digest("hex");
|
|
230285
230672
|
const slabPath = join12(
|
|
230286
230673
|
input.cwd,
|
|
230287
230674
|
".orbit",
|
|
@@ -230635,16 +231022,16 @@ function truncateVolatileContextToBudget(sourceHistory, targetTokens) {
|
|
|
230635
231022
|
}
|
|
230636
231023
|
return { history, truncated };
|
|
230637
231024
|
}
|
|
230638
|
-
var RoutingInputSchema =
|
|
230639
|
-
query:
|
|
230640
|
-
defaultModel:
|
|
230641
|
-
fastModel:
|
|
230642
|
-
qualityModel:
|
|
230643
|
-
lockedModel:
|
|
230644
|
-
fallbackModel:
|
|
230645
|
-
activeModel:
|
|
230646
|
-
repairTurn:
|
|
230647
|
-
hasWrittenFiles:
|
|
231025
|
+
var RoutingInputSchema = z210.object({
|
|
231026
|
+
query: z210.string(),
|
|
231027
|
+
defaultModel: z210.string().min(1),
|
|
231028
|
+
fastModel: z210.string().min(1).optional(),
|
|
231029
|
+
qualityModel: z210.string().min(1).optional(),
|
|
231030
|
+
lockedModel: z210.string().min(1).optional(),
|
|
231031
|
+
fallbackModel: z210.string().min(1).optional(),
|
|
231032
|
+
activeModel: z210.string().min(1).optional(),
|
|
231033
|
+
repairTurn: z210.boolean().default(false),
|
|
231034
|
+
hasWrittenFiles: z210.boolean().default(false)
|
|
230648
231035
|
});
|
|
230649
231036
|
var COMPLEX_SIGNALS = [
|
|
230650
231037
|
"debug",
|
|
@@ -230766,15 +231153,23 @@ function decision(model, lane, reason, confidence) {
|
|
|
230766
231153
|
return { model, lane, reason, confidence };
|
|
230767
231154
|
}
|
|
230768
231155
|
var StepRunner = class {
|
|
230769
|
-
constructor(cwd, sessionId, config) {
|
|
231156
|
+
constructor(cwd, sessionId, config, services) {
|
|
230770
231157
|
this.cwd = cwd;
|
|
230771
231158
|
this.sessionId = sessionId;
|
|
230772
231159
|
this.config = config;
|
|
231160
|
+
this.services = services;
|
|
230773
231161
|
}
|
|
230774
231162
|
cwd;
|
|
230775
231163
|
sessionId;
|
|
230776
231164
|
config;
|
|
231165
|
+
services;
|
|
230777
231166
|
async run(toolCall, abortSignal) {
|
|
231167
|
+
if (abortSignal?.aborted) {
|
|
231168
|
+
return {
|
|
231169
|
+
ok: false,
|
|
231170
|
+
error: "Tool execution was cancelled before it started."
|
|
231171
|
+
};
|
|
231172
|
+
}
|
|
230778
231173
|
const tool = toolRegistry.get(toolCall.name);
|
|
230779
231174
|
if (!tool) {
|
|
230780
231175
|
return {
|
|
@@ -230816,7 +231211,8 @@ var StepRunner = class {
|
|
|
230816
231211
|
cwd: this.cwd,
|
|
230817
231212
|
sessionId: this.sessionId,
|
|
230818
231213
|
config: this.config,
|
|
230819
|
-
abortSignal: timeoutController.signal
|
|
231214
|
+
abortSignal: timeoutController.signal,
|
|
231215
|
+
services: this.services
|
|
230820
231216
|
});
|
|
230821
231217
|
return result;
|
|
230822
231218
|
} catch (error) {
|
|
@@ -230826,6 +231222,12 @@ var StepRunner = class {
|
|
|
230826
231222
|
error: `Tool execution timed out after ${timeoutMs}ms. Command tree was terminated.`
|
|
230827
231223
|
};
|
|
230828
231224
|
}
|
|
231225
|
+
if (abortSignal?.aborted) {
|
|
231226
|
+
return {
|
|
231227
|
+
ok: false,
|
|
231228
|
+
error: "Tool execution was cancelled by the user."
|
|
231229
|
+
};
|
|
231230
|
+
}
|
|
230829
231231
|
return {
|
|
230830
231232
|
ok: false,
|
|
230831
231233
|
error: `Tool execution threw exception: ${getErrorMessage(error)}`
|
|
@@ -230914,7 +231316,7 @@ Core rules:
|
|
|
230914
231316
|
1. Understand the project before editing.
|
|
230915
231317
|
2. Prefer minimal, precise changes.
|
|
230916
231318
|
3. Never modify files blindly.
|
|
230917
|
-
4. Before large changes, produce a short plan.
|
|
231319
|
+
4. Before large changes, produce a short plan and keep it current with update_plan. Skip plan bookkeeping for simple one-step requests.
|
|
230918
231320
|
5. When editing code, preserve existing style and architecture.
|
|
230919
231321
|
6. After changes, run relevant tests or explain why tests were not run.
|
|
230920
231322
|
7. Never read or expose secrets unless explicitly approved by the user.
|
|
@@ -230924,7 +231326,7 @@ Core rules:
|
|
|
230924
231326
|
11. Do not claim success unless verification passed.
|
|
230925
231327
|
12. If verification fails, explain the failure clearly and propose next steps.
|
|
230926
231328
|
13. Keep your answers concise, practical, and highly focused.
|
|
230927
|
-
14. Use the runtime date from the Volatile Context for all relative-date requests. For current weather, news, prices, laws, schedules, API/model information, or any other time-sensitive facts, search the live web instead of relying on model training memory.`;
|
|
231329
|
+
14. Use the runtime date from the Volatile Context for all relative-date requests. For current weather, news, prices, laws, schedules, API/model information, or any other time-sensitive facts, search the live web instead of relying on model training memory: use web_search first, then web_fetch when a result's full source text is needed.`;
|
|
230928
231330
|
if (supportsThinking) {
|
|
230929
231331
|
return prompt + "\n15. Since you are a reasoning model, utilize your internal reasoning tokens to deeply analyze the codebase structure, potential side-effects of edits, and root causes of errors before making any tool calls. Keep your final output extremely concise, direct, and avoid repeating the reasoning process in your response.\n16. CRITICAL: Never output <tool_call> or SEARCH/REPLACE blocks inside your reasoning/thinking block. All tool calls and code edits must be placed strictly in your final response text.";
|
|
230930
231332
|
}
|
|
@@ -231327,6 +231729,23 @@ function generateXMLToolsPrompt(tools) {
|
|
|
231327
231729
|
` - \`${key}\`: (type: ${field.typeName}${field.isOptional ? ", optional" : ""}${values})${description}`
|
|
231328
231730
|
);
|
|
231329
231731
|
}
|
|
231732
|
+
} else if (tool.inputJsonSchema) {
|
|
231733
|
+
const properties = tool.inputJsonSchema.properties;
|
|
231734
|
+
const required = new Set(
|
|
231735
|
+
Array.isArray(tool.inputJsonSchema.required) ? tool.inputJsonSchema.required.filter(
|
|
231736
|
+
(value) => typeof value === "string"
|
|
231737
|
+
) : []
|
|
231738
|
+
);
|
|
231739
|
+
if (properties && typeof properties === "object") {
|
|
231740
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
231741
|
+
const property = value && typeof value === "object" ? value : {};
|
|
231742
|
+
const typeName = typeof property.type === "string" ? property.type : "unknown";
|
|
231743
|
+
const description = typeof property.description === "string" ? ` - ${property.description.replace(/\s+/g, " ").trim()}` : "";
|
|
231744
|
+
lines.push(
|
|
231745
|
+
` - \`${key}\`: (type: ${typeName}${required.has(key) ? "" : ", optional"})${description}`
|
|
231746
|
+
);
|
|
231747
|
+
}
|
|
231748
|
+
}
|
|
231330
231749
|
}
|
|
231331
231750
|
lines.push("");
|
|
231332
231751
|
}
|
|
@@ -231478,10 +231897,9 @@ var McpRuntimeManager = class {
|
|
|
231478
231897
|
};
|
|
231479
231898
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
231480
231899
|
const client = this.createClient(serverName, serverConfig);
|
|
231900
|
+
const registeredForClient = [];
|
|
231481
231901
|
try {
|
|
231482
231902
|
const tools = await client.start();
|
|
231483
|
-
this.clients.push(client);
|
|
231484
|
-
result.startedServers += 1;
|
|
231485
231903
|
for (const toolDefinition of tools) {
|
|
231486
231904
|
const risk = serverConfig.tools?.[toolDefinition.name]?.risk ?? "execute";
|
|
231487
231905
|
const dynamicTool = new DynamicMCPTool(
|
|
@@ -231490,12 +231908,25 @@ var McpRuntimeManager = class {
|
|
|
231490
231908
|
risk,
|
|
231491
231909
|
client
|
|
231492
231910
|
);
|
|
231911
|
+
if (this.registry.get(dynamicTool.name)) {
|
|
231912
|
+
throw new Error(
|
|
231913
|
+
`MCP tool name collision after normalization: "${dynamicTool.name}". Rename the server or remote tool.`
|
|
231914
|
+
);
|
|
231915
|
+
}
|
|
231493
231916
|
this.registry.register(dynamicTool);
|
|
231494
231917
|
this.registeredToolNames.add(dynamicTool.name);
|
|
231918
|
+
registeredForClient.push(dynamicTool.name);
|
|
231495
231919
|
result.registeredTools += 1;
|
|
231496
231920
|
report(` \u2714 Registered MCP tool: ${dynamicTool.name} (${risk})`);
|
|
231497
231921
|
}
|
|
231922
|
+
this.clients.push(client);
|
|
231923
|
+
result.startedServers += 1;
|
|
231498
231924
|
} catch (error) {
|
|
231925
|
+
for (const toolName of registeredForClient) {
|
|
231926
|
+
this.registry.unregister(toolName);
|
|
231927
|
+
this.registeredToolNames.delete(toolName);
|
|
231928
|
+
result.registeredTools -= 1;
|
|
231929
|
+
}
|
|
231499
231930
|
await client.stop().catch(() => void 0);
|
|
231500
231931
|
const message = safeMcpRuntimeMessage(error);
|
|
231501
231932
|
result.failures.push({ serverName, message });
|
|
@@ -231864,7 +232295,9 @@ function initializeAgentSession(cwd, config, provider, task, options = {}) {
|
|
|
231864
232295
|
rollbackManager: new RollbackManager(cwd),
|
|
231865
232296
|
permissionEngine: new PermissionEngine(config),
|
|
231866
232297
|
contextBuilder: new ContextPackBuilder(cwd),
|
|
231867
|
-
stepRunner: new StepRunner(cwd, session.id, config
|
|
232298
|
+
stepRunner: new StepRunner(cwd, session.id, config, {
|
|
232299
|
+
updatePlan: (update) => updateSessionTaskPlan(sessionManager, update)
|
|
232300
|
+
}),
|
|
231868
232301
|
verificationManager: new VerificationContractManager(
|
|
231869
232302
|
cwd,
|
|
231870
232303
|
session.id,
|
|
@@ -231881,6 +232314,28 @@ function initializeAgentSession(cwd, config, provider, task, options = {}) {
|
|
|
231881
232314
|
totalCacheReadTokens: session.totalCacheReadTokens || 0
|
|
231882
232315
|
};
|
|
231883
232316
|
}
|
|
232317
|
+
function updateSessionTaskPlan(sessionManager, update) {
|
|
232318
|
+
const existing = sessionManager.getTaskPlan();
|
|
232319
|
+
const available = [...existing?.items ?? []];
|
|
232320
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
232321
|
+
const items = update.plan.map((entry) => {
|
|
232322
|
+
const matchIndex = available.findIndex((item) => item.text === entry.step);
|
|
232323
|
+
const previous = matchIndex >= 0 ? available.splice(matchIndex, 1)[0] : void 0;
|
|
232324
|
+
return {
|
|
232325
|
+
id: previous?.id ?? `step_${createHash32("sha256").update(`${entry.step}\0${now}`).digest("hex").slice(0, 16)}`,
|
|
232326
|
+
text: entry.step,
|
|
232327
|
+
status: entry.status,
|
|
232328
|
+
createdAt: previous?.createdAt ?? now,
|
|
232329
|
+
updatedAt: previous?.status === entry.status ? previous.updatedAt : now
|
|
232330
|
+
};
|
|
232331
|
+
});
|
|
232332
|
+
const saved = sessionManager.saveTaskPlan(items, existing?.goal);
|
|
232333
|
+
sessionManager.logEvent("model_task_plan_update", {
|
|
232334
|
+
explanation: update.explanation?.slice(0, 1e3),
|
|
232335
|
+
itemCount: items.length
|
|
232336
|
+
});
|
|
232337
|
+
return saved;
|
|
232338
|
+
}
|
|
231884
232339
|
function restoreSessionHistory(sessionManager, state) {
|
|
231885
232340
|
const savedHistory = sessionManager.getHistory();
|
|
231886
232341
|
if (savedHistory.length === 0) return;
|
|
@@ -231909,6 +232364,8 @@ var DEEPSEEK_VERBOSE_CACHE_ENV = "ORBIT_DEEPSEEK_VERBOSE_CACHE";
|
|
|
231909
232364
|
var NETWORK_TOOL_RESULT_MAX_RESULTS = 10;
|
|
231910
232365
|
var NETWORK_TOOL_RESULT_SUMMARY_CHARS = 280;
|
|
231911
232366
|
var NETWORK_TOOL_RESULT_MAX_CHARS = 6e3;
|
|
232367
|
+
var TOOL_RESULT_MAX_CHARS = 24e3;
|
|
232368
|
+
var TOOL_STATUS_MAX_CHARS = 2e3;
|
|
231912
232369
|
var AGENT_LOOP_ERROR_MESSAGE_MAX_CHARS = 2e3;
|
|
231913
232370
|
var AgentLoopExecutionError = class extends Error {
|
|
231914
232371
|
constructor(code, message) {
|
|
@@ -232021,20 +232478,23 @@ var AgentLoop = class _AgentLoop {
|
|
|
232021
232478
|
return Math.max(10, Math.min(20, Math.floor(this.state.maxAttempts / 2)));
|
|
232022
232479
|
}
|
|
232023
232480
|
getReusableApprovalScope(toolName, risk) {
|
|
232024
|
-
if (toolName === "web_search" && risk === "network") {
|
|
232025
|
-
return "network:
|
|
232481
|
+
if ((toolName === "web_search" || toolName === "web_fetch") && risk === "network") {
|
|
232482
|
+
return "network:web";
|
|
232026
232483
|
}
|
|
232027
232484
|
return null;
|
|
232028
232485
|
}
|
|
232029
232486
|
buildToolResultContent(toolName, result) {
|
|
232030
232487
|
const content = result.ok ? this.serializeToolResultData(result.data, result.display) : result.error || "Unknown error";
|
|
232031
232488
|
if (!result.ok || toolName !== "web_search") {
|
|
232032
|
-
return
|
|
232489
|
+
return this.truncatePlain(
|
|
232490
|
+
redactSecrets(content),
|
|
232491
|
+
result.ok ? TOOL_RESULT_MAX_CHARS : TOOL_STATUS_MAX_CHARS
|
|
232492
|
+
);
|
|
232033
232493
|
}
|
|
232034
232494
|
return this.compactNetworkToolResult(
|
|
232035
232495
|
toolName,
|
|
232036
|
-
content,
|
|
232037
|
-
result.display || ""
|
|
232496
|
+
redactSecrets(content),
|
|
232497
|
+
redactSecrets(result.display || "")
|
|
232038
232498
|
);
|
|
232039
232499
|
}
|
|
232040
232500
|
serializeToolResultData(data, display) {
|
|
@@ -232341,7 +232801,9 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232341
232801
|
}
|
|
232342
232802
|
let toolDefs = toolRegistry.getDefinitions();
|
|
232343
232803
|
if (!this.config.tools.webSearch.enabled) {
|
|
232344
|
-
toolDefs = toolDefs.filter(
|
|
232804
|
+
toolDefs = toolDefs.filter(
|
|
232805
|
+
(tool) => tool.name !== "web_search" && tool.name !== "web_fetch"
|
|
232806
|
+
);
|
|
232345
232807
|
}
|
|
232346
232808
|
if (!this.config.tools.bash.enabled) {
|
|
232347
232809
|
toolDefs = toolDefs.filter(
|
|
@@ -232452,6 +232914,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232452
232914
|
let resolvedModel;
|
|
232453
232915
|
let providerRequestId;
|
|
232454
232916
|
const toolCallsToExecute = [];
|
|
232917
|
+
const toolCallProtocolErrors = /* @__PURE__ */ new Map();
|
|
232455
232918
|
try {
|
|
232456
232919
|
for await (const event of stream) {
|
|
232457
232920
|
this.statusBar.stop();
|
|
@@ -232565,6 +233028,39 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232565
233028
|
}
|
|
232566
233029
|
}
|
|
232567
233030
|
}
|
|
233031
|
+
if (toolCallsToExecute.length > 1) {
|
|
233032
|
+
const seenToolCallIds = /* @__PURE__ */ new Set();
|
|
233033
|
+
const uniqueToolCalls = [];
|
|
233034
|
+
for (const toolCall of toolCallsToExecute) {
|
|
233035
|
+
if (seenToolCallIds.has(toolCall.id)) {
|
|
233036
|
+
const message = `Ignored duplicate tool call id "${toolCall.id}" from the model response.`;
|
|
233037
|
+
this.interaction.showText(picocolors8.yellow(`\u26A0 ${message}`));
|
|
233038
|
+
this.sessionManager.logEvent("duplicate_tool_call_ignored", {
|
|
233039
|
+
toolCallId: toolCall.id,
|
|
233040
|
+
toolName: toolCall.name
|
|
233041
|
+
});
|
|
233042
|
+
continue;
|
|
233043
|
+
}
|
|
233044
|
+
seenToolCallIds.add(toolCall.id);
|
|
233045
|
+
uniqueToolCalls.push(toolCall);
|
|
233046
|
+
}
|
|
233047
|
+
toolCallsToExecute.splice(
|
|
233048
|
+
0,
|
|
233049
|
+
toolCallsToExecute.length,
|
|
233050
|
+
...uniqueToolCalls
|
|
233051
|
+
);
|
|
233052
|
+
}
|
|
233053
|
+
for (const toolCall of toolCallsToExecute) {
|
|
233054
|
+
try {
|
|
233055
|
+
JSON.parse(toolCall.arguments);
|
|
233056
|
+
} catch (error) {
|
|
233057
|
+
toolCallProtocolErrors.set(
|
|
233058
|
+
toolCall.id,
|
|
233059
|
+
`Tool input JSON parse failed: ${safeAgentLoopErrorMessage(error)}`
|
|
233060
|
+
);
|
|
233061
|
+
toolCall.arguments = "{}";
|
|
233062
|
+
}
|
|
233063
|
+
}
|
|
232568
233064
|
eventBus.emitEvent("model_response", {
|
|
232569
233065
|
model: activeModel2,
|
|
232570
233066
|
requestedModel: activeModel2,
|
|
@@ -232836,6 +233332,32 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232836
233332
|
break;
|
|
232837
233333
|
}
|
|
232838
233334
|
const toolResultBlocks = [];
|
|
233335
|
+
const rejectInvalidToolCall = (toolCall, message, risk = "read") => {
|
|
233336
|
+
const error = safeAgentLoopErrorMessage(message);
|
|
233337
|
+
this.interaction.showText(` ${picocolors8.red("\u2716")} ${error}`);
|
|
233338
|
+
eventBus.emitEvent("tool_result", {
|
|
233339
|
+
toolCallId: toolCall.id,
|
|
233340
|
+
toolName: toolCall.name,
|
|
233341
|
+
error
|
|
233342
|
+
});
|
|
233343
|
+
toolResultBlocks.push({
|
|
233344
|
+
type: "tool_result",
|
|
233345
|
+
toolResult: {
|
|
233346
|
+
toolCallId: toolCall.id,
|
|
233347
|
+
name: toolCall.name,
|
|
233348
|
+
content: error,
|
|
233349
|
+
isError: true
|
|
233350
|
+
}
|
|
233351
|
+
});
|
|
233352
|
+
this.sessionManager.recordToolExecution(
|
|
233353
|
+
toolCall.name,
|
|
233354
|
+
toolCall,
|
|
233355
|
+
{ ok: false, error },
|
|
233356
|
+
risk,
|
|
233357
|
+
"invalid",
|
|
233358
|
+
"failed"
|
|
233359
|
+
);
|
|
233360
|
+
};
|
|
232839
233361
|
for (const tc of toolCallsToExecute) {
|
|
232840
233362
|
let argSummary = "";
|
|
232841
233363
|
try {
|
|
@@ -232870,8 +233392,41 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232870
233392
|
${picocolors8.cyan("\u2726")} ${picocolors8.bold(picocolors8.white(tc.name))} ${picocolors8.gray(argSummary)}`
|
|
232871
233393
|
);
|
|
232872
233394
|
const registeredTool = toolRegistry.get(tc.name);
|
|
233395
|
+
if (!registeredTool) {
|
|
233396
|
+
rejectInvalidToolCall(
|
|
233397
|
+
tc,
|
|
233398
|
+
`Tool "${tc.name}" was not found in the registry.`
|
|
233399
|
+
);
|
|
233400
|
+
continue;
|
|
233401
|
+
}
|
|
232873
233402
|
const declaredRisk = registeredTool?.risk;
|
|
232874
|
-
const
|
|
233403
|
+
const protocolError = toolCallProtocolErrors.get(tc.id);
|
|
233404
|
+
if (protocolError) {
|
|
233405
|
+
rejectInvalidToolCall(tc, protocolError, declaredRisk);
|
|
233406
|
+
continue;
|
|
233407
|
+
}
|
|
233408
|
+
let preflightArgs;
|
|
233409
|
+
try {
|
|
233410
|
+
preflightArgs = JSON.parse(tc.arguments);
|
|
233411
|
+
} catch (error) {
|
|
233412
|
+
rejectInvalidToolCall(
|
|
233413
|
+
tc,
|
|
233414
|
+
`Tool input JSON parse failed: ${safeAgentLoopErrorMessage(error)}`,
|
|
233415
|
+
declaredRisk
|
|
233416
|
+
);
|
|
233417
|
+
continue;
|
|
233418
|
+
}
|
|
233419
|
+
const validation = registeredTool.inputSchema.safeParse(preflightArgs);
|
|
233420
|
+
if (!validation.success) {
|
|
233421
|
+
rejectInvalidToolCall(
|
|
233422
|
+
tc,
|
|
233423
|
+
`Tool input validation failed: ${validation.error.message}`,
|
|
233424
|
+
declaredRisk
|
|
233425
|
+
);
|
|
233426
|
+
continue;
|
|
233427
|
+
}
|
|
233428
|
+
const evalArgs = validation.data;
|
|
233429
|
+
const evalArgsRecord = toUnknownRecord(evalArgs);
|
|
232875
233430
|
eventBus.emitEvent("tool_proposal", {
|
|
232876
233431
|
toolCallId: tc.id,
|
|
232877
233432
|
toolName: tc.name,
|
|
@@ -232883,7 +233438,12 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232883
233438
|
declaredRisk
|
|
232884
233439
|
);
|
|
232885
233440
|
if (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content") {
|
|
232886
|
-
const targetPath2 =
|
|
233441
|
+
const targetPath2 = firstStringValue(
|
|
233442
|
+
evalArgsRecord.path,
|
|
233443
|
+
evalArgsRecord.TargetFile,
|
|
233444
|
+
evalArgsRecord.filePath,
|
|
233445
|
+
evalArgsRecord.file
|
|
233446
|
+
);
|
|
232887
233447
|
if (targetPath2) {
|
|
232888
233448
|
const relPath = path4.relative(this.cwd, path4.resolve(this.cwd, targetPath2)).replace(/\\/g, "/");
|
|
232889
233449
|
const foundFile = this.state.relevantFiles.find(
|
|
@@ -233026,9 +233586,9 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
233026
233586
|
try {
|
|
233027
233587
|
const parsed = JSON.parse(edited);
|
|
233028
233588
|
if (registeredTool && registeredTool.inputSchema) {
|
|
233029
|
-
const
|
|
233030
|
-
if (!
|
|
233031
|
-
const errorMsgs =
|
|
233589
|
+
const validation2 = registeredTool.inputSchema.safeParse(parsed);
|
|
233590
|
+
if (!validation2.success) {
|
|
233591
|
+
const errorMsgs = validation2.error.errors.map(
|
|
233032
233592
|
(e2) => `${e2.path.join(".") || "root"}: ${e2.message}`
|
|
233033
233593
|
).join(", ");
|
|
233034
233594
|
this.interaction.showText(
|
|
@@ -233856,8 +234416,12 @@ ${stdout.substring(0, 2e4)}`
|
|
|
233856
234416
|
status
|
|
233857
234417
|
);
|
|
233858
234418
|
if (finalResult.ok) {
|
|
234419
|
+
const statusText = this.truncatePlain(
|
|
234420
|
+
redactSecrets(finalResult.display || "Done"),
|
|
234421
|
+
TOOL_STATUS_MAX_CHARS
|
|
234422
|
+
);
|
|
233859
234423
|
this.interaction.showText(
|
|
233860
|
-
` ${picocolors8.green("\u2714")} Success: ${picocolors8.gray(
|
|
234424
|
+
` ${picocolors8.green("\u2714")} Success: ${picocolors8.gray(statusText)}`
|
|
233861
234425
|
);
|
|
233862
234426
|
if (targetPath) {
|
|
233863
234427
|
this.addRelevantFile(targetPath, `Modified by ${tc.name}`);
|
|
@@ -233867,8 +234431,12 @@ ${stdout.substring(0, 2e4)}`
|
|
|
233867
234431
|
});
|
|
233868
234432
|
}
|
|
233869
234433
|
} else {
|
|
234434
|
+
const statusError = this.truncatePlain(
|
|
234435
|
+
redactSecrets(finalResult.error || "Unknown error"),
|
|
234436
|
+
TOOL_STATUS_MAX_CHARS
|
|
234437
|
+
);
|
|
233870
234438
|
this.interaction.showText(
|
|
233871
|
-
` ${picocolors8.red("\u2716")} Failed: ${picocolors8.red(
|
|
234439
|
+
` ${picocolors8.red("\u2716")} Failed: ${picocolors8.red(statusError)}`
|
|
233872
234440
|
);
|
|
233873
234441
|
}
|
|
233874
234442
|
eventBus.emitEvent("tool_result", {
|
|
@@ -234729,6 +235297,12 @@ ${diff.substring(0, 2e4)}`
|
|
|
234729
235297
|
}
|
|
234730
235298
|
}
|
|
234731
235299
|
};
|
|
235300
|
+
function toUnknownRecord(value) {
|
|
235301
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
235302
|
+
}
|
|
235303
|
+
function firstStringValue(...values) {
|
|
235304
|
+
return values.find((value) => typeof value === "string");
|
|
235305
|
+
}
|
|
234732
235306
|
var AgentTaskGraphSchema = z83.array(
|
|
234733
235307
|
z83.object({
|
|
234734
235308
|
id: z83.string().min(1).max(128),
|
|
@@ -235833,103 +236407,293 @@ import readline3 from "readline";
|
|
|
235833
236407
|
|
|
235834
236408
|
// src/runtime/SlashCommandCatalog.ts
|
|
235835
236409
|
import picocolors9 from "picocolors";
|
|
235836
|
-
var
|
|
235837
|
-
|
|
235838
|
-
|
|
235839
|
-
|
|
235840
|
-
|
|
235841
|
-
|
|
235842
|
-
|
|
235843
|
-
|
|
235844
|
-
|
|
235845
|
-
|
|
235846
|
-
|
|
235847
|
-
|
|
235848
|
-
|
|
235849
|
-
|
|
235850
|
-
|
|
235851
|
-
|
|
235852
|
-
|
|
235853
|
-
|
|
235854
|
-
|
|
235855
|
-
|
|
235856
|
-
|
|
235857
|
-
|
|
235858
|
-
|
|
235859
|
-
|
|
235860
|
-
|
|
236410
|
+
var SLASH_COMMAND_DEFINITIONS = [
|
|
236411
|
+
{
|
|
236412
|
+
command: "/help",
|
|
236413
|
+
usage: "",
|
|
236414
|
+
category: "system",
|
|
236415
|
+
description: {
|
|
236416
|
+
en: "Show all commands and usage",
|
|
236417
|
+
zh: "\u663E\u793A\u5168\u90E8\u547D\u4EE4\u4E0E\u7528\u6CD5"
|
|
236418
|
+
},
|
|
236419
|
+
webSuggested: true
|
|
236420
|
+
},
|
|
236421
|
+
{
|
|
236422
|
+
command: "/status",
|
|
236423
|
+
usage: "",
|
|
236424
|
+
category: "settings",
|
|
236425
|
+
description: {
|
|
236426
|
+
en: "Show the active session, model, context, and cost",
|
|
236427
|
+
zh: "\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u3001\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D39\u7528"
|
|
236428
|
+
},
|
|
236429
|
+
webSuggested: true
|
|
236430
|
+
},
|
|
236431
|
+
{
|
|
236432
|
+
command: "/goal",
|
|
236433
|
+
usage: "[objective]",
|
|
236434
|
+
category: "session",
|
|
236435
|
+
description: {
|
|
236436
|
+
en: "Show or set this chat's durable goal; use clear to remove",
|
|
236437
|
+
zh: "\u67E5\u770B\u6216\u8BBE\u7F6E\u5F53\u524D\u804A\u5929\u7684\u6301\u7EED\u76EE\u6807\uFF1B\u4F7F\u7528 clear \u6E05\u9664"
|
|
236438
|
+
},
|
|
236439
|
+
webSuggested: true
|
|
236440
|
+
},
|
|
236441
|
+
{
|
|
236442
|
+
command: "/rename",
|
|
236443
|
+
usage: "<title>",
|
|
236444
|
+
category: "session",
|
|
236445
|
+
description: { en: "Rename the current chat", zh: "\u91CD\u547D\u540D\u5F53\u524D\u804A\u5929" },
|
|
236446
|
+
webSuggested: true
|
|
236447
|
+
},
|
|
236448
|
+
{
|
|
236449
|
+
command: "/memory",
|
|
236450
|
+
usage: "[action]",
|
|
236451
|
+
category: "session",
|
|
236452
|
+
description: {
|
|
236453
|
+
en: "Review and manage explicit project memory",
|
|
236454
|
+
zh: "\u5BA1\u67E5\u548C\u7BA1\u7406\u9879\u76EE\u7EA7\u663E\u5F0F\u8BB0\u5FC6"
|
|
236455
|
+
},
|
|
236456
|
+
webSuggested: true
|
|
236457
|
+
},
|
|
236458
|
+
{
|
|
236459
|
+
command: "/plan",
|
|
236460
|
+
usage: "[action]",
|
|
236461
|
+
category: "session",
|
|
236462
|
+
description: {
|
|
236463
|
+
en: "Manage this chat's recoverable task plan",
|
|
236464
|
+
zh: "\u7BA1\u7406\u5F53\u524D\u804A\u5929\u53EF\u6062\u590D\u7684\u4EFB\u52A1\u8BA1\u5212"
|
|
236465
|
+
},
|
|
236466
|
+
webSuggested: true
|
|
236467
|
+
},
|
|
236468
|
+
{
|
|
236469
|
+
command: "/metrics",
|
|
236470
|
+
usage: "",
|
|
236471
|
+
category: "settings",
|
|
236472
|
+
description: {
|
|
236473
|
+
en: "Show local runtime and reliability metrics",
|
|
236474
|
+
zh: "\u67E5\u770B\u672C\u5730\u8FD0\u884C\u4E0E\u53EF\u9760\u6027\u6307\u6807"
|
|
236475
|
+
},
|
|
236476
|
+
webSuggested: true
|
|
236477
|
+
},
|
|
236478
|
+
{
|
|
236479
|
+
command: "/doctor",
|
|
236480
|
+
usage: "",
|
|
236481
|
+
category: "settings",
|
|
236482
|
+
description: {
|
|
236483
|
+
en: "Diagnose runtime, models, web, skills, and safety",
|
|
236484
|
+
zh: "\u8BCA\u65AD\u8FD0\u884C\u73AF\u5883\u3001\u6A21\u578B\u3001\u8054\u7F51\u3001\u6280\u80FD\u4E0E\u5B89\u5168\u914D\u7F6E"
|
|
236485
|
+
},
|
|
236486
|
+
webSuggested: true
|
|
236487
|
+
},
|
|
236488
|
+
{
|
|
236489
|
+
command: "/config",
|
|
236490
|
+
usage: "[key=value]",
|
|
236491
|
+
category: "settings",
|
|
236492
|
+
description: {
|
|
236493
|
+
en: "View or update Orbit configuration",
|
|
236494
|
+
zh: "\u67E5\u770B\u6216\u66F4\u65B0 Orbit \u914D\u7F6E"
|
|
236495
|
+
},
|
|
236496
|
+
webSuggested: true
|
|
236497
|
+
},
|
|
236498
|
+
{
|
|
236499
|
+
command: "/model",
|
|
236500
|
+
usage: "[name]",
|
|
236501
|
+
category: "settings",
|
|
236502
|
+
description: {
|
|
236503
|
+
en: "Show or switch the active model",
|
|
236504
|
+
zh: "\u67E5\u770B\u6216\u5207\u6362\u5F53\u524D\u6A21\u578B"
|
|
236505
|
+
},
|
|
236506
|
+
webSuggested: true
|
|
236507
|
+
},
|
|
236508
|
+
{
|
|
236509
|
+
command: "/chat",
|
|
236510
|
+
usage: "[action]",
|
|
236511
|
+
category: "session",
|
|
236512
|
+
description: {
|
|
236513
|
+
en: "List, create, delete, or switch chats",
|
|
236514
|
+
zh: "\u5217\u51FA\u3001\u65B0\u5EFA\u3001\u5220\u9664\u6216\u5207\u6362\u804A\u5929"
|
|
236515
|
+
},
|
|
236516
|
+
webSuggested: true
|
|
236517
|
+
},
|
|
236518
|
+
{
|
|
236519
|
+
command: "/commit",
|
|
236520
|
+
usage: "[message]",
|
|
236521
|
+
category: "git",
|
|
236522
|
+
description: {
|
|
236523
|
+
en: "Stage workspace changes and create a commit",
|
|
236524
|
+
zh: "\u6682\u5B58\u5DE5\u4F5C\u533A\u4FEE\u6539\u5E76\u521B\u5EFA\u63D0\u4EA4"
|
|
236525
|
+
},
|
|
236526
|
+
webSuggested: true
|
|
236527
|
+
},
|
|
236528
|
+
{
|
|
236529
|
+
command: "/exit",
|
|
236530
|
+
usage: "",
|
|
236531
|
+
category: "system",
|
|
236532
|
+
description: { en: "Exit the interactive terminal", zh: "\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF" },
|
|
236533
|
+
webSuggested: false
|
|
236534
|
+
},
|
|
236535
|
+
{
|
|
236536
|
+
command: "/quit",
|
|
236537
|
+
usage: "",
|
|
236538
|
+
category: "system",
|
|
236539
|
+
description: { en: "Exit the interactive terminal", zh: "\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF" },
|
|
236540
|
+
webSuggested: false
|
|
236541
|
+
},
|
|
236542
|
+
{
|
|
236543
|
+
command: "/rollback",
|
|
236544
|
+
usage: "",
|
|
236545
|
+
category: "session",
|
|
236546
|
+
description: {
|
|
236547
|
+
en: "Restore the latest file modification checkpoint",
|
|
236548
|
+
zh: "\u6062\u590D\u6700\u8FD1\u4E00\u6B21\u6587\u4EF6\u4FEE\u6539\u68C0\u67E5\u70B9"
|
|
236549
|
+
},
|
|
236550
|
+
webSuggested: true
|
|
236551
|
+
},
|
|
236552
|
+
{
|
|
236553
|
+
command: "/timeline",
|
|
236554
|
+
usage: "",
|
|
236555
|
+
category: "session",
|
|
236556
|
+
description: {
|
|
236557
|
+
en: "List persisted file checkpoints for this chat",
|
|
236558
|
+
zh: "\u5217\u51FA\u5F53\u524D\u804A\u5929\u6301\u4E45\u5316\u7684\u6587\u4EF6\u68C0\u67E5\u70B9"
|
|
236559
|
+
},
|
|
236560
|
+
webSuggested: true
|
|
236561
|
+
},
|
|
236562
|
+
{
|
|
236563
|
+
command: "/rewind",
|
|
236564
|
+
usage: "<id|number>",
|
|
236565
|
+
category: "session",
|
|
236566
|
+
description: {
|
|
236567
|
+
en: "Rewind this chat to a selected file checkpoint",
|
|
236568
|
+
zh: "\u5C06\u5F53\u524D\u804A\u5929\u56DE\u9000\u5230\u6307\u5B9A\u6587\u4EF6\u68C0\u67E5\u70B9"
|
|
236569
|
+
},
|
|
236570
|
+
webSuggested: true
|
|
236571
|
+
},
|
|
236572
|
+
{
|
|
236573
|
+
command: "/compact",
|
|
236574
|
+
usage: "",
|
|
236575
|
+
category: "context",
|
|
236576
|
+
description: {
|
|
236577
|
+
en: "Compact older dialogue against the active model window",
|
|
236578
|
+
zh: "\u6309\u5F53\u524D\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\u538B\u7F29\u65E7\u5BF9\u8BDD"
|
|
236579
|
+
},
|
|
236580
|
+
webSuggested: true
|
|
236581
|
+
},
|
|
236582
|
+
{
|
|
236583
|
+
command: "/clear",
|
|
236584
|
+
usage: "",
|
|
236585
|
+
category: "context",
|
|
236586
|
+
description: {
|
|
236587
|
+
en: "Reset dialogue history and clear the conversation view",
|
|
236588
|
+
zh: "\u91CD\u7F6E\u5BF9\u8BDD\u5386\u53F2\u5E76\u6E05\u7A7A\u4F1A\u8BDD\u89C6\u56FE"
|
|
236589
|
+
},
|
|
236590
|
+
webSuggested: true
|
|
236591
|
+
},
|
|
236592
|
+
{
|
|
236593
|
+
command: "/add",
|
|
236594
|
+
usage: "<file>",
|
|
236595
|
+
category: "context",
|
|
236596
|
+
description: {
|
|
236597
|
+
en: "Add a file or directory to active context",
|
|
236598
|
+
zh: "\u5C06\u6587\u4EF6\u6216\u76EE\u5F55\u52A0\u5165\u6D3B\u52A8\u4E0A\u4E0B\u6587"
|
|
236599
|
+
},
|
|
236600
|
+
webSuggested: true
|
|
236601
|
+
},
|
|
236602
|
+
{
|
|
236603
|
+
command: "/drop",
|
|
236604
|
+
usage: "<file>",
|
|
236605
|
+
category: "context",
|
|
236606
|
+
description: {
|
|
236607
|
+
en: "Remove a file or pattern from active context",
|
|
236608
|
+
zh: "\u4ECE\u6D3B\u52A8\u4E0A\u4E0B\u6587\u79FB\u9664\u6587\u4EF6\u6216\u901A\u914D\u7B26"
|
|
236609
|
+
},
|
|
236610
|
+
webSuggested: true
|
|
236611
|
+
},
|
|
236612
|
+
{
|
|
236613
|
+
command: "/mode",
|
|
236614
|
+
usage: "[mode]",
|
|
236615
|
+
category: "settings",
|
|
236616
|
+
description: {
|
|
236617
|
+
en: "Switch permission mode: strict, normal, auto, or plan",
|
|
236618
|
+
zh: "\u5207\u6362\u6743\u9650\u6A21\u5F0F\uFF1Astrict\u3001normal\u3001auto \u6216 plan"
|
|
236619
|
+
},
|
|
236620
|
+
webSuggested: true
|
|
236621
|
+
},
|
|
236622
|
+
{
|
|
236623
|
+
command: "/copy",
|
|
236624
|
+
usage: "",
|
|
236625
|
+
category: "session",
|
|
236626
|
+
description: {
|
|
236627
|
+
en: "Copy the latest Orbit reply",
|
|
236628
|
+
zh: "\u590D\u5236 Orbit \u7684\u6700\u65B0\u56DE\u590D"
|
|
236629
|
+
},
|
|
236630
|
+
webSuggested: true
|
|
236631
|
+
},
|
|
236632
|
+
{
|
|
236633
|
+
command: "/run",
|
|
236634
|
+
usage: "<command>",
|
|
236635
|
+
category: "system",
|
|
236636
|
+
description: {
|
|
236637
|
+
en: "Run a native shell command after permission checks",
|
|
236638
|
+
zh: "\u7ECF\u8FC7\u6743\u9650\u68C0\u67E5\u540E\u8FD0\u884C\u672C\u5730 Shell \u547D\u4EE4"
|
|
236639
|
+
},
|
|
236640
|
+
webSuggested: true
|
|
236641
|
+
},
|
|
236642
|
+
{
|
|
236643
|
+
command: "/update",
|
|
236644
|
+
usage: "",
|
|
236645
|
+
category: "settings",
|
|
236646
|
+
description: {
|
|
236647
|
+
en: "Check and update Orbit from npm",
|
|
236648
|
+
zh: "\u4ECE npm \u68C0\u67E5\u5E76\u66F4\u65B0 Orbit"
|
|
236649
|
+
},
|
|
236650
|
+
webSuggested: true
|
|
236651
|
+
},
|
|
236652
|
+
{
|
|
236653
|
+
command: "/webui",
|
|
236654
|
+
usage: "[port]",
|
|
236655
|
+
category: "settings",
|
|
236656
|
+
description: {
|
|
236657
|
+
en: "Open the Orbit graphical console",
|
|
236658
|
+
zh: "\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0"
|
|
236659
|
+
},
|
|
236660
|
+
webSuggested: false
|
|
236661
|
+
}
|
|
235861
236662
|
];
|
|
236663
|
+
var BUILTIN_SLASH_COMMANDS = SLASH_COMMAND_DEFINITIONS.map(
|
|
236664
|
+
({ command }) => command
|
|
236665
|
+
);
|
|
236666
|
+
var CATEGORY_LABELS = {
|
|
236667
|
+
context: { en: "Context Management", zh: "\u4E0A\u4E0B\u6587\u7BA1\u7406" },
|
|
236668
|
+
session: { en: "Session & History", zh: "\u4F1A\u8BDD\u4E0E\u5386\u53F2" },
|
|
236669
|
+
settings: { en: "Configuration & Status", zh: "\u914D\u7F6E\u4E0E\u72B6\u6001" },
|
|
236670
|
+
git: { en: "Git Version Control", zh: "Git \u63D0\u4EA4" },
|
|
236671
|
+
system: { en: "System Control", zh: "\u7CFB\u7EDF\u63A7\u5236" }
|
|
236672
|
+
};
|
|
235862
236673
|
function buildSlashCommandHelp(isZh) {
|
|
235863
|
-
|
|
235864
|
-
|
|
235865
|
-
|
|
235866
|
-
|
|
235867
|
-
|
|
235868
|
-
|
|
235869
|
-
|
|
235870
|
-
|
|
235871
|
-
|
|
235872
|
-
|
|
235873
|
-
|
|
235874
|
-
|
|
235875
|
-
|
|
235876
|
-
|
|
235877
|
-
|
|
235878
|
-
|
|
235879
|
-
""
|
|
235880
|
-
|
|
235881
|
-
` ${picocolors9.green("/status")} - \u8BCA\u65AD\u5E76\u5C55\u793A\u5F53\u524D\u4F1A\u8BDD\u3001\u6A21\u578B\u4E0E\u6D88\u8017`,
|
|
235882
|
-
` ${picocolors9.green("/metrics")} - \u5C55\u793A\u672C\u5730\u4F1A\u8BDD\u8FD0\u884C\u4E0E\u53EF\u9760\u6027\u6307\u6807`,
|
|
235883
|
-
` ${picocolors9.green("/doctor")} - \u5168\u9762\u8BCA\u65AD\u8FD0\u884C\u73AF\u5883\u3001\u6A21\u578B\u3001\u8054\u7F51\u3001skills \u4E0E\u5B89\u5168\u914D\u7F6E`,
|
|
235884
|
-
` ${picocolors9.green("/config")} ${picocolors9.cyan("[k=v]")} - \u67E5\u770B\u6216\u76F4\u63A5\u4FEE\u6539\u914D\u7F6E\u53C2\u6570`,
|
|
235885
|
-
` ${picocolors9.green("/model")} ${picocolors9.cyan("[name]")} - \u52A8\u6001\u67E5\u8BE2\u6216\u5207\u6362\u6B63\u5728\u4F7F\u7528\u7684\u8BED\u8A00\u5927\u6A21\u578B`,
|
|
235886
|
-
` ${picocolors9.green("/mode")} ${picocolors9.cyan("[mode]")} - \u5207\u6362\u5B89\u5168\u786E\u8BA4\u6A21\u5F0F (strict, normal, auto, plan)`,
|
|
235887
|
-
` ${picocolors9.green("/update")} - \u68C0\u67E5\u5E76\u66F4\u65B0 Orbit \u5230\u6700\u65B0 npm \u7248\u672C`,
|
|
235888
|
-
` ${picocolors9.green("/webui")} ${picocolors9.cyan("[port]")} - \u542F\u52A8\u5E76\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0`,
|
|
235889
|
-
"",
|
|
235890
|
-
picocolors9.bold(picocolors9.yellow("[ Git \u63D0\u4EA4 (Git) ]")),
|
|
235891
|
-
` ${picocolors9.green("/commit")} ${picocolors9.cyan("[msg]")} - \u6682\u5B58\u5DE5\u4F5C\u533A\u4FEE\u6539\u5E76\u751F\u6210\u63D0\u4EA4`,
|
|
235892
|
-
"",
|
|
235893
|
-
picocolors9.bold(picocolors9.yellow("[ \u7CFB\u7EDF\u63A7\u5236 (System) ]")),
|
|
235894
|
-
` ${picocolors9.green("/help")} - \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F`,
|
|
235895
|
-
` ${picocolors9.green("/exit")} / ${picocolors9.green("/quit")} - \u5B89\u5168\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF`,
|
|
235896
|
-
` ${picocolors9.green("!<cmd>")} / ${picocolors9.green("/run")} ${picocolors9.cyan("<cmd>")} - \u76F4\u63A5\u6267\u884C\u7CFB\u7EDF\u539F\u751F Shell \u547D\u4EE4`
|
|
235897
|
-
].join("\n");
|
|
236674
|
+
const locale = isZh ? "zh" : "en";
|
|
236675
|
+
const sections = [];
|
|
236676
|
+
for (const category of Object.keys(
|
|
236677
|
+
CATEGORY_LABELS
|
|
236678
|
+
)) {
|
|
236679
|
+
const commands = SLASH_COMMAND_DEFINITIONS.filter(
|
|
236680
|
+
(definition) => definition.category === category
|
|
236681
|
+
);
|
|
236682
|
+
sections.push(
|
|
236683
|
+
picocolors9.bold(
|
|
236684
|
+
picocolors9.yellow(`[ ${CATEGORY_LABELS[category][locale]} ]`)
|
|
236685
|
+
),
|
|
236686
|
+
...commands.map(({ command, usage, description }) => {
|
|
236687
|
+
const invocation = usage ? `${command} ${usage}` : command;
|
|
236688
|
+
return ` ${picocolors9.green(invocation.padEnd(25))} - ${description[locale]}`;
|
|
236689
|
+
}),
|
|
236690
|
+
""
|
|
236691
|
+
);
|
|
235898
236692
|
}
|
|
235899
|
-
|
|
235900
|
-
picocolors9.
|
|
235901
|
-
|
|
235902
|
-
|
|
235903
|
-
` ${picocolors9.green("/compact")} - Compact older dialogue now; auto-compacts against the active model window`,
|
|
235904
|
-
` ${picocolors9.green("/clear")} - Reset dialogue history and clear TUI screen`,
|
|
235905
|
-
"",
|
|
235906
|
-
picocolors9.bold(picocolors9.yellow("[ Session & History ]")),
|
|
235907
|
-
` ${picocolors9.green("/chat")} ${picocolors9.cyan("[action]")} - Manage sessions (list/ls, new, delete/rm, switch)`,
|
|
235908
|
-
` ${picocolors9.green("/goal")} ${picocolors9.cyan("[objective]")} - Show or set this chat's durable goal (clear to remove)`,
|
|
235909
|
-
` ${picocolors9.green("/rename")} ${picocolors9.cyan("<title>")} - Rename the current chat`,
|
|
235910
|
-
` ${picocolors9.green("/plan")} ${picocolors9.cyan("[action]")} - Manage this chat's recoverable task plan`,
|
|
235911
|
-
` ${picocolors9.green("/memory")} ${picocolors9.cyan("[action]")} - Review and manage explicit project memory`,
|
|
235912
|
-
` ${picocolors9.green("/rollback")} - Rollback to last file modification checkpoint`,
|
|
235913
|
-
` ${picocolors9.green("/copy")} - Copy last AI message to clipboard`,
|
|
235914
|
-
"",
|
|
235915
|
-
picocolors9.bold(picocolors9.yellow("[ Configuration & Status ]")),
|
|
235916
|
-
` ${picocolors9.green("/status")} - Show current session, model, and cost`,
|
|
235917
|
-
` ${picocolors9.green("/metrics")} - Show local runtime and reliability metrics`,
|
|
235918
|
-
` ${picocolors9.green("/doctor")} - Diagnose runtime, models, web, skills, and safety config`,
|
|
235919
|
-
` ${picocolors9.green("/config")} ${picocolors9.cyan("[k=v]")} - View or modify configurations`,
|
|
235920
|
-
` ${picocolors9.green("/model")} ${picocolors9.cyan("[name]")} - Show or switch active model`,
|
|
235921
|
-
` ${picocolors9.green("/mode")} ${picocolors9.cyan("[mode]")} - Switch permission mode (strict, normal, auto, plan)`,
|
|
235922
|
-
` ${picocolors9.green("/update")} - Check and update Orbit from npm`,
|
|
235923
|
-
` ${picocolors9.green("/webui")} ${picocolors9.cyan("[port]")} - Start and open the Orbit graphical console`,
|
|
235924
|
-
"",
|
|
235925
|
-
picocolors9.bold(picocolors9.yellow("[ Git Version Control ]")),
|
|
235926
|
-
` ${picocolors9.green("/commit")} ${picocolors9.cyan("[msg]")} - Stage files and commit with auto-generated message`,
|
|
235927
|
-
"",
|
|
235928
|
-
picocolors9.bold(picocolors9.yellow("[ System Control ]")),
|
|
235929
|
-
` ${picocolors9.green("/help")} - Show this help screen`,
|
|
235930
|
-
` ${picocolors9.green("/exit")} / ${picocolors9.green("/quit")} - Exit interactive shell`,
|
|
235931
|
-
` ${picocolors9.green("!<cmd>")} / ${picocolors9.green("/run")} ${picocolors9.cyan("<cmd>")} - Execute native shell command`
|
|
235932
|
-
].join("\n");
|
|
236693
|
+
sections.push(
|
|
236694
|
+
` ${picocolors9.green("!<cmd>")} - ${isZh ? "\u76F4\u63A5\u8FD0\u884C\u672C\u5730 Shell \u547D\u4EE4\uFF08\u7B49\u540C /run\uFF09" : "Run a native shell command (same as /run)"}`
|
|
236695
|
+
);
|
|
236696
|
+
return sections.join("\n").trimEnd();
|
|
235933
236697
|
}
|
|
235934
236698
|
|
|
235935
236699
|
// src/tui/TerminalText.ts
|
|
@@ -236197,8 +236961,8 @@ function findPreviousHistoryEntry(history, query, startIndex = history.length) {
|
|
|
236197
236961
|
import { dirname as dirname7, join as join13 } from "path";
|
|
236198
236962
|
import { homedir as homedir6 } from "os";
|
|
236199
236963
|
import { existsSync as existsSync14, mkdirSync as mkdirSync10, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
|
|
236200
|
-
import { z as
|
|
236201
|
-
var inputHistorySchema =
|
|
236964
|
+
import { z as z30 } from "zod";
|
|
236965
|
+
var inputHistorySchema = z30.array(z30.string());
|
|
236202
236966
|
var InputHistoryStore = class {
|
|
236203
236967
|
constructor(filePath = join13(homedir6(), ".orbit", "input_history.json")) {
|
|
236204
236968
|
this.filePath = filePath;
|
|
@@ -236761,13 +237525,13 @@ function renderPromptScreen(state, viewport, theme = MORANDI) {
|
|
|
236761
237525
|
|
|
236762
237526
|
// src/runtime/UpdateManager.ts
|
|
236763
237527
|
import { execFile as execFile4, execFileSync as execFileSync4 } from "child_process";
|
|
236764
|
-
import { z as
|
|
236765
|
-
var SemanticVersionSchema =
|
|
236766
|
-
var UpdateChannelSchema =
|
|
236767
|
-
var UpdateCheckSchema =
|
|
237528
|
+
import { z as z31 } from "zod";
|
|
237529
|
+
var SemanticVersionSchema = z31.string().trim().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
237530
|
+
var UpdateChannelSchema = z31.enum(["stable", "beta"]);
|
|
237531
|
+
var UpdateCheckSchema = z31.object({
|
|
236768
237532
|
currentVersion: SemanticVersionSchema,
|
|
236769
237533
|
latestVersion: SemanticVersionSchema,
|
|
236770
|
-
updateAvailable:
|
|
237534
|
+
updateAvailable: z31.boolean()
|
|
236771
237535
|
});
|
|
236772
237536
|
var UpdateManager = class {
|
|
236773
237537
|
executable;
|
|
@@ -236851,9 +237615,9 @@ var UpdateManager = class {
|
|
|
236851
237615
|
],
|
|
236852
237616
|
{ timeoutMs: this.timeoutMs, inheritOutput: false }
|
|
236853
237617
|
);
|
|
236854
|
-
const parsed =
|
|
236855
|
-
dependencies:
|
|
236856
|
-
"@orbit-build/cli":
|
|
237618
|
+
const parsed = z31.object({
|
|
237619
|
+
dependencies: z31.object({
|
|
237620
|
+
"@orbit-build/cli": z31.object({ version: SemanticVersionSchema })
|
|
236857
237621
|
})
|
|
236858
237622
|
}).parse(JSON.parse(raw));
|
|
236859
237623
|
return parsed.dependencies["@orbit-build/cli"].version;
|
|
@@ -239125,7 +239889,7 @@ import { dirname as dirname9, resolve as resolve10 } from "path";
|
|
|
239125
239889
|
import { homedir as homedir10 } from "os";
|
|
239126
239890
|
import http2 from "http";
|
|
239127
239891
|
import { randomBytes as randomBytes2, randomUUID as randomUUID8, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
239128
|
-
import { z as
|
|
239892
|
+
import { z as z47 } from "zod";
|
|
239129
239893
|
|
|
239130
239894
|
// src/runtime/CommandRouter.ts
|
|
239131
239895
|
import picocolors18 from "picocolors";
|
|
@@ -239135,11 +239899,11 @@ import { existsSync as existsSync16, readFileSync as readFileSync17, readdirSync
|
|
|
239135
239899
|
import { basename as basename5, extname as extname2, join as join15 } from "path";
|
|
239136
239900
|
import { homedir as homedir8 } from "os";
|
|
239137
239901
|
import { parse as parse3 } from "yaml";
|
|
239138
|
-
import { z as
|
|
239139
|
-
var CommandMetadataSchema =
|
|
239140
|
-
description:
|
|
239141
|
-
argumentHint:
|
|
239142
|
-
"argument-hint":
|
|
239902
|
+
import { z as z35 } from "zod";
|
|
239903
|
+
var CommandMetadataSchema = z35.object({
|
|
239904
|
+
description: z35.string().max(240).optional(),
|
|
239905
|
+
argumentHint: z35.string().max(120).optional(),
|
|
239906
|
+
"argument-hint": z35.string().max(120).optional()
|
|
239143
239907
|
});
|
|
239144
239908
|
var VALID_COMMAND_NAME = /^[a-z0-9][a-z0-9-_]{0,47}$/i;
|
|
239145
239909
|
var MAX_COMMAND_FILE_BYTES = 256 * 1024;
|
|
@@ -239285,20 +240049,20 @@ import { spawn as spawn2 } from "child_process";
|
|
|
239285
240049
|
// src/runtime/webui/WebUiRuntime.ts
|
|
239286
240050
|
import http from "http";
|
|
239287
240051
|
import { randomBytes, randomUUID as randomUUID6 } from "crypto";
|
|
239288
|
-
import { z as
|
|
240052
|
+
import { z as z38 } from "zod";
|
|
239289
240053
|
|
|
239290
240054
|
// src/runtime/AutocompleteCandidates.ts
|
|
239291
240055
|
import glob6 from "fast-glob";
|
|
239292
240056
|
import { existsSync as existsSync17, readFileSync as readFileSync18, readdirSync as readdirSync6 } from "fs";
|
|
239293
240057
|
import { homedir as homedir9 } from "os";
|
|
239294
240058
|
import { dirname as dirname8, join as join16, resolve as resolve7 } from "path";
|
|
239295
|
-
import { z as
|
|
239296
|
-
var symbolIndexSchema =
|
|
239297
|
-
files:
|
|
239298
|
-
|
|
239299
|
-
symbols:
|
|
239300
|
-
|
|
239301
|
-
name:
|
|
240059
|
+
import { z as z36 } from "zod";
|
|
240060
|
+
var symbolIndexSchema = z36.object({
|
|
240061
|
+
files: z36.record(
|
|
240062
|
+
z36.object({
|
|
240063
|
+
symbols: z36.array(
|
|
240064
|
+
z36.object({
|
|
240065
|
+
name: z36.string().min(1)
|
|
239302
240066
|
})
|
|
239303
240067
|
).optional()
|
|
239304
240068
|
})
|
|
@@ -239310,6 +240074,12 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239310
240074
|
...BUILTIN_SLASH_COMMANDS,
|
|
239311
240075
|
...customCommands.map((command) => `/${command.name}`)
|
|
239312
240076
|
];
|
|
240077
|
+
const commandDetails = customCommands.map((command) => ({
|
|
240078
|
+
command: `/${command.name}`,
|
|
240079
|
+
description: command.description,
|
|
240080
|
+
argumentHint: command.argumentHint,
|
|
240081
|
+
source: command.source
|
|
240082
|
+
}));
|
|
239313
240083
|
const files = [];
|
|
239314
240084
|
const symbols = [];
|
|
239315
240085
|
const sessions = [];
|
|
@@ -239317,7 +240087,7 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239317
240087
|
const normHome = resolve7(homedir9()).toLowerCase().replace(/\\/g, "/");
|
|
239318
240088
|
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname8(normCwd) === normCwd;
|
|
239319
240089
|
if (isHomeOrRoot) {
|
|
239320
|
-
return { commands, files, symbols, sessions };
|
|
240090
|
+
return { commands, commandDetails, files, symbols, sessions };
|
|
239321
240091
|
}
|
|
239322
240092
|
try {
|
|
239323
240093
|
files.push(
|
|
@@ -239363,6 +240133,7 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239363
240133
|
}
|
|
239364
240134
|
return {
|
|
239365
240135
|
commands,
|
|
240136
|
+
commandDetails,
|
|
239366
240137
|
files,
|
|
239367
240138
|
symbols: [...new Set(symbols)],
|
|
239368
240139
|
sessions
|
|
@@ -239382,6 +240153,15 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
239382
240153
|
autoSizePrompt();
|
|
239383
240154
|
writeLocalStorage('orbit.webui.draft', elements.prompt.value);
|
|
239384
240155
|
updateSendButtonState();
|
|
240156
|
+
slashCommandSelection = 0;
|
|
240157
|
+
renderSlashCommands();
|
|
240158
|
+
});
|
|
240159
|
+
|
|
240160
|
+
elements.prompt.addEventListener('focus', renderSlashCommands);
|
|
240161
|
+
elements.prompt.addEventListener('blur', () => {
|
|
240162
|
+
window.setTimeout(() => {
|
|
240163
|
+
if (!elements.slashCommandMenu.contains(document.activeElement)) closeSlashCommands();
|
|
240164
|
+
}, 0);
|
|
239385
240165
|
});
|
|
239386
240166
|
|
|
239387
240167
|
elements.prompt.addEventListener('keydown', (event) => {
|
|
@@ -239849,7 +240629,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
239849
240629
|
}
|
|
239850
240630
|
try {
|
|
239851
240631
|
await bootstrapSession();
|
|
239852
|
-
await Promise.all([renderMessages(), loadStatus()]);
|
|
240632
|
+
await Promise.all([renderMessages(), loadStatus(), loadSlashCommands()]);
|
|
239853
240633
|
connectEvents();
|
|
239854
240634
|
if (draft) showToast(copy.draftRestored);
|
|
239855
240635
|
elements.prompt.focus();
|
|
@@ -240429,6 +241209,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
240429
241209
|
jumpBottom: byId('jumpBottom'),
|
|
240430
241210
|
composer: byId('composer'),
|
|
240431
241211
|
prompt: byId('prompt'),
|
|
241212
|
+
slashCommandMenu: byId('slashCommandMenu'),
|
|
241213
|
+
slashCommandResults: byId('slashCommandResults'),
|
|
241214
|
+
slashCommandEmpty: byId('slashCommandEmpty'),
|
|
240432
241215
|
contextPickerButton: byId('contextPickerButton'),
|
|
240433
241216
|
contextChipCount: byId('contextChipCount'),
|
|
240434
241217
|
contextShelf: byId('contextShelf'),
|
|
@@ -241601,23 +242384,29 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
|
|
|
241601
242384
|
autoSizePrompt();
|
|
241602
242385
|
updateSendButtonState();
|
|
241603
242386
|
elements.prompt.focus();
|
|
242387
|
+
closeSlashCommands();
|
|
241604
242388
|
}
|
|
241605
242389
|
|
|
241606
242390
|
function buildPaletteActions() {
|
|
241607
242391
|
const actions = [
|
|
241608
242392
|
{ icon: '+', label: language === 'zh' ? '新建任务' : 'New task', detail: 'Ctrl N', keywords: 'new session task', idle: true, run: () => updateSession({ action: 'new' }) },
|
|
241609
242393
|
{ icon: '▣', label: language === 'zh' ? '新建或打开项目' : 'New or open project', detail: language === 'zh' ? '选择项目文件夹' : 'Choose a project folder', keywords: 'new open create project workspace folder', idle: true, run: openProjectDialog },
|
|
241610
|
-
{ icon: '◎', label: language === 'zh' ? '设置聊天目标' : 'Set chat goal', detail: '/goal', keywords: 'goal objective target session', idle: true, run: () => setComposerValue('/goal ') },
|
|
241611
|
-
{ icon: '✎', label: language === 'zh' ? '重命名聊天' : 'Rename chat', detail: '/rename', keywords: 'rename title session chat', idle: true, run: () => setComposerValue('/rename ') },
|
|
241612
242394
|
{ icon: '›', label: copy.focusComposer, detail: language === 'zh' ? '发送消息' : 'Message Orbit', keywords: 'focus prompt message composer', run: () => elements.prompt.focus() },
|
|
241613
242395
|
{ icon: '◫', label: copy.openActivity, detail: language === 'zh' ? '运行状态与工具' : 'Runtime and tools', keywords: 'activity details runtime tools', run: () => setInspector(true, 'activity') },
|
|
241614
242396
|
{ icon: '⚙', label: copy.openSettings, detail: 'Ctrl ,', keywords: 'settings preferences configuration', run: () => setInspector(true, 'settings') },
|
|
241615
242397
|
{ icon: '◧', label: language === 'zh' ? '切换导航栏' : 'Toggle navigation', detail: 'Ctrl B', keywords: 'toggle sidebar navigation focus', run: toggleNavigation },
|
|
241616
|
-
{ icon: '✓', label: language === 'zh' ? '运行诊断' : 'Run diagnostics', detail: '/doctor', keywords: 'doctor health diagnostics', idle: true, run: () => submitTurn('/doctor') },
|
|
241617
|
-
{ icon: '?', label: language === 'zh' ? '查看命令帮助' : 'Show command help', detail: '/help', keywords: 'help commands reference', idle: true, run: () => submitTurn('/help') },
|
|
241618
|
-
{ icon: '↺', label: copy.compactContext, detail: '/compact', keywords: 'compact context tokens summarize', idle: true, run: () => submitTurn('/compact') },
|
|
241619
242398
|
{ icon: '+', label: language === 'zh' ? '添加文件上下文' : 'Add file context', detail: language === 'zh' ? '搜索工作区文件' : 'Search workspace files', keywords: 'add context file', idle: true, run: openContextPicker },
|
|
241620
242399
|
];
|
|
242400
|
+
for (const definition of slashCommands) {
|
|
242401
|
+
actions.push({
|
|
242402
|
+
icon: '/',
|
|
242403
|
+
label: definition.command + (definition.usage ? ' ' + definition.usage : ''),
|
|
242404
|
+
detail: definition.description,
|
|
242405
|
+
keywords: 'slash command ' + definition.command + ' ' + definition.description,
|
|
242406
|
+
idle: true,
|
|
242407
|
+
run: () => setComposerValue(definition.command + (definition.usage ? ' ' : '')),
|
|
242408
|
+
});
|
|
242409
|
+
}
|
|
241621
242410
|
const status = state.status || {};
|
|
241622
242411
|
const session = status.session || {};
|
|
241623
242412
|
for (const item of session.recent || []) {
|
|
@@ -242479,6 +243268,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
242479
243268
|
setBusy(false, '');
|
|
242480
243269
|
}
|
|
242481
243270
|
closeContextPicker({ skipRestore: true });
|
|
243271
|
+
closeSlashCommands();
|
|
242482
243272
|
const turnId = crypto.randomUUID ? crypto.randomUUID() : String(Date.now()) + '-' + Math.random().toString(16).slice(2);
|
|
242483
243273
|
const previousDraft = elements.prompt.value;
|
|
242484
243274
|
const restoreDraft = String(options && options.restoreDraft || '');
|
|
@@ -242747,6 +243537,168 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
242747
243537
|
|
|
242748
243538
|
`;
|
|
242749
243539
|
|
|
243540
|
+
// src/runtime/webui/WebUiClientSlashCommands.ts
|
|
243541
|
+
var WEB_UI_SLASH_COMMANDS = JSON.stringify(
|
|
243542
|
+
SLASH_COMMAND_DEFINITIONS.filter(({ webSuggested }) => webSuggested).map(
|
|
243543
|
+
({ command, usage, description }) => ({ command, usage, description })
|
|
243544
|
+
)
|
|
243545
|
+
);
|
|
243546
|
+
var WEB_UI_RESERVED_SLASH_COMMANDS = JSON.stringify(BUILTIN_SLASH_COMMANDS);
|
|
243547
|
+
var WEB_UI_CLIENT_SLASH_COMMANDS_SCRIPT = String.raw` const builtInSlashCommands = ${WEB_UI_SLASH_COMMANDS};
|
|
243548
|
+
const reservedSlashCommands = new Set(${WEB_UI_RESERVED_SLASH_COMMANDS});
|
|
243549
|
+
let slashCommands = builtInSlashCommands.map((definition) => ({
|
|
243550
|
+
command: definition.command,
|
|
243551
|
+
usage: definition.usage,
|
|
243552
|
+
description: definition.description[language],
|
|
243553
|
+
custom: false,
|
|
243554
|
+
}));
|
|
243555
|
+
let slashCommandMatches = [];
|
|
243556
|
+
let slashCommandSelection = 0;
|
|
243557
|
+
|
|
243558
|
+
function slashCommandQuery() {
|
|
243559
|
+
const value = elements.prompt.value.trimStart();
|
|
243560
|
+
return /^\/[a-z0-9_-]*$/i.test(value) ? value.toLowerCase() : null;
|
|
243561
|
+
}
|
|
243562
|
+
|
|
243563
|
+
function closeSlashCommands() {
|
|
243564
|
+
elements.slashCommandMenu.hidden = true;
|
|
243565
|
+
elements.slashCommandMenu.setAttribute('aria-hidden', 'true');
|
|
243566
|
+
elements.prompt.setAttribute('aria-expanded', 'false');
|
|
243567
|
+
elements.prompt.removeAttribute('aria-activedescendant');
|
|
243568
|
+
}
|
|
243569
|
+
|
|
243570
|
+
function syncSlashCommandSelection() {
|
|
243571
|
+
let activeId = '';
|
|
243572
|
+
elements.slashCommandResults.querySelectorAll('.slash-command-option').forEach((button, index) => {
|
|
243573
|
+
const selected = index === slashCommandSelection;
|
|
243574
|
+
button.setAttribute('aria-selected', selected ? 'true' : 'false');
|
|
243575
|
+
if (selected) {
|
|
243576
|
+
activeId = button.id;
|
|
243577
|
+
button.scrollIntoView({ block: 'nearest' });
|
|
243578
|
+
}
|
|
243579
|
+
});
|
|
243580
|
+
if (activeId) elements.prompt.setAttribute('aria-activedescendant', activeId);
|
|
243581
|
+
}
|
|
243582
|
+
|
|
243583
|
+
function chooseSlashCommand(index) {
|
|
243584
|
+
const definition = slashCommandMatches[index];
|
|
243585
|
+
if (!definition) return;
|
|
243586
|
+
elements.prompt.value = definition.command + (definition.usage ? ' ' : '');
|
|
243587
|
+
writeLocalStorage('orbit.webui.draft', elements.prompt.value);
|
|
243588
|
+
autoSizePrompt();
|
|
243589
|
+
updateSendButtonState();
|
|
243590
|
+
closeSlashCommands();
|
|
243591
|
+
elements.prompt.focus();
|
|
243592
|
+
}
|
|
243593
|
+
|
|
243594
|
+
function renderSlashCommands() {
|
|
243595
|
+
const query = slashCommandQuery();
|
|
243596
|
+
if (query === null || state.busy) {
|
|
243597
|
+
closeSlashCommands();
|
|
243598
|
+
return;
|
|
243599
|
+
}
|
|
243600
|
+
slashCommandMatches = slashCommands
|
|
243601
|
+
.filter((definition) => definition.command.startsWith(query))
|
|
243602
|
+
.sort((left, right) => {
|
|
243603
|
+
const leftExact = left.command === query ? 0 : 1;
|
|
243604
|
+
const rightExact = right.command === query ? 0 : 1;
|
|
243605
|
+
return leftExact - rightExact || left.command.localeCompare(right.command);
|
|
243606
|
+
})
|
|
243607
|
+
.slice(0, 10);
|
|
243608
|
+
slashCommandSelection = Math.max(0, Math.min(slashCommandSelection, slashCommandMatches.length - 1));
|
|
243609
|
+
elements.slashCommandResults.replaceChildren();
|
|
243610
|
+
slashCommandMatches.forEach((definition, index) => {
|
|
243611
|
+
const button = document.createElement('button');
|
|
243612
|
+
button.type = 'button';
|
|
243613
|
+
button.id = 'slash-command-option-' + index;
|
|
243614
|
+
button.className = 'slash-command-option';
|
|
243615
|
+
button.setAttribute('role', 'option');
|
|
243616
|
+
button.setAttribute('aria-selected', index === slashCommandSelection ? 'true' : 'false');
|
|
243617
|
+
const invocation = document.createElement('span');
|
|
243618
|
+
invocation.className = 'slash-command-invocation';
|
|
243619
|
+
const command = document.createElement('strong');
|
|
243620
|
+
command.textContent = definition.command;
|
|
243621
|
+
const usage = document.createElement('small');
|
|
243622
|
+
usage.textContent = definition.usage || '';
|
|
243623
|
+
invocation.append(command, usage);
|
|
243624
|
+
const description = document.createElement('span');
|
|
243625
|
+
description.className = 'slash-command-description';
|
|
243626
|
+
description.textContent = definition.description;
|
|
243627
|
+
button.append(invocation, description);
|
|
243628
|
+
button.addEventListener('mousedown', (event) => event.preventDefault());
|
|
243629
|
+
button.addEventListener('mouseenter', () => {
|
|
243630
|
+
slashCommandSelection = index;
|
|
243631
|
+
syncSlashCommandSelection();
|
|
243632
|
+
});
|
|
243633
|
+
button.addEventListener('click', () => chooseSlashCommand(index));
|
|
243634
|
+
elements.slashCommandResults.append(button);
|
|
243635
|
+
});
|
|
243636
|
+
elements.slashCommandEmpty.hidden = slashCommandMatches.length !== 0;
|
|
243637
|
+
elements.slashCommandMenu.hidden = false;
|
|
243638
|
+
elements.slashCommandMenu.setAttribute('aria-hidden', 'false');
|
|
243639
|
+
elements.prompt.setAttribute('aria-expanded', 'true');
|
|
243640
|
+
syncSlashCommandSelection();
|
|
243641
|
+
}
|
|
243642
|
+
|
|
243643
|
+
async function loadSlashCommands() {
|
|
243644
|
+
try {
|
|
243645
|
+
const result = await api('/api/completions?query=');
|
|
243646
|
+
const available = new Set(Array.isArray(result.commands) ? result.commands : []);
|
|
243647
|
+
const customDetails = new Map(
|
|
243648
|
+
(Array.isArray(result.commandDetails) ? result.commandDetails : [])
|
|
243649
|
+
.filter((detail) => detail && typeof detail.command === 'string')
|
|
243650
|
+
.map((detail) => [detail.command, detail]),
|
|
243651
|
+
);
|
|
243652
|
+
const custom = Array.from(available)
|
|
243653
|
+
.filter((command) => /^\/[a-z0-9][a-z0-9_-]{0,47}$/i.test(command))
|
|
243654
|
+
.filter((command) => !reservedSlashCommands.has(command))
|
|
243655
|
+
.map((command) => {
|
|
243656
|
+
const detail = customDetails.get(command) || {};
|
|
243657
|
+
return {
|
|
243658
|
+
command,
|
|
243659
|
+
usage: typeof detail.argumentHint === 'string' && detail.argumentHint.trim()
|
|
243660
|
+
? detail.argumentHint.trim()
|
|
243661
|
+
: '[arguments]',
|
|
243662
|
+
description: typeof detail.description === 'string' && detail.description.trim()
|
|
243663
|
+
? detail.description.trim()
|
|
243664
|
+
: language === 'zh' ? '自定义提示词命令' : 'Custom prompt command',
|
|
243665
|
+
custom: true,
|
|
243666
|
+
};
|
|
243667
|
+
});
|
|
243668
|
+
slashCommands = [
|
|
243669
|
+
...builtInSlashCommands.map((definition) => ({
|
|
243670
|
+
command: definition.command,
|
|
243671
|
+
usage: definition.usage,
|
|
243672
|
+
description: definition.description[language],
|
|
243673
|
+
custom: false,
|
|
243674
|
+
})),
|
|
243675
|
+
...custom,
|
|
243676
|
+
];
|
|
243677
|
+
} catch {
|
|
243678
|
+
// Built-ins remain available when optional workspace discovery fails.
|
|
243679
|
+
}
|
|
243680
|
+
}
|
|
243681
|
+
|
|
243682
|
+
elements.prompt.addEventListener('keydown', (event) => {
|
|
243683
|
+
if (elements.slashCommandMenu.hidden) return;
|
|
243684
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && slashCommandMatches.length) {
|
|
243685
|
+
event.preventDefault();
|
|
243686
|
+
event.stopImmediatePropagation();
|
|
243687
|
+
const delta = event.key === 'ArrowDown' ? 1 : -1;
|
|
243688
|
+
slashCommandSelection = (slashCommandSelection + delta + slashCommandMatches.length) % slashCommandMatches.length;
|
|
243689
|
+
syncSlashCommandSelection();
|
|
243690
|
+
} else if ((event.key === 'Enter' || event.key === 'Tab') && slashCommandMatches.length) {
|
|
243691
|
+
event.preventDefault();
|
|
243692
|
+
event.stopImmediatePropagation();
|
|
243693
|
+
chooseSlashCommand(slashCommandSelection);
|
|
243694
|
+
} else if (event.key === 'Escape') {
|
|
243695
|
+
event.preventDefault();
|
|
243696
|
+
event.stopImmediatePropagation();
|
|
243697
|
+
closeSlashCommands();
|
|
243698
|
+
}
|
|
243699
|
+
});
|
|
243700
|
+
`;
|
|
243701
|
+
|
|
242750
243702
|
// src/runtime/webui/WebUiClient.ts
|
|
242751
243703
|
var WEB_UI_CLIENT_PREAMBLE = String.raw`(() => {
|
|
242752
243704
|
'use strict';
|
|
@@ -242762,6 +243714,7 @@ var WEB_UI_CLIENT_SCRIPT = [
|
|
|
242762
243714
|
WEB_UI_CLIENT_CONTEXT_SCRIPT,
|
|
242763
243715
|
WEB_UI_CLIENT_MESSAGES_SCRIPT,
|
|
242764
243716
|
WEB_UI_CLIENT_SESSION_SCRIPT,
|
|
243717
|
+
WEB_UI_CLIENT_SLASH_COMMANDS_SCRIPT,
|
|
242765
243718
|
WEB_UI_CLIENT_PALETTE_SCRIPT,
|
|
242766
243719
|
WEB_UI_CLIENT_BINDINGS_SCRIPT,
|
|
242767
243720
|
WEB_UI_CLIENT_EPILOGUE
|
|
@@ -242789,7 +243742,7 @@ var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4
|
|
|
242789
243742
|
|
|
242790
243743
|
// src/runtime/webui/WebUiSecurity.ts
|
|
242791
243744
|
import { timingSafeEqual } from "crypto";
|
|
242792
|
-
import { z as
|
|
243745
|
+
import { z as z37 } from "zod";
|
|
242793
243746
|
function sanitizeWebEventPayload(type, payload) {
|
|
242794
243747
|
if (!isRecord3(payload)) return void 0;
|
|
242795
243748
|
switch (type) {
|
|
@@ -242982,7 +243935,7 @@ function sanitizeBaseUrl(value) {
|
|
|
242982
243935
|
}
|
|
242983
243936
|
}
|
|
242984
243937
|
function webRequestErrorStatus(error) {
|
|
242985
|
-
if (error instanceof
|
|
243938
|
+
if (error instanceof z37.ZodError) return 400;
|
|
242986
243939
|
if (error instanceof Error && error.message === "Request body too large.") {
|
|
242987
243940
|
return 413;
|
|
242988
243941
|
}
|
|
@@ -243668,6 +244621,9 @@ var COPY = {
|
|
|
243668
244621
|
suggestionImproveBody: "Optimize performance, safety, and maintainability.",
|
|
243669
244622
|
inputLabel: "Message Orbit",
|
|
243670
244623
|
inputPlaceholder: "Ask Orbit to work on this codebase\u2026",
|
|
244624
|
+
slashCommands: "Slash commands",
|
|
244625
|
+
slashCommandEmpty: "No matching commands",
|
|
244626
|
+
slashCommandHint: "\u2191\u2193 navigate \xB7 Enter or Tab to insert \xB7 Esc to close",
|
|
243671
244627
|
context: "Context",
|
|
243672
244628
|
contextPickerTitle: "Add file context",
|
|
243673
244629
|
contextPickerSearch: "Search workspace files\u2026",
|
|
@@ -243764,6 +244720,9 @@ var COPY = {
|
|
|
243764
244720
|
suggestionImproveBody: "\u4F18\u5316\u6027\u80FD\u3001\u5B89\u5168\u6027\u4E0E\u53EF\u7EF4\u62A4\u6027\u3002",
|
|
243765
244721
|
inputLabel: "\u7ED9 Orbit \u53D1\u9001\u6D88\u606F",
|
|
243766
244722
|
inputPlaceholder: "\u8BA9 Orbit \u5728\u8FD9\u4E2A\u4EE3\u7801\u5E93\u4E2D\u5B8C\u6210\u4EFB\u52A1\u2026",
|
|
244723
|
+
slashCommands: "\u659C\u6760\u547D\u4EE4",
|
|
244724
|
+
slashCommandEmpty: "\u6CA1\u6709\u5339\u914D\u7684\u547D\u4EE4",
|
|
244725
|
+
slashCommandHint: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u6216 Tab \u63D2\u5165 \xB7 Esc \u5173\u95ED",
|
|
243767
244726
|
context: "\u4E0A\u4E0B\u6587",
|
|
243768
244727
|
contextPickerTitle: "\u6DFB\u52A0\u6587\u4EF6\u4E0A\u4E0B\u6587",
|
|
243769
244728
|
contextPickerSearch: "\u641C\u7D22\u5DE5\u4F5C\u533A\u6587\u4EF6\u2026",
|
|
@@ -243847,7 +244806,13 @@ function renderComposer(copy) {
|
|
|
243847
244806
|
</section>
|
|
243848
244807
|
<form class="composer" id="composer">
|
|
243849
244808
|
<label class="sr-only" for="prompt">${copy.inputLabel}</label>
|
|
243850
|
-
<textarea id="prompt" data-testid="composer-input" rows="1" maxlength="100000" autocomplete="off" autofocus placeholder="${copy.inputPlaceholder}"></textarea>
|
|
244809
|
+
<textarea id="prompt" data-testid="composer-input" rows="1" maxlength="100000" autocomplete="off" autofocus placeholder="${copy.inputPlaceholder}" aria-autocomplete="list" aria-controls="slashCommandResults" aria-expanded="false"></textarea>
|
|
244810
|
+
<section class="slash-command-menu" id="slashCommandMenu" aria-label="${copy.slashCommands}" aria-hidden="true" hidden>
|
|
244811
|
+
<div class="slash-command-heading"><strong>${copy.slashCommands}</strong><span>/</span></div>
|
|
244812
|
+
<div class="slash-command-results" id="slashCommandResults" role="listbox"></div>
|
|
244813
|
+
<p class="slash-command-empty" id="slashCommandEmpty" role="status" hidden>${copy.slashCommandEmpty}</p>
|
|
244814
|
+
<p class="slash-command-hint">${copy.slashCommandHint}</p>
|
|
244815
|
+
</section>
|
|
243851
244816
|
<section class="context-shelf" id="contextShelf" aria-label="${copy.activeContext}" hidden>
|
|
243852
244817
|
<div class="context-shelf-header">
|
|
243853
244818
|
<span>${renderUiIcon("context")}<strong>${copy.activeContext}</strong></span>
|
|
@@ -244312,6 +245277,116 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
244312
245277
|
box-shadow: none;
|
|
244313
245278
|
}
|
|
244314
245279
|
|
|
245280
|
+
.slash-command-menu {
|
|
245281
|
+
position: absolute;
|
|
245282
|
+
z-index: 24;
|
|
245283
|
+
left: 10px;
|
|
245284
|
+
right: 10px;
|
|
245285
|
+
bottom: calc(100% + 8px);
|
|
245286
|
+
overflow: hidden;
|
|
245287
|
+
color: var(--ink);
|
|
245288
|
+
background: var(--surface-raised);
|
|
245289
|
+
border: 1px solid var(--border-strong);
|
|
245290
|
+
border-radius: 13px;
|
|
245291
|
+
box-shadow: 0 12px 28px color-mix(in srgb, var(--ink-strong) 10%, transparent);
|
|
245292
|
+
}
|
|
245293
|
+
|
|
245294
|
+
/* The landing composer has ample space below; opening downward keeps the
|
|
245295
|
+
command heading visible instead of letting the application topbar clip it. */
|
|
245296
|
+
.empty-composer-slot .slash-command-menu {
|
|
245297
|
+
top: calc(100% + 8px);
|
|
245298
|
+
bottom: auto;
|
|
245299
|
+
}
|
|
245300
|
+
|
|
245301
|
+
.empty-composer-slot .slash-command-results {
|
|
245302
|
+
max-height: min(230px, 32vh);
|
|
245303
|
+
}
|
|
245304
|
+
|
|
245305
|
+
.slash-command-heading,
|
|
245306
|
+
.slash-command-hint {
|
|
245307
|
+
display: flex;
|
|
245308
|
+
align-items: center;
|
|
245309
|
+
justify-content: space-between;
|
|
245310
|
+
margin: 0;
|
|
245311
|
+
color: var(--faint);
|
|
245312
|
+
font-size: 10px;
|
|
245313
|
+
}
|
|
245314
|
+
|
|
245315
|
+
.slash-command-heading {
|
|
245316
|
+
padding: 9px 11px 7px;
|
|
245317
|
+
border-bottom: 1px solid var(--border);
|
|
245318
|
+
letter-spacing: 0.04em;
|
|
245319
|
+
text-transform: uppercase;
|
|
245320
|
+
}
|
|
245321
|
+
|
|
245322
|
+
.slash-command-heading span {
|
|
245323
|
+
font-family: var(--font-mono);
|
|
245324
|
+
font-size: 13px;
|
|
245325
|
+
}
|
|
245326
|
+
|
|
245327
|
+
.slash-command-results {
|
|
245328
|
+
max-height: min(318px, 46vh);
|
|
245329
|
+
overflow-y: auto;
|
|
245330
|
+
padding: 5px;
|
|
245331
|
+
}
|
|
245332
|
+
|
|
245333
|
+
.slash-command-option {
|
|
245334
|
+
width: 100%;
|
|
245335
|
+
min-height: 45px;
|
|
245336
|
+
display: grid;
|
|
245337
|
+
grid-template-columns: minmax(145px, 0.38fr) minmax(0, 1fr);
|
|
245338
|
+
align-items: center;
|
|
245339
|
+
gap: 12px;
|
|
245340
|
+
padding: 6px 9px;
|
|
245341
|
+
color: var(--ink);
|
|
245342
|
+
background: transparent;
|
|
245343
|
+
border: 0;
|
|
245344
|
+
border-radius: 9px;
|
|
245345
|
+
text-align: left;
|
|
245346
|
+
}
|
|
245347
|
+
|
|
245348
|
+
.slash-command-option[aria-selected="true"],
|
|
245349
|
+
.slash-command-option:hover {
|
|
245350
|
+
background: var(--accent-soft);
|
|
245351
|
+
}
|
|
245352
|
+
|
|
245353
|
+
.slash-command-invocation {
|
|
245354
|
+
min-width: 0;
|
|
245355
|
+
display: flex;
|
|
245356
|
+
align-items: baseline;
|
|
245357
|
+
gap: 6px;
|
|
245358
|
+
font-family: var(--font-mono);
|
|
245359
|
+
white-space: nowrap;
|
|
245360
|
+
}
|
|
245361
|
+
|
|
245362
|
+
.slash-command-invocation strong {
|
|
245363
|
+
color: var(--accent-strong);
|
|
245364
|
+
font-size: 12px;
|
|
245365
|
+
}
|
|
245366
|
+
|
|
245367
|
+
.slash-command-invocation small,
|
|
245368
|
+
.slash-command-description {
|
|
245369
|
+
overflow: hidden;
|
|
245370
|
+
color: var(--muted);
|
|
245371
|
+
font-size: 11px;
|
|
245372
|
+
text-overflow: ellipsis;
|
|
245373
|
+
white-space: nowrap;
|
|
245374
|
+
}
|
|
245375
|
+
|
|
245376
|
+
.slash-command-empty {
|
|
245377
|
+
margin: 0;
|
|
245378
|
+
padding: 18px 12px;
|
|
245379
|
+
color: var(--muted);
|
|
245380
|
+
font-size: 12px;
|
|
245381
|
+
text-align: center;
|
|
245382
|
+
}
|
|
245383
|
+
|
|
245384
|
+
.slash-command-hint {
|
|
245385
|
+
justify-content: flex-start;
|
|
245386
|
+
padding: 7px 11px 8px;
|
|
245387
|
+
border-top: 1px solid var(--border);
|
|
245388
|
+
}
|
|
245389
|
+
|
|
244315
245390
|
#prompt {
|
|
244316
245391
|
display: block;
|
|
244317
245392
|
width: 100%;
|
|
@@ -244328,6 +245403,13 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
244328
245403
|
line-height: 1.55;
|
|
244329
245404
|
}
|
|
244330
245405
|
|
|
245406
|
+
@media (max-width: 620px) {
|
|
245407
|
+
.slash-command-option {
|
|
245408
|
+
grid-template-columns: 1fr;
|
|
245409
|
+
gap: 2px;
|
|
245410
|
+
}
|
|
245411
|
+
}
|
|
245412
|
+
|
|
244331
245413
|
.empty-composer-slot #prompt {
|
|
244332
245414
|
min-height: clamp(54px, 7vh, 74px);
|
|
244333
245415
|
font-size: 15px;
|
|
@@ -249049,45 +250131,45 @@ var WEB_UI_STYLE_SECTIONS = [
|
|
|
249049
250131
|
var WEB_UI_STYLES = WEB_UI_STYLE_SECTIONS.join("");
|
|
249050
250132
|
|
|
249051
250133
|
// src/runtime/webui/WebUiRuntime.ts
|
|
249052
|
-
var WebTurnIdSchema =
|
|
249053
|
-
var ChatRequestSchema =
|
|
249054
|
-
prompt:
|
|
250134
|
+
var WebTurnIdSchema = z38.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
|
|
250135
|
+
var ChatRequestSchema = z38.object({
|
|
250136
|
+
prompt: z38.string().trim().min(1).max(1e5),
|
|
249055
250137
|
turnId: WebTurnIdSchema.optional()
|
|
249056
250138
|
}).strict();
|
|
249057
|
-
var CancelRequestSchema =
|
|
249058
|
-
var ApprovalDecisionSchema =
|
|
250139
|
+
var CancelRequestSchema = z38.object({ turnId: WebTurnIdSchema.nullish() }).strict();
|
|
250140
|
+
var ApprovalDecisionSchema = z38.object({
|
|
249059
250141
|
id: WebTurnIdSchema,
|
|
249060
|
-
approved:
|
|
250142
|
+
approved: z38.boolean()
|
|
249061
250143
|
}).strict();
|
|
249062
|
-
var SettingsPatchSchema =
|
|
249063
|
-
provider:
|
|
249064
|
-
model:
|
|
249065
|
-
permissionMode:
|
|
249066
|
-
webSearchEnabled:
|
|
249067
|
-
webSearchProvider:
|
|
249068
|
-
webSearchMaxResults:
|
|
250144
|
+
var SettingsPatchSchema = z38.object({
|
|
250145
|
+
provider: z38.string().trim().min(1).max(256).optional(),
|
|
250146
|
+
model: z38.string().trim().min(1).max(200).optional(),
|
|
250147
|
+
permissionMode: z38.enum(["strict", "normal", "auto", "plan"]).optional(),
|
|
250148
|
+
webSearchEnabled: z38.boolean().optional(),
|
|
250149
|
+
webSearchProvider: z38.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
|
|
250150
|
+
webSearchMaxResults: z38.number().int().min(1).max(20).optional()
|
|
249069
250151
|
}).strict();
|
|
249070
|
-
var SessionActionSchema =
|
|
249071
|
-
|
|
250152
|
+
var SessionActionSchema = z38.discriminatedUnion("action", [
|
|
250153
|
+
z38.object({ action: z38.literal("new") }).strict(),
|
|
249072
250154
|
...["resume", "archive", "restore", "delete"].map(
|
|
249073
|
-
(action) =>
|
|
249074
|
-
action:
|
|
249075
|
-
sessionId:
|
|
250155
|
+
(action) => z38.object({
|
|
250156
|
+
action: z38.literal(action),
|
|
250157
|
+
sessionId: z38.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
|
|
249076
250158
|
}).strict()
|
|
249077
250159
|
)
|
|
249078
250160
|
]);
|
|
249079
|
-
var ProjectActionSchema =
|
|
249080
|
-
|
|
249081
|
-
|
|
249082
|
-
action:
|
|
249083
|
-
path:
|
|
250161
|
+
var ProjectActionSchema = z38.discriminatedUnion("action", [
|
|
250162
|
+
z38.object({ action: z38.literal("pick") }).strict(),
|
|
250163
|
+
z38.object({
|
|
250164
|
+
action: z38.enum(["open", "create"]),
|
|
250165
|
+
path: z38.string().trim().min(1).max(4096)
|
|
249084
250166
|
}).strict(),
|
|
249085
|
-
|
|
249086
|
-
action:
|
|
249087
|
-
projectId:
|
|
250167
|
+
z38.object({
|
|
250168
|
+
action: z38.literal("remove"),
|
|
250169
|
+
projectId: z38.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
|
|
249088
250170
|
}).strict()
|
|
249089
250171
|
]);
|
|
249090
|
-
var CompletionQuerySchema =
|
|
250172
|
+
var CompletionQuerySchema = z38.string().trim().max(200);
|
|
249091
250173
|
function safeCall2(fn) {
|
|
249092
250174
|
try {
|
|
249093
250175
|
return fn();
|
|
@@ -249122,7 +250204,7 @@ var OrbitWebUiRuntime = class {
|
|
|
249122
250204
|
server;
|
|
249123
250205
|
handle;
|
|
249124
250206
|
stopPromise;
|
|
249125
|
-
|
|
250207
|
+
completionCandidatesPromise;
|
|
249126
250208
|
constructor(options) {
|
|
249127
250209
|
this.options = options;
|
|
249128
250210
|
this.events = new WebUiEventStream(() => this.activeTurn);
|
|
@@ -249145,7 +250227,7 @@ var OrbitWebUiRuntime = class {
|
|
|
249145
250227
|
throw new Error("Orbit Web UI is not running.");
|
|
249146
250228
|
}
|
|
249147
250229
|
this.options = options;
|
|
249148
|
-
this.
|
|
250230
|
+
this.completionCandidatesPromise = void 0;
|
|
249149
250231
|
}
|
|
249150
250232
|
/** Return this instance's live public handle. */
|
|
249151
250233
|
getHandle() {
|
|
@@ -249293,10 +250375,17 @@ var OrbitWebUiRuntime = class {
|
|
|
249293
250375
|
sendJson(res, 400, { error: "Invalid completion query." });
|
|
249294
250376
|
return;
|
|
249295
250377
|
}
|
|
249296
|
-
const
|
|
250378
|
+
const candidates = await this.getCompletionCandidates(options);
|
|
250379
|
+
const normalizedQuery = query.data.trim().toLowerCase();
|
|
249297
250380
|
sendJson(res, 200, {
|
|
249298
|
-
files: filterWebUiCompletionFiles(files, query.data),
|
|
249299
|
-
|
|
250381
|
+
files: filterWebUiCompletionFiles(candidates.files, query.data),
|
|
250382
|
+
commands: candidates.commands.filter(
|
|
250383
|
+
(command) => !normalizedQuery || command.includes(normalizedQuery)
|
|
250384
|
+
),
|
|
250385
|
+
commandDetails: (candidates.commandDetails ?? []).filter(
|
|
250386
|
+
({ command }) => !normalizedQuery || command.includes(normalizedQuery)
|
|
250387
|
+
),
|
|
250388
|
+
total: candidates.files.length
|
|
249300
250389
|
});
|
|
249301
250390
|
return;
|
|
249302
250391
|
}
|
|
@@ -249383,16 +250472,20 @@ var OrbitWebUiRuntime = class {
|
|
|
249383
250472
|
});
|
|
249384
250473
|
}
|
|
249385
250474
|
}
|
|
249386
|
-
|
|
249387
|
-
if (!this.
|
|
249388
|
-
this.
|
|
250475
|
+
getCompletionCandidates(options) {
|
|
250476
|
+
if (!this.completionCandidatesPromise) {
|
|
250477
|
+
this.completionCandidatesPromise = getAutocompleteCandidates(
|
|
249389
250478
|
options.cwd,
|
|
249390
250479
|
options.config
|
|
249391
|
-
).then(
|
|
249392
|
-
|
|
249393
|
-
|
|
250480
|
+
).then((candidates) => ({
|
|
250481
|
+
...candidates,
|
|
250482
|
+
files: candidates.files.slice(
|
|
250483
|
+
0,
|
|
250484
|
+
options.config.context.maxFilesToIndex
|
|
250485
|
+
)
|
|
250486
|
+
}));
|
|
249394
250487
|
}
|
|
249395
|
-
return this.
|
|
250488
|
+
return this.completionCandidatesPromise;
|
|
249396
250489
|
}
|
|
249397
250490
|
async handleChat(req, res, options) {
|
|
249398
250491
|
if (!options.submitPrompt) {
|
|
@@ -250473,9 +251566,9 @@ async function handleContextCommand(command, argument, dependencies) {
|
|
|
250473
251566
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
250474
251567
|
import { existsSync as existsSync19, rmSync as rmSync5 } from "fs";
|
|
250475
251568
|
import picocolors13 from "picocolors";
|
|
250476
|
-
import { z as
|
|
250477
|
-
var GitStatusCodeSchema =
|
|
250478
|
-
var GitStatusPathSchema =
|
|
251569
|
+
import { z as z39 } from "zod";
|
|
251570
|
+
var GitStatusCodeSchema = z39.string().length(2).regex(/^[ MADRCU?!]{2}$/);
|
|
251571
|
+
var GitStatusPathSchema = z39.string().min(1).max(32768);
|
|
250479
251572
|
var defaultGitAdapter = {
|
|
250480
251573
|
status: (cwd) => execFileSync5("git", ["status", "--porcelain=v1", "-z"], {
|
|
250481
251574
|
cwd,
|
|
@@ -250510,8 +251603,16 @@ function parseGitStatusPaths(output) {
|
|
|
250510
251603
|
return [...new Set(paths)];
|
|
250511
251604
|
}
|
|
250512
251605
|
async function handleRollbackCommand(command, argument, dependencies) {
|
|
250513
|
-
if (command !== "/rollback") return null;
|
|
250514
251606
|
const isZh = dependencies.language === "zh";
|
|
251607
|
+
if (command === "/timeline") {
|
|
251608
|
+
printCheckpointTimeline(dependencies.loop.getCheckpoints(), dependencies);
|
|
251609
|
+
return HANDLED_COMMAND;
|
|
251610
|
+
}
|
|
251611
|
+
if (command === "/rewind") {
|
|
251612
|
+
await rewindToCheckpoint(argument, dependencies);
|
|
251613
|
+
return HANDLED_COMMAND;
|
|
251614
|
+
}
|
|
251615
|
+
if (command !== "/rollback") return null;
|
|
250515
251616
|
if (argument === "all" || argument === "--all") {
|
|
250516
251617
|
await dependencies.loop.rollbackLastCheckpoint();
|
|
250517
251618
|
return HANDLED_COMMAND;
|
|
@@ -250591,6 +251692,65 @@ async function handleRollbackCommand(command, argument, dependencies) {
|
|
|
250591
251692
|
}
|
|
250592
251693
|
return HANDLED_COMMAND;
|
|
250593
251694
|
}
|
|
251695
|
+
function printCheckpointTimeline(checkpoints, dependencies) {
|
|
251696
|
+
const isZh = dependencies.language === "zh";
|
|
251697
|
+
if (checkpoints.length === 0) {
|
|
251698
|
+
dependencies.printOutput(
|
|
251699
|
+
picocolors13.yellow(
|
|
251700
|
+
isZh ? "\u5F53\u524D\u804A\u5929\u8FD8\u6CA1\u6709\u6587\u4EF6\u68C0\u67E5\u70B9\u3002" : "This chat has no file checkpoints yet."
|
|
251701
|
+
)
|
|
251702
|
+
);
|
|
251703
|
+
return;
|
|
251704
|
+
}
|
|
251705
|
+
const newestFirst = checkpoints.slice().reverse();
|
|
251706
|
+
const visible = newestFirst.slice(0, 50);
|
|
251707
|
+
const lines = [
|
|
251708
|
+
picocolors13.bold(
|
|
251709
|
+
isZh ? `\u6587\u4EF6\u68C0\u67E5\u70B9\uFF08${checkpoints.length}\uFF09` : `File checkpoints (${checkpoints.length})`
|
|
251710
|
+
),
|
|
251711
|
+
...visible.map((checkpoint, index) => {
|
|
251712
|
+
const files = checkpoint.files.length ? checkpoint.files.slice(0, 3).join(", ") + (checkpoint.files.length > 3 ? ` +${checkpoint.files.length - 3}` : "") : isZh ? "\u65E0\u6587\u4EF6" : "no files";
|
|
251713
|
+
return `${picocolors13.cyan(String(index + 1).padStart(2))} ${checkpoint.id.slice(0, 12)} ${checkpoint.timestamp} ${files}`;
|
|
251714
|
+
})
|
|
251715
|
+
];
|
|
251716
|
+
if (newestFirst.length > visible.length) {
|
|
251717
|
+
lines.push(
|
|
251718
|
+
picocolors13.gray(
|
|
251719
|
+
isZh ? `\u4EC5\u663E\u793A\u6700\u8FD1 ${visible.length} \u4E2A\u68C0\u67E5\u70B9\u3002` : `Showing the ${visible.length} most recent checkpoints.`
|
|
251720
|
+
)
|
|
251721
|
+
);
|
|
251722
|
+
}
|
|
251723
|
+
lines.push(
|
|
251724
|
+
picocolors13.gray(
|
|
251725
|
+
isZh ? "\u4F7F\u7528 /rewind <\u7F16\u53F7\u6216 ID \u524D\u7F00> \u56DE\u9000\u3002" : "Use /rewind <number or ID prefix> to restore one."
|
|
251726
|
+
)
|
|
251727
|
+
);
|
|
251728
|
+
dependencies.printOutput(lines.join("\n"));
|
|
251729
|
+
}
|
|
251730
|
+
async function rewindToCheckpoint(argument, dependencies) {
|
|
251731
|
+
const isZh = dependencies.language === "zh";
|
|
251732
|
+
const selector = argument.trim();
|
|
251733
|
+
if (!selector) {
|
|
251734
|
+
dependencies.printOutput(
|
|
251735
|
+
picocolors13.red(
|
|
251736
|
+
isZh ? "\u2716 \u7528\u6CD5\uFF1A/rewind <\u68C0\u67E5\u70B9\u7F16\u53F7\u6216 ID \u524D\u7F00>" : "\u2716 Usage: /rewind <checkpoint number or ID prefix>"
|
|
251737
|
+
)
|
|
251738
|
+
);
|
|
251739
|
+
return;
|
|
251740
|
+
}
|
|
251741
|
+
const newestFirst = dependencies.loop.getCheckpoints().slice().reverse();
|
|
251742
|
+
const numeric = /^\d+$/.test(selector) ? Number(selector) : Number.NaN;
|
|
251743
|
+
const matches = Number.isInteger(numeric) && numeric >= 1 ? newestFirst[numeric - 1] ? [newestFirst[numeric - 1]] : [] : newestFirst.filter((checkpoint) => checkpoint.id.startsWith(selector));
|
|
251744
|
+
if (matches.length !== 1) {
|
|
251745
|
+
dependencies.printOutput(
|
|
251746
|
+
picocolors13.red(
|
|
251747
|
+
matches.length > 1 ? isZh ? "\u2716 ID \u524D\u7F00\u5339\u914D\u591A\u4E2A\u68C0\u67E5\u70B9\uFF0C\u8BF7\u8F93\u5165\u66F4\u957F\u7684\u524D\u7F00\u3002" : "\u2716 The ID prefix matches multiple checkpoints; enter a longer prefix." : isZh ? `\u2716 \u672A\u627E\u5230\u68C0\u67E5\u70B9\uFF1A${selector}` : `\u2716 Checkpoint not found: ${selector}`
|
|
251748
|
+
)
|
|
251749
|
+
);
|
|
251750
|
+
return;
|
|
251751
|
+
}
|
|
251752
|
+
await dependencies.loop.rewindToCheckpoint(matches[0].id);
|
|
251753
|
+
}
|
|
250594
251754
|
function removeWorkspacePath(absolutePath) {
|
|
250595
251755
|
rmSync5(absolutePath, { recursive: true, force: true });
|
|
250596
251756
|
}
|
|
@@ -250906,32 +252066,32 @@ function ensureSessionTitle(loop, prompt) {
|
|
|
250906
252066
|
}
|
|
250907
252067
|
|
|
250908
252068
|
// src/runtime/ModelDiscovery.ts
|
|
250909
|
-
import { z as
|
|
250910
|
-
var ModelEntrySchema =
|
|
250911
|
-
id:
|
|
250912
|
-
model:
|
|
250913
|
-
context_length:
|
|
250914
|
-
context_window:
|
|
250915
|
-
max_context_tokens:
|
|
250916
|
-
max_output_tokens:
|
|
250917
|
-
input_modalities:
|
|
250918
|
-
output_modalities:
|
|
250919
|
-
modalities:
|
|
250920
|
-
architecture:
|
|
250921
|
-
capabilities:
|
|
250922
|
-
supported_parameters:
|
|
250923
|
-
type:
|
|
250924
|
-
kind:
|
|
250925
|
-
task:
|
|
250926
|
-
endpoint:
|
|
250927
|
-
details:
|
|
252069
|
+
import { z as z40 } from "zod";
|
|
252070
|
+
var ModelEntrySchema = z40.object({
|
|
252071
|
+
id: z40.unknown().optional(),
|
|
252072
|
+
model: z40.unknown().optional(),
|
|
252073
|
+
context_length: z40.unknown().optional(),
|
|
252074
|
+
context_window: z40.unknown().optional(),
|
|
252075
|
+
max_context_tokens: z40.unknown().optional(),
|
|
252076
|
+
max_output_tokens: z40.unknown().optional(),
|
|
252077
|
+
input_modalities: z40.unknown().optional(),
|
|
252078
|
+
output_modalities: z40.unknown().optional(),
|
|
252079
|
+
modalities: z40.unknown().optional(),
|
|
252080
|
+
architecture: z40.unknown().optional(),
|
|
252081
|
+
capabilities: z40.unknown().optional(),
|
|
252082
|
+
supported_parameters: z40.unknown().optional(),
|
|
252083
|
+
type: z40.unknown().optional(),
|
|
252084
|
+
kind: z40.unknown().optional(),
|
|
252085
|
+
task: z40.unknown().optional(),
|
|
252086
|
+
endpoint: z40.unknown().optional(),
|
|
252087
|
+
details: z40.unknown().optional()
|
|
250928
252088
|
}).passthrough();
|
|
250929
|
-
var ModelListSchema =
|
|
250930
|
-
|
|
250931
|
-
|
|
250932
|
-
|
|
252089
|
+
var ModelListSchema = z40.union([
|
|
252090
|
+
z40.object({ data: z40.array(ModelEntrySchema).max(1e3) }),
|
|
252091
|
+
z40.object({ models: z40.array(ModelEntrySchema).max(1e3) }),
|
|
252092
|
+
z40.array(ModelEntrySchema).max(1e3)
|
|
250933
252093
|
]);
|
|
250934
|
-
var DiscoveryUrlSchema =
|
|
252094
|
+
var DiscoveryUrlSchema = z40.string().url().max(4096).transform((value) => new URL(value));
|
|
250935
252095
|
var MAX_MODEL_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
250936
252096
|
async function discoverProviderModels(options) {
|
|
250937
252097
|
const base = DiscoveryUrlSchema.parse(options.baseUrl.trim());
|
|
@@ -251098,9 +252258,9 @@ function normalizeModelEntries(entries) {
|
|
|
251098
252258
|
}
|
|
251099
252259
|
return { models, modelCapabilities };
|
|
251100
252260
|
}
|
|
251101
|
-
var OllamaShowSchema =
|
|
251102
|
-
capabilities:
|
|
251103
|
-
model_info:
|
|
252261
|
+
var OllamaShowSchema = z40.object({
|
|
252262
|
+
capabilities: z40.array(z40.string().max(128)).max(64).optional(),
|
|
252263
|
+
model_info: z40.record(z40.unknown()).optional()
|
|
251104
252264
|
}).passthrough();
|
|
251105
252265
|
async function enrichOllamaCapabilities(base, models, target, fetchImpl, signal) {
|
|
251106
252266
|
const endpoint = new URL(base);
|
|
@@ -251347,9 +252507,9 @@ function isPickerCancellation(error) {
|
|
|
251347
252507
|
|
|
251348
252508
|
// src/runtime/commands/SessionMetadataCommandHandler.ts
|
|
251349
252509
|
import picocolors15 from "picocolors";
|
|
251350
|
-
import { z as
|
|
251351
|
-
var GoalSchema =
|
|
251352
|
-
var SessionTitleSchema =
|
|
252510
|
+
import { z as z41 } from "zod";
|
|
252511
|
+
var GoalSchema = z41.string().trim().min(1).max(4e3);
|
|
252512
|
+
var SessionTitleSchema = z41.string().trim().min(1).max(160);
|
|
251353
252513
|
function handleSessionMetadataCommand(command, argument, dependencies) {
|
|
251354
252514
|
if (command === "/goal") {
|
|
251355
252515
|
handleGoal(argument, dependencies);
|
|
@@ -251414,9 +252574,9 @@ function handleRename(argument, { loop, isZh, printOutput }) {
|
|
|
251414
252574
|
|
|
251415
252575
|
// src/runtime/commands/WorkspaceStateCommandHandler.ts
|
|
251416
252576
|
import picocolors16 from "picocolors";
|
|
251417
|
-
import { z as
|
|
251418
|
-
var TextSchema =
|
|
251419
|
-
var ItemReferenceSchema =
|
|
252577
|
+
import { z as z45 } from "zod";
|
|
252578
|
+
var TextSchema = z45.string().trim().min(1).max(2e3);
|
|
252579
|
+
var ItemReferenceSchema = z45.string().trim().min(1).max(100);
|
|
251420
252580
|
function handleWorkspaceStateCommand(command, argument, dependencies) {
|
|
251421
252581
|
if (command === "/memory") {
|
|
251422
252582
|
handleMemory(argument, dependencies);
|
|
@@ -251592,11 +252752,11 @@ function resolveItemId(reference, items) {
|
|
|
251592
252752
|
// src/commands/update.ts
|
|
251593
252753
|
import readline4 from "readline";
|
|
251594
252754
|
import picocolors17 from "picocolors";
|
|
251595
|
-
import { z as
|
|
251596
|
-
var UpdateCommandOptionsSchema =
|
|
251597
|
-
check:
|
|
251598
|
-
yes:
|
|
251599
|
-
json:
|
|
252755
|
+
import { z as z46 } from "zod";
|
|
252756
|
+
var UpdateCommandOptionsSchema = z46.object({
|
|
252757
|
+
check: z46.boolean().default(false),
|
|
252758
|
+
yes: z46.boolean().default(false),
|
|
252759
|
+
json: z46.boolean().default(false),
|
|
251600
252760
|
channel: UpdateChannelSchema.default("stable")
|
|
251601
252761
|
}).strict();
|
|
251602
252762
|
async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
@@ -252667,20 +253827,20 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
|
|
|
252667
253827
|
};
|
|
252668
253828
|
|
|
252669
253829
|
// src/runtime/ReplController.ts
|
|
252670
|
-
var AutocompleteRequestSchema =
|
|
252671
|
-
prefix:
|
|
252672
|
-
suffix:
|
|
252673
|
-
windowId:
|
|
253830
|
+
var AutocompleteRequestSchema = z47.object({
|
|
253831
|
+
prefix: z47.string().max(2e4),
|
|
253832
|
+
suffix: z47.string().max(2e4),
|
|
253833
|
+
windowId: z47.string().max(1e3).optional()
|
|
252674
253834
|
});
|
|
252675
253835
|
var AUTOCOMPLETE_BODY_LIMIT_BYTES = 1e5;
|
|
252676
253836
|
var AUTOCOMPLETE_MAX_CONCURRENCY = 4;
|
|
252677
|
-
var LocalStateSchema =
|
|
252678
|
-
lastSessionId:
|
|
252679
|
-
lastModel:
|
|
253837
|
+
var LocalStateSchema = z47.object({
|
|
253838
|
+
lastSessionId: z47.string().optional(),
|
|
253839
|
+
lastModel: z47.string().optional()
|
|
252680
253840
|
});
|
|
252681
|
-
var AutocompleteEndpointSchema =
|
|
252682
|
-
port:
|
|
252683
|
-
token:
|
|
253841
|
+
var AutocompleteEndpointSchema = z47.object({
|
|
253842
|
+
port: z47.number().int().min(1).max(65535),
|
|
253843
|
+
token: z47.string().min(32).max(256)
|
|
252684
253844
|
});
|
|
252685
253845
|
function getRunOutcomeMessage(outcome) {
|
|
252686
253846
|
if (!outcome || outcome.status === "completed") return void 0;
|
|
@@ -253549,36 +254709,36 @@ function isRecord6(value) {
|
|
|
253549
254709
|
}
|
|
253550
254710
|
|
|
253551
254711
|
// src/commands/LSPServer.ts
|
|
253552
|
-
import { z as
|
|
254712
|
+
import { z as z48 } from "zod";
|
|
253553
254713
|
var MAX_LSP_HEADER_BYTES = 8 * 1024;
|
|
253554
254714
|
var MAX_LSP_BODY_BYTES = 8 * 1024 * 1024;
|
|
253555
|
-
var JsonRpcIdSchema =
|
|
253556
|
-
var JSONRPCMessageSchema =
|
|
253557
|
-
jsonrpc:
|
|
254715
|
+
var JsonRpcIdSchema = z48.union([z48.string(), z48.number(), z48.null()]);
|
|
254716
|
+
var JSONRPCMessageSchema = z48.object({
|
|
254717
|
+
jsonrpc: z48.literal("2.0"),
|
|
253558
254718
|
id: JsonRpcIdSchema.optional(),
|
|
253559
|
-
method:
|
|
253560
|
-
params:
|
|
254719
|
+
method: z48.string().min(1).max(512),
|
|
254720
|
+
params: z48.unknown().optional()
|
|
253561
254721
|
}).strict();
|
|
253562
|
-
var TextDocumentIdentifierSchema =
|
|
253563
|
-
uri:
|
|
254722
|
+
var TextDocumentIdentifierSchema = z48.object({
|
|
254723
|
+
uri: z48.string().min(1).max(16384)
|
|
253564
254724
|
});
|
|
253565
|
-
var DidOpenParamsSchema =
|
|
254725
|
+
var DidOpenParamsSchema = z48.object({
|
|
253566
254726
|
textDocument: TextDocumentIdentifierSchema.extend({
|
|
253567
|
-
text:
|
|
254727
|
+
text: z48.string().max(MAX_LSP_BODY_BYTES)
|
|
253568
254728
|
}).passthrough()
|
|
253569
254729
|
});
|
|
253570
|
-
var DidChangeParamsSchema =
|
|
254730
|
+
var DidChangeParamsSchema = z48.object({
|
|
253571
254731
|
textDocument: TextDocumentIdentifierSchema,
|
|
253572
|
-
contentChanges:
|
|
254732
|
+
contentChanges: z48.array(z48.object({ text: z48.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
|
|
253573
254733
|
});
|
|
253574
|
-
var DidCloseParamsSchema =
|
|
254734
|
+
var DidCloseParamsSchema = z48.object({
|
|
253575
254735
|
textDocument: TextDocumentIdentifierSchema
|
|
253576
254736
|
});
|
|
253577
|
-
var CompletionParamsSchema =
|
|
254737
|
+
var CompletionParamsSchema = z48.object({
|
|
253578
254738
|
textDocument: TextDocumentIdentifierSchema,
|
|
253579
|
-
position:
|
|
253580
|
-
line:
|
|
253581
|
-
character:
|
|
254739
|
+
position: z48.object({
|
|
254740
|
+
line: z48.number().int().nonnegative(),
|
|
254741
|
+
character: z48.number().int().nonnegative()
|
|
253582
254742
|
})
|
|
253583
254743
|
});
|
|
253584
254744
|
var JSONRPCReader = class {
|
|
@@ -253824,7 +254984,7 @@ ${completion}
|
|
|
253824
254984
|
);
|
|
253825
254985
|
}
|
|
253826
254986
|
} catch (error) {
|
|
253827
|
-
if (error instanceof
|
|
254987
|
+
if (error instanceof z48.ZodError) {
|
|
253828
254988
|
sendError(message.id, -32602, "Invalid method parameters.");
|
|
253829
254989
|
return;
|
|
253830
254990
|
}
|
|
@@ -254197,10 +255357,10 @@ import {
|
|
|
254197
255357
|
writeFileSync as writeFileSync13
|
|
254198
255358
|
} from "fs";
|
|
254199
255359
|
import { dirname as dirname10, resolve as resolve11 } from "path";
|
|
254200
|
-
import { z as
|
|
254201
|
-
var TraceOptionsSchema =
|
|
254202
|
-
full:
|
|
254203
|
-
out:
|
|
255360
|
+
import { z as z49 } from "zod";
|
|
255361
|
+
var TraceOptionsSchema = z49.object({
|
|
255362
|
+
full: z49.boolean().default(false),
|
|
255363
|
+
out: z49.string().trim().min(1).max(4096).optional()
|
|
254204
255364
|
});
|
|
254205
255365
|
function runTraceExport(cwd, sessionId, options = {}) {
|
|
254206
255366
|
const value = TraceOptionsSchema.parse(options);
|
|
@@ -254255,16 +255415,16 @@ import { basename as basename6, dirname as dirname11, join as join18 } from "pat
|
|
|
254255
255415
|
import { promisify as promisify5 } from "util";
|
|
254256
255416
|
import picocolors23 from "picocolors";
|
|
254257
255417
|
import { parse as parseYaml2 } from "yaml";
|
|
254258
|
-
import { z as
|
|
255418
|
+
import { z as z50 } from "zod";
|
|
254259
255419
|
var exec4 = promisify5(execCallback);
|
|
254260
255420
|
var MAX_SUITE_BYTES = 1024 * 1024;
|
|
254261
255421
|
var MAX_VERIFICATION_OUTPUT = 4e3;
|
|
254262
|
-
var EvalOptionsSchema =
|
|
254263
|
-
provider:
|
|
254264
|
-
model:
|
|
254265
|
-
task:
|
|
254266
|
-
allowCommands:
|
|
254267
|
-
json:
|
|
255422
|
+
var EvalOptionsSchema = z50.object({
|
|
255423
|
+
provider: z50.string().trim().min(1).optional(),
|
|
255424
|
+
model: z50.string().trim().min(1).optional(),
|
|
255425
|
+
task: z50.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
|
|
255426
|
+
allowCommands: z50.boolean().default(false),
|
|
255427
|
+
json: z50.boolean().default(false)
|
|
254268
255428
|
});
|
|
254269
255429
|
async function runEval(cwd, suiteFile, options = {}) {
|
|
254270
255430
|
const value = EvalOptionsSchema.parse(options);
|
|
@@ -254587,16 +255747,16 @@ function safeSummary(value) {
|
|
|
254587
255747
|
import readline6 from "readline";
|
|
254588
255748
|
import picocolors24 from "picocolors";
|
|
254589
255749
|
import { resolve as resolve13 } from "path";
|
|
254590
|
-
import { z as
|
|
255750
|
+
import { z as z54 } from "zod";
|
|
254591
255751
|
|
|
254592
255752
|
// src/runtime/CleanupManager.ts
|
|
254593
255753
|
import { lstatSync as lstatSync6, readdirSync as readdirSync7, rmSync as rmSync9 } from "fs";
|
|
254594
255754
|
import { homedir as homedir11 } from "os";
|
|
254595
255755
|
import { basename as basename7, join as join19, parse as parse5, resolve as resolve12 } from "path";
|
|
254596
|
-
import { z as
|
|
254597
|
-
var CleanupScopeSchema =
|
|
255756
|
+
import { z as z51 } from "zod";
|
|
255757
|
+
var CleanupScopeSchema = z51.enum(["user", "project"]);
|
|
254598
255758
|
function buildCleanupPlan(options) {
|
|
254599
|
-
const scopes =
|
|
255759
|
+
const scopes = z51.array(CleanupScopeSchema).min(1).parse(options.scopes);
|
|
254600
255760
|
const homeDirectory = resolve12(options.homeDirectory ?? homedir11());
|
|
254601
255761
|
const projectDirectory = resolve12(options.projectDirectory ?? options.cwd);
|
|
254602
255762
|
const candidates = scopes.map((scope) => ({
|
|
@@ -254719,12 +255879,12 @@ function safeInventoryWarning(targetPath, error) {
|
|
|
254719
255879
|
}
|
|
254720
255880
|
|
|
254721
255881
|
// src/commands/clean.ts
|
|
254722
|
-
var CleanCommandOptionsSchema =
|
|
254723
|
-
user:
|
|
254724
|
-
project:
|
|
254725
|
-
all:
|
|
254726
|
-
yes:
|
|
254727
|
-
json:
|
|
255882
|
+
var CleanCommandOptionsSchema = z54.object({
|
|
255883
|
+
user: z54.boolean().default(false),
|
|
255884
|
+
project: z54.union([z54.boolean(), z54.string().min(1).max(4096)]).optional(),
|
|
255885
|
+
all: z54.boolean().default(false),
|
|
255886
|
+
yes: z54.boolean().default(false),
|
|
255887
|
+
json: z54.boolean().default(false)
|
|
254728
255888
|
}).strict();
|
|
254729
255889
|
async function runClean(cwd, rawOptions, dependencies = {}) {
|
|
254730
255890
|
const options = CleanCommandOptionsSchema.parse(rawOptions);
|