context-mode 2.1.7 → 2.1.8
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +771 -577
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +89 -89
- package/opencode/plugin.js +442 -229
- package/package.json +1 -1
- package/pi/index.js +298 -123
- package/qwen-extension.json +1 -1
- package/run.mjs +65 -25
- package/search.mjs +65 -25
- package/server.mjs +202 -74
package/server.mjs
CHANGED
|
@@ -3487,7 +3487,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
3487
3487
|
var NONE = 0;
|
|
3488
3488
|
var ASSUMED = 1;
|
|
3489
3489
|
var PROVEN = 2;
|
|
3490
|
-
function isRecursive(inst, stack2,
|
|
3490
|
+
function isRecursive(inst, stack2, resolve10) {
|
|
3491
3491
|
const cached4 = recursive.get(inst);
|
|
3492
3492
|
if (cached4 !== void 0)
|
|
3493
3493
|
return cached4 ? PROVEN : NONE;
|
|
@@ -3497,7 +3497,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3497
3497
|
let result = NONE;
|
|
3498
3498
|
const check2 = (child) => {
|
|
3499
3499
|
if (result !== PROVEN && child?._zod) {
|
|
3500
|
-
const answer3 = isRecursive(child, stack2,
|
|
3500
|
+
const answer3 = isRecursive(child, stack2, resolve10);
|
|
3501
3501
|
if (answer3 > result)
|
|
3502
3502
|
result = answer3;
|
|
3503
3503
|
}
|
|
@@ -3508,7 +3508,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3508
3508
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3509
3509
|
if (spread && !desc.enumerable)
|
|
3510
3510
|
continue;
|
|
3511
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2,
|
|
3511
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve10) : NONE;
|
|
3512
3512
|
if (child > answer3)
|
|
3513
3513
|
answer3 = child;
|
|
3514
3514
|
}
|
|
@@ -3572,7 +3572,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3572
3572
|
break;
|
|
3573
3573
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
3574
3574
|
case "lazy": {
|
|
3575
|
-
const inner = def._cachedInner ?? (
|
|
3575
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
3576
3576
|
merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
|
|
3577
3577
|
break;
|
|
3578
3578
|
}
|
|
@@ -11016,7 +11016,7 @@ var recursive2 = /* @__PURE__ */ new WeakMap();
|
|
|
11016
11016
|
var NONE2 = 0;
|
|
11017
11017
|
var ASSUMED2 = 1;
|
|
11018
11018
|
var PROVEN2 = 2;
|
|
11019
|
-
function isRecursive2(inst, stack2,
|
|
11019
|
+
function isRecursive2(inst, stack2, resolve10) {
|
|
11020
11020
|
const cached4 = recursive2.get(inst);
|
|
11021
11021
|
if (cached4 !== void 0)
|
|
11022
11022
|
return cached4 ? PROVEN2 : NONE2;
|
|
@@ -11026,7 +11026,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11026
11026
|
let result = NONE2;
|
|
11027
11027
|
const check2 = (child) => {
|
|
11028
11028
|
if (result !== PROVEN2 && child?._zod) {
|
|
11029
|
-
const answer3 = isRecursive2(child, stack2,
|
|
11029
|
+
const answer3 = isRecursive2(child, stack2, resolve10);
|
|
11030
11030
|
if (answer3 > result)
|
|
11031
11031
|
result = answer3;
|
|
11032
11032
|
}
|
|
@@ -11037,7 +11037,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11037
11037
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
11038
11038
|
if (spread && !desc.enumerable)
|
|
11039
11039
|
continue;
|
|
11040
|
-
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2,
|
|
11040
|
+
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve10) : NONE2;
|
|
11041
11041
|
if (child > answer3)
|
|
11042
11042
|
answer3 = child;
|
|
11043
11043
|
}
|
|
@@ -11101,7 +11101,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11101
11101
|
break;
|
|
11102
11102
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
11103
11103
|
case "lazy": {
|
|
11104
|
-
const inner = def._cachedInner ?? (
|
|
11104
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
11105
11105
|
merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
|
|
11106
11106
|
break;
|
|
11107
11107
|
}
|
|
@@ -17705,14 +17705,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
17705
17705
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
17706
17706
|
}
|
|
17707
17707
|
function sleep(ms, signal) {
|
|
17708
|
-
return new Promise((
|
|
17708
|
+
return new Promise((resolve10, reject) => {
|
|
17709
17709
|
if (signal?.aborted) {
|
|
17710
17710
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
17711
17711
|
return;
|
|
17712
17712
|
}
|
|
17713
17713
|
const timer = setTimeout(() => {
|
|
17714
17714
|
signal?.removeEventListener("abort", onAbort);
|
|
17715
|
-
|
|
17715
|
+
resolve10();
|
|
17716
17716
|
}, ms);
|
|
17717
17717
|
const onAbort = () => {
|
|
17718
17718
|
clearTimeout(timer);
|
|
@@ -18511,7 +18511,7 @@ var Protocol = class {
|
|
|
18511
18511
|
const flowStartedAt = Date.now();
|
|
18512
18512
|
let onAbort;
|
|
18513
18513
|
let cleanupMessageId;
|
|
18514
|
-
return new Promise((
|
|
18514
|
+
return new Promise((resolve10, reject) => {
|
|
18515
18515
|
const earlyReject = (error42) => {
|
|
18516
18516
|
reject(error42);
|
|
18517
18517
|
};
|
|
@@ -18580,7 +18580,7 @@ var Protocol = class {
|
|
|
18580
18580
|
}
|
|
18581
18581
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
18582
18582
|
if (decoded.kind === "input_required") {
|
|
18583
|
-
if (options?.allowInputRequired === true) return
|
|
18583
|
+
if (options?.allowInputRequired === true) return resolve10(manualInputRequiredValue(decoded));
|
|
18584
18584
|
const flow = {
|
|
18585
18585
|
codec,
|
|
18586
18586
|
request: request2,
|
|
@@ -18592,11 +18592,11 @@ var Protocol = class {
|
|
|
18592
18592
|
params
|
|
18593
18593
|
}, resultSchema, legOptions)
|
|
18594
18594
|
};
|
|
18595
|
-
return
|
|
18595
|
+
return resolve10(this._resolveNonCompleteResult(decoded, flow));
|
|
18596
18596
|
}
|
|
18597
18597
|
const result = decoded.result;
|
|
18598
18598
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
18599
|
-
if (parseResult.success)
|
|
18599
|
+
if (parseResult.success) resolve10(parseResult.data);
|
|
18600
18600
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
18601
18601
|
}, reject);
|
|
18602
18602
|
});
|
|
@@ -21512,7 +21512,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21512
21512
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
21513
21513
|
const schOrFunc = root.refs[ref];
|
|
21514
21514
|
if (schOrFunc) return schOrFunc;
|
|
21515
|
-
let _sch =
|
|
21515
|
+
let _sch = resolve10.call(this, root, ref);
|
|
21516
21516
|
if (_sch === void 0) {
|
|
21517
21517
|
const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
|
|
21518
21518
|
const { schemaId } = this.opts;
|
|
@@ -21538,7 +21538,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21538
21538
|
function sameSchemaEnv(s1, s2) {
|
|
21539
21539
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
21540
21540
|
}
|
|
21541
|
-
function
|
|
21541
|
+
function resolve10(root, ref) {
|
|
21542
21542
|
let sch;
|
|
21543
21543
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
21544
21544
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -21988,7 +21988,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21988
21988
|
else if (typeof uri === "object") uri = parse6(serialize(uri, options), options);
|
|
21989
21989
|
return uri;
|
|
21990
21990
|
}
|
|
21991
|
-
function
|
|
21991
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
21992
21992
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
21993
21993
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
21994
21994
|
schemelessOptions.skipEscape = true;
|
|
@@ -22162,7 +22162,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
22162
22162
|
const fastUri = {
|
|
22163
22163
|
SCHEMES,
|
|
22164
22164
|
normalize: normalize2,
|
|
22165
|
-
resolve:
|
|
22165
|
+
resolve: resolve10,
|
|
22166
22166
|
resolveComponent,
|
|
22167
22167
|
equal,
|
|
22168
22168
|
serialize,
|
|
@@ -27627,7 +27627,7 @@ var StdioServerTransport = class {
|
|
|
27627
27627
|
}
|
|
27628
27628
|
send(message2) {
|
|
27629
27629
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
27630
|
-
return new Promise((
|
|
27630
|
+
return new Promise((resolve10, reject) => {
|
|
27631
27631
|
const json2 = serializeMessage(message2);
|
|
27632
27632
|
let settled = false;
|
|
27633
27633
|
const onError = (error42) => {
|
|
@@ -27642,14 +27642,14 @@ var StdioServerTransport = class {
|
|
|
27642
27642
|
settled = true;
|
|
27643
27643
|
this._stdout.off("error", onError);
|
|
27644
27644
|
this._stdout.off("drain", onDrain);
|
|
27645
|
-
|
|
27645
|
+
resolve10();
|
|
27646
27646
|
};
|
|
27647
27647
|
this._stdout.once("error", onError);
|
|
27648
27648
|
if (this._stdout.write(json2)) {
|
|
27649
27649
|
if (settled) return;
|
|
27650
27650
|
settled = true;
|
|
27651
27651
|
this._stdout.off("error", onError);
|
|
27652
|
-
|
|
27652
|
+
resolve10();
|
|
27653
27653
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
27654
27654
|
});
|
|
27655
27655
|
}
|
|
@@ -27703,14 +27703,14 @@ var StdioConnectionChannel = class {
|
|
|
27703
27703
|
*/
|
|
27704
27704
|
async whenRequestsAnswered(timeoutMs) {
|
|
27705
27705
|
if (this._closed || this._pendingRequests.size === 0) return true;
|
|
27706
|
-
return await new Promise((
|
|
27706
|
+
return await new Promise((resolve10) => {
|
|
27707
27707
|
const waiter = () => {
|
|
27708
27708
|
clearTimeout(timer);
|
|
27709
|
-
|
|
27709
|
+
resolve10(true);
|
|
27710
27710
|
};
|
|
27711
27711
|
const timer = setTimeout(() => {
|
|
27712
27712
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
27713
|
-
|
|
27713
|
+
resolve10(false);
|
|
27714
27714
|
}, timeoutMs);
|
|
27715
27715
|
this._drainWaiters.push(waiter);
|
|
27716
27716
|
});
|
|
@@ -28446,7 +28446,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28446
28446
|
var DECISION_SOURCE = "decision";
|
|
28447
28447
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28448
28448
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28449
|
-
var BUNDLE_SHA = true ? "
|
|
28449
|
+
var BUNDLE_SHA = true ? "92c1ad26d57b45e786a3dc9149549c416badca09" : void 0;
|
|
28450
28450
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28451
28451
|
var DOCTOR_LABEL = Object.freeze({
|
|
28452
28452
|
D1: "version",
|
|
@@ -28850,6 +28850,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
|
|
|
28850
28850
|
var V1_HOOK_COMMAND = "context-mode hook";
|
|
28851
28851
|
var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
|
|
28852
28852
|
var V1_CODEX_HOOKS_DIR = Object.freeze(["hooks", "codex"]);
|
|
28853
|
+
var V1_CODEX_SCRIPT_NAMES = Object.freeze([
|
|
28854
|
+
"pretooluse.mjs",
|
|
28855
|
+
"posttooluse.mjs",
|
|
28856
|
+
"sessionstart.mjs",
|
|
28857
|
+
"precompact.mjs",
|
|
28858
|
+
"userpromptsubmit.mjs",
|
|
28859
|
+
"stop.mjs"
|
|
28860
|
+
]);
|
|
28853
28861
|
var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
|
|
28854
28862
|
var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
|
|
28855
28863
|
var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
@@ -28909,7 +28917,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
|
28909
28917
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28910
28918
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28911
28919
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
28912
|
-
var V1_SCRIPT_EXT = ".mjs";
|
|
28913
28920
|
var V1_BIN_COMMAND = SERVER_KEY;
|
|
28914
28921
|
var VSCODE_MCP_SERVERS_KEY = "servers";
|
|
28915
28922
|
var ZCODE_EVENTS_KEY = "events";
|
|
@@ -28925,7 +28932,7 @@ var V1_REASON = Object.freeze({
|
|
|
28925
28932
|
cacheHealFile: "old context-mode cache-heal script file",
|
|
28926
28933
|
statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
|
|
28927
28934
|
mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
|
|
28928
|
-
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex
|
|
28935
|
+
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
|
|
28929
28936
|
codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
|
|
28930
28937
|
hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
|
|
28931
28938
|
vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
|
|
@@ -28963,7 +28970,6 @@ var HOST_CONFIG_TEXT_PATH = "(given text)";
|
|
|
28963
28970
|
var JSON_INDENT_UNIT = " ";
|
|
28964
28971
|
var MCP_COMMAND_FIELD = "command";
|
|
28965
28972
|
var MCP_ARGS_FIELD = "args";
|
|
28966
|
-
var MCP_ENV_FIELD = "env";
|
|
28967
28973
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
28968
28974
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
28969
28975
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -29659,10 +29665,10 @@ function resolveConfigDir(env) {
|
|
|
29659
29665
|
}
|
|
29660
29666
|
|
|
29661
29667
|
// src/core/project/resolve.ts
|
|
29662
|
-
import { basename as basename2, dirname as dirname3, join as join3, resolve as
|
|
29668
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve3 } from "node:path";
|
|
29663
29669
|
|
|
29664
29670
|
// src/core/project/contain.ts
|
|
29665
|
-
import { dirname as dirname2, join as join2, relative, sep } from "node:path";
|
|
29671
|
+
import { dirname as dirname2, isAbsolute, join as join2, relative, resolve as resolve2, sep } from "node:path";
|
|
29666
29672
|
var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29667
29673
|
function real(p) {
|
|
29668
29674
|
try {
|
|
@@ -29881,7 +29887,7 @@ function gitDirs(dir) {
|
|
|
29881
29887
|
const gitDir = gitDirAt(join3(cur, GIT_DIR_NAME));
|
|
29882
29888
|
if (gitDir !== null) {
|
|
29883
29889
|
const common = firstLine(join3(gitDir, GIT_COMMONDIR_FILE));
|
|
29884
|
-
return { commonDir: realpathSync3.native(common === null ? gitDir :
|
|
29890
|
+
return { commonDir: realpathSync3.native(common === null ? gitDir : resolve3(gitDir, common)), worktree: cur, start };
|
|
29885
29891
|
}
|
|
29886
29892
|
const up = dirname3(cur);
|
|
29887
29893
|
if (up === cur) return { commonDir: null, start };
|
|
@@ -29896,7 +29902,7 @@ function gitDirAt(dotGit) {
|
|
|
29896
29902
|
} else {
|
|
29897
29903
|
const line = firstLine(dotGit);
|
|
29898
29904
|
if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
|
|
29899
|
-
gitDir =
|
|
29905
|
+
gitDir = resolve3(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
|
|
29900
29906
|
}
|
|
29901
29907
|
} catch {
|
|
29902
29908
|
return null;
|
|
@@ -44310,10 +44316,10 @@ function startArgv(argv) {
|
|
|
44310
44316
|
return sh === null ? null : [sh, ...argv];
|
|
44311
44317
|
}
|
|
44312
44318
|
function runProcess(argv, o) {
|
|
44313
|
-
return new Promise((
|
|
44319
|
+
return new Promise((resolve10) => {
|
|
44314
44320
|
const isWin2 = process.platform === "win32";
|
|
44315
44321
|
const start = startArgv(argv);
|
|
44316
|
-
if (start === null) return
|
|
44322
|
+
if (start === null) return resolve10(NOT_STARTED);
|
|
44317
44323
|
let child;
|
|
44318
44324
|
try {
|
|
44319
44325
|
child = spawn2(start[0], start.slice(1), {
|
|
@@ -44327,7 +44333,7 @@ function runProcess(argv, o) {
|
|
|
44327
44333
|
windowsHide: true
|
|
44328
44334
|
});
|
|
44329
44335
|
} catch {
|
|
44330
|
-
return
|
|
44336
|
+
return resolve10(NOT_STARTED);
|
|
44331
44337
|
}
|
|
44332
44338
|
const stdoutChunks = [];
|
|
44333
44339
|
const stderrChunks = [];
|
|
@@ -44361,7 +44367,7 @@ function runProcess(argv, o) {
|
|
|
44361
44367
|
clearTimeout(drainTimer);
|
|
44362
44368
|
clearTimeout(stopTimer);
|
|
44363
44369
|
o.signal.removeEventListener("abort", onAbort);
|
|
44364
|
-
|
|
44370
|
+
resolve10({
|
|
44365
44371
|
stdout: Buffer.concat(stdoutChunks),
|
|
44366
44372
|
stderr: Buffer.concat(stderrChunks),
|
|
44367
44373
|
exitCode,
|
|
@@ -44808,12 +44814,16 @@ function answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4) {
|
|
|
44808
44814
|
}
|
|
44809
44815
|
async function handler(input, ctx) {
|
|
44810
44816
|
const sort = input.sort ?? "relevance";
|
|
44811
|
-
if (sort === "timeline" && input.offset !==
|
|
44817
|
+
if (sort === "timeline" && (input.offset ?? 0) !== 0) {
|
|
44812
44818
|
return invalid("offset", 'drop offset; page a timeline with "after"');
|
|
44813
44819
|
}
|
|
44814
|
-
if (sort === "relevance" && input.after !==
|
|
44820
|
+
if (sort === "relevance" && (input.after ?? 0) !== 0) {
|
|
44815
44821
|
return invalid("after", 'drop after, or pass sort:"timeline"');
|
|
44816
44822
|
}
|
|
44823
|
+
if (input.source !== void 0 && input.source.trim() === "") {
|
|
44824
|
+
const { source: _blank, ...rest } = input;
|
|
44825
|
+
input = rest;
|
|
44826
|
+
}
|
|
44817
44827
|
const scope = input.scope ?? "worktree";
|
|
44818
44828
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
44819
44829
|
try {
|
|
@@ -45787,6 +45797,7 @@ function readResult6(p) {
|
|
|
45787
45797
|
const text = p.content === void 0 ? "" : typeof p.content === "string" ? p.content : JSON.stringify(p.content);
|
|
45788
45798
|
const info = { isError: p.isError === true, bytes: Buffer.byteLength(text), text };
|
|
45789
45799
|
if (typeof p.exitCode === "number") info.exitCode = p.exitCode;
|
|
45800
|
+
if (p.keep === true) info.keep = true;
|
|
45790
45801
|
return info;
|
|
45791
45802
|
}
|
|
45792
45803
|
function decode11(raw) {
|
|
@@ -45863,6 +45874,11 @@ function decode12(raw) {
|
|
|
45863
45874
|
const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
|
|
45864
45875
|
if (event === void 0) throw new Error("opencode: unknown hook event " + String(p.type));
|
|
45865
45876
|
const ev = { event, agent: "opencode", sessionId: String(p.sessionID ?? ""), cwd: String(p.directory ?? "") };
|
|
45877
|
+
if (typeof p.agentID === "string" && p.agentID !== "") {
|
|
45878
|
+
ev.agentId = p.agentID;
|
|
45879
|
+
ev.agentType = p.agentID;
|
|
45880
|
+
}
|
|
45881
|
+
if (Array.isArray(p.agentTools)) ev.agentTools = p.agentTools.filter((t) => typeof t === "string");
|
|
45866
45882
|
if (event === "UserPromptSubmit" && typeof p.message === "string") ev.prompt = p.message;
|
|
45867
45883
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
45868
45884
|
const name = String(p.tool ?? "");
|
|
@@ -45883,7 +45899,7 @@ function encode12(ev, d, _extra) {
|
|
|
45883
45899
|
if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
|
|
45884
45900
|
return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
|
|
45885
45901
|
case "replace":
|
|
45886
|
-
return { stdout: "", exitCode: 0 };
|
|
45902
|
+
return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
|
|
45887
45903
|
}
|
|
45888
45904
|
}
|
|
45889
45905
|
|
|
@@ -46088,7 +46104,7 @@ var ADAPTERS = Object.freeze([
|
|
|
46088
46104
|
}
|
|
46089
46105
|
]);
|
|
46090
46106
|
var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
|
|
46091
|
-
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi"]);
|
|
46107
|
+
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
|
|
46092
46108
|
function hasReplace(row5) {
|
|
46093
46109
|
return REPLACE_ROWS.has(row5.id);
|
|
46094
46110
|
}
|
|
@@ -46120,7 +46136,7 @@ function ownBundleDir() {
|
|
|
46120
46136
|
|
|
46121
46137
|
// src/core/ops/doctor-config.ts
|
|
46122
46138
|
import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
46123
|
-
import { dirname as dirname7, join as join11 } from "node:path";
|
|
46139
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
|
|
46124
46140
|
|
|
46125
46141
|
// src/core/ops/host-text.ts
|
|
46126
46142
|
var BOM_CODE = 65279;
|
|
@@ -48806,7 +48822,7 @@ function flatCommands(events, prefix) {
|
|
|
48806
48822
|
return out;
|
|
48807
48823
|
}
|
|
48808
48824
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
48809
|
-
var isCodexScript = (cmd) =>
|
|
48825
|
+
var isCodexScript = (cmd) => V1_PATH_SEPS.some((sep3) => V1_CODEX_SCRIPT_NAMES.some((name) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3 + name)));
|
|
48810
48826
|
function dataDir(dir, reason, out) {
|
|
48811
48827
|
if (existsSync7(dir)) out.push(finding(dir, "", reason));
|
|
48812
48828
|
}
|
|
@@ -48854,8 +48870,7 @@ function scanCodex(agentHome, out) {
|
|
|
48854
48870
|
const config4 = readTomlValue(tomlFile);
|
|
48855
48871
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48856
48872
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48857
|
-
if (
|
|
48858
|
-
if (span2.path.length === 3 && span2.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48873
|
+
if (isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48859
48874
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48860
48875
|
}
|
|
48861
48876
|
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
@@ -49018,7 +49033,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
49018
49033
|
|
|
49019
49034
|
// src/core/ops/plugin-root.ts
|
|
49020
49035
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync7, realpathSync as realpathSync4 } from "node:fs";
|
|
49021
|
-
import { dirname as dirname6, isAbsolute, join as join10, sep as sep2 } from "node:path";
|
|
49036
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep2 } from "node:path";
|
|
49022
49037
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
49023
49038
|
function missing(agent, path8) {
|
|
49024
49039
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
@@ -49130,7 +49145,7 @@ function configEntryRoot(adapter, env) {
|
|
|
49130
49145
|
const value = parseHostConfig(adapter.id, file2, current.text, current.format);
|
|
49131
49146
|
const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
|
|
49132
49147
|
const script = Array.isArray(args) ? args[0] : void 0;
|
|
49133
|
-
if (typeof script !== "string" || !
|
|
49148
|
+
if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
|
|
49134
49149
|
return dirname6(script);
|
|
49135
49150
|
}
|
|
49136
49151
|
function candidate(adapter, env, worktree) {
|
|
@@ -49350,11 +49365,122 @@ function nativeMcpWrong(dir, row5) {
|
|
|
49350
49365
|
return true;
|
|
49351
49366
|
}
|
|
49352
49367
|
}
|
|
49368
|
+
function opencodeEntrySpec(entry) {
|
|
49369
|
+
return isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry) ? entry[0] : entry;
|
|
49370
|
+
}
|
|
49371
|
+
function isNativeOpencodeEntry(entry, key) {
|
|
49372
|
+
const spec = opencodeEntrySpec(entry);
|
|
49373
|
+
if (typeof spec !== "string") return false;
|
|
49374
|
+
return spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
49375
|
+
}
|
|
49353
49376
|
function isOwnOpencodeEntry(entry, key, own4) {
|
|
49354
|
-
const spec =
|
|
49377
|
+
const spec = opencodeEntrySpec(entry);
|
|
49355
49378
|
if (typeof spec !== "string") return false;
|
|
49356
|
-
|
|
49357
|
-
|
|
49379
|
+
return spec === OPENCODE_GIT_SPEC || own4.includes(spec) || isNativeOpencodeEntry(entry, key);
|
|
49380
|
+
}
|
|
49381
|
+
function stringLiterals(src) {
|
|
49382
|
+
const out = [];
|
|
49383
|
+
let i = 0;
|
|
49384
|
+
while (i < src.length) {
|
|
49385
|
+
const c = src[i];
|
|
49386
|
+
if (c === "/" && src[i + 1] === "/") {
|
|
49387
|
+
const n = src.indexOf("\n", i);
|
|
49388
|
+
i = n < 0 ? src.length : n;
|
|
49389
|
+
continue;
|
|
49390
|
+
}
|
|
49391
|
+
if (c === "/" && src[i + 1] === "*") {
|
|
49392
|
+
const n = src.indexOf("*/", i + 2);
|
|
49393
|
+
i = n < 0 ? src.length : n + 2;
|
|
49394
|
+
continue;
|
|
49395
|
+
}
|
|
49396
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
49397
|
+
let j = i + 1;
|
|
49398
|
+
let s = "";
|
|
49399
|
+
while (j < src.length && src[j] !== c) {
|
|
49400
|
+
if (src[j] === "\\") {
|
|
49401
|
+
s += src[j + 1] ?? "";
|
|
49402
|
+
j += 2;
|
|
49403
|
+
continue;
|
|
49404
|
+
}
|
|
49405
|
+
s += src[j];
|
|
49406
|
+
j++;
|
|
49407
|
+
}
|
|
49408
|
+
out.push(s);
|
|
49409
|
+
i = j + 1;
|
|
49410
|
+
continue;
|
|
49411
|
+
}
|
|
49412
|
+
i++;
|
|
49413
|
+
}
|
|
49414
|
+
return out;
|
|
49415
|
+
}
|
|
49416
|
+
var OPENCODE_PLUGINS_DIR = "plugins";
|
|
49417
|
+
var OPENCODE_PROJECT_DIR = ".opencode";
|
|
49418
|
+
var OPENCODE_PLUGIN_EXTS = [".js", ".mjs", ".ts"];
|
|
49419
|
+
var OPENCODE_PLUGIN_INDEX = "index";
|
|
49420
|
+
var OPENCODE_DIR_FILE_MAX = 64 * 1024;
|
|
49421
|
+
var OWN_PLUGIN_MODULES = [SERVER_KEY, `${SERVER_KEY}/server`];
|
|
49422
|
+
var FILE_URL_PREFIX = "file://";
|
|
49423
|
+
var NODE_MODULES_DIR = "node_modules";
|
|
49424
|
+
var PACKAGE_JSON_FILE = "package.json";
|
|
49425
|
+
var OPENCODE_PACKAGE_DIR_HINT = `${NODE_MODULES_DIR}/${SERVER_KEY}`;
|
|
49426
|
+
function opencodePluginDirs(configDir, worktree) {
|
|
49427
|
+
return [configDir, opencodeProjectDir(worktree)];
|
|
49428
|
+
}
|
|
49429
|
+
function opencodeProjectDir(worktree) {
|
|
49430
|
+
return join11(worktree, OPENCODE_PROJECT_DIR);
|
|
49431
|
+
}
|
|
49432
|
+
function packageResolves(fromDir) {
|
|
49433
|
+
for (let d = fromDir; ; d = dirname7(d)) {
|
|
49434
|
+
if (existsSync10(join11(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
|
|
49435
|
+
if (dirname7(d) === d) return false;
|
|
49436
|
+
}
|
|
49437
|
+
}
|
|
49438
|
+
function opencodeDirPlugins(dirs) {
|
|
49439
|
+
const bundle = opencodePluginFile();
|
|
49440
|
+
const ownFile = join11(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
|
|
49441
|
+
const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
|
|
49442
|
+
const isPath = (p) => {
|
|
49443
|
+
if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
|
|
49444
|
+
const seg = p.split("/");
|
|
49445
|
+
const n = seg.length;
|
|
49446
|
+
return n >= 3 && seg[n - 1] === "plugin.js" && seg[n - 2] === "opencode" && seg[n - 3] === SERVER_KEY;
|
|
49447
|
+
};
|
|
49448
|
+
const out = [];
|
|
49449
|
+
for (const dir of dirs) {
|
|
49450
|
+
const pdir = join11(dir, OPENCODE_PLUGINS_DIR);
|
|
49451
|
+
let names;
|
|
49452
|
+
try {
|
|
49453
|
+
names = readdirSync7(pdir);
|
|
49454
|
+
} catch {
|
|
49455
|
+
continue;
|
|
49456
|
+
}
|
|
49457
|
+
for (const name of names) {
|
|
49458
|
+
const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join11(pdir, name)] : [];
|
|
49459
|
+
const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join11(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
|
|
49460
|
+
for (const f of files) {
|
|
49461
|
+
let text;
|
|
49462
|
+
try {
|
|
49463
|
+
const b = readFileSync9(f);
|
|
49464
|
+
if (b.length > OPENCODE_DIR_FILE_MAX) continue;
|
|
49465
|
+
text = b.toString("utf8");
|
|
49466
|
+
} catch {
|
|
49467
|
+
continue;
|
|
49468
|
+
}
|
|
49469
|
+
const lits = stringLiterals(text).map((s) => s.split("\\").join("/")).filter((p) => isModule(p) || isPath(p));
|
|
49470
|
+
if (!lits.length) continue;
|
|
49471
|
+
const loads = lits.some((p) => {
|
|
49472
|
+
if (isModule(p)) return packageResolves(dirname7(f));
|
|
49473
|
+
const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
|
|
49474
|
+
return existsSync10(isAbsolute3(bare2) ? bare2 : resolve4(dirname7(f), bare2));
|
|
49475
|
+
});
|
|
49476
|
+
out.push({ file: f, loads });
|
|
49477
|
+
}
|
|
49478
|
+
}
|
|
49479
|
+
}
|
|
49480
|
+
return out;
|
|
49481
|
+
}
|
|
49482
|
+
function opencodeDirPlugin(dirs) {
|
|
49483
|
+
return opencodeDirPlugins(dirs).find((p) => p.loads)?.file;
|
|
49358
49484
|
}
|
|
49359
49485
|
function opencodeMcpOwn(entry) {
|
|
49360
49486
|
if (!isObject4(entry)) return false;
|
|
@@ -49375,7 +49501,8 @@ function opencodeValueListed(value) {
|
|
|
49375
49501
|
}
|
|
49376
49502
|
function opencodeListed(file2, worktree) {
|
|
49377
49503
|
const dirs = [dirname7(file2), worktree];
|
|
49378
|
-
|
|
49504
|
+
if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))))) return true;
|
|
49505
|
+
return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
|
|
49379
49506
|
}
|
|
49380
49507
|
function mcpWrong(row5, home, env, worktree) {
|
|
49381
49508
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
@@ -49598,7 +49725,7 @@ async function checkIndex(project) {
|
|
|
49598
49725
|
|
|
49599
49726
|
// src/core/ops/doctor-env.ts
|
|
49600
49727
|
import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
49601
|
-
import { isAbsolute as
|
|
49728
|
+
import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
|
|
49602
49729
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49603
49730
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49604
49731
|
}
|
|
@@ -49767,7 +49894,7 @@ function checkMcp(ctx, adapter) {
|
|
|
49767
49894
|
function piCwdInside(worktree, piCwd) {
|
|
49768
49895
|
if (piCwd === void 0 || !existsSync12(piCwd)) return false;
|
|
49769
49896
|
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49770
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
49897
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
|
|
49771
49898
|
}
|
|
49772
49899
|
function checkProject(i) {
|
|
49773
49900
|
const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
|
|
@@ -51551,7 +51678,7 @@ function hasType(v, t) {
|
|
|
51551
51678
|
function same(a, b) {
|
|
51552
51679
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
51553
51680
|
}
|
|
51554
|
-
function
|
|
51681
|
+
function resolve5(root, ref) {
|
|
51555
51682
|
const parts = ref.split("/");
|
|
51556
51683
|
if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
|
|
51557
51684
|
let at = root;
|
|
@@ -51564,7 +51691,7 @@ function shapeErrors(schema, value, root = schema, at = "$") {
|
|
|
51564
51691
|
if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at} is not read by the checker`);
|
|
51565
51692
|
}
|
|
51566
51693
|
const errs = [];
|
|
51567
|
-
if (typeof schema.$ref === "string") errs.push(...shapeErrors(
|
|
51694
|
+
if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve5(root, schema.$ref), value, root, at));
|
|
51568
51695
|
if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at));
|
|
51569
51696
|
if (schema.type !== void 0) {
|
|
51570
51697
|
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
@@ -51731,14 +51858,14 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
51731
51858
|
function askPluginHooks(env, pluginId, cwd) {
|
|
51732
51859
|
const bin = whichBin("codex", env);
|
|
51733
51860
|
if (!bin) return Promise.resolve({ kind: "absent" });
|
|
51734
|
-
return new Promise((
|
|
51861
|
+
return new Promise((resolve10) => {
|
|
51735
51862
|
let asked;
|
|
51736
51863
|
const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
|
|
51737
51864
|
let f;
|
|
51738
51865
|
try {
|
|
51739
51866
|
f = spawnForm(bin, ["app-server"], env);
|
|
51740
51867
|
} catch {
|
|
51741
|
-
|
|
51868
|
+
resolve10({ kind: "silent" });
|
|
51742
51869
|
return;
|
|
51743
51870
|
}
|
|
51744
51871
|
const child = spawn3(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
|
|
@@ -51748,7 +51875,7 @@ function askPluginHooks(env, pluginId, cwd) {
|
|
|
51748
51875
|
let result;
|
|
51749
51876
|
const settle3 = () => {
|
|
51750
51877
|
clearTimeout(grace);
|
|
51751
|
-
|
|
51878
|
+
resolve10(done_(result));
|
|
51752
51879
|
};
|
|
51753
51880
|
let grace;
|
|
51754
51881
|
const finish2 = (v) => {
|
|
@@ -52107,14 +52234,14 @@ async function checkHookRoundTrip(i) {
|
|
|
52107
52234
|
}
|
|
52108
52235
|
|
|
52109
52236
|
// src/core/hooks/fallback.ts
|
|
52110
|
-
import { join as join14, resolve as
|
|
52237
|
+
import { join as join14, resolve as resolve7 } from "node:path";
|
|
52111
52238
|
|
|
52112
52239
|
// src/core/policy/read-media.ts
|
|
52113
52240
|
import { extname } from "node:path";
|
|
52114
52241
|
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
52115
52242
|
|
|
52116
52243
|
// src/core/policy/own-file.ts
|
|
52117
|
-
import { extname as extname2, join as join13 } from "node:path";
|
|
52244
|
+
import { extname as extname2, join as join13, resolve as resolve6 } from "node:path";
|
|
52118
52245
|
|
|
52119
52246
|
// src/core/hooks/fallback.ts
|
|
52120
52247
|
var fs = process.getBuiltinModule("node:fs");
|
|
@@ -52690,7 +52817,7 @@ var ctxDoctor = Object.freeze({
|
|
|
52690
52817
|
// src/core/tools/execute.ts
|
|
52691
52818
|
import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
52692
52819
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
52693
|
-
import { dirname as dirname10, join as join18, parse as parse5, resolve as
|
|
52820
|
+
import { dirname as dirname10, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
|
|
52694
52821
|
|
|
52695
52822
|
// src/core/index/select.ts
|
|
52696
52823
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -52876,7 +53003,7 @@ async function handler3(raw, ctx) {
|
|
|
52876
53003
|
const cwd = ctx.project.worktree;
|
|
52877
53004
|
const extra = { ...PLAIN_OUTPUT_ENV2 };
|
|
52878
53005
|
if (input.file !== void 0) {
|
|
52879
|
-
const abs =
|
|
53006
|
+
const abs = resolve8(cwd, input.file);
|
|
52880
53007
|
const bad = fileError(input.file, abs, ctx.project.containmentRoot);
|
|
52881
53008
|
if (bad !== null) return fail4(bad);
|
|
52882
53009
|
extra.CTX_FILE = abs;
|
|
@@ -52931,7 +53058,7 @@ var ctxExecute = {
|
|
|
52931
53058
|
|
|
52932
53059
|
// src/core/tools/index.ts
|
|
52933
53060
|
import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
|
|
52934
|
-
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as
|
|
53061
|
+
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
|
|
52935
53062
|
|
|
52936
53063
|
// src/core/index/walk.ts
|
|
52937
53064
|
import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
@@ -53218,18 +53345,18 @@ function request(u, conn, proxy, signal) {
|
|
|
53218
53345
|
const host = bare(u.hostname);
|
|
53219
53346
|
const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
|
|
53220
53347
|
const path8 = u.pathname + u.search;
|
|
53221
|
-
return new Promise((
|
|
53348
|
+
return new Promise((resolve10, reject) => {
|
|
53222
53349
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
53223
53350
|
if (proxy === void 0) {
|
|
53224
53351
|
const mod = u.protocol === "https:" ? https : http;
|
|
53225
53352
|
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
53226
|
-
req.on("response",
|
|
53353
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53227
53354
|
return;
|
|
53228
53355
|
}
|
|
53229
53356
|
const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
|
|
53230
53357
|
if (u.protocol === "http:") {
|
|
53231
53358
|
const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
|
|
53232
|
-
req.on("response",
|
|
53359
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53233
53360
|
return;
|
|
53234
53361
|
}
|
|
53235
53362
|
const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
|
|
@@ -53249,16 +53376,16 @@ function request(u, conn, proxy, signal) {
|
|
|
53249
53376
|
headers: { host: u.host },
|
|
53250
53377
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
53251
53378
|
});
|
|
53252
|
-
req.on("response",
|
|
53379
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53253
53380
|
});
|
|
53254
53381
|
tunnel.end();
|
|
53255
53382
|
});
|
|
53256
53383
|
}
|
|
53257
53384
|
function readBody(res) {
|
|
53258
|
-
return new Promise((
|
|
53385
|
+
return new Promise((resolve10, reject) => {
|
|
53259
53386
|
const parts = [];
|
|
53260
53387
|
res.on("data", (b) => parts.push(b));
|
|
53261
|
-
res.on("end", () =>
|
|
53388
|
+
res.on("end", () => resolve10(Buffer.concat(parts)));
|
|
53262
53389
|
res.on("error", (err) => reject(fail5(causeCode(err))));
|
|
53263
53390
|
res.on("aborted", () => reject(fail5("ECONNRESET")));
|
|
53264
53391
|
});
|
|
@@ -57136,7 +57263,7 @@ function missingOrOutside(given, abs, root) {
|
|
|
57136
57263
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
57137
57264
|
}
|
|
57138
57265
|
function pathItems(input, project) {
|
|
57139
|
-
const abs =
|
|
57266
|
+
const abs = resolve9(project.worktree, input.path);
|
|
57140
57267
|
if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
|
|
57141
57268
|
const base = relative3(project.worktree, abs);
|
|
57142
57269
|
if (statSync7(abs).isDirectory()) {
|
|
@@ -57568,7 +57695,8 @@ function reply3(text, isError) {
|
|
|
57568
57695
|
return { text, isError, sandboxBytes: 0 };
|
|
57569
57696
|
}
|
|
57570
57697
|
async function handler6(input, ctx) {
|
|
57571
|
-
const
|
|
57698
|
+
const given = input.session !== void 0 && input.session.trim() !== "" ? input.session : void 0;
|
|
57699
|
+
const sessionId = given ?? ctx.sessionId;
|
|
57572
57700
|
if (sessionId === "") return reply3(RESUME_NO_SESSION_LINE, true);
|
|
57573
57701
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
57574
57702
|
try {
|
|
@@ -58468,12 +58596,12 @@ function sessionIdOf(meta3, agent, env, serverId) {
|
|
|
58468
58596
|
return RUN_SESSION_PREFIX + serverId;
|
|
58469
58597
|
}
|
|
58470
58598
|
var CODEX_SANDBOX_STATE_META = "codex/sandbox-state-meta";
|
|
58471
|
-
var
|
|
58599
|
+
var FILE_URL_PREFIX2 = "file:";
|
|
58472
58600
|
function workspaceFromMeta(meta3) {
|
|
58473
58601
|
const state = meta3?.[CODEX_SANDBOX_STATE_META];
|
|
58474
58602
|
const cwd = typeof state === "object" && state !== null ? state.sandboxCwd : void 0;
|
|
58475
58603
|
if (typeof cwd !== "string" || cwd === "") return void 0;
|
|
58476
|
-
if (!cwd.startsWith(
|
|
58604
|
+
if (!cwd.startsWith(FILE_URL_PREFIX2)) return cwd;
|
|
58477
58605
|
try {
|
|
58478
58606
|
return fileURLToPath3(cwd);
|
|
58479
58607
|
} catch {
|
|
@@ -58497,7 +58625,7 @@ async function workspaceFromRoots(server) {
|
|
|
58497
58625
|
try {
|
|
58498
58626
|
const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
|
|
58499
58627
|
for (const root of roots) {
|
|
58500
|
-
if (root.uri.startsWith(
|
|
58628
|
+
if (root.uri.startsWith(FILE_URL_PREFIX2)) return fileURLToPath3(root.uri);
|
|
58501
58629
|
}
|
|
58502
58630
|
} catch (err) {
|
|
58503
58631
|
console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
|
|
@@ -58664,7 +58792,7 @@ async function startServer(argv, env) {
|
|
|
58664
58792
|
}
|
|
58665
58793
|
installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
|
|
58666
58794
|
handle = serveStdio(createServer);
|
|
58667
|
-
await new Promise((
|
|
58795
|
+
await new Promise((resolve10) => process.once("exit", () => resolve10()));
|
|
58668
58796
|
}
|
|
58669
58797
|
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
58670
58798
|
const [, , ...cliArgs] = process.argv;
|