context-mode 2.0.0-next.18 → 2.0.0-next.20
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/SHA256SUMS +14 -14
- package/cli.mjs +18 -6
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +62 -62
- package/opencode/plugin.js +70 -10
- package/package.json +5 -1
- package/pi/index.js +13 -7
- package/qwen-extension.json +1 -1
- package/run.mjs +2 -1
- package/search.mjs +2 -1
- package/server.mjs +13 -7
package/opencode/plugin.js
CHANGED
|
@@ -362,7 +362,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
362
362
|
var DECISION_LABEL_JOIN = " | ";
|
|
363
363
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
364
364
|
var RELEASE_BRANCH = "release";
|
|
365
|
-
var BUNDLE_SHA = true ? "
|
|
365
|
+
var BUNDLE_SHA = true ? "efe519b1d2f8b002ada6ef542af2df61e2abc20f" : void 0;
|
|
366
366
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
367
367
|
var DOCTOR_LABEL = Object.freeze({
|
|
368
368
|
D1: "version",
|
|
@@ -1427,7 +1427,8 @@ var OPENCODE_EVENTS = {
|
|
|
1427
1427
|
"step-finish": "Usage"
|
|
1428
1428
|
};
|
|
1429
1429
|
var SHELL_TOOL_NAME = "bash";
|
|
1430
|
-
var
|
|
1430
|
+
var SHELL_TOOL_NAMES4 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1431
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES4.map((n) => [n, "Bash"])) };
|
|
1431
1432
|
function toCanonicalTool(name) {
|
|
1432
1433
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1433
1434
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -22826,7 +22827,7 @@ function ownMcpValue(agent, node, server2) {
|
|
|
22826
22827
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server2, AGENT_ARG, agent, ...tail] };
|
|
22827
22828
|
}
|
|
22828
22829
|
function opencodePluginFile() {
|
|
22829
|
-
return
|
|
22830
|
+
return dirname4(process.argv[1] ?? "");
|
|
22830
22831
|
}
|
|
22831
22832
|
function listTarget(key, own2, v1, alt = []) {
|
|
22832
22833
|
return {
|
|
@@ -23657,7 +23658,8 @@ function checkShell(env) {
|
|
|
23657
23658
|
// src/core/ops/doctor-hook.ts
|
|
23658
23659
|
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
|
|
23659
23660
|
import path4 from "node:path";
|
|
23660
|
-
var
|
|
23661
|
+
var D5_MIN_PAIRS = 3;
|
|
23662
|
+
var D5_MAX_PAIRS = 9;
|
|
23661
23663
|
var row = (status, detail, fixCommand) => fixCommand === void 0 ? { id: "D5", label: DOCTOR_LABEL.D5, status, detail } : { id: "D5", label: DOCTOR_LABEL.D5, status, detail, fixCommand };
|
|
23662
23664
|
function isObject5(v) {
|
|
23663
23665
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -23701,7 +23703,9 @@ async function checkHookRoundTrip(i) {
|
|
|
23701
23703
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
23702
23704
|
if (fixture === null) return row("UNKNOWN", D5_NO_FIXTURE_DETAIL(i.agent));
|
|
23703
23705
|
const now = i.now ?? (() => performance.now());
|
|
23704
|
-
const
|
|
23706
|
+
const fixed = i.samples === void 0 ? null : Math.max(1, i.samples);
|
|
23707
|
+
const maxPairs = fixed ?? D5_MAX_PAIRS;
|
|
23708
|
+
const minPairs = fixed ?? D5_MIN_PAIRS;
|
|
23705
23709
|
const bareMs = i.bareMs ?? (async () => {
|
|
23706
23710
|
const t = performance.now();
|
|
23707
23711
|
await runProcess([process.execPath, "-e", ""], { cwd: i.bundleDir, env: i.env, signal: i.signal, timeoutMs: HOOK_TIMEOUT_MS });
|
|
@@ -23709,7 +23713,8 @@ async function checkHookRoundTrip(i) {
|
|
|
23709
23713
|
});
|
|
23710
23714
|
const hookWalls = [];
|
|
23711
23715
|
const bareWalls = [];
|
|
23712
|
-
|
|
23716
|
+
let ms = 0;
|
|
23717
|
+
for (let n = 1; n <= maxPairs; n++) {
|
|
23713
23718
|
const start = now();
|
|
23714
23719
|
const r = await runProcess([process.execPath, path4.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
23715
23720
|
cwd: i.bundleDir,
|
|
@@ -23721,8 +23726,9 @@ async function checkHookRoundTrip(i) {
|
|
|
23721
23726
|
hookWalls.push(now() - start);
|
|
23722
23727
|
if (!isNativeShape(r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
|
|
23723
23728
|
bareWalls.push(await bareMs());
|
|
23729
|
+
ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
23730
|
+
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
23724
23731
|
}
|
|
23725
|
-
const ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
23726
23732
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
23727
23733
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
23728
23734
|
}
|
|
@@ -29219,7 +29225,7 @@ function checkCall(tool, input) {
|
|
|
29219
29225
|
// src/entries/opencode.ts
|
|
29220
29226
|
var AGENT = "opencode";
|
|
29221
29227
|
var id = PLUGIN_ID;
|
|
29222
|
-
async function
|
|
29228
|
+
async function setupLegacy(app) {
|
|
29223
29229
|
const cwd = app.directory;
|
|
29224
29230
|
const env = process.env;
|
|
29225
29231
|
const turns = /* @__PURE__ */ new Map();
|
|
@@ -29301,6 +29307,7 @@ async function setup(app) {
|
|
|
29301
29307
|
callID: input.callID,
|
|
29302
29308
|
args: input.args,
|
|
29303
29309
|
output: output.output,
|
|
29310
|
+
isError: output.isError,
|
|
29304
29311
|
turn: turnOf(sessionId)
|
|
29305
29312
|
});
|
|
29306
29313
|
},
|
|
@@ -29324,9 +29331,61 @@ async function setup(app) {
|
|
|
29324
29331
|
}
|
|
29325
29332
|
};
|
|
29326
29333
|
}
|
|
29334
|
+
function oc2Text(content) {
|
|
29335
|
+
if (typeof content === "string") return content;
|
|
29336
|
+
return (content ?? []).filter((c) => c.type === "text").map((c) => c.text ?? "").join("\n");
|
|
29337
|
+
}
|
|
29338
|
+
async function setup(ctx) {
|
|
29339
|
+
const tools = /* @__PURE__ */ new Map();
|
|
29340
|
+
const hooks = await setupLegacy({
|
|
29341
|
+
directory: ctx.location.directory,
|
|
29342
|
+
tool(name, def) {
|
|
29343
|
+
tools.set(name, {
|
|
29344
|
+
name,
|
|
29345
|
+
description: def.description,
|
|
29346
|
+
input: external_exports.toJSONSchema(def.args, { target: "draft-2020-12", io: "input" }),
|
|
29347
|
+
options: { codemode: false },
|
|
29348
|
+
// a ctx_* tool is listed to the model by name, not behind the host's code tool
|
|
29349
|
+
async execute(input, context) {
|
|
29350
|
+
return { content: await def.execute(input, { sessionID: context.sessionID, abort: context.signal }) };
|
|
29351
|
+
}
|
|
29352
|
+
});
|
|
29353
|
+
}
|
|
29354
|
+
});
|
|
29355
|
+
await ctx.tool.transform((editor) => {
|
|
29356
|
+
for (const t of tools.values()) editor.add(t);
|
|
29357
|
+
});
|
|
29358
|
+
await ctx.tool.hook("execute.before", async (i) => {
|
|
29359
|
+
await hooks["tool.execute.before"]({ tool: i.tool, sessionID: i.sessionID, callID: i.id }, { args: i.input });
|
|
29360
|
+
});
|
|
29361
|
+
await ctx.tool.hook("execute.after", async (i) => {
|
|
29362
|
+
const failed2 = i.status === "error";
|
|
29363
|
+
const output = failed2 ? i.error?.message ?? "" : oc2Text(i.result?.content);
|
|
29364
|
+
await hooks["tool.execute.after"]({ tool: i.tool, sessionID: i.sessionID, callID: i.id, args: i.input }, { output, isError: failed2 });
|
|
29365
|
+
});
|
|
29366
|
+
await ctx.session.hook("prompt", async (p) => {
|
|
29367
|
+
await hooks["chat.message"]({ sessionID: p.sessionID }, { parts: [{ type: "text", text: p.prompt?.text ?? "" }] });
|
|
29368
|
+
});
|
|
29369
|
+
await ctx.session.hook("context", async (c) => {
|
|
29370
|
+
const system = [];
|
|
29371
|
+
await hooks["experimental.chat.system.transform"]({ sessionID: c.sessionID }, { system });
|
|
29372
|
+
for (const text of system) if (!c.system.some((p) => p.text === text)) c.system.push({ type: "text", text });
|
|
29373
|
+
});
|
|
29374
|
+
await ctx.session.hook("compaction", async (c) => {
|
|
29375
|
+
await hooks["experimental.session.compacting"]({ sessionID: c.sessionID });
|
|
29376
|
+
});
|
|
29377
|
+
const stop = new AbortController();
|
|
29378
|
+
void (async () => {
|
|
29379
|
+
for await (const e of ctx.event.subscribe({ types: ["session.step.ended"], signal: stop.signal })) {
|
|
29380
|
+
await hooks.event({ event: { type: "message.part.updated", properties: { part: { type: "step-finish", sessionID: e.data?.sessionID } } } });
|
|
29381
|
+
}
|
|
29382
|
+
})().catch(() => {
|
|
29383
|
+
});
|
|
29384
|
+
return () => stop.abort();
|
|
29385
|
+
}
|
|
29327
29386
|
async function server(input, _options) {
|
|
29328
29387
|
const tool = {};
|
|
29329
|
-
const hooks = await
|
|
29388
|
+
const hooks = await setupLegacy({
|
|
29330
29389
|
directory: input.directory,
|
|
29331
29390
|
tool(name, def) {
|
|
29332
29391
|
const shape = def.args.shape;
|
|
@@ -29340,5 +29399,6 @@ export {
|
|
|
29340
29399
|
opencode_default as default,
|
|
29341
29400
|
id,
|
|
29342
29401
|
server,
|
|
29343
|
-
setup
|
|
29402
|
+
setup,
|
|
29403
|
+
setupLegacy
|
|
29344
29404
|
};
|
package/package.json
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"engines": {
|
|
10
10
|
"node": ">=24.15.0"
|
|
11
11
|
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./opencode/plugin.js",
|
|
14
|
+
"./server": "./opencode/plugin.js"
|
|
15
|
+
},
|
|
12
16
|
"files": [
|
|
13
17
|
".claude-plugin",
|
|
14
18
|
".codex-plugin",
|
|
@@ -63,5 +67,5 @@
|
|
|
63
67
|
"url": "git+https://github.com/mksglu/context-mode.git"
|
|
64
68
|
},
|
|
65
69
|
"type": "module",
|
|
66
|
-
"version": "2.0.0-next.
|
|
70
|
+
"version": "2.0.0-next.20"
|
|
67
71
|
}
|
package/pi/index.js
CHANGED
|
@@ -11508,7 +11508,7 @@ var DECISION_OPTION_KEY = "option";
|
|
|
11508
11508
|
var DECISION_LABEL_JOIN = " | ";
|
|
11509
11509
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
11510
11510
|
var RELEASE_BRANCH = "release";
|
|
11511
|
-
var BUNDLE_SHA = true ? "
|
|
11511
|
+
var BUNDLE_SHA = true ? "efe519b1d2f8b002ada6ef542af2df61e2abc20f" : void 0;
|
|
11512
11512
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
11513
11513
|
var DOCTOR_LABEL = Object.freeze({
|
|
11514
11514
|
D1: "version",
|
|
@@ -12573,7 +12573,8 @@ var OPENCODE_EVENTS = {
|
|
|
12573
12573
|
"step-finish": "Usage"
|
|
12574
12574
|
};
|
|
12575
12575
|
var SHELL_TOOL_NAME = "bash";
|
|
12576
|
-
var
|
|
12576
|
+
var SHELL_TOOL_NAMES4 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
12577
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES4.map((n) => [n, "Bash"])) };
|
|
12577
12578
|
function toCanonicalTool(name) {
|
|
12578
12579
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
12579
12580
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -22833,7 +22834,7 @@ function ownMcpValue(agent, node3, server) {
|
|
|
22833
22834
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
22834
22835
|
}
|
|
22835
22836
|
function opencodePluginFile() {
|
|
22836
|
-
return
|
|
22837
|
+
return dirname4(process.argv[1] ?? "");
|
|
22837
22838
|
}
|
|
22838
22839
|
function listTarget(key, own4, v1, alt = []) {
|
|
22839
22840
|
return {
|
|
@@ -23664,7 +23665,8 @@ function checkShell(env) {
|
|
|
23664
23665
|
// src/core/ops/doctor-hook.ts
|
|
23665
23666
|
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "node:fs";
|
|
23666
23667
|
import path4 from "node:path";
|
|
23667
|
-
var
|
|
23668
|
+
var D5_MIN_PAIRS = 3;
|
|
23669
|
+
var D5_MAX_PAIRS = 9;
|
|
23668
23670
|
var row = (status, detail, fixCommand) => fixCommand === void 0 ? { id: "D5", label: DOCTOR_LABEL.D5, status, detail } : { id: "D5", label: DOCTOR_LABEL.D5, status, detail, fixCommand };
|
|
23669
23671
|
function isObject5(v) {
|
|
23670
23672
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -23708,7 +23710,9 @@ async function checkHookRoundTrip(i) {
|
|
|
23708
23710
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
23709
23711
|
if (fixture === null) return row("UNKNOWN", D5_NO_FIXTURE_DETAIL(i.agent));
|
|
23710
23712
|
const now = i.now ?? (() => performance.now());
|
|
23711
|
-
const
|
|
23713
|
+
const fixed = i.samples === void 0 ? null : Math.max(1, i.samples);
|
|
23714
|
+
const maxPairs = fixed ?? D5_MAX_PAIRS;
|
|
23715
|
+
const minPairs = fixed ?? D5_MIN_PAIRS;
|
|
23712
23716
|
const bareMs = i.bareMs ?? (async () => {
|
|
23713
23717
|
const t = performance.now();
|
|
23714
23718
|
await runProcess([process.execPath, "-e", ""], { cwd: i.bundleDir, env: i.env, signal: i.signal, timeoutMs: HOOK_TIMEOUT_MS });
|
|
@@ -23716,7 +23720,8 @@ async function checkHookRoundTrip(i) {
|
|
|
23716
23720
|
});
|
|
23717
23721
|
const hookWalls = [];
|
|
23718
23722
|
const bareWalls = [];
|
|
23719
|
-
|
|
23723
|
+
let ms = 0;
|
|
23724
|
+
for (let n = 1; n <= maxPairs; n++) {
|
|
23720
23725
|
const start = now();
|
|
23721
23726
|
const r = await runProcess([process.execPath, path4.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
23722
23727
|
cwd: i.bundleDir,
|
|
@@ -23728,8 +23733,9 @@ async function checkHookRoundTrip(i) {
|
|
|
23728
23733
|
hookWalls.push(now() - start);
|
|
23729
23734
|
if (!isNativeShape(r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
|
|
23730
23735
|
bareWalls.push(await bareMs());
|
|
23736
|
+
ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
23737
|
+
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
23731
23738
|
}
|
|
23732
|
-
const ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
23733
23739
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
23734
23740
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
23735
23741
|
}
|
package/qwen-extension.json
CHANGED
package/run.mjs
CHANGED
|
@@ -1040,7 +1040,8 @@ var OPENCODE_EVENTS = {
|
|
|
1040
1040
|
"step-finish": "Usage"
|
|
1041
1041
|
};
|
|
1042
1042
|
var SHELL_TOOL_NAME = "bash";
|
|
1043
|
-
var
|
|
1043
|
+
var SHELL_TOOL_NAMES4 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1044
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES4.map((n) => [n, "Bash"])) };
|
|
1044
1045
|
function toCanonicalTool(name) {
|
|
1045
1046
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1046
1047
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
package/search.mjs
CHANGED
|
@@ -1040,7 +1040,8 @@ var OPENCODE_EVENTS = {
|
|
|
1040
1040
|
"step-finish": "Usage"
|
|
1041
1041
|
};
|
|
1042
1042
|
var SHELL_TOOL_NAME = "bash";
|
|
1043
|
-
var
|
|
1043
|
+
var SHELL_TOOL_NAMES4 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
1044
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES4.map((n) => [n, "Bash"])) };
|
|
1044
1045
|
function toCanonicalTool(name) {
|
|
1045
1046
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
1046
1047
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
package/server.mjs
CHANGED
|
@@ -28343,7 +28343,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28343
28343
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28344
28344
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28345
28345
|
var RELEASE_BRANCH = "release";
|
|
28346
|
-
var BUNDLE_SHA = true ? "
|
|
28346
|
+
var BUNDLE_SHA = true ? "efe519b1d2f8b002ada6ef542af2df61e2abc20f" : void 0;
|
|
28347
28347
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28348
28348
|
var DOCTOR_LABEL = Object.freeze({
|
|
28349
28349
|
D1: "version",
|
|
@@ -44917,7 +44917,8 @@ var OPENCODE_EVENTS = {
|
|
|
44917
44917
|
"step-finish": "Usage"
|
|
44918
44918
|
};
|
|
44919
44919
|
var SHELL_TOOL_NAME = "bash";
|
|
44920
|
-
var
|
|
44920
|
+
var SHELL_TOOL_NAMES4 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
44921
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES4.map((n) => [n, "Bash"])) };
|
|
44921
44922
|
function toCanonicalTool(name) {
|
|
44922
44923
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
44923
44924
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -47684,7 +47685,7 @@ function ownMcpValue(agent, node3, server) {
|
|
|
47684
47685
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
47685
47686
|
}
|
|
47686
47687
|
function opencodePluginFile() {
|
|
47687
|
-
return
|
|
47688
|
+
return dirname3(process.argv[1] ?? "");
|
|
47688
47689
|
}
|
|
47689
47690
|
function listTarget(key, own4, v1, alt = []) {
|
|
47690
47691
|
return {
|
|
@@ -48515,7 +48516,8 @@ function checkShell(env) {
|
|
|
48515
48516
|
// src/core/ops/doctor-hook.ts
|
|
48516
48517
|
import { existsSync as existsSync10, readFileSync as readFileSync7 } from "node:fs";
|
|
48517
48518
|
import path4 from "node:path";
|
|
48518
|
-
var
|
|
48519
|
+
var D5_MIN_PAIRS = 3;
|
|
48520
|
+
var D5_MAX_PAIRS = 9;
|
|
48519
48521
|
var row = (status, detail, fixCommand) => fixCommand === void 0 ? { id: "D5", label: DOCTOR_LABEL.D5, status, detail } : { id: "D5", label: DOCTOR_LABEL.D5, status, detail, fixCommand };
|
|
48520
48522
|
function isObject5(v) {
|
|
48521
48523
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -48559,7 +48561,9 @@ async function checkHookRoundTrip(i) {
|
|
|
48559
48561
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
48560
48562
|
if (fixture === null) return row("UNKNOWN", D5_NO_FIXTURE_DETAIL(i.agent));
|
|
48561
48563
|
const now = i.now ?? (() => performance.now());
|
|
48562
|
-
const
|
|
48564
|
+
const fixed = i.samples === void 0 ? null : Math.max(1, i.samples);
|
|
48565
|
+
const maxPairs = fixed ?? D5_MAX_PAIRS;
|
|
48566
|
+
const minPairs = fixed ?? D5_MIN_PAIRS;
|
|
48563
48567
|
const bareMs = i.bareMs ?? (async () => {
|
|
48564
48568
|
const t = performance.now();
|
|
48565
48569
|
await runProcess([process.execPath, "-e", ""], { cwd: i.bundleDir, env: i.env, signal: i.signal, timeoutMs: HOOK_TIMEOUT_MS });
|
|
@@ -48567,7 +48571,8 @@ async function checkHookRoundTrip(i) {
|
|
|
48567
48571
|
});
|
|
48568
48572
|
const hookWalls = [];
|
|
48569
48573
|
const bareWalls = [];
|
|
48570
|
-
|
|
48574
|
+
let ms = 0;
|
|
48575
|
+
for (let n = 1; n <= maxPairs; n++) {
|
|
48571
48576
|
const start = now();
|
|
48572
48577
|
const r = await runProcess([process.execPath, path4.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
48573
48578
|
cwd: i.bundleDir,
|
|
@@ -48579,8 +48584,9 @@ async function checkHookRoundTrip(i) {
|
|
|
48579
48584
|
hookWalls.push(now() - start);
|
|
48580
48585
|
if (!isNativeShape(r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
|
|
48581
48586
|
bareWalls.push(await bareMs());
|
|
48587
|
+
ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
48588
|
+
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
48582
48589
|
}
|
|
48583
|
-
const ms = Math.max(0, Math.round(Math.min(...hookWalls) - Math.min(...bareWalls)));
|
|
48584
48590
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
48585
48591
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
48586
48592
|
}
|