chatroom-cli 1.101.5 → 1.102.0
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/dist/index.js
CHANGED
|
@@ -28548,13 +28548,6 @@ function prefixCatalogModelsWithInfer(infer, models) {
|
|
|
28548
28548
|
var init_model_provider = () => {};
|
|
28549
28549
|
|
|
28550
28550
|
// src/daemon/infrastructure/local/harness/services/cursor-sdk/cursor-sdk-package.ts
|
|
28551
|
-
var exports_cursor_sdk_package = {};
|
|
28552
|
-
__export(exports_cursor_sdk_package, {
|
|
28553
|
-
importBundledCursorSdk: () => importBundledCursorSdk,
|
|
28554
|
-
getBundledCursorSdkVersion: () => getBundledCursorSdkVersion,
|
|
28555
|
-
formatCursorSdkLoadError: () => formatCursorSdkLoadError,
|
|
28556
|
-
formatCursorSdkError: () => formatCursorSdkError
|
|
28557
|
-
});
|
|
28558
28551
|
import { existsSync, readFileSync as readFileSync3 } from "node:fs";
|
|
28559
28552
|
import { createRequire as createRequire3 } from "node:module";
|
|
28560
28553
|
import { dirname as dirname2, join as join7 } from "node:path";
|
|
@@ -29396,13 +29389,6 @@ var init_claude = __esm(() => {
|
|
|
29396
29389
|
});
|
|
29397
29390
|
|
|
29398
29391
|
// src/daemon/infrastructure/local/harness/services/claude-sdk/claude-sdk-package.ts
|
|
29399
|
-
var exports_claude_sdk_package = {};
|
|
29400
|
-
__export(exports_claude_sdk_package, {
|
|
29401
|
-
resolvePathToClaudeCodeExecutable: () => resolvePathToClaudeCodeExecutable,
|
|
29402
|
-
importBundledClaudeSdk: () => importBundledClaudeSdk,
|
|
29403
|
-
getBundledClaudeSdkVersion: () => getBundledClaudeSdkVersion,
|
|
29404
|
-
formatClaudeSdkLoadError: () => formatClaudeSdkLoadError
|
|
29405
|
-
});
|
|
29406
29392
|
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
|
|
29407
29393
|
import { createRequire as createRequire4 } from "node:module";
|
|
29408
29394
|
import { dirname as dirname3, join as join8 } from "node:path";
|
|
@@ -35120,12 +35106,6 @@ var init_opencode_sdk = __esm(() => {
|
|
|
35120
35106
|
});
|
|
35121
35107
|
|
|
35122
35108
|
// src/daemon/infrastructure/local/harness/services/pi-sdk/pi-sdk-package.ts
|
|
35123
|
-
var exports_pi_sdk_package = {};
|
|
35124
|
-
__export(exports_pi_sdk_package, {
|
|
35125
|
-
importBundledPiSdk: () => importBundledPiSdk,
|
|
35126
|
-
getBundledPiSdkVersion: () => getBundledPiSdkVersion,
|
|
35127
|
-
formatPiSdkLoadError: () => formatPiSdkLoadError
|
|
35128
|
-
});
|
|
35129
35109
|
import { existsSync as existsSync5, readFileSync as readFileSync7 } from "node:fs";
|
|
35130
35110
|
import { dirname as dirname6, join as join11 } from "node:path";
|
|
35131
35111
|
import { fileURLToPath as fileURLToPath5, pathToFileURL as pathToFileURL4 } from "node:url";
|
|
@@ -85390,28 +85370,6 @@ async function recoverAgentState(deps) {
|
|
|
85390
85370
|
log4(` \uD83D\uDD00 Registered ${registeredCount} workspace(s) on recovery`);
|
|
85391
85371
|
}
|
|
85392
85372
|
}
|
|
85393
|
-
try {
|
|
85394
|
-
const managedSessions = await deps.backend.getMachineHarnessSessions();
|
|
85395
|
-
let orphanSessionCount = 0;
|
|
85396
|
-
let totalFailedTurns = 0;
|
|
85397
|
-
for (const hs of managedSessions) {
|
|
85398
|
-
const hasActiveSlot = activeSlots.some((s) => s.chatroomId === hs.chatroomId);
|
|
85399
|
-
if (hasActiveSlot)
|
|
85400
|
-
continue;
|
|
85401
|
-
try {
|
|
85402
|
-
const result = await deps.backend.markOrphanTurnsFailed(hs.harnessSessionId);
|
|
85403
|
-
orphanSessionCount++;
|
|
85404
|
-
totalFailedTurns += result.failedTurns;
|
|
85405
|
-
} catch (err) {
|
|
85406
|
-
warn(`[daemon] ⚠️ Failed to mark orphan turns for session ${hs.harnessSessionId}: ${err.message}`);
|
|
85407
|
-
}
|
|
85408
|
-
}
|
|
85409
|
-
if (orphanSessionCount > 0) {
|
|
85410
|
-
log4(` \uD83E\uDDF9 Marked ${totalFailedTurns} turns as failed across ${orphanSessionCount} orphan sessions`);
|
|
85411
|
-
}
|
|
85412
|
-
} catch (err) {
|
|
85413
|
-
warn(`[daemon] ⚠️ Orphan turn cleanup failed: ${err.message}`);
|
|
85414
|
-
}
|
|
85415
85373
|
}
|
|
85416
85374
|
|
|
85417
85375
|
// ../../services/backend/src/domain/usecase/agent/build-agent-restart-event.ts
|
|
@@ -101420,15 +101378,6 @@ function createRecoverAgentStateDeps(agentMgr, session2) {
|
|
|
101420
101378
|
workingDir: args2.workingDir,
|
|
101421
101379
|
hostname: session2.config?.hostname ?? "unknown",
|
|
101422
101380
|
registeredBy: args2.registeredBy
|
|
101423
|
-
}),
|
|
101424
|
-
getMachineHarnessSessions: async () => session2.backend.query(api.daemon.directHarness.turns.getMachineHarnessSessions, {
|
|
101425
|
-
sessionId: session2.sessionId,
|
|
101426
|
-
machineId: session2.machineId
|
|
101427
|
-
}),
|
|
101428
|
-
markOrphanTurnsFailed: async (harnessSessionId) => session2.backend.mutation(api.daemon.directHarness.turns.markOrphanTurnsFailed, {
|
|
101429
|
-
sessionId: session2.sessionId,
|
|
101430
|
-
machineId: session2.machineId,
|
|
101431
|
-
harnessSessionId
|
|
101432
101381
|
})
|
|
101433
101382
|
},
|
|
101434
101383
|
session: {
|
|
@@ -105023,31 +104972,6 @@ var init_capabilities_bridge = __esm(() => {
|
|
|
105023
104972
|
init_models_refresh();
|
|
105024
104973
|
});
|
|
105025
104974
|
|
|
105026
|
-
// ../../services/backend/config/featureFlags.ts
|
|
105027
|
-
function getAllowedSignupMethodsForEnvironment(nodeEnv, convexDeployment, e2eSeedingEnabled) {
|
|
105028
|
-
if (e2eSeedingEnabled === "true") {
|
|
105029
|
-
return ["self", "invite"];
|
|
105030
|
-
}
|
|
105031
|
-
if (convexDeployment?.startsWith("local:")) {
|
|
105032
|
-
return ["self", "invite"];
|
|
105033
|
-
}
|
|
105034
|
-
if (nodeEnv && DEV_NODE_ENVS.has(nodeEnv)) {
|
|
105035
|
-
return ["self", "invite"];
|
|
105036
|
-
}
|
|
105037
|
-
return ["invite"];
|
|
105038
|
-
}
|
|
105039
|
-
var DEV_NODE_ENVS, featureFlags;
|
|
105040
|
-
var init_featureFlags = __esm(() => {
|
|
105041
|
-
DEV_NODE_ENVS = new Set(["development", "test"]);
|
|
105042
|
-
featureFlags = {
|
|
105043
|
-
disableLogin: false,
|
|
105044
|
-
directHarnessWorkers: true,
|
|
105045
|
-
get allowedSignupMethods() {
|
|
105046
|
-
return getAllowedSignupMethodsForEnvironment("development", process.env.CONVEX_DEPLOYMENT, process.env.E2E_SEEDING_ENABLED);
|
|
105047
|
-
}
|
|
105048
|
-
};
|
|
105049
|
-
});
|
|
105050
|
-
|
|
105051
104975
|
// ../../services/backend/prompts/agentic-query/system-prompt.ts
|
|
105052
104976
|
function renderAgenticQuerySystemPrompt(params) {
|
|
105053
104977
|
const completeCmd = `chatroom agentic-query complete --chatroom-id=${params.chatroomId} --query-id=${params.queryId} << 'CHATROOM_AGENTIC_QUERY_END'
|
|
@@ -106623,7 +106547,6 @@ var init_pi_sdk2 = __esm(() => {
|
|
|
106623
106547
|
});
|
|
106624
106548
|
|
|
106625
106549
|
// src/daemon/infrastructure/local/harness/bound-harness-registry.ts
|
|
106626
|
-
import { execSync as execSync2 } from "node:child_process";
|
|
106627
106550
|
async function startBoundHarness(config4) {
|
|
106628
106551
|
switch (config4.harnessName) {
|
|
106629
106552
|
case "opencode-sdk":
|
|
@@ -106654,58 +106577,6 @@ function createChunkExtractor(harnessName) {
|
|
|
106654
106577
|
return createStandardSdkChunkExtractor();
|
|
106655
106578
|
}
|
|
106656
106579
|
}
|
|
106657
|
-
function opencodeOnPath() {
|
|
106658
|
-
try {
|
|
106659
|
-
execSync2("opencode --version", { stdio: "pipe" });
|
|
106660
|
-
return true;
|
|
106661
|
-
} catch {
|
|
106662
|
-
return false;
|
|
106663
|
-
}
|
|
106664
|
-
}
|
|
106665
|
-
async function isCursorSdkInstalled() {
|
|
106666
|
-
if (!process.env.CURSOR_API_KEY?.trim())
|
|
106667
|
-
return false;
|
|
106668
|
-
try {
|
|
106669
|
-
const { importBundledCursorSdk: importBundledCursorSdk2 } = await Promise.resolve().then(() => (init_cursor_sdk_package(), exports_cursor_sdk_package));
|
|
106670
|
-
await importBundledCursorSdk2();
|
|
106671
|
-
return true;
|
|
106672
|
-
} catch {
|
|
106673
|
-
return false;
|
|
106674
|
-
}
|
|
106675
|
-
}
|
|
106676
|
-
async function isPiSdkInstalled() {
|
|
106677
|
-
try {
|
|
106678
|
-
const { importBundledPiSdk: importBundledPiSdk2 } = await Promise.resolve().then(() => (init_pi_sdk_package(), exports_pi_sdk_package));
|
|
106679
|
-
const { ModelRegistry, AuthStorage } = await importBundledPiSdk2();
|
|
106680
|
-
const authStorage = AuthStorage.create();
|
|
106681
|
-
const modelRegistry = ModelRegistry.create(authStorage);
|
|
106682
|
-
return modelRegistry.getAvailable().length > 0;
|
|
106683
|
-
} catch {
|
|
106684
|
-
return false;
|
|
106685
|
-
}
|
|
106686
|
-
}
|
|
106687
|
-
async function isClaudeSdkInstalled() {
|
|
106688
|
-
try {
|
|
106689
|
-
const { importBundledClaudeSdk: importBundledClaudeSdk2, resolvePathToClaudeCodeExecutable: resolvePathToClaudeCodeExecutable2 } = await Promise.resolve().then(() => (init_claude_sdk_package(), exports_claude_sdk_package));
|
|
106690
|
-
await importBundledClaudeSdk2();
|
|
106691
|
-
await resolvePathToClaudeCodeExecutable2();
|
|
106692
|
-
return true;
|
|
106693
|
-
} catch {
|
|
106694
|
-
return false;
|
|
106695
|
-
}
|
|
106696
|
-
}
|
|
106697
|
-
async function listInstalledNativeDirectHarnesses() {
|
|
106698
|
-
const installed2 = [];
|
|
106699
|
-
if (opencodeOnPath())
|
|
106700
|
-
installed2.push("opencode-sdk");
|
|
106701
|
-
if (await isCursorSdkInstalled())
|
|
106702
|
-
installed2.push("cursor-sdk");
|
|
106703
|
-
if (await isPiSdkInstalled())
|
|
106704
|
-
installed2.push("pi-sdk");
|
|
106705
|
-
if (await isClaudeSdkInstalled())
|
|
106706
|
-
installed2.push("claude-sdk");
|
|
106707
|
-
return installed2;
|
|
106708
|
-
}
|
|
106709
106580
|
var init_bound_harness_registry = __esm(() => {
|
|
106710
106581
|
init_claude_sdk2();
|
|
106711
106582
|
init_cursor_sdk2();
|
|
@@ -106717,14 +106588,26 @@ var init_bound_harness_registry = __esm(() => {
|
|
|
106717
106588
|
function makeHarnessKey(workspaceId, harnessName) {
|
|
106718
106589
|
return `${workspaceId}:${harnessName}`;
|
|
106719
106590
|
}
|
|
106720
|
-
|
|
106721
|
-
|
|
106722
|
-
|
|
106723
|
-
|
|
106724
|
-
return
|
|
106591
|
+
|
|
106592
|
+
// src/daemon/entry/shared-harness/bind-turn-message-on-event.ts
|
|
106593
|
+
function bindTurnMessageOnEvent(handle, sessionRepository, logPrefix) {
|
|
106594
|
+
let lastBoundKey = null;
|
|
106595
|
+
return () => {
|
|
106596
|
+
const turn = handle.currentTurn;
|
|
106597
|
+
if (!turn)
|
|
106598
|
+
return;
|
|
106599
|
+
const messageId = turn.messageId;
|
|
106600
|
+
if (messageId == null)
|
|
106601
|
+
return;
|
|
106602
|
+
const key = `${turn.turnId}:${messageId}`;
|
|
106603
|
+
if (key === lastBoundKey)
|
|
106604
|
+
return;
|
|
106605
|
+
lastBoundKey = key;
|
|
106606
|
+
sessionRepository.bindTurnMessageId(turn.turnId, messageId).catch((err) => console.warn(`[${logPrefix}] bindTurnMessageId error (resume):`, err));
|
|
106607
|
+
};
|
|
106725
106608
|
}
|
|
106726
106609
|
|
|
106727
|
-
// src/daemon/entry/
|
|
106610
|
+
// src/daemon/entry/shared-harness/idle-handler.ts
|
|
106728
106611
|
async function handleSessionIdle(handle, journal, config4, sessionRepository) {
|
|
106729
106612
|
await exports_Effect.runPromise(handleSessionIdleEffect(handle, journal, config4, sessionRepository));
|
|
106730
106613
|
}
|
|
@@ -106737,7 +106620,7 @@ var handleSessionIdleEffect = (handle, journal, config4, sessionRepository) => e
|
|
|
106737
106620
|
try: () => sessionRepository.finalizeAssistantTurn(turnId),
|
|
106738
106621
|
catch: (e) => e
|
|
106739
106622
|
})), exports_Effect.catchAll((err) => exports_Effect.sync(() => {
|
|
106740
|
-
console.warn(`[
|
|
106623
|
+
console.warn(`[harness] Failed to finalize turn ${turnId} for session ${rowId}:`, err instanceof Error ? err.message : String(err));
|
|
106741
106624
|
})));
|
|
106742
106625
|
}
|
|
106743
106626
|
const next4 = yield* exports_Effect.tryPromise({
|
|
@@ -106763,35 +106646,17 @@ var handleSessionIdleEffect = (handle, journal, config4, sessionRepository) => e
|
|
|
106763
106646
|
try: () => sessionRepository.markTurnProcessed(rowId, next4.seq),
|
|
106764
106647
|
catch: (e) => e
|
|
106765
106648
|
})), exports_Effect.catchAll((err) => exports_Effect.gen(function* () {
|
|
106766
|
-
console.warn(`[
|
|
106649
|
+
console.warn(`[harness] Failed to prompt queued message for session ${rowId}:`, err instanceof Error ? err.message : String(err));
|
|
106767
106650
|
yield* exports_Effect.promise(() => sessionRepository.setGenerating(rowId, false));
|
|
106768
106651
|
handle.currentTurn = null;
|
|
106769
106652
|
})));
|
|
106770
106653
|
}), (err) => exports_Effect.sync(() => {
|
|
106771
|
-
console.warn(`[
|
|
106654
|
+
console.warn(`[harness] Unexpected error in handleSessionIdleEffect:`, err instanceof Error ? err.message : String(err));
|
|
106772
106655
|
}));
|
|
106773
106656
|
var init_idle_handler = __esm(() => {
|
|
106774
106657
|
init_esm();
|
|
106775
106658
|
});
|
|
106776
106659
|
|
|
106777
|
-
// src/daemon/entry/shared-harness/bind-turn-message-on-event.ts
|
|
106778
|
-
function bindTurnMessageOnEvent(handle, sessionRepository, logPrefix) {
|
|
106779
|
-
let lastBoundKey = null;
|
|
106780
|
-
return () => {
|
|
106781
|
-
const turn = handle.currentTurn;
|
|
106782
|
-
if (!turn)
|
|
106783
|
-
return;
|
|
106784
|
-
const messageId = turn.messageId;
|
|
106785
|
-
if (messageId == null)
|
|
106786
|
-
return;
|
|
106787
|
-
const key = `${turn.turnId}:${messageId}`;
|
|
106788
|
-
if (key === lastBoundKey)
|
|
106789
|
-
return;
|
|
106790
|
-
lastBoundKey = key;
|
|
106791
|
-
sessionRepository.bindTurnMessageId(turn.turnId, messageId).catch((err) => console.warn(`[${logPrefix}] bindTurnMessageId error (resume):`, err));
|
|
106792
|
-
};
|
|
106793
|
-
}
|
|
106794
|
-
|
|
106795
106660
|
// src/daemon/entry/agentic-query/prompt-drain.ts
|
|
106796
106661
|
async function drainPendingAgenticQueryMessages(daemonSession, deps) {
|
|
106797
106662
|
const batch = await daemonSession.backend.query(api.daemon.agenticQuery.messages.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId });
|
|
@@ -107050,10 +106915,10 @@ async function openPendingHarnessSession(daemonSession, deps, input, options) {
|
|
|
107050
106915
|
}
|
|
107051
106916
|
var init_open_pending_session = __esm(() => {
|
|
107052
106917
|
init_get_or_create_bound_harness();
|
|
106918
|
+
init_idle_handler();
|
|
107053
106919
|
init_api3();
|
|
107054
106920
|
init_bound_harness_registry();
|
|
107055
106921
|
init_opencode_session_events();
|
|
107056
|
-
init_idle_handler();
|
|
107057
106922
|
});
|
|
107058
106923
|
|
|
107059
106924
|
// src/daemon/entry/agentic-query/session-processor.ts
|
|
@@ -110471,772 +110336,6 @@ async function dispatchCommandInboundEvent(event) {
|
|
|
110471
110336
|
}
|
|
110472
110337
|
var handler2;
|
|
110473
110338
|
|
|
110474
|
-
// src/daemon/entry/direct-harness/command-processor.ts
|
|
110475
|
-
async function dispatchPendingCommand(session2, deps, cmd) {
|
|
110476
|
-
switch (cmd.type) {
|
|
110477
|
-
case "refreshCapabilities":
|
|
110478
|
-
await handleRefreshCapabilities(session2, deps, cmd);
|
|
110479
|
-
break;
|
|
110480
|
-
case "refreshSessionTitle":
|
|
110481
|
-
await handleRefreshSessionTitle(session2, deps, cmd);
|
|
110482
|
-
break;
|
|
110483
|
-
case "closeSession":
|
|
110484
|
-
await handleCloseSession(session2, deps, cmd);
|
|
110485
|
-
break;
|
|
110486
|
-
default:
|
|
110487
|
-
await markFailed(session2, cmd._id, `Unknown command type: ${cmd.type}`);
|
|
110488
|
-
}
|
|
110489
|
-
}
|
|
110490
|
-
async function processPendingCommand(session2, deps, cmd, now) {
|
|
110491
|
-
if (now - cmd.createdAt > DIRECT_HARNESS_COMMAND_TTL_MS) {
|
|
110492
|
-
console.log(`[direct-harness] Discarding stale command ${cmd._id} (type=${cmd.type}, age=${now - cmd.createdAt}ms)`);
|
|
110493
|
-
await markFailed(session2, cmd._id, "Command expired (TTL)");
|
|
110494
|
-
return;
|
|
110495
|
-
}
|
|
110496
|
-
await dispatchPendingCommand(session2, deps, cmd);
|
|
110497
|
-
}
|
|
110498
|
-
async function drainPendingHarnessCommands(session2, deps, processed = new Set) {
|
|
110499
|
-
await drain(session2, deps, processed);
|
|
110500
|
-
}
|
|
110501
|
-
async function drain(session2, deps, processed) {
|
|
110502
|
-
const pending3 = await session2.backend.query(api.daemon.directHarness.commands.listPendingCommands, { sessionId: session2.sessionId, machineId: session2.machineId });
|
|
110503
|
-
if (!pending3 || pending3.length === 0)
|
|
110504
|
-
return;
|
|
110505
|
-
const now = Date.now();
|
|
110506
|
-
for (const cmd of pending3) {
|
|
110507
|
-
if (processed.has(cmd._id))
|
|
110508
|
-
continue;
|
|
110509
|
-
processed.add(cmd._id);
|
|
110510
|
-
try {
|
|
110511
|
-
await processPendingCommand(session2, deps, cmd, now);
|
|
110512
|
-
} catch (err) {
|
|
110513
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
110514
|
-
console.warn(`[direct-harness] Command ${cmd._id} failed: ${message}`);
|
|
110515
|
-
await markFailed(session2, cmd._id, message).catch(() => {});
|
|
110516
|
-
}
|
|
110517
|
-
}
|
|
110518
|
-
}
|
|
110519
|
-
async function handleRefreshCapabilities(session2, deps, cmd) {
|
|
110520
|
-
const payload = cmd.refreshCapabilities;
|
|
110521
|
-
console.log(`[direct-harness] Processing refreshCapabilities for workspace=${cmd.workspaceId}` + (payload ? ` (initiatedBy=${payload.initiatedBy})` : ""));
|
|
110522
|
-
const installed2 = await listInstalledNativeDirectHarnesses();
|
|
110523
|
-
const harnessEntries = [];
|
|
110524
|
-
let cwd = "";
|
|
110525
|
-
for (const harnessName of installed2) {
|
|
110526
|
-
const harness = await deps.lifecycleManager.getOrStart(cmd.workspaceId, harnessName);
|
|
110527
|
-
cwd = harness.cwd;
|
|
110528
|
-
const [agents, providers] = await Promise.all([harness.listAgents(), harness.listProviders()]);
|
|
110529
|
-
harnessEntries.push({
|
|
110530
|
-
name: harness.type,
|
|
110531
|
-
displayName: harness.displayName,
|
|
110532
|
-
agents: [...agents],
|
|
110533
|
-
providers: [...providers]
|
|
110534
|
-
});
|
|
110535
|
-
}
|
|
110536
|
-
const existing = await session2.backend.query(api.daemon.directHarness.capabilities.getForMachine, { sessionId: session2.sessionId, machineId: session2.machineId });
|
|
110537
|
-
const updatedWorkspace = {
|
|
110538
|
-
workspaceId: cmd.workspaceId,
|
|
110539
|
-
cwd,
|
|
110540
|
-
name: cwd,
|
|
110541
|
-
harnesses: harnessEntries
|
|
110542
|
-
};
|
|
110543
|
-
const merged = [
|
|
110544
|
-
...(existing?.workspaces ?? []).filter((ws) => ws.workspaceId !== cmd.workspaceId),
|
|
110545
|
-
updatedWorkspace
|
|
110546
|
-
];
|
|
110547
|
-
await deps.publisher.publish({
|
|
110548
|
-
machineId: session2.machineId,
|
|
110549
|
-
lastSeenAt: Date.now(),
|
|
110550
|
-
workspaces: merged
|
|
110551
|
-
});
|
|
110552
|
-
await session2.backend.mutation(api.daemon.directHarness.commands.updateCommandStatus, {
|
|
110553
|
-
sessionId: session2.sessionId,
|
|
110554
|
-
commandId: cmd._id,
|
|
110555
|
-
status: "done"
|
|
110556
|
-
});
|
|
110557
|
-
console.log(`[direct-harness] Capabilities refreshed for workspace=${cmd.workspaceId}`);
|
|
110558
|
-
}
|
|
110559
|
-
async function handleRefreshSessionTitle(session2, deps, cmd) {
|
|
110560
|
-
const { harnessSessionId } = cmd.refreshSessionTitle ?? {};
|
|
110561
|
-
if (!harnessSessionId) {
|
|
110562
|
-
await markFailed(session2, cmd._id, "refreshSessionTitle: missing harnessSessionId");
|
|
110563
|
-
return;
|
|
110564
|
-
}
|
|
110565
|
-
const sessionRow = await session2.backend.query(api.daemon.directHarness.sessions.getSession, {
|
|
110566
|
-
harnessSessionId
|
|
110567
|
-
});
|
|
110568
|
-
if (!sessionRow?.opencodeSessionId) {
|
|
110569
|
-
await session2.backend.mutation(api.daemon.directHarness.commands.updateCommandStatus, {
|
|
110570
|
-
sessionId: session2.sessionId,
|
|
110571
|
-
commandId: cmd._id,
|
|
110572
|
-
status: "done"
|
|
110573
|
-
});
|
|
110574
|
-
return;
|
|
110575
|
-
}
|
|
110576
|
-
const harnessName = sessionRow.harnessName ?? "opencode-sdk";
|
|
110577
|
-
const harness = await deps.lifecycleManager.getOrStart(sessionRow.workspaceId ?? cmd.workspaceId, harnessName);
|
|
110578
|
-
const newTitle = await harness.fetchSessionTitle(sessionRow.opencodeSessionId);
|
|
110579
|
-
if (newTitle) {
|
|
110580
|
-
await session2.backend.mutation(api.daemon.directHarness.sessions.updateSessionTitle, {
|
|
110581
|
-
sessionId: session2.sessionId,
|
|
110582
|
-
harnessSessionId,
|
|
110583
|
-
sessionTitle: newTitle
|
|
110584
|
-
});
|
|
110585
|
-
console.log(`[direct-harness] Refreshed title for session ${harnessSessionId}: "${newTitle}"`);
|
|
110586
|
-
}
|
|
110587
|
-
await session2.backend.mutation(api.daemon.directHarness.commands.updateCommandStatus, {
|
|
110588
|
-
sessionId: session2.sessionId,
|
|
110589
|
-
commandId: cmd._id,
|
|
110590
|
-
status: "done"
|
|
110591
|
-
});
|
|
110592
|
-
}
|
|
110593
|
-
async function closeDisconnectedHarnessSession(deps, sessionRow, harnessSessionId) {
|
|
110594
|
-
if (!sessionRow.opencodeSessionId) {
|
|
110595
|
-
await deps.sessionRepository.markClosed(harnessSessionId);
|
|
110596
|
-
return;
|
|
110597
|
-
}
|
|
110598
|
-
const harnessName = sessionRow.harnessName ?? "opencode-sdk";
|
|
110599
|
-
const harness = await deps.lifecycleManager.getOrStart(sessionRow.workspaceId ?? "", harnessName);
|
|
110600
|
-
const liveSession = await harness.resumeSession(sessionRow.opencodeSessionId, {
|
|
110601
|
-
harnessSessionId
|
|
110602
|
-
});
|
|
110603
|
-
await liveSession.close();
|
|
110604
|
-
await deps.sessionRepository.markClosed(harnessSessionId);
|
|
110605
|
-
}
|
|
110606
|
-
async function closeHarnessSession(session2, deps, harnessSessionId) {
|
|
110607
|
-
const sessionRow = await session2.backend.query(api.daemon.directHarness.sessions.getSession, {
|
|
110608
|
-
harnessSessionId
|
|
110609
|
-
});
|
|
110610
|
-
if (!sessionRow) {
|
|
110611
|
-
throw new Error(`Harness session ${harnessSessionId} not found`);
|
|
110612
|
-
}
|
|
110613
|
-
if (sessionRow.status === "closed" || sessionRow.status === "failed") {
|
|
110614
|
-
return;
|
|
110615
|
-
}
|
|
110616
|
-
const handle = deps.activeSessions.get(harnessSessionId);
|
|
110617
|
-
if (handle) {
|
|
110618
|
-
await handle.close();
|
|
110619
|
-
deps.activeSessions.delete(harnessSessionId);
|
|
110620
|
-
return;
|
|
110621
|
-
}
|
|
110622
|
-
await closeDisconnectedHarnessSession(deps, sessionRow, harnessSessionId);
|
|
110623
|
-
}
|
|
110624
|
-
async function handleCloseSession(session2, deps, cmd) {
|
|
110625
|
-
const { harnessSessionId } = cmd.closeSession ?? {};
|
|
110626
|
-
if (!harnessSessionId) {
|
|
110627
|
-
await markFailed(session2, cmd._id, "closeSession: missing harnessSessionId");
|
|
110628
|
-
return;
|
|
110629
|
-
}
|
|
110630
|
-
console.log(`[direct-harness] Processing closeSession for harnessSessionId=${harnessSessionId}`);
|
|
110631
|
-
await closeHarnessSession(session2, deps, harnessSessionId);
|
|
110632
|
-
await session2.backend.mutation(api.daemon.directHarness.commands.updateCommandStatus, {
|
|
110633
|
-
sessionId: session2.sessionId,
|
|
110634
|
-
commandId: cmd._id,
|
|
110635
|
-
status: "done"
|
|
110636
|
-
});
|
|
110637
|
-
console.log(`[direct-harness] Closed session ${harnessSessionId}`);
|
|
110638
|
-
}
|
|
110639
|
-
async function markFailed(session2, commandId, errorMessage) {
|
|
110640
|
-
await session2.backend.mutation(api.daemon.directHarness.commands.updateCommandStatus, {
|
|
110641
|
-
sessionId: session2.sessionId,
|
|
110642
|
-
commandId,
|
|
110643
|
-
status: "failed",
|
|
110644
|
-
errorMessage
|
|
110645
|
-
});
|
|
110646
|
-
}
|
|
110647
|
-
var DIRECT_HARNESS_COMMAND_TTL_MS = 60000;
|
|
110648
|
-
var init_command_processor = __esm(() => {
|
|
110649
|
-
init_api3();
|
|
110650
|
-
init_bound_harness_registry();
|
|
110651
|
-
});
|
|
110652
|
-
|
|
110653
|
-
// src/daemon/entry/direct-harness/harness-lifecycle-manager.ts
|
|
110654
|
-
class HarnessLifecycleManager {
|
|
110655
|
-
harnesses;
|
|
110656
|
-
activeSessions;
|
|
110657
|
-
resolveWorkspace;
|
|
110658
|
-
resolvedConvexUrl;
|
|
110659
|
-
idleSince = new Map;
|
|
110660
|
-
monitorTimer = null;
|
|
110661
|
-
constructor(harnesses, activeSessions, resolveWorkspace, resolvedConvexUrl) {
|
|
110662
|
-
this.harnesses = harnesses;
|
|
110663
|
-
this.activeSessions = activeSessions;
|
|
110664
|
-
this.resolveWorkspace = resolveWorkspace;
|
|
110665
|
-
this.resolvedConvexUrl = resolvedConvexUrl;
|
|
110666
|
-
}
|
|
110667
|
-
getOrStartHarnessEffect(workspaceId, harnessName) {
|
|
110668
|
-
const key = makeHarnessKey(workspaceId, harnessName);
|
|
110669
|
-
const existing = this.harnesses.get(key);
|
|
110670
|
-
if (existing?.isAlive())
|
|
110671
|
-
return exports_Effect.succeed(existing);
|
|
110672
|
-
if (existing) {
|
|
110673
|
-
existing.close().catch(() => {});
|
|
110674
|
-
this.harnesses.delete(key);
|
|
110675
|
-
}
|
|
110676
|
-
return exports_Effect.gen(this, function* () {
|
|
110677
|
-
const workspace = yield* exports_Effect.tryPromise({
|
|
110678
|
-
try: () => this.resolveWorkspace(workspaceId),
|
|
110679
|
-
catch: (e) => e instanceof Error ? e : new Error(String(e))
|
|
110680
|
-
});
|
|
110681
|
-
if (!workspace) {
|
|
110682
|
-
return yield* exports_Effect.fail(new Error(`Workspace ${workspaceId} not found — cannot start harness`));
|
|
110683
|
-
}
|
|
110684
|
-
console.log(`[${formatTimestamp()}] \uD83D\uDD27 Auto-starting ${harnessName} for workspace=${workspaceId} (${workspace.workingDir})`);
|
|
110685
|
-
const harness = yield* exports_Effect.tryPromise({
|
|
110686
|
-
try: () => startBoundHarness({
|
|
110687
|
-
harnessName,
|
|
110688
|
-
workingDir: workspace.workingDir,
|
|
110689
|
-
workspaceId,
|
|
110690
|
-
resolvedConvexUrl: this.resolvedConvexUrl
|
|
110691
|
-
}),
|
|
110692
|
-
catch: (e) => e instanceof Error ? e : new Error(String(e))
|
|
110693
|
-
});
|
|
110694
|
-
this.harnesses.set(key, harness);
|
|
110695
|
-
this.idleSince.set(key, Date.now());
|
|
110696
|
-
return harness;
|
|
110697
|
-
});
|
|
110698
|
-
}
|
|
110699
|
-
async getOrStart(workspaceId, harnessName) {
|
|
110700
|
-
return exports_Effect.runPromise(this.getOrStartHarnessEffect(workspaceId, harnessName));
|
|
110701
|
-
}
|
|
110702
|
-
startMonitoring() {
|
|
110703
|
-
if (this.monitorTimer)
|
|
110704
|
-
return;
|
|
110705
|
-
this.monitorTimer = setInterval(() => this.checkInactivity(), CHECK_INTERVAL_MS);
|
|
110706
|
-
this.monitorTimer.unref();
|
|
110707
|
-
}
|
|
110708
|
-
stopMonitoring() {
|
|
110709
|
-
if (this.monitorTimer) {
|
|
110710
|
-
clearInterval(this.monitorTimer);
|
|
110711
|
-
this.monitorTimer = null;
|
|
110712
|
-
}
|
|
110713
|
-
}
|
|
110714
|
-
checkInactivity() {
|
|
110715
|
-
const now = Date.now();
|
|
110716
|
-
for (const key of this.harnesses.keys()) {
|
|
110717
|
-
const { workspaceId, harnessName } = parseHarnessKey(key);
|
|
110718
|
-
const hasActiveSessions = this.hasSessionsForHarnessKey(workspaceId, harnessName);
|
|
110719
|
-
if (hasActiveSessions) {
|
|
110720
|
-
this.idleSince.delete(key);
|
|
110721
|
-
} else {
|
|
110722
|
-
const idleStart = this.idleSince.get(key);
|
|
110723
|
-
if (idleStart === undefined) {
|
|
110724
|
-
this.idleSince.set(key, now);
|
|
110725
|
-
} else if (now - idleStart >= INACTIVITY_TTL_MS) {
|
|
110726
|
-
const idleMinutes = Math.round((now - idleStart) / 60000);
|
|
110727
|
-
console.log(`[${formatTimestamp()}] \uD83D\uDD2A Killing idle harness ${harnessName} for workspace=${workspaceId} (idle ${idleMinutes}min)`);
|
|
110728
|
-
this.harnesses.get(key)?.close().catch(() => {});
|
|
110729
|
-
this.harnesses.delete(key);
|
|
110730
|
-
this.idleSince.delete(key);
|
|
110731
|
-
}
|
|
110732
|
-
}
|
|
110733
|
-
}
|
|
110734
|
-
}
|
|
110735
|
-
hasSessionsForHarnessKey(workspaceId, harnessName) {
|
|
110736
|
-
for (const handle of this.activeSessions.values()) {
|
|
110737
|
-
if (handle.workspaceId === workspaceId && handle.harnessName === harnessName) {
|
|
110738
|
-
return true;
|
|
110739
|
-
}
|
|
110740
|
-
}
|
|
110741
|
-
return false;
|
|
110742
|
-
}
|
|
110743
|
-
}
|
|
110744
|
-
var INACTIVITY_TTL_MS, CHECK_INTERVAL_MS;
|
|
110745
|
-
var init_harness_lifecycle_manager = __esm(() => {
|
|
110746
|
-
init_esm();
|
|
110747
|
-
init_bound_harness_registry();
|
|
110748
|
-
INACTIVITY_TTL_MS = 15 * 60 * 1000;
|
|
110749
|
-
CHECK_INTERVAL_MS = 60 * 1000;
|
|
110750
|
-
});
|
|
110751
|
-
|
|
110752
|
-
// src/daemon/entry/direct-harness/prompt-drain.ts
|
|
110753
|
-
async function drainPendingHarnessMessages(session2, deps) {
|
|
110754
|
-
const pending3 = await session2.backend.query(api.daemon.directHarness.messages.pendingForMachine, { sessionId: session2.sessionId, machineId: session2.machineId });
|
|
110755
|
-
if (!pending3 || pending3.messages.length === 0)
|
|
110756
|
-
return;
|
|
110757
|
-
const bySession = new Map;
|
|
110758
|
-
for (const msg of pending3.messages) {
|
|
110759
|
-
const list = bySession.get(msg.harnessSessionId);
|
|
110760
|
-
if (list) {
|
|
110761
|
-
list.push(msg);
|
|
110762
|
-
} else {
|
|
110763
|
-
bySession.set(msg.harnessSessionId, [msg]);
|
|
110764
|
-
}
|
|
110765
|
-
}
|
|
110766
|
-
const sessionInfo = new Map;
|
|
110767
|
-
for (const s of pending3.sessions) {
|
|
110768
|
-
sessionInfo.set(s._id, s);
|
|
110769
|
-
}
|
|
110770
|
-
for (const [rowId, messages] of bySession) {
|
|
110771
|
-
try {
|
|
110772
|
-
await processSessionMessages(session2, deps, rowId, messages, sessionInfo.get(rowId));
|
|
110773
|
-
} catch (err) {
|
|
110774
|
-
console.warn(`[direct-harness] Failed to process messages for session ${rowId}:`, err instanceof Error ? err.message : String(err));
|
|
110775
|
-
}
|
|
110776
|
-
}
|
|
110777
|
-
}
|
|
110778
|
-
async function resumeSessionHandle(session2, deps, rowId, info) {
|
|
110779
|
-
const opencodeSessionId = info.opencodeSessionId;
|
|
110780
|
-
if (!opencodeSessionId) {
|
|
110781
|
-
console.warn(`[direct-harness] Session ${rowId} not yet open — waiting for session-subscriber`);
|
|
110782
|
-
return null;
|
|
110783
|
-
}
|
|
110784
|
-
const workspaceId = info.workspaceId;
|
|
110785
|
-
const harnessName = info.harnessName;
|
|
110786
|
-
if (!workspaceId) {
|
|
110787
|
-
console.warn(`[direct-harness] Cannot resume session ${rowId}: no workspace info`);
|
|
110788
|
-
return null;
|
|
110789
|
-
}
|
|
110790
|
-
const key = makeHarnessKey(workspaceId, harnessName);
|
|
110791
|
-
let harness = deps.harnesses.get(key);
|
|
110792
|
-
if (harness && !harness.isAlive()) {
|
|
110793
|
-
harness.close().catch(() => {});
|
|
110794
|
-
deps.harnesses.delete(key);
|
|
110795
|
-
harness = undefined;
|
|
110796
|
-
}
|
|
110797
|
-
if (!harness) {
|
|
110798
|
-
const workspace = await session2.backend.query(api.workspaces.getWorkspaceById, {
|
|
110799
|
-
sessionId: session2.sessionId,
|
|
110800
|
-
workspaceId
|
|
110801
|
-
});
|
|
110802
|
-
if (!workspace) {
|
|
110803
|
-
console.warn(`[direct-harness] Cannot resume session ${rowId}: workspace not found`);
|
|
110804
|
-
return null;
|
|
110805
|
-
}
|
|
110806
|
-
harness = await startBoundHarness({
|
|
110807
|
-
harnessName,
|
|
110808
|
-
workingDir: workspace.workingDir,
|
|
110809
|
-
workspaceId,
|
|
110810
|
-
resolvedConvexUrl: session2.convexUrl
|
|
110811
|
-
});
|
|
110812
|
-
deps.harnesses.set(key, harness);
|
|
110813
|
-
}
|
|
110814
|
-
try {
|
|
110815
|
-
return await resumeSession({
|
|
110816
|
-
harness,
|
|
110817
|
-
journalFactory: deps.journalFactory,
|
|
110818
|
-
chunkExtractor: createChunkExtractor(harness.type)
|
|
110819
|
-
}, { harnessSessionId: rowId, opencodeSessionId, workspaceId, harnessName });
|
|
110820
|
-
} catch (err) {
|
|
110821
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
110822
|
-
console.warn(`[direct-harness] Cannot resume session ${rowId}: ${message}`);
|
|
110823
|
-
await deps.sessionRepository.markFailed(rowId).catch(() => {});
|
|
110824
|
-
return null;
|
|
110825
|
-
}
|
|
110826
|
-
}
|
|
110827
|
-
function wireResumedSessionEvents(handle, deps, info) {
|
|
110828
|
-
const idleConfig = {
|
|
110829
|
-
agent: info.lastUsedConfig.agent ?? "build",
|
|
110830
|
-
model: info.lastUsedConfig.model
|
|
110831
|
-
};
|
|
110832
|
-
const bindTurnMessage = bindTurnMessageOnEvent(handle, deps.sessionRepository, "direct-harness");
|
|
110833
|
-
handle.session.onEvent((event) => {
|
|
110834
|
-
bindTurnMessage();
|
|
110835
|
-
if (event.type === OPENCODE_SESSION_EVENT_TYPES[0]) {
|
|
110836
|
-
handleSessionIdle(handle, handle.journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[direct-harness] idle handler error (resume):", err));
|
|
110837
|
-
}
|
|
110838
|
-
});
|
|
110839
|
-
}
|
|
110840
|
-
async function deliverPendingMessages(handle, deps, rowId, messages, info, _daemonSession) {
|
|
110841
|
-
for (const msg of messages) {
|
|
110842
|
-
const override = info?.lastUsedConfig ?? { agent: "build" };
|
|
110843
|
-
try {
|
|
110844
|
-
await deps.sessionRepository.setGenerating(rowId, true);
|
|
110845
|
-
const { turnId } = await deps.sessionRepository.beginAssistantTurn(rowId);
|
|
110846
|
-
handle.currentTurn = { turnId, messageId: null };
|
|
110847
|
-
await handle.session.prompt({
|
|
110848
|
-
parts: [{ type: "text", text: msg.content }],
|
|
110849
|
-
agent: override.agent,
|
|
110850
|
-
...override.model ? { model: override.model } : {}
|
|
110851
|
-
});
|
|
110852
|
-
await deps.sessionRepository.markTurnProcessed(rowId, msg.seq);
|
|
110853
|
-
} catch (err) {
|
|
110854
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
110855
|
-
console.warn(`[direct-harness] Prompt failed for session ${rowId} seq=${msg.seq}: ${message}`);
|
|
110856
|
-
await deps.sessionRepository.markIdle(rowId).catch(() => {});
|
|
110857
|
-
deps.activeSessions.delete(rowId);
|
|
110858
|
-
if (info?.workspaceId && info.harnessName) {
|
|
110859
|
-
deps.harnesses.delete(makeHarnessKey(info.workspaceId, info.harnessName));
|
|
110860
|
-
}
|
|
110861
|
-
return;
|
|
110862
|
-
}
|
|
110863
|
-
}
|
|
110864
|
-
}
|
|
110865
|
-
async function processSessionMessages(session2, deps, rowId, messages, info) {
|
|
110866
|
-
let handle = deps.activeSessions.get(rowId);
|
|
110867
|
-
if (!handle) {
|
|
110868
|
-
if (!info) {
|
|
110869
|
-
console.warn(`[direct-harness] Session ${rowId} not yet open — waiting for session-subscriber`);
|
|
110870
|
-
return;
|
|
110871
|
-
}
|
|
110872
|
-
const resumed = await resumeSessionHandle(session2, deps, rowId, info);
|
|
110873
|
-
if (!resumed) {
|
|
110874
|
-
return;
|
|
110875
|
-
}
|
|
110876
|
-
handle = resumed;
|
|
110877
|
-
deps.activeSessions.set(rowId, handle);
|
|
110878
|
-
await deps.sessionRepository.markActive(rowId).catch(() => {});
|
|
110879
|
-
wireResumedSessionEvents(handle, deps, info);
|
|
110880
|
-
}
|
|
110881
|
-
await deliverPendingMessages(handle, deps, rowId, messages, info, session2);
|
|
110882
|
-
}
|
|
110883
|
-
var init_prompt_drain2 = __esm(() => {
|
|
110884
|
-
init_idle_handler();
|
|
110885
|
-
init_api3();
|
|
110886
|
-
init_resume_harness_session();
|
|
110887
|
-
init_bound_harness_registry();
|
|
110888
|
-
init_opencode_session_events();
|
|
110889
|
-
});
|
|
110890
|
-
|
|
110891
|
-
// src/daemon/entry/direct-harness/session-processor.ts
|
|
110892
|
-
async function processPendingHarnessSessions(daemonSession, deps) {
|
|
110893
|
-
const pendingSessions = await daemonSession.backend.query(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
|
|
110894
|
-
sessionId: daemonSession.sessionId,
|
|
110895
|
-
machineId: daemonSession.machineId
|
|
110896
|
-
});
|
|
110897
|
-
await processPendingHarnessSessionRows(daemonSession, deps, pendingSessions);
|
|
110898
|
-
}
|
|
110899
|
-
async function processPendingHarnessSessionRows(daemonSession, deps, pendingSessions) {
|
|
110900
|
-
if (!pendingSessions || pendingSessions.length === 0)
|
|
110901
|
-
return;
|
|
110902
|
-
for (const session2 of pendingSessions) {
|
|
110903
|
-
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
110904
|
-
const agent = session2.opencode?.lastUsedConfig?.agent ?? "build";
|
|
110905
|
-
const model = session2.opencode?.lastUsedConfig?.model;
|
|
110906
|
-
await openPendingHarnessSession(daemonSession, deps, {
|
|
110907
|
-
rowId: session2._id,
|
|
110908
|
-
workspaceId: session2.workspaceId,
|
|
110909
|
-
harnessName,
|
|
110910
|
-
lastUsedConfig: { agent, ...model ? { model } : {} }
|
|
110911
|
-
}, { logPrefix: "[direct-harness]", handleProviderIdEvents: true });
|
|
110912
|
-
}
|
|
110913
|
-
}
|
|
110914
|
-
var init_session_processor2 = __esm(() => {
|
|
110915
|
-
init_api3();
|
|
110916
|
-
init_open_pending_session();
|
|
110917
|
-
});
|
|
110918
|
-
|
|
110919
|
-
// src/daemon/entry/direct-harness/shutdown-sessions.ts
|
|
110920
|
-
async function listHarnessSessionIdsForShutdown(session2) {
|
|
110921
|
-
const ids3 = new Set;
|
|
110922
|
-
const managed = await session2.backend.query(api.daemon.directHarness.turns.getMachineHarnessSessions, {
|
|
110923
|
-
sessionId: session2.sessionId,
|
|
110924
|
-
machineId: session2.machineId
|
|
110925
|
-
});
|
|
110926
|
-
for (const row of managed) {
|
|
110927
|
-
ids3.add(row.harnessSessionId);
|
|
110928
|
-
}
|
|
110929
|
-
const pending3 = await session2.backend.query(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
|
|
110930
|
-
sessionId: session2.sessionId,
|
|
110931
|
-
machineId: session2.machineId
|
|
110932
|
-
});
|
|
110933
|
-
for (const row of pending3) {
|
|
110934
|
-
ids3.add(row._id);
|
|
110935
|
-
}
|
|
110936
|
-
return [...ids3];
|
|
110937
|
-
}
|
|
110938
|
-
async function closeAllMachineHarnessSessionsOnShutdown(session2, deps) {
|
|
110939
|
-
const commandDeps = {
|
|
110940
|
-
lifecycleManager: deps.lifecycleManager,
|
|
110941
|
-
publisher: {},
|
|
110942
|
-
activeSessions: deps.activeSessions,
|
|
110943
|
-
sessionRepository: deps.sessionRepository
|
|
110944
|
-
};
|
|
110945
|
-
const harnessSessionIds = await listHarnessSessionIdsForShutdown(session2);
|
|
110946
|
-
if (harnessSessionIds.length === 0)
|
|
110947
|
-
return;
|
|
110948
|
-
console.log(`[direct-harness] Closing ${harnessSessionIds.length} harness session(s) on daemon shutdown...`);
|
|
110949
|
-
for (const harnessSessionId of harnessSessionIds) {
|
|
110950
|
-
try {
|
|
110951
|
-
await session2.backend.mutation(api.daemon.directHarness.turns.markOrphanTurnsFailed, {
|
|
110952
|
-
sessionId: session2.sessionId,
|
|
110953
|
-
machineId: session2.machineId,
|
|
110954
|
-
harnessSessionId
|
|
110955
|
-
});
|
|
110956
|
-
} catch {}
|
|
110957
|
-
try {
|
|
110958
|
-
await closeHarnessSession(session2, commandDeps, harnessSessionId);
|
|
110959
|
-
} catch (err) {
|
|
110960
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
110961
|
-
console.warn(`[direct-harness] Failed to close session ${harnessSessionId} on shutdown: ${message}`);
|
|
110962
|
-
try {
|
|
110963
|
-
await deps.sessionRepository.markClosed(harnessSessionId);
|
|
110964
|
-
} catch {}
|
|
110965
|
-
}
|
|
110966
|
-
}
|
|
110967
|
-
}
|
|
110968
|
-
var init_shutdown_sessions = __esm(() => {
|
|
110969
|
-
init_command_processor();
|
|
110970
|
-
init_api3();
|
|
110971
|
-
});
|
|
110972
|
-
|
|
110973
|
-
// src/infrastructure/repos/convex-capabilities-publisher.ts
|
|
110974
|
-
class ConvexCapabilitiesPublisher {
|
|
110975
|
-
options;
|
|
110976
|
-
constructor(options) {
|
|
110977
|
-
this.options = options;
|
|
110978
|
-
}
|
|
110979
|
-
async publish(caps) {
|
|
110980
|
-
const { backend: backend2, sessionId } = this.options;
|
|
110981
|
-
await backend2.mutation(api.daemon.directHarness.capabilities.publishMachineCapabilities, {
|
|
110982
|
-
sessionId,
|
|
110983
|
-
machineId: caps.machineId,
|
|
110984
|
-
workspaces: caps.workspaces.map((ws) => ({
|
|
110985
|
-
workspaceId: ws.workspaceId,
|
|
110986
|
-
cwd: ws.cwd,
|
|
110987
|
-
name: ws.name,
|
|
110988
|
-
harnesses: ws.harnesses.map((h) => ({
|
|
110989
|
-
name: h.name,
|
|
110990
|
-
displayName: h.displayName,
|
|
110991
|
-
agents: h.agents.map((a) => ({
|
|
110992
|
-
name: a.name,
|
|
110993
|
-
mode: a.mode,
|
|
110994
|
-
...a.model ? { model: a.model } : {},
|
|
110995
|
-
...a.description ? { description: a.description } : {}
|
|
110996
|
-
})),
|
|
110997
|
-
providers: h.providers.map((p) => ({
|
|
110998
|
-
providerID: p.providerID,
|
|
110999
|
-
name: p.name,
|
|
111000
|
-
models: p.models.map((m) => ({ modelID: m.modelID, name: m.name }))
|
|
111001
|
-
})),
|
|
111002
|
-
...h.configSchema !== undefined ? { configSchema: h.configSchema } : {}
|
|
111003
|
-
}))
|
|
111004
|
-
}))
|
|
111005
|
-
});
|
|
111006
|
-
}
|
|
111007
|
-
}
|
|
111008
|
-
var init_convex_capabilities_publisher = __esm(() => {
|
|
111009
|
-
init_api3();
|
|
111010
|
-
});
|
|
111011
|
-
|
|
111012
|
-
// src/infrastructure/repos/convex-output-repository.ts
|
|
111013
|
-
class ConvexOutputRepository {
|
|
111014
|
-
options;
|
|
111015
|
-
constructor(options) {
|
|
111016
|
-
this.options = options;
|
|
111017
|
-
}
|
|
111018
|
-
async appendChunks(harnessSessionId, chunks) {
|
|
111019
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111020
|
-
if (chunks.length === 0)
|
|
111021
|
-
return;
|
|
111022
|
-
console.log(`[output-repo] Calling appendMessages: harnessSessionId="${harnessSessionId}", ${chunks.length} chunks`);
|
|
111023
|
-
try {
|
|
111024
|
-
await backend2.mutation(api.daemon.directHarness.messages.appendMessages, {
|
|
111025
|
-
sessionId,
|
|
111026
|
-
harnessSessionId,
|
|
111027
|
-
chunks: chunks.map((c) => ({
|
|
111028
|
-
content: c.content,
|
|
111029
|
-
timestamp: c.timestamp,
|
|
111030
|
-
messageId: c.messageId,
|
|
111031
|
-
partType: c.partType
|
|
111032
|
-
}))
|
|
111033
|
-
});
|
|
111034
|
-
console.log(`[output-repo] appendMessages succeeded for "${harnessSessionId}"`);
|
|
111035
|
-
} catch (err) {
|
|
111036
|
-
console.error(`[output-repo] appendMessages FAILED for "${harnessSessionId}": ${err instanceof Error ? err.message : String(err)}`);
|
|
111037
|
-
throw err;
|
|
111038
|
-
}
|
|
111039
|
-
}
|
|
111040
|
-
}
|
|
111041
|
-
var init_convex_output_repository = __esm(() => {
|
|
111042
|
-
init_api3();
|
|
111043
|
-
});
|
|
111044
|
-
|
|
111045
|
-
// src/infrastructure/repos/convex-session-repository.ts
|
|
111046
|
-
class ConvexSessionRepository {
|
|
111047
|
-
options;
|
|
111048
|
-
constructor(options) {
|
|
111049
|
-
this.options = options;
|
|
111050
|
-
}
|
|
111051
|
-
async associateOpenCodeSessionId(harnessSessionId, opencodeSessionId, sessionTitle) {
|
|
111052
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111053
|
-
await backend2.mutation(api.daemon.directHarness.sessions.associateHarnessSessionId, {
|
|
111054
|
-
sessionId,
|
|
111055
|
-
harnessSessionId,
|
|
111056
|
-
opencodeSessionId,
|
|
111057
|
-
sessionTitle
|
|
111058
|
-
});
|
|
111059
|
-
}
|
|
111060
|
-
async getOpenCodeSessionId(harnessSessionId) {
|
|
111061
|
-
const result = await this.options.backend.query(api.daemon.directHarness.sessions.getSession, {
|
|
111062
|
-
harnessSessionId
|
|
111063
|
-
});
|
|
111064
|
-
return result?.opencodeSessionId;
|
|
111065
|
-
}
|
|
111066
|
-
async markClosed(harnessSessionId) {
|
|
111067
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111068
|
-
await backend2.mutation(api.daemon.directHarness.sessions.closeSession, {
|
|
111069
|
-
sessionId,
|
|
111070
|
-
harnessSessionId
|
|
111071
|
-
});
|
|
111072
|
-
}
|
|
111073
|
-
async markIdle(harnessSessionId) {
|
|
111074
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111075
|
-
await backend2.mutation(api.daemon.directHarness.sessions.markIdle, {
|
|
111076
|
-
sessionId,
|
|
111077
|
-
harnessSessionId
|
|
111078
|
-
});
|
|
111079
|
-
}
|
|
111080
|
-
async markFailed(harnessSessionId) {
|
|
111081
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111082
|
-
await backend2.mutation(api.daemon.directHarness.sessions.markFailed, {
|
|
111083
|
-
sessionId,
|
|
111084
|
-
harnessSessionId
|
|
111085
|
-
});
|
|
111086
|
-
}
|
|
111087
|
-
async markActive(harnessSessionId) {
|
|
111088
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111089
|
-
await backend2.mutation(api.daemon.directHarness.sessions.markActive, {
|
|
111090
|
-
sessionId,
|
|
111091
|
-
harnessSessionId
|
|
111092
|
-
});
|
|
111093
|
-
}
|
|
111094
|
-
async markTurnProcessed(harnessSessionId, turnSeq) {
|
|
111095
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111096
|
-
await backend2.mutation(api.daemon.directHarness.turns.markTurnProcessed, {
|
|
111097
|
-
sessionId,
|
|
111098
|
-
harnessSessionId,
|
|
111099
|
-
turnSeq
|
|
111100
|
-
});
|
|
111101
|
-
}
|
|
111102
|
-
async setGenerating(harnessSessionId, isGenerating) {
|
|
111103
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111104
|
-
await backend2.mutation(api.daemon.directHarness.queue.setGenerating, {
|
|
111105
|
-
sessionId,
|
|
111106
|
-
harnessSessionId,
|
|
111107
|
-
isGenerating
|
|
111108
|
-
});
|
|
111109
|
-
}
|
|
111110
|
-
async dequeueNext(harnessSessionId) {
|
|
111111
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111112
|
-
const result = await backend2.mutation(api.daemon.directHarness.queue.dequeueNext, {
|
|
111113
|
-
sessionId,
|
|
111114
|
-
harnessSessionId
|
|
111115
|
-
});
|
|
111116
|
-
if (!result)
|
|
111117
|
-
return null;
|
|
111118
|
-
return { content: result.content, seq: result.turnSeq };
|
|
111119
|
-
}
|
|
111120
|
-
async beginAssistantTurn(harnessSessionId) {
|
|
111121
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111122
|
-
return backend2.mutation(api.daemon.directHarness.turns.beginAssistantTurn, {
|
|
111123
|
-
sessionId,
|
|
111124
|
-
harnessSessionId
|
|
111125
|
-
});
|
|
111126
|
-
}
|
|
111127
|
-
async bindTurnMessageId(turnId, messageId) {
|
|
111128
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111129
|
-
await backend2.mutation(api.daemon.directHarness.turns.bindTurnMessageId, {
|
|
111130
|
-
sessionId,
|
|
111131
|
-
turnId,
|
|
111132
|
-
messageId
|
|
111133
|
-
});
|
|
111134
|
-
}
|
|
111135
|
-
async finalizeAssistantTurn(turnId) {
|
|
111136
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111137
|
-
await backend2.mutation(api.daemon.directHarness.turns.finalizeAssistantTurn, {
|
|
111138
|
-
sessionId,
|
|
111139
|
-
turnId
|
|
111140
|
-
});
|
|
111141
|
-
}
|
|
111142
|
-
async updateSessionTitle(harnessSessionId, title) {
|
|
111143
|
-
const { backend: backend2, sessionId } = this.options;
|
|
111144
|
-
await backend2.mutation(api.daemon.directHarness.sessions.updateSessionTitle, {
|
|
111145
|
-
sessionId,
|
|
111146
|
-
harnessSessionId,
|
|
111147
|
-
sessionTitle: title
|
|
111148
|
-
});
|
|
111149
|
-
}
|
|
111150
|
-
}
|
|
111151
|
-
var init_convex_session_repository = __esm(() => {
|
|
111152
|
-
init_api3();
|
|
111153
|
-
});
|
|
111154
|
-
|
|
111155
|
-
// src/daemon/entry/direct-harness-inbound-registry.ts
|
|
111156
|
-
function registerDirectHarnessInboundHandler(h) {
|
|
111157
|
-
handler3 = h;
|
|
111158
|
-
}
|
|
111159
|
-
function unregisterDirectHarnessInboundHandler() {
|
|
111160
|
-
handler3 = undefined;
|
|
111161
|
-
}
|
|
111162
|
-
async function dispatchDirectHarnessInboundEvent(event) {
|
|
111163
|
-
if (handler3)
|
|
111164
|
-
await handler3(event);
|
|
111165
|
-
}
|
|
111166
|
-
var handler3;
|
|
111167
|
-
|
|
111168
|
-
// src/daemon/entry/direct-harness/start-subscriptions.ts
|
|
111169
|
-
function startDirectHarnessSubscriptions(session2, activeSessions, harnesses) {
|
|
111170
|
-
const sessionRepository = new ConvexSessionRepository({
|
|
111171
|
-
backend: session2.backend,
|
|
111172
|
-
sessionId: session2.sessionId
|
|
111173
|
-
});
|
|
111174
|
-
const outputRepository = new ConvexOutputRepository({
|
|
111175
|
-
backend: session2.backend,
|
|
111176
|
-
sessionId: session2.sessionId
|
|
111177
|
-
});
|
|
111178
|
-
const journalFactory = new BufferedJournalFactory({ outputRepository });
|
|
111179
|
-
const sharedDeps = {
|
|
111180
|
-
activeSessions,
|
|
111181
|
-
harnesses,
|
|
111182
|
-
sessionRepository,
|
|
111183
|
-
journalFactory
|
|
111184
|
-
};
|
|
111185
|
-
const lifecycleManager = new HarnessLifecycleManager(harnesses, activeSessions, async (workspaceId) => session2.backend.query(api.workspaces.getWorkspaceById, {
|
|
111186
|
-
sessionId: session2.sessionId,
|
|
111187
|
-
workspaceId
|
|
111188
|
-
}), session2.convexUrl);
|
|
111189
|
-
lifecycleManager.startMonitoring();
|
|
111190
|
-
const commandDeps = {
|
|
111191
|
-
lifecycleManager,
|
|
111192
|
-
publisher: new ConvexCapabilitiesPublisher({
|
|
111193
|
-
backend: session2.backend,
|
|
111194
|
-
sessionId: session2.sessionId
|
|
111195
|
-
}),
|
|
111196
|
-
activeSessions,
|
|
111197
|
-
sessionRepository
|
|
111198
|
-
};
|
|
111199
|
-
registerDirectHarnessInboundHandler(async (event) => {
|
|
111200
|
-
switch (event.type) {
|
|
111201
|
-
case "direct-harness.prompt":
|
|
111202
|
-
await drainPendingHarnessMessages(session2, sharedDeps);
|
|
111203
|
-
break;
|
|
111204
|
-
case "direct-harness.session-opened":
|
|
111205
|
-
await processPendingHarnessSessions(session2, sharedDeps);
|
|
111206
|
-
break;
|
|
111207
|
-
case "direct-harness.command":
|
|
111208
|
-
await drainPendingHarnessCommands(session2, commandDeps);
|
|
111209
|
-
break;
|
|
111210
|
-
}
|
|
111211
|
-
});
|
|
111212
|
-
return {
|
|
111213
|
-
lifecycleManager,
|
|
111214
|
-
closeSessionsOnShutdown: async () => {
|
|
111215
|
-
unregisterDirectHarnessInboundHandler();
|
|
111216
|
-
await closeAllMachineHarnessSessionsOnShutdown(session2, {
|
|
111217
|
-
lifecycleManager,
|
|
111218
|
-
activeSessions,
|
|
111219
|
-
sessionRepository
|
|
111220
|
-
});
|
|
111221
|
-
},
|
|
111222
|
-
stop: () => {
|
|
111223
|
-
unregisterDirectHarnessInboundHandler();
|
|
111224
|
-
lifecycleManager.stopMonitoring();
|
|
111225
|
-
}
|
|
111226
|
-
};
|
|
111227
|
-
}
|
|
111228
|
-
var init_start_subscriptions2 = __esm(() => {
|
|
111229
|
-
init_command_processor();
|
|
111230
|
-
init_harness_lifecycle_manager();
|
|
111231
|
-
init_prompt_drain2();
|
|
111232
|
-
init_session_processor2();
|
|
111233
|
-
init_shutdown_sessions();
|
|
111234
|
-
init_api3();
|
|
111235
|
-
init_convex_capabilities_publisher();
|
|
111236
|
-
init_convex_output_repository();
|
|
111237
|
-
init_convex_session_repository();
|
|
111238
|
-
});
|
|
111239
|
-
|
|
111240
110339
|
// src/daemon/entry/enhancer/constants.ts
|
|
111241
110340
|
var ENHANCER_AGENT_ROLE = "enhancer", ENHANCER_AGENT_END_GRACE_MS = 3000;
|
|
111242
110341
|
|
|
@@ -111418,16 +110517,16 @@ var init_wait_for_enhancer_job = __esm(() => {
|
|
|
111418
110517
|
|
|
111419
110518
|
// src/daemon/entry/enhancer-inbound-registry.ts
|
|
111420
110519
|
function registerEnhancerInboundHandler(h) {
|
|
111421
|
-
|
|
110520
|
+
handler3 = h;
|
|
111422
110521
|
}
|
|
111423
110522
|
function unregisterEnhancerInboundHandler() {
|
|
111424
|
-
|
|
110523
|
+
handler3 = undefined;
|
|
111425
110524
|
}
|
|
111426
110525
|
async function dispatchEnhancerInboundEvent(event) {
|
|
111427
|
-
if (
|
|
111428
|
-
await
|
|
110526
|
+
if (handler3)
|
|
110527
|
+
await handler3(event);
|
|
111429
110528
|
}
|
|
111430
|
-
var
|
|
110529
|
+
var handler3;
|
|
111431
110530
|
|
|
111432
110531
|
// src/daemon/entry/enhancer/job-subscriber.ts
|
|
111433
110532
|
async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsClient2, backend2, agentServices, job, inFlight2, logSink) {
|
|
@@ -111619,22 +110718,22 @@ var init_job_subscriber = __esm(() => {
|
|
|
111619
110718
|
function startEnhancerSubscriptions(sessionId, machineId, convexUrl, wsClient2, backend2, agentServices, logSink) {
|
|
111620
110719
|
return startEnhancerJobSubscriber(sessionId, machineId, convexUrl, wsClient2, backend2, agentServices, logSink);
|
|
111621
110720
|
}
|
|
111622
|
-
var
|
|
110721
|
+
var init_start_subscriptions2 = __esm(() => {
|
|
111623
110722
|
init_job_subscriber();
|
|
111624
110723
|
});
|
|
111625
110724
|
|
|
111626
110725
|
// src/daemon/entry/file-inbound-registry.ts
|
|
111627
110726
|
function registerFileInboundHandler(h) {
|
|
111628
|
-
|
|
110727
|
+
handler4 = h;
|
|
111629
110728
|
}
|
|
111630
110729
|
function unregisterFileInboundHandler() {
|
|
111631
|
-
|
|
110730
|
+
handler4 = undefined;
|
|
111632
110731
|
}
|
|
111633
110732
|
async function dispatchFileInboundEvent(event) {
|
|
111634
|
-
if (
|
|
111635
|
-
await
|
|
110733
|
+
if (handler4)
|
|
110734
|
+
await handler4(event);
|
|
111636
110735
|
}
|
|
111637
|
-
var
|
|
110736
|
+
var handler4;
|
|
111638
110737
|
|
|
111639
110738
|
// src/daemon/entry/files/file-content-classifier.ts
|
|
111640
110739
|
function extensionOf(path3) {
|
|
@@ -115721,7 +114820,7 @@ function createCoalescingStateOutbox(options) {
|
|
|
115721
114820
|
return;
|
|
115722
114821
|
timer = setTimeout(() => {
|
|
115723
114822
|
timer = null;
|
|
115724
|
-
|
|
114823
|
+
drain().catch(() => {
|
|
115725
114824
|
return;
|
|
115726
114825
|
});
|
|
115727
114826
|
}, Math.max(0, delayMs));
|
|
@@ -115730,7 +114829,7 @@ function createCoalescingStateOutbox(options) {
|
|
|
115730
114829
|
if (pending3) {
|
|
115731
114830
|
schedule2(retryAttempt > 0 ? computeExponentialRetryDelayMs(retryAttempt - 1, retryDelayMs, maxRetryDelayMs) : 0);
|
|
115732
114831
|
}
|
|
115733
|
-
async function
|
|
114832
|
+
async function drain() {
|
|
115734
114833
|
if (stopped || !pending3 || inFlight2)
|
|
115735
114834
|
return;
|
|
115736
114835
|
const batch = pending3;
|
|
@@ -115794,7 +114893,7 @@ function createCoalescingStateOutbox(options) {
|
|
|
115794
114893
|
});
|
|
115795
114894
|
}
|
|
115796
114895
|
if (pending3)
|
|
115797
|
-
await
|
|
114896
|
+
await drain();
|
|
115798
114897
|
};
|
|
115799
114898
|
const stop4 = async () => {
|
|
115800
114899
|
if (stopped)
|
|
@@ -118482,16 +117581,16 @@ var init_git_subscription = __esm(() => {
|
|
|
118482
117581
|
|
|
118483
117582
|
// src/daemon/entry/workspace-git-inbound-registry.ts
|
|
118484
117583
|
function registerWorkspaceGitInboundHandler(h) {
|
|
118485
|
-
|
|
117584
|
+
handler5 = h;
|
|
118486
117585
|
}
|
|
118487
117586
|
function unregisterWorkspaceGitInboundHandler() {
|
|
118488
|
-
|
|
117587
|
+
handler5 = undefined;
|
|
118489
117588
|
}
|
|
118490
117589
|
async function dispatchWorkspaceGitInboundEvent(event) {
|
|
118491
|
-
if (
|
|
118492
|
-
await
|
|
117590
|
+
if (handler5)
|
|
117591
|
+
await handler5(event);
|
|
118493
117592
|
}
|
|
118494
|
-
var
|
|
117593
|
+
var handler5;
|
|
118495
117594
|
|
|
118496
117595
|
// src/events/lifecycle/on-daemon-shutdown.ts
|
|
118497
117596
|
var onDaemonShutdownEffect;
|
|
@@ -118538,7 +117637,6 @@ function createDaemonRuntime(deps) {
|
|
|
118538
117637
|
let fileTreeSubscriptionHandle = null;
|
|
118539
117638
|
let workspaceListSubscriptionHandle = null;
|
|
118540
117639
|
let logObserverSubscriptionHandle = null;
|
|
118541
|
-
let directHarnessWorkerHandle = null;
|
|
118542
117640
|
let agenticQueryWorkerHandle = null;
|
|
118543
117641
|
let enhancerWorkerHandle = null;
|
|
118544
117642
|
let taskInboxHandle = null;
|
|
@@ -118578,7 +117676,6 @@ function createDaemonRuntime(deps) {
|
|
|
118578
117676
|
workspaceListSubscriptionHandle?.stop();
|
|
118579
117677
|
taskInboxHandle?.stop();
|
|
118580
117678
|
logObserverSubscriptionHandle?.stop();
|
|
118581
|
-
directHarnessWorkerHandle?.stop();
|
|
118582
117679
|
agenticQueryWorkerHandle?.stop();
|
|
118583
117680
|
enhancerWorkerHandle?.stop();
|
|
118584
117681
|
};
|
|
@@ -118603,12 +117700,8 @@ function createDaemonRuntime(deps) {
|
|
|
118603
117700
|
await deps.agentLifecycleOutbox?.stopAll().catch(() => {
|
|
118604
117701
|
return;
|
|
118605
117702
|
});
|
|
118606
|
-
|
|
118607
|
-
await withTimeout2(
|
|
118608
|
-
} else {
|
|
118609
|
-
for (const handle of activeSessions.values()) {
|
|
118610
|
-
await withTimeout2(handle.close(), CLOSE_TIMEOUT_MS);
|
|
118611
|
-
}
|
|
117703
|
+
for (const handle of activeSessions.values()) {
|
|
117704
|
+
await withTimeout2(handle.close(), CLOSE_TIMEOUT_MS);
|
|
118612
117705
|
}
|
|
118613
117706
|
for (const harness of harnesses.values()) {
|
|
118614
117707
|
await withTimeout2(harness.close(), CLOSE_TIMEOUT_MS);
|
|
@@ -118684,21 +117777,13 @@ function createDaemonRuntime(deps) {
|
|
|
118684
117777
|
taskInboxHandle = yield* startTaskInboxEffect(deps.wsClient);
|
|
118685
117778
|
logObserverSubscriptionHandle = startLogObserverSubscription({ sessionId: session2.sessionId, machineId: session2.machineId }, deps.wsClient);
|
|
118686
117779
|
const commandRunRuntime = yield* exports_Effect.runtime();
|
|
118687
|
-
|
|
118688
|
-
|
|
118689
|
-
|
|
118690
|
-
|
|
118691
|
-
|
|
118692
|
-
|
|
118693
|
-
|
|
118694
|
-
agenticQueryWorkerHandle = startAgenticQuerySubscriptions({
|
|
118695
|
-
sessionId: session2.sessionId,
|
|
118696
|
-
machineId: session2.machineId,
|
|
118697
|
-
backend: session2.backend,
|
|
118698
|
-
convexUrl: session2.convexUrl
|
|
118699
|
-
}, activeSessions, harnesses);
|
|
118700
|
-
enhancerWorkerHandle = startEnhancerSubscriptions(session2.sessionId, session2.machineId, session2.convexUrl, deps.wsClient, session2.backend, session2.agentServices, getActiveLogSink());
|
|
118701
|
-
}
|
|
117780
|
+
agenticQueryWorkerHandle = startAgenticQuerySubscriptions({
|
|
117781
|
+
sessionId: session2.sessionId,
|
|
117782
|
+
machineId: session2.machineId,
|
|
117783
|
+
backend: session2.backend,
|
|
117784
|
+
convexUrl: session2.convexUrl
|
|
117785
|
+
}, activeSessions, harnesses);
|
|
117786
|
+
enhancerWorkerHandle = startEnhancerSubscriptions(session2.sessionId, session2.machineId, session2.convexUrl, deps.wsClient, session2.backend, session2.agentServices, getActiveLogSink());
|
|
118702
117787
|
console.log(`
|
|
118703
117788
|
Listening for commands...`);
|
|
118704
117789
|
console.log(`Press Ctrl+C to stop
|
|
@@ -118725,14 +117810,12 @@ Listening for commands...`);
|
|
|
118725
117810
|
}
|
|
118726
117811
|
var PROCESS_KILL_TIMEOUT_MS = 6000, CLOSE_TIMEOUT_MS = 3000, SHUTDOWN_WATCHDOG_MS = 12000;
|
|
118727
117812
|
var init_daemon_runtime = __esm(() => {
|
|
118728
|
-
init_featureFlags();
|
|
118729
117813
|
init_reliability();
|
|
118730
117814
|
init_esm();
|
|
118731
117815
|
init_start_subscriptions();
|
|
118732
117816
|
init_command_dispatch();
|
|
118733
117817
|
init_daemon_services();
|
|
118734
117818
|
init_start_subscriptions2();
|
|
118735
|
-
init_start_subscriptions3();
|
|
118736
117819
|
init_file_content_subscription();
|
|
118737
117820
|
init_file_tree_subscription();
|
|
118738
117821
|
init_file_write_subscription();
|
|
@@ -118783,24 +117866,6 @@ function createCommandRouterDeps() {
|
|
|
118783
117866
|
}
|
|
118784
117867
|
var init_command_bridge = () => {};
|
|
118785
117868
|
|
|
118786
|
-
// src/daemon/domain/usecase/process-direct-harness-prompt.ts
|
|
118787
|
-
async function processDirectHarnessInbound(deps, event) {
|
|
118788
|
-
await deps.dispatchInbound(event);
|
|
118789
|
-
}
|
|
118790
|
-
var init_process_direct_harness_prompt = () => {};
|
|
118791
|
-
|
|
118792
|
-
// src/daemon/entry/bridge/direct-harness-bridge.ts
|
|
118793
|
-
function createDirectHarnessRouterDeps() {
|
|
118794
|
-
return {
|
|
118795
|
-
deliverInbound: async (event) => {
|
|
118796
|
-
await processDirectHarnessInbound({ dispatchInbound: dispatchDirectHarnessInboundEvent }, event);
|
|
118797
|
-
}
|
|
118798
|
-
};
|
|
118799
|
-
}
|
|
118800
|
-
var init_direct_harness_bridge = __esm(() => {
|
|
118801
|
-
init_process_direct_harness_prompt();
|
|
118802
|
-
});
|
|
118803
|
-
|
|
118804
117869
|
// src/daemon/domain/usecase/process-enhancer-job.ts
|
|
118805
117870
|
async function processEnhancerJobInbound(deps, event) {
|
|
118806
117871
|
await deps.dispatchInbound(event);
|
|
@@ -118882,7 +117947,6 @@ var init_workspace_git_bridge = () => {};
|
|
|
118882
117947
|
// src/daemon/entry/default-router-deps.ts
|
|
118883
117948
|
function createDefaultEventRouterDeps() {
|
|
118884
117949
|
return {
|
|
118885
|
-
directHarness: createDirectHarnessRouterDeps(),
|
|
118886
117950
|
command: createCommandRouterDeps(),
|
|
118887
117951
|
workspaceGit: createWorkspaceGitRouterDeps(),
|
|
118888
117952
|
file: createFileRouterDeps(),
|
|
@@ -118893,7 +117957,6 @@ function createDefaultEventRouterDeps() {
|
|
|
118893
117957
|
var init_default_router_deps = __esm(() => {
|
|
118894
117958
|
init_agentic_query_bridge();
|
|
118895
117959
|
init_command_bridge();
|
|
118896
|
-
init_direct_harness_bridge();
|
|
118897
117960
|
init_enhancer_bridge();
|
|
118898
117961
|
init_file_bridge();
|
|
118899
117962
|
init_workspace_git_bridge();
|
|
@@ -118932,24 +117995,6 @@ function createAssignedTaskStatusPublisher(deps) {
|
|
|
118932
117995
|
}
|
|
118933
117996
|
var init_assigned_task_status = () => {};
|
|
118934
117997
|
|
|
118935
|
-
// src/daemon/infrastructure/convex/publishers/capabilities.ts
|
|
118936
|
-
function createCapabilitiesPublisher(deps) {
|
|
118937
|
-
const capabilitiesPublisher = new ConvexCapabilitiesPublisher({
|
|
118938
|
-
backend: deps.backend,
|
|
118939
|
-
sessionId: deps.sessionId
|
|
118940
|
-
});
|
|
118941
|
-
return {
|
|
118942
|
-
async publish(event) {
|
|
118943
|
-
if (event.type !== "capabilities.updated")
|
|
118944
|
-
return;
|
|
118945
|
-
await capabilitiesPublisher.publish(event.capabilities);
|
|
118946
|
-
}
|
|
118947
|
-
};
|
|
118948
|
-
}
|
|
118949
|
-
var init_capabilities = __esm(() => {
|
|
118950
|
-
init_convex_capabilities_publisher();
|
|
118951
|
-
});
|
|
118952
|
-
|
|
118953
117998
|
// src/daemon/infrastructure/convex/publishers/command-result.ts
|
|
118954
117999
|
function createCommandResultPublisher(deps) {
|
|
118955
118000
|
return {
|
|
@@ -119067,77 +118112,6 @@ var init_models = __esm(() => {
|
|
|
119067
118112
|
init_api3();
|
|
119068
118113
|
});
|
|
119069
118114
|
|
|
119070
|
-
// src/daemon/infrastructure/convex/publishers/session-lifecycle.ts
|
|
119071
|
-
function createSessionLifecyclePublisher(deps) {
|
|
119072
|
-
const sessionRepository = new ConvexSessionRepository({
|
|
119073
|
-
backend: deps.backend,
|
|
119074
|
-
sessionId: deps.sessionId
|
|
119075
|
-
});
|
|
119076
|
-
return {
|
|
119077
|
-
async publish(event) {
|
|
119078
|
-
if (event.type !== "session.lifecycle")
|
|
119079
|
-
return;
|
|
119080
|
-
const { harnessSessionId, action, opencodeSessionId, sessionTitle } = event;
|
|
119081
|
-
switch (action) {
|
|
119082
|
-
case "opened":
|
|
119083
|
-
if (!opencodeSessionId || !sessionTitle)
|
|
119084
|
-
return;
|
|
119085
|
-
await sessionRepository.associateOpenCodeSessionId(harnessSessionId, opencodeSessionId, sessionTitle);
|
|
119086
|
-
break;
|
|
119087
|
-
case "resumed":
|
|
119088
|
-
await sessionRepository.markActive(harnessSessionId);
|
|
119089
|
-
break;
|
|
119090
|
-
case "idle":
|
|
119091
|
-
await sessionRepository.markIdle(harnessSessionId);
|
|
119092
|
-
break;
|
|
119093
|
-
case "closed":
|
|
119094
|
-
await sessionRepository.markClosed(harnessSessionId);
|
|
119095
|
-
break;
|
|
119096
|
-
case "failed":
|
|
119097
|
-
await sessionRepository.markFailed(harnessSessionId);
|
|
119098
|
-
break;
|
|
119099
|
-
}
|
|
119100
|
-
}
|
|
119101
|
-
};
|
|
119102
|
-
}
|
|
119103
|
-
var init_session_lifecycle = __esm(() => {
|
|
119104
|
-
init_convex_session_repository();
|
|
119105
|
-
});
|
|
119106
|
-
|
|
119107
|
-
// src/daemon/infrastructure/convex/publishers/turn-output.ts
|
|
119108
|
-
function createTurnOutputPublisher(deps) {
|
|
119109
|
-
const outputRepository = new ConvexOutputRepository({
|
|
119110
|
-
backend: deps.backend,
|
|
119111
|
-
sessionId: deps.sessionId
|
|
119112
|
-
});
|
|
119113
|
-
const sessionRepository = new ConvexSessionRepository({
|
|
119114
|
-
backend: deps.backend,
|
|
119115
|
-
sessionId: deps.sessionId
|
|
119116
|
-
});
|
|
119117
|
-
return {
|
|
119118
|
-
async publish(event) {
|
|
119119
|
-
if (event.type === "turn.chunk") {
|
|
119120
|
-
await outputRepository.appendChunks(event.harnessSessionId, [
|
|
119121
|
-
{
|
|
119122
|
-
content: event.content,
|
|
119123
|
-
timestamp: event.timestamp,
|
|
119124
|
-
messageId: event.messageId,
|
|
119125
|
-
partType: event.partType === "text" || event.partType === "reasoning" ? event.partType : undefined
|
|
119126
|
-
}
|
|
119127
|
-
]);
|
|
119128
|
-
return;
|
|
119129
|
-
}
|
|
119130
|
-
if (event.type === "turn.completed") {
|
|
119131
|
-
await sessionRepository.finalizeAssistantTurn(event.turnId);
|
|
119132
|
-
}
|
|
119133
|
-
}
|
|
119134
|
-
};
|
|
119135
|
-
}
|
|
119136
|
-
var init_turn_output = __esm(() => {
|
|
119137
|
-
init_convex_output_repository();
|
|
119138
|
-
init_convex_session_repository();
|
|
119139
|
-
});
|
|
119140
|
-
|
|
119141
118115
|
// src/daemon/infrastructure/convex/publishers/workspace-commands.ts
|
|
119142
118116
|
function createWorkspaceCommandsPublisher(deps) {
|
|
119143
118117
|
return {
|
|
@@ -119161,11 +118135,8 @@ var init_workspace_commands = __esm(() => {
|
|
|
119161
118135
|
function createConvexPublishers(deps) {
|
|
119162
118136
|
return {
|
|
119163
118137
|
heartbeat: createDaemonHeartbeatPublisher(deps),
|
|
119164
|
-
turnOutput: createTurnOutputPublisher(deps),
|
|
119165
|
-
sessionLifecycle: createSessionLifecyclePublisher(deps),
|
|
119166
118138
|
assignedTaskStatus: createAssignedTaskStatusPublisher(deps),
|
|
119167
118139
|
gitState: createGitStatePublisher(deps),
|
|
119168
|
-
capabilities: createCapabilitiesPublisher(deps),
|
|
119169
118140
|
models: createModelsPublisher(deps),
|
|
119170
118141
|
harnessFingerprint: createHarnessFingerprintPublisher(deps),
|
|
119171
118142
|
commandResult: createCommandResultPublisher(deps),
|
|
@@ -119176,17 +118147,10 @@ function routeConvexEvent(publishers, event) {
|
|
|
119176
118147
|
switch (event.type) {
|
|
119177
118148
|
case "heartbeat":
|
|
119178
118149
|
return publishers.heartbeat.publish(event);
|
|
119179
|
-
case "turn.chunk":
|
|
119180
|
-
case "turn.completed":
|
|
119181
|
-
return publishers.turnOutput.publish(event);
|
|
119182
|
-
case "session.lifecycle":
|
|
119183
|
-
return publishers.sessionLifecycle.publish(event);
|
|
119184
118150
|
case "task.status":
|
|
119185
118151
|
return publishers.assignedTaskStatus.publish(event);
|
|
119186
118152
|
case "git.state":
|
|
119187
118153
|
return publishers.gitState.publish(event);
|
|
119188
|
-
case "capabilities.updated":
|
|
119189
|
-
return publishers.capabilities.publish(event);
|
|
119190
118154
|
case "models.updated":
|
|
119191
118155
|
return publishers.models.publish(event);
|
|
119192
118156
|
case "harness.fingerprint.updated":
|
|
@@ -119224,14 +118188,11 @@ function createPublisherRegistry(deps = {}) {
|
|
|
119224
118188
|
}
|
|
119225
118189
|
var init_publisher_registry = __esm(() => {
|
|
119226
118190
|
init_assigned_task_status();
|
|
119227
|
-
init_capabilities();
|
|
119228
118191
|
init_command_result();
|
|
119229
118192
|
init_daemon_heartbeat();
|
|
119230
118193
|
init_git_state();
|
|
119231
118194
|
init_harness_fingerprint();
|
|
119232
118195
|
init_models();
|
|
119233
|
-
init_session_lifecycle();
|
|
119234
|
-
init_turn_output();
|
|
119235
118196
|
init_workspace_commands();
|
|
119236
118197
|
});
|
|
119237
118198
|
|
|
@@ -119293,13 +118254,6 @@ async function handleCommandInbound(deps, event) {
|
|
|
119293
118254
|
}
|
|
119294
118255
|
}
|
|
119295
118256
|
|
|
119296
|
-
// src/daemon/domain/usecase/handle-direct-harness-inbound.ts
|
|
119297
|
-
async function handleDirectHarnessInbound(deps, event) {
|
|
119298
|
-
if (deps.deliverInbound) {
|
|
119299
|
-
await deps.deliverInbound(event);
|
|
119300
|
-
}
|
|
119301
|
-
}
|
|
119302
|
-
|
|
119303
118257
|
// src/daemon/domain/usecase/handle-enhancer-inbound.ts
|
|
119304
118258
|
async function handleEnhancerInbound(deps, event) {
|
|
119305
118259
|
if (deps.deliverInbound) {
|
|
@@ -119324,11 +118278,6 @@ async function handleWorkspaceGitInbound(deps, event) {
|
|
|
119324
118278
|
// src/daemon/entry/event-router.ts
|
|
119325
118279
|
async function routeInboundEvent(deps, event) {
|
|
119326
118280
|
switch (event.type) {
|
|
119327
|
-
case "direct-harness.session-opened":
|
|
119328
|
-
case "direct-harness.prompt":
|
|
119329
|
-
case "direct-harness.command":
|
|
119330
|
-
await handleDirectHarnessInbound(deps.directHarness, event);
|
|
119331
|
-
break;
|
|
119332
118281
|
case "command.received":
|
|
119333
118282
|
case "command-run.updated":
|
|
119334
118283
|
await handleCommandInbound(deps.command, event);
|
|
@@ -119359,7 +118308,7 @@ var init_event_router = () => {};
|
|
|
119359
118308
|
function startAgenticQueryPromptSubscriber(deps, onEvent) {
|
|
119360
118309
|
let processing = false;
|
|
119361
118310
|
const emittedThisDrain = new Set;
|
|
119362
|
-
const
|
|
118311
|
+
const drain = (batch) => {
|
|
119363
118312
|
if (!batch.messages?.length)
|
|
119364
118313
|
return;
|
|
119365
118314
|
const runIds = new Set(batch.messages.map((m) => m.runId));
|
|
@@ -119377,7 +118326,7 @@ function startAgenticQueryPromptSubscriber(deps, onEvent) {
|
|
|
119377
118326
|
return;
|
|
119378
118327
|
processing = true;
|
|
119379
118328
|
try {
|
|
119380
|
-
|
|
118329
|
+
drain(batch);
|
|
119381
118330
|
} finally {
|
|
119382
118331
|
processing = false;
|
|
119383
118332
|
emittedThisDrain.clear();
|
|
@@ -119457,106 +118406,6 @@ var init_command_run = __esm(() => {
|
|
|
119457
118406
|
init_api3();
|
|
119458
118407
|
});
|
|
119459
118408
|
|
|
119460
|
-
// src/daemon/infrastructure/convex/subscribers/direct-harness-command.ts
|
|
119461
|
-
function startDirectHarnessCommandSubscriber(deps, onEvent) {
|
|
119462
|
-
const seen = new Set;
|
|
119463
|
-
let processing = false;
|
|
119464
|
-
const drain2 = async () => {
|
|
119465
|
-
const pending3 = await deps.wsClient.query(api.daemon.directHarness.commands.listPendingCommands, { sessionId: deps.sessionId, machineId: deps.machineId });
|
|
119466
|
-
if (!pending3?.length)
|
|
119467
|
-
return;
|
|
119468
|
-
for (const cmd of pending3) {
|
|
119469
|
-
if (seen.has(cmd._id))
|
|
119470
|
-
continue;
|
|
119471
|
-
seen.add(cmd._id);
|
|
119472
|
-
onEvent({ type: "direct-harness.command", commandId: cmd._id });
|
|
119473
|
-
}
|
|
119474
|
-
};
|
|
119475
|
-
const unsub = deps.wsClient.onUpdate(api.daemon.directHarness.commands.listPendingCommands, { sessionId: deps.sessionId, machineId: deps.machineId }, () => {
|
|
119476
|
-
if (processing)
|
|
119477
|
-
return;
|
|
119478
|
-
processing = true;
|
|
119479
|
-
drain2().catch((err) => console.warn(`[daemon] direct-harness-command drain error: ${err instanceof Error ? err.message : String(err)}`)).finally(() => {
|
|
119480
|
-
processing = false;
|
|
119481
|
-
});
|
|
119482
|
-
}, (err) => {
|
|
119483
|
-
console.warn(`[daemon] direct-harness-command subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119484
|
-
});
|
|
119485
|
-
return {
|
|
119486
|
-
async stop() {
|
|
119487
|
-
unsub();
|
|
119488
|
-
}
|
|
119489
|
-
};
|
|
119490
|
-
}
|
|
119491
|
-
var init_direct_harness_command = __esm(() => {
|
|
119492
|
-
init_api3();
|
|
119493
|
-
});
|
|
119494
|
-
|
|
119495
|
-
// src/daemon/infrastructure/convex/subscribers/direct-harness-prompt.ts
|
|
119496
|
-
function startDirectHarnessPromptSubscriber(deps, onEvent) {
|
|
119497
|
-
let processing = false;
|
|
119498
|
-
const emittedForDrain = new Set;
|
|
119499
|
-
const drain2 = async () => {
|
|
119500
|
-
const pending3 = await deps.wsClient.query(api.daemon.directHarness.messages.pendingForMachine, { sessionId: deps.sessionId, machineId: deps.machineId });
|
|
119501
|
-
if (!pending3?.messages.length)
|
|
119502
|
-
return;
|
|
119503
|
-
const sessionIds = new Set(pending3.messages.map((m) => m.harnessSessionId));
|
|
119504
|
-
for (const harnessSessionId of sessionIds) {
|
|
119505
|
-
if (emittedForDrain.has(harnessSessionId))
|
|
119506
|
-
continue;
|
|
119507
|
-
emittedForDrain.add(harnessSessionId);
|
|
119508
|
-
onEvent({ type: "direct-harness.prompt", harnessSessionId });
|
|
119509
|
-
}
|
|
119510
|
-
};
|
|
119511
|
-
const unsub = deps.wsClient.onUpdate(api.daemon.directHarness.messages.pendingForMachine, { sessionId: deps.sessionId, machineId: deps.machineId }, () => {
|
|
119512
|
-
if (processing)
|
|
119513
|
-
return;
|
|
119514
|
-
processing = true;
|
|
119515
|
-
drain2().catch((err) => console.warn(`[daemon] direct-harness-prompt drain error: ${err instanceof Error ? err.message : String(err)}`)).finally(() => {
|
|
119516
|
-
processing = false;
|
|
119517
|
-
emittedForDrain.clear();
|
|
119518
|
-
});
|
|
119519
|
-
}, (err) => {
|
|
119520
|
-
console.warn(`[daemon] direct-harness-prompt subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119521
|
-
});
|
|
119522
|
-
return {
|
|
119523
|
-
async stop() {
|
|
119524
|
-
unsub();
|
|
119525
|
-
}
|
|
119526
|
-
};
|
|
119527
|
-
}
|
|
119528
|
-
var init_direct_harness_prompt = __esm(() => {
|
|
119529
|
-
init_api3();
|
|
119530
|
-
});
|
|
119531
|
-
|
|
119532
|
-
// src/daemon/infrastructure/convex/subscribers/direct-harness-session.ts
|
|
119533
|
-
function startDirectHarnessSessionSubscriber(deps, onEvent) {
|
|
119534
|
-
const seen = new Set;
|
|
119535
|
-
const unsub = deps.wsClient.onUpdate(api.daemon.directHarness.sessions.listPendingSessionsForMachine, { sessionId: deps.sessionId, machineId: deps.machineId }, (pendingSessions) => {
|
|
119536
|
-
if (!pendingSessions?.length)
|
|
119537
|
-
return;
|
|
119538
|
-
for (const session2 of pendingSessions) {
|
|
119539
|
-
if (seen.has(session2._id))
|
|
119540
|
-
continue;
|
|
119541
|
-
seen.add(session2._id);
|
|
119542
|
-
onEvent({
|
|
119543
|
-
type: "direct-harness.session-opened",
|
|
119544
|
-
harnessSessionId: session2._id
|
|
119545
|
-
});
|
|
119546
|
-
}
|
|
119547
|
-
}, (err) => {
|
|
119548
|
-
console.warn(`[daemon] direct-harness-session subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119549
|
-
});
|
|
119550
|
-
return {
|
|
119551
|
-
async stop() {
|
|
119552
|
-
unsub();
|
|
119553
|
-
}
|
|
119554
|
-
};
|
|
119555
|
-
}
|
|
119556
|
-
var init_direct_harness_session = __esm(() => {
|
|
119557
|
-
init_api3();
|
|
119558
|
-
});
|
|
119559
|
-
|
|
119560
118409
|
// src/daemon/infrastructure/convex/subscribers/enhancer-job.ts
|
|
119561
118410
|
function startEnhancerJobSubscriber2(deps, onEvent) {
|
|
119562
118411
|
const seen = new Set;
|
|
@@ -119775,7 +118624,7 @@ function startMachineCommandInboxSubscriber(deps, onClaimed) {
|
|
|
119775
118624
|
let queued = false;
|
|
119776
118625
|
let stopped = false;
|
|
119777
118626
|
const args2 = { sessionId: deps.sessionId, machineId: deps.machineId };
|
|
119778
|
-
const
|
|
118627
|
+
const drain = async () => {
|
|
119779
118628
|
if (stopped || draining) {
|
|
119780
118629
|
queued = true;
|
|
119781
118630
|
return;
|
|
@@ -119794,9 +118643,9 @@ function startMachineCommandInboxSubscriber(deps, onClaimed) {
|
|
|
119794
118643
|
};
|
|
119795
118644
|
const unsub = deps.wsClient.onUpdate(api.daemon.machineCommandInbox.watchNext, args2, (result) => {
|
|
119796
118645
|
if (result?.commandId)
|
|
119797
|
-
|
|
118646
|
+
drain();
|
|
119798
118647
|
}, (err) => console.warn(`[daemon] machine-command-inbox watch error: ${String(err)}`));
|
|
119799
|
-
|
|
118648
|
+
drain();
|
|
119800
118649
|
return {
|
|
119801
118650
|
async stop() {
|
|
119802
118651
|
stopped = true;
|
|
@@ -119813,9 +118662,6 @@ function startAllSubscribers(deps) {
|
|
|
119813
118662
|
const onEvent = (event) => {
|
|
119814
118663
|
routeInboundEvent(deps.router, event);
|
|
119815
118664
|
};
|
|
119816
|
-
const session2 = startDirectHarnessSessionSubscriber(deps, onEvent);
|
|
119817
|
-
const prompt = startDirectHarnessPromptSubscriber(deps, onEvent);
|
|
119818
|
-
const directHarnessCommand = startDirectHarnessCommandSubscriber(deps, onEvent);
|
|
119819
118665
|
const machineCommands = startMachineCommandInboxSubscriber(deps, async (claimed) => {
|
|
119820
118666
|
await dispatchCommandInboundEvent({
|
|
119821
118667
|
type: "command.received",
|
|
@@ -119835,9 +118681,6 @@ function startAllSubscribers(deps) {
|
|
|
119835
118681
|
return {
|
|
119836
118682
|
async stopAll() {
|
|
119837
118683
|
await Promise.all([
|
|
119838
|
-
session2.stop(),
|
|
119839
|
-
prompt.stop(),
|
|
119840
|
-
directHarnessCommand.stop(),
|
|
119841
118684
|
machineCommands.stop(),
|
|
119842
118685
|
commandRun.stop(),
|
|
119843
118686
|
gitRequest.stop(),
|
|
@@ -119857,9 +118700,6 @@ var init_subscriber_registry = __esm(() => {
|
|
|
119857
118700
|
init_agentic_query_prompt();
|
|
119858
118701
|
init_agentic_query_session();
|
|
119859
118702
|
init_command_run();
|
|
119860
|
-
init_direct_harness_command();
|
|
119861
|
-
init_direct_harness_prompt();
|
|
119862
|
-
init_direct_harness_session();
|
|
119863
118703
|
init_enhancer_job();
|
|
119864
118704
|
init_file_content_request();
|
|
119865
118705
|
init_file_tree_release_request();
|
|
@@ -122941,9 +121781,9 @@ var require_event_target2 = __commonJS((exports, module) => {
|
|
|
122941
121781
|
}
|
|
122942
121782
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
122943
121783
|
var EventTarget = {
|
|
122944
|
-
addEventListener(type,
|
|
121784
|
+
addEventListener(type, handler6, options = {}) {
|
|
122945
121785
|
for (const listener of this.listeners(type)) {
|
|
122946
|
-
if (!options[kForOnEventAttribute] && listener[kListener] ===
|
|
121786
|
+
if (!options[kForOnEventAttribute] && listener[kListener] === handler6 && !listener[kForOnEventAttribute]) {
|
|
122947
121787
|
return;
|
|
122948
121788
|
}
|
|
122949
121789
|
}
|
|
@@ -122954,7 +121794,7 @@ var require_event_target2 = __commonJS((exports, module) => {
|
|
|
122954
121794
|
data: isBinary ? data : data.toString()
|
|
122955
121795
|
});
|
|
122956
121796
|
event[kTarget] = this;
|
|
122957
|
-
callListener(
|
|
121797
|
+
callListener(handler6, this, event);
|
|
122958
121798
|
};
|
|
122959
121799
|
} else if (type === "close") {
|
|
122960
121800
|
wrapper = function onClose(code2, message) {
|
|
@@ -122964,7 +121804,7 @@ var require_event_target2 = __commonJS((exports, module) => {
|
|
|
122964
121804
|
wasClean: this._closeFrameReceived && this._closeFrameSent
|
|
122965
121805
|
});
|
|
122966
121806
|
event[kTarget] = this;
|
|
122967
|
-
callListener(
|
|
121807
|
+
callListener(handler6, this, event);
|
|
122968
121808
|
};
|
|
122969
121809
|
} else if (type === "error") {
|
|
122970
121810
|
wrapper = function onError3(error51) {
|
|
@@ -122973,28 +121813,28 @@ var require_event_target2 = __commonJS((exports, module) => {
|
|
|
122973
121813
|
message: error51.message
|
|
122974
121814
|
});
|
|
122975
121815
|
event[kTarget] = this;
|
|
122976
|
-
callListener(
|
|
121816
|
+
callListener(handler6, this, event);
|
|
122977
121817
|
};
|
|
122978
121818
|
} else if (type === "open") {
|
|
122979
121819
|
wrapper = function onOpen() {
|
|
122980
121820
|
const event = new Event2("open");
|
|
122981
121821
|
event[kTarget] = this;
|
|
122982
|
-
callListener(
|
|
121822
|
+
callListener(handler6, this, event);
|
|
122983
121823
|
};
|
|
122984
121824
|
} else {
|
|
122985
121825
|
return;
|
|
122986
121826
|
}
|
|
122987
121827
|
wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
|
|
122988
|
-
wrapper[kListener] =
|
|
121828
|
+
wrapper[kListener] = handler6;
|
|
122989
121829
|
if (options.once) {
|
|
122990
121830
|
this.once(type, wrapper);
|
|
122991
121831
|
} else {
|
|
122992
121832
|
this.on(type, wrapper);
|
|
122993
121833
|
}
|
|
122994
121834
|
},
|
|
122995
|
-
removeEventListener(type,
|
|
121835
|
+
removeEventListener(type, handler6) {
|
|
122996
121836
|
for (const listener of this.listeners(type)) {
|
|
122997
|
-
if (listener[kListener] ===
|
|
121837
|
+
if (listener[kListener] === handler6 && !listener[kForOnEventAttribute]) {
|
|
122998
121838
|
this.removeListener(type, listener);
|
|
122999
121839
|
break;
|
|
123000
121840
|
}
|
|
@@ -123523,16 +122363,16 @@ var require_websocket2 = __commonJS((exports, module) => {
|
|
|
123523
122363
|
}
|
|
123524
122364
|
return null;
|
|
123525
122365
|
},
|
|
123526
|
-
set(
|
|
122366
|
+
set(handler6) {
|
|
123527
122367
|
for (const listener of this.listeners(method)) {
|
|
123528
122368
|
if (listener[kForOnEventAttribute]) {
|
|
123529
122369
|
this.removeListener(method, listener);
|
|
123530
122370
|
break;
|
|
123531
122371
|
}
|
|
123532
122372
|
}
|
|
123533
|
-
if (typeof
|
|
122373
|
+
if (typeof handler6 !== "function")
|
|
123534
122374
|
return;
|
|
123535
|
-
this.addEventListener(method,
|
|
122375
|
+
this.addEventListener(method, handler6, {
|
|
123536
122376
|
[kForOnEventAttribute]: true
|
|
123537
122377
|
});
|
|
123538
122378
|
}
|
|
@@ -134571,8 +133411,8 @@ import * as os2 from "os";
|
|
|
134571
133411
|
import * as path8 from "path";
|
|
134572
133412
|
async function isChatroomInstalledDefault() {
|
|
134573
133413
|
try {
|
|
134574
|
-
const { execSync:
|
|
134575
|
-
|
|
133414
|
+
const { execSync: execSync2 } = await import("child_process");
|
|
133415
|
+
execSync2("chatroom --version", { stdio: "pipe" });
|
|
134576
133416
|
return true;
|
|
134577
133417
|
} catch {
|
|
134578
133418
|
return false;
|
|
@@ -135626,4 +134466,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
135626
134466
|
});
|
|
135627
134467
|
program2.parse();
|
|
135628
134468
|
|
|
135629
|
-
//# debugId=
|
|
134469
|
+
//# debugId=471FD0F14F27D83064756E2164756E21
|