repoburg 1.3.321 → 1.3.323
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/agent-pane/backend/dist/index.js +518 -88
- package/agent-pane/backend/dist/server.js +518 -88
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.d.ts +6 -1
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js +31 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js.map +1 -1
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +22 -2
- package/backend/dist/src/ai-actions/ai-action-batch.service.d.ts +3 -1
- package/backend/dist/src/ai-actions/ai-action-batch.service.js +20 -6
- package/backend/dist/src/ai-actions/ai-action-batch.service.js.map +1 -1
- package/backend/dist/src/app.module.js +6 -0
- package/backend/dist/src/app.module.js.map +1 -1
- package/backend/dist/src/application-state/application-state.controller.d.ts +0 -6
- package/backend/dist/src/application-state/application-state.controller.js +0 -29
- package/backend/dist/src/application-state/application-state.controller.js.map +1 -1
- package/backend/dist/src/application-state/application-state.service.d.ts +1 -3
- package/backend/dist/src/application-state/application-state.service.js +8 -15
- package/backend/dist/src/application-state/application-state.service.js.map +1 -1
- package/backend/dist/src/background-tasks/background-tasks.controller.d.ts +9 -0
- package/backend/dist/src/background-tasks/background-tasks.controller.js +59 -0
- package/backend/dist/src/background-tasks/background-tasks.controller.js.map +1 -0
- package/backend/dist/src/background-tasks/background-tasks.module.d.ts +2 -0
- package/backend/dist/src/background-tasks/background-tasks.module.js +32 -0
- package/backend/dist/src/background-tasks/background-tasks.module.js.map +1 -0
- package/backend/dist/src/background-tasks/background-tasks.service.d.ts +62 -0
- package/backend/dist/src/background-tasks/background-tasks.service.js +415 -0
- package/backend/dist/src/background-tasks/background-tasks.service.js.map +1 -0
- package/backend/dist/src/command-hooks/command-hooks.module.d.ts +2 -0
- package/backend/dist/src/command-hooks/command-hooks.module.js +24 -0
- package/backend/dist/src/command-hooks/command-hooks.module.js.map +1 -0
- package/backend/dist/src/command-hooks/command-hooks.service.d.ts +39 -0
- package/backend/dist/src/command-hooks/command-hooks.service.js +367 -0
- package/backend/dist/src/command-hooks/command-hooks.service.js.map +1 -0
- package/backend/dist/src/context-generation/context-generation.service.d.ts +3 -0
- package/backend/dist/src/context-generation/context-generation.service.js +7 -1
- package/backend/dist/src/context-generation/context-generation.service.js.map +1 -1
- package/backend/dist/src/core-entities/session.entity.d.ts +1 -0
- package/backend/dist/src/core-entities/session.entity.js +7 -0
- package/backend/dist/src/core-entities/session.entity.js.map +1 -1
- package/backend/dist/src/file-read-registry/file-read-registry.module.d.ts +2 -0
- package/backend/dist/src/file-read-registry/file-read-registry.module.js +26 -0
- package/backend/dist/src/file-read-registry/file-read-registry.module.js.map +1 -0
- package/backend/dist/src/file-read-registry/file-read-registry.service.d.ts +28 -0
- package/backend/dist/src/file-read-registry/file-read-registry.service.js +199 -0
- package/backend/dist/src/file-read-registry/file-read-registry.service.js.map +1 -0
- package/backend/dist/src/global-config/dto/update-global-config.dto.d.ts +1 -1
- package/backend/dist/src/global-config/dto/update-global-config.dto.js +7 -5
- package/backend/dist/src/global-config/dto/update-global-config.dto.js.map +1 -1
- package/backend/dist/src/global-config/global-config.service.d.ts +1 -1
- package/backend/dist/src/global-config/global-config.service.js.map +1 -1
- package/backend/dist/src/interactive-chat/auto-compact.service.d.ts +3 -1
- package/backend/dist/src/interactive-chat/auto-compact.service.js +8 -2
- package/backend/dist/src/interactive-chat/auto-compact.service.js.map +1 -1
- package/backend/dist/src/interactive-chat/chat.service.d.ts +7 -1
- package/backend/dist/src/interactive-chat/chat.service.js +82 -2
- package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/action-handler.interface.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.d.ts +2 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js +10 -0
- package/backend/dist/src/llm-orchestration/action-handlers/dto/run-command.args.dto.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp-resources.handler.d.ts +11 -0
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp-resources.handler.js +100 -0
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp-resources.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp.handler.d.ts +4 -2
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp.handler.js +15 -4
- package/backend/dist/src/llm-orchestration/action-handlers/list-mcp.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/list-tools.handler.d.ts +4 -2
- package/backend/dist/src/llm-orchestration/action-handlers/list-tools.handler.js +15 -4
- package/backend/dist/src/llm-orchestration/action-handlers/list-tools.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/load-tool.handler.d.ts +3 -1
- package/backend/dist/src/llm-orchestration/action-handlers/load-tool.handler.js +11 -3
- package/backend/dist/src/llm-orchestration/action-handlers/load-tool.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/mcp-tool-action.handler.d.ts +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/mcp-tool-action.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/read-mcp-resource.handler.d.ts +11 -0
- package/backend/dist/src/llm-orchestration/action-handlers/read-mcp-resource.handler.js +94 -0
- package/backend/dist/src/llm-orchestration/action-handlers/read-mcp-resource.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.d.ts +18 -1
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js +266 -25
- package/backend/dist/src/llm-orchestration/action-handlers/request-context.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.d.ts +4 -1
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js +79 -2
- package/backend/dist/src/llm-orchestration/action-handlers/run-command.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/task-output.handler.d.ts +16 -0
- package/backend/dist/src/llm-orchestration/action-handlers/task-output.handler.js +135 -0
- package/backend/dist/src/llm-orchestration/action-handlers/task-output.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/task-stop.handler.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/action-handlers/task-stop.handler.js +78 -0
- package/backend/dist/src/llm-orchestration/action-handlers/task-stop.handler.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/utils/local-web-fetch.d.ts +28 -0
- package/backend/dist/src/llm-orchestration/action-handlers/utils/local-web-fetch.js +208 -0
- package/backend/dist/src/llm-orchestration/action-handlers/utils/local-web-fetch.js.map +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/web-fetch.handler.d.ts +2 -0
- package/backend/dist/src/llm-orchestration/action-handlers/web-fetch.handler.js +85 -60
- package/backend/dist/src/llm-orchestration/action-handlers/web-fetch.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/web-search.handler.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/action-handlers/web-search.handler.js +3 -0
- package/backend/dist/src/llm-orchestration/action-handlers/web-search.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js +13 -5
- package/backend/dist/src/llm-orchestration/hooks/frontend-notification.hook.js.map +1 -1
- package/backend/dist/src/llm-orchestration/hooks/invalid-tool-feedback.hook.js +2 -0
- package/backend/dist/src/llm-orchestration/hooks/invalid-tool-feedback.hook.js.map +1 -1
- package/backend/dist/src/llm-orchestration/hooks/max-turns-post-execution.hook.d.ts +12 -0
- package/backend/dist/src/llm-orchestration/hooks/max-turns-post-execution.hook.js +52 -0
- package/backend/dist/src/llm-orchestration/hooks/max-turns-post-execution.hook.js.map +1 -0
- package/backend/dist/src/llm-orchestration/hooks/stop-command-hooks.post-execution.hook.d.ts +16 -0
- package/backend/dist/src/llm-orchestration/hooks/stop-command-hooks.post-execution.hook.js +79 -0
- package/backend/dist/src/llm-orchestration/hooks/stop-command-hooks.post-execution.hook.js.map +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +49 -88
- package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.d.ts +9 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +143 -5
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/tool-schema.service.d.ts +6 -1
- package/backend/dist/src/llm-orchestration/tool-schema.service.js +47 -8
- package/backend/dist/src/llm-orchestration/tool-schema.service.js.map +1 -1
- package/backend/dist/src/mcp/mcp.module.js +8 -4
- package/backend/dist/src/mcp/mcp.module.js.map +1 -1
- package/backend/dist/src/mcp/mcp.service.d.ts +3 -0
- package/backend/dist/src/mcp/mcp.service.js +9 -0
- package/backend/dist/src/mcp/mcp.service.js.map +1 -1
- package/backend/dist/src/mcp/session-mcp.controller.d.ts +11 -0
- package/backend/dist/src/mcp/session-mcp.controller.js +54 -0
- package/backend/dist/src/mcp/session-mcp.controller.js.map +1 -0
- package/backend/dist/src/mcp/session-mcp.service.d.ts +67 -0
- package/backend/dist/src/mcp/session-mcp.service.js +421 -0
- package/backend/dist/src/mcp/session-mcp.service.js.map +1 -0
- package/backend/dist/src/seeding/data/sub-agents/control-repoburg.js +4 -0
- package/backend/dist/src/seeding/data/sub-agents/control-repoburg.js.map +1 -1
- package/backend/dist/src/seeding/data/sub-agents/explore-codebase.js +4 -0
- package/backend/dist/src/seeding/data/sub-agents/explore-codebase.js.map +1 -1
- package/backend/dist/src/seeding/data/sub-agents/general-purpose.js +4 -0
- package/backend/dist/src/seeding/data/sub-agents/general-purpose.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/control-repoburg-agent.js +4 -0
- package/backend/dist/src/seeding/data/system-prompts/control-repoburg-agent.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.js +8 -0
- package/backend/dist/src/seeding/data/system-prompts/default_native_tool_agent.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/explore-codebase-agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/explore-codebase-agent.js +5 -1
- package/backend/dist/src/seeding/data/system-prompts/explore-codebase-agent.js.map +1 -1
- package/backend/dist/src/seeding/data/system-prompts/general-purpose-agent.d.ts +1 -1
- package/backend/dist/src/seeding/data/system-prompts/general-purpose-agent.js +7 -2
- package/backend/dist/src/seeding/data/system-prompts/general-purpose-agent.js.map +1 -1
- package/backend/dist/src/session-cancellation/session-cancellation.service.d.ts +5 -0
- package/backend/dist/src/session-cancellation/session-cancellation.service.js +20 -0
- package/backend/dist/src/session-cancellation/session-cancellation.service.js.map +1 -1
- package/backend/dist/src/session-event-logs/session-event-logs.service.d.ts +1 -0
- package/backend/dist/src/session-event-logs/session-event-logs.service.js +4 -0
- package/backend/dist/src/session-event-logs/session-event-logs.service.js.map +1 -1
- package/backend/dist/src/session-inputs/dto/session-input.dto.d.ts +1 -0
- package/backend/dist/src/session-inputs/dto/session-input.dto.js +10 -0
- package/backend/dist/src/session-inputs/dto/session-input.dto.js.map +1 -1
- package/backend/dist/src/session-inputs/session-input-context.service.d.ts +5 -2
- package/backend/dist/src/session-inputs/session-input-context.service.js +20 -4
- package/backend/dist/src/session-inputs/session-input-context.service.js.map +1 -1
- package/backend/dist/src/session-inputs/session-inputs.controller.js +3 -1
- package/backend/dist/src/session-inputs/session-inputs.controller.js.map +1 -1
- package/backend/dist/src/session-inputs/session-inputs.service.d.ts +8 -2
- package/backend/dist/src/session-inputs/session-inputs.service.js +43 -8
- package/backend/dist/src/session-inputs/session-inputs.service.js.map +1 -1
- package/backend/dist/src/sessions/sessions.controller.d.ts +2 -2
- package/backend/dist/src/sessions/sessions.controller.js.map +1 -1
- package/backend/dist/src/sessions/sessions.service.d.ts +4 -1
- package/backend/dist/src/sessions/sessions.service.js +5 -1
- package/backend/dist/src/sessions/sessions.service.js.map +1 -1
- package/backend/dist/src/slash-commands/slash-commands.controller.d.ts +1 -1
- package/backend/dist/src/slash-commands/slash-commands.controller.js +7 -3
- package/backend/dist/src/slash-commands/slash-commands.controller.js.map +1 -1
- package/backend/dist/src/slash-commands/slash-commands.module.js +2 -0
- package/backend/dist/src/slash-commands/slash-commands.module.js.map +1 -1
- package/backend/dist/src/slash-commands/slash-commands.service.d.ts +12 -4
- package/backend/dist/src/slash-commands/slash-commands.service.js +279 -65
- package/backend/dist/src/slash-commands/slash-commands.service.js.map +1 -1
- package/backend/dist/src/system-prompts/system-prompts.service.js +4 -0
- package/backend/dist/src/system-prompts/system-prompts.service.js.map +1 -1
- package/backend/dist/src/utils/pdf-text.d.ts +16 -0
- package/backend/dist/src/utils/pdf-text.js +27 -0
- package/backend/dist/src/utils/pdf-text.js.map +1 -0
- package/backend/dist/src/utils/tool-images.d.ts +10 -0
- package/backend/dist/src/utils/tool-images.js +55 -0
- package/backend/dist/src/utils/tool-images.js.map +1 -0
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/backend/package.json +1 -0
- package/package.json +3 -1
- package/tabtape/extension/dist/build-info.json +3 -3
- package/tabtape/extension/dist/manifest.json +1 -1
- package/tabtape/ui/dist/build-info.json +3 -3
- package/backend/dist/src/application-state/dto/set-websocket-enabled.dto.d.ts +0 -3
- package/backend/dist/src/application-state/dto/set-websocket-enabled.dto.js +0 -23
- package/backend/dist/src/application-state/dto/set-websocket-enabled.dto.js.map +0 -1
|
@@ -7854,7 +7854,7 @@ var require_thread_stream = __commonJS({
|
|
|
7854
7854
|
var { version: version2 } = require_package();
|
|
7855
7855
|
var { EventEmitter: EventEmitter5 } = __require("events");
|
|
7856
7856
|
var { Worker } = __require("worker_threads");
|
|
7857
|
-
var { join:
|
|
7857
|
+
var { join: join7 } = __require("path");
|
|
7858
7858
|
var { pathToFileURL } = __require("url");
|
|
7859
7859
|
var { wait } = require_wait();
|
|
7860
7860
|
var {
|
|
@@ -7905,7 +7905,7 @@ var require_thread_stream = __commonJS({
|
|
|
7905
7905
|
function createWorker(stream, opts) {
|
|
7906
7906
|
const { filename, workerData } = opts;
|
|
7907
7907
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
7908
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
7908
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join7(__dirname, "lib", "worker.js");
|
|
7909
7909
|
const worker = new Worker(toExecute, {
|
|
7910
7910
|
...opts.workerOpts,
|
|
7911
7911
|
name: opts.workerOpts?.name || "thread-stream",
|
|
@@ -8373,7 +8373,7 @@ var require_transport = __commonJS({
|
|
|
8373
8373
|
var { createRequire } = __require("module");
|
|
8374
8374
|
var { existsSync: existsSync3 } = __require("node:fs");
|
|
8375
8375
|
var getCallers = require_caller();
|
|
8376
|
-
var { join:
|
|
8376
|
+
var { join: join7, isAbsolute: isAbsolute2, sep } = __require("node:path");
|
|
8377
8377
|
var { fileURLToPath: fileURLToPath6 } = __require("node:url");
|
|
8378
8378
|
var sleep2 = require_atomic_sleep();
|
|
8379
8379
|
var onExit = require_on_exit_leak_free();
|
|
@@ -8445,7 +8445,7 @@ var require_transport = __commonJS({
|
|
|
8445
8445
|
return false;
|
|
8446
8446
|
}
|
|
8447
8447
|
}
|
|
8448
|
-
return
|
|
8448
|
+
return isAbsolute2(path21) && !existsSync3(path21);
|
|
8449
8449
|
}
|
|
8450
8450
|
function stripQuotes(value) {
|
|
8451
8451
|
const first = value[0];
|
|
@@ -8526,7 +8526,7 @@ var require_transport = __commonJS({
|
|
|
8526
8526
|
throw new Error("only one of target or targets can be specified");
|
|
8527
8527
|
}
|
|
8528
8528
|
if (targets) {
|
|
8529
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
8529
|
+
target = bundlerOverrides["pino-worker"] || join7(__dirname, "worker.js");
|
|
8530
8530
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
8531
8531
|
return {
|
|
8532
8532
|
...dest,
|
|
@@ -8544,7 +8544,7 @@ var require_transport = __commonJS({
|
|
|
8544
8544
|
});
|
|
8545
8545
|
});
|
|
8546
8546
|
} else if (pipeline) {
|
|
8547
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
8547
|
+
target = bundlerOverrides["pino-worker"] || join7(__dirname, "worker.js");
|
|
8548
8548
|
options.pipelines = [pipeline.map((dest) => {
|
|
8549
8549
|
return {
|
|
8550
8550
|
...dest,
|
|
@@ -8563,11 +8563,11 @@ var require_transport = __commonJS({
|
|
|
8563
8563
|
return buildStream(fixTarget(target), options, worker, sync, name);
|
|
8564
8564
|
function fixTarget(origin) {
|
|
8565
8565
|
origin = bundlerOverrides[origin] || origin;
|
|
8566
|
-
if (
|
|
8566
|
+
if (isAbsolute2(origin) || origin.indexOf("file://") === 0) {
|
|
8567
8567
|
return origin;
|
|
8568
8568
|
}
|
|
8569
8569
|
if (origin === "pino/file") {
|
|
8570
|
-
return
|
|
8570
|
+
return join7(__dirname, "..", "file.js");
|
|
8571
8571
|
}
|
|
8572
8572
|
let fixTarget2;
|
|
8573
8573
|
for (const filePath of callers) {
|
|
@@ -9547,7 +9547,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
9547
9547
|
return circularValue;
|
|
9548
9548
|
}
|
|
9549
9549
|
let res = "";
|
|
9550
|
-
let
|
|
9550
|
+
let join7 = ",";
|
|
9551
9551
|
const originalIndentation = indentation;
|
|
9552
9552
|
if (Array.isArray(value)) {
|
|
9553
9553
|
if (value.length === 0) {
|
|
@@ -9561,7 +9561,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
9561
9561
|
indentation += spacer;
|
|
9562
9562
|
res += `
|
|
9563
9563
|
${indentation}`;
|
|
9564
|
-
|
|
9564
|
+
join7 = `,
|
|
9565
9565
|
${indentation}`;
|
|
9566
9566
|
}
|
|
9567
9567
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -9569,13 +9569,13 @@ ${indentation}`;
|
|
|
9569
9569
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9570
9570
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
9571
9571
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
9572
|
-
res +=
|
|
9572
|
+
res += join7;
|
|
9573
9573
|
}
|
|
9574
9574
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
9575
9575
|
res += tmp !== void 0 ? tmp : "null";
|
|
9576
9576
|
if (value.length - 1 > maximumBreadth) {
|
|
9577
9577
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9578
|
-
res += `${
|
|
9578
|
+
res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9579
9579
|
}
|
|
9580
9580
|
if (spacer !== "") {
|
|
9581
9581
|
res += `
|
|
@@ -9596,7 +9596,7 @@ ${originalIndentation}`;
|
|
|
9596
9596
|
let separator = "";
|
|
9597
9597
|
if (spacer !== "") {
|
|
9598
9598
|
indentation += spacer;
|
|
9599
|
-
|
|
9599
|
+
join7 = `,
|
|
9600
9600
|
${indentation}`;
|
|
9601
9601
|
whitespace = " ";
|
|
9602
9602
|
}
|
|
@@ -9610,13 +9610,13 @@ ${indentation}`;
|
|
|
9610
9610
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
9611
9611
|
if (tmp !== void 0) {
|
|
9612
9612
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
9613
|
-
separator =
|
|
9613
|
+
separator = join7;
|
|
9614
9614
|
}
|
|
9615
9615
|
}
|
|
9616
9616
|
if (keyLength > maximumBreadth) {
|
|
9617
9617
|
const removedKeys = keyLength - maximumBreadth;
|
|
9618
9618
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
9619
|
-
separator =
|
|
9619
|
+
separator = join7;
|
|
9620
9620
|
}
|
|
9621
9621
|
if (spacer !== "" && separator.length > 1) {
|
|
9622
9622
|
res = `
|
|
@@ -9657,7 +9657,7 @@ ${originalIndentation}`;
|
|
|
9657
9657
|
}
|
|
9658
9658
|
const originalIndentation = indentation;
|
|
9659
9659
|
let res = "";
|
|
9660
|
-
let
|
|
9660
|
+
let join7 = ",";
|
|
9661
9661
|
if (Array.isArray(value)) {
|
|
9662
9662
|
if (value.length === 0) {
|
|
9663
9663
|
return "[]";
|
|
@@ -9670,7 +9670,7 @@ ${originalIndentation}`;
|
|
|
9670
9670
|
indentation += spacer;
|
|
9671
9671
|
res += `
|
|
9672
9672
|
${indentation}`;
|
|
9673
|
-
|
|
9673
|
+
join7 = `,
|
|
9674
9674
|
${indentation}`;
|
|
9675
9675
|
}
|
|
9676
9676
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -9678,13 +9678,13 @@ ${indentation}`;
|
|
|
9678
9678
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9679
9679
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
9680
9680
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
9681
|
-
res +=
|
|
9681
|
+
res += join7;
|
|
9682
9682
|
}
|
|
9683
9683
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
9684
9684
|
res += tmp !== void 0 ? tmp : "null";
|
|
9685
9685
|
if (value.length - 1 > maximumBreadth) {
|
|
9686
9686
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9687
|
-
res += `${
|
|
9687
|
+
res += `${join7}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9688
9688
|
}
|
|
9689
9689
|
if (spacer !== "") {
|
|
9690
9690
|
res += `
|
|
@@ -9697,7 +9697,7 @@ ${originalIndentation}`;
|
|
|
9697
9697
|
let whitespace = "";
|
|
9698
9698
|
if (spacer !== "") {
|
|
9699
9699
|
indentation += spacer;
|
|
9700
|
-
|
|
9700
|
+
join7 = `,
|
|
9701
9701
|
${indentation}`;
|
|
9702
9702
|
whitespace = " ";
|
|
9703
9703
|
}
|
|
@@ -9706,7 +9706,7 @@ ${indentation}`;
|
|
|
9706
9706
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
9707
9707
|
if (tmp !== void 0) {
|
|
9708
9708
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
9709
|
-
separator =
|
|
9709
|
+
separator = join7;
|
|
9710
9710
|
}
|
|
9711
9711
|
}
|
|
9712
9712
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -9764,20 +9764,20 @@ ${originalIndentation}`;
|
|
|
9764
9764
|
indentation += spacer;
|
|
9765
9765
|
let res2 = `
|
|
9766
9766
|
${indentation}`;
|
|
9767
|
-
const
|
|
9767
|
+
const join8 = `,
|
|
9768
9768
|
${indentation}`;
|
|
9769
9769
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
9770
9770
|
let i = 0;
|
|
9771
9771
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
9772
9772
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
9773
9773
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
9774
|
-
res2 +=
|
|
9774
|
+
res2 += join8;
|
|
9775
9775
|
}
|
|
9776
9776
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
9777
9777
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
9778
9778
|
if (value.length - 1 > maximumBreadth) {
|
|
9779
9779
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
9780
|
-
res2 += `${
|
|
9780
|
+
res2 += `${join8}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
9781
9781
|
}
|
|
9782
9782
|
res2 += `
|
|
9783
9783
|
${originalIndentation}`;
|
|
@@ -9793,16 +9793,16 @@ ${originalIndentation}`;
|
|
|
9793
9793
|
return '"[Object]"';
|
|
9794
9794
|
}
|
|
9795
9795
|
indentation += spacer;
|
|
9796
|
-
const
|
|
9796
|
+
const join7 = `,
|
|
9797
9797
|
${indentation}`;
|
|
9798
9798
|
let res = "";
|
|
9799
9799
|
let separator = "";
|
|
9800
9800
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
9801
9801
|
if (isTypedArrayWithEntries(value)) {
|
|
9802
|
-
res += stringifyTypedArray(value,
|
|
9802
|
+
res += stringifyTypedArray(value, join7, maximumBreadth);
|
|
9803
9803
|
keys = keys.slice(value.length);
|
|
9804
9804
|
maximumPropertiesToStringify -= value.length;
|
|
9805
|
-
separator =
|
|
9805
|
+
separator = join7;
|
|
9806
9806
|
}
|
|
9807
9807
|
if (deterministic) {
|
|
9808
9808
|
keys = sort(keys, comparator);
|
|
@@ -9813,13 +9813,13 @@ ${indentation}`;
|
|
|
9813
9813
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
9814
9814
|
if (tmp !== void 0) {
|
|
9815
9815
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
9816
|
-
separator =
|
|
9816
|
+
separator = join7;
|
|
9817
9817
|
}
|
|
9818
9818
|
}
|
|
9819
9819
|
if (keyLength > maximumBreadth) {
|
|
9820
9820
|
const removedKeys = keyLength - maximumBreadth;
|
|
9821
9821
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
9822
|
-
separator =
|
|
9822
|
+
separator = join7;
|
|
9823
9823
|
}
|
|
9824
9824
|
if (separator !== "") {
|
|
9825
9825
|
res = `
|
|
@@ -41941,8 +41941,8 @@ function forkPoint(db2, sessionId, target) {
|
|
|
41941
41941
|
return row?.external_turn_id ?? null;
|
|
41942
41942
|
}
|
|
41943
41943
|
function snapshotTurnIds(db2, sessionId) {
|
|
41944
|
-
const rows = db2.prepare("SELECT id, external_turn_id FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41945
|
-
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, r.external_turn_id])));
|
|
41944
|
+
const rows = db2.prepare("SELECT id, external_turn_id, runtime_input_ids FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41945
|
+
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, [r.external_turn_id, r.runtime_input_ids]])));
|
|
41946
41946
|
}
|
|
41947
41947
|
function restoreTurnIds(db2, sessionId, snapshot) {
|
|
41948
41948
|
if (!snapshot) return;
|
|
@@ -41952,19 +41952,40 @@ function restoreTurnIds(db2, sessionId, snapshot) {
|
|
|
41952
41952
|
} catch {
|
|
41953
41953
|
return;
|
|
41954
41954
|
}
|
|
41955
|
-
const
|
|
41956
|
-
|
|
41955
|
+
const updateExternal = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ? AND session_id = ?");
|
|
41956
|
+
const updateBoth = db2.prepare(
|
|
41957
|
+
"UPDATE turns SET external_turn_id = ?, runtime_input_ids = ? WHERE id = ? AND session_id = ?"
|
|
41958
|
+
);
|
|
41959
|
+
for (const [turnId, value] of Object.entries(ids)) {
|
|
41960
|
+
if (Array.isArray(value)) updateBoth.run(value[0] ?? null, value[1] ?? null, turnId, sessionId);
|
|
41961
|
+
else updateExternal.run(value, turnId, sessionId);
|
|
41962
|
+
}
|
|
41963
|
+
}
|
|
41964
|
+
function forkedRuntimeInputIds(raw, map2) {
|
|
41965
|
+
if (!raw) return raw;
|
|
41966
|
+
let ids;
|
|
41967
|
+
try {
|
|
41968
|
+
ids = JSON.parse(raw);
|
|
41969
|
+
} catch {
|
|
41970
|
+
return raw;
|
|
41971
|
+
}
|
|
41972
|
+
if (!Array.isArray(ids)) return raw;
|
|
41973
|
+
return JSON.stringify(ids.map((id) => typeof id === "string" ? map2.get(id) ?? id : id));
|
|
41957
41974
|
}
|
|
41958
41975
|
function applyTurnIdMap(db2, sessionId, map2, upToCreatedAt = null) {
|
|
41959
41976
|
if (map2.size === 0) return;
|
|
41960
41977
|
const rows = db2.prepare(
|
|
41961
|
-
`SELECT id, external_turn_id FROM turns
|
|
41962
|
-
WHERE session_id = ? AND thread_id IS NULL
|
|
41978
|
+
`SELECT id, external_turn_id, runtime_input_ids FROM turns
|
|
41979
|
+
WHERE session_id = ? AND thread_id IS NULL
|
|
41980
|
+
AND (external_turn_id IS NOT NULL OR runtime_input_ids IS NOT NULL)` + (upToCreatedAt ? " AND created_at <= ?" : "")
|
|
41963
41981
|
).all(...upToCreatedAt ? [sessionId, upToCreatedAt] : [sessionId]);
|
|
41964
|
-
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ?");
|
|
41982
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ?, runtime_input_ids = ? WHERE id = ?");
|
|
41965
41983
|
for (const row of rows) {
|
|
41966
|
-
const
|
|
41967
|
-
|
|
41984
|
+
const externalId = (row.external_turn_id && map2.get(row.external_turn_id)) ?? row.external_turn_id;
|
|
41985
|
+
const inputIds = forkedRuntimeInputIds(row.runtime_input_ids, map2);
|
|
41986
|
+
if (externalId !== row.external_turn_id || inputIds !== row.runtime_input_ids) {
|
|
41987
|
+
update.run(externalId, inputIds, row.id);
|
|
41988
|
+
}
|
|
41968
41989
|
}
|
|
41969
41990
|
}
|
|
41970
41991
|
function dropRewoundTurns(db2, sessionId) {
|
|
@@ -42543,8 +42564,8 @@ async function registerSessionRoutes(fastify) {
|
|
|
42543
42564
|
for (const turn of turnRows) {
|
|
42544
42565
|
const newTurnId = v4_default();
|
|
42545
42566
|
db2.prepare(
|
|
42546
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, attachments, origin, origin_name, created_at, updated_at)
|
|
42547
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42567
|
+
`INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, runtime_input_ids, status, error, attachments, origin, origin_name, created_at, updated_at)
|
|
42568
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42548
42569
|
).run(
|
|
42549
42570
|
newTurnId,
|
|
42550
42571
|
newSessionId,
|
|
@@ -42553,6 +42574,7 @@ async function registerSessionRoutes(fastify) {
|
|
|
42553
42574
|
turn.thoughts,
|
|
42554
42575
|
turn.token_usage,
|
|
42555
42576
|
(turn.external_turn_id && turnIds.get(turn.external_turn_id)) ?? turn.external_turn_id,
|
|
42577
|
+
forkedRuntimeInputIds(turn.runtime_input_ids, turnIds),
|
|
42556
42578
|
turn.status,
|
|
42557
42579
|
turn.error,
|
|
42558
42580
|
turn.attachments,
|
|
@@ -42787,7 +42809,7 @@ function recoverInterruptedTurns(db2, opts) {
|
|
|
42787
42809
|
WHERE i.status = 'in_progress'`
|
|
42788
42810
|
).all();
|
|
42789
42811
|
const orphaned = open.filter((i) => !skip.entries.has(runtimeEntryKey(i.session_id, i.thread_id)));
|
|
42790
|
-
const
|
|
42812
|
+
const stopTask4 = db2.prepare(
|
|
42791
42813
|
`UPDATE items SET data = json_set(COALESCE(data, '{}'), '$.status', 'stopped')
|
|
42792
42814
|
WHERE id = ? AND json_valid(COALESCE(data, '{}'))`
|
|
42793
42815
|
);
|
|
@@ -42795,7 +42817,7 @@ function recoverInterruptedTurns(db2, opts) {
|
|
|
42795
42817
|
const items = { changes: 0 };
|
|
42796
42818
|
db2.transaction(() => {
|
|
42797
42819
|
for (const item of orphaned) {
|
|
42798
|
-
if (item.type === "background_task")
|
|
42820
|
+
if (item.type === "background_task") stopTask4.run(item.id);
|
|
42799
42821
|
items.changes += failItem.run(now, item.id).changes;
|
|
42800
42822
|
}
|
|
42801
42823
|
})();
|
|
@@ -119947,7 +119969,10 @@ function claudeUserMcpNames(cwd) {
|
|
|
119947
119969
|
const file2 = claudeConfigFile();
|
|
119948
119970
|
return /* @__PURE__ */ new Set([
|
|
119949
119971
|
...jsonServerNames(file2, (json2) => json2.mcpServers),
|
|
119950
|
-
...jsonServerNames(
|
|
119972
|
+
...jsonServerNames(
|
|
119973
|
+
file2,
|
|
119974
|
+
(json2) => json2.projects?.[cwd]?.mcpServers
|
|
119975
|
+
),
|
|
119951
119976
|
...jsonServerNames(path18.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
|
|
119952
119977
|
]);
|
|
119953
119978
|
}
|
|
@@ -119972,7 +119997,10 @@ function tomlServerNames(file2) {
|
|
|
119972
119997
|
}
|
|
119973
119998
|
function codexUserMcpNames(cwd) {
|
|
119974
119999
|
const home = process.env.CODEX_HOME || path18.join(os6.homedir(), ".codex");
|
|
119975
|
-
return /* @__PURE__ */ new Set([
|
|
120000
|
+
return /* @__PURE__ */ new Set([
|
|
120001
|
+
...tomlServerNames(path18.join(home, "config.toml")),
|
|
120002
|
+
...tomlServerNames(path18.join(cwd, ".codex", "config.toml"))
|
|
120003
|
+
]);
|
|
119976
120004
|
}
|
|
119977
120005
|
var CODEX_BROWSER_CHECK_INSTRUCTIONS = `Browser checks: when you check a change end-to-end in a browser, use the playwright MCP tools (a Chromium with the tabtape recorder) and record the check. Call the tabtape tool get_record_link (name: what you check, url: the first page), open its start link with browser_navigate, do the check, then open its stop link: that page shows the replay link, which you give the user. When a check fails, look into the recording with the tabtape tools before guessing. If recording does not work (the start page says "Nothing happened", or tabtape cannot be reached), carry on with the check and tell the user the recording failed.`;
|
|
119978
120006
|
async function codexBrowserMcp(cwd) {
|
|
@@ -119997,6 +120025,20 @@ async function codexBrowserMcp(cwd) {
|
|
|
119997
120025
|
}
|
|
119998
120026
|
return { args, instructions: mcp.tabtape ? CODEX_BROWSER_CHECK_INSTRUCTIONS : null };
|
|
119999
120027
|
}
|
|
120028
|
+
async function repoburgBrowserMcpServers(_cwd) {
|
|
120029
|
+
const mcp = await browserMcp(/* @__PURE__ */ new Set());
|
|
120030
|
+
const servers = [];
|
|
120031
|
+
if (mcp.tabtape) {
|
|
120032
|
+
servers.push({
|
|
120033
|
+
name: TABTAPE_MCP_NAME,
|
|
120034
|
+
type: "http",
|
|
120035
|
+
url: mcp.tabtape,
|
|
120036
|
+
instructions: CODEX_BROWSER_CHECK_INSTRUCTIONS
|
|
120037
|
+
});
|
|
120038
|
+
}
|
|
120039
|
+
if (mcp.playwright) servers.push({ name: PLAYWRIGHT_MCP_NAME, type: "stdio", ...mcp.playwright });
|
|
120040
|
+
return servers;
|
|
120041
|
+
}
|
|
120000
120042
|
var prepared = false;
|
|
120001
120043
|
function chromiumDownloadCommand(execPath = process.execPath) {
|
|
120002
120044
|
const bin = path18.dirname(execPath);
|
|
@@ -123377,25 +123419,25 @@ function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
|
|
|
123377
123419
|
}
|
|
123378
123420
|
async function interruptTurn2(sessionId, threadId) {
|
|
123379
123421
|
let entry;
|
|
123380
|
-
let
|
|
123422
|
+
let entryKey2 = null;
|
|
123381
123423
|
if (threadId) {
|
|
123382
|
-
|
|
123383
|
-
entry = sessionMap2.get(
|
|
123424
|
+
entryKey2 = `${sessionId}:thread:${threadId}`;
|
|
123425
|
+
entry = sessionMap2.get(entryKey2);
|
|
123384
123426
|
} else {
|
|
123385
123427
|
entry = sessionMap2.get(sessionId);
|
|
123386
|
-
|
|
123428
|
+
entryKey2 = sessionId;
|
|
123387
123429
|
if (!entry || !entry.turnId) {
|
|
123388
|
-
|
|
123430
|
+
entryKey2 = null;
|
|
123389
123431
|
for (const [key, threadEntry] of sessionMap2) {
|
|
123390
123432
|
if (key.startsWith(`${sessionId}:thread:`) && threadEntry.turnId) {
|
|
123391
123433
|
entry = threadEntry;
|
|
123392
|
-
|
|
123434
|
+
entryKey2 = key;
|
|
123393
123435
|
break;
|
|
123394
123436
|
}
|
|
123395
123437
|
}
|
|
123396
123438
|
}
|
|
123397
123439
|
}
|
|
123398
|
-
if (entry && entry.turnId &&
|
|
123440
|
+
if (entry && entry.turnId && entryKey2) {
|
|
123399
123441
|
const turnId = entry.turnId;
|
|
123400
123442
|
try {
|
|
123401
123443
|
await entry.query.interrupt();
|
|
@@ -123418,7 +123460,7 @@ async function interruptTurn2(sessionId, threadId) {
|
|
|
123418
123460
|
entry.promptQueue.close();
|
|
123419
123461
|
entry.query.close();
|
|
123420
123462
|
streamingMessageIds.delete(turnId);
|
|
123421
|
-
sessionMap2.delete(
|
|
123463
|
+
sessionMap2.delete(entryKey2);
|
|
123422
123464
|
dropBackgroundTasks(sessionId, entry);
|
|
123423
123465
|
}
|
|
123424
123466
|
}
|
|
@@ -124113,7 +124155,7 @@ var RepoburgHttpClient = class {
|
|
|
124113
124155
|
return this.request("POST", "/sessions", dto);
|
|
124114
124156
|
}
|
|
124115
124157
|
async patchSession(id, dto) {
|
|
124116
|
-
return this.request("
|
|
124158
|
+
return this.request("PUT", `/sessions/${id}`, dto);
|
|
124117
124159
|
}
|
|
124118
124160
|
async getSession(id) {
|
|
124119
124161
|
return this.request("GET", `/sessions/${id}`);
|
|
@@ -124122,19 +124164,13 @@ var RepoburgHttpClient = class {
|
|
|
124122
124164
|
return this.request("POST", `/sessions/${sessionId}/inputs`, dto);
|
|
124123
124165
|
}
|
|
124124
124166
|
async getInputWithActions(sessionId, inputId) {
|
|
124125
|
-
return this.request(
|
|
124126
|
-
"GET",
|
|
124127
|
-
`/sessions/${sessionId}/inputs/${inputId}/actions-with-logs`
|
|
124128
|
-
);
|
|
124167
|
+
return this.request("GET", `/sessions/${sessionId}/inputs/${inputId}/actions-with-logs`);
|
|
124129
124168
|
}
|
|
124130
124169
|
async getSessionInputs(sessionId) {
|
|
124131
124170
|
return this.request("GET", `/sessions/${sessionId}/inputs`);
|
|
124132
124171
|
}
|
|
124133
124172
|
async deleteInputsUntilHere(sessionId, anchorInputId) {
|
|
124134
|
-
await this.request(
|
|
124135
|
-
"DELETE",
|
|
124136
|
-
`/sessions/${sessionId}/inputs/${anchorInputId}/until-here`
|
|
124137
|
-
);
|
|
124173
|
+
await this.request("DELETE", `/sessions/${sessionId}/inputs/${anchorInputId}/until-here`);
|
|
124138
124174
|
}
|
|
124139
124175
|
async deleteSession(id) {
|
|
124140
124176
|
await this.request("DELETE", `/sessions/${id}`);
|
|
@@ -124145,11 +124181,24 @@ var RepoburgHttpClient = class {
|
|
|
124145
124181
|
});
|
|
124146
124182
|
}
|
|
124147
124183
|
async cancel(sessionId) {
|
|
124184
|
+
return this.request("POST", `/streaming/${sessionId}/cancel`);
|
|
124185
|
+
}
|
|
124186
|
+
async listBackgroundTasks(sessionId) {
|
|
124187
|
+
const result = await this.request(
|
|
124188
|
+
"GET",
|
|
124189
|
+
`/sessions/${sessionId}/background-tasks`
|
|
124190
|
+
);
|
|
124191
|
+
return result.tasks ?? [];
|
|
124192
|
+
}
|
|
124193
|
+
async stopBackgroundTask(sessionId, taskId) {
|
|
124148
124194
|
return this.request(
|
|
124149
124195
|
"POST",
|
|
124150
|
-
`/
|
|
124196
|
+
`/sessions/${sessionId}/background-tasks/${encodeURIComponent(taskId)}/stop`
|
|
124151
124197
|
);
|
|
124152
124198
|
}
|
|
124199
|
+
async setSessionMcpServers(sessionId, servers) {
|
|
124200
|
+
await this.request("PUT", `/sessions/${sessionId}/mcp-servers`, { servers });
|
|
124201
|
+
}
|
|
124153
124202
|
async getModels() {
|
|
124154
124203
|
const result = await this.request("GET", "/llm-provider/models");
|
|
124155
124204
|
return result.models ?? [];
|
|
@@ -124709,6 +124758,96 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124709
124758
|
}
|
|
124710
124759
|
}
|
|
124711
124760
|
|
|
124761
|
+
// src/repoburg/repoburg-tasks.ts
|
|
124762
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
124763
|
+
import { isAbsolute, join as join6 } from "node:path";
|
|
124764
|
+
var TASK_OUTPUT_MAX2 = 2e4;
|
|
124765
|
+
var REPOBURG_TASK_TYPE = "background_terminal";
|
|
124766
|
+
var NOT_BACKGROUND_COMMAND = `NOT (type = 'background_task' AND json_valid(COALESCE(data, '{}'))
|
|
124767
|
+
AND json_extract(data, '$.task_type') = '${REPOBURG_TASK_TYPE}')`;
|
|
124768
|
+
function taskItemExternalId(taskId) {
|
|
124769
|
+
return `task-${taskId}`;
|
|
124770
|
+
}
|
|
124771
|
+
function taskOutputPath(outputFile, cwd) {
|
|
124772
|
+
if (!outputFile) return null;
|
|
124773
|
+
if (isAbsolute(outputFile)) return outputFile;
|
|
124774
|
+
return cwd ? join6(cwd, outputFile) : null;
|
|
124775
|
+
}
|
|
124776
|
+
function readTaskOutput(path21) {
|
|
124777
|
+
if (!path21) return "";
|
|
124778
|
+
try {
|
|
124779
|
+
const text2 = readFileSync5(path21, "utf-8");
|
|
124780
|
+
return text2.length > TASK_OUTPUT_MAX2 ? text2.slice(-TASK_OUTPUT_MAX2) : text2;
|
|
124781
|
+
} catch {
|
|
124782
|
+
return "";
|
|
124783
|
+
}
|
|
124784
|
+
}
|
|
124785
|
+
function findTaskItem2(db2, sessionId, taskId) {
|
|
124786
|
+
return db2.prepare(
|
|
124787
|
+
`SELECT i.* FROM items i JOIN turns t ON t.id = i.turn_id
|
|
124788
|
+
WHERE t.session_id = ? AND i.external_item_id = ? AND i.type = 'background_task'
|
|
124789
|
+
ORDER BY i.created_at DESC LIMIT 1`
|
|
124790
|
+
).get(sessionId, taskItemExternalId(taskId));
|
|
124791
|
+
}
|
|
124792
|
+
function openTaskItem2(db2, sessionId, turnId, task) {
|
|
124793
|
+
if (findTaskItem2(db2, sessionId, task.task_id)) return;
|
|
124794
|
+
insertItem(
|
|
124795
|
+
db2,
|
|
124796
|
+
sessionId,
|
|
124797
|
+
turnId,
|
|
124798
|
+
taskItemExternalId(task.task_id),
|
|
124799
|
+
"background_task",
|
|
124800
|
+
{
|
|
124801
|
+
task_id: task.task_id,
|
|
124802
|
+
description: task.description,
|
|
124803
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
124804
|
+
subagent_type: null,
|
|
124805
|
+
prompt: task.command,
|
|
124806
|
+
status: "running",
|
|
124807
|
+
summary: null,
|
|
124808
|
+
output_file: task.output_file,
|
|
124809
|
+
output: "",
|
|
124810
|
+
token_count: null,
|
|
124811
|
+
last_tool_name: null
|
|
124812
|
+
},
|
|
124813
|
+
"in_progress",
|
|
124814
|
+
"item:started"
|
|
124815
|
+
);
|
|
124816
|
+
}
|
|
124817
|
+
function updateTaskItem(db2, sessionId, taskId, update) {
|
|
124818
|
+
const row = findTaskItem2(db2, sessionId, taskId);
|
|
124819
|
+
if (!row) return false;
|
|
124820
|
+
if (row.status !== "in_progress") return true;
|
|
124821
|
+
const prev = row.data ? JSON.parse(row.data) : {};
|
|
124822
|
+
const output = readTaskOutput(prev.output_file ?? null) || String(prev.output ?? "");
|
|
124823
|
+
const ended = update.status !== "running";
|
|
124824
|
+
if (!ended && output === prev.output) return true;
|
|
124825
|
+
const data = {
|
|
124826
|
+
...prev,
|
|
124827
|
+
status: update.status,
|
|
124828
|
+
output,
|
|
124829
|
+
...update.summary !== void 0 ? { summary: update.summary } : {},
|
|
124830
|
+
...update.exit_code !== void 0 ? { exit_code: update.exit_code } : {}
|
|
124831
|
+
};
|
|
124832
|
+
const status = !ended ? "in_progress" : update.status === "failed" ? "failed" : "completed";
|
|
124833
|
+
const item = { ...row, data: prev };
|
|
124834
|
+
updateItem(db2, sessionId, row.turn_id, item, data, status);
|
|
124835
|
+
return true;
|
|
124836
|
+
}
|
|
124837
|
+
function taskSummary(task) {
|
|
124838
|
+
const name = `Background command "${task.description}"`;
|
|
124839
|
+
switch (task.status) {
|
|
124840
|
+
case "completed":
|
|
124841
|
+
return `${name} completed (exit code 0)`;
|
|
124842
|
+
case "stopped":
|
|
124843
|
+
return `${name} was stopped`;
|
|
124844
|
+
case "failed":
|
|
124845
|
+
return task.exit_code === null ? `${name} was killed` : `${name} failed with exit code ${task.exit_code}`;
|
|
124846
|
+
default:
|
|
124847
|
+
return `${name} is running`;
|
|
124848
|
+
}
|
|
124849
|
+
}
|
|
124850
|
+
|
|
124712
124851
|
// src/repoburg/turn-projector.ts
|
|
124713
124852
|
var RESULT_TIMEOUT_MS = 15 * 6e4;
|
|
124714
124853
|
var MAX_RESULT_EXTENSIONS = 3;
|
|
@@ -124744,6 +124883,8 @@ var TurnProjector = class {
|
|
|
124744
124883
|
switch (message.type) {
|
|
124745
124884
|
case "system":
|
|
124746
124885
|
if (message.subtype === "compact_boundary") this.handleCompactBoundary(message);
|
|
124886
|
+
else if (message.subtype === "task_started") this.handleTaskStarted(message);
|
|
124887
|
+
else if (message.subtype === "task_notification") this.handleTaskNotification(message);
|
|
124747
124888
|
break;
|
|
124748
124889
|
case "stream_event":
|
|
124749
124890
|
this.handleStreamEvent(message);
|
|
@@ -125073,6 +125214,27 @@ var TurnProjector = class {
|
|
|
125073
125214
|
}
|
|
125074
125215
|
this.touch();
|
|
125075
125216
|
}
|
|
125217
|
+
/** A background task started in this turn → its background_task item. */
|
|
125218
|
+
handleTaskStarted(msg) {
|
|
125219
|
+
openTaskItem2(getDb(), this.deps.agentPaneSessionId, this.deps.turnId, {
|
|
125220
|
+
task_id: msg.task_id,
|
|
125221
|
+
description: msg.description,
|
|
125222
|
+
command: msg.command,
|
|
125223
|
+
output_file: taskOutputPath(msg.output_file, this.deps.cwd)
|
|
125224
|
+
});
|
|
125225
|
+
this.deps.onTaskEvent?.(msg);
|
|
125226
|
+
this.touch();
|
|
125227
|
+
}
|
|
125228
|
+
/** A background task ended — maybe one an earlier turn started. */
|
|
125229
|
+
handleTaskNotification(msg) {
|
|
125230
|
+
updateTaskItem(getDb(), this.deps.agentPaneSessionId, msg.task_id, {
|
|
125231
|
+
status: msg.status,
|
|
125232
|
+
summary: msg.summary,
|
|
125233
|
+
exit_code: msg.exit_code
|
|
125234
|
+
});
|
|
125235
|
+
this.deps.onTaskEvent?.(msg);
|
|
125236
|
+
this.touch();
|
|
125237
|
+
}
|
|
125076
125238
|
handleResult(msg) {
|
|
125077
125239
|
switch (msg.subtype) {
|
|
125078
125240
|
case "success":
|
|
@@ -125237,12 +125399,9 @@ var TurnProjector = class {
|
|
|
125237
125399
|
closeOpenItems(status) {
|
|
125238
125400
|
const db2 = getDb();
|
|
125239
125401
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
125240
|
-
db2.prepare(
|
|
125241
|
-
status
|
|
125242
|
-
|
|
125243
|
-
this.deps.turnId,
|
|
125244
|
-
"in_progress"
|
|
125245
|
-
);
|
|
125402
|
+
db2.prepare(
|
|
125403
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
125404
|
+
).run(status, now, this.deps.turnId, "in_progress");
|
|
125246
125405
|
}
|
|
125247
125406
|
// -------------------------------------------------------------------------
|
|
125248
125407
|
// Watch-dog + snapshot reconcile
|
|
@@ -125419,9 +125578,10 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
125419
125578
|
repoburgSessionId: session.external_thread_id,
|
|
125420
125579
|
client,
|
|
125421
125580
|
baseUrl,
|
|
125422
|
-
|
|
125423
|
-
//
|
|
125581
|
+
// undefined forces a re-push of model and effort on the next turn —
|
|
125582
|
+
// heals switches made while the pane was down, and sessions created
|
|
125424
125583
|
// before unsafe effort values (e.g. ollama xhigh) were clamped.
|
|
125584
|
+
modelId: void 0,
|
|
125425
125585
|
reasoningEffort: void 0,
|
|
125426
125586
|
threadId: null,
|
|
125427
125587
|
contextWindow: null,
|
|
@@ -125466,6 +125626,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
125466
125626
|
const db2 = getDb();
|
|
125467
125627
|
const thread = db2.prepare("SELECT external_thread_id FROM discussion_threads WHERE id = ?").get(turn.thread_id);
|
|
125468
125628
|
let runtimeId = thread?.external_thread_id ?? null;
|
|
125629
|
+
const forked = !!runtimeId;
|
|
125469
125630
|
if (!runtimeId) {
|
|
125470
125631
|
const created = await client.createSession({
|
|
125471
125632
|
session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
|
|
@@ -125485,7 +125646,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
125485
125646
|
repoburgSessionId: runtimeId,
|
|
125486
125647
|
client,
|
|
125487
125648
|
baseUrl,
|
|
125488
|
-
modelId: session.model || null,
|
|
125649
|
+
modelId: forked ? void 0 : session.model || null,
|
|
125489
125650
|
reasoningEffort: void 0,
|
|
125490
125651
|
// re-pushed on the first thread turn
|
|
125491
125652
|
threadId: turn.thread_id,
|
|
@@ -125536,12 +125697,9 @@ function failTurn3(entry, error51) {
|
|
|
125536
125697
|
now,
|
|
125537
125698
|
active.turnId
|
|
125538
125699
|
);
|
|
125539
|
-
db2.prepare(
|
|
125540
|
-
|
|
125541
|
-
|
|
125542
|
-
active.turnId,
|
|
125543
|
-
"in_progress"
|
|
125544
|
-
);
|
|
125700
|
+
db2.prepare(
|
|
125701
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
125702
|
+
).run("failed", now, active.turnId, "in_progress");
|
|
125545
125703
|
recomputeSessionRunning(db2, entry.agentPaneSessionId, "failed");
|
|
125546
125704
|
broadcast("turn:failed", { sessionId: entry.agentPaneSessionId, turnId: active.turnId, error: error51 });
|
|
125547
125705
|
}
|
|
@@ -125670,6 +125828,16 @@ async function startTurn4(session, turn) {
|
|
|
125670
125828
|
entry.baseUrl = baseUrl;
|
|
125671
125829
|
entry.client = client;
|
|
125672
125830
|
}
|
|
125831
|
+
startingEntries.add(entry);
|
|
125832
|
+
try {
|
|
125833
|
+
await runTurn2(session, turn, entry, firstInput);
|
|
125834
|
+
} finally {
|
|
125835
|
+
startingEntries.delete(entry);
|
|
125836
|
+
}
|
|
125837
|
+
}
|
|
125838
|
+
async function runTurn2(session, turn, entry, firstInput) {
|
|
125839
|
+
const db2 = getDb();
|
|
125840
|
+
await syncSessionMcp(entry, session.cwd ?? process.cwd());
|
|
125673
125841
|
const wantedModel = session.model || null;
|
|
125674
125842
|
const wantedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
125675
125843
|
if (wantedModel !== entry.modelId || wantedEffort !== entry.reasoningEffort) {
|
|
@@ -125689,7 +125857,11 @@ async function startTurn4(session, turn) {
|
|
|
125689
125857
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("running", now, turn.id);
|
|
125690
125858
|
setSessionStatus3(db2, session.id, 1, "running", now);
|
|
125691
125859
|
broadcast("turn:started", { sessionId: session.id, turnId: turn.id });
|
|
125692
|
-
|
|
125860
|
+
let state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
125861
|
+
if (state?.turnInFlight && !(entry.activeTurn && !entry.activeTurn.projector.isDone)) {
|
|
125862
|
+
await entry.client.cancel(entry.repoburgSessionId).catch(() => void 0);
|
|
125863
|
+
state = await waitForRunEnd(entry, RUN_END_WAIT_MS) ?? state;
|
|
125864
|
+
}
|
|
125693
125865
|
if (state) {
|
|
125694
125866
|
const cursor = {
|
|
125695
125867
|
bootId: state.bootId,
|
|
@@ -125707,7 +125879,10 @@ async function startTurn4(session, turn) {
|
|
|
125707
125879
|
// Late-bound — the window resolves from the runtime catalog while the
|
|
125708
125880
|
// turn streams and is read at turn completion.
|
|
125709
125881
|
getContextWindow: () => entry.contextWindow,
|
|
125710
|
-
...state ? { firstSeq: state.lastSeq + 1 } : {}
|
|
125882
|
+
...state ? { firstSeq: state.lastSeq + 1 } : {},
|
|
125883
|
+
cwd: session.cwd ?? null,
|
|
125884
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
125885
|
+
onFinished: () => onTurnFinished(entry)
|
|
125711
125886
|
});
|
|
125712
125887
|
entry.activeTurn = {
|
|
125713
125888
|
turnId: turn.id,
|
|
@@ -125736,6 +125911,245 @@ async function startTurn4(session, turn) {
|
|
|
125736
125911
|
failTurn3(entry, err.message);
|
|
125737
125912
|
}
|
|
125738
125913
|
}
|
|
125914
|
+
var TASK_POLL_MS = 2e3;
|
|
125915
|
+
var WAKE_WATCH_MS = 2e4;
|
|
125916
|
+
var RUN_END_WAIT_MS = 1e4;
|
|
125917
|
+
var taskStates = /* @__PURE__ */ new WeakMap();
|
|
125918
|
+
var startingEntries = /* @__PURE__ */ new Set();
|
|
125919
|
+
var publishedTasks = /* @__PURE__ */ new Map();
|
|
125920
|
+
function taskStateOf(entry) {
|
|
125921
|
+
let state = taskStates.get(entry);
|
|
125922
|
+
if (!state) {
|
|
125923
|
+
state = { running: /* @__PURE__ */ new Map(), timer: null, polling: false, watchUntil: 0 };
|
|
125924
|
+
taskStates.set(entry, state);
|
|
125925
|
+
}
|
|
125926
|
+
return state;
|
|
125927
|
+
}
|
|
125928
|
+
function taskPollMs2() {
|
|
125929
|
+
const fromEnv = Number(process.env.AGENT_PANE_REPOBURG_TASK_POLL_MS);
|
|
125930
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : TASK_POLL_MS;
|
|
125931
|
+
}
|
|
125932
|
+
function sessionCwd(sessionId) {
|
|
125933
|
+
try {
|
|
125934
|
+
const row = getDb().prepare("SELECT cwd FROM sessions WHERE id = ?").get(sessionId);
|
|
125935
|
+
return row?.cwd ?? null;
|
|
125936
|
+
} catch {
|
|
125937
|
+
return null;
|
|
125938
|
+
}
|
|
125939
|
+
}
|
|
125940
|
+
function entryKey(entry) {
|
|
125941
|
+
return entry.threadId ? `${entry.agentPaneSessionId}:thread:${entry.threadId}` : entry.agentPaneSessionId;
|
|
125942
|
+
}
|
|
125943
|
+
function onTaskEvent(entry, message) {
|
|
125944
|
+
const state = taskStateOf(entry);
|
|
125945
|
+
if (message.subtype === "task_started") {
|
|
125946
|
+
state.running.set(message.task_id, {
|
|
125947
|
+
task_id: message.task_id,
|
|
125948
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
125949
|
+
description: message.description
|
|
125950
|
+
});
|
|
125951
|
+
} else {
|
|
125952
|
+
state.running.delete(message.task_id);
|
|
125953
|
+
state.watchUntil = Date.now() + WAKE_WATCH_MS;
|
|
125954
|
+
}
|
|
125955
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
125956
|
+
ensureTaskPolling(entry);
|
|
125957
|
+
}
|
|
125958
|
+
function onTurnFinished(entry) {
|
|
125959
|
+
const state = taskStates.get(entry);
|
|
125960
|
+
if (!state) return;
|
|
125961
|
+
state.watchUntil = Math.max(state.watchUntil, Date.now() + WAKE_WATCH_MS);
|
|
125962
|
+
ensureTaskPolling(entry);
|
|
125963
|
+
}
|
|
125964
|
+
function sessionTasks(sessionId) {
|
|
125965
|
+
const tasks = [];
|
|
125966
|
+
for (const [key, entry] of sessionMap3) {
|
|
125967
|
+
if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
|
|
125968
|
+
const state = taskStates.get(entry);
|
|
125969
|
+
if (state) tasks.push(...state.running.values());
|
|
125970
|
+
}
|
|
125971
|
+
return tasks;
|
|
125972
|
+
}
|
|
125973
|
+
function publishTasks2(sessionId) {
|
|
125974
|
+
const tasks = sessionTasks(sessionId);
|
|
125975
|
+
const json2 = JSON.stringify(tasks);
|
|
125976
|
+
if ((publishedTasks.get(sessionId) ?? "[]") === json2) return;
|
|
125977
|
+
if (tasks.length > 0) publishedTasks.set(sessionId, json2);
|
|
125978
|
+
else publishedTasks.delete(sessionId);
|
|
125979
|
+
broadcast("background_tasks", { sessionId, tasks });
|
|
125980
|
+
}
|
|
125981
|
+
function ensureTaskPolling(entry) {
|
|
125982
|
+
const state = taskStateOf(entry);
|
|
125983
|
+
if (state.timer || !entry.client.listBackgroundTasks) return;
|
|
125984
|
+
if (state.running.size === 0 && Date.now() >= state.watchUntil) return;
|
|
125985
|
+
state.timer = setInterval(() => void pollTasks(entry), taskPollMs2());
|
|
125986
|
+
state.timer.unref?.();
|
|
125987
|
+
}
|
|
125988
|
+
function stopTaskPolling2(entry) {
|
|
125989
|
+
const state = taskStates.get(entry);
|
|
125990
|
+
if (!state?.timer) return;
|
|
125991
|
+
clearInterval(state.timer);
|
|
125992
|
+
state.timer = null;
|
|
125993
|
+
}
|
|
125994
|
+
async function pollTasks(entry) {
|
|
125995
|
+
const state = taskStateOf(entry);
|
|
125996
|
+
if (state.polling) return;
|
|
125997
|
+
if (sessionMap3.get(entryKey(entry)) !== entry) {
|
|
125998
|
+
stopTaskPolling2(entry);
|
|
125999
|
+
return;
|
|
126000
|
+
}
|
|
126001
|
+
state.polling = true;
|
|
126002
|
+
try {
|
|
126003
|
+
const tasks = await entry.client.listBackgroundTasks(entry.repoburgSessionId);
|
|
126004
|
+
const db2 = getDb();
|
|
126005
|
+
const listed = new Set(tasks.map((task) => task.task_id));
|
|
126006
|
+
for (const task of tasks) {
|
|
126007
|
+
if (task.status === "running") {
|
|
126008
|
+
state.running.set(task.task_id, {
|
|
126009
|
+
task_id: task.task_id,
|
|
126010
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
126011
|
+
description: task.description
|
|
126012
|
+
});
|
|
126013
|
+
updateTaskItem(db2, entry.agentPaneSessionId, task.task_id, { status: "running" });
|
|
126014
|
+
} else if (state.running.delete(task.task_id)) {
|
|
126015
|
+
state.watchUntil = Date.now() + WAKE_WATCH_MS;
|
|
126016
|
+
updateTaskItem(db2, entry.agentPaneSessionId, task.task_id, {
|
|
126017
|
+
status: task.status,
|
|
126018
|
+
summary: taskSummary(task),
|
|
126019
|
+
exit_code: task.exit_code
|
|
126020
|
+
});
|
|
126021
|
+
}
|
|
126022
|
+
}
|
|
126023
|
+
for (const taskId of [...state.running.keys()]) {
|
|
126024
|
+
if (listed.has(taskId)) continue;
|
|
126025
|
+
state.running.delete(taskId);
|
|
126026
|
+
updateTaskItem(db2, entry.agentPaneSessionId, taskId, {
|
|
126027
|
+
status: "stopped",
|
|
126028
|
+
summary: "The Repoburg backend stopped running this task.",
|
|
126029
|
+
exit_code: null
|
|
126030
|
+
});
|
|
126031
|
+
}
|
|
126032
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
126033
|
+
await attachWakeRun(entry);
|
|
126034
|
+
} catch (err) {
|
|
126035
|
+
if (httpStatus(err) === 404) {
|
|
126036
|
+
state.running.clear();
|
|
126037
|
+
state.watchUntil = 0;
|
|
126038
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
126039
|
+
} else if (isConnectionError(err)) {
|
|
126040
|
+
invalidateBackend(entry.baseUrl);
|
|
126041
|
+
}
|
|
126042
|
+
} finally {
|
|
126043
|
+
state.polling = false;
|
|
126044
|
+
if (state.running.size === 0 && Date.now() >= state.watchUntil) stopTaskPolling2(entry);
|
|
126045
|
+
}
|
|
126046
|
+
}
|
|
126047
|
+
function entryBusy(entry) {
|
|
126048
|
+
return startingEntries.has(entry) || !!entry.activeTurn && !entry.activeTurn.projector.isDone;
|
|
126049
|
+
}
|
|
126050
|
+
async function attachWakeRun(entry) {
|
|
126051
|
+
if (entryBusy(entry)) return;
|
|
126052
|
+
const state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
126053
|
+
if (!state || entryBusy(entry)) return;
|
|
126054
|
+
const previous = entry.activeTurn;
|
|
126055
|
+
const handled = previous && previous.bootId === state.bootId && previous.lastSeq !== null ? previous.lastSeq : null;
|
|
126056
|
+
const missedRun = handled !== null && !previous?.cancelled && state.lastResult !== null && (state.lastResult.seq ?? 0) > handled;
|
|
126057
|
+
if (!state.turnInFlight && !missedRun) return;
|
|
126058
|
+
const db2 = getDb();
|
|
126059
|
+
const turn = db2.prepare("SELECT id, status FROM turns WHERE session_id = ? AND thread_id IS ? ORDER BY created_at DESC LIMIT 1").get(entry.agentPaneSessionId, entry.threadId);
|
|
126060
|
+
if (!turn || turn.status === "running" || turn.status === "pending") return;
|
|
126061
|
+
const fromSeq = handled ?? state.lastResult?.seq ?? 0;
|
|
126062
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
126063
|
+
const cursor = {
|
|
126064
|
+
bootId: state.bootId,
|
|
126065
|
+
firstSeq: fromSeq + 1,
|
|
126066
|
+
baseUrl: entry.baseUrl,
|
|
126067
|
+
runtimeSessionId: entry.repoburgSessionId
|
|
126068
|
+
};
|
|
126069
|
+
db2.prepare("UPDATE turns SET status = 'running', error = NULL, stream_cursor = ?, updated_at = ? WHERE id = ?").run(
|
|
126070
|
+
JSON.stringify(cursor),
|
|
126071
|
+
now,
|
|
126072
|
+
turn.id
|
|
126073
|
+
);
|
|
126074
|
+
setSessionStatus3(db2, entry.agentPaneSessionId, 1, "running", now);
|
|
126075
|
+
broadcast("turn:started", { sessionId: entry.agentPaneSessionId, turnId: turn.id });
|
|
126076
|
+
const projector = new TurnProjector({
|
|
126077
|
+
agentPaneSessionId: entry.agentPaneSessionId,
|
|
126078
|
+
turnId: turn.id,
|
|
126079
|
+
repoburgSessionId: entry.repoburgSessionId,
|
|
126080
|
+
client: entry.client,
|
|
126081
|
+
getContextWindow: () => entry.contextWindow,
|
|
126082
|
+
firstSeq: fromSeq + 1,
|
|
126083
|
+
cwd: sessionCwd(entry.agentPaneSessionId),
|
|
126084
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
126085
|
+
onFinished: () => onTurnFinished(entry)
|
|
126086
|
+
});
|
|
126087
|
+
entry.activeTurn = {
|
|
126088
|
+
turnId: turn.id,
|
|
126089
|
+
projector,
|
|
126090
|
+
sseAbort: new AbortController(),
|
|
126091
|
+
cancelled: false,
|
|
126092
|
+
bootId: state.bootId,
|
|
126093
|
+
lastSeq: fromSeq
|
|
126094
|
+
};
|
|
126095
|
+
console.log(`[repoburg] session ${entry.agentPaneSessionId}: a background task ended, turn ${turn.id} runs again`);
|
|
126096
|
+
runStreamLoop(entry, projector).catch((err) => {
|
|
126097
|
+
console.error("[repoburg] stream loop crashed:", err);
|
|
126098
|
+
failTurn3(entry, `Stream loop failed: ${err.message}`);
|
|
126099
|
+
});
|
|
126100
|
+
}
|
|
126101
|
+
async function waitForRunEnd(entry, timeoutMs) {
|
|
126102
|
+
const end = Date.now() + timeoutMs;
|
|
126103
|
+
for (; ; ) {
|
|
126104
|
+
const state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
126105
|
+
if (!state || !state.turnInFlight || Date.now() >= end) return state;
|
|
126106
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
126107
|
+
}
|
|
126108
|
+
}
|
|
126109
|
+
async function stopTask3(sessionId, taskId) {
|
|
126110
|
+
for (const [key, entry] of sessionMap3) {
|
|
126111
|
+
if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
|
|
126112
|
+
const state = taskStates.get(entry);
|
|
126113
|
+
if (!state?.running.has(taskId) || !entry.client.stopBackgroundTask) continue;
|
|
126114
|
+
const task = await entry.client.stopBackgroundTask(entry.repoburgSessionId, taskId);
|
|
126115
|
+
state.running.delete(taskId);
|
|
126116
|
+
updateTaskItem(getDb(), sessionId, taskId, {
|
|
126117
|
+
status: task.status === "running" ? "stopped" : task.status,
|
|
126118
|
+
summary: taskSummary(task),
|
|
126119
|
+
exit_code: task.exit_code
|
|
126120
|
+
});
|
|
126121
|
+
publishTasks2(sessionId);
|
|
126122
|
+
return;
|
|
126123
|
+
}
|
|
126124
|
+
throw new Error(`No running background task ${taskId} in this session`);
|
|
126125
|
+
}
|
|
126126
|
+
function listBackgroundTasks3() {
|
|
126127
|
+
const bySession = {};
|
|
126128
|
+
for (const entry of sessionMap3.values()) {
|
|
126129
|
+
const tasks = sessionTasks(entry.agentPaneSessionId);
|
|
126130
|
+
if (tasks.length > 0) bySession[entry.agentPaneSessionId] = tasks;
|
|
126131
|
+
}
|
|
126132
|
+
return bySession;
|
|
126133
|
+
}
|
|
126134
|
+
var pushedMcp = /* @__PURE__ */ new Map();
|
|
126135
|
+
var noSessionMcp = /* @__PURE__ */ new Set();
|
|
126136
|
+
async function syncSessionMcp(entry, cwd) {
|
|
126137
|
+
if (!entry.client.setSessionMcpServers || noSessionMcp.has(entry.baseUrl)) return;
|
|
126138
|
+
try {
|
|
126139
|
+
const servers = await repoburgBrowserMcpServers(cwd);
|
|
126140
|
+
const json2 = JSON.stringify(servers);
|
|
126141
|
+
const key = `${entry.baseUrl} ${entry.repoburgSessionId}`;
|
|
126142
|
+
if (pushedMcp.get(key) === json2) return;
|
|
126143
|
+
await entry.client.setSessionMcpServers(entry.repoburgSessionId, servers);
|
|
126144
|
+
pushedMcp.set(key, json2);
|
|
126145
|
+
} catch (err) {
|
|
126146
|
+
if (httpStatus(err) === 404 || httpStatus(err) === 400) {
|
|
126147
|
+
noSessionMcp.add(entry.baseUrl);
|
|
126148
|
+
return;
|
|
126149
|
+
}
|
|
126150
|
+
console.warn("[repoburg] could not set the session MCP servers:", err.message);
|
|
126151
|
+
}
|
|
126152
|
+
}
|
|
125739
126153
|
function parseCursor(raw) {
|
|
125740
126154
|
if (!raw) return null;
|
|
125741
126155
|
try {
|
|
@@ -125794,9 +126208,9 @@ async function adoptRepoburgTurns(db2, result) {
|
|
|
125794
126208
|
repoburgSessionId: cursor.runtimeSessionId,
|
|
125795
126209
|
client: new RepoburgHttpClient(cursor.baseUrl),
|
|
125796
126210
|
baseUrl: cursor.baseUrl,
|
|
125797
|
-
modelId:
|
|
126211
|
+
modelId: void 0,
|
|
126212
|
+
// model and effort re-pushed on the next turn
|
|
125798
126213
|
reasoningEffort: void 0,
|
|
125799
|
-
// re-pushed on the next turn
|
|
125800
126214
|
threadId: row.thread_id,
|
|
125801
126215
|
contextWindow: null,
|
|
125802
126216
|
modelsResolved: false,
|
|
@@ -125809,7 +126223,10 @@ async function adoptRepoburgTurns(db2, result) {
|
|
|
125809
126223
|
repoburgSessionId: cursor.runtimeSessionId,
|
|
125810
126224
|
client: entry.client,
|
|
125811
126225
|
getContextWindow: () => entry.contextWindow,
|
|
125812
|
-
firstSeq: cursor.firstSeq
|
|
126226
|
+
firstSeq: cursor.firstSeq,
|
|
126227
|
+
cwd: sessionCwd(row.session_id),
|
|
126228
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
126229
|
+
onFinished: () => onTurnFinished(entry)
|
|
125813
126230
|
});
|
|
125814
126231
|
entry.activeTurn = {
|
|
125815
126232
|
turnId: row.id,
|
|
@@ -125852,12 +126269,9 @@ async function interruptTurn3(sessionId, threadId) {
|
|
|
125852
126269
|
const db2 = getDb();
|
|
125853
126270
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
125854
126271
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, active.turnId);
|
|
125855
|
-
db2.prepare(
|
|
125856
|
-
|
|
125857
|
-
|
|
125858
|
-
active.turnId,
|
|
125859
|
-
"in_progress"
|
|
125860
|
-
);
|
|
126272
|
+
db2.prepare(
|
|
126273
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
126274
|
+
).run("completed", now, active.turnId, "in_progress");
|
|
125861
126275
|
recomputeSessionRunning(db2, sessionId);
|
|
125862
126276
|
broadcast("turn:cancelled", { sessionId, turnId: active.turnId });
|
|
125863
126277
|
return true;
|
|
@@ -125871,6 +126285,7 @@ function clearThread3(sessionId) {
|
|
|
125871
126285
|
active.projector.close();
|
|
125872
126286
|
active.sseAbort.abort();
|
|
125873
126287
|
}
|
|
126288
|
+
stopTaskPolling2(entry);
|
|
125874
126289
|
sessionMap3.delete(key);
|
|
125875
126290
|
}
|
|
125876
126291
|
}
|
|
@@ -125884,6 +126299,7 @@ function clearThreadBranch3(sessionId, threadId) {
|
|
|
125884
126299
|
active.projector.close();
|
|
125885
126300
|
active.sseAbort.abort();
|
|
125886
126301
|
}
|
|
126302
|
+
stopTaskPolling2(entry);
|
|
125887
126303
|
sessionMap3.delete(key);
|
|
125888
126304
|
}
|
|
125889
126305
|
}
|
|
@@ -125933,8 +126349,15 @@ async function forkSession2(session, targetTurn) {
|
|
|
125933
126349
|
}
|
|
125934
126350
|
const client = await resolveClient(session);
|
|
125935
126351
|
const forked = await client.forkSession(session.external_thread_id, anchor);
|
|
126352
|
+
forkInputIds.set(forked.id, new Map(Object.entries(forked.input_id_map ?? {})));
|
|
125936
126353
|
return forked.id;
|
|
125937
126354
|
}
|
|
126355
|
+
var forkInputIds = /* @__PURE__ */ new Map();
|
|
126356
|
+
async function forkedTurnIds2(_session, forkedId) {
|
|
126357
|
+
const ids = forkInputIds.get(forkedId) ?? /* @__PURE__ */ new Map();
|
|
126358
|
+
forkInputIds.delete(forkedId);
|
|
126359
|
+
return ids;
|
|
126360
|
+
}
|
|
125938
126361
|
var THREAD_SUMMARY_TIMEOUT_MS = 12e4;
|
|
125939
126362
|
async function summarizeThread(session, _thread, transcript, directives) {
|
|
125940
126363
|
try {
|
|
@@ -125958,8 +126381,12 @@ function clearAllThreads3() {
|
|
|
125958
126381
|
active.projector.close();
|
|
125959
126382
|
active.sseAbort.abort();
|
|
125960
126383
|
}
|
|
126384
|
+
stopTaskPolling2(entry);
|
|
125961
126385
|
}
|
|
125962
126386
|
sessionMap3.clear();
|
|
126387
|
+
publishedTasks.clear();
|
|
126388
|
+
pushedMcp.clear();
|
|
126389
|
+
noSessionMcp.clear();
|
|
125963
126390
|
}
|
|
125964
126391
|
async function getModels3(cwd) {
|
|
125965
126392
|
try {
|
|
@@ -126062,7 +126489,10 @@ var repoburgProvider = {
|
|
|
126062
126489
|
getCommands: getCommands3,
|
|
126063
126490
|
rewindRuntime,
|
|
126064
126491
|
forkSession: forkSession2,
|
|
126492
|
+
forkedTurnIds: forkedTurnIds2,
|
|
126065
126493
|
summarizeThread,
|
|
126494
|
+
stopTask: stopTask3,
|
|
126495
|
+
listBackgroundTasks: listBackgroundTasks3,
|
|
126066
126496
|
shutdown: shutdown3
|
|
126067
126497
|
};
|
|
126068
126498
|
|