repoburg 1.3.322 → 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 = `
|
|
@@ -41958,8 +41958,8 @@ function forkPoint(db2, sessionId, target) {
|
|
|
41958
41958
|
return row?.external_turn_id ?? null;
|
|
41959
41959
|
}
|
|
41960
41960
|
function snapshotTurnIds(db2, sessionId) {
|
|
41961
|
-
const rows = db2.prepare("SELECT id, external_turn_id FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41962
|
-
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, r.external_turn_id])));
|
|
41961
|
+
const rows = db2.prepare("SELECT id, external_turn_id, runtime_input_ids FROM turns WHERE session_id = ? AND thread_id IS NULL").all(sessionId);
|
|
41962
|
+
return JSON.stringify(Object.fromEntries(rows.map((r) => [r.id, [r.external_turn_id, r.runtime_input_ids]])));
|
|
41963
41963
|
}
|
|
41964
41964
|
function restoreTurnIds(db2, sessionId, snapshot) {
|
|
41965
41965
|
if (!snapshot) return;
|
|
@@ -41969,19 +41969,40 @@ function restoreTurnIds(db2, sessionId, snapshot) {
|
|
|
41969
41969
|
} catch {
|
|
41970
41970
|
return;
|
|
41971
41971
|
}
|
|
41972
|
-
const
|
|
41973
|
-
|
|
41972
|
+
const updateExternal = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ? AND session_id = ?");
|
|
41973
|
+
const updateBoth = db2.prepare(
|
|
41974
|
+
"UPDATE turns SET external_turn_id = ?, runtime_input_ids = ? WHERE id = ? AND session_id = ?"
|
|
41975
|
+
);
|
|
41976
|
+
for (const [turnId, value] of Object.entries(ids)) {
|
|
41977
|
+
if (Array.isArray(value)) updateBoth.run(value[0] ?? null, value[1] ?? null, turnId, sessionId);
|
|
41978
|
+
else updateExternal.run(value, turnId, sessionId);
|
|
41979
|
+
}
|
|
41980
|
+
}
|
|
41981
|
+
function forkedRuntimeInputIds(raw, map2) {
|
|
41982
|
+
if (!raw) return raw;
|
|
41983
|
+
let ids;
|
|
41984
|
+
try {
|
|
41985
|
+
ids = JSON.parse(raw);
|
|
41986
|
+
} catch {
|
|
41987
|
+
return raw;
|
|
41988
|
+
}
|
|
41989
|
+
if (!Array.isArray(ids)) return raw;
|
|
41990
|
+
return JSON.stringify(ids.map((id) => typeof id === "string" ? map2.get(id) ?? id : id));
|
|
41974
41991
|
}
|
|
41975
41992
|
function applyTurnIdMap(db2, sessionId, map2, upToCreatedAt = null) {
|
|
41976
41993
|
if (map2.size === 0) return;
|
|
41977
41994
|
const rows = db2.prepare(
|
|
41978
|
-
`SELECT id, external_turn_id FROM turns
|
|
41979
|
-
WHERE session_id = ? AND thread_id IS NULL
|
|
41995
|
+
`SELECT id, external_turn_id, runtime_input_ids FROM turns
|
|
41996
|
+
WHERE session_id = ? AND thread_id IS NULL
|
|
41997
|
+
AND (external_turn_id IS NOT NULL OR runtime_input_ids IS NOT NULL)` + (upToCreatedAt ? " AND created_at <= ?" : "")
|
|
41980
41998
|
).all(...upToCreatedAt ? [sessionId, upToCreatedAt] : [sessionId]);
|
|
41981
|
-
const update = db2.prepare("UPDATE turns SET external_turn_id = ? WHERE id = ?");
|
|
41999
|
+
const update = db2.prepare("UPDATE turns SET external_turn_id = ?, runtime_input_ids = ? WHERE id = ?");
|
|
41982
42000
|
for (const row of rows) {
|
|
41983
|
-
const
|
|
41984
|
-
|
|
42001
|
+
const externalId = (row.external_turn_id && map2.get(row.external_turn_id)) ?? row.external_turn_id;
|
|
42002
|
+
const inputIds = forkedRuntimeInputIds(row.runtime_input_ids, map2);
|
|
42003
|
+
if (externalId !== row.external_turn_id || inputIds !== row.runtime_input_ids) {
|
|
42004
|
+
update.run(externalId, inputIds, row.id);
|
|
42005
|
+
}
|
|
41985
42006
|
}
|
|
41986
42007
|
}
|
|
41987
42008
|
function dropRewoundTurns(db2, sessionId) {
|
|
@@ -42560,8 +42581,8 @@ async function registerSessionRoutes(fastify) {
|
|
|
42560
42581
|
for (const turn of turnRows) {
|
|
42561
42582
|
const newTurnId = v4_default();
|
|
42562
42583
|
db2.prepare(
|
|
42563
|
-
`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)
|
|
42564
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42584
|
+
`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)
|
|
42585
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
|
42565
42586
|
).run(
|
|
42566
42587
|
newTurnId,
|
|
42567
42588
|
newSessionId,
|
|
@@ -42570,6 +42591,7 @@ async function registerSessionRoutes(fastify) {
|
|
|
42570
42591
|
turn.thoughts,
|
|
42571
42592
|
turn.token_usage,
|
|
42572
42593
|
(turn.external_turn_id && turnIds.get(turn.external_turn_id)) ?? turn.external_turn_id,
|
|
42594
|
+
forkedRuntimeInputIds(turn.runtime_input_ids, turnIds),
|
|
42573
42595
|
turn.status,
|
|
42574
42596
|
turn.error,
|
|
42575
42597
|
turn.attachments,
|
|
@@ -42804,7 +42826,7 @@ function recoverInterruptedTurns(db2, opts) {
|
|
|
42804
42826
|
WHERE i.status = 'in_progress'`
|
|
42805
42827
|
).all();
|
|
42806
42828
|
const orphaned = open.filter((i) => !skip.entries.has(runtimeEntryKey(i.session_id, i.thread_id)));
|
|
42807
|
-
const
|
|
42829
|
+
const stopTask4 = db2.prepare(
|
|
42808
42830
|
`UPDATE items SET data = json_set(COALESCE(data, '{}'), '$.status', 'stopped')
|
|
42809
42831
|
WHERE id = ? AND json_valid(COALESCE(data, '{}'))`
|
|
42810
42832
|
);
|
|
@@ -42812,7 +42834,7 @@ function recoverInterruptedTurns(db2, opts) {
|
|
|
42812
42834
|
const items = { changes: 0 };
|
|
42813
42835
|
db2.transaction(() => {
|
|
42814
42836
|
for (const item of orphaned) {
|
|
42815
|
-
if (item.type === "background_task")
|
|
42837
|
+
if (item.type === "background_task") stopTask4.run(item.id);
|
|
42816
42838
|
items.changes += failItem.run(now, item.id).changes;
|
|
42817
42839
|
}
|
|
42818
42840
|
})();
|
|
@@ -119934,7 +119956,10 @@ function claudeUserMcpNames(cwd) {
|
|
|
119934
119956
|
const file2 = claudeConfigFile();
|
|
119935
119957
|
return /* @__PURE__ */ new Set([
|
|
119936
119958
|
...jsonServerNames(file2, (json2) => json2.mcpServers),
|
|
119937
|
-
...jsonServerNames(
|
|
119959
|
+
...jsonServerNames(
|
|
119960
|
+
file2,
|
|
119961
|
+
(json2) => json2.projects?.[cwd]?.mcpServers
|
|
119962
|
+
),
|
|
119938
119963
|
...jsonServerNames(path18.join(cwd, ".mcp.json"), (json2) => json2.mcpServers)
|
|
119939
119964
|
]);
|
|
119940
119965
|
}
|
|
@@ -119959,7 +119984,10 @@ function tomlServerNames(file2) {
|
|
|
119959
119984
|
}
|
|
119960
119985
|
function codexUserMcpNames(cwd) {
|
|
119961
119986
|
const home = process.env.CODEX_HOME || path18.join(os6.homedir(), ".codex");
|
|
119962
|
-
return /* @__PURE__ */ new Set([
|
|
119987
|
+
return /* @__PURE__ */ new Set([
|
|
119988
|
+
...tomlServerNames(path18.join(home, "config.toml")),
|
|
119989
|
+
...tomlServerNames(path18.join(cwd, ".codex", "config.toml"))
|
|
119990
|
+
]);
|
|
119963
119991
|
}
|
|
119964
119992
|
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.`;
|
|
119965
119993
|
async function codexBrowserMcp(cwd) {
|
|
@@ -119984,6 +120012,20 @@ async function codexBrowserMcp(cwd) {
|
|
|
119984
120012
|
}
|
|
119985
120013
|
return { args, instructions: mcp.tabtape ? CODEX_BROWSER_CHECK_INSTRUCTIONS : null };
|
|
119986
120014
|
}
|
|
120015
|
+
async function repoburgBrowserMcpServers(_cwd) {
|
|
120016
|
+
const mcp = await browserMcp(/* @__PURE__ */ new Set());
|
|
120017
|
+
const servers = [];
|
|
120018
|
+
if (mcp.tabtape) {
|
|
120019
|
+
servers.push({
|
|
120020
|
+
name: TABTAPE_MCP_NAME,
|
|
120021
|
+
type: "http",
|
|
120022
|
+
url: mcp.tabtape,
|
|
120023
|
+
instructions: CODEX_BROWSER_CHECK_INSTRUCTIONS
|
|
120024
|
+
});
|
|
120025
|
+
}
|
|
120026
|
+
if (mcp.playwright) servers.push({ name: PLAYWRIGHT_MCP_NAME, type: "stdio", ...mcp.playwright });
|
|
120027
|
+
return servers;
|
|
120028
|
+
}
|
|
119987
120029
|
var prepared = false;
|
|
119988
120030
|
function chromiumDownloadCommand(execPath = process.execPath) {
|
|
119989
120031
|
const bin = path18.dirname(execPath);
|
|
@@ -123364,25 +123406,25 @@ function upsertItem(db2, desc, sessionId, turnId, status, broadcastEvent) {
|
|
|
123364
123406
|
}
|
|
123365
123407
|
async function interruptTurn2(sessionId, threadId) {
|
|
123366
123408
|
let entry;
|
|
123367
|
-
let
|
|
123409
|
+
let entryKey2 = null;
|
|
123368
123410
|
if (threadId) {
|
|
123369
|
-
|
|
123370
|
-
entry = sessionMap2.get(
|
|
123411
|
+
entryKey2 = `${sessionId}:thread:${threadId}`;
|
|
123412
|
+
entry = sessionMap2.get(entryKey2);
|
|
123371
123413
|
} else {
|
|
123372
123414
|
entry = sessionMap2.get(sessionId);
|
|
123373
|
-
|
|
123415
|
+
entryKey2 = sessionId;
|
|
123374
123416
|
if (!entry || !entry.turnId) {
|
|
123375
|
-
|
|
123417
|
+
entryKey2 = null;
|
|
123376
123418
|
for (const [key, threadEntry] of sessionMap2) {
|
|
123377
123419
|
if (key.startsWith(`${sessionId}:thread:`) && threadEntry.turnId) {
|
|
123378
123420
|
entry = threadEntry;
|
|
123379
|
-
|
|
123421
|
+
entryKey2 = key;
|
|
123380
123422
|
break;
|
|
123381
123423
|
}
|
|
123382
123424
|
}
|
|
123383
123425
|
}
|
|
123384
123426
|
}
|
|
123385
|
-
if (entry && entry.turnId &&
|
|
123427
|
+
if (entry && entry.turnId && entryKey2) {
|
|
123386
123428
|
const turnId = entry.turnId;
|
|
123387
123429
|
try {
|
|
123388
123430
|
await entry.query.interrupt();
|
|
@@ -123405,7 +123447,7 @@ async function interruptTurn2(sessionId, threadId) {
|
|
|
123405
123447
|
entry.promptQueue.close();
|
|
123406
123448
|
entry.query.close();
|
|
123407
123449
|
streamingMessageIds.delete(turnId);
|
|
123408
|
-
sessionMap2.delete(
|
|
123450
|
+
sessionMap2.delete(entryKey2);
|
|
123409
123451
|
dropBackgroundTasks(sessionId, entry);
|
|
123410
123452
|
}
|
|
123411
123453
|
}
|
|
@@ -124100,7 +124142,7 @@ var RepoburgHttpClient = class {
|
|
|
124100
124142
|
return this.request("POST", "/sessions", dto);
|
|
124101
124143
|
}
|
|
124102
124144
|
async patchSession(id, dto) {
|
|
124103
|
-
return this.request("
|
|
124145
|
+
return this.request("PUT", `/sessions/${id}`, dto);
|
|
124104
124146
|
}
|
|
124105
124147
|
async getSession(id) {
|
|
124106
124148
|
return this.request("GET", `/sessions/${id}`);
|
|
@@ -124109,19 +124151,13 @@ var RepoburgHttpClient = class {
|
|
|
124109
124151
|
return this.request("POST", `/sessions/${sessionId}/inputs`, dto);
|
|
124110
124152
|
}
|
|
124111
124153
|
async getInputWithActions(sessionId, inputId) {
|
|
124112
|
-
return this.request(
|
|
124113
|
-
"GET",
|
|
124114
|
-
`/sessions/${sessionId}/inputs/${inputId}/actions-with-logs`
|
|
124115
|
-
);
|
|
124154
|
+
return this.request("GET", `/sessions/${sessionId}/inputs/${inputId}/actions-with-logs`);
|
|
124116
124155
|
}
|
|
124117
124156
|
async getSessionInputs(sessionId) {
|
|
124118
124157
|
return this.request("GET", `/sessions/${sessionId}/inputs`);
|
|
124119
124158
|
}
|
|
124120
124159
|
async deleteInputsUntilHere(sessionId, anchorInputId) {
|
|
124121
|
-
await this.request(
|
|
124122
|
-
"DELETE",
|
|
124123
|
-
`/sessions/${sessionId}/inputs/${anchorInputId}/until-here`
|
|
124124
|
-
);
|
|
124160
|
+
await this.request("DELETE", `/sessions/${sessionId}/inputs/${anchorInputId}/until-here`);
|
|
124125
124161
|
}
|
|
124126
124162
|
async deleteSession(id) {
|
|
124127
124163
|
await this.request("DELETE", `/sessions/${id}`);
|
|
@@ -124132,11 +124168,24 @@ var RepoburgHttpClient = class {
|
|
|
124132
124168
|
});
|
|
124133
124169
|
}
|
|
124134
124170
|
async cancel(sessionId) {
|
|
124171
|
+
return this.request("POST", `/streaming/${sessionId}/cancel`);
|
|
124172
|
+
}
|
|
124173
|
+
async listBackgroundTasks(sessionId) {
|
|
124174
|
+
const result = await this.request(
|
|
124175
|
+
"GET",
|
|
124176
|
+
`/sessions/${sessionId}/background-tasks`
|
|
124177
|
+
);
|
|
124178
|
+
return result.tasks ?? [];
|
|
124179
|
+
}
|
|
124180
|
+
async stopBackgroundTask(sessionId, taskId) {
|
|
124135
124181
|
return this.request(
|
|
124136
124182
|
"POST",
|
|
124137
|
-
`/
|
|
124183
|
+
`/sessions/${sessionId}/background-tasks/${encodeURIComponent(taskId)}/stop`
|
|
124138
124184
|
);
|
|
124139
124185
|
}
|
|
124186
|
+
async setSessionMcpServers(sessionId, servers) {
|
|
124187
|
+
await this.request("PUT", `/sessions/${sessionId}/mcp-servers`, { servers });
|
|
124188
|
+
}
|
|
124140
124189
|
async getModels() {
|
|
124141
124190
|
const result = await this.request("GET", "/llm-provider/models");
|
|
124142
124191
|
return result.models ?? [];
|
|
@@ -124696,6 +124745,96 @@ async function runThrowawayPrompt(client, options) {
|
|
|
124696
124745
|
}
|
|
124697
124746
|
}
|
|
124698
124747
|
|
|
124748
|
+
// src/repoburg/repoburg-tasks.ts
|
|
124749
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
124750
|
+
import { isAbsolute, join as join6 } from "node:path";
|
|
124751
|
+
var TASK_OUTPUT_MAX2 = 2e4;
|
|
124752
|
+
var REPOBURG_TASK_TYPE = "background_terminal";
|
|
124753
|
+
var NOT_BACKGROUND_COMMAND = `NOT (type = 'background_task' AND json_valid(COALESCE(data, '{}'))
|
|
124754
|
+
AND json_extract(data, '$.task_type') = '${REPOBURG_TASK_TYPE}')`;
|
|
124755
|
+
function taskItemExternalId(taskId) {
|
|
124756
|
+
return `task-${taskId}`;
|
|
124757
|
+
}
|
|
124758
|
+
function taskOutputPath(outputFile, cwd) {
|
|
124759
|
+
if (!outputFile) return null;
|
|
124760
|
+
if (isAbsolute(outputFile)) return outputFile;
|
|
124761
|
+
return cwd ? join6(cwd, outputFile) : null;
|
|
124762
|
+
}
|
|
124763
|
+
function readTaskOutput(path21) {
|
|
124764
|
+
if (!path21) return "";
|
|
124765
|
+
try {
|
|
124766
|
+
const text2 = readFileSync5(path21, "utf-8");
|
|
124767
|
+
return text2.length > TASK_OUTPUT_MAX2 ? text2.slice(-TASK_OUTPUT_MAX2) : text2;
|
|
124768
|
+
} catch {
|
|
124769
|
+
return "";
|
|
124770
|
+
}
|
|
124771
|
+
}
|
|
124772
|
+
function findTaskItem2(db2, sessionId, taskId) {
|
|
124773
|
+
return db2.prepare(
|
|
124774
|
+
`SELECT i.* FROM items i JOIN turns t ON t.id = i.turn_id
|
|
124775
|
+
WHERE t.session_id = ? AND i.external_item_id = ? AND i.type = 'background_task'
|
|
124776
|
+
ORDER BY i.created_at DESC LIMIT 1`
|
|
124777
|
+
).get(sessionId, taskItemExternalId(taskId));
|
|
124778
|
+
}
|
|
124779
|
+
function openTaskItem2(db2, sessionId, turnId, task) {
|
|
124780
|
+
if (findTaskItem2(db2, sessionId, task.task_id)) return;
|
|
124781
|
+
insertItem(
|
|
124782
|
+
db2,
|
|
124783
|
+
sessionId,
|
|
124784
|
+
turnId,
|
|
124785
|
+
taskItemExternalId(task.task_id),
|
|
124786
|
+
"background_task",
|
|
124787
|
+
{
|
|
124788
|
+
task_id: task.task_id,
|
|
124789
|
+
description: task.description,
|
|
124790
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
124791
|
+
subagent_type: null,
|
|
124792
|
+
prompt: task.command,
|
|
124793
|
+
status: "running",
|
|
124794
|
+
summary: null,
|
|
124795
|
+
output_file: task.output_file,
|
|
124796
|
+
output: "",
|
|
124797
|
+
token_count: null,
|
|
124798
|
+
last_tool_name: null
|
|
124799
|
+
},
|
|
124800
|
+
"in_progress",
|
|
124801
|
+
"item:started"
|
|
124802
|
+
);
|
|
124803
|
+
}
|
|
124804
|
+
function updateTaskItem(db2, sessionId, taskId, update) {
|
|
124805
|
+
const row = findTaskItem2(db2, sessionId, taskId);
|
|
124806
|
+
if (!row) return false;
|
|
124807
|
+
if (row.status !== "in_progress") return true;
|
|
124808
|
+
const prev = row.data ? JSON.parse(row.data) : {};
|
|
124809
|
+
const output = readTaskOutput(prev.output_file ?? null) || String(prev.output ?? "");
|
|
124810
|
+
const ended = update.status !== "running";
|
|
124811
|
+
if (!ended && output === prev.output) return true;
|
|
124812
|
+
const data = {
|
|
124813
|
+
...prev,
|
|
124814
|
+
status: update.status,
|
|
124815
|
+
output,
|
|
124816
|
+
...update.summary !== void 0 ? { summary: update.summary } : {},
|
|
124817
|
+
...update.exit_code !== void 0 ? { exit_code: update.exit_code } : {}
|
|
124818
|
+
};
|
|
124819
|
+
const status = !ended ? "in_progress" : update.status === "failed" ? "failed" : "completed";
|
|
124820
|
+
const item = { ...row, data: prev };
|
|
124821
|
+
updateItem(db2, sessionId, row.turn_id, item, data, status);
|
|
124822
|
+
return true;
|
|
124823
|
+
}
|
|
124824
|
+
function taskSummary(task) {
|
|
124825
|
+
const name = `Background command "${task.description}"`;
|
|
124826
|
+
switch (task.status) {
|
|
124827
|
+
case "completed":
|
|
124828
|
+
return `${name} completed (exit code 0)`;
|
|
124829
|
+
case "stopped":
|
|
124830
|
+
return `${name} was stopped`;
|
|
124831
|
+
case "failed":
|
|
124832
|
+
return task.exit_code === null ? `${name} was killed` : `${name} failed with exit code ${task.exit_code}`;
|
|
124833
|
+
default:
|
|
124834
|
+
return `${name} is running`;
|
|
124835
|
+
}
|
|
124836
|
+
}
|
|
124837
|
+
|
|
124699
124838
|
// src/repoburg/turn-projector.ts
|
|
124700
124839
|
var RESULT_TIMEOUT_MS = 15 * 6e4;
|
|
124701
124840
|
var MAX_RESULT_EXTENSIONS = 3;
|
|
@@ -124731,6 +124870,8 @@ var TurnProjector = class {
|
|
|
124731
124870
|
switch (message.type) {
|
|
124732
124871
|
case "system":
|
|
124733
124872
|
if (message.subtype === "compact_boundary") this.handleCompactBoundary(message);
|
|
124873
|
+
else if (message.subtype === "task_started") this.handleTaskStarted(message);
|
|
124874
|
+
else if (message.subtype === "task_notification") this.handleTaskNotification(message);
|
|
124734
124875
|
break;
|
|
124735
124876
|
case "stream_event":
|
|
124736
124877
|
this.handleStreamEvent(message);
|
|
@@ -125060,6 +125201,27 @@ var TurnProjector = class {
|
|
|
125060
125201
|
}
|
|
125061
125202
|
this.touch();
|
|
125062
125203
|
}
|
|
125204
|
+
/** A background task started in this turn → its background_task item. */
|
|
125205
|
+
handleTaskStarted(msg) {
|
|
125206
|
+
openTaskItem2(getDb(), this.deps.agentPaneSessionId, this.deps.turnId, {
|
|
125207
|
+
task_id: msg.task_id,
|
|
125208
|
+
description: msg.description,
|
|
125209
|
+
command: msg.command,
|
|
125210
|
+
output_file: taskOutputPath(msg.output_file, this.deps.cwd)
|
|
125211
|
+
});
|
|
125212
|
+
this.deps.onTaskEvent?.(msg);
|
|
125213
|
+
this.touch();
|
|
125214
|
+
}
|
|
125215
|
+
/** A background task ended — maybe one an earlier turn started. */
|
|
125216
|
+
handleTaskNotification(msg) {
|
|
125217
|
+
updateTaskItem(getDb(), this.deps.agentPaneSessionId, msg.task_id, {
|
|
125218
|
+
status: msg.status,
|
|
125219
|
+
summary: msg.summary,
|
|
125220
|
+
exit_code: msg.exit_code
|
|
125221
|
+
});
|
|
125222
|
+
this.deps.onTaskEvent?.(msg);
|
|
125223
|
+
this.touch();
|
|
125224
|
+
}
|
|
125063
125225
|
handleResult(msg) {
|
|
125064
125226
|
switch (msg.subtype) {
|
|
125065
125227
|
case "success":
|
|
@@ -125224,12 +125386,9 @@ var TurnProjector = class {
|
|
|
125224
125386
|
closeOpenItems(status) {
|
|
125225
125387
|
const db2 = getDb();
|
|
125226
125388
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
125227
|
-
db2.prepare(
|
|
125228
|
-
status
|
|
125229
|
-
|
|
125230
|
-
this.deps.turnId,
|
|
125231
|
-
"in_progress"
|
|
125232
|
-
);
|
|
125389
|
+
db2.prepare(
|
|
125390
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
125391
|
+
).run(status, now, this.deps.turnId, "in_progress");
|
|
125233
125392
|
}
|
|
125234
125393
|
// -------------------------------------------------------------------------
|
|
125235
125394
|
// Watch-dog + snapshot reconcile
|
|
@@ -125406,9 +125565,10 @@ async function ensureSession(session, client, baseUrl) {
|
|
|
125406
125565
|
repoburgSessionId: session.external_thread_id,
|
|
125407
125566
|
client,
|
|
125408
125567
|
baseUrl,
|
|
125409
|
-
|
|
125410
|
-
//
|
|
125568
|
+
// undefined forces a re-push of model and effort on the next turn —
|
|
125569
|
+
// heals switches made while the pane was down, and sessions created
|
|
125411
125570
|
// before unsafe effort values (e.g. ollama xhigh) were clamped.
|
|
125571
|
+
modelId: void 0,
|
|
125412
125572
|
reasoningEffort: void 0,
|
|
125413
125573
|
threadId: null,
|
|
125414
125574
|
contextWindow: null,
|
|
@@ -125453,6 +125613,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
125453
125613
|
const db2 = getDb();
|
|
125454
125614
|
const thread = db2.prepare("SELECT external_thread_id FROM discussion_threads WHERE id = ?").get(turn.thread_id);
|
|
125455
125615
|
let runtimeId = thread?.external_thread_id ?? null;
|
|
125616
|
+
const forked = !!runtimeId;
|
|
125456
125617
|
if (!runtimeId) {
|
|
125457
125618
|
const created = await client.createSession({
|
|
125458
125619
|
session_title: session.title ? `Discussion: ${session.title}` : "Discussion",
|
|
@@ -125472,7 +125633,7 @@ async function ensureThreadSession(session, turn, client, baseUrl) {
|
|
|
125472
125633
|
repoburgSessionId: runtimeId,
|
|
125473
125634
|
client,
|
|
125474
125635
|
baseUrl,
|
|
125475
|
-
modelId: session.model || null,
|
|
125636
|
+
modelId: forked ? void 0 : session.model || null,
|
|
125476
125637
|
reasoningEffort: void 0,
|
|
125477
125638
|
// re-pushed on the first thread turn
|
|
125478
125639
|
threadId: turn.thread_id,
|
|
@@ -125523,12 +125684,9 @@ function failTurn3(entry, error51) {
|
|
|
125523
125684
|
now,
|
|
125524
125685
|
active.turnId
|
|
125525
125686
|
);
|
|
125526
|
-
db2.prepare(
|
|
125527
|
-
|
|
125528
|
-
|
|
125529
|
-
active.turnId,
|
|
125530
|
-
"in_progress"
|
|
125531
|
-
);
|
|
125687
|
+
db2.prepare(
|
|
125688
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
125689
|
+
).run("failed", now, active.turnId, "in_progress");
|
|
125532
125690
|
recomputeSessionRunning(db2, entry.agentPaneSessionId, "failed");
|
|
125533
125691
|
broadcast("turn:failed", { sessionId: entry.agentPaneSessionId, turnId: active.turnId, error: error51 });
|
|
125534
125692
|
}
|
|
@@ -125657,6 +125815,16 @@ async function startTurn4(session, turn) {
|
|
|
125657
125815
|
entry.baseUrl = baseUrl;
|
|
125658
125816
|
entry.client = client;
|
|
125659
125817
|
}
|
|
125818
|
+
startingEntries.add(entry);
|
|
125819
|
+
try {
|
|
125820
|
+
await runTurn2(session, turn, entry, firstInput);
|
|
125821
|
+
} finally {
|
|
125822
|
+
startingEntries.delete(entry);
|
|
125823
|
+
}
|
|
125824
|
+
}
|
|
125825
|
+
async function runTurn2(session, turn, entry, firstInput) {
|
|
125826
|
+
const db2 = getDb();
|
|
125827
|
+
await syncSessionMcp(entry, session.cwd ?? process.cwd());
|
|
125660
125828
|
const wantedModel = session.model || null;
|
|
125661
125829
|
const wantedEffort = mapReasoningEffort(session.model_reasoning_effort);
|
|
125662
125830
|
if (wantedModel !== entry.modelId || wantedEffort !== entry.reasoningEffort) {
|
|
@@ -125676,7 +125844,11 @@ async function startTurn4(session, turn) {
|
|
|
125676
125844
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("running", now, turn.id);
|
|
125677
125845
|
setSessionStatus3(db2, session.id, 1, "running", now);
|
|
125678
125846
|
broadcast("turn:started", { sessionId: session.id, turnId: turn.id });
|
|
125679
|
-
|
|
125847
|
+
let state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
125848
|
+
if (state?.turnInFlight && !(entry.activeTurn && !entry.activeTurn.projector.isDone)) {
|
|
125849
|
+
await entry.client.cancel(entry.repoburgSessionId).catch(() => void 0);
|
|
125850
|
+
state = await waitForRunEnd(entry, RUN_END_WAIT_MS) ?? state;
|
|
125851
|
+
}
|
|
125680
125852
|
if (state) {
|
|
125681
125853
|
const cursor = {
|
|
125682
125854
|
bootId: state.bootId,
|
|
@@ -125694,7 +125866,10 @@ async function startTurn4(session, turn) {
|
|
|
125694
125866
|
// Late-bound — the window resolves from the runtime catalog while the
|
|
125695
125867
|
// turn streams and is read at turn completion.
|
|
125696
125868
|
getContextWindow: () => entry.contextWindow,
|
|
125697
|
-
...state ? { firstSeq: state.lastSeq + 1 } : {}
|
|
125869
|
+
...state ? { firstSeq: state.lastSeq + 1 } : {},
|
|
125870
|
+
cwd: session.cwd ?? null,
|
|
125871
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
125872
|
+
onFinished: () => onTurnFinished(entry)
|
|
125698
125873
|
});
|
|
125699
125874
|
entry.activeTurn = {
|
|
125700
125875
|
turnId: turn.id,
|
|
@@ -125723,6 +125898,245 @@ async function startTurn4(session, turn) {
|
|
|
125723
125898
|
failTurn3(entry, err.message);
|
|
125724
125899
|
}
|
|
125725
125900
|
}
|
|
125901
|
+
var TASK_POLL_MS = 2e3;
|
|
125902
|
+
var WAKE_WATCH_MS = 2e4;
|
|
125903
|
+
var RUN_END_WAIT_MS = 1e4;
|
|
125904
|
+
var taskStates = /* @__PURE__ */ new WeakMap();
|
|
125905
|
+
var startingEntries = /* @__PURE__ */ new Set();
|
|
125906
|
+
var publishedTasks = /* @__PURE__ */ new Map();
|
|
125907
|
+
function taskStateOf(entry) {
|
|
125908
|
+
let state = taskStates.get(entry);
|
|
125909
|
+
if (!state) {
|
|
125910
|
+
state = { running: /* @__PURE__ */ new Map(), timer: null, polling: false, watchUntil: 0 };
|
|
125911
|
+
taskStates.set(entry, state);
|
|
125912
|
+
}
|
|
125913
|
+
return state;
|
|
125914
|
+
}
|
|
125915
|
+
function taskPollMs2() {
|
|
125916
|
+
const fromEnv = Number(process.env.AGENT_PANE_REPOBURG_TASK_POLL_MS);
|
|
125917
|
+
return Number.isFinite(fromEnv) && fromEnv > 0 ? fromEnv : TASK_POLL_MS;
|
|
125918
|
+
}
|
|
125919
|
+
function sessionCwd(sessionId) {
|
|
125920
|
+
try {
|
|
125921
|
+
const row = getDb().prepare("SELECT cwd FROM sessions WHERE id = ?").get(sessionId);
|
|
125922
|
+
return row?.cwd ?? null;
|
|
125923
|
+
} catch {
|
|
125924
|
+
return null;
|
|
125925
|
+
}
|
|
125926
|
+
}
|
|
125927
|
+
function entryKey(entry) {
|
|
125928
|
+
return entry.threadId ? `${entry.agentPaneSessionId}:thread:${entry.threadId}` : entry.agentPaneSessionId;
|
|
125929
|
+
}
|
|
125930
|
+
function onTaskEvent(entry, message) {
|
|
125931
|
+
const state = taskStateOf(entry);
|
|
125932
|
+
if (message.subtype === "task_started") {
|
|
125933
|
+
state.running.set(message.task_id, {
|
|
125934
|
+
task_id: message.task_id,
|
|
125935
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
125936
|
+
description: message.description
|
|
125937
|
+
});
|
|
125938
|
+
} else {
|
|
125939
|
+
state.running.delete(message.task_id);
|
|
125940
|
+
state.watchUntil = Date.now() + WAKE_WATCH_MS;
|
|
125941
|
+
}
|
|
125942
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
125943
|
+
ensureTaskPolling(entry);
|
|
125944
|
+
}
|
|
125945
|
+
function onTurnFinished(entry) {
|
|
125946
|
+
const state = taskStates.get(entry);
|
|
125947
|
+
if (!state) return;
|
|
125948
|
+
state.watchUntil = Math.max(state.watchUntil, Date.now() + WAKE_WATCH_MS);
|
|
125949
|
+
ensureTaskPolling(entry);
|
|
125950
|
+
}
|
|
125951
|
+
function sessionTasks(sessionId) {
|
|
125952
|
+
const tasks = [];
|
|
125953
|
+
for (const [key, entry] of sessionMap3) {
|
|
125954
|
+
if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
|
|
125955
|
+
const state = taskStates.get(entry);
|
|
125956
|
+
if (state) tasks.push(...state.running.values());
|
|
125957
|
+
}
|
|
125958
|
+
return tasks;
|
|
125959
|
+
}
|
|
125960
|
+
function publishTasks2(sessionId) {
|
|
125961
|
+
const tasks = sessionTasks(sessionId);
|
|
125962
|
+
const json2 = JSON.stringify(tasks);
|
|
125963
|
+
if ((publishedTasks.get(sessionId) ?? "[]") === json2) return;
|
|
125964
|
+
if (tasks.length > 0) publishedTasks.set(sessionId, json2);
|
|
125965
|
+
else publishedTasks.delete(sessionId);
|
|
125966
|
+
broadcast("background_tasks", { sessionId, tasks });
|
|
125967
|
+
}
|
|
125968
|
+
function ensureTaskPolling(entry) {
|
|
125969
|
+
const state = taskStateOf(entry);
|
|
125970
|
+
if (state.timer || !entry.client.listBackgroundTasks) return;
|
|
125971
|
+
if (state.running.size === 0 && Date.now() >= state.watchUntil) return;
|
|
125972
|
+
state.timer = setInterval(() => void pollTasks(entry), taskPollMs2());
|
|
125973
|
+
state.timer.unref?.();
|
|
125974
|
+
}
|
|
125975
|
+
function stopTaskPolling2(entry) {
|
|
125976
|
+
const state = taskStates.get(entry);
|
|
125977
|
+
if (!state?.timer) return;
|
|
125978
|
+
clearInterval(state.timer);
|
|
125979
|
+
state.timer = null;
|
|
125980
|
+
}
|
|
125981
|
+
async function pollTasks(entry) {
|
|
125982
|
+
const state = taskStateOf(entry);
|
|
125983
|
+
if (state.polling) return;
|
|
125984
|
+
if (sessionMap3.get(entryKey(entry)) !== entry) {
|
|
125985
|
+
stopTaskPolling2(entry);
|
|
125986
|
+
return;
|
|
125987
|
+
}
|
|
125988
|
+
state.polling = true;
|
|
125989
|
+
try {
|
|
125990
|
+
const tasks = await entry.client.listBackgroundTasks(entry.repoburgSessionId);
|
|
125991
|
+
const db2 = getDb();
|
|
125992
|
+
const listed = new Set(tasks.map((task) => task.task_id));
|
|
125993
|
+
for (const task of tasks) {
|
|
125994
|
+
if (task.status === "running") {
|
|
125995
|
+
state.running.set(task.task_id, {
|
|
125996
|
+
task_id: task.task_id,
|
|
125997
|
+
task_type: REPOBURG_TASK_TYPE,
|
|
125998
|
+
description: task.description
|
|
125999
|
+
});
|
|
126000
|
+
updateTaskItem(db2, entry.agentPaneSessionId, task.task_id, { status: "running" });
|
|
126001
|
+
} else if (state.running.delete(task.task_id)) {
|
|
126002
|
+
state.watchUntil = Date.now() + WAKE_WATCH_MS;
|
|
126003
|
+
updateTaskItem(db2, entry.agentPaneSessionId, task.task_id, {
|
|
126004
|
+
status: task.status,
|
|
126005
|
+
summary: taskSummary(task),
|
|
126006
|
+
exit_code: task.exit_code
|
|
126007
|
+
});
|
|
126008
|
+
}
|
|
126009
|
+
}
|
|
126010
|
+
for (const taskId of [...state.running.keys()]) {
|
|
126011
|
+
if (listed.has(taskId)) continue;
|
|
126012
|
+
state.running.delete(taskId);
|
|
126013
|
+
updateTaskItem(db2, entry.agentPaneSessionId, taskId, {
|
|
126014
|
+
status: "stopped",
|
|
126015
|
+
summary: "The Repoburg backend stopped running this task.",
|
|
126016
|
+
exit_code: null
|
|
126017
|
+
});
|
|
126018
|
+
}
|
|
126019
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
126020
|
+
await attachWakeRun(entry);
|
|
126021
|
+
} catch (err) {
|
|
126022
|
+
if (httpStatus(err) === 404) {
|
|
126023
|
+
state.running.clear();
|
|
126024
|
+
state.watchUntil = 0;
|
|
126025
|
+
publishTasks2(entry.agentPaneSessionId);
|
|
126026
|
+
} else if (isConnectionError(err)) {
|
|
126027
|
+
invalidateBackend(entry.baseUrl);
|
|
126028
|
+
}
|
|
126029
|
+
} finally {
|
|
126030
|
+
state.polling = false;
|
|
126031
|
+
if (state.running.size === 0 && Date.now() >= state.watchUntil) stopTaskPolling2(entry);
|
|
126032
|
+
}
|
|
126033
|
+
}
|
|
126034
|
+
function entryBusy(entry) {
|
|
126035
|
+
return startingEntries.has(entry) || !!entry.activeTurn && !entry.activeTurn.projector.isDone;
|
|
126036
|
+
}
|
|
126037
|
+
async function attachWakeRun(entry) {
|
|
126038
|
+
if (entryBusy(entry)) return;
|
|
126039
|
+
const state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
126040
|
+
if (!state || entryBusy(entry)) return;
|
|
126041
|
+
const previous = entry.activeTurn;
|
|
126042
|
+
const handled = previous && previous.bootId === state.bootId && previous.lastSeq !== null ? previous.lastSeq : null;
|
|
126043
|
+
const missedRun = handled !== null && !previous?.cancelled && state.lastResult !== null && (state.lastResult.seq ?? 0) > handled;
|
|
126044
|
+
if (!state.turnInFlight && !missedRun) return;
|
|
126045
|
+
const db2 = getDb();
|
|
126046
|
+
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);
|
|
126047
|
+
if (!turn || turn.status === "running" || turn.status === "pending") return;
|
|
126048
|
+
const fromSeq = handled ?? state.lastResult?.seq ?? 0;
|
|
126049
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
126050
|
+
const cursor = {
|
|
126051
|
+
bootId: state.bootId,
|
|
126052
|
+
firstSeq: fromSeq + 1,
|
|
126053
|
+
baseUrl: entry.baseUrl,
|
|
126054
|
+
runtimeSessionId: entry.repoburgSessionId
|
|
126055
|
+
};
|
|
126056
|
+
db2.prepare("UPDATE turns SET status = 'running', error = NULL, stream_cursor = ?, updated_at = ? WHERE id = ?").run(
|
|
126057
|
+
JSON.stringify(cursor),
|
|
126058
|
+
now,
|
|
126059
|
+
turn.id
|
|
126060
|
+
);
|
|
126061
|
+
setSessionStatus3(db2, entry.agentPaneSessionId, 1, "running", now);
|
|
126062
|
+
broadcast("turn:started", { sessionId: entry.agentPaneSessionId, turnId: turn.id });
|
|
126063
|
+
const projector = new TurnProjector({
|
|
126064
|
+
agentPaneSessionId: entry.agentPaneSessionId,
|
|
126065
|
+
turnId: turn.id,
|
|
126066
|
+
repoburgSessionId: entry.repoburgSessionId,
|
|
126067
|
+
client: entry.client,
|
|
126068
|
+
getContextWindow: () => entry.contextWindow,
|
|
126069
|
+
firstSeq: fromSeq + 1,
|
|
126070
|
+
cwd: sessionCwd(entry.agentPaneSessionId),
|
|
126071
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
126072
|
+
onFinished: () => onTurnFinished(entry)
|
|
126073
|
+
});
|
|
126074
|
+
entry.activeTurn = {
|
|
126075
|
+
turnId: turn.id,
|
|
126076
|
+
projector,
|
|
126077
|
+
sseAbort: new AbortController(),
|
|
126078
|
+
cancelled: false,
|
|
126079
|
+
bootId: state.bootId,
|
|
126080
|
+
lastSeq: fromSeq
|
|
126081
|
+
};
|
|
126082
|
+
console.log(`[repoburg] session ${entry.agentPaneSessionId}: a background task ended, turn ${turn.id} runs again`);
|
|
126083
|
+
runStreamLoop(entry, projector).catch((err) => {
|
|
126084
|
+
console.error("[repoburg] stream loop crashed:", err);
|
|
126085
|
+
failTurn3(entry, `Stream loop failed: ${err.message}`);
|
|
126086
|
+
});
|
|
126087
|
+
}
|
|
126088
|
+
async function waitForRunEnd(entry, timeoutMs) {
|
|
126089
|
+
const end = Date.now() + timeoutMs;
|
|
126090
|
+
for (; ; ) {
|
|
126091
|
+
const state = await getAgentRuntimeState(entry.baseUrl, entry.repoburgSessionId).catch(() => null);
|
|
126092
|
+
if (!state || !state.turnInFlight || Date.now() >= end) return state;
|
|
126093
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
126094
|
+
}
|
|
126095
|
+
}
|
|
126096
|
+
async function stopTask3(sessionId, taskId) {
|
|
126097
|
+
for (const [key, entry] of sessionMap3) {
|
|
126098
|
+
if (key !== sessionId && !key.startsWith(`${sessionId}:thread:`)) continue;
|
|
126099
|
+
const state = taskStates.get(entry);
|
|
126100
|
+
if (!state?.running.has(taskId) || !entry.client.stopBackgroundTask) continue;
|
|
126101
|
+
const task = await entry.client.stopBackgroundTask(entry.repoburgSessionId, taskId);
|
|
126102
|
+
state.running.delete(taskId);
|
|
126103
|
+
updateTaskItem(getDb(), sessionId, taskId, {
|
|
126104
|
+
status: task.status === "running" ? "stopped" : task.status,
|
|
126105
|
+
summary: taskSummary(task),
|
|
126106
|
+
exit_code: task.exit_code
|
|
126107
|
+
});
|
|
126108
|
+
publishTasks2(sessionId);
|
|
126109
|
+
return;
|
|
126110
|
+
}
|
|
126111
|
+
throw new Error(`No running background task ${taskId} in this session`);
|
|
126112
|
+
}
|
|
126113
|
+
function listBackgroundTasks3() {
|
|
126114
|
+
const bySession = {};
|
|
126115
|
+
for (const entry of sessionMap3.values()) {
|
|
126116
|
+
const tasks = sessionTasks(entry.agentPaneSessionId);
|
|
126117
|
+
if (tasks.length > 0) bySession[entry.agentPaneSessionId] = tasks;
|
|
126118
|
+
}
|
|
126119
|
+
return bySession;
|
|
126120
|
+
}
|
|
126121
|
+
var pushedMcp = /* @__PURE__ */ new Map();
|
|
126122
|
+
var noSessionMcp = /* @__PURE__ */ new Set();
|
|
126123
|
+
async function syncSessionMcp(entry, cwd) {
|
|
126124
|
+
if (!entry.client.setSessionMcpServers || noSessionMcp.has(entry.baseUrl)) return;
|
|
126125
|
+
try {
|
|
126126
|
+
const servers = await repoburgBrowserMcpServers(cwd);
|
|
126127
|
+
const json2 = JSON.stringify(servers);
|
|
126128
|
+
const key = `${entry.baseUrl} ${entry.repoburgSessionId}`;
|
|
126129
|
+
if (pushedMcp.get(key) === json2) return;
|
|
126130
|
+
await entry.client.setSessionMcpServers(entry.repoburgSessionId, servers);
|
|
126131
|
+
pushedMcp.set(key, json2);
|
|
126132
|
+
} catch (err) {
|
|
126133
|
+
if (httpStatus(err) === 404 || httpStatus(err) === 400) {
|
|
126134
|
+
noSessionMcp.add(entry.baseUrl);
|
|
126135
|
+
return;
|
|
126136
|
+
}
|
|
126137
|
+
console.warn("[repoburg] could not set the session MCP servers:", err.message);
|
|
126138
|
+
}
|
|
126139
|
+
}
|
|
125726
126140
|
function parseCursor(raw) {
|
|
125727
126141
|
if (!raw) return null;
|
|
125728
126142
|
try {
|
|
@@ -125781,9 +126195,9 @@ async function adoptRepoburgTurns(db2, result) {
|
|
|
125781
126195
|
repoburgSessionId: cursor.runtimeSessionId,
|
|
125782
126196
|
client: new RepoburgHttpClient(cursor.baseUrl),
|
|
125783
126197
|
baseUrl: cursor.baseUrl,
|
|
125784
|
-
modelId:
|
|
126198
|
+
modelId: void 0,
|
|
126199
|
+
// model and effort re-pushed on the next turn
|
|
125785
126200
|
reasoningEffort: void 0,
|
|
125786
|
-
// re-pushed on the next turn
|
|
125787
126201
|
threadId: row.thread_id,
|
|
125788
126202
|
contextWindow: null,
|
|
125789
126203
|
modelsResolved: false,
|
|
@@ -125796,7 +126210,10 @@ async function adoptRepoburgTurns(db2, result) {
|
|
|
125796
126210
|
repoburgSessionId: cursor.runtimeSessionId,
|
|
125797
126211
|
client: entry.client,
|
|
125798
126212
|
getContextWindow: () => entry.contextWindow,
|
|
125799
|
-
firstSeq: cursor.firstSeq
|
|
126213
|
+
firstSeq: cursor.firstSeq,
|
|
126214
|
+
cwd: sessionCwd(row.session_id),
|
|
126215
|
+
onTaskEvent: (message) => onTaskEvent(entry, message),
|
|
126216
|
+
onFinished: () => onTurnFinished(entry)
|
|
125800
126217
|
});
|
|
125801
126218
|
entry.activeTurn = {
|
|
125802
126219
|
turnId: row.id,
|
|
@@ -125839,12 +126256,9 @@ async function interruptTurn3(sessionId, threadId) {
|
|
|
125839
126256
|
const db2 = getDb();
|
|
125840
126257
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
125841
126258
|
db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("aborted", now, active.turnId);
|
|
125842
|
-
db2.prepare(
|
|
125843
|
-
|
|
125844
|
-
|
|
125845
|
-
active.turnId,
|
|
125846
|
-
"in_progress"
|
|
125847
|
-
);
|
|
126259
|
+
db2.prepare(
|
|
126260
|
+
`UPDATE items SET status = ?, updated_at = ? WHERE turn_id = ? AND status = ? AND ${NOT_BACKGROUND_COMMAND}`
|
|
126261
|
+
).run("completed", now, active.turnId, "in_progress");
|
|
125848
126262
|
recomputeSessionRunning(db2, sessionId);
|
|
125849
126263
|
broadcast("turn:cancelled", { sessionId, turnId: active.turnId });
|
|
125850
126264
|
return true;
|
|
@@ -125858,6 +126272,7 @@ function clearThread3(sessionId) {
|
|
|
125858
126272
|
active.projector.close();
|
|
125859
126273
|
active.sseAbort.abort();
|
|
125860
126274
|
}
|
|
126275
|
+
stopTaskPolling2(entry);
|
|
125861
126276
|
sessionMap3.delete(key);
|
|
125862
126277
|
}
|
|
125863
126278
|
}
|
|
@@ -125871,6 +126286,7 @@ function clearThreadBranch3(sessionId, threadId) {
|
|
|
125871
126286
|
active.projector.close();
|
|
125872
126287
|
active.sseAbort.abort();
|
|
125873
126288
|
}
|
|
126289
|
+
stopTaskPolling2(entry);
|
|
125874
126290
|
sessionMap3.delete(key);
|
|
125875
126291
|
}
|
|
125876
126292
|
}
|
|
@@ -125920,8 +126336,15 @@ async function forkSession2(session, targetTurn) {
|
|
|
125920
126336
|
}
|
|
125921
126337
|
const client = await resolveClient(session);
|
|
125922
126338
|
const forked = await client.forkSession(session.external_thread_id, anchor);
|
|
126339
|
+
forkInputIds.set(forked.id, new Map(Object.entries(forked.input_id_map ?? {})));
|
|
125923
126340
|
return forked.id;
|
|
125924
126341
|
}
|
|
126342
|
+
var forkInputIds = /* @__PURE__ */ new Map();
|
|
126343
|
+
async function forkedTurnIds2(_session, forkedId) {
|
|
126344
|
+
const ids = forkInputIds.get(forkedId) ?? /* @__PURE__ */ new Map();
|
|
126345
|
+
forkInputIds.delete(forkedId);
|
|
126346
|
+
return ids;
|
|
126347
|
+
}
|
|
125925
126348
|
var THREAD_SUMMARY_TIMEOUT_MS = 12e4;
|
|
125926
126349
|
async function summarizeThread(session, _thread, transcript, directives) {
|
|
125927
126350
|
try {
|
|
@@ -125945,8 +126368,12 @@ function clearAllThreads3() {
|
|
|
125945
126368
|
active.projector.close();
|
|
125946
126369
|
active.sseAbort.abort();
|
|
125947
126370
|
}
|
|
126371
|
+
stopTaskPolling2(entry);
|
|
125948
126372
|
}
|
|
125949
126373
|
sessionMap3.clear();
|
|
126374
|
+
publishedTasks.clear();
|
|
126375
|
+
pushedMcp.clear();
|
|
126376
|
+
noSessionMcp.clear();
|
|
125950
126377
|
}
|
|
125951
126378
|
async function getModels3(cwd) {
|
|
125952
126379
|
try {
|
|
@@ -126049,7 +126476,10 @@ var repoburgProvider = {
|
|
|
126049
126476
|
getCommands: getCommands3,
|
|
126050
126477
|
rewindRuntime,
|
|
126051
126478
|
forkSession: forkSession2,
|
|
126479
|
+
forkedTurnIds: forkedTurnIds2,
|
|
126052
126480
|
summarizeThread,
|
|
126481
|
+
stopTask: stopTask3,
|
|
126482
|
+
listBackgroundTasks: listBackgroundTasks3,
|
|
126053
126483
|
shutdown: shutdown3
|
|
126054
126484
|
};
|
|
126055
126485
|
|