refactor(coding-agent/core): simplified Python gateway coordination by removing reference counting

- Simplified Python gateway coordination by removing reference counting and idle timeout functionality.
- Updated Python kernel initialization to support environment variable setup and working directory configuration.
- Modified interactive status display to show Python and venv paths instead of client counts.
- Updated system prompt to clarify CHECKPOINT step 0 timing after user request completion.
This commit is contained in:
can1357
2026-01-23 09:17:24 +01:00
parent 564df10b2c
commit d676150f9c
10 changed files with 122 additions and 348 deletions
@@ -182,6 +182,7 @@ describe("PythonKernel (external gateway)", () => {
});
globalThis.fetch = fetchMock as unknown as typeof fetch;
let initSeen = false;
let preludeSeen = false;
const kernelPromise = PythonKernel.start({ cwd: "/" });
@@ -191,6 +192,12 @@ describe("PythonKernel (external gateway)", () => {
ws.setSendHandler((data) => {
const msg = typeof data === "string" ? (JSON.parse(data) as JupyterMessage) : decodeMessage(data);
const code = String(msg.content.code ?? "");
if (!initSeen) {
// First execution is kernel environment init
initSeen = true;
sendOkExecution(ws, msg.header.msg_id);
return;
}
if (!preludeSeen) {
expect(code).toBe(PYTHON_PRELUDE);
preludeSeen = true;
@@ -307,6 +314,7 @@ describe("PythonKernel (external gateway)", () => {
});
globalThis.fetch = fetchMock as unknown as typeof fetch;
let initSeen = false;
let preludeSeen = false;
const kernelPromise = PythonKernel.start({ cwd: "/" });
@@ -316,6 +324,11 @@ describe("PythonKernel (external gateway)", () => {
ws.setSendHandler((data) => {
const msg = typeof data === "string" ? (JSON.parse(data) as JupyterMessage) : decodeMessage(data);
const code = String(msg.content.code ?? "");
if (!initSeen) {
initSeen = true;
sendOkExecution(ws, msg.header.msg_id);
return;
}
if (!preludeSeen) {
expect(code).toBe(PYTHON_PRELUDE);
preludeSeen = true;
@@ -343,6 +356,7 @@ describe("PythonKernel (external gateway)", () => {
});
globalThis.fetch = fetchMock as unknown as typeof fetch;
let initSeen = false;
let preludeSeen = false;
const kernelPromise = PythonKernel.start({ cwd: "/" });
@@ -352,6 +366,11 @@ describe("PythonKernel (external gateway)", () => {
ws.setSendHandler((data) => {
const msg = typeof data === "string" ? (JSON.parse(data) as JupyterMessage) : decodeMessage(data);
const code = String(msg.content.code ?? "");
if (!initSeen) {
initSeen = true;
sendOkExecution(ws, msg.header.msg_id);
return;
}
if (!preludeSeen) {
expect(code).toBe(PYTHON_PRELUDE);
preludeSeen = true;
@@ -383,6 +402,7 @@ describe("PythonKernel (external gateway)", () => {
];
const payload = JSON.stringify(docs);
let initSeen = false;
let preludeSeen = false;
const kernelPromise = PythonKernel.start({ cwd: "/" });
@@ -392,6 +412,11 @@ describe("PythonKernel (external gateway)", () => {
ws.setSendHandler((data) => {
const msg = typeof data === "string" ? (JSON.parse(data) as JupyterMessage) : decodeMessage(data);
const code = String(msg.content.code ?? "");
if (!initSeen) {
initSeen = true;
sendOkExecution(ws, msg.header.msg_id);
return;
}
if (!preludeSeen) {
expect(code).toBe(PYTHON_PRELUDE);
preludeSeen = true;