@orbit-build/cli 0.1.8 → 0.1.10
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 +48 -103
- package/dist/index.js +1809 -598
- 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) {
|
|
@@ -219985,7 +219985,7 @@ var CliPackageManifestSchema = z10.object({
|
|
|
219985
219985
|
"expected a semantic version"
|
|
219986
219986
|
)
|
|
219987
219987
|
});
|
|
219988
|
-
function
|
|
219988
|
+
function loadCliVersion() {
|
|
219989
219989
|
const candidates = [
|
|
219990
219990
|
new URL("../package.json", import.meta.url),
|
|
219991
219991
|
new URL("../../package.json", import.meta.url)
|
|
@@ -220006,6 +220006,10 @@ function readCliVersion() {
|
|
|
220006
220006
|
cause: lastError
|
|
220007
220007
|
});
|
|
220008
220008
|
}
|
|
220009
|
+
var RUNNING_CLI_VERSION = loadCliVersion();
|
|
220010
|
+
function readCliVersion() {
|
|
220011
|
+
return RUNNING_CLI_VERSION;
|
|
220012
|
+
}
|
|
220009
220013
|
|
|
220010
220014
|
// src/commands/doctor.ts
|
|
220011
220015
|
var DoctorIssueSchema = z11.object({
|
|
@@ -221009,10 +221013,10 @@ import {
|
|
|
221009
221013
|
renameSync as renameSync7,
|
|
221010
221014
|
writeFileSync as writeFileSync9
|
|
221011
221015
|
} from "fs";
|
|
221012
|
-
import { createHash as
|
|
221016
|
+
import { createHash as createHash6 } from "crypto";
|
|
221013
221017
|
import { dirname as dirname6, join as join12 } from "path";
|
|
221014
|
-
import { z as
|
|
221015
|
-
import { z as
|
|
221018
|
+
import { z as z29 } from "zod";
|
|
221019
|
+
import { z as z210 } from "zod";
|
|
221016
221020
|
|
|
221017
221021
|
// ../tools/dist/index.js
|
|
221018
221022
|
import { z as z13 } from "zod";
|
|
@@ -222635,8 +222639,12 @@ import glob4 from "fast-glob";
|
|
|
222635
222639
|
import { z as z15 } from "zod";
|
|
222636
222640
|
import { existsSync as existsSync32, readFileSync as readFileSync62 } from "fs";
|
|
222637
222641
|
import { z as z16 } from "zod";
|
|
222642
|
+
import { lookup } from "dns/promises";
|
|
222643
|
+
import { isIP } from "net";
|
|
222638
222644
|
import { z as z17 } from "zod";
|
|
222645
|
+
import { z as z18 } from "zod";
|
|
222639
222646
|
import { existsSync as existsSync42, readFileSync as readFileSync72, statSync } from "fs";
|
|
222647
|
+
import { z as z19 } from "zod";
|
|
222640
222648
|
var ToolRegistry = class {
|
|
222641
222649
|
tools = /* @__PURE__ */ new Map();
|
|
222642
222650
|
register(tool) {
|
|
@@ -222655,19 +222663,20 @@ var ToolRegistry = class {
|
|
|
222655
222663
|
return this.list().map((t) => ({
|
|
222656
222664
|
name: t.name,
|
|
222657
222665
|
description: t.description,
|
|
222658
|
-
inputSchema: t.inputSchema
|
|
222666
|
+
inputSchema: t.inputSchema,
|
|
222667
|
+
inputJsonSchema: t.inputJsonSchema
|
|
222659
222668
|
}));
|
|
222660
222669
|
}
|
|
222661
222670
|
};
|
|
222662
222671
|
var toolRegistry = new ToolRegistry();
|
|
222663
222672
|
var ReadFileInputSchema = z13.object({
|
|
222664
|
-
path: z13.string(),
|
|
222665
|
-
startLine: z13.number().optional(),
|
|
222666
|
-
endLine: z13.number().optional()
|
|
222673
|
+
path: z13.string().min(1).max(4096),
|
|
222674
|
+
startLine: z13.number().int().positive().optional(),
|
|
222675
|
+
endLine: z13.number().int().positive().optional()
|
|
222667
222676
|
});
|
|
222668
222677
|
var ReadFileTool = class {
|
|
222669
222678
|
name = "read_file";
|
|
222670
|
-
description = "Read content from a file inside the project. Defaults to
|
|
222679
|
+
description = "Read content from a file inside the project. Defaults to at most 400 lines and bounds oversized output for the model context.";
|
|
222671
222680
|
inputSchema = ReadFileInputSchema;
|
|
222672
222681
|
risk = "read";
|
|
222673
222682
|
async execute(input, ctx) {
|
|
@@ -222678,23 +222687,25 @@ var ReadFileTool = class {
|
|
|
222678
222687
|
const start = input.startLine !== void 0 ? Math.max(1, input.startLine) : 1;
|
|
222679
222688
|
const end = input.endLine !== void 0 ? Math.min(lines.length, input.endLine) : Math.min(lines.length, start + 399);
|
|
222680
222689
|
const slicedLines = lines.slice(start - 1, end);
|
|
222681
|
-
const
|
|
222690
|
+
const rawDisplayContent = slicedLines.join("\n");
|
|
222691
|
+
const displayContent = rawDisplayContent.length > 12e4 ? `${rawDisplayContent.slice(0, 119940)}
|
|
222692
|
+
... [truncated by read_file]` : rawDisplayContent;
|
|
222682
222693
|
return {
|
|
222683
222694
|
ok: true,
|
|
222684
222695
|
data: displayContent,
|
|
222685
222696
|
display: `Read lines ${start}-${end} of ${input.path}`
|
|
222686
222697
|
};
|
|
222687
|
-
} catch (
|
|
222698
|
+
} catch (error) {
|
|
222688
222699
|
return {
|
|
222689
222700
|
ok: false,
|
|
222690
|
-
error:
|
|
222701
|
+
error: error instanceof Error ? error.message : String(error)
|
|
222691
222702
|
};
|
|
222692
222703
|
}
|
|
222693
222704
|
}
|
|
222694
222705
|
};
|
|
222695
222706
|
var WriteFileInputSchema = z23.object({
|
|
222696
|
-
path: z23.string(),
|
|
222697
|
-
content: z23.string()
|
|
222707
|
+
path: z23.string().trim().min(1).max(4096),
|
|
222708
|
+
content: z23.string().max(5e6)
|
|
222698
222709
|
});
|
|
222699
222710
|
var WriteFileTool = class {
|
|
222700
222711
|
name = "write_file";
|
|
@@ -222710,10 +222721,10 @@ var WriteFileTool = class {
|
|
|
222710
222721
|
ok: true,
|
|
222711
222722
|
display: `Wrote file to ${input.path}`
|
|
222712
222723
|
};
|
|
222713
|
-
} catch (
|
|
222724
|
+
} catch (error) {
|
|
222714
222725
|
return {
|
|
222715
222726
|
ok: false,
|
|
222716
|
-
error:
|
|
222727
|
+
error: error instanceof Error ? error.message : String(error)
|
|
222717
222728
|
};
|
|
222718
222729
|
}
|
|
222719
222730
|
}
|
|
@@ -222766,6 +222777,7 @@ var EditFileTool = class {
|
|
|
222766
222777
|
const N2 = fileLines.length;
|
|
222767
222778
|
let matchedIndex = null;
|
|
222768
222779
|
let occurrences = 0;
|
|
222780
|
+
const matchedIndices = [];
|
|
222769
222781
|
if (M3 > 0 && N2 >= M3) {
|
|
222770
222782
|
for (let i = 0; i <= N2 - M3; i++) {
|
|
222771
222783
|
let match = true;
|
|
@@ -222778,6 +222790,7 @@ var EditFileTool = class {
|
|
|
222778
222790
|
if (match) {
|
|
222779
222791
|
occurrences++;
|
|
222780
222792
|
matchedIndex = i;
|
|
222793
|
+
matchedIndices.push(i);
|
|
222781
222794
|
}
|
|
222782
222795
|
}
|
|
222783
222796
|
}
|
|
@@ -222811,6 +222824,28 @@ var EditFileTool = class {
|
|
|
222811
222824
|
error: `Found multiple whitespace-insensitive occurrences of oldText in "${input.path}". Please provide more surrounding lines.`
|
|
222812
222825
|
};
|
|
222813
222826
|
}
|
|
222827
|
+
if (occurrences > 1 && input.replaceAll) {
|
|
222828
|
+
for (const index of matchedIndices.reverse()) {
|
|
222829
|
+
const matchedFileLines = fileLines.slice(index, index + M3);
|
|
222830
|
+
const adjustedNewLines = adjustIndentation(
|
|
222831
|
+
newLines,
|
|
222832
|
+
matchedFileLines,
|
|
222833
|
+
oldLines
|
|
222834
|
+
);
|
|
222835
|
+
fileLines.splice(index, M3, ...adjustedNewLines);
|
|
222836
|
+
}
|
|
222837
|
+
const writeError = await this.checkAndWrite(
|
|
222838
|
+
input.path,
|
|
222839
|
+
safePath,
|
|
222840
|
+
fileLines.join("\n"),
|
|
222841
|
+
originalContent
|
|
222842
|
+
);
|
|
222843
|
+
if (writeError) return writeError;
|
|
222844
|
+
return {
|
|
222845
|
+
ok: true,
|
|
222846
|
+
display: `Successfully replaced ${occurrences} whitespace-insensitive matches in ${input.path}`
|
|
222847
|
+
};
|
|
222848
|
+
}
|
|
222814
222849
|
if (M3 > 0 && N2 >= M3) {
|
|
222815
222850
|
let bestIndex = -1;
|
|
222816
222851
|
let bestSim = 0;
|
|
@@ -223223,12 +223258,13 @@ ${oldText}
|
|
|
223223
223258
|
return null;
|
|
223224
223259
|
}
|
|
223225
223260
|
var ListFilesInputSchema = z42.object({
|
|
223226
|
-
path: z42.string().optional(),
|
|
223227
|
-
depth: z42.number().optional()
|
|
223261
|
+
path: z42.string().max(4096).optional(),
|
|
223262
|
+
depth: z42.number().int().min(1).max(100).optional(),
|
|
223263
|
+
maxResults: z42.number().int().min(1).max(5e3).optional()
|
|
223228
223264
|
});
|
|
223229
223265
|
var ListFilesTool = class {
|
|
223230
223266
|
name = "list_files";
|
|
223231
|
-
description = "List
|
|
223267
|
+
description = "List files recursively in the project directory with bounded depth/results, ignoring dependencies and build output folders.";
|
|
223232
223268
|
inputSchema = ListFilesInputSchema;
|
|
223233
223269
|
risk = "read";
|
|
223234
223270
|
async execute(input, ctx) {
|
|
@@ -223247,25 +223283,28 @@ var ListFilesTool = class {
|
|
|
223247
223283
|
dot: true,
|
|
223248
223284
|
suppressErrors: true
|
|
223249
223285
|
});
|
|
223286
|
+
const maxResults = input.maxResults ?? 1e3;
|
|
223287
|
+
const boundedFiles = files.slice(0, maxResults);
|
|
223250
223288
|
return {
|
|
223251
223289
|
ok: true,
|
|
223252
|
-
data:
|
|
223253
|
-
display: `Listed ${files.length} files in ${input.path || "project root"}`
|
|
223290
|
+
data: boundedFiles,
|
|
223291
|
+
display: `Listed ${boundedFiles.length}${files.length > boundedFiles.length ? ` of ${files.length}` : ""} files in ${input.path || "project root"}`
|
|
223254
223292
|
};
|
|
223255
|
-
} catch (
|
|
223293
|
+
} catch (error) {
|
|
223256
223294
|
return {
|
|
223257
223295
|
ok: false,
|
|
223258
|
-
error:
|
|
223296
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223259
223297
|
};
|
|
223260
223298
|
}
|
|
223261
223299
|
}
|
|
223262
223300
|
};
|
|
223263
223301
|
var GlobInputSchema = z52.object({
|
|
223264
|
-
pattern: z52.string()
|
|
223302
|
+
pattern: z52.string().min(1).max(4096),
|
|
223303
|
+
maxResults: z52.number().int().min(1).max(5e3).optional()
|
|
223265
223304
|
});
|
|
223266
223305
|
var GlobTool = class {
|
|
223267
223306
|
name = "glob";
|
|
223268
|
-
description = "Find files matching a glob pattern inside the project workspace.";
|
|
223307
|
+
description = "Find files matching a glob pattern inside the project workspace, with a configurable bounded result count.";
|
|
223269
223308
|
inputSchema = GlobInputSchema;
|
|
223270
223309
|
risk = "read";
|
|
223271
223310
|
async execute(input, ctx) {
|
|
@@ -223282,24 +223321,26 @@ var GlobTool = class {
|
|
|
223282
223321
|
dot: true,
|
|
223283
223322
|
suppressErrors: true
|
|
223284
223323
|
});
|
|
223324
|
+
const maxResults = input.maxResults ?? 500;
|
|
223325
|
+
const boundedFiles = files.slice(0, maxResults);
|
|
223285
223326
|
return {
|
|
223286
223327
|
ok: true,
|
|
223287
|
-
data:
|
|
223288
|
-
display: `Glob matches for "${input.pattern}":
|
|
223328
|
+
data: boundedFiles,
|
|
223329
|
+
display: `Glob matches for "${input.pattern}": returned ${boundedFiles.length}${files.length > boundedFiles.length ? ` of ${files.length}` : ""} files`
|
|
223289
223330
|
};
|
|
223290
|
-
} catch (
|
|
223331
|
+
} catch (error) {
|
|
223291
223332
|
return {
|
|
223292
223333
|
ok: false,
|
|
223293
|
-
error:
|
|
223334
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223294
223335
|
};
|
|
223295
223336
|
}
|
|
223296
223337
|
}
|
|
223297
223338
|
};
|
|
223298
223339
|
var GrepInputSchema = z62.object({
|
|
223299
|
-
pattern: z62.string(),
|
|
223300
|
-
path: z62.string().optional(),
|
|
223301
|
-
include: z62.string().optional(),
|
|
223302
|
-
maxResults: z62.number().optional()
|
|
223340
|
+
pattern: z62.string().min(1).max(4096),
|
|
223341
|
+
path: z62.string().max(4096).optional(),
|
|
223342
|
+
include: z62.string().max(4096).optional(),
|
|
223343
|
+
maxResults: z62.number().int().min(1).max(1e3).optional()
|
|
223303
223344
|
});
|
|
223304
223345
|
var GrepTool = class {
|
|
223305
223346
|
name = "grep";
|
|
@@ -223307,7 +223348,7 @@ var GrepTool = class {
|
|
|
223307
223348
|
inputSchema = GrepInputSchema;
|
|
223308
223349
|
risk = "read";
|
|
223309
223350
|
async execute(input, ctx) {
|
|
223310
|
-
const max = input.maxResults
|
|
223351
|
+
const max = input.maxResults ?? 100;
|
|
223311
223352
|
const searchDir = input.path ? resolveSafePath(ctx.cwd, input.path) : ctx.cwd;
|
|
223312
223353
|
try {
|
|
223313
223354
|
const args = [
|
|
@@ -223320,7 +223361,15 @@ var GrepTool = class {
|
|
|
223320
223361
|
args.push("--glob", input.include);
|
|
223321
223362
|
}
|
|
223322
223363
|
args.push(searchDir);
|
|
223323
|
-
const
|
|
223364
|
+
const result = await execa("rg", args, {
|
|
223365
|
+
reject: false,
|
|
223366
|
+
signal: ctx.abortSignal,
|
|
223367
|
+
maxBuffer: 2 * 1024 * 1024
|
|
223368
|
+
});
|
|
223369
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) {
|
|
223370
|
+
throw new Error(result.stderr || `ripgrep exited ${result.exitCode}`);
|
|
223371
|
+
}
|
|
223372
|
+
const stdout = result.stdout;
|
|
223324
223373
|
const matches = [];
|
|
223325
223374
|
const lines = stdout.split("\n");
|
|
223326
223375
|
for (const line of lines) {
|
|
@@ -223345,10 +223394,13 @@ var GrepTool = class {
|
|
|
223345
223394
|
display: `Grep for "${input.pattern}" using ripgrep: found ${matches.length} matches`
|
|
223346
223395
|
};
|
|
223347
223396
|
} catch {
|
|
223348
|
-
|
|
223397
|
+
if (ctx.abortSignal?.aborted) {
|
|
223398
|
+
return { ok: false, error: "Grep was cancelled by the user." };
|
|
223399
|
+
}
|
|
223400
|
+
return this.jsFallback(input, searchDir, ctx.cwd, max, ctx.abortSignal);
|
|
223349
223401
|
}
|
|
223350
223402
|
}
|
|
223351
|
-
async jsFallback(input, searchDir, cwd, max) {
|
|
223403
|
+
async jsFallback(input, searchDir, cwd, max, abortSignal) {
|
|
223352
223404
|
try {
|
|
223353
223405
|
const globPattern = input.include || "**/*";
|
|
223354
223406
|
const files = await glob3(globPattern, {
|
|
@@ -223365,6 +223417,9 @@ var GrepTool = class {
|
|
|
223365
223417
|
});
|
|
223366
223418
|
const matches = [];
|
|
223367
223419
|
for (const file of files) {
|
|
223420
|
+
if (abortSignal?.aborted) {
|
|
223421
|
+
return { ok: false, error: "Grep was cancelled by the user." };
|
|
223422
|
+
}
|
|
223368
223423
|
if (matches.length >= max) break;
|
|
223369
223424
|
const content = readFileSync32(file, "utf8");
|
|
223370
223425
|
if (!content.includes(input.pattern)) continue;
|
|
@@ -223386,17 +223441,17 @@ var GrepTool = class {
|
|
|
223386
223441
|
data: matches,
|
|
223387
223442
|
display: `Grep for "${input.pattern}" using JS fallback: found ${matches.length} matches`
|
|
223388
223443
|
};
|
|
223389
|
-
} catch (
|
|
223444
|
+
} catch (error) {
|
|
223390
223445
|
return {
|
|
223391
223446
|
ok: false,
|
|
223392
|
-
error: `Grep failed: Ripgrep was unavailable and fallback search failed: ${
|
|
223447
|
+
error: `Grep failed: Ripgrep was unavailable and fallback search failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223393
223448
|
};
|
|
223394
223449
|
}
|
|
223395
223450
|
}
|
|
223396
223451
|
};
|
|
223397
223452
|
var BashInputSchema = z72.object({
|
|
223398
|
-
command: z72.string(),
|
|
223399
|
-
timeoutMs: z72.number().optional()
|
|
223453
|
+
command: z72.string().min(1).max(1e5),
|
|
223454
|
+
timeoutMs: z72.number().int().positive().optional()
|
|
223400
223455
|
});
|
|
223401
223456
|
var BashTool = class {
|
|
223402
223457
|
name = "bash";
|
|
@@ -223431,13 +223486,17 @@ ${displayStderr}` : "",
|
|
|
223431
223486
|
return {
|
|
223432
223487
|
ok: exitCode === 0,
|
|
223433
223488
|
data: {
|
|
223434
|
-
stdout,
|
|
223435
|
-
stderr,
|
|
223489
|
+
stdout: displayStdout,
|
|
223490
|
+
stderr: displayStderr,
|
|
223436
223491
|
exitCode
|
|
223437
223492
|
},
|
|
223438
223493
|
display,
|
|
223439
223494
|
error: exitCode === 0 ? void 0 : `Command exited with non-zero status ${exitCode}.`,
|
|
223440
|
-
metadata: {
|
|
223495
|
+
metadata: {
|
|
223496
|
+
truncated,
|
|
223497
|
+
stdoutChars: stdout.length,
|
|
223498
|
+
stderrChars: stderr.length
|
|
223499
|
+
}
|
|
223441
223500
|
};
|
|
223442
223501
|
} catch (error) {
|
|
223443
223502
|
if (error instanceof Error && error.name === "AbortError" || ctx.abortSignal?.aborted) {
|
|
@@ -223454,7 +223513,7 @@ ${displayStderr}` : "",
|
|
|
223454
223513
|
}
|
|
223455
223514
|
};
|
|
223456
223515
|
var RunTestsInputSchema = z82.object({
|
|
223457
|
-
command: z82.string().optional()
|
|
223516
|
+
command: z82.string().trim().min(1).max(1e5).optional()
|
|
223458
223517
|
});
|
|
223459
223518
|
var RunTestsTool = class {
|
|
223460
223519
|
name = "run_tests";
|
|
@@ -223481,9 +223540,10 @@ var RunTestsTool = class {
|
|
|
223481
223540
|
const exitCode = result.exitCode ?? 0;
|
|
223482
223541
|
const displayStdout = LogTruncator.truncate(stdout, 150, 2e4);
|
|
223483
223542
|
const displayStderr = LogTruncator.truncate(stderr, 150, 2e4);
|
|
223543
|
+
const truncated = displayStdout.length !== stdout.length || displayStderr.length !== stderr.length;
|
|
223484
223544
|
return {
|
|
223485
223545
|
ok: exitCode === 0,
|
|
223486
|
-
data: { stdout, stderr, exitCode },
|
|
223546
|
+
data: { stdout: displayStdout, stderr: displayStderr, exitCode },
|
|
223487
223547
|
display: `Ran tests using command "${testCommand}":
|
|
223488
223548
|
|
|
223489
223549
|
Stdout:
|
|
@@ -223493,7 +223553,12 @@ Stderr:
|
|
|
223493
223553
|
${displayStderr}
|
|
223494
223554
|
|
|
223495
223555
|
Exit code: ${exitCode}`,
|
|
223496
|
-
error: exitCode !== 0 ? `Tests failed with exit code ${exitCode}` : void 0
|
|
223556
|
+
error: exitCode !== 0 ? `Tests failed with exit code ${exitCode}` : void 0,
|
|
223557
|
+
metadata: {
|
|
223558
|
+
truncated,
|
|
223559
|
+
stdoutChars: stdout.length,
|
|
223560
|
+
stderrChars: stderr.length
|
|
223561
|
+
}
|
|
223497
223562
|
};
|
|
223498
223563
|
} catch (error) {
|
|
223499
223564
|
if (error instanceof Error && error.name === "AbortError" || ctx.abortSignal?.aborted) {
|
|
@@ -223553,16 +223618,24 @@ var GitDiffTool = class {
|
|
|
223553
223618
|
if (input.staged) {
|
|
223554
223619
|
args.push("--staged");
|
|
223555
223620
|
}
|
|
223556
|
-
const { stdout } = await execa("git", args, {
|
|
223621
|
+
const { stdout } = await execa("git", args, {
|
|
223622
|
+
cwd: ctx.cwd,
|
|
223623
|
+
signal: ctx.abortSignal
|
|
223624
|
+
});
|
|
223625
|
+
const bounded = LogTruncator.truncate(stdout, 300, 4e4);
|
|
223557
223626
|
return {
|
|
223558
223627
|
ok: true,
|
|
223559
|
-
data:
|
|
223560
|
-
display:
|
|
223628
|
+
data: bounded,
|
|
223629
|
+
display: bounded || "No changes detected in git workspace.",
|
|
223630
|
+
metadata: {
|
|
223631
|
+
truncated: bounded.length !== stdout.length,
|
|
223632
|
+
outputChars: stdout.length
|
|
223633
|
+
}
|
|
223561
223634
|
};
|
|
223562
|
-
} catch (
|
|
223635
|
+
} catch (error) {
|
|
223563
223636
|
return {
|
|
223564
223637
|
ok: false,
|
|
223565
|
-
error: `Git diff failed: ${
|
|
223638
|
+
error: `Git diff failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223566
223639
|
};
|
|
223567
223640
|
}
|
|
223568
223641
|
}
|
|
@@ -223573,26 +223646,27 @@ var GitStatusTool = class {
|
|
|
223573
223646
|
description = "Show working tree status of git files (short format).";
|
|
223574
223647
|
inputSchema = GitStatusInputSchema;
|
|
223575
223648
|
risk = "read";
|
|
223576
|
-
async execute(
|
|
223649
|
+
async execute(_input, ctx) {
|
|
223577
223650
|
try {
|
|
223578
223651
|
const { stdout } = await execa("git", ["status", "--short"], {
|
|
223579
|
-
cwd: ctx.cwd
|
|
223652
|
+
cwd: ctx.cwd,
|
|
223653
|
+
signal: ctx.abortSignal
|
|
223580
223654
|
});
|
|
223581
223655
|
return {
|
|
223582
223656
|
ok: true,
|
|
223583
223657
|
data: stdout,
|
|
223584
223658
|
display: stdout ? stdout : "Working tree clean."
|
|
223585
223659
|
};
|
|
223586
|
-
} catch (
|
|
223660
|
+
} catch (error) {
|
|
223587
223661
|
return {
|
|
223588
223662
|
ok: false,
|
|
223589
|
-
error: `Git status failed: ${
|
|
223663
|
+
error: `Git status failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223590
223664
|
};
|
|
223591
223665
|
}
|
|
223592
223666
|
}
|
|
223593
223667
|
};
|
|
223594
223668
|
var GitCommitInputSchema = z112.object({
|
|
223595
|
-
message: z112.string().optional()
|
|
223669
|
+
message: z112.string().trim().min(1).max(1e3).optional()
|
|
223596
223670
|
});
|
|
223597
223671
|
var GitCommitTool = class {
|
|
223598
223672
|
name = "git_commit";
|
|
@@ -223603,7 +223677,8 @@ var GitCommitTool = class {
|
|
|
223603
223677
|
try {
|
|
223604
223678
|
const commitMessage = input.message || "chore: update workspace";
|
|
223605
223679
|
const { stdout } = await execa("git", ["commit", "-m", commitMessage], {
|
|
223606
|
-
cwd: ctx.cwd
|
|
223680
|
+
cwd: ctx.cwd,
|
|
223681
|
+
signal: ctx.abortSignal
|
|
223607
223682
|
});
|
|
223608
223683
|
return {
|
|
223609
223684
|
ok: true,
|
|
@@ -223611,16 +223686,16 @@ var GitCommitTool = class {
|
|
|
223611
223686
|
display: `Staged changes committed:
|
|
223612
223687
|
${stdout}`
|
|
223613
223688
|
};
|
|
223614
|
-
} catch (
|
|
223689
|
+
} catch (error) {
|
|
223615
223690
|
return {
|
|
223616
223691
|
ok: false,
|
|
223617
|
-
error: `Git commit failed: ${
|
|
223692
|
+
error: `Git commit failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223618
223693
|
};
|
|
223619
223694
|
}
|
|
223620
223695
|
}
|
|
223621
223696
|
};
|
|
223622
223697
|
var GitRestoreInputSchema = z122.object({
|
|
223623
|
-
paths: z122.array(z122.string())
|
|
223698
|
+
paths: z122.array(z122.string().trim().min(1).max(4096)).min(1).max(200)
|
|
223624
223699
|
});
|
|
223625
223700
|
var GitRestoreTool = class {
|
|
223626
223701
|
name = "git_restore";
|
|
@@ -223630,17 +223705,18 @@ var GitRestoreTool = class {
|
|
|
223630
223705
|
async execute(input, ctx) {
|
|
223631
223706
|
try {
|
|
223632
223707
|
const { stdout } = await execa("git", ["restore", ...input.paths], {
|
|
223633
|
-
cwd: ctx.cwd
|
|
223708
|
+
cwd: ctx.cwd,
|
|
223709
|
+
signal: ctx.abortSignal
|
|
223634
223710
|
});
|
|
223635
223711
|
return {
|
|
223636
223712
|
ok: true,
|
|
223637
223713
|
data: stdout,
|
|
223638
223714
|
display: `Restored files: ${input.paths.join(", ")}`
|
|
223639
223715
|
};
|
|
223640
|
-
} catch (
|
|
223716
|
+
} catch (error) {
|
|
223641
223717
|
return {
|
|
223642
223718
|
ok: false,
|
|
223643
|
-
error: `Git restore failed: ${
|
|
223719
|
+
error: `Git restore failed: ${error instanceof Error ? error.message : String(error)}`
|
|
223644
223720
|
};
|
|
223645
223721
|
}
|
|
223646
223722
|
}
|
|
@@ -223651,7 +223727,7 @@ var DetectProjectTool = class {
|
|
|
223651
223727
|
description = "Detect project profile including programming languages, frameworks, package manager, test/lint/build scripts, and main entry files.";
|
|
223652
223728
|
inputSchema = DetectProjectInputSchema;
|
|
223653
223729
|
risk = "read";
|
|
223654
|
-
async execute(
|
|
223730
|
+
async execute(_input, ctx) {
|
|
223655
223731
|
try {
|
|
223656
223732
|
const root = ctx.cwd;
|
|
223657
223733
|
const languages = [];
|
|
@@ -223745,10 +223821,10 @@ var DetectProjectTool = class {
|
|
|
223745
223821
|
data,
|
|
223746
223822
|
display: `Detected Project: ${data.detectedLanguages.join(", ")} project. Frameworks: ${data.frameworks.join(", ") || "None"}. PM: ${data.packageManager || "None"}`
|
|
223747
223823
|
};
|
|
223748
|
-
} catch (
|
|
223824
|
+
} catch (error) {
|
|
223749
223825
|
return {
|
|
223750
223826
|
ok: false,
|
|
223751
|
-
error:
|
|
223827
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223752
223828
|
};
|
|
223753
223829
|
}
|
|
223754
223830
|
}
|
|
@@ -223759,7 +223835,7 @@ var InspectProjectTool = class {
|
|
|
223759
223835
|
description = "Inspect project directory structure, returning a tree summary of top-level folders and files.";
|
|
223760
223836
|
inputSchema = InspectProjectInputSchema;
|
|
223761
223837
|
risk = "read";
|
|
223762
|
-
async execute(
|
|
223838
|
+
async execute(_input, ctx) {
|
|
223763
223839
|
try {
|
|
223764
223840
|
const files = await glob4("**/*", {
|
|
223765
223841
|
cwd: ctx.cwd,
|
|
@@ -223790,10 +223866,10 @@ ${treeLines.slice(0, 200).join("\n")}${treeLines.length > 200 ? "\n... [TRUNCATE
|
|
|
223790
223866
|
data: display,
|
|
223791
223867
|
display
|
|
223792
223868
|
};
|
|
223793
|
-
} catch (
|
|
223869
|
+
} catch (error) {
|
|
223794
223870
|
return {
|
|
223795
223871
|
ok: false,
|
|
223796
|
-
error:
|
|
223872
|
+
error: error instanceof Error ? error.message : String(error)
|
|
223797
223873
|
};
|
|
223798
223874
|
}
|
|
223799
223875
|
}
|
|
@@ -223866,12 +223942,15 @@ var SearchSymbolsTool = class {
|
|
|
223866
223942
|
}
|
|
223867
223943
|
}
|
|
223868
223944
|
results.sort((a3, b3) => a3.name.localeCompare(b3.name));
|
|
223869
|
-
const
|
|
223870
|
-
|
|
223945
|
+
const totalMatches = results.length;
|
|
223946
|
+
const boundedResults = results.slice(0, 200);
|
|
223947
|
+
const display = boundedResults.length > 0 ? `Found ${totalMatches} matching symbol(s), returning ${boundedResults.length}:
|
|
223948
|
+
` + boundedResults.map((r2) => `- [${r2.type}] ${r2.name} in ${r2.filePath}:${r2.line}`).join("\n") : `No symbols matching "${input.query}" found.`;
|
|
223871
223949
|
return {
|
|
223872
223950
|
ok: true,
|
|
223873
|
-
data:
|
|
223874
|
-
display
|
|
223951
|
+
data: boundedResults,
|
|
223952
|
+
display,
|
|
223953
|
+
metadata: { truncated: totalMatches > boundedResults.length }
|
|
223875
223954
|
};
|
|
223876
223955
|
} catch (error) {
|
|
223877
223956
|
return {
|
|
@@ -223882,7 +223961,7 @@ var SearchSymbolsTool = class {
|
|
|
223882
223961
|
}
|
|
223883
223962
|
};
|
|
223884
223963
|
var WebSearchInputSchema = z16.object({
|
|
223885
|
-
query: z16.string().describe(
|
|
223964
|
+
query: z16.string().trim().min(1).max(2048).describe(
|
|
223886
223965
|
"Search query. Resolve relative dates using the Runtime Context current date before adding date terms; do not add stale years from model memory."
|
|
223887
223966
|
),
|
|
223888
223967
|
maxResults: z16.number().int().min(1).max(20).describe("Maximum number of search results to return, from 1 to 20.").optional()
|
|
@@ -224575,8 +224654,198 @@ var WebSearchTool = class {
|
|
|
224575
224654
|
};
|
|
224576
224655
|
}
|
|
224577
224656
|
};
|
|
224578
|
-
var
|
|
224579
|
-
|
|
224657
|
+
var WEB_FETCH_MAX_BYTES = 1024 * 1024;
|
|
224658
|
+
var WEB_FETCH_MAX_REDIRECTS = 5;
|
|
224659
|
+
var WebFetchInputSchema = z17.object({
|
|
224660
|
+
url: z17.string().url().max(8192).describe(
|
|
224661
|
+
"Public HTTP(S) URL to read. Local and private network targets are blocked."
|
|
224662
|
+
),
|
|
224663
|
+
maxChars: z17.number().int().min(1e3).max(5e4).describe("Maximum readable characters to return.").optional()
|
|
224664
|
+
});
|
|
224665
|
+
async function defaultAddressResolver(hostname) {
|
|
224666
|
+
return (await lookup(hostname, { all: true, verbatim: true })).map(
|
|
224667
|
+
(entry) => entry.address
|
|
224668
|
+
);
|
|
224669
|
+
}
|
|
224670
|
+
var WebFetchTool = class {
|
|
224671
|
+
constructor(fetchImplementation = globalThis.fetch, resolveAddresses = defaultAddressResolver) {
|
|
224672
|
+
this.fetchImplementation = fetchImplementation;
|
|
224673
|
+
this.resolveAddresses = resolveAddresses;
|
|
224674
|
+
}
|
|
224675
|
+
fetchImplementation;
|
|
224676
|
+
resolveAddresses;
|
|
224677
|
+
name = "web_fetch";
|
|
224678
|
+
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.";
|
|
224679
|
+
inputSchema = WebFetchInputSchema;
|
|
224680
|
+
risk = "network";
|
|
224681
|
+
async execute(input, context) {
|
|
224682
|
+
const controller = new AbortController();
|
|
224683
|
+
const onAbort = () => controller.abort();
|
|
224684
|
+
if (context.abortSignal?.aborted) {
|
|
224685
|
+
return { ok: false, error: "Web fetch was cancelled before it started." };
|
|
224686
|
+
}
|
|
224687
|
+
context.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
224688
|
+
const timeoutMs = Math.max(
|
|
224689
|
+
1e3,
|
|
224690
|
+
Math.min(3e4, context.config?.tools?.webSearch?.timeoutMs ?? 8e3)
|
|
224691
|
+
);
|
|
224692
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
224693
|
+
try {
|
|
224694
|
+
let currentUrl = await assertPublicHttpUrl(
|
|
224695
|
+
input.url,
|
|
224696
|
+
this.resolveAddresses
|
|
224697
|
+
);
|
|
224698
|
+
for (let redirect = 0; redirect <= WEB_FETCH_MAX_REDIRECTS; redirect += 1) {
|
|
224699
|
+
const response = await this.fetchImplementation(currentUrl, {
|
|
224700
|
+
method: "GET",
|
|
224701
|
+
redirect: "manual",
|
|
224702
|
+
signal: controller.signal,
|
|
224703
|
+
headers: {
|
|
224704
|
+
Accept: "text/html, text/plain, application/json, application/xml;q=0.9, text/xml;q=0.9",
|
|
224705
|
+
"User-Agent": "Orbit/0.1 (+https://github.com/Hephaestus-DevKit/Orbit)"
|
|
224706
|
+
}
|
|
224707
|
+
});
|
|
224708
|
+
if (isRedirectStatus(response.status)) {
|
|
224709
|
+
const location = response.headers.get("location");
|
|
224710
|
+
if (!location) {
|
|
224711
|
+
return {
|
|
224712
|
+
ok: false,
|
|
224713
|
+
error: "Web fetch received a redirect without a Location header."
|
|
224714
|
+
};
|
|
224715
|
+
}
|
|
224716
|
+
if (redirect === WEB_FETCH_MAX_REDIRECTS) {
|
|
224717
|
+
return {
|
|
224718
|
+
ok: false,
|
|
224719
|
+
error: "Web fetch exceeded the redirect limit."
|
|
224720
|
+
};
|
|
224721
|
+
}
|
|
224722
|
+
currentUrl = await assertPublicHttpUrl(
|
|
224723
|
+
new URL(location, currentUrl).toString(),
|
|
224724
|
+
this.resolveAddresses
|
|
224725
|
+
);
|
|
224726
|
+
continue;
|
|
224727
|
+
}
|
|
224728
|
+
if (!response.ok) {
|
|
224729
|
+
return {
|
|
224730
|
+
ok: false,
|
|
224731
|
+
error: `Web fetch failed with HTTP ${response.status} ${response.statusText}`.trim()
|
|
224732
|
+
};
|
|
224733
|
+
}
|
|
224734
|
+
const contentType = response.headers.get("content-type") || "text/plain";
|
|
224735
|
+
if (!isReadableContentType(contentType)) {
|
|
224736
|
+
return {
|
|
224737
|
+
ok: false,
|
|
224738
|
+
error: `Web fetch rejected non-text content type "${contentType.slice(0, 200)}".`
|
|
224739
|
+
};
|
|
224740
|
+
}
|
|
224741
|
+
const rawText = await readBoundedResponseText(response);
|
|
224742
|
+
const text = contentType.toLowerCase().includes("text/html") ? htmlToReadableText(rawText) : rawText.trim();
|
|
224743
|
+
const maxChars = input.maxChars ?? 24e3;
|
|
224744
|
+
const bounded = text.length > maxChars ? `${text.slice(0, Math.max(0, maxChars - 35)).trimEnd()}
|
|
224745
|
+
... [truncated by web_fetch]` : text;
|
|
224746
|
+
const output = `Source: ${currentUrl}
|
|
224747
|
+
Content-Type: ${contentType}
|
|
224748
|
+
|
|
224749
|
+
${bounded || "[No readable text content]"}`;
|
|
224750
|
+
return {
|
|
224751
|
+
ok: true,
|
|
224752
|
+
data: output,
|
|
224753
|
+
display: `Fetched ${currentUrl} (${bounded.length} readable characters).`
|
|
224754
|
+
};
|
|
224755
|
+
}
|
|
224756
|
+
return { ok: false, error: "Web fetch exceeded the redirect limit." };
|
|
224757
|
+
} catch (error) {
|
|
224758
|
+
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)}`;
|
|
224759
|
+
return { ok: false, error: redactSecrets(message).slice(0, 2e3) };
|
|
224760
|
+
} finally {
|
|
224761
|
+
clearTimeout(timeout);
|
|
224762
|
+
context.abortSignal?.removeEventListener("abort", onAbort);
|
|
224763
|
+
}
|
|
224764
|
+
}
|
|
224765
|
+
};
|
|
224766
|
+
async function assertPublicHttpUrl(rawUrl, resolveAddresses = defaultAddressResolver) {
|
|
224767
|
+
const url = new URL(rawUrl);
|
|
224768
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
224769
|
+
throw new Error("Only http:// and https:// URLs are supported.");
|
|
224770
|
+
}
|
|
224771
|
+
if (url.username || url.password) {
|
|
224772
|
+
throw new Error("URLs containing credentials are not allowed.");
|
|
224773
|
+
}
|
|
224774
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
224775
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost") || hostname.endsWith(".local") || hostname.endsWith(".internal") || hostname.endsWith(".home.arpa")) {
|
|
224776
|
+
throw new Error("Local and private network URLs are blocked.");
|
|
224777
|
+
}
|
|
224778
|
+
if (isIP(hostname) > 0 && isPrivateOrReservedAddress(hostname)) {
|
|
224779
|
+
throw new Error(
|
|
224780
|
+
"Local, private, or reserved network addresses are blocked."
|
|
224781
|
+
);
|
|
224782
|
+
}
|
|
224783
|
+
const addresses = await resolveAddresses(hostname);
|
|
224784
|
+
if (addresses.length === 0 || addresses.some(isPrivateOrReservedAddress)) {
|
|
224785
|
+
throw new Error(
|
|
224786
|
+
"Local, private, or reserved network addresses are blocked."
|
|
224787
|
+
);
|
|
224788
|
+
}
|
|
224789
|
+
url.hash = "";
|
|
224790
|
+
return url.toString();
|
|
224791
|
+
}
|
|
224792
|
+
function isPrivateOrReservedAddress(address) {
|
|
224793
|
+
const normalized = address.toLowerCase().replace(/^\[|\]$/g, "");
|
|
224794
|
+
if (normalized.includes(":")) {
|
|
224795
|
+
if (normalized === "::1" || normalized === "::") return true;
|
|
224796
|
+
if (/^(?:fc|fd|fe[89ab])/.test(normalized)) return true;
|
|
224797
|
+
const mapped = normalized.match(/::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
224798
|
+
return mapped ? isPrivateOrReservedAddress(mapped[1]) : false;
|
|
224799
|
+
}
|
|
224800
|
+
const parts = normalized.split(".").map(Number);
|
|
224801
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part))) {
|
|
224802
|
+
return true;
|
|
224803
|
+
}
|
|
224804
|
+
const [a3, b3] = parts;
|
|
224805
|
+
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;
|
|
224806
|
+
}
|
|
224807
|
+
function isRedirectStatus(status) {
|
|
224808
|
+
return [301, 302, 303, 307, 308].includes(status);
|
|
224809
|
+
}
|
|
224810
|
+
function isReadableContentType(contentType) {
|
|
224811
|
+
return /^(?:text\/|application\/(?:json|[\w.+-]*\+json|xml|[\w.+-]*\+xml))/i.test(
|
|
224812
|
+
contentType.trim()
|
|
224813
|
+
);
|
|
224814
|
+
}
|
|
224815
|
+
async function readBoundedResponseText(response) {
|
|
224816
|
+
if (!response.body) return "";
|
|
224817
|
+
const reader = response.body.getReader();
|
|
224818
|
+
const chunks = [];
|
|
224819
|
+
let total = 0;
|
|
224820
|
+
while (true) {
|
|
224821
|
+
const next = await reader.read();
|
|
224822
|
+
if (next.done) break;
|
|
224823
|
+
const remaining = WEB_FETCH_MAX_BYTES - total;
|
|
224824
|
+
if (remaining <= 0) {
|
|
224825
|
+
await reader.cancel().catch(() => void 0);
|
|
224826
|
+
break;
|
|
224827
|
+
}
|
|
224828
|
+
const chunk = next.value.byteLength > remaining ? next.value.subarray(0, remaining) : next.value;
|
|
224829
|
+
chunks.push(chunk);
|
|
224830
|
+
total += chunk.byteLength;
|
|
224831
|
+
if (total >= WEB_FETCH_MAX_BYTES) {
|
|
224832
|
+
await reader.cancel().catch(() => void 0);
|
|
224833
|
+
break;
|
|
224834
|
+
}
|
|
224835
|
+
}
|
|
224836
|
+
const combined = new Uint8Array(total);
|
|
224837
|
+
let offset = 0;
|
|
224838
|
+
for (const chunk of chunks) {
|
|
224839
|
+
combined.set(chunk, offset);
|
|
224840
|
+
offset += chunk.byteLength;
|
|
224841
|
+
}
|
|
224842
|
+
return new TextDecoder("utf-8", { fatal: false }).decode(combined);
|
|
224843
|
+
}
|
|
224844
|
+
function htmlToReadableText(html) {
|
|
224845
|
+
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();
|
|
224846
|
+
}
|
|
224847
|
+
var FindSymbolReferencesInputSchema = z18.object({
|
|
224848
|
+
symbol: z18.string().trim().min(1).max(512).describe("The symbol name to search references for.")
|
|
224580
224849
|
});
|
|
224581
224850
|
function escapeRegExp(value) {
|
|
224582
224851
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -224605,6 +224874,7 @@ var FindSymbolReferencesTool = class {
|
|
|
224605
224874
|
};
|
|
224606
224875
|
}
|
|
224607
224876
|
const results = [];
|
|
224877
|
+
let truncated = false;
|
|
224608
224878
|
const escapedSymbol = escapeRegExp(input.symbol);
|
|
224609
224879
|
const symbolRegex = new RegExp(
|
|
224610
224880
|
`(?<![\\p{ID_Continue}$\\u200C\\u200D])${escapedSymbol}(?![\\p{ID_Continue}$\\u200C\\u200D])`,
|
|
@@ -224635,11 +224905,16 @@ var FindSymbolReferencesTool = class {
|
|
|
224635
224905
|
results.push({
|
|
224636
224906
|
file,
|
|
224637
224907
|
line: idx + 1,
|
|
224638
|
-
content: trimmed
|
|
224908
|
+
content: trimmed.slice(0, 500)
|
|
224639
224909
|
});
|
|
224910
|
+
if (results.length >= 300) {
|
|
224911
|
+
truncated = true;
|
|
224912
|
+
break;
|
|
224913
|
+
}
|
|
224640
224914
|
}
|
|
224641
224915
|
}
|
|
224642
224916
|
}
|
|
224917
|
+
if (truncated) break;
|
|
224643
224918
|
}
|
|
224644
224919
|
const display = results.length > 0 ? `Found ${results.length} references for symbol "${input.symbol}":
|
|
224645
224920
|
` + results.map(
|
|
@@ -224648,7 +224923,8 @@ var FindSymbolReferencesTool = class {
|
|
|
224648
224923
|
return {
|
|
224649
224924
|
ok: true,
|
|
224650
224925
|
data: results,
|
|
224651
|
-
display
|
|
224926
|
+
display,
|
|
224927
|
+
metadata: { truncated }
|
|
224652
224928
|
};
|
|
224653
224929
|
} catch (error) {
|
|
224654
224930
|
return {
|
|
@@ -224658,6 +224934,55 @@ var FindSymbolReferencesTool = class {
|
|
|
224658
224934
|
}
|
|
224659
224935
|
}
|
|
224660
224936
|
};
|
|
224937
|
+
var UpdatePlanInputSchema = z19.object({
|
|
224938
|
+
explanation: z19.string().trim().min(1).max(1e3).describe("Brief reason for changing the plan.").optional(),
|
|
224939
|
+
plan: z19.array(
|
|
224940
|
+
z19.object({
|
|
224941
|
+
step: z19.string().trim().min(1).max(1e3),
|
|
224942
|
+
status: z19.enum(["pending", "in_progress", "completed"])
|
|
224943
|
+
})
|
|
224944
|
+
).max(100)
|
|
224945
|
+
}).superRefine((value, ctx) => {
|
|
224946
|
+
if (value.plan.filter((item) => item.status === "in_progress").length > 1) {
|
|
224947
|
+
ctx.addIssue({
|
|
224948
|
+
code: z19.ZodIssueCode.custom,
|
|
224949
|
+
path: ["plan"],
|
|
224950
|
+
message: "At most one plan item may be in progress."
|
|
224951
|
+
});
|
|
224952
|
+
}
|
|
224953
|
+
const normalizedSteps = value.plan.map((item) => item.step.toLowerCase());
|
|
224954
|
+
if (new Set(normalizedSteps).size !== normalizedSteps.length) {
|
|
224955
|
+
ctx.addIssue({
|
|
224956
|
+
code: z19.ZodIssueCode.custom,
|
|
224957
|
+
path: ["plan"],
|
|
224958
|
+
message: "Plan steps must be unique."
|
|
224959
|
+
});
|
|
224960
|
+
}
|
|
224961
|
+
});
|
|
224962
|
+
var UpdatePlanTool = class {
|
|
224963
|
+
name = "update_plan";
|
|
224964
|
+
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.";
|
|
224965
|
+
inputSchema = UpdatePlanInputSchema;
|
|
224966
|
+
risk = "write";
|
|
224967
|
+
async execute(input, context) {
|
|
224968
|
+
if (!context.services?.updatePlan) {
|
|
224969
|
+
return { ok: false, error: "Task-plan service is unavailable." };
|
|
224970
|
+
}
|
|
224971
|
+
try {
|
|
224972
|
+
const data = await context.services.updatePlan(input);
|
|
224973
|
+
return {
|
|
224974
|
+
ok: true,
|
|
224975
|
+
data,
|
|
224976
|
+
display: `Updated task plan with ${input.plan.length} step(s).`
|
|
224977
|
+
};
|
|
224978
|
+
} catch (error) {
|
|
224979
|
+
return {
|
|
224980
|
+
ok: false,
|
|
224981
|
+
error: `Unable to update task plan: ${error instanceof Error ? error.message : String(error)}`
|
|
224982
|
+
};
|
|
224983
|
+
}
|
|
224984
|
+
}
|
|
224985
|
+
};
|
|
224661
224986
|
toolRegistry.register(new ReadFileTool());
|
|
224662
224987
|
toolRegistry.register(new WriteFileTool());
|
|
224663
224988
|
toolRegistry.register(new EditFileTool());
|
|
@@ -224674,7 +224999,9 @@ toolRegistry.register(new DetectProjectTool());
|
|
|
224674
224999
|
toolRegistry.register(new InspectProjectTool());
|
|
224675
225000
|
toolRegistry.register(new SearchSymbolsTool());
|
|
224676
225001
|
toolRegistry.register(new WebSearchTool());
|
|
225002
|
+
toolRegistry.register(new WebFetchTool());
|
|
224677
225003
|
toolRegistry.register(new FindSymbolReferencesTool());
|
|
225004
|
+
toolRegistry.register(new UpdatePlanTool());
|
|
224678
225005
|
|
|
224679
225006
|
// ../sandbox/dist/index.js
|
|
224680
225007
|
import {
|
|
@@ -225077,7 +225404,7 @@ var import_typescript = __toESM(require_typescript(), 1);
|
|
|
225077
225404
|
import { existsSync as existsSync11, promises as fsPromises2 } from "fs";
|
|
225078
225405
|
import { dirname as dirname5, resolve as resolve5 } from "path";
|
|
225079
225406
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
225080
|
-
import { z as
|
|
225407
|
+
import { z as z20 } from "zod";
|
|
225081
225408
|
import { basename as basename3, join as join10 } from "path";
|
|
225082
225409
|
import { existsSync as existsSync25, promises as fsPromises3 } from "fs";
|
|
225083
225410
|
import { dirname as dirname22, resolve as resolve22 } from "path";
|
|
@@ -225093,10 +225420,13 @@ var ProjectIndexer = class {
|
|
|
225093
225420
|
cwd;
|
|
225094
225421
|
async index() {
|
|
225095
225422
|
const tool = new DetectProjectTool();
|
|
225096
|
-
const result = await tool.execute(
|
|
225097
|
-
|
|
225098
|
-
|
|
225099
|
-
|
|
225423
|
+
const result = await tool.execute(
|
|
225424
|
+
{},
|
|
225425
|
+
{
|
|
225426
|
+
cwd: this.cwd,
|
|
225427
|
+
sessionId: "indexer"
|
|
225428
|
+
}
|
|
225429
|
+
);
|
|
225100
225430
|
if (result.ok && result.data) {
|
|
225101
225431
|
return result.data;
|
|
225102
225432
|
}
|
|
@@ -225245,29 +225575,29 @@ function getOrbitCachePath(cwd, fileName) {
|
|
|
225245
225575
|
const relativePath = branchName ? join10(".orbit", "branches", branchName, fileName) : join10(".orbit", fileName);
|
|
225246
225576
|
return resolveSafePath(cwd, relativePath);
|
|
225247
225577
|
}
|
|
225248
|
-
var EmbeddingVectorSchema =
|
|
225249
|
-
var DocumentSchema =
|
|
225250
|
-
id:
|
|
225251
|
-
text:
|
|
225578
|
+
var EmbeddingVectorSchema = z20.array(z20.number().finite()).min(1).max(32768);
|
|
225579
|
+
var DocumentSchema = z20.object({
|
|
225580
|
+
id: z20.string().min(1).max(4096),
|
|
225581
|
+
text: z20.string().max(2e6),
|
|
225252
225582
|
vector: EmbeddingVectorSchema.optional(),
|
|
225253
|
-
metadata:
|
|
225254
|
-
filePath:
|
|
225255
|
-
symbolName:
|
|
225256
|
-
symbolType:
|
|
225257
|
-
startLine:
|
|
225258
|
-
endLine:
|
|
225583
|
+
metadata: z20.object({
|
|
225584
|
+
filePath: z20.string().min(1).max(4096),
|
|
225585
|
+
symbolName: z20.string().max(4096).optional(),
|
|
225586
|
+
symbolType: z20.string().max(256).optional(),
|
|
225587
|
+
startLine: z20.number().int().positive(),
|
|
225588
|
+
endLine: z20.number().int().positive()
|
|
225259
225589
|
})
|
|
225260
225590
|
});
|
|
225261
|
-
var DBHeaderSchema =
|
|
225262
|
-
modelName:
|
|
225263
|
-
dimension:
|
|
225264
|
-
updatedAt:
|
|
225591
|
+
var DBHeaderSchema = z20.object({
|
|
225592
|
+
modelName: z20.string().min(1).max(1024),
|
|
225593
|
+
dimension: z20.number().int().positive().max(32768),
|
|
225594
|
+
updatedAt: z20.string().min(1)
|
|
225265
225595
|
});
|
|
225266
|
-
var VectorStoreFileSchema =
|
|
225596
|
+
var VectorStoreFileSchema = z20.object({
|
|
225267
225597
|
header: DBHeaderSchema.nullable(),
|
|
225268
|
-
documents:
|
|
225598
|
+
documents: z20.array(DocumentSchema)
|
|
225269
225599
|
});
|
|
225270
|
-
var LegacyVectorStoreFileSchema =
|
|
225600
|
+
var LegacyVectorStoreFileSchema = z20.array(DocumentSchema);
|
|
225271
225601
|
var JSVectorStore = class {
|
|
225272
225602
|
constructor(cwd, modelName) {
|
|
225273
225603
|
this.cwd = cwd;
|
|
@@ -225286,7 +225616,7 @@ var JSVectorStore = class {
|
|
|
225286
225616
|
if (!this.loaded) {
|
|
225287
225617
|
await this.load();
|
|
225288
225618
|
}
|
|
225289
|
-
const validatedDocs =
|
|
225619
|
+
const validatedDocs = z20.array(DocumentSchema).parse(docs);
|
|
225290
225620
|
const vectorDimensions = new Set(
|
|
225291
225621
|
validatedDocs.flatMap(
|
|
225292
225622
|
(doc) => doc.vector === void 0 ? [] : [doc.vector.length]
|
|
@@ -227252,7 +227582,7 @@ function lD(e2) {
|
|
|
227252
227582
|
function v(e2, u) {
|
|
227253
227583
|
e2.isTTY && e2.setRawMode(u);
|
|
227254
227584
|
}
|
|
227255
|
-
var
|
|
227585
|
+
var z21 = /* @__PURE__ */ new Map([["k", "up"], ["j", "down"], ["h", "left"], ["l", "right"]]);
|
|
227256
227586
|
var xD = /* @__PURE__ */ new Set(["up", "down", "left", "right", "space", "enter"]);
|
|
227257
227587
|
var x = class {
|
|
227258
227588
|
constructor({ render: u, input: F = $2, output: t = k, ...s }, C2 = true) {
|
|
@@ -227287,7 +227617,7 @@ var x = class {
|
|
|
227287
227617
|
this.subscribers.clear();
|
|
227288
227618
|
}
|
|
227289
227619
|
onKeypress(u, F) {
|
|
227290
|
-
if (this.state === "error" && (this.state = "active"), F?.name && !this._track &&
|
|
227620
|
+
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
227621
|
if (this.opts.validate) {
|
|
227292
227622
|
const t = this.opts.validate(this.value);
|
|
227293
227623
|
t && (this.error = t, this.state = "error", this.rl.write(this.value));
|
|
@@ -227498,7 +227828,7 @@ var M2 = o("\u25FB", "[ ]");
|
|
|
227498
227828
|
var U2 = o("\u25AA", "\u2022");
|
|
227499
227829
|
var B = o("\u2500", "-");
|
|
227500
227830
|
var Z2 = o("\u256E", "+");
|
|
227501
|
-
var
|
|
227831
|
+
var z25 = o("\u251C", "+");
|
|
227502
227832
|
var X2 = o("\u256F", "+");
|
|
227503
227833
|
var J2 = o("\u25CF", "\u2022");
|
|
227504
227834
|
var Y2 = o("\u25C6", "*");
|
|
@@ -228360,34 +228690,35 @@ import { promisify } from "util";
|
|
|
228360
228690
|
|
|
228361
228691
|
// ../mcp/dist/index.js
|
|
228362
228692
|
import { spawn } from "child_process";
|
|
228363
|
-
import {
|
|
228693
|
+
import { createHash as createHash4 } from "crypto";
|
|
228694
|
+
import { z as z26 } from "zod";
|
|
228364
228695
|
var MCP_REQUEST_TIMEOUT_MS = 3e4;
|
|
228365
228696
|
var MCP_STDIO_LINE_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
228366
228697
|
var MCP_STDERR_LIMIT_CHARS = 4e3;
|
|
228367
|
-
var MCPToolDefinitionSchema =
|
|
228368
|
-
name:
|
|
228369
|
-
description:
|
|
228370
|
-
inputSchema:
|
|
228698
|
+
var MCPToolDefinitionSchema = z26.object({
|
|
228699
|
+
name: z26.string().min(1).max(512),
|
|
228700
|
+
description: z26.string().max(1e4).default(""),
|
|
228701
|
+
inputSchema: z26.record(z26.unknown()).default({})
|
|
228371
228702
|
});
|
|
228372
|
-
var MCPToolsListSchema =
|
|
228373
|
-
tools:
|
|
228703
|
+
var MCPToolsListSchema = z26.object({
|
|
228704
|
+
tools: z26.array(MCPToolDefinitionSchema).max(1e4).default([])
|
|
228374
228705
|
});
|
|
228375
|
-
var MCPToolCallResultSchema =
|
|
228376
|
-
content:
|
|
228377
|
-
|
|
228378
|
-
type:
|
|
228379
|
-
text:
|
|
228706
|
+
var MCPToolCallResultSchema = z26.object({
|
|
228707
|
+
content: z26.array(
|
|
228708
|
+
z26.object({
|
|
228709
|
+
type: z26.string().max(100),
|
|
228710
|
+
text: z26.string().max(MCP_STDIO_LINE_LIMIT_BYTES).optional()
|
|
228380
228711
|
}).passthrough()
|
|
228381
228712
|
).max(1e4).default([]),
|
|
228382
|
-
isError:
|
|
228713
|
+
isError: z26.boolean().default(false)
|
|
228383
228714
|
}).passthrough();
|
|
228384
|
-
var MCPResponseSchema =
|
|
228385
|
-
jsonrpc:
|
|
228386
|
-
id:
|
|
228387
|
-
result:
|
|
228388
|
-
error:
|
|
228389
|
-
code:
|
|
228390
|
-
message:
|
|
228715
|
+
var MCPResponseSchema = z26.object({
|
|
228716
|
+
jsonrpc: z26.literal("2.0"),
|
|
228717
|
+
id: z26.number().int().positive(),
|
|
228718
|
+
result: z26.unknown().optional(),
|
|
228719
|
+
error: z26.object({
|
|
228720
|
+
code: z26.number().int(),
|
|
228721
|
+
message: z26.string().max(1e4)
|
|
228391
228722
|
}).passthrough().optional()
|
|
228392
228723
|
}).refine((message) => message.result !== void 0 || message.error, {
|
|
228393
228724
|
message: "MCP response requires a result or error."
|
|
@@ -228484,14 +228815,18 @@ var MCPClient = class {
|
|
|
228484
228815
|
}
|
|
228485
228816
|
}
|
|
228486
228817
|
/** Call one validated MCP tool with JSON-object arguments. */
|
|
228487
|
-
async callTool(originalToolName, args) {
|
|
228818
|
+
async callTool(originalToolName, args, abortSignal) {
|
|
228488
228819
|
if (!this.isConnected) {
|
|
228489
228820
|
throw new Error(`MCP client "${this.serverName}" is not connected.`);
|
|
228490
228821
|
}
|
|
228491
|
-
const result = await this.sendRequest(
|
|
228492
|
-
|
|
228493
|
-
|
|
228494
|
-
|
|
228822
|
+
const result = await this.sendRequest(
|
|
228823
|
+
"tools/call",
|
|
228824
|
+
{
|
|
228825
|
+
name: originalToolName,
|
|
228826
|
+
arguments: args
|
|
228827
|
+
},
|
|
228828
|
+
abortSignal
|
|
228829
|
+
);
|
|
228495
228830
|
return MCPToolCallResultSchema.parse(result);
|
|
228496
228831
|
}
|
|
228497
228832
|
/** Stop the child and reject outstanding requests. */
|
|
@@ -228525,8 +228860,12 @@ var MCPClient = class {
|
|
|
228525
228860
|
);
|
|
228526
228861
|
return result.tools;
|
|
228527
228862
|
}
|
|
228528
|
-
sendRequest(method, params) {
|
|
228863
|
+
sendRequest(method, params, abortSignal) {
|
|
228529
228864
|
return new Promise((resolve15, reject) => {
|
|
228865
|
+
if (abortSignal?.aborted) {
|
|
228866
|
+
reject(createAbortError(`MCP request "${method}" was cancelled.`));
|
|
228867
|
+
return;
|
|
228868
|
+
}
|
|
228530
228869
|
const stdin = this.child?.stdin;
|
|
228531
228870
|
if (!this.isConnected || !stdin || !stdin.writable) {
|
|
228532
228871
|
reject(new Error("MCP server process is not running."));
|
|
@@ -228534,14 +228873,37 @@ var MCPClient = class {
|
|
|
228534
228873
|
}
|
|
228535
228874
|
const id = this.nextRequestId++;
|
|
228536
228875
|
const timeout = setTimeout(() => {
|
|
228876
|
+
const pending = this.pendingRequests.get(id);
|
|
228537
228877
|
this.pendingRequests.delete(id);
|
|
228878
|
+
pending?.removeAbortListener?.();
|
|
228538
228879
|
reject(
|
|
228539
228880
|
new Error(
|
|
228540
228881
|
`MCP request "${method}" (id: ${id}) timed out after ${MCP_REQUEST_TIMEOUT_MS}ms.`
|
|
228541
228882
|
)
|
|
228542
228883
|
);
|
|
228543
228884
|
}, MCP_REQUEST_TIMEOUT_MS);
|
|
228544
|
-
|
|
228885
|
+
const onAbort = () => {
|
|
228886
|
+
const pending = this.pendingRequests.get(id);
|
|
228887
|
+
if (!pending) return;
|
|
228888
|
+
clearTimeout(pending.timeout);
|
|
228889
|
+
this.pendingRequests.delete(id);
|
|
228890
|
+
pending.removeAbortListener?.();
|
|
228891
|
+
this.sendNotification("notifications/cancelled", {
|
|
228892
|
+
requestId: id,
|
|
228893
|
+
reason: "Orbit tool execution cancelled"
|
|
228894
|
+
});
|
|
228895
|
+
pending.reject(
|
|
228896
|
+
createAbortError(`MCP request "${method}" was cancelled.`)
|
|
228897
|
+
);
|
|
228898
|
+
};
|
|
228899
|
+
const removeAbortListener = abortSignal ? () => abortSignal.removeEventListener("abort", onAbort) : void 0;
|
|
228900
|
+
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
228901
|
+
this.pendingRequests.set(id, {
|
|
228902
|
+
resolve: resolve15,
|
|
228903
|
+
reject,
|
|
228904
|
+
timeout,
|
|
228905
|
+
removeAbortListener
|
|
228906
|
+
});
|
|
228545
228907
|
stdin.write(
|
|
228546
228908
|
`${JSON.stringify({ jsonrpc: "2.0", id, method, params })}
|
|
228547
228909
|
`,
|
|
@@ -228551,6 +228913,7 @@ var MCPClient = class {
|
|
|
228551
228913
|
if (!pending) return;
|
|
228552
228914
|
clearTimeout(pending.timeout);
|
|
228553
228915
|
this.pendingRequests.delete(id);
|
|
228916
|
+
pending.removeAbortListener?.();
|
|
228554
228917
|
pending.reject(
|
|
228555
228918
|
new Error(`Unable to write MCP request: ${safeMessage(error)}`)
|
|
228556
228919
|
);
|
|
@@ -228593,6 +228956,7 @@ var MCPClient = class {
|
|
|
228593
228956
|
if (!pending) return;
|
|
228594
228957
|
clearTimeout(pending.timeout);
|
|
228595
228958
|
this.pendingRequests.delete(response.id);
|
|
228959
|
+
pending.removeAbortListener?.();
|
|
228596
228960
|
if (response.error) {
|
|
228597
228961
|
pending.reject(
|
|
228598
228962
|
new Error(
|
|
@@ -228607,6 +228971,7 @@ var MCPClient = class {
|
|
|
228607
228971
|
this.isConnected = false;
|
|
228608
228972
|
for (const pending of this.pendingRequests.values()) {
|
|
228609
228973
|
clearTimeout(pending.timeout);
|
|
228974
|
+
pending.removeAbortListener?.();
|
|
228610
228975
|
pending.reject(error);
|
|
228611
228976
|
}
|
|
228612
228977
|
this.pendingRequests.clear();
|
|
@@ -228619,20 +228984,26 @@ function safeMessage(error) {
|
|
|
228619
228984
|
var DynamicMCPTool = class {
|
|
228620
228985
|
constructor(serverName, toolDefinition, risk, client) {
|
|
228621
228986
|
this.client = client;
|
|
228622
|
-
this.name =
|
|
228987
|
+
this.name = createMcpToolName(serverName, toolDefinition.name);
|
|
228623
228988
|
this.description = `[MCP Tool: ${serverName}] ${toolDefinition.description}`;
|
|
228624
228989
|
this.risk = risk;
|
|
228625
228990
|
this.originalToolName = toolDefinition.name;
|
|
228991
|
+
this.inputJsonSchema = toolDefinition.inputSchema;
|
|
228626
228992
|
}
|
|
228627
228993
|
client;
|
|
228628
228994
|
name;
|
|
228629
228995
|
description;
|
|
228630
|
-
inputSchema =
|
|
228996
|
+
inputSchema = z26.record(z26.unknown());
|
|
228997
|
+
inputJsonSchema;
|
|
228631
228998
|
risk;
|
|
228632
228999
|
originalToolName;
|
|
228633
|
-
async execute(input,
|
|
229000
|
+
async execute(input, context) {
|
|
228634
229001
|
try {
|
|
228635
|
-
const response = await this.client.callTool(
|
|
229002
|
+
const response = await this.client.callTool(
|
|
229003
|
+
this.originalToolName,
|
|
229004
|
+
input,
|
|
229005
|
+
context.abortSignal
|
|
229006
|
+
);
|
|
228636
229007
|
const text = response.content.map((content) => content.text || "").filter(Boolean).join("\n");
|
|
228637
229008
|
if (response.isError) {
|
|
228638
229009
|
return {
|
|
@@ -228649,6 +229020,19 @@ var DynamicMCPTool = class {
|
|
|
228649
229020
|
}
|
|
228650
229021
|
}
|
|
228651
229022
|
};
|
|
229023
|
+
function createMcpToolName(serverName, originalToolName) {
|
|
229024
|
+
const rawName = `mcp__${serverName}__${originalToolName}`;
|
|
229025
|
+
if (/^[A-Za-z0-9_-]{1,64}$/.test(rawName)) return rawName;
|
|
229026
|
+
const normalized = rawName.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
229027
|
+
const digest = createHash4("sha256").update(rawName).digest("hex").slice(0, 8);
|
|
229028
|
+
const prefix = (normalized || "mcp_tool").slice(0, 55).replace(/_+$/g, "");
|
|
229029
|
+
return `${prefix}_${digest}`;
|
|
229030
|
+
}
|
|
229031
|
+
function createAbortError(message) {
|
|
229032
|
+
const error = new Error(message);
|
|
229033
|
+
error.name = "AbortError";
|
|
229034
|
+
return error;
|
|
229035
|
+
}
|
|
228652
229036
|
|
|
228653
229037
|
// ../core/dist/index.js
|
|
228654
229038
|
import { createHash as createHash32 } from "crypto";
|
|
@@ -228752,6 +229136,13 @@ var PermissionEngine = class {
|
|
|
228752
229136
|
"multi_replace_file_content"
|
|
228753
229137
|
]);
|
|
228754
229138
|
const safeArgs = isRecord2(args) ? args : {};
|
|
229139
|
+
if (toolName === "update_plan") {
|
|
229140
|
+
return {
|
|
229141
|
+
action: "allow",
|
|
229142
|
+
reason: "Updating the current chat plan does not modify project files.",
|
|
229143
|
+
risk: "write"
|
|
229144
|
+
};
|
|
229145
|
+
}
|
|
228755
229146
|
if (readTools.has(toolName) || writeTools.has(toolName)) {
|
|
228756
229147
|
targetPath = firstString(
|
|
228757
229148
|
safeArgs.path,
|
|
@@ -228894,8 +229285,8 @@ function firstString(...values) {
|
|
|
228894
229285
|
}
|
|
228895
229286
|
|
|
228896
229287
|
// ../session/dist/index.js
|
|
228897
|
-
import { z as
|
|
228898
|
-
import { createHash as
|
|
229288
|
+
import { z as z27 } from "zod";
|
|
229289
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "crypto";
|
|
228899
229290
|
import { isAbsolute as isAbsolute4, join as join11, relative as relative2, resolve as resolve6, sep } from "path";
|
|
228900
229291
|
import {
|
|
228901
229292
|
appendFileSync,
|
|
@@ -228925,89 +229316,89 @@ import {
|
|
|
228925
229316
|
} from "fs";
|
|
228926
229317
|
import { homedir as homedir5 } from "os";
|
|
228927
229318
|
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 =
|
|
229319
|
+
import { z as z28 } from "zod";
|
|
229320
|
+
var SafeObjectKeySchema = z27.string().refine(
|
|
228930
229321
|
(key) => !["__proto__", "constructor", "prototype"].includes(key),
|
|
228931
229322
|
"Unsafe object key."
|
|
228932
229323
|
);
|
|
228933
|
-
var JsonValueSchema =
|
|
228934
|
-
() =>
|
|
228935
|
-
|
|
228936
|
-
|
|
228937
|
-
|
|
228938
|
-
|
|
228939
|
-
|
|
228940
|
-
|
|
229324
|
+
var JsonValueSchema = z27.lazy(
|
|
229325
|
+
() => z27.union([
|
|
229326
|
+
z27.string(),
|
|
229327
|
+
z27.number().finite(),
|
|
229328
|
+
z27.boolean(),
|
|
229329
|
+
z27.null(),
|
|
229330
|
+
z27.array(JsonValueSchema),
|
|
229331
|
+
z27.record(SafeObjectKeySchema, JsonValueSchema)
|
|
228941
229332
|
])
|
|
228942
229333
|
);
|
|
228943
|
-
var JsonTextSchema =
|
|
229334
|
+
var JsonTextSchema = z27.string().superRefine((value, context) => {
|
|
228944
229335
|
try {
|
|
228945
229336
|
const parsed = JSON.parse(value);
|
|
228946
229337
|
if (JsonValueSchema.safeParse(parsed).success) return;
|
|
228947
229338
|
} catch {
|
|
228948
229339
|
}
|
|
228949
229340
|
context.addIssue({
|
|
228950
|
-
code:
|
|
229341
|
+
code: z27.ZodIssueCode.custom,
|
|
228951
229342
|
message: "Expected valid, safe JSON text."
|
|
228952
229343
|
});
|
|
228953
229344
|
});
|
|
228954
|
-
var SessionIdSchema =
|
|
228955
|
-
var SessionSchema =
|
|
228956
|
-
schemaVersion:
|
|
229345
|
+
var SessionIdSchema = z27.string().regex(/^sess_[a-z]+-[a-z]+-\d{3}$/, "Invalid Orbit session id.");
|
|
229346
|
+
var SessionSchema = z27.object({
|
|
229347
|
+
schemaVersion: z27.literal(1).default(1),
|
|
228957
229348
|
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:
|
|
229349
|
+
cwd: z27.string().min(1),
|
|
229350
|
+
title: z27.string(),
|
|
229351
|
+
goal: z27.string().trim().min(1).max(4e3).optional(),
|
|
229352
|
+
status: z27.enum(["active", "completed", "failed", "aborted"]),
|
|
229353
|
+
createdAt: z27.string().datetime(),
|
|
229354
|
+
updatedAt: z27.string().datetime(),
|
|
229355
|
+
provider: z27.string().min(1),
|
|
229356
|
+
model: z27.string().min(1),
|
|
229357
|
+
totalInputTokens: z27.number().int().nonnegative(),
|
|
229358
|
+
totalOutputTokens: z27.number().int().nonnegative(),
|
|
229359
|
+
totalCostEstimate: z27.number().finite().nonnegative(),
|
|
229360
|
+
totalCacheReadTokens: z27.number().int().nonnegative().optional(),
|
|
229361
|
+
archivedAt: z27.string().datetime().optional()
|
|
228971
229362
|
});
|
|
228972
|
-
var SessionEventSchema =
|
|
228973
|
-
id:
|
|
229363
|
+
var SessionEventSchema = z27.object({
|
|
229364
|
+
id: z27.string().min(1),
|
|
228974
229365
|
sessionId: SessionIdSchema,
|
|
228975
|
-
type:
|
|
229366
|
+
type: z27.string().min(1),
|
|
228976
229367
|
payload: JsonValueSchema,
|
|
228977
|
-
createdAt:
|
|
229368
|
+
createdAt: z27.string().datetime()
|
|
228978
229369
|
});
|
|
228979
|
-
var TaskPlanItemSchema =
|
|
228980
|
-
id:
|
|
228981
|
-
text:
|
|
228982
|
-
status:
|
|
228983
|
-
createdAt:
|
|
228984
|
-
updatedAt:
|
|
229370
|
+
var TaskPlanItemSchema = z27.object({
|
|
229371
|
+
id: z27.string().regex(/^step_[a-z0-9-]+$/, "Invalid task-plan item id."),
|
|
229372
|
+
text: z27.string().trim().min(1).max(1e3),
|
|
229373
|
+
status: z27.enum(["pending", "in_progress", "completed"]),
|
|
229374
|
+
createdAt: z27.string().datetime(),
|
|
229375
|
+
updatedAt: z27.string().datetime()
|
|
228985
229376
|
});
|
|
228986
|
-
var TaskPlanSchema =
|
|
228987
|
-
schemaVersion:
|
|
229377
|
+
var TaskPlanSchema = z27.object({
|
|
229378
|
+
schemaVersion: z27.literal(1).default(1),
|
|
228988
229379
|
sessionId: SessionIdSchema,
|
|
228989
|
-
goal:
|
|
228990
|
-
items:
|
|
228991
|
-
updatedAt:
|
|
229380
|
+
goal: z27.string().trim().min(1).max(4e3).optional(),
|
|
229381
|
+
items: z27.array(TaskPlanItemSchema).max(100),
|
|
229382
|
+
updatedAt: z27.string().datetime()
|
|
228992
229383
|
});
|
|
228993
|
-
var SessionMetricsSchema =
|
|
229384
|
+
var SessionMetricsSchema = z27.object({
|
|
228994
229385
|
sessionId: SessionIdSchema,
|
|
228995
|
-
eventCount:
|
|
228996
|
-
toolRuns:
|
|
228997
|
-
toolFailures:
|
|
228998
|
-
deniedTools:
|
|
228999
|
-
filesChanged:
|
|
229000
|
-
modelSwitches:
|
|
229001
|
-
routingDecisions:
|
|
229002
|
-
fastRoutes:
|
|
229003
|
-
qualityRoutes:
|
|
229004
|
-
compactions:
|
|
229005
|
-
resumedCount:
|
|
229386
|
+
eventCount: z27.number().int().nonnegative(),
|
|
229387
|
+
toolRuns: z27.number().int().nonnegative(),
|
|
229388
|
+
toolFailures: z27.number().int().nonnegative(),
|
|
229389
|
+
deniedTools: z27.number().int().nonnegative(),
|
|
229390
|
+
filesChanged: z27.number().int().nonnegative(),
|
|
229391
|
+
modelSwitches: z27.number().int().nonnegative(),
|
|
229392
|
+
routingDecisions: z27.number().int().nonnegative(),
|
|
229393
|
+
fastRoutes: z27.number().int().nonnegative(),
|
|
229394
|
+
qualityRoutes: z27.number().int().nonnegative(),
|
|
229395
|
+
compactions: z27.number().int().nonnegative(),
|
|
229396
|
+
resumedCount: z27.number().int().nonnegative()
|
|
229006
229397
|
});
|
|
229007
|
-
var RunJournalSchema =
|
|
229008
|
-
schemaVersion:
|
|
229398
|
+
var RunJournalSchema = z27.object({
|
|
229399
|
+
schemaVersion: z27.literal(1).default(1),
|
|
229009
229400
|
sessionId: SessionIdSchema,
|
|
229010
|
-
state:
|
|
229401
|
+
state: z27.enum([
|
|
229011
229402
|
"running",
|
|
229012
229403
|
"awaiting_approval",
|
|
229013
229404
|
"verifying",
|
|
@@ -229016,83 +229407,83 @@ var RunJournalSchema = z25.object({
|
|
|
229016
229407
|
"aborted",
|
|
229017
229408
|
"interrupted"
|
|
229018
229409
|
]),
|
|
229019
|
-
phase:
|
|
229020
|
-
attempt:
|
|
229021
|
-
activeToolCallId:
|
|
229022
|
-
startedAt:
|
|
229023
|
-
updatedAt:
|
|
229024
|
-
recoveryCount:
|
|
229410
|
+
phase: z27.string().trim().min(1).max(200),
|
|
229411
|
+
attempt: z27.number().int().nonnegative().default(0),
|
|
229412
|
+
activeToolCallId: z27.string().min(1).max(512).optional(),
|
|
229413
|
+
startedAt: z27.string().datetime(),
|
|
229414
|
+
updatedAt: z27.string().datetime(),
|
|
229415
|
+
recoveryCount: z27.number().int().nonnegative().default(0)
|
|
229025
229416
|
});
|
|
229026
|
-
var StoredToolCallSchema =
|
|
229027
|
-
id:
|
|
229028
|
-
name:
|
|
229417
|
+
var StoredToolCallSchema = z27.object({
|
|
229418
|
+
id: z27.string().min(1),
|
|
229419
|
+
name: z27.string().min(1),
|
|
229029
229420
|
arguments: JsonTextSchema
|
|
229030
229421
|
});
|
|
229031
|
-
var StoredToolResultSchema =
|
|
229032
|
-
toolCallId:
|
|
229033
|
-
name:
|
|
229034
|
-
content:
|
|
229035
|
-
isError:
|
|
229422
|
+
var StoredToolResultSchema = z27.object({
|
|
229423
|
+
toolCallId: z27.string().min(1),
|
|
229424
|
+
name: z27.string().min(1),
|
|
229425
|
+
content: z27.string(),
|
|
229426
|
+
isError: z27.boolean().optional()
|
|
229036
229427
|
});
|
|
229037
|
-
var StoredContentBlockSchema =
|
|
229038
|
-
|
|
229039
|
-
|
|
229040
|
-
|
|
229041
|
-
type:
|
|
229428
|
+
var StoredContentBlockSchema = z27.discriminatedUnion("type", [
|
|
229429
|
+
z27.object({ type: z27.literal("text"), text: z27.string() }),
|
|
229430
|
+
z27.object({ type: z27.literal("tool_call"), toolCall: StoredToolCallSchema }),
|
|
229431
|
+
z27.object({
|
|
229432
|
+
type: z27.literal("tool_result"),
|
|
229042
229433
|
toolResult: StoredToolResultSchema
|
|
229043
229434
|
}),
|
|
229044
|
-
|
|
229045
|
-
type:
|
|
229046
|
-
text:
|
|
229047
|
-
signature:
|
|
229435
|
+
z27.object({
|
|
229436
|
+
type: z27.literal("thinking"),
|
|
229437
|
+
text: z27.string(),
|
|
229438
|
+
signature: z27.string().optional()
|
|
229048
229439
|
})
|
|
229049
229440
|
]);
|
|
229050
|
-
var StoredHistoryMessageSchema =
|
|
229051
|
-
id:
|
|
229052
|
-
role:
|
|
229053
|
-
content:
|
|
229054
|
-
createdAt:
|
|
229055
|
-
metadata:
|
|
229441
|
+
var StoredHistoryMessageSchema = z27.object({
|
|
229442
|
+
id: z27.string().min(1),
|
|
229443
|
+
role: z27.enum(["system", "user", "assistant", "tool"]),
|
|
229444
|
+
content: z27.array(StoredContentBlockSchema),
|
|
229445
|
+
createdAt: z27.string().datetime(),
|
|
229446
|
+
metadata: z27.record(SafeObjectKeySchema, JsonValueSchema).optional()
|
|
229056
229447
|
});
|
|
229057
|
-
var StoredHistorySchema =
|
|
229058
|
-
var ToolCallRecordSchema =
|
|
229059
|
-
id:
|
|
229448
|
+
var StoredHistorySchema = z27.array(StoredHistoryMessageSchema);
|
|
229449
|
+
var ToolCallRecordSchema = z27.object({
|
|
229450
|
+
id: z27.string().min(1),
|
|
229060
229451
|
sessionId: SessionIdSchema,
|
|
229061
|
-
toolName:
|
|
229452
|
+
toolName: z27.string().min(1),
|
|
229062
229453
|
inputJson: JsonTextSchema,
|
|
229063
229454
|
outputJson: JsonTextSchema.optional(),
|
|
229064
|
-
risk:
|
|
229065
|
-
permissionDecision:
|
|
229066
|
-
status:
|
|
229067
|
-
startedAt:
|
|
229068
|
-
endedAt:
|
|
229455
|
+
risk: z27.string().min(1),
|
|
229456
|
+
permissionDecision: z27.string().min(1),
|
|
229457
|
+
status: z27.enum(["pending", "success", "failed", "denied"]),
|
|
229458
|
+
startedAt: z27.string().datetime(),
|
|
229459
|
+
endedAt: z27.string().datetime().optional()
|
|
229069
229460
|
});
|
|
229070
|
-
var FileChangeRecordSchema =
|
|
229071
|
-
id:
|
|
229461
|
+
var FileChangeRecordSchema = z27.object({
|
|
229462
|
+
id: z27.string().min(1),
|
|
229072
229463
|
sessionId: SessionIdSchema,
|
|
229073
|
-
path:
|
|
229074
|
-
beforeHash:
|
|
229075
|
-
afterHash:
|
|
229076
|
-
diff:
|
|
229077
|
-
createdAt:
|
|
229464
|
+
path: z27.string().min(1),
|
|
229465
|
+
beforeHash: z27.string().optional(),
|
|
229466
|
+
afterHash: z27.string().optional(),
|
|
229467
|
+
diff: z27.string(),
|
|
229468
|
+
createdAt: z27.string().datetime()
|
|
229078
229469
|
});
|
|
229079
|
-
var SessionTraceBundleSchema =
|
|
229080
|
-
schemaVersion:
|
|
229081
|
-
exportedAt:
|
|
229082
|
-
workspace:
|
|
229083
|
-
id:
|
|
229084
|
-
path:
|
|
229470
|
+
var SessionTraceBundleSchema = z27.object({
|
|
229471
|
+
schemaVersion: z27.literal(1),
|
|
229472
|
+
exportedAt: z27.string().datetime(),
|
|
229473
|
+
workspace: z27.object({
|
|
229474
|
+
id: z27.string().regex(/^[a-f0-9]{16}$/),
|
|
229475
|
+
path: z27.literal("<workspace>")
|
|
229085
229476
|
}),
|
|
229086
229477
|
session: SessionSchema.omit({ cwd: true }).extend({
|
|
229087
|
-
cwd:
|
|
229478
|
+
cwd: z27.literal("<workspace>")
|
|
229088
229479
|
}),
|
|
229089
229480
|
journal: RunJournalSchema.optional(),
|
|
229090
229481
|
plan: TaskPlanSchema.optional(),
|
|
229091
229482
|
metrics: SessionMetricsSchema,
|
|
229092
|
-
events:
|
|
229093
|
-
toolCalls:
|
|
229094
|
-
fileChanges:
|
|
229095
|
-
history:
|
|
229483
|
+
events: z27.array(SessionEventSchema),
|
|
229484
|
+
toolCalls: z27.array(ToolCallRecordSchema),
|
|
229485
|
+
fileChanges: z27.array(FileChangeRecordSchema),
|
|
229486
|
+
history: z27.array(JsonValueSchema).optional()
|
|
229096
229487
|
});
|
|
229097
229488
|
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
229489
|
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 +229920,7 @@ var SessionStore = class {
|
|
|
229529
229920
|
schemaVersion: 1,
|
|
229530
229921
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
229531
229922
|
workspace: {
|
|
229532
|
-
id:
|
|
229923
|
+
id: createHash5("sha256").update(this.cwd).digest("hex").slice(0, 16),
|
|
229533
229924
|
path: "<workspace>"
|
|
229534
229925
|
},
|
|
229535
229926
|
session: {
|
|
@@ -229896,21 +230287,21 @@ var SessionManager = class {
|
|
|
229896
230287
|
var PRIVATE_DIRECTORY_MODE2 = 448;
|
|
229897
230288
|
var PRIVATE_FILE_MODE2 = 384;
|
|
229898
230289
|
var MAX_PROJECTS = 200;
|
|
229899
|
-
var ProjectRecordSchema =
|
|
229900
|
-
id:
|
|
229901
|
-
path:
|
|
229902
|
-
name:
|
|
229903
|
-
createdAt:
|
|
229904
|
-
lastOpenedAt:
|
|
229905
|
-
lastSessionId:
|
|
229906
|
-
archivedAt:
|
|
230290
|
+
var ProjectRecordSchema = z28.object({
|
|
230291
|
+
id: z28.string().regex(/^proj_[a-f0-9]{16}$/),
|
|
230292
|
+
path: z28.string().min(1).max(4096).refine((value) => !/[\u0000-\u001f\u007f]/.test(value)),
|
|
230293
|
+
name: z28.string().trim().min(1).max(200),
|
|
230294
|
+
createdAt: z28.string().datetime(),
|
|
230295
|
+
lastOpenedAt: z28.string().datetime(),
|
|
230296
|
+
lastSessionId: z28.string().min(1).optional(),
|
|
230297
|
+
archivedAt: z28.string().datetime().optional()
|
|
229907
230298
|
});
|
|
229908
|
-
var ProjectRegistrySnapshotSchema =
|
|
229909
|
-
schemaVersion:
|
|
229910
|
-
projects:
|
|
230299
|
+
var ProjectRegistrySnapshotSchema = z28.object({
|
|
230300
|
+
schemaVersion: z28.literal(1),
|
|
230301
|
+
projects: z28.array(ProjectRecordSchema).max(MAX_PROJECTS)
|
|
229911
230302
|
});
|
|
229912
|
-
var LegacyProjectRegistrySnapshotSchema =
|
|
229913
|
-
projects:
|
|
230303
|
+
var LegacyProjectRegistrySnapshotSchema = z28.object({
|
|
230304
|
+
projects: z28.array(ProjectRecordSchema).max(MAX_PROJECTS)
|
|
229914
230305
|
});
|
|
229915
230306
|
function parseProjectRegistrySnapshot(value) {
|
|
229916
230307
|
const current = ProjectRegistrySnapshotSchema.safeParse(value);
|
|
@@ -230263,25 +230654,25 @@ ${this.normalizeContextText(options.repoMapText)}` : "",
|
|
|
230263
230654
|
);
|
|
230264
230655
|
}
|
|
230265
230656
|
};
|
|
230266
|
-
var PromptCacheTelemetrySampleSchema =
|
|
230267
|
-
recordedAt:
|
|
230268
|
-
inputTokens:
|
|
230269
|
-
hitTokens:
|
|
230270
|
-
missTokens:
|
|
230271
|
-
hitRate:
|
|
230272
|
-
degraded:
|
|
230657
|
+
var PromptCacheTelemetrySampleSchema = z29.object({
|
|
230658
|
+
recordedAt: z29.string(),
|
|
230659
|
+
inputTokens: z29.number().int().nonnegative(),
|
|
230660
|
+
hitTokens: z29.number().int().nonnegative(),
|
|
230661
|
+
missTokens: z29.number().int().nonnegative(),
|
|
230662
|
+
hitRate: z29.number().min(0).max(1),
|
|
230663
|
+
degraded: z29.boolean()
|
|
230273
230664
|
});
|
|
230274
|
-
var PromptCacheSlabMetadataSchema =
|
|
230275
|
-
hash:
|
|
230276
|
-
model:
|
|
230277
|
-
tokenEstimate:
|
|
230278
|
-
lastPrimedAt:
|
|
230279
|
-
telemetry:
|
|
230665
|
+
var PromptCacheSlabMetadataSchema = z29.object({
|
|
230666
|
+
hash: z29.string().optional(),
|
|
230667
|
+
model: z29.string().optional(),
|
|
230668
|
+
tokenEstimate: z29.number().int().nonnegative().optional(),
|
|
230669
|
+
lastPrimedAt: z29.string().optional(),
|
|
230670
|
+
telemetry: z29.array(PromptCacheTelemetrySampleSchema).max(100).optional()
|
|
230280
230671
|
}).passthrough();
|
|
230281
230672
|
var PromptCacheSlabBuilder = class {
|
|
230282
230673
|
static build(input) {
|
|
230283
230674
|
const stableText = this.buildStableText(input);
|
|
230284
|
-
const hash =
|
|
230675
|
+
const hash = createHash6("sha256").update(stableText).digest("hex");
|
|
230285
230676
|
const slabPath = join12(
|
|
230286
230677
|
input.cwd,
|
|
230287
230678
|
".orbit",
|
|
@@ -230635,16 +231026,16 @@ function truncateVolatileContextToBudget(sourceHistory, targetTokens) {
|
|
|
230635
231026
|
}
|
|
230636
231027
|
return { history, truncated };
|
|
230637
231028
|
}
|
|
230638
|
-
var RoutingInputSchema =
|
|
230639
|
-
query:
|
|
230640
|
-
defaultModel:
|
|
230641
|
-
fastModel:
|
|
230642
|
-
qualityModel:
|
|
230643
|
-
lockedModel:
|
|
230644
|
-
fallbackModel:
|
|
230645
|
-
activeModel:
|
|
230646
|
-
repairTurn:
|
|
230647
|
-
hasWrittenFiles:
|
|
231029
|
+
var RoutingInputSchema = z210.object({
|
|
231030
|
+
query: z210.string(),
|
|
231031
|
+
defaultModel: z210.string().min(1),
|
|
231032
|
+
fastModel: z210.string().min(1).optional(),
|
|
231033
|
+
qualityModel: z210.string().min(1).optional(),
|
|
231034
|
+
lockedModel: z210.string().min(1).optional(),
|
|
231035
|
+
fallbackModel: z210.string().min(1).optional(),
|
|
231036
|
+
activeModel: z210.string().min(1).optional(),
|
|
231037
|
+
repairTurn: z210.boolean().default(false),
|
|
231038
|
+
hasWrittenFiles: z210.boolean().default(false)
|
|
230648
231039
|
});
|
|
230649
231040
|
var COMPLEX_SIGNALS = [
|
|
230650
231041
|
"debug",
|
|
@@ -230766,15 +231157,23 @@ function decision(model, lane, reason, confidence) {
|
|
|
230766
231157
|
return { model, lane, reason, confidence };
|
|
230767
231158
|
}
|
|
230768
231159
|
var StepRunner = class {
|
|
230769
|
-
constructor(cwd, sessionId, config) {
|
|
231160
|
+
constructor(cwd, sessionId, config, services) {
|
|
230770
231161
|
this.cwd = cwd;
|
|
230771
231162
|
this.sessionId = sessionId;
|
|
230772
231163
|
this.config = config;
|
|
231164
|
+
this.services = services;
|
|
230773
231165
|
}
|
|
230774
231166
|
cwd;
|
|
230775
231167
|
sessionId;
|
|
230776
231168
|
config;
|
|
231169
|
+
services;
|
|
230777
231170
|
async run(toolCall, abortSignal) {
|
|
231171
|
+
if (abortSignal?.aborted) {
|
|
231172
|
+
return {
|
|
231173
|
+
ok: false,
|
|
231174
|
+
error: "Tool execution was cancelled before it started."
|
|
231175
|
+
};
|
|
231176
|
+
}
|
|
230778
231177
|
const tool = toolRegistry.get(toolCall.name);
|
|
230779
231178
|
if (!tool) {
|
|
230780
231179
|
return {
|
|
@@ -230816,7 +231215,8 @@ var StepRunner = class {
|
|
|
230816
231215
|
cwd: this.cwd,
|
|
230817
231216
|
sessionId: this.sessionId,
|
|
230818
231217
|
config: this.config,
|
|
230819
|
-
abortSignal: timeoutController.signal
|
|
231218
|
+
abortSignal: timeoutController.signal,
|
|
231219
|
+
services: this.services
|
|
230820
231220
|
});
|
|
230821
231221
|
return result;
|
|
230822
231222
|
} catch (error) {
|
|
@@ -230826,6 +231226,12 @@ var StepRunner = class {
|
|
|
230826
231226
|
error: `Tool execution timed out after ${timeoutMs}ms. Command tree was terminated.`
|
|
230827
231227
|
};
|
|
230828
231228
|
}
|
|
231229
|
+
if (abortSignal?.aborted) {
|
|
231230
|
+
return {
|
|
231231
|
+
ok: false,
|
|
231232
|
+
error: "Tool execution was cancelled by the user."
|
|
231233
|
+
};
|
|
231234
|
+
}
|
|
230829
231235
|
return {
|
|
230830
231236
|
ok: false,
|
|
230831
231237
|
error: `Tool execution threw exception: ${getErrorMessage(error)}`
|
|
@@ -230914,7 +231320,7 @@ Core rules:
|
|
|
230914
231320
|
1. Understand the project before editing.
|
|
230915
231321
|
2. Prefer minimal, precise changes.
|
|
230916
231322
|
3. Never modify files blindly.
|
|
230917
|
-
4. Before large changes, produce a short plan.
|
|
231323
|
+
4. Before large changes, produce a short plan and keep it current with update_plan. Skip plan bookkeeping for simple one-step requests.
|
|
230918
231324
|
5. When editing code, preserve existing style and architecture.
|
|
230919
231325
|
6. After changes, run relevant tests or explain why tests were not run.
|
|
230920
231326
|
7. Never read or expose secrets unless explicitly approved by the user.
|
|
@@ -230924,7 +231330,7 @@ Core rules:
|
|
|
230924
231330
|
11. Do not claim success unless verification passed.
|
|
230925
231331
|
12. If verification fails, explain the failure clearly and propose next steps.
|
|
230926
231332
|
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.`;
|
|
231333
|
+
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
231334
|
if (supportsThinking) {
|
|
230929
231335
|
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
231336
|
}
|
|
@@ -231327,6 +231733,23 @@ function generateXMLToolsPrompt(tools) {
|
|
|
231327
231733
|
` - \`${key}\`: (type: ${field.typeName}${field.isOptional ? ", optional" : ""}${values})${description}`
|
|
231328
231734
|
);
|
|
231329
231735
|
}
|
|
231736
|
+
} else if (tool.inputJsonSchema) {
|
|
231737
|
+
const properties = tool.inputJsonSchema.properties;
|
|
231738
|
+
const required = new Set(
|
|
231739
|
+
Array.isArray(tool.inputJsonSchema.required) ? tool.inputJsonSchema.required.filter(
|
|
231740
|
+
(value) => typeof value === "string"
|
|
231741
|
+
) : []
|
|
231742
|
+
);
|
|
231743
|
+
if (properties && typeof properties === "object") {
|
|
231744
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
231745
|
+
const property = value && typeof value === "object" ? value : {};
|
|
231746
|
+
const typeName = typeof property.type === "string" ? property.type : "unknown";
|
|
231747
|
+
const description = typeof property.description === "string" ? ` - ${property.description.replace(/\s+/g, " ").trim()}` : "";
|
|
231748
|
+
lines.push(
|
|
231749
|
+
` - \`${key}\`: (type: ${typeName}${required.has(key) ? "" : ", optional"})${description}`
|
|
231750
|
+
);
|
|
231751
|
+
}
|
|
231752
|
+
}
|
|
231330
231753
|
}
|
|
231331
231754
|
lines.push("");
|
|
231332
231755
|
}
|
|
@@ -231478,10 +231901,9 @@ var McpRuntimeManager = class {
|
|
|
231478
231901
|
};
|
|
231479
231902
|
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
231480
231903
|
const client = this.createClient(serverName, serverConfig);
|
|
231904
|
+
const registeredForClient = [];
|
|
231481
231905
|
try {
|
|
231482
231906
|
const tools = await client.start();
|
|
231483
|
-
this.clients.push(client);
|
|
231484
|
-
result.startedServers += 1;
|
|
231485
231907
|
for (const toolDefinition of tools) {
|
|
231486
231908
|
const risk = serverConfig.tools?.[toolDefinition.name]?.risk ?? "execute";
|
|
231487
231909
|
const dynamicTool = new DynamicMCPTool(
|
|
@@ -231490,12 +231912,25 @@ var McpRuntimeManager = class {
|
|
|
231490
231912
|
risk,
|
|
231491
231913
|
client
|
|
231492
231914
|
);
|
|
231915
|
+
if (this.registry.get(dynamicTool.name)) {
|
|
231916
|
+
throw new Error(
|
|
231917
|
+
`MCP tool name collision after normalization: "${dynamicTool.name}". Rename the server or remote tool.`
|
|
231918
|
+
);
|
|
231919
|
+
}
|
|
231493
231920
|
this.registry.register(dynamicTool);
|
|
231494
231921
|
this.registeredToolNames.add(dynamicTool.name);
|
|
231922
|
+
registeredForClient.push(dynamicTool.name);
|
|
231495
231923
|
result.registeredTools += 1;
|
|
231496
231924
|
report(` \u2714 Registered MCP tool: ${dynamicTool.name} (${risk})`);
|
|
231497
231925
|
}
|
|
231926
|
+
this.clients.push(client);
|
|
231927
|
+
result.startedServers += 1;
|
|
231498
231928
|
} catch (error) {
|
|
231929
|
+
for (const toolName of registeredForClient) {
|
|
231930
|
+
this.registry.unregister(toolName);
|
|
231931
|
+
this.registeredToolNames.delete(toolName);
|
|
231932
|
+
result.registeredTools -= 1;
|
|
231933
|
+
}
|
|
231499
231934
|
await client.stop().catch(() => void 0);
|
|
231500
231935
|
const message = safeMcpRuntimeMessage(error);
|
|
231501
231936
|
result.failures.push({ serverName, message });
|
|
@@ -231864,7 +232299,9 @@ function initializeAgentSession(cwd, config, provider, task, options = {}) {
|
|
|
231864
232299
|
rollbackManager: new RollbackManager(cwd),
|
|
231865
232300
|
permissionEngine: new PermissionEngine(config),
|
|
231866
232301
|
contextBuilder: new ContextPackBuilder(cwd),
|
|
231867
|
-
stepRunner: new StepRunner(cwd, session.id, config
|
|
232302
|
+
stepRunner: new StepRunner(cwd, session.id, config, {
|
|
232303
|
+
updatePlan: (update) => updateSessionTaskPlan(sessionManager, update)
|
|
232304
|
+
}),
|
|
231868
232305
|
verificationManager: new VerificationContractManager(
|
|
231869
232306
|
cwd,
|
|
231870
232307
|
session.id,
|
|
@@ -231881,6 +232318,28 @@ function initializeAgentSession(cwd, config, provider, task, options = {}) {
|
|
|
231881
232318
|
totalCacheReadTokens: session.totalCacheReadTokens || 0
|
|
231882
232319
|
};
|
|
231883
232320
|
}
|
|
232321
|
+
function updateSessionTaskPlan(sessionManager, update) {
|
|
232322
|
+
const existing = sessionManager.getTaskPlan();
|
|
232323
|
+
const available = [...existing?.items ?? []];
|
|
232324
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
232325
|
+
const items = update.plan.map((entry) => {
|
|
232326
|
+
const matchIndex = available.findIndex((item) => item.text === entry.step);
|
|
232327
|
+
const previous = matchIndex >= 0 ? available.splice(matchIndex, 1)[0] : void 0;
|
|
232328
|
+
return {
|
|
232329
|
+
id: previous?.id ?? `step_${createHash32("sha256").update(`${entry.step}\0${now}`).digest("hex").slice(0, 16)}`,
|
|
232330
|
+
text: entry.step,
|
|
232331
|
+
status: entry.status,
|
|
232332
|
+
createdAt: previous?.createdAt ?? now,
|
|
232333
|
+
updatedAt: previous?.status === entry.status ? previous.updatedAt : now
|
|
232334
|
+
};
|
|
232335
|
+
});
|
|
232336
|
+
const saved = sessionManager.saveTaskPlan(items, existing?.goal);
|
|
232337
|
+
sessionManager.logEvent("model_task_plan_update", {
|
|
232338
|
+
explanation: update.explanation?.slice(0, 1e3),
|
|
232339
|
+
itemCount: items.length
|
|
232340
|
+
});
|
|
232341
|
+
return saved;
|
|
232342
|
+
}
|
|
231884
232343
|
function restoreSessionHistory(sessionManager, state) {
|
|
231885
232344
|
const savedHistory = sessionManager.getHistory();
|
|
231886
232345
|
if (savedHistory.length === 0) return;
|
|
@@ -231909,6 +232368,8 @@ var DEEPSEEK_VERBOSE_CACHE_ENV = "ORBIT_DEEPSEEK_VERBOSE_CACHE";
|
|
|
231909
232368
|
var NETWORK_TOOL_RESULT_MAX_RESULTS = 10;
|
|
231910
232369
|
var NETWORK_TOOL_RESULT_SUMMARY_CHARS = 280;
|
|
231911
232370
|
var NETWORK_TOOL_RESULT_MAX_CHARS = 6e3;
|
|
232371
|
+
var TOOL_RESULT_MAX_CHARS = 24e3;
|
|
232372
|
+
var TOOL_STATUS_MAX_CHARS = 2e3;
|
|
231912
232373
|
var AGENT_LOOP_ERROR_MESSAGE_MAX_CHARS = 2e3;
|
|
231913
232374
|
var AgentLoopExecutionError = class extends Error {
|
|
231914
232375
|
constructor(code, message) {
|
|
@@ -232021,20 +232482,23 @@ var AgentLoop = class _AgentLoop {
|
|
|
232021
232482
|
return Math.max(10, Math.min(20, Math.floor(this.state.maxAttempts / 2)));
|
|
232022
232483
|
}
|
|
232023
232484
|
getReusableApprovalScope(toolName, risk) {
|
|
232024
|
-
if (toolName === "web_search" && risk === "network") {
|
|
232025
|
-
return "network:
|
|
232485
|
+
if ((toolName === "web_search" || toolName === "web_fetch") && risk === "network") {
|
|
232486
|
+
return "network:web";
|
|
232026
232487
|
}
|
|
232027
232488
|
return null;
|
|
232028
232489
|
}
|
|
232029
232490
|
buildToolResultContent(toolName, result) {
|
|
232030
232491
|
const content = result.ok ? this.serializeToolResultData(result.data, result.display) : result.error || "Unknown error";
|
|
232031
232492
|
if (!result.ok || toolName !== "web_search") {
|
|
232032
|
-
return
|
|
232493
|
+
return this.truncatePlain(
|
|
232494
|
+
redactSecrets(content),
|
|
232495
|
+
result.ok ? TOOL_RESULT_MAX_CHARS : TOOL_STATUS_MAX_CHARS
|
|
232496
|
+
);
|
|
232033
232497
|
}
|
|
232034
232498
|
return this.compactNetworkToolResult(
|
|
232035
232499
|
toolName,
|
|
232036
|
-
content,
|
|
232037
|
-
result.display || ""
|
|
232500
|
+
redactSecrets(content),
|
|
232501
|
+
redactSecrets(result.display || "")
|
|
232038
232502
|
);
|
|
232039
232503
|
}
|
|
232040
232504
|
serializeToolResultData(data, display) {
|
|
@@ -232341,7 +232805,9 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232341
232805
|
}
|
|
232342
232806
|
let toolDefs = toolRegistry.getDefinitions();
|
|
232343
232807
|
if (!this.config.tools.webSearch.enabled) {
|
|
232344
|
-
toolDefs = toolDefs.filter(
|
|
232808
|
+
toolDefs = toolDefs.filter(
|
|
232809
|
+
(tool) => tool.name !== "web_search" && tool.name !== "web_fetch"
|
|
232810
|
+
);
|
|
232345
232811
|
}
|
|
232346
232812
|
if (!this.config.tools.bash.enabled) {
|
|
232347
232813
|
toolDefs = toolDefs.filter(
|
|
@@ -232452,6 +232918,7 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232452
232918
|
let resolvedModel;
|
|
232453
232919
|
let providerRequestId;
|
|
232454
232920
|
const toolCallsToExecute = [];
|
|
232921
|
+
const toolCallProtocolErrors = /* @__PURE__ */ new Map();
|
|
232455
232922
|
try {
|
|
232456
232923
|
for await (const event of stream) {
|
|
232457
232924
|
this.statusBar.stop();
|
|
@@ -232565,6 +233032,39 @@ Note: To find where a symbol (class, function, etc.) is declared or referenced,
|
|
|
232565
233032
|
}
|
|
232566
233033
|
}
|
|
232567
233034
|
}
|
|
233035
|
+
if (toolCallsToExecute.length > 1) {
|
|
233036
|
+
const seenToolCallIds = /* @__PURE__ */ new Set();
|
|
233037
|
+
const uniqueToolCalls = [];
|
|
233038
|
+
for (const toolCall of toolCallsToExecute) {
|
|
233039
|
+
if (seenToolCallIds.has(toolCall.id)) {
|
|
233040
|
+
const message = `Ignored duplicate tool call id "${toolCall.id}" from the model response.`;
|
|
233041
|
+
this.interaction.showText(picocolors8.yellow(`\u26A0 ${message}`));
|
|
233042
|
+
this.sessionManager.logEvent("duplicate_tool_call_ignored", {
|
|
233043
|
+
toolCallId: toolCall.id,
|
|
233044
|
+
toolName: toolCall.name
|
|
233045
|
+
});
|
|
233046
|
+
continue;
|
|
233047
|
+
}
|
|
233048
|
+
seenToolCallIds.add(toolCall.id);
|
|
233049
|
+
uniqueToolCalls.push(toolCall);
|
|
233050
|
+
}
|
|
233051
|
+
toolCallsToExecute.splice(
|
|
233052
|
+
0,
|
|
233053
|
+
toolCallsToExecute.length,
|
|
233054
|
+
...uniqueToolCalls
|
|
233055
|
+
);
|
|
233056
|
+
}
|
|
233057
|
+
for (const toolCall of toolCallsToExecute) {
|
|
233058
|
+
try {
|
|
233059
|
+
JSON.parse(toolCall.arguments);
|
|
233060
|
+
} catch (error) {
|
|
233061
|
+
toolCallProtocolErrors.set(
|
|
233062
|
+
toolCall.id,
|
|
233063
|
+
`Tool input JSON parse failed: ${safeAgentLoopErrorMessage(error)}`
|
|
233064
|
+
);
|
|
233065
|
+
toolCall.arguments = "{}";
|
|
233066
|
+
}
|
|
233067
|
+
}
|
|
232568
233068
|
eventBus.emitEvent("model_response", {
|
|
232569
233069
|
model: activeModel2,
|
|
232570
233070
|
requestedModel: activeModel2,
|
|
@@ -232836,6 +233336,32 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232836
233336
|
break;
|
|
232837
233337
|
}
|
|
232838
233338
|
const toolResultBlocks = [];
|
|
233339
|
+
const rejectInvalidToolCall = (toolCall, message, risk = "read") => {
|
|
233340
|
+
const error = safeAgentLoopErrorMessage(message);
|
|
233341
|
+
this.interaction.showText(` ${picocolors8.red("\u2716")} ${error}`);
|
|
233342
|
+
eventBus.emitEvent("tool_result", {
|
|
233343
|
+
toolCallId: toolCall.id,
|
|
233344
|
+
toolName: toolCall.name,
|
|
233345
|
+
error
|
|
233346
|
+
});
|
|
233347
|
+
toolResultBlocks.push({
|
|
233348
|
+
type: "tool_result",
|
|
233349
|
+
toolResult: {
|
|
233350
|
+
toolCallId: toolCall.id,
|
|
233351
|
+
name: toolCall.name,
|
|
233352
|
+
content: error,
|
|
233353
|
+
isError: true
|
|
233354
|
+
}
|
|
233355
|
+
});
|
|
233356
|
+
this.sessionManager.recordToolExecution(
|
|
233357
|
+
toolCall.name,
|
|
233358
|
+
toolCall,
|
|
233359
|
+
{ ok: false, error },
|
|
233360
|
+
risk,
|
|
233361
|
+
"invalid",
|
|
233362
|
+
"failed"
|
|
233363
|
+
);
|
|
233364
|
+
};
|
|
232839
233365
|
for (const tc of toolCallsToExecute) {
|
|
232840
233366
|
let argSummary = "";
|
|
232841
233367
|
try {
|
|
@@ -232870,8 +233396,41 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232870
233396
|
${picocolors8.cyan("\u2726")} ${picocolors8.bold(picocolors8.white(tc.name))} ${picocolors8.gray(argSummary)}`
|
|
232871
233397
|
);
|
|
232872
233398
|
const registeredTool = toolRegistry.get(tc.name);
|
|
233399
|
+
if (!registeredTool) {
|
|
233400
|
+
rejectInvalidToolCall(
|
|
233401
|
+
tc,
|
|
233402
|
+
`Tool "${tc.name}" was not found in the registry.`
|
|
233403
|
+
);
|
|
233404
|
+
continue;
|
|
233405
|
+
}
|
|
232873
233406
|
const declaredRisk = registeredTool?.risk;
|
|
232874
|
-
const
|
|
233407
|
+
const protocolError = toolCallProtocolErrors.get(tc.id);
|
|
233408
|
+
if (protocolError) {
|
|
233409
|
+
rejectInvalidToolCall(tc, protocolError, declaredRisk);
|
|
233410
|
+
continue;
|
|
233411
|
+
}
|
|
233412
|
+
let preflightArgs;
|
|
233413
|
+
try {
|
|
233414
|
+
preflightArgs = JSON.parse(tc.arguments);
|
|
233415
|
+
} catch (error) {
|
|
233416
|
+
rejectInvalidToolCall(
|
|
233417
|
+
tc,
|
|
233418
|
+
`Tool input JSON parse failed: ${safeAgentLoopErrorMessage(error)}`,
|
|
233419
|
+
declaredRisk
|
|
233420
|
+
);
|
|
233421
|
+
continue;
|
|
233422
|
+
}
|
|
233423
|
+
const validation = registeredTool.inputSchema.safeParse(preflightArgs);
|
|
233424
|
+
if (!validation.success) {
|
|
233425
|
+
rejectInvalidToolCall(
|
|
233426
|
+
tc,
|
|
233427
|
+
`Tool input validation failed: ${validation.error.message}`,
|
|
233428
|
+
declaredRisk
|
|
233429
|
+
);
|
|
233430
|
+
continue;
|
|
233431
|
+
}
|
|
233432
|
+
const evalArgs = validation.data;
|
|
233433
|
+
const evalArgsRecord = toUnknownRecord(evalArgs);
|
|
232875
233434
|
eventBus.emitEvent("tool_proposal", {
|
|
232876
233435
|
toolCallId: tc.id,
|
|
232877
233436
|
toolName: tc.name,
|
|
@@ -232883,7 +233442,12 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
232883
233442
|
declaredRisk
|
|
232884
233443
|
);
|
|
232885
233444
|
if (tc.name === "write_file" || tc.name === "edit_file" || tc.name === "replace_file_content" || tc.name === "multi_replace_file_content") {
|
|
232886
|
-
const targetPath2 =
|
|
233445
|
+
const targetPath2 = firstStringValue(
|
|
233446
|
+
evalArgsRecord.path,
|
|
233447
|
+
evalArgsRecord.TargetFile,
|
|
233448
|
+
evalArgsRecord.filePath,
|
|
233449
|
+
evalArgsRecord.file
|
|
233450
|
+
);
|
|
232887
233451
|
if (targetPath2) {
|
|
232888
233452
|
const relPath = path4.relative(this.cwd, path4.resolve(this.cwd, targetPath2)).replace(/\\/g, "/");
|
|
232889
233453
|
const foundFile = this.state.relevantFiles.find(
|
|
@@ -233026,9 +233590,9 @@ Please analyze this failure log, locate the files causing assertion or compile e
|
|
|
233026
233590
|
try {
|
|
233027
233591
|
const parsed = JSON.parse(edited);
|
|
233028
233592
|
if (registeredTool && registeredTool.inputSchema) {
|
|
233029
|
-
const
|
|
233030
|
-
if (!
|
|
233031
|
-
const errorMsgs =
|
|
233593
|
+
const validation2 = registeredTool.inputSchema.safeParse(parsed);
|
|
233594
|
+
if (!validation2.success) {
|
|
233595
|
+
const errorMsgs = validation2.error.errors.map(
|
|
233032
233596
|
(e2) => `${e2.path.join(".") || "root"}: ${e2.message}`
|
|
233033
233597
|
).join(", ");
|
|
233034
233598
|
this.interaction.showText(
|
|
@@ -233856,8 +234420,12 @@ ${stdout.substring(0, 2e4)}`
|
|
|
233856
234420
|
status
|
|
233857
234421
|
);
|
|
233858
234422
|
if (finalResult.ok) {
|
|
234423
|
+
const statusText = this.truncatePlain(
|
|
234424
|
+
redactSecrets(finalResult.display || "Done"),
|
|
234425
|
+
TOOL_STATUS_MAX_CHARS
|
|
234426
|
+
);
|
|
233859
234427
|
this.interaction.showText(
|
|
233860
|
-
` ${picocolors8.green("\u2714")} Success: ${picocolors8.gray(
|
|
234428
|
+
` ${picocolors8.green("\u2714")} Success: ${picocolors8.gray(statusText)}`
|
|
233861
234429
|
);
|
|
233862
234430
|
if (targetPath) {
|
|
233863
234431
|
this.addRelevantFile(targetPath, `Modified by ${tc.name}`);
|
|
@@ -233867,8 +234435,12 @@ ${stdout.substring(0, 2e4)}`
|
|
|
233867
234435
|
});
|
|
233868
234436
|
}
|
|
233869
234437
|
} else {
|
|
234438
|
+
const statusError = this.truncatePlain(
|
|
234439
|
+
redactSecrets(finalResult.error || "Unknown error"),
|
|
234440
|
+
TOOL_STATUS_MAX_CHARS
|
|
234441
|
+
);
|
|
233870
234442
|
this.interaction.showText(
|
|
233871
|
-
` ${picocolors8.red("\u2716")} Failed: ${picocolors8.red(
|
|
234443
|
+
` ${picocolors8.red("\u2716")} Failed: ${picocolors8.red(statusError)}`
|
|
233872
234444
|
);
|
|
233873
234445
|
}
|
|
233874
234446
|
eventBus.emitEvent("tool_result", {
|
|
@@ -234729,6 +235301,12 @@ ${diff.substring(0, 2e4)}`
|
|
|
234729
235301
|
}
|
|
234730
235302
|
}
|
|
234731
235303
|
};
|
|
235304
|
+
function toUnknownRecord(value) {
|
|
235305
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
235306
|
+
}
|
|
235307
|
+
function firstStringValue(...values) {
|
|
235308
|
+
return values.find((value) => typeof value === "string");
|
|
235309
|
+
}
|
|
234732
235310
|
var AgentTaskGraphSchema = z83.array(
|
|
234733
235311
|
z83.object({
|
|
234734
235312
|
id: z83.string().min(1).max(128),
|
|
@@ -235833,103 +236411,293 @@ import readline3 from "readline";
|
|
|
235833
236411
|
|
|
235834
236412
|
// src/runtime/SlashCommandCatalog.ts
|
|
235835
236413
|
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
|
-
|
|
236414
|
+
var SLASH_COMMAND_DEFINITIONS = [
|
|
236415
|
+
{
|
|
236416
|
+
command: "/help",
|
|
236417
|
+
usage: "",
|
|
236418
|
+
category: "system",
|
|
236419
|
+
description: {
|
|
236420
|
+
en: "Show all commands and usage",
|
|
236421
|
+
zh: "\u663E\u793A\u5168\u90E8\u547D\u4EE4\u4E0E\u7528\u6CD5"
|
|
236422
|
+
},
|
|
236423
|
+
webSuggested: true
|
|
236424
|
+
},
|
|
236425
|
+
{
|
|
236426
|
+
command: "/status",
|
|
236427
|
+
usage: "",
|
|
236428
|
+
category: "settings",
|
|
236429
|
+
description: {
|
|
236430
|
+
en: "Show the active session, model, context, and cost",
|
|
236431
|
+
zh: "\u67E5\u770B\u5F53\u524D\u4F1A\u8BDD\u3001\u6A21\u578B\u3001\u4E0A\u4E0B\u6587\u4E0E\u8D39\u7528"
|
|
236432
|
+
},
|
|
236433
|
+
webSuggested: true
|
|
236434
|
+
},
|
|
236435
|
+
{
|
|
236436
|
+
command: "/goal",
|
|
236437
|
+
usage: "[objective]",
|
|
236438
|
+
category: "session",
|
|
236439
|
+
description: {
|
|
236440
|
+
en: "Show or set this chat's durable goal; use clear to remove",
|
|
236441
|
+
zh: "\u67E5\u770B\u6216\u8BBE\u7F6E\u5F53\u524D\u804A\u5929\u7684\u6301\u7EED\u76EE\u6807\uFF1B\u4F7F\u7528 clear \u6E05\u9664"
|
|
236442
|
+
},
|
|
236443
|
+
webSuggested: true
|
|
236444
|
+
},
|
|
236445
|
+
{
|
|
236446
|
+
command: "/rename",
|
|
236447
|
+
usage: "<title>",
|
|
236448
|
+
category: "session",
|
|
236449
|
+
description: { en: "Rename the current chat", zh: "\u91CD\u547D\u540D\u5F53\u524D\u804A\u5929" },
|
|
236450
|
+
webSuggested: true
|
|
236451
|
+
},
|
|
236452
|
+
{
|
|
236453
|
+
command: "/memory",
|
|
236454
|
+
usage: "[action]",
|
|
236455
|
+
category: "session",
|
|
236456
|
+
description: {
|
|
236457
|
+
en: "Review and manage explicit project memory",
|
|
236458
|
+
zh: "\u5BA1\u67E5\u548C\u7BA1\u7406\u9879\u76EE\u7EA7\u663E\u5F0F\u8BB0\u5FC6"
|
|
236459
|
+
},
|
|
236460
|
+
webSuggested: true
|
|
236461
|
+
},
|
|
236462
|
+
{
|
|
236463
|
+
command: "/plan",
|
|
236464
|
+
usage: "[action]",
|
|
236465
|
+
category: "session",
|
|
236466
|
+
description: {
|
|
236467
|
+
en: "Manage this chat's recoverable task plan",
|
|
236468
|
+
zh: "\u7BA1\u7406\u5F53\u524D\u804A\u5929\u53EF\u6062\u590D\u7684\u4EFB\u52A1\u8BA1\u5212"
|
|
236469
|
+
},
|
|
236470
|
+
webSuggested: true
|
|
236471
|
+
},
|
|
236472
|
+
{
|
|
236473
|
+
command: "/metrics",
|
|
236474
|
+
usage: "",
|
|
236475
|
+
category: "settings",
|
|
236476
|
+
description: {
|
|
236477
|
+
en: "Show local runtime and reliability metrics",
|
|
236478
|
+
zh: "\u67E5\u770B\u672C\u5730\u8FD0\u884C\u4E0E\u53EF\u9760\u6027\u6307\u6807"
|
|
236479
|
+
},
|
|
236480
|
+
webSuggested: true
|
|
236481
|
+
},
|
|
236482
|
+
{
|
|
236483
|
+
command: "/doctor",
|
|
236484
|
+
usage: "",
|
|
236485
|
+
category: "settings",
|
|
236486
|
+
description: {
|
|
236487
|
+
en: "Diagnose runtime, models, web, skills, and safety",
|
|
236488
|
+
zh: "\u8BCA\u65AD\u8FD0\u884C\u73AF\u5883\u3001\u6A21\u578B\u3001\u8054\u7F51\u3001\u6280\u80FD\u4E0E\u5B89\u5168\u914D\u7F6E"
|
|
236489
|
+
},
|
|
236490
|
+
webSuggested: true
|
|
236491
|
+
},
|
|
236492
|
+
{
|
|
236493
|
+
command: "/config",
|
|
236494
|
+
usage: "[key=value]",
|
|
236495
|
+
category: "settings",
|
|
236496
|
+
description: {
|
|
236497
|
+
en: "View or update Orbit configuration",
|
|
236498
|
+
zh: "\u67E5\u770B\u6216\u66F4\u65B0 Orbit \u914D\u7F6E"
|
|
236499
|
+
},
|
|
236500
|
+
webSuggested: true
|
|
236501
|
+
},
|
|
236502
|
+
{
|
|
236503
|
+
command: "/model",
|
|
236504
|
+
usage: "[name]",
|
|
236505
|
+
category: "settings",
|
|
236506
|
+
description: {
|
|
236507
|
+
en: "Show or switch the active model",
|
|
236508
|
+
zh: "\u67E5\u770B\u6216\u5207\u6362\u5F53\u524D\u6A21\u578B"
|
|
236509
|
+
},
|
|
236510
|
+
webSuggested: true
|
|
236511
|
+
},
|
|
236512
|
+
{
|
|
236513
|
+
command: "/chat",
|
|
236514
|
+
usage: "[action]",
|
|
236515
|
+
category: "session",
|
|
236516
|
+
description: {
|
|
236517
|
+
en: "List, create, delete, or switch chats",
|
|
236518
|
+
zh: "\u5217\u51FA\u3001\u65B0\u5EFA\u3001\u5220\u9664\u6216\u5207\u6362\u804A\u5929"
|
|
236519
|
+
},
|
|
236520
|
+
webSuggested: true
|
|
236521
|
+
},
|
|
236522
|
+
{
|
|
236523
|
+
command: "/commit",
|
|
236524
|
+
usage: "[message]",
|
|
236525
|
+
category: "git",
|
|
236526
|
+
description: {
|
|
236527
|
+
en: "Stage workspace changes and create a commit",
|
|
236528
|
+
zh: "\u6682\u5B58\u5DE5\u4F5C\u533A\u4FEE\u6539\u5E76\u521B\u5EFA\u63D0\u4EA4"
|
|
236529
|
+
},
|
|
236530
|
+
webSuggested: true
|
|
236531
|
+
},
|
|
236532
|
+
{
|
|
236533
|
+
command: "/exit",
|
|
236534
|
+
usage: "",
|
|
236535
|
+
category: "system",
|
|
236536
|
+
description: { en: "Exit the interactive terminal", zh: "\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF" },
|
|
236537
|
+
webSuggested: false
|
|
236538
|
+
},
|
|
236539
|
+
{
|
|
236540
|
+
command: "/quit",
|
|
236541
|
+
usage: "",
|
|
236542
|
+
category: "system",
|
|
236543
|
+
description: { en: "Exit the interactive terminal", zh: "\u9000\u51FA\u4EA4\u4E92\u5F0F\u7EC8\u7AEF" },
|
|
236544
|
+
webSuggested: false
|
|
236545
|
+
},
|
|
236546
|
+
{
|
|
236547
|
+
command: "/rollback",
|
|
236548
|
+
usage: "",
|
|
236549
|
+
category: "session",
|
|
236550
|
+
description: {
|
|
236551
|
+
en: "Restore the latest file modification checkpoint",
|
|
236552
|
+
zh: "\u6062\u590D\u6700\u8FD1\u4E00\u6B21\u6587\u4EF6\u4FEE\u6539\u68C0\u67E5\u70B9"
|
|
236553
|
+
},
|
|
236554
|
+
webSuggested: true
|
|
236555
|
+
},
|
|
236556
|
+
{
|
|
236557
|
+
command: "/timeline",
|
|
236558
|
+
usage: "",
|
|
236559
|
+
category: "session",
|
|
236560
|
+
description: {
|
|
236561
|
+
en: "List persisted file checkpoints for this chat",
|
|
236562
|
+
zh: "\u5217\u51FA\u5F53\u524D\u804A\u5929\u6301\u4E45\u5316\u7684\u6587\u4EF6\u68C0\u67E5\u70B9"
|
|
236563
|
+
},
|
|
236564
|
+
webSuggested: true
|
|
236565
|
+
},
|
|
236566
|
+
{
|
|
236567
|
+
command: "/rewind",
|
|
236568
|
+
usage: "<id|number>",
|
|
236569
|
+
category: "session",
|
|
236570
|
+
description: {
|
|
236571
|
+
en: "Rewind this chat to a selected file checkpoint",
|
|
236572
|
+
zh: "\u5C06\u5F53\u524D\u804A\u5929\u56DE\u9000\u5230\u6307\u5B9A\u6587\u4EF6\u68C0\u67E5\u70B9"
|
|
236573
|
+
},
|
|
236574
|
+
webSuggested: true
|
|
236575
|
+
},
|
|
236576
|
+
{
|
|
236577
|
+
command: "/compact",
|
|
236578
|
+
usage: "",
|
|
236579
|
+
category: "context",
|
|
236580
|
+
description: {
|
|
236581
|
+
en: "Compact older dialogue against the active model window",
|
|
236582
|
+
zh: "\u6309\u5F53\u524D\u6A21\u578B\u4E0A\u4E0B\u6587\u7A97\u53E3\u538B\u7F29\u65E7\u5BF9\u8BDD"
|
|
236583
|
+
},
|
|
236584
|
+
webSuggested: true
|
|
236585
|
+
},
|
|
236586
|
+
{
|
|
236587
|
+
command: "/clear",
|
|
236588
|
+
usage: "",
|
|
236589
|
+
category: "context",
|
|
236590
|
+
description: {
|
|
236591
|
+
en: "Reset dialogue history and clear the conversation view",
|
|
236592
|
+
zh: "\u91CD\u7F6E\u5BF9\u8BDD\u5386\u53F2\u5E76\u6E05\u7A7A\u4F1A\u8BDD\u89C6\u56FE"
|
|
236593
|
+
},
|
|
236594
|
+
webSuggested: true
|
|
236595
|
+
},
|
|
236596
|
+
{
|
|
236597
|
+
command: "/add",
|
|
236598
|
+
usage: "<file>",
|
|
236599
|
+
category: "context",
|
|
236600
|
+
description: {
|
|
236601
|
+
en: "Add a file or directory to active context",
|
|
236602
|
+
zh: "\u5C06\u6587\u4EF6\u6216\u76EE\u5F55\u52A0\u5165\u6D3B\u52A8\u4E0A\u4E0B\u6587"
|
|
236603
|
+
},
|
|
236604
|
+
webSuggested: true
|
|
236605
|
+
},
|
|
236606
|
+
{
|
|
236607
|
+
command: "/drop",
|
|
236608
|
+
usage: "<file>",
|
|
236609
|
+
category: "context",
|
|
236610
|
+
description: {
|
|
236611
|
+
en: "Remove a file or pattern from active context",
|
|
236612
|
+
zh: "\u4ECE\u6D3B\u52A8\u4E0A\u4E0B\u6587\u79FB\u9664\u6587\u4EF6\u6216\u901A\u914D\u7B26"
|
|
236613
|
+
},
|
|
236614
|
+
webSuggested: true
|
|
236615
|
+
},
|
|
236616
|
+
{
|
|
236617
|
+
command: "/mode",
|
|
236618
|
+
usage: "[mode]",
|
|
236619
|
+
category: "settings",
|
|
236620
|
+
description: {
|
|
236621
|
+
en: "Switch permission mode: strict, normal, auto, or plan",
|
|
236622
|
+
zh: "\u5207\u6362\u6743\u9650\u6A21\u5F0F\uFF1Astrict\u3001normal\u3001auto \u6216 plan"
|
|
236623
|
+
},
|
|
236624
|
+
webSuggested: true
|
|
236625
|
+
},
|
|
236626
|
+
{
|
|
236627
|
+
command: "/copy",
|
|
236628
|
+
usage: "",
|
|
236629
|
+
category: "session",
|
|
236630
|
+
description: {
|
|
236631
|
+
en: "Copy the latest Orbit reply",
|
|
236632
|
+
zh: "\u590D\u5236 Orbit \u7684\u6700\u65B0\u56DE\u590D"
|
|
236633
|
+
},
|
|
236634
|
+
webSuggested: true
|
|
236635
|
+
},
|
|
236636
|
+
{
|
|
236637
|
+
command: "/run",
|
|
236638
|
+
usage: "<command>",
|
|
236639
|
+
category: "system",
|
|
236640
|
+
description: {
|
|
236641
|
+
en: "Run a native shell command after permission checks",
|
|
236642
|
+
zh: "\u7ECF\u8FC7\u6743\u9650\u68C0\u67E5\u540E\u8FD0\u884C\u672C\u5730 Shell \u547D\u4EE4"
|
|
236643
|
+
},
|
|
236644
|
+
webSuggested: true
|
|
236645
|
+
},
|
|
236646
|
+
{
|
|
236647
|
+
command: "/update",
|
|
236648
|
+
usage: "",
|
|
236649
|
+
category: "settings",
|
|
236650
|
+
description: {
|
|
236651
|
+
en: "Check npm; terminal sessions can install and verify updates",
|
|
236652
|
+
zh: "\u68C0\u67E5 npm\uFF1B\u7EC8\u7AEF\u4F1A\u8BDD\u53EF\u5B89\u88C5\u5E76\u9A8C\u8BC1\u66F4\u65B0"
|
|
236653
|
+
},
|
|
236654
|
+
webSuggested: true
|
|
236655
|
+
},
|
|
236656
|
+
{
|
|
236657
|
+
command: "/webui",
|
|
236658
|
+
usage: "[port]",
|
|
236659
|
+
category: "settings",
|
|
236660
|
+
description: {
|
|
236661
|
+
en: "Open the Orbit graphical console",
|
|
236662
|
+
zh: "\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0"
|
|
236663
|
+
},
|
|
236664
|
+
webSuggested: false
|
|
236665
|
+
}
|
|
235861
236666
|
];
|
|
236667
|
+
var BUILTIN_SLASH_COMMANDS = SLASH_COMMAND_DEFINITIONS.map(
|
|
236668
|
+
({ command }) => command
|
|
236669
|
+
);
|
|
236670
|
+
var CATEGORY_LABELS = {
|
|
236671
|
+
context: { en: "Context Management", zh: "\u4E0A\u4E0B\u6587\u7BA1\u7406" },
|
|
236672
|
+
session: { en: "Session & History", zh: "\u4F1A\u8BDD\u4E0E\u5386\u53F2" },
|
|
236673
|
+
settings: { en: "Configuration & Status", zh: "\u914D\u7F6E\u4E0E\u72B6\u6001" },
|
|
236674
|
+
git: { en: "Git Version Control", zh: "Git \u63D0\u4EA4" },
|
|
236675
|
+
system: { en: "System Control", zh: "\u7CFB\u7EDF\u63A7\u5236" }
|
|
236676
|
+
};
|
|
235862
236677
|
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");
|
|
236678
|
+
const locale = isZh ? "zh" : "en";
|
|
236679
|
+
const sections = [];
|
|
236680
|
+
for (const category of Object.keys(
|
|
236681
|
+
CATEGORY_LABELS
|
|
236682
|
+
)) {
|
|
236683
|
+
const commands = SLASH_COMMAND_DEFINITIONS.filter(
|
|
236684
|
+
(definition) => definition.category === category
|
|
236685
|
+
);
|
|
236686
|
+
sections.push(
|
|
236687
|
+
picocolors9.bold(
|
|
236688
|
+
picocolors9.yellow(`[ ${CATEGORY_LABELS[category][locale]} ]`)
|
|
236689
|
+
),
|
|
236690
|
+
...commands.map(({ command, usage, description }) => {
|
|
236691
|
+
const invocation = usage ? `${command} ${usage}` : command;
|
|
236692
|
+
return ` ${picocolors9.green(invocation.padEnd(25))} - ${description[locale]}`;
|
|
236693
|
+
}),
|
|
236694
|
+
""
|
|
236695
|
+
);
|
|
235898
236696
|
}
|
|
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");
|
|
236697
|
+
sections.push(
|
|
236698
|
+
` ${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)"}`
|
|
236699
|
+
);
|
|
236700
|
+
return sections.join("\n").trimEnd();
|
|
235933
236701
|
}
|
|
235934
236702
|
|
|
235935
236703
|
// src/tui/TerminalText.ts
|
|
@@ -236197,8 +236965,8 @@ function findPreviousHistoryEntry(history, query, startIndex = history.length) {
|
|
|
236197
236965
|
import { dirname as dirname7, join as join13 } from "path";
|
|
236198
236966
|
import { homedir as homedir6 } from "os";
|
|
236199
236967
|
import { existsSync as existsSync14, mkdirSync as mkdirSync10, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
|
|
236200
|
-
import { z as
|
|
236201
|
-
var inputHistorySchema =
|
|
236968
|
+
import { z as z30 } from "zod";
|
|
236969
|
+
var inputHistorySchema = z30.array(z30.string());
|
|
236202
236970
|
var InputHistoryStore = class {
|
|
236203
236971
|
constructor(filePath = join13(homedir6(), ".orbit", "input_history.json")) {
|
|
236204
236972
|
this.filePath = filePath;
|
|
@@ -236761,13 +237529,13 @@ function renderPromptScreen(state, viewport, theme = MORANDI) {
|
|
|
236761
237529
|
|
|
236762
237530
|
// src/runtime/UpdateManager.ts
|
|
236763
237531
|
import { execFile as execFile4, execFileSync as execFileSync4 } from "child_process";
|
|
236764
|
-
import { z as
|
|
236765
|
-
var SemanticVersionSchema =
|
|
236766
|
-
var UpdateChannelSchema =
|
|
236767
|
-
var UpdateCheckSchema =
|
|
237532
|
+
import { z as z31 } from "zod";
|
|
237533
|
+
var SemanticVersionSchema = z31.string().trim().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
237534
|
+
var UpdateChannelSchema = z31.enum(["stable", "beta"]);
|
|
237535
|
+
var UpdateCheckSchema = z31.object({
|
|
236768
237536
|
currentVersion: SemanticVersionSchema,
|
|
236769
237537
|
latestVersion: SemanticVersionSchema,
|
|
236770
|
-
updateAvailable:
|
|
237538
|
+
updateAvailable: z31.boolean()
|
|
236771
237539
|
});
|
|
236772
237540
|
var UpdateManager = class {
|
|
236773
237541
|
executable;
|
|
@@ -236851,9 +237619,9 @@ var UpdateManager = class {
|
|
|
236851
237619
|
],
|
|
236852
237620
|
{ timeoutMs: this.timeoutMs, inheritOutput: false }
|
|
236853
237621
|
);
|
|
236854
|
-
const parsed =
|
|
236855
|
-
dependencies:
|
|
236856
|
-
"@orbit-build/cli":
|
|
237622
|
+
const parsed = z31.object({
|
|
237623
|
+
dependencies: z31.object({
|
|
237624
|
+
"@orbit-build/cli": z31.object({ version: SemanticVersionSchema })
|
|
236857
237625
|
})
|
|
236858
237626
|
}).parse(JSON.parse(raw));
|
|
236859
237627
|
return parsed.dependencies["@orbit-build/cli"].version;
|
|
@@ -237092,6 +237860,7 @@ var FullscreenTui = class {
|
|
|
237092
237860
|
hasCheckedOrbitUpdate = false;
|
|
237093
237861
|
isCheckingOrbitUpdate = false;
|
|
237094
237862
|
orbitUpdateAvailable = false;
|
|
237863
|
+
orbitRestartRequired = false;
|
|
237095
237864
|
budgetLimit = 0;
|
|
237096
237865
|
resolveInput = null;
|
|
237097
237866
|
activeRunnable = null;
|
|
@@ -237441,7 +238210,13 @@ var FullscreenTui = class {
|
|
|
237441
238210
|
}
|
|
237442
238211
|
setOrbitUpdateAvailable(updateAvailable) {
|
|
237443
238212
|
this.hasCheckedOrbitUpdate = true;
|
|
237444
|
-
this.orbitUpdateAvailable = updateAvailable;
|
|
238213
|
+
this.orbitUpdateAvailable = this.orbitRestartRequired ? false : updateAvailable;
|
|
238214
|
+
if (this.isActive) this.render();
|
|
238215
|
+
}
|
|
238216
|
+
/** Mark that npm has updated the package while this process remains on the old runtime. */
|
|
238217
|
+
setOrbitRestartRequired(restartRequired) {
|
|
238218
|
+
this.orbitRestartRequired = restartRequired;
|
|
238219
|
+
if (restartRequired) this.orbitUpdateAvailable = false;
|
|
237445
238220
|
if (this.isActive) this.render();
|
|
237446
238221
|
}
|
|
237447
238222
|
async refreshOrbitUpdateStatus() {
|
|
@@ -238510,7 +239285,7 @@ var FullscreenTui = class {
|
|
|
238510
239285
|
"/mode": "\u52A8\u6001\u5207\u6362\u7CFB\u7EDF\u5B89\u5168\u786E\u8BA4\u6A21\u5F0F (strict, normal, auto, plan)",
|
|
238511
239286
|
"/copy": "\u62F7\u8D1D AI \u7684\u4E0A\u4E00\u6761\u56DE\u590D\u5230\u7CFB\u7EDF\u526A\u8D34\u677F",
|
|
238512
239287
|
"/run": "\u6267\u884C\u4E00\u6761\u672C\u673A Shell \u547D\u4EE4\uFF0C\u4F1A\u5148\u8D70\u6743\u9650\u68C0\u67E5",
|
|
238513
|
-
"/update": "\u68C0\u67E5\u5E76\
|
|
239288
|
+
"/update": "\u68C0\u67E5 npm\uFF0C\u5E76\u5728\u7EC8\u7AEF\u4E2D\u5B89\u88C5\u548C\u9A8C\u8BC1 Orbit \u66F4\u65B0",
|
|
238514
239289
|
"/webui": "\u542F\u52A8\u5E76\u6253\u5F00 Orbit \u56FE\u5F62\u63A7\u5236\u53F0\u9875\u9762"
|
|
238515
239290
|
} : {
|
|
238516
239291
|
"/help": "Display detailed help and commands reference",
|
|
@@ -238536,7 +239311,7 @@ var FullscreenTui = class {
|
|
|
238536
239311
|
"/mode": "Switch permission mode (strict, normal, auto, plan)",
|
|
238537
239312
|
"/copy": "Copy last assistant response to clipboard",
|
|
238538
239313
|
"/run": "Run one local shell command after permission checks",
|
|
238539
|
-
"/update": "Check and
|
|
239314
|
+
"/update": "Check npm, then install and verify Orbit updates",
|
|
238540
239315
|
"/webui": "Start and open the Orbit graphical console"
|
|
238541
239316
|
};
|
|
238542
239317
|
const maxVisible = 5;
|
|
@@ -238716,7 +239491,8 @@ var FullscreenTui = class {
|
|
|
238716
239491
|
const cleanModel = displayedModel.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "");
|
|
238717
239492
|
const gitSummary = this.getGitSummary();
|
|
238718
239493
|
const gitBranch = gitSummary.branch;
|
|
238719
|
-
const
|
|
239494
|
+
const updateAvailable = this.getOrbitUpdateAvailable();
|
|
239495
|
+
const heartColor = this.orbitRestartRequired ? `\x1B[5m\x1B[38;2;120;190;150m` : updateAvailable ? `\x1B[5m\x1B[38;2;230;190;80m` : `\x1B[38;2;230;110;110m`;
|
|
238720
239496
|
const logoLines = [
|
|
238721
239497
|
`\x1B[38;2;158;184;196m /\\___/\\ \x1B[0m`,
|
|
238722
239498
|
`\x1B[38;2;158;184;196m ( o.o ) \x1B[0m`,
|
|
@@ -239125,7 +239901,7 @@ import { dirname as dirname9, resolve as resolve10 } from "path";
|
|
|
239125
239901
|
import { homedir as homedir10 } from "os";
|
|
239126
239902
|
import http2 from "http";
|
|
239127
239903
|
import { randomBytes as randomBytes2, randomUUID as randomUUID8, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
239128
|
-
import { z as
|
|
239904
|
+
import { z as z47 } from "zod";
|
|
239129
239905
|
|
|
239130
239906
|
// src/runtime/CommandRouter.ts
|
|
239131
239907
|
import picocolors18 from "picocolors";
|
|
@@ -239135,11 +239911,11 @@ import { existsSync as existsSync16, readFileSync as readFileSync17, readdirSync
|
|
|
239135
239911
|
import { basename as basename5, extname as extname2, join as join15 } from "path";
|
|
239136
239912
|
import { homedir as homedir8 } from "os";
|
|
239137
239913
|
import { parse as parse3 } from "yaml";
|
|
239138
|
-
import { z as
|
|
239139
|
-
var CommandMetadataSchema =
|
|
239140
|
-
description:
|
|
239141
|
-
argumentHint:
|
|
239142
|
-
"argument-hint":
|
|
239914
|
+
import { z as z35 } from "zod";
|
|
239915
|
+
var CommandMetadataSchema = z35.object({
|
|
239916
|
+
description: z35.string().max(240).optional(),
|
|
239917
|
+
argumentHint: z35.string().max(120).optional(),
|
|
239918
|
+
"argument-hint": z35.string().max(120).optional()
|
|
239143
239919
|
});
|
|
239144
239920
|
var VALID_COMMAND_NAME = /^[a-z0-9][a-z0-9-_]{0,47}$/i;
|
|
239145
239921
|
var MAX_COMMAND_FILE_BYTES = 256 * 1024;
|
|
@@ -239285,20 +240061,20 @@ import { spawn as spawn2 } from "child_process";
|
|
|
239285
240061
|
// src/runtime/webui/WebUiRuntime.ts
|
|
239286
240062
|
import http from "http";
|
|
239287
240063
|
import { randomBytes, randomUUID as randomUUID6 } from "crypto";
|
|
239288
|
-
import { z as
|
|
240064
|
+
import { z as z38 } from "zod";
|
|
239289
240065
|
|
|
239290
240066
|
// src/runtime/AutocompleteCandidates.ts
|
|
239291
240067
|
import glob6 from "fast-glob";
|
|
239292
240068
|
import { existsSync as existsSync17, readFileSync as readFileSync18, readdirSync as readdirSync6 } from "fs";
|
|
239293
240069
|
import { homedir as homedir9 } from "os";
|
|
239294
240070
|
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:
|
|
240071
|
+
import { z as z36 } from "zod";
|
|
240072
|
+
var symbolIndexSchema = z36.object({
|
|
240073
|
+
files: z36.record(
|
|
240074
|
+
z36.object({
|
|
240075
|
+
symbols: z36.array(
|
|
240076
|
+
z36.object({
|
|
240077
|
+
name: z36.string().min(1)
|
|
239302
240078
|
})
|
|
239303
240079
|
).optional()
|
|
239304
240080
|
})
|
|
@@ -239310,6 +240086,12 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239310
240086
|
...BUILTIN_SLASH_COMMANDS,
|
|
239311
240087
|
...customCommands.map((command) => `/${command.name}`)
|
|
239312
240088
|
];
|
|
240089
|
+
const commandDetails = customCommands.map((command) => ({
|
|
240090
|
+
command: `/${command.name}`,
|
|
240091
|
+
description: command.description,
|
|
240092
|
+
argumentHint: command.argumentHint,
|
|
240093
|
+
source: command.source
|
|
240094
|
+
}));
|
|
239313
240095
|
const files = [];
|
|
239314
240096
|
const symbols = [];
|
|
239315
240097
|
const sessions = [];
|
|
@@ -239317,7 +240099,7 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239317
240099
|
const normHome = resolve7(homedir9()).toLowerCase().replace(/\\/g, "/");
|
|
239318
240100
|
const isHomeOrRoot = normCwd === normHome || normCwd === "/" || /^[a-zA-Z]:\/$/.test(normCwd) || dirname8(normCwd) === normCwd;
|
|
239319
240101
|
if (isHomeOrRoot) {
|
|
239320
|
-
return { commands, files, symbols, sessions };
|
|
240102
|
+
return { commands, commandDetails, files, symbols, sessions };
|
|
239321
240103
|
}
|
|
239322
240104
|
try {
|
|
239323
240105
|
files.push(
|
|
@@ -239363,6 +240145,7 @@ async function getAutocompleteCandidates(cwd, config) {
|
|
|
239363
240145
|
}
|
|
239364
240146
|
return {
|
|
239365
240147
|
commands,
|
|
240148
|
+
commandDetails,
|
|
239366
240149
|
files,
|
|
239367
240150
|
symbols: [...new Set(symbols)],
|
|
239368
240151
|
sessions
|
|
@@ -239382,6 +240165,15 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
239382
240165
|
autoSizePrompt();
|
|
239383
240166
|
writeLocalStorage('orbit.webui.draft', elements.prompt.value);
|
|
239384
240167
|
updateSendButtonState();
|
|
240168
|
+
slashCommandSelection = 0;
|
|
240169
|
+
renderSlashCommands();
|
|
240170
|
+
});
|
|
240171
|
+
|
|
240172
|
+
elements.prompt.addEventListener('focus', renderSlashCommands);
|
|
240173
|
+
elements.prompt.addEventListener('blur', () => {
|
|
240174
|
+
window.setTimeout(() => {
|
|
240175
|
+
if (!elements.slashCommandMenu.contains(document.activeElement)) closeSlashCommands();
|
|
240176
|
+
}, 0);
|
|
239385
240177
|
});
|
|
239386
240178
|
|
|
239387
240179
|
elements.prompt.addEventListener('keydown', (event) => {
|
|
@@ -239849,7 +240641,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
|
|
|
239849
240641
|
}
|
|
239850
240642
|
try {
|
|
239851
240643
|
await bootstrapSession();
|
|
239852
|
-
await Promise.all([renderMessages(), loadStatus()]);
|
|
240644
|
+
await Promise.all([renderMessages(), loadStatus(), loadSlashCommands()]);
|
|
239853
240645
|
connectEvents();
|
|
239854
240646
|
if (draft) showToast(copy.draftRestored);
|
|
239855
240647
|
elements.prompt.focus();
|
|
@@ -240429,6 +241221,9 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
|
|
|
240429
241221
|
jumpBottom: byId('jumpBottom'),
|
|
240430
241222
|
composer: byId('composer'),
|
|
240431
241223
|
prompt: byId('prompt'),
|
|
241224
|
+
slashCommandMenu: byId('slashCommandMenu'),
|
|
241225
|
+
slashCommandResults: byId('slashCommandResults'),
|
|
241226
|
+
slashCommandEmpty: byId('slashCommandEmpty'),
|
|
240432
241227
|
contextPickerButton: byId('contextPickerButton'),
|
|
240433
241228
|
contextChipCount: byId('contextChipCount'),
|
|
240434
241229
|
contextShelf: byId('contextShelf'),
|
|
@@ -241601,23 +242396,29 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
|
|
|
241601
242396
|
autoSizePrompt();
|
|
241602
242397
|
updateSendButtonState();
|
|
241603
242398
|
elements.prompt.focus();
|
|
242399
|
+
closeSlashCommands();
|
|
241604
242400
|
}
|
|
241605
242401
|
|
|
241606
242402
|
function buildPaletteActions() {
|
|
241607
242403
|
const actions = [
|
|
241608
242404
|
{ icon: '+', label: language === 'zh' ? '新建任务' : 'New task', detail: 'Ctrl N', keywords: 'new session task', idle: true, run: () => updateSession({ action: 'new' }) },
|
|
241609
242405
|
{ 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
242406
|
{ icon: '›', label: copy.focusComposer, detail: language === 'zh' ? '发送消息' : 'Message Orbit', keywords: 'focus prompt message composer', run: () => elements.prompt.focus() },
|
|
241613
242407
|
{ icon: '◫', label: copy.openActivity, detail: language === 'zh' ? '运行状态与工具' : 'Runtime and tools', keywords: 'activity details runtime tools', run: () => setInspector(true, 'activity') },
|
|
241614
242408
|
{ icon: '⚙', label: copy.openSettings, detail: 'Ctrl ,', keywords: 'settings preferences configuration', run: () => setInspector(true, 'settings') },
|
|
241615
242409
|
{ 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
242410
|
{ icon: '+', label: language === 'zh' ? '添加文件上下文' : 'Add file context', detail: language === 'zh' ? '搜索工作区文件' : 'Search workspace files', keywords: 'add context file', idle: true, run: openContextPicker },
|
|
241620
242411
|
];
|
|
242412
|
+
for (const definition of slashCommands) {
|
|
242413
|
+
actions.push({
|
|
242414
|
+
icon: '/',
|
|
242415
|
+
label: definition.command + (definition.usage ? ' ' + definition.usage : ''),
|
|
242416
|
+
detail: definition.description,
|
|
242417
|
+
keywords: 'slash command ' + definition.command + ' ' + definition.description,
|
|
242418
|
+
idle: true,
|
|
242419
|
+
run: () => setComposerValue(definition.command + (definition.usage ? ' ' : '')),
|
|
242420
|
+
});
|
|
242421
|
+
}
|
|
241621
242422
|
const status = state.status || {};
|
|
241622
242423
|
const session = status.session || {};
|
|
241623
242424
|
for (const item of session.recent || []) {
|
|
@@ -242479,6 +243280,7 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
242479
243280
|
setBusy(false, '');
|
|
242480
243281
|
}
|
|
242481
243282
|
closeContextPicker({ skipRestore: true });
|
|
243283
|
+
closeSlashCommands();
|
|
242482
243284
|
const turnId = crypto.randomUUID ? crypto.randomUUID() : String(Date.now()) + '-' + Math.random().toString(16).slice(2);
|
|
242483
243285
|
const previousDraft = elements.prompt.value;
|
|
242484
243286
|
const restoreDraft = String(options && options.restoreDraft || '');
|
|
@@ -242747,6 +243549,168 @@ var WEB_UI_CLIENT_SESSION_SCRIPT = String.raw` const controlCommands = ${WEB_UI
|
|
|
242747
243549
|
|
|
242748
243550
|
`;
|
|
242749
243551
|
|
|
243552
|
+
// src/runtime/webui/WebUiClientSlashCommands.ts
|
|
243553
|
+
var WEB_UI_SLASH_COMMANDS = JSON.stringify(
|
|
243554
|
+
SLASH_COMMAND_DEFINITIONS.filter(({ webSuggested }) => webSuggested).map(
|
|
243555
|
+
({ command, usage, description }) => ({ command, usage, description })
|
|
243556
|
+
)
|
|
243557
|
+
);
|
|
243558
|
+
var WEB_UI_RESERVED_SLASH_COMMANDS = JSON.stringify(BUILTIN_SLASH_COMMANDS);
|
|
243559
|
+
var WEB_UI_CLIENT_SLASH_COMMANDS_SCRIPT = String.raw` const builtInSlashCommands = ${WEB_UI_SLASH_COMMANDS};
|
|
243560
|
+
const reservedSlashCommands = new Set(${WEB_UI_RESERVED_SLASH_COMMANDS});
|
|
243561
|
+
let slashCommands = builtInSlashCommands.map((definition) => ({
|
|
243562
|
+
command: definition.command,
|
|
243563
|
+
usage: definition.usage,
|
|
243564
|
+
description: definition.description[language],
|
|
243565
|
+
custom: false,
|
|
243566
|
+
}));
|
|
243567
|
+
let slashCommandMatches = [];
|
|
243568
|
+
let slashCommandSelection = 0;
|
|
243569
|
+
|
|
243570
|
+
function slashCommandQuery() {
|
|
243571
|
+
const value = elements.prompt.value.trimStart();
|
|
243572
|
+
return /^\/[a-z0-9_-]*$/i.test(value) ? value.toLowerCase() : null;
|
|
243573
|
+
}
|
|
243574
|
+
|
|
243575
|
+
function closeSlashCommands() {
|
|
243576
|
+
elements.slashCommandMenu.hidden = true;
|
|
243577
|
+
elements.slashCommandMenu.setAttribute('aria-hidden', 'true');
|
|
243578
|
+
elements.prompt.setAttribute('aria-expanded', 'false');
|
|
243579
|
+
elements.prompt.removeAttribute('aria-activedescendant');
|
|
243580
|
+
}
|
|
243581
|
+
|
|
243582
|
+
function syncSlashCommandSelection() {
|
|
243583
|
+
let activeId = '';
|
|
243584
|
+
elements.slashCommandResults.querySelectorAll('.slash-command-option').forEach((button, index) => {
|
|
243585
|
+
const selected = index === slashCommandSelection;
|
|
243586
|
+
button.setAttribute('aria-selected', selected ? 'true' : 'false');
|
|
243587
|
+
if (selected) {
|
|
243588
|
+
activeId = button.id;
|
|
243589
|
+
button.scrollIntoView({ block: 'nearest' });
|
|
243590
|
+
}
|
|
243591
|
+
});
|
|
243592
|
+
if (activeId) elements.prompt.setAttribute('aria-activedescendant', activeId);
|
|
243593
|
+
}
|
|
243594
|
+
|
|
243595
|
+
function chooseSlashCommand(index) {
|
|
243596
|
+
const definition = slashCommandMatches[index];
|
|
243597
|
+
if (!definition) return;
|
|
243598
|
+
elements.prompt.value = definition.command + (definition.usage ? ' ' : '');
|
|
243599
|
+
writeLocalStorage('orbit.webui.draft', elements.prompt.value);
|
|
243600
|
+
autoSizePrompt();
|
|
243601
|
+
updateSendButtonState();
|
|
243602
|
+
closeSlashCommands();
|
|
243603
|
+
elements.prompt.focus();
|
|
243604
|
+
}
|
|
243605
|
+
|
|
243606
|
+
function renderSlashCommands() {
|
|
243607
|
+
const query = slashCommandQuery();
|
|
243608
|
+
if (query === null || state.busy) {
|
|
243609
|
+
closeSlashCommands();
|
|
243610
|
+
return;
|
|
243611
|
+
}
|
|
243612
|
+
slashCommandMatches = slashCommands
|
|
243613
|
+
.filter((definition) => definition.command.startsWith(query))
|
|
243614
|
+
.sort((left, right) => {
|
|
243615
|
+
const leftExact = left.command === query ? 0 : 1;
|
|
243616
|
+
const rightExact = right.command === query ? 0 : 1;
|
|
243617
|
+
return leftExact - rightExact || left.command.localeCompare(right.command);
|
|
243618
|
+
})
|
|
243619
|
+
.slice(0, 10);
|
|
243620
|
+
slashCommandSelection = Math.max(0, Math.min(slashCommandSelection, slashCommandMatches.length - 1));
|
|
243621
|
+
elements.slashCommandResults.replaceChildren();
|
|
243622
|
+
slashCommandMatches.forEach((definition, index) => {
|
|
243623
|
+
const button = document.createElement('button');
|
|
243624
|
+
button.type = 'button';
|
|
243625
|
+
button.id = 'slash-command-option-' + index;
|
|
243626
|
+
button.className = 'slash-command-option';
|
|
243627
|
+
button.setAttribute('role', 'option');
|
|
243628
|
+
button.setAttribute('aria-selected', index === slashCommandSelection ? 'true' : 'false');
|
|
243629
|
+
const invocation = document.createElement('span');
|
|
243630
|
+
invocation.className = 'slash-command-invocation';
|
|
243631
|
+
const command = document.createElement('strong');
|
|
243632
|
+
command.textContent = definition.command;
|
|
243633
|
+
const usage = document.createElement('small');
|
|
243634
|
+
usage.textContent = definition.usage || '';
|
|
243635
|
+
invocation.append(command, usage);
|
|
243636
|
+
const description = document.createElement('span');
|
|
243637
|
+
description.className = 'slash-command-description';
|
|
243638
|
+
description.textContent = definition.description;
|
|
243639
|
+
button.append(invocation, description);
|
|
243640
|
+
button.addEventListener('mousedown', (event) => event.preventDefault());
|
|
243641
|
+
button.addEventListener('mouseenter', () => {
|
|
243642
|
+
slashCommandSelection = index;
|
|
243643
|
+
syncSlashCommandSelection();
|
|
243644
|
+
});
|
|
243645
|
+
button.addEventListener('click', () => chooseSlashCommand(index));
|
|
243646
|
+
elements.slashCommandResults.append(button);
|
|
243647
|
+
});
|
|
243648
|
+
elements.slashCommandEmpty.hidden = slashCommandMatches.length !== 0;
|
|
243649
|
+
elements.slashCommandMenu.hidden = false;
|
|
243650
|
+
elements.slashCommandMenu.setAttribute('aria-hidden', 'false');
|
|
243651
|
+
elements.prompt.setAttribute('aria-expanded', 'true');
|
|
243652
|
+
syncSlashCommandSelection();
|
|
243653
|
+
}
|
|
243654
|
+
|
|
243655
|
+
async function loadSlashCommands() {
|
|
243656
|
+
try {
|
|
243657
|
+
const result = await api('/api/completions?query=');
|
|
243658
|
+
const available = new Set(Array.isArray(result.commands) ? result.commands : []);
|
|
243659
|
+
const customDetails = new Map(
|
|
243660
|
+
(Array.isArray(result.commandDetails) ? result.commandDetails : [])
|
|
243661
|
+
.filter((detail) => detail && typeof detail.command === 'string')
|
|
243662
|
+
.map((detail) => [detail.command, detail]),
|
|
243663
|
+
);
|
|
243664
|
+
const custom = Array.from(available)
|
|
243665
|
+
.filter((command) => /^\/[a-z0-9][a-z0-9_-]{0,47}$/i.test(command))
|
|
243666
|
+
.filter((command) => !reservedSlashCommands.has(command))
|
|
243667
|
+
.map((command) => {
|
|
243668
|
+
const detail = customDetails.get(command) || {};
|
|
243669
|
+
return {
|
|
243670
|
+
command,
|
|
243671
|
+
usage: typeof detail.argumentHint === 'string' && detail.argumentHint.trim()
|
|
243672
|
+
? detail.argumentHint.trim()
|
|
243673
|
+
: '[arguments]',
|
|
243674
|
+
description: typeof detail.description === 'string' && detail.description.trim()
|
|
243675
|
+
? detail.description.trim()
|
|
243676
|
+
: language === 'zh' ? '自定义提示词命令' : 'Custom prompt command',
|
|
243677
|
+
custom: true,
|
|
243678
|
+
};
|
|
243679
|
+
});
|
|
243680
|
+
slashCommands = [
|
|
243681
|
+
...builtInSlashCommands.map((definition) => ({
|
|
243682
|
+
command: definition.command,
|
|
243683
|
+
usage: definition.usage,
|
|
243684
|
+
description: definition.description[language],
|
|
243685
|
+
custom: false,
|
|
243686
|
+
})),
|
|
243687
|
+
...custom,
|
|
243688
|
+
];
|
|
243689
|
+
} catch {
|
|
243690
|
+
// Built-ins remain available when optional workspace discovery fails.
|
|
243691
|
+
}
|
|
243692
|
+
}
|
|
243693
|
+
|
|
243694
|
+
elements.prompt.addEventListener('keydown', (event) => {
|
|
243695
|
+
if (elements.slashCommandMenu.hidden) return;
|
|
243696
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && slashCommandMatches.length) {
|
|
243697
|
+
event.preventDefault();
|
|
243698
|
+
event.stopImmediatePropagation();
|
|
243699
|
+
const delta = event.key === 'ArrowDown' ? 1 : -1;
|
|
243700
|
+
slashCommandSelection = (slashCommandSelection + delta + slashCommandMatches.length) % slashCommandMatches.length;
|
|
243701
|
+
syncSlashCommandSelection();
|
|
243702
|
+
} else if ((event.key === 'Enter' || event.key === 'Tab') && slashCommandMatches.length) {
|
|
243703
|
+
event.preventDefault();
|
|
243704
|
+
event.stopImmediatePropagation();
|
|
243705
|
+
chooseSlashCommand(slashCommandSelection);
|
|
243706
|
+
} else if (event.key === 'Escape') {
|
|
243707
|
+
event.preventDefault();
|
|
243708
|
+
event.stopImmediatePropagation();
|
|
243709
|
+
closeSlashCommands();
|
|
243710
|
+
}
|
|
243711
|
+
});
|
|
243712
|
+
`;
|
|
243713
|
+
|
|
242750
243714
|
// src/runtime/webui/WebUiClient.ts
|
|
242751
243715
|
var WEB_UI_CLIENT_PREAMBLE = String.raw`(() => {
|
|
242752
243716
|
'use strict';
|
|
@@ -242762,6 +243726,7 @@ var WEB_UI_CLIENT_SCRIPT = [
|
|
|
242762
243726
|
WEB_UI_CLIENT_CONTEXT_SCRIPT,
|
|
242763
243727
|
WEB_UI_CLIENT_MESSAGES_SCRIPT,
|
|
242764
243728
|
WEB_UI_CLIENT_SESSION_SCRIPT,
|
|
243729
|
+
WEB_UI_CLIENT_SLASH_COMMANDS_SCRIPT,
|
|
242765
243730
|
WEB_UI_CLIENT_PALETTE_SCRIPT,
|
|
242766
243731
|
WEB_UI_CLIENT_BINDINGS_SCRIPT,
|
|
242767
243732
|
WEB_UI_CLIENT_EPILOGUE
|
|
@@ -242770,26 +243735,27 @@ var WEB_UI_CLIENT_SCRIPT = [
|
|
|
242770
243735
|
// src/runtime/webui/WebUiBrand.ts
|
|
242771
243736
|
var CAT_HEAD_PATH = "M13 19 11.5 10.5l8.1 4.4a15.6 15.6 0 0 1 8.8 0l8.1-4.4L35 19c2.6 2.5 4 5.8 4 9.5 0 7.6-6.2 12.2-15 12.2S9 36.1 9 28.5c0-3.7 1.4-7 4-9.5Z";
|
|
242772
243737
|
var CAT_FACE_PATH = "M23.9 28.8v2.3m-2.5.8c1.5 1.4 3.7 1.4 5.2 0";
|
|
243738
|
+
var CAT_EYE_RADIUS = 1.35;
|
|
242773
243739
|
function renderOrbitMark(className) {
|
|
242774
243740
|
return `<svg class="orbit-mark ${className}" viewBox="0 0 48 48" fill="none" aria-hidden="true" focusable="false">
|
|
242775
243741
|
<path class="orbit-cat-head" d="${CAT_HEAD_PATH}" />
|
|
242776
|
-
<circle class="orbit-cat-eye" cx="18.5" cy="26.6" r="
|
|
242777
|
-
<circle class="orbit-cat-eye" cx="29.5" cy="26.6" r="
|
|
243742
|
+
<circle class="orbit-cat-eye" cx="18.5" cy="26.6" r="${CAT_EYE_RADIUS}" />
|
|
243743
|
+
<circle class="orbit-cat-eye" cx="29.5" cy="26.6" r="${CAT_EYE_RADIUS}" />
|
|
242778
243744
|
<path class="orbit-cat-face" d="${CAT_FACE_PATH}" />
|
|
242779
243745
|
<circle class="orbit-cat-satellite" cx="37" cy="12" r="2.2" />
|
|
242780
243746
|
</svg>`;
|
|
242781
243747
|
}
|
|
242782
243748
|
var WEB_UI_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" fill="none">
|
|
242783
243749
|
<path d="${CAT_HEAD_PATH}" stroke="#587481" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
242784
|
-
<circle cx="18.5" cy="26.6" r="
|
|
242785
|
-
<circle cx="29.5" cy="26.6" r="
|
|
243750
|
+
<circle cx="18.5" cy="26.6" r="${CAT_EYE_RADIUS}" fill="#587481" />
|
|
243751
|
+
<circle cx="29.5" cy="26.6" r="${CAT_EYE_RADIUS}" fill="#587481" />
|
|
242786
243752
|
<path d="${CAT_FACE_PATH}" stroke="#587481" stroke-width="1.35" stroke-linecap="round" />
|
|
242787
243753
|
<circle cx="37" cy="12" r="2.2" fill="#d97972" />
|
|
242788
243754
|
</svg>`;
|
|
242789
243755
|
|
|
242790
243756
|
// src/runtime/webui/WebUiSecurity.ts
|
|
242791
243757
|
import { timingSafeEqual } from "crypto";
|
|
242792
|
-
import { z as
|
|
243758
|
+
import { z as z37 } from "zod";
|
|
242793
243759
|
function sanitizeWebEventPayload(type, payload) {
|
|
242794
243760
|
if (!isRecord3(payload)) return void 0;
|
|
242795
243761
|
switch (type) {
|
|
@@ -242982,7 +243948,7 @@ function sanitizeBaseUrl(value) {
|
|
|
242982
243948
|
}
|
|
242983
243949
|
}
|
|
242984
243950
|
function webRequestErrorStatus(error) {
|
|
242985
|
-
if (error instanceof
|
|
243951
|
+
if (error instanceof z37.ZodError) return 400;
|
|
242986
243952
|
if (error instanceof Error && error.message === "Request body too large.") {
|
|
242987
243953
|
return 413;
|
|
242988
243954
|
}
|
|
@@ -243668,6 +244634,9 @@ var COPY = {
|
|
|
243668
244634
|
suggestionImproveBody: "Optimize performance, safety, and maintainability.",
|
|
243669
244635
|
inputLabel: "Message Orbit",
|
|
243670
244636
|
inputPlaceholder: "Ask Orbit to work on this codebase\u2026",
|
|
244637
|
+
slashCommands: "Slash commands",
|
|
244638
|
+
slashCommandEmpty: "No matching commands",
|
|
244639
|
+
slashCommandHint: "\u2191\u2193 navigate \xB7 Enter or Tab to insert \xB7 Esc to close",
|
|
243671
244640
|
context: "Context",
|
|
243672
244641
|
contextPickerTitle: "Add file context",
|
|
243673
244642
|
contextPickerSearch: "Search workspace files\u2026",
|
|
@@ -243764,6 +244733,9 @@ var COPY = {
|
|
|
243764
244733
|
suggestionImproveBody: "\u4F18\u5316\u6027\u80FD\u3001\u5B89\u5168\u6027\u4E0E\u53EF\u7EF4\u62A4\u6027\u3002",
|
|
243765
244734
|
inputLabel: "\u7ED9 Orbit \u53D1\u9001\u6D88\u606F",
|
|
243766
244735
|
inputPlaceholder: "\u8BA9 Orbit \u5728\u8FD9\u4E2A\u4EE3\u7801\u5E93\u4E2D\u5B8C\u6210\u4EFB\u52A1\u2026",
|
|
244736
|
+
slashCommands: "\u659C\u6760\u547D\u4EE4",
|
|
244737
|
+
slashCommandEmpty: "\u6CA1\u6709\u5339\u914D\u7684\u547D\u4EE4",
|
|
244738
|
+
slashCommandHint: "\u2191\u2193 \u9009\u62E9 \xB7 Enter \u6216 Tab \u63D2\u5165 \xB7 Esc \u5173\u95ED",
|
|
243767
244739
|
context: "\u4E0A\u4E0B\u6587",
|
|
243768
244740
|
contextPickerTitle: "\u6DFB\u52A0\u6587\u4EF6\u4E0A\u4E0B\u6587",
|
|
243769
244741
|
contextPickerSearch: "\u641C\u7D22\u5DE5\u4F5C\u533A\u6587\u4EF6\u2026",
|
|
@@ -243847,7 +244819,13 @@ function renderComposer(copy) {
|
|
|
243847
244819
|
</section>
|
|
243848
244820
|
<form class="composer" id="composer">
|
|
243849
244821
|
<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>
|
|
244822
|
+
<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>
|
|
244823
|
+
<section class="slash-command-menu" id="slashCommandMenu" aria-label="${copy.slashCommands}" aria-hidden="true" hidden>
|
|
244824
|
+
<div class="slash-command-heading"><strong>${copy.slashCommands}</strong><span>/</span></div>
|
|
244825
|
+
<div class="slash-command-results" id="slashCommandResults" role="listbox"></div>
|
|
244826
|
+
<p class="slash-command-empty" id="slashCommandEmpty" role="status" hidden>${copy.slashCommandEmpty}</p>
|
|
244827
|
+
<p class="slash-command-hint">${copy.slashCommandHint}</p>
|
|
244828
|
+
</section>
|
|
243851
244829
|
<section class="context-shelf" id="contextShelf" aria-label="${copy.activeContext}" hidden>
|
|
243852
244830
|
<div class="context-shelf-header">
|
|
243853
244831
|
<span>${renderUiIcon("context")}<strong>${copy.activeContext}</strong></span>
|
|
@@ -244312,6 +245290,116 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
244312
245290
|
box-shadow: none;
|
|
244313
245291
|
}
|
|
244314
245292
|
|
|
245293
|
+
.slash-command-menu {
|
|
245294
|
+
position: absolute;
|
|
245295
|
+
z-index: 24;
|
|
245296
|
+
left: 10px;
|
|
245297
|
+
right: 10px;
|
|
245298
|
+
bottom: calc(100% + 8px);
|
|
245299
|
+
overflow: hidden;
|
|
245300
|
+
color: var(--ink);
|
|
245301
|
+
background: var(--surface-raised);
|
|
245302
|
+
border: 1px solid var(--border-strong);
|
|
245303
|
+
border-radius: 13px;
|
|
245304
|
+
box-shadow: 0 12px 28px color-mix(in srgb, var(--ink-strong) 10%, transparent);
|
|
245305
|
+
}
|
|
245306
|
+
|
|
245307
|
+
/* The landing composer has ample space below; opening downward keeps the
|
|
245308
|
+
command heading visible instead of letting the application topbar clip it. */
|
|
245309
|
+
.empty-composer-slot .slash-command-menu {
|
|
245310
|
+
top: calc(100% + 8px);
|
|
245311
|
+
bottom: auto;
|
|
245312
|
+
}
|
|
245313
|
+
|
|
245314
|
+
.empty-composer-slot .slash-command-results {
|
|
245315
|
+
max-height: min(230px, 32vh);
|
|
245316
|
+
}
|
|
245317
|
+
|
|
245318
|
+
.slash-command-heading,
|
|
245319
|
+
.slash-command-hint {
|
|
245320
|
+
display: flex;
|
|
245321
|
+
align-items: center;
|
|
245322
|
+
justify-content: space-between;
|
|
245323
|
+
margin: 0;
|
|
245324
|
+
color: var(--faint);
|
|
245325
|
+
font-size: 10px;
|
|
245326
|
+
}
|
|
245327
|
+
|
|
245328
|
+
.slash-command-heading {
|
|
245329
|
+
padding: 9px 11px 7px;
|
|
245330
|
+
border-bottom: 1px solid var(--border);
|
|
245331
|
+
letter-spacing: 0.04em;
|
|
245332
|
+
text-transform: uppercase;
|
|
245333
|
+
}
|
|
245334
|
+
|
|
245335
|
+
.slash-command-heading span {
|
|
245336
|
+
font-family: var(--font-mono);
|
|
245337
|
+
font-size: 13px;
|
|
245338
|
+
}
|
|
245339
|
+
|
|
245340
|
+
.slash-command-results {
|
|
245341
|
+
max-height: min(318px, 46vh);
|
|
245342
|
+
overflow-y: auto;
|
|
245343
|
+
padding: 5px;
|
|
245344
|
+
}
|
|
245345
|
+
|
|
245346
|
+
.slash-command-option {
|
|
245347
|
+
width: 100%;
|
|
245348
|
+
min-height: 45px;
|
|
245349
|
+
display: grid;
|
|
245350
|
+
grid-template-columns: minmax(145px, 0.38fr) minmax(0, 1fr);
|
|
245351
|
+
align-items: center;
|
|
245352
|
+
gap: 12px;
|
|
245353
|
+
padding: 6px 9px;
|
|
245354
|
+
color: var(--ink);
|
|
245355
|
+
background: transparent;
|
|
245356
|
+
border: 0;
|
|
245357
|
+
border-radius: 9px;
|
|
245358
|
+
text-align: left;
|
|
245359
|
+
}
|
|
245360
|
+
|
|
245361
|
+
.slash-command-option[aria-selected="true"],
|
|
245362
|
+
.slash-command-option:hover {
|
|
245363
|
+
background: var(--accent-soft);
|
|
245364
|
+
}
|
|
245365
|
+
|
|
245366
|
+
.slash-command-invocation {
|
|
245367
|
+
min-width: 0;
|
|
245368
|
+
display: flex;
|
|
245369
|
+
align-items: baseline;
|
|
245370
|
+
gap: 6px;
|
|
245371
|
+
font-family: var(--font-mono);
|
|
245372
|
+
white-space: nowrap;
|
|
245373
|
+
}
|
|
245374
|
+
|
|
245375
|
+
.slash-command-invocation strong {
|
|
245376
|
+
color: var(--accent-strong);
|
|
245377
|
+
font-size: 12px;
|
|
245378
|
+
}
|
|
245379
|
+
|
|
245380
|
+
.slash-command-invocation small,
|
|
245381
|
+
.slash-command-description {
|
|
245382
|
+
overflow: hidden;
|
|
245383
|
+
color: var(--muted);
|
|
245384
|
+
font-size: 11px;
|
|
245385
|
+
text-overflow: ellipsis;
|
|
245386
|
+
white-space: nowrap;
|
|
245387
|
+
}
|
|
245388
|
+
|
|
245389
|
+
.slash-command-empty {
|
|
245390
|
+
margin: 0;
|
|
245391
|
+
padding: 18px 12px;
|
|
245392
|
+
color: var(--muted);
|
|
245393
|
+
font-size: 12px;
|
|
245394
|
+
text-align: center;
|
|
245395
|
+
}
|
|
245396
|
+
|
|
245397
|
+
.slash-command-hint {
|
|
245398
|
+
justify-content: flex-start;
|
|
245399
|
+
padding: 7px 11px 8px;
|
|
245400
|
+
border-top: 1px solid var(--border);
|
|
245401
|
+
}
|
|
245402
|
+
|
|
244315
245403
|
#prompt {
|
|
244316
245404
|
display: block;
|
|
244317
245405
|
width: 100%;
|
|
@@ -244328,6 +245416,13 @@ var WEB_UI_COMPOSER_STYLES = String.raw`
|
|
|
244328
245416
|
line-height: 1.55;
|
|
244329
245417
|
}
|
|
244330
245418
|
|
|
245419
|
+
@media (max-width: 620px) {
|
|
245420
|
+
.slash-command-option {
|
|
245421
|
+
grid-template-columns: 1fr;
|
|
245422
|
+
gap: 2px;
|
|
245423
|
+
}
|
|
245424
|
+
}
|
|
245425
|
+
|
|
244331
245426
|
.empty-composer-slot #prompt {
|
|
244332
245427
|
min-height: clamp(54px, 7vh, 74px);
|
|
244333
245428
|
font-size: 15px;
|
|
@@ -249049,45 +250144,45 @@ var WEB_UI_STYLE_SECTIONS = [
|
|
|
249049
250144
|
var WEB_UI_STYLES = WEB_UI_STYLE_SECTIONS.join("");
|
|
249050
250145
|
|
|
249051
250146
|
// src/runtime/webui/WebUiRuntime.ts
|
|
249052
|
-
var WebTurnIdSchema =
|
|
249053
|
-
var ChatRequestSchema =
|
|
249054
|
-
prompt:
|
|
250147
|
+
var WebTurnIdSchema = z38.string().trim().min(8).max(100).regex(/^[a-zA-Z0-9_-]+$/);
|
|
250148
|
+
var ChatRequestSchema = z38.object({
|
|
250149
|
+
prompt: z38.string().trim().min(1).max(1e5),
|
|
249055
250150
|
turnId: WebTurnIdSchema.optional()
|
|
249056
250151
|
}).strict();
|
|
249057
|
-
var CancelRequestSchema =
|
|
249058
|
-
var ApprovalDecisionSchema =
|
|
250152
|
+
var CancelRequestSchema = z38.object({ turnId: WebTurnIdSchema.nullish() }).strict();
|
|
250153
|
+
var ApprovalDecisionSchema = z38.object({
|
|
249059
250154
|
id: WebTurnIdSchema,
|
|
249060
|
-
approved:
|
|
250155
|
+
approved: z38.boolean()
|
|
249061
250156
|
}).strict();
|
|
249062
|
-
var SettingsPatchSchema =
|
|
249063
|
-
provider:
|
|
249064
|
-
model:
|
|
249065
|
-
permissionMode:
|
|
249066
|
-
webSearchEnabled:
|
|
249067
|
-
webSearchProvider:
|
|
249068
|
-
webSearchMaxResults:
|
|
250157
|
+
var SettingsPatchSchema = z38.object({
|
|
250158
|
+
provider: z38.string().trim().min(1).max(256).optional(),
|
|
250159
|
+
model: z38.string().trim().min(1).max(200).optional(),
|
|
250160
|
+
permissionMode: z38.enum(["strict", "normal", "auto", "plan"]).optional(),
|
|
250161
|
+
webSearchEnabled: z38.boolean().optional(),
|
|
250162
|
+
webSearchProvider: z38.enum(["auto", "searxng", "tavily", "bing", "duckduckgo"]).optional(),
|
|
250163
|
+
webSearchMaxResults: z38.number().int().min(1).max(20).optional()
|
|
249069
250164
|
}).strict();
|
|
249070
|
-
var SessionActionSchema =
|
|
249071
|
-
|
|
250165
|
+
var SessionActionSchema = z38.discriminatedUnion("action", [
|
|
250166
|
+
z38.object({ action: z38.literal("new") }).strict(),
|
|
249072
250167
|
...["resume", "archive", "restore", "delete"].map(
|
|
249073
|
-
(action) =>
|
|
249074
|
-
action:
|
|
249075
|
-
sessionId:
|
|
250168
|
+
(action) => z38.object({
|
|
250169
|
+
action: z38.literal(action),
|
|
250170
|
+
sessionId: z38.string().trim().min(1).max(200).regex(/^[a-zA-Z0-9_-]+$/)
|
|
249076
250171
|
}).strict()
|
|
249077
250172
|
)
|
|
249078
250173
|
]);
|
|
249079
|
-
var ProjectActionSchema =
|
|
249080
|
-
|
|
249081
|
-
|
|
249082
|
-
action:
|
|
249083
|
-
path:
|
|
250174
|
+
var ProjectActionSchema = z38.discriminatedUnion("action", [
|
|
250175
|
+
z38.object({ action: z38.literal("pick") }).strict(),
|
|
250176
|
+
z38.object({
|
|
250177
|
+
action: z38.enum(["open", "create"]),
|
|
250178
|
+
path: z38.string().trim().min(1).max(4096)
|
|
249084
250179
|
}).strict(),
|
|
249085
|
-
|
|
249086
|
-
action:
|
|
249087
|
-
projectId:
|
|
250180
|
+
z38.object({
|
|
250181
|
+
action: z38.literal("remove"),
|
|
250182
|
+
projectId: z38.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/)
|
|
249088
250183
|
}).strict()
|
|
249089
250184
|
]);
|
|
249090
|
-
var CompletionQuerySchema =
|
|
250185
|
+
var CompletionQuerySchema = z38.string().trim().max(200);
|
|
249091
250186
|
function safeCall2(fn) {
|
|
249092
250187
|
try {
|
|
249093
250188
|
return fn();
|
|
@@ -249122,7 +250217,7 @@ var OrbitWebUiRuntime = class {
|
|
|
249122
250217
|
server;
|
|
249123
250218
|
handle;
|
|
249124
250219
|
stopPromise;
|
|
249125
|
-
|
|
250220
|
+
completionCandidatesPromise;
|
|
249126
250221
|
constructor(options) {
|
|
249127
250222
|
this.options = options;
|
|
249128
250223
|
this.events = new WebUiEventStream(() => this.activeTurn);
|
|
@@ -249145,7 +250240,7 @@ var OrbitWebUiRuntime = class {
|
|
|
249145
250240
|
throw new Error("Orbit Web UI is not running.");
|
|
249146
250241
|
}
|
|
249147
250242
|
this.options = options;
|
|
249148
|
-
this.
|
|
250243
|
+
this.completionCandidatesPromise = void 0;
|
|
249149
250244
|
}
|
|
249150
250245
|
/** Return this instance's live public handle. */
|
|
249151
250246
|
getHandle() {
|
|
@@ -249293,10 +250388,17 @@ var OrbitWebUiRuntime = class {
|
|
|
249293
250388
|
sendJson(res, 400, { error: "Invalid completion query." });
|
|
249294
250389
|
return;
|
|
249295
250390
|
}
|
|
249296
|
-
const
|
|
250391
|
+
const candidates = await this.getCompletionCandidates(options);
|
|
250392
|
+
const normalizedQuery = query.data.trim().toLowerCase();
|
|
249297
250393
|
sendJson(res, 200, {
|
|
249298
|
-
files: filterWebUiCompletionFiles(files, query.data),
|
|
249299
|
-
|
|
250394
|
+
files: filterWebUiCompletionFiles(candidates.files, query.data),
|
|
250395
|
+
commands: candidates.commands.filter(
|
|
250396
|
+
(command) => !normalizedQuery || command.includes(normalizedQuery)
|
|
250397
|
+
),
|
|
250398
|
+
commandDetails: (candidates.commandDetails ?? []).filter(
|
|
250399
|
+
({ command }) => !normalizedQuery || command.includes(normalizedQuery)
|
|
250400
|
+
),
|
|
250401
|
+
total: candidates.files.length
|
|
249300
250402
|
});
|
|
249301
250403
|
return;
|
|
249302
250404
|
}
|
|
@@ -249383,16 +250485,20 @@ var OrbitWebUiRuntime = class {
|
|
|
249383
250485
|
});
|
|
249384
250486
|
}
|
|
249385
250487
|
}
|
|
249386
|
-
|
|
249387
|
-
if (!this.
|
|
249388
|
-
this.
|
|
250488
|
+
getCompletionCandidates(options) {
|
|
250489
|
+
if (!this.completionCandidatesPromise) {
|
|
250490
|
+
this.completionCandidatesPromise = getAutocompleteCandidates(
|
|
249389
250491
|
options.cwd,
|
|
249390
250492
|
options.config
|
|
249391
|
-
).then(
|
|
249392
|
-
|
|
249393
|
-
|
|
250493
|
+
).then((candidates) => ({
|
|
250494
|
+
...candidates,
|
|
250495
|
+
files: candidates.files.slice(
|
|
250496
|
+
0,
|
|
250497
|
+
options.config.context.maxFilesToIndex
|
|
250498
|
+
)
|
|
250499
|
+
}));
|
|
249394
250500
|
}
|
|
249395
|
-
return this.
|
|
250501
|
+
return this.completionCandidatesPromise;
|
|
249396
250502
|
}
|
|
249397
250503
|
async handleChat(req, res, options) {
|
|
249398
250504
|
if (!options.submitPrompt) {
|
|
@@ -250473,9 +251579,9 @@ async function handleContextCommand(command, argument, dependencies) {
|
|
|
250473
251579
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
250474
251580
|
import { existsSync as existsSync19, rmSync as rmSync5 } from "fs";
|
|
250475
251581
|
import picocolors13 from "picocolors";
|
|
250476
|
-
import { z as
|
|
250477
|
-
var GitStatusCodeSchema =
|
|
250478
|
-
var GitStatusPathSchema =
|
|
251582
|
+
import { z as z39 } from "zod";
|
|
251583
|
+
var GitStatusCodeSchema = z39.string().length(2).regex(/^[ MADRCU?!]{2}$/);
|
|
251584
|
+
var GitStatusPathSchema = z39.string().min(1).max(32768);
|
|
250479
251585
|
var defaultGitAdapter = {
|
|
250480
251586
|
status: (cwd) => execFileSync5("git", ["status", "--porcelain=v1", "-z"], {
|
|
250481
251587
|
cwd,
|
|
@@ -250510,8 +251616,16 @@ function parseGitStatusPaths(output) {
|
|
|
250510
251616
|
return [...new Set(paths)];
|
|
250511
251617
|
}
|
|
250512
251618
|
async function handleRollbackCommand(command, argument, dependencies) {
|
|
250513
|
-
if (command !== "/rollback") return null;
|
|
250514
251619
|
const isZh = dependencies.language === "zh";
|
|
251620
|
+
if (command === "/timeline") {
|
|
251621
|
+
printCheckpointTimeline(dependencies.loop.getCheckpoints(), dependencies);
|
|
251622
|
+
return HANDLED_COMMAND;
|
|
251623
|
+
}
|
|
251624
|
+
if (command === "/rewind") {
|
|
251625
|
+
await rewindToCheckpoint(argument, dependencies);
|
|
251626
|
+
return HANDLED_COMMAND;
|
|
251627
|
+
}
|
|
251628
|
+
if (command !== "/rollback") return null;
|
|
250515
251629
|
if (argument === "all" || argument === "--all") {
|
|
250516
251630
|
await dependencies.loop.rollbackLastCheckpoint();
|
|
250517
251631
|
return HANDLED_COMMAND;
|
|
@@ -250591,6 +251705,65 @@ async function handleRollbackCommand(command, argument, dependencies) {
|
|
|
250591
251705
|
}
|
|
250592
251706
|
return HANDLED_COMMAND;
|
|
250593
251707
|
}
|
|
251708
|
+
function printCheckpointTimeline(checkpoints, dependencies) {
|
|
251709
|
+
const isZh = dependencies.language === "zh";
|
|
251710
|
+
if (checkpoints.length === 0) {
|
|
251711
|
+
dependencies.printOutput(
|
|
251712
|
+
picocolors13.yellow(
|
|
251713
|
+
isZh ? "\u5F53\u524D\u804A\u5929\u8FD8\u6CA1\u6709\u6587\u4EF6\u68C0\u67E5\u70B9\u3002" : "This chat has no file checkpoints yet."
|
|
251714
|
+
)
|
|
251715
|
+
);
|
|
251716
|
+
return;
|
|
251717
|
+
}
|
|
251718
|
+
const newestFirst = checkpoints.slice().reverse();
|
|
251719
|
+
const visible = newestFirst.slice(0, 50);
|
|
251720
|
+
const lines = [
|
|
251721
|
+
picocolors13.bold(
|
|
251722
|
+
isZh ? `\u6587\u4EF6\u68C0\u67E5\u70B9\uFF08${checkpoints.length}\uFF09` : `File checkpoints (${checkpoints.length})`
|
|
251723
|
+
),
|
|
251724
|
+
...visible.map((checkpoint, index) => {
|
|
251725
|
+
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";
|
|
251726
|
+
return `${picocolors13.cyan(String(index + 1).padStart(2))} ${checkpoint.id.slice(0, 12)} ${checkpoint.timestamp} ${files}`;
|
|
251727
|
+
})
|
|
251728
|
+
];
|
|
251729
|
+
if (newestFirst.length > visible.length) {
|
|
251730
|
+
lines.push(
|
|
251731
|
+
picocolors13.gray(
|
|
251732
|
+
isZh ? `\u4EC5\u663E\u793A\u6700\u8FD1 ${visible.length} \u4E2A\u68C0\u67E5\u70B9\u3002` : `Showing the ${visible.length} most recent checkpoints.`
|
|
251733
|
+
)
|
|
251734
|
+
);
|
|
251735
|
+
}
|
|
251736
|
+
lines.push(
|
|
251737
|
+
picocolors13.gray(
|
|
251738
|
+
isZh ? "\u4F7F\u7528 /rewind <\u7F16\u53F7\u6216 ID \u524D\u7F00> \u56DE\u9000\u3002" : "Use /rewind <number or ID prefix> to restore one."
|
|
251739
|
+
)
|
|
251740
|
+
);
|
|
251741
|
+
dependencies.printOutput(lines.join("\n"));
|
|
251742
|
+
}
|
|
251743
|
+
async function rewindToCheckpoint(argument, dependencies) {
|
|
251744
|
+
const isZh = dependencies.language === "zh";
|
|
251745
|
+
const selector = argument.trim();
|
|
251746
|
+
if (!selector) {
|
|
251747
|
+
dependencies.printOutput(
|
|
251748
|
+
picocolors13.red(
|
|
251749
|
+
isZh ? "\u2716 \u7528\u6CD5\uFF1A/rewind <\u68C0\u67E5\u70B9\u7F16\u53F7\u6216 ID \u524D\u7F00>" : "\u2716 Usage: /rewind <checkpoint number or ID prefix>"
|
|
251750
|
+
)
|
|
251751
|
+
);
|
|
251752
|
+
return;
|
|
251753
|
+
}
|
|
251754
|
+
const newestFirst = dependencies.loop.getCheckpoints().slice().reverse();
|
|
251755
|
+
const numeric = /^\d+$/.test(selector) ? Number(selector) : Number.NaN;
|
|
251756
|
+
const matches = Number.isInteger(numeric) && numeric >= 1 ? newestFirst[numeric - 1] ? [newestFirst[numeric - 1]] : [] : newestFirst.filter((checkpoint) => checkpoint.id.startsWith(selector));
|
|
251757
|
+
if (matches.length !== 1) {
|
|
251758
|
+
dependencies.printOutput(
|
|
251759
|
+
picocolors13.red(
|
|
251760
|
+
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}`
|
|
251761
|
+
)
|
|
251762
|
+
);
|
|
251763
|
+
return;
|
|
251764
|
+
}
|
|
251765
|
+
await dependencies.loop.rewindToCheckpoint(matches[0].id);
|
|
251766
|
+
}
|
|
250594
251767
|
function removeWorkspacePath(absolutePath) {
|
|
250595
251768
|
rmSync5(absolutePath, { recursive: true, force: true });
|
|
250596
251769
|
}
|
|
@@ -250906,32 +252079,32 @@ function ensureSessionTitle(loop, prompt) {
|
|
|
250906
252079
|
}
|
|
250907
252080
|
|
|
250908
252081
|
// 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:
|
|
252082
|
+
import { z as z40 } from "zod";
|
|
252083
|
+
var ModelEntrySchema = z40.object({
|
|
252084
|
+
id: z40.unknown().optional(),
|
|
252085
|
+
model: z40.unknown().optional(),
|
|
252086
|
+
context_length: z40.unknown().optional(),
|
|
252087
|
+
context_window: z40.unknown().optional(),
|
|
252088
|
+
max_context_tokens: z40.unknown().optional(),
|
|
252089
|
+
max_output_tokens: z40.unknown().optional(),
|
|
252090
|
+
input_modalities: z40.unknown().optional(),
|
|
252091
|
+
output_modalities: z40.unknown().optional(),
|
|
252092
|
+
modalities: z40.unknown().optional(),
|
|
252093
|
+
architecture: z40.unknown().optional(),
|
|
252094
|
+
capabilities: z40.unknown().optional(),
|
|
252095
|
+
supported_parameters: z40.unknown().optional(),
|
|
252096
|
+
type: z40.unknown().optional(),
|
|
252097
|
+
kind: z40.unknown().optional(),
|
|
252098
|
+
task: z40.unknown().optional(),
|
|
252099
|
+
endpoint: z40.unknown().optional(),
|
|
252100
|
+
details: z40.unknown().optional()
|
|
250928
252101
|
}).passthrough();
|
|
250929
|
-
var ModelListSchema =
|
|
250930
|
-
|
|
250931
|
-
|
|
250932
|
-
|
|
252102
|
+
var ModelListSchema = z40.union([
|
|
252103
|
+
z40.object({ data: z40.array(ModelEntrySchema).max(1e3) }),
|
|
252104
|
+
z40.object({ models: z40.array(ModelEntrySchema).max(1e3) }),
|
|
252105
|
+
z40.array(ModelEntrySchema).max(1e3)
|
|
250933
252106
|
]);
|
|
250934
|
-
var DiscoveryUrlSchema =
|
|
252107
|
+
var DiscoveryUrlSchema = z40.string().url().max(4096).transform((value) => new URL(value));
|
|
250935
252108
|
var MAX_MODEL_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
250936
252109
|
async function discoverProviderModels(options) {
|
|
250937
252110
|
const base = DiscoveryUrlSchema.parse(options.baseUrl.trim());
|
|
@@ -251098,9 +252271,9 @@ function normalizeModelEntries(entries) {
|
|
|
251098
252271
|
}
|
|
251099
252272
|
return { models, modelCapabilities };
|
|
251100
252273
|
}
|
|
251101
|
-
var OllamaShowSchema =
|
|
251102
|
-
capabilities:
|
|
251103
|
-
model_info:
|
|
252274
|
+
var OllamaShowSchema = z40.object({
|
|
252275
|
+
capabilities: z40.array(z40.string().max(128)).max(64).optional(),
|
|
252276
|
+
model_info: z40.record(z40.unknown()).optional()
|
|
251104
252277
|
}).passthrough();
|
|
251105
252278
|
async function enrichOllamaCapabilities(base, models, target, fetchImpl, signal) {
|
|
251106
252279
|
const endpoint = new URL(base);
|
|
@@ -251347,9 +252520,9 @@ function isPickerCancellation(error) {
|
|
|
251347
252520
|
|
|
251348
252521
|
// src/runtime/commands/SessionMetadataCommandHandler.ts
|
|
251349
252522
|
import picocolors15 from "picocolors";
|
|
251350
|
-
import { z as
|
|
251351
|
-
var GoalSchema =
|
|
251352
|
-
var SessionTitleSchema =
|
|
252523
|
+
import { z as z41 } from "zod";
|
|
252524
|
+
var GoalSchema = z41.string().trim().min(1).max(4e3);
|
|
252525
|
+
var SessionTitleSchema = z41.string().trim().min(1).max(160);
|
|
251353
252526
|
function handleSessionMetadataCommand(command, argument, dependencies) {
|
|
251354
252527
|
if (command === "/goal") {
|
|
251355
252528
|
handleGoal(argument, dependencies);
|
|
@@ -251414,9 +252587,9 @@ function handleRename(argument, { loop, isZh, printOutput }) {
|
|
|
251414
252587
|
|
|
251415
252588
|
// src/runtime/commands/WorkspaceStateCommandHandler.ts
|
|
251416
252589
|
import picocolors16 from "picocolors";
|
|
251417
|
-
import { z as
|
|
251418
|
-
var TextSchema =
|
|
251419
|
-
var ItemReferenceSchema =
|
|
252590
|
+
import { z as z45 } from "zod";
|
|
252591
|
+
var TextSchema = z45.string().trim().min(1).max(2e3);
|
|
252592
|
+
var ItemReferenceSchema = z45.string().trim().min(1).max(100);
|
|
251420
252593
|
function handleWorkspaceStateCommand(command, argument, dependencies) {
|
|
251421
252594
|
if (command === "/memory") {
|
|
251422
252595
|
handleMemory(argument, dependencies);
|
|
@@ -251592,11 +252765,11 @@ function resolveItemId(reference, items) {
|
|
|
251592
252765
|
// src/commands/update.ts
|
|
251593
252766
|
import readline4 from "readline";
|
|
251594
252767
|
import picocolors17 from "picocolors";
|
|
251595
|
-
import { z as
|
|
251596
|
-
var UpdateCommandOptionsSchema =
|
|
251597
|
-
check:
|
|
251598
|
-
yes:
|
|
251599
|
-
json:
|
|
252768
|
+
import { z as z46 } from "zod";
|
|
252769
|
+
var UpdateCommandOptionsSchema = z46.object({
|
|
252770
|
+
check: z46.boolean().default(false),
|
|
252771
|
+
yes: z46.boolean().default(false),
|
|
252772
|
+
json: z46.boolean().default(false),
|
|
251600
252773
|
channel: UpdateChannelSchema.default("stable")
|
|
251601
252774
|
}).strict();
|
|
251602
252775
|
async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
@@ -251605,7 +252778,12 @@ async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
|
251605
252778
|
const write = dependencies.write ?? ((text) => console.log(text));
|
|
251606
252779
|
const check = manager.check(currentVersion, options.channel);
|
|
251607
252780
|
if (!check.updateAvailable) {
|
|
251608
|
-
const result2 = {
|
|
252781
|
+
const result2 = {
|
|
252782
|
+
check,
|
|
252783
|
+
installed: false,
|
|
252784
|
+
restartRequired: false,
|
|
252785
|
+
channel: options.channel
|
|
252786
|
+
};
|
|
251609
252787
|
write(
|
|
251610
252788
|
options.json ? JSON.stringify({ schemaVersion: 1, ...result2 }) : picocolors17.green(
|
|
251611
252789
|
`\u2714 Orbit ${check.currentVersion} is already up to date.`
|
|
@@ -251613,11 +252791,35 @@ async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
|
251613
252791
|
);
|
|
251614
252792
|
return result2;
|
|
251615
252793
|
}
|
|
252794
|
+
let latestAlreadyInstalled = false;
|
|
252795
|
+
try {
|
|
252796
|
+
latestAlreadyInstalled = manager.readInstalledVersion() === check.latestVersion;
|
|
252797
|
+
} catch {
|
|
252798
|
+
}
|
|
252799
|
+
if (latestAlreadyInstalled) {
|
|
252800
|
+
const result2 = {
|
|
252801
|
+
check,
|
|
252802
|
+
installed: false,
|
|
252803
|
+
restartRequired: true,
|
|
252804
|
+
channel: options.channel
|
|
252805
|
+
};
|
|
252806
|
+
write(
|
|
252807
|
+
options.json ? JSON.stringify({ schemaVersion: 1, ...result2 }) : picocolors17.yellow(
|
|
252808
|
+
`\u25CF Orbit ${check.latestVersion} is installed, but this process is still ${check.currentVersion}. Exit and relaunch Orbit, then reopen /webui.`
|
|
252809
|
+
)
|
|
252810
|
+
);
|
|
252811
|
+
return result2;
|
|
252812
|
+
}
|
|
251616
252813
|
if (options.check || options.json && !options.yes) {
|
|
251617
|
-
const result2 = {
|
|
252814
|
+
const result2 = {
|
|
252815
|
+
check,
|
|
252816
|
+
installed: false,
|
|
252817
|
+
restartRequired: false,
|
|
252818
|
+
channel: options.channel
|
|
252819
|
+
};
|
|
251618
252820
|
write(
|
|
251619
252821
|
options.json ? JSON.stringify({ schemaVersion: 1, ...result2 }) : `${picocolors17.yellow("\u25CF Update available:")} ${check.currentVersion} \u2192 ${check.latestVersion}
|
|
251620
|
-
Run ${picocolors17.cyan("orbit update --yes")}
|
|
252822
|
+
Run ${picocolors17.cyan("orbit update --yes")} in a terminal, then restart Orbit and reopen ${picocolors17.cyan("/webui")}.`
|
|
251621
252823
|
);
|
|
251622
252824
|
return result2;
|
|
251623
252825
|
}
|
|
@@ -251636,7 +252838,12 @@ async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
|
251636
252838
|
}
|
|
251637
252839
|
if (!confirmed) {
|
|
251638
252840
|
write(picocolors17.yellow("\u26A0 Update cancelled."));
|
|
251639
|
-
return {
|
|
252841
|
+
return {
|
|
252842
|
+
check,
|
|
252843
|
+
installed: false,
|
|
252844
|
+
restartRequired: false,
|
|
252845
|
+
channel: options.channel
|
|
252846
|
+
};
|
|
251640
252847
|
}
|
|
251641
252848
|
dependencies.beforeInstall?.();
|
|
251642
252849
|
try {
|
|
@@ -251668,12 +252875,13 @@ async function runUpdate(currentVersion, rawOptions, dependencies = {}) {
|
|
|
251668
252875
|
const result = {
|
|
251669
252876
|
check,
|
|
251670
252877
|
installed: true,
|
|
252878
|
+
restartRequired: true,
|
|
251671
252879
|
channel: options.channel,
|
|
251672
252880
|
rollback: "not-needed"
|
|
251673
252881
|
};
|
|
251674
252882
|
write(
|
|
251675
252883
|
options.json ? JSON.stringify({ schemaVersion: 1, ...result }) : picocolors17.green(
|
|
251676
|
-
`\u2714 Orbit ${check.latestVersion} installed.
|
|
252884
|
+
`\u2714 Orbit ${check.latestVersion} was installed and verified. This process is still ${check.currentVersion}; exit and relaunch Orbit, then reopen /webui.`
|
|
251677
252885
|
)
|
|
251678
252886
|
);
|
|
251679
252887
|
return result;
|
|
@@ -251909,8 +253117,11 @@ var CommandRouter = class {
|
|
|
251909
253117
|
}
|
|
251910
253118
|
);
|
|
251911
253119
|
tui.setOrbitUpdateAvailable?.(
|
|
251912
|
-
updateResult.
|
|
253120
|
+
updateResult.restartRequired ? false : updateResult.check.updateAvailable
|
|
251913
253121
|
);
|
|
253122
|
+
if (updateResult.restartRequired) {
|
|
253123
|
+
tui.setOrbitRestartRequired?.(true);
|
|
253124
|
+
}
|
|
251914
253125
|
} catch (error) {
|
|
251915
253126
|
const message = error instanceof Error ? error.message : String(error);
|
|
251916
253127
|
this.printOutput(
|
|
@@ -252667,20 +253878,20 @@ ${picocolors18.green("\u2714")} Switched security mode to: ${picocolors18.green(
|
|
|
252667
253878
|
};
|
|
252668
253879
|
|
|
252669
253880
|
// src/runtime/ReplController.ts
|
|
252670
|
-
var AutocompleteRequestSchema =
|
|
252671
|
-
prefix:
|
|
252672
|
-
suffix:
|
|
252673
|
-
windowId:
|
|
253881
|
+
var AutocompleteRequestSchema = z47.object({
|
|
253882
|
+
prefix: z47.string().max(2e4),
|
|
253883
|
+
suffix: z47.string().max(2e4),
|
|
253884
|
+
windowId: z47.string().max(1e3).optional()
|
|
252674
253885
|
});
|
|
252675
253886
|
var AUTOCOMPLETE_BODY_LIMIT_BYTES = 1e5;
|
|
252676
253887
|
var AUTOCOMPLETE_MAX_CONCURRENCY = 4;
|
|
252677
|
-
var LocalStateSchema =
|
|
252678
|
-
lastSessionId:
|
|
252679
|
-
lastModel:
|
|
253888
|
+
var LocalStateSchema = z47.object({
|
|
253889
|
+
lastSessionId: z47.string().optional(),
|
|
253890
|
+
lastModel: z47.string().optional()
|
|
252680
253891
|
});
|
|
252681
|
-
var AutocompleteEndpointSchema =
|
|
252682
|
-
port:
|
|
252683
|
-
token:
|
|
253892
|
+
var AutocompleteEndpointSchema = z47.object({
|
|
253893
|
+
port: z47.number().int().min(1).max(65535),
|
|
253894
|
+
token: z47.string().min(32).max(256)
|
|
252684
253895
|
});
|
|
252685
253896
|
function getRunOutcomeMessage(outcome) {
|
|
252686
253897
|
if (!outcome || outcome.status === "completed") return void 0;
|
|
@@ -253549,36 +254760,36 @@ function isRecord6(value) {
|
|
|
253549
254760
|
}
|
|
253550
254761
|
|
|
253551
254762
|
// src/commands/LSPServer.ts
|
|
253552
|
-
import { z as
|
|
254763
|
+
import { z as z48 } from "zod";
|
|
253553
254764
|
var MAX_LSP_HEADER_BYTES = 8 * 1024;
|
|
253554
254765
|
var MAX_LSP_BODY_BYTES = 8 * 1024 * 1024;
|
|
253555
|
-
var JsonRpcIdSchema =
|
|
253556
|
-
var JSONRPCMessageSchema =
|
|
253557
|
-
jsonrpc:
|
|
254766
|
+
var JsonRpcIdSchema = z48.union([z48.string(), z48.number(), z48.null()]);
|
|
254767
|
+
var JSONRPCMessageSchema = z48.object({
|
|
254768
|
+
jsonrpc: z48.literal("2.0"),
|
|
253558
254769
|
id: JsonRpcIdSchema.optional(),
|
|
253559
|
-
method:
|
|
253560
|
-
params:
|
|
254770
|
+
method: z48.string().min(1).max(512),
|
|
254771
|
+
params: z48.unknown().optional()
|
|
253561
254772
|
}).strict();
|
|
253562
|
-
var TextDocumentIdentifierSchema =
|
|
253563
|
-
uri:
|
|
254773
|
+
var TextDocumentIdentifierSchema = z48.object({
|
|
254774
|
+
uri: z48.string().min(1).max(16384)
|
|
253564
254775
|
});
|
|
253565
|
-
var DidOpenParamsSchema =
|
|
254776
|
+
var DidOpenParamsSchema = z48.object({
|
|
253566
254777
|
textDocument: TextDocumentIdentifierSchema.extend({
|
|
253567
|
-
text:
|
|
254778
|
+
text: z48.string().max(MAX_LSP_BODY_BYTES)
|
|
253568
254779
|
}).passthrough()
|
|
253569
254780
|
});
|
|
253570
|
-
var DidChangeParamsSchema =
|
|
254781
|
+
var DidChangeParamsSchema = z48.object({
|
|
253571
254782
|
textDocument: TextDocumentIdentifierSchema,
|
|
253572
|
-
contentChanges:
|
|
254783
|
+
contentChanges: z48.array(z48.object({ text: z48.string().max(MAX_LSP_BODY_BYTES) }).passthrough()).min(1).max(100)
|
|
253573
254784
|
});
|
|
253574
|
-
var DidCloseParamsSchema =
|
|
254785
|
+
var DidCloseParamsSchema = z48.object({
|
|
253575
254786
|
textDocument: TextDocumentIdentifierSchema
|
|
253576
254787
|
});
|
|
253577
|
-
var CompletionParamsSchema =
|
|
254788
|
+
var CompletionParamsSchema = z48.object({
|
|
253578
254789
|
textDocument: TextDocumentIdentifierSchema,
|
|
253579
|
-
position:
|
|
253580
|
-
line:
|
|
253581
|
-
character:
|
|
254790
|
+
position: z48.object({
|
|
254791
|
+
line: z48.number().int().nonnegative(),
|
|
254792
|
+
character: z48.number().int().nonnegative()
|
|
253582
254793
|
})
|
|
253583
254794
|
});
|
|
253584
254795
|
var JSONRPCReader = class {
|
|
@@ -253824,7 +255035,7 @@ ${completion}
|
|
|
253824
255035
|
);
|
|
253825
255036
|
}
|
|
253826
255037
|
} catch (error) {
|
|
253827
|
-
if (error instanceof
|
|
255038
|
+
if (error instanceof z48.ZodError) {
|
|
253828
255039
|
sendError(message.id, -32602, "Invalid method parameters.");
|
|
253829
255040
|
return;
|
|
253830
255041
|
}
|
|
@@ -254197,10 +255408,10 @@ import {
|
|
|
254197
255408
|
writeFileSync as writeFileSync13
|
|
254198
255409
|
} from "fs";
|
|
254199
255410
|
import { dirname as dirname10, resolve as resolve11 } from "path";
|
|
254200
|
-
import { z as
|
|
254201
|
-
var TraceOptionsSchema =
|
|
254202
|
-
full:
|
|
254203
|
-
out:
|
|
255411
|
+
import { z as z49 } from "zod";
|
|
255412
|
+
var TraceOptionsSchema = z49.object({
|
|
255413
|
+
full: z49.boolean().default(false),
|
|
255414
|
+
out: z49.string().trim().min(1).max(4096).optional()
|
|
254204
255415
|
});
|
|
254205
255416
|
function runTraceExport(cwd, sessionId, options = {}) {
|
|
254206
255417
|
const value = TraceOptionsSchema.parse(options);
|
|
@@ -254255,16 +255466,16 @@ import { basename as basename6, dirname as dirname11, join as join18 } from "pat
|
|
|
254255
255466
|
import { promisify as promisify5 } from "util";
|
|
254256
255467
|
import picocolors23 from "picocolors";
|
|
254257
255468
|
import { parse as parseYaml2 } from "yaml";
|
|
254258
|
-
import { z as
|
|
255469
|
+
import { z as z50 } from "zod";
|
|
254259
255470
|
var exec4 = promisify5(execCallback);
|
|
254260
255471
|
var MAX_SUITE_BYTES = 1024 * 1024;
|
|
254261
255472
|
var MAX_VERIFICATION_OUTPUT = 4e3;
|
|
254262
|
-
var EvalOptionsSchema =
|
|
254263
|
-
provider:
|
|
254264
|
-
model:
|
|
254265
|
-
task:
|
|
254266
|
-
allowCommands:
|
|
254267
|
-
json:
|
|
255473
|
+
var EvalOptionsSchema = z50.object({
|
|
255474
|
+
provider: z50.string().trim().min(1).optional(),
|
|
255475
|
+
model: z50.string().trim().min(1).optional(),
|
|
255476
|
+
task: z50.string().regex(/^[a-z0-9][a-z0-9_-]{0,63}$/).optional(),
|
|
255477
|
+
allowCommands: z50.boolean().default(false),
|
|
255478
|
+
json: z50.boolean().default(false)
|
|
254268
255479
|
});
|
|
254269
255480
|
async function runEval(cwd, suiteFile, options = {}) {
|
|
254270
255481
|
const value = EvalOptionsSchema.parse(options);
|
|
@@ -254587,16 +255798,16 @@ function safeSummary(value) {
|
|
|
254587
255798
|
import readline6 from "readline";
|
|
254588
255799
|
import picocolors24 from "picocolors";
|
|
254589
255800
|
import { resolve as resolve13 } from "path";
|
|
254590
|
-
import { z as
|
|
255801
|
+
import { z as z54 } from "zod";
|
|
254591
255802
|
|
|
254592
255803
|
// src/runtime/CleanupManager.ts
|
|
254593
255804
|
import { lstatSync as lstatSync6, readdirSync as readdirSync7, rmSync as rmSync9 } from "fs";
|
|
254594
255805
|
import { homedir as homedir11 } from "os";
|
|
254595
255806
|
import { basename as basename7, join as join19, parse as parse5, resolve as resolve12 } from "path";
|
|
254596
|
-
import { z as
|
|
254597
|
-
var CleanupScopeSchema =
|
|
255807
|
+
import { z as z51 } from "zod";
|
|
255808
|
+
var CleanupScopeSchema = z51.enum(["user", "project"]);
|
|
254598
255809
|
function buildCleanupPlan(options) {
|
|
254599
|
-
const scopes =
|
|
255810
|
+
const scopes = z51.array(CleanupScopeSchema).min(1).parse(options.scopes);
|
|
254600
255811
|
const homeDirectory = resolve12(options.homeDirectory ?? homedir11());
|
|
254601
255812
|
const projectDirectory = resolve12(options.projectDirectory ?? options.cwd);
|
|
254602
255813
|
const candidates = scopes.map((scope) => ({
|
|
@@ -254719,12 +255930,12 @@ function safeInventoryWarning(targetPath, error) {
|
|
|
254719
255930
|
}
|
|
254720
255931
|
|
|
254721
255932
|
// src/commands/clean.ts
|
|
254722
|
-
var CleanCommandOptionsSchema =
|
|
254723
|
-
user:
|
|
254724
|
-
project:
|
|
254725
|
-
all:
|
|
254726
|
-
yes:
|
|
254727
|
-
json:
|
|
255933
|
+
var CleanCommandOptionsSchema = z54.object({
|
|
255934
|
+
user: z54.boolean().default(false),
|
|
255935
|
+
project: z54.union([z54.boolean(), z54.string().min(1).max(4096)]).optional(),
|
|
255936
|
+
all: z54.boolean().default(false),
|
|
255937
|
+
yes: z54.boolean().default(false),
|
|
255938
|
+
json: z54.boolean().default(false)
|
|
254728
255939
|
}).strict();
|
|
254729
255940
|
async function runClean(cwd, rawOptions, dependencies = {}) {
|
|
254730
255941
|
const options = CleanCommandOptionsSchema.parse(rawOptions);
|