chatroom-cli 1.68.5 → 1.69.1
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 +789 -298
- package/dist/index.js.map +24 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2168,7 +2168,8 @@ __export(exports_stdin_heredoc, {
|
|
|
2168
2168
|
HANDOFF_STDIN_DELIMITER: () => HANDOFF_STDIN_DELIMITER,
|
|
2169
2169
|
HANDOFF_MESSAGE_MARKER: () => HANDOFF_MESSAGE_MARKER,
|
|
2170
2170
|
CONTEXT_STDIN_DELIMITER: () => CONTEXT_STDIN_DELIMITER,
|
|
2171
|
-
BACKLOG_STDIN_DELIMITER: () => BACKLOG_STDIN_DELIMITER
|
|
2171
|
+
BACKLOG_STDIN_DELIMITER: () => BACKLOG_STDIN_DELIMITER,
|
|
2172
|
+
AGENTIC_QUERY_STDIN_DELIMITER: () => AGENTIC_QUERY_STDIN_DELIMITER
|
|
2172
2173
|
});
|
|
2173
2174
|
function formatStdinHeredocCommand(commandPrefix, delimiter, placeholder, options) {
|
|
2174
2175
|
const marker = options?.messageMarker;
|
|
@@ -2204,16 +2205,18 @@ function findReservedDelimiterLines(content) {
|
|
|
2204
2205
|
}
|
|
2205
2206
|
return hits;
|
|
2206
2207
|
}
|
|
2207
|
-
var HANDOFF_STDIN_DELIMITER = "CHATROOM_HANDOFF_END", CONTEXT_STDIN_DELIMITER = "CHATROOM_CONTEXT_END", BACKLOG_STDIN_DELIMITER = "CHATROOM_BACKLOG_END", CLASSIFY_STDIN_DELIMITER = "CHATROOM_CLASSIFY_END", HANDOFF_MESSAGE_MARKER = "---MESSAGE---", RESERVED_STDIN_HEREDOC_DELIMITERS, RESERVED_STRUCTURED_PARAM_MARKERS;
|
|
2208
|
+
var HANDOFF_STDIN_DELIMITER = "CHATROOM_HANDOFF_END", CONTEXT_STDIN_DELIMITER = "CHATROOM_CONTEXT_END", BACKLOG_STDIN_DELIMITER = "CHATROOM_BACKLOG_END", AGENTIC_QUERY_STDIN_DELIMITER = "CHATROOM_AGENTIC_QUERY_END", CLASSIFY_STDIN_DELIMITER = "CHATROOM_CLASSIFY_END", HANDOFF_MESSAGE_MARKER = "---MESSAGE---", RESERVED_STDIN_HEREDOC_DELIMITERS, RESERVED_STRUCTURED_PARAM_MARKERS;
|
|
2208
2209
|
var init_stdin_heredoc = __esm(() => {
|
|
2209
2210
|
RESERVED_STDIN_HEREDOC_DELIMITERS = [
|
|
2210
2211
|
HANDOFF_STDIN_DELIMITER,
|
|
2211
2212
|
CONTEXT_STDIN_DELIMITER,
|
|
2212
2213
|
BACKLOG_STDIN_DELIMITER,
|
|
2214
|
+
AGENTIC_QUERY_STDIN_DELIMITER,
|
|
2213
2215
|
CLASSIFY_STDIN_DELIMITER
|
|
2214
2216
|
];
|
|
2215
2217
|
RESERVED_STRUCTURED_PARAM_MARKERS = [
|
|
2216
2218
|
HANDOFF_MESSAGE_MARKER,
|
|
2219
|
+
"---RESULT---",
|
|
2217
2220
|
"---TITLE---",
|
|
2218
2221
|
"---DESCRIPTION---",
|
|
2219
2222
|
"---TECH_SPECS---"
|
|
@@ -29916,6 +29919,22 @@ var init_commandcode = __esm(() => {
|
|
|
29916
29919
|
init_command_code_agent_service();
|
|
29917
29920
|
});
|
|
29918
29921
|
|
|
29922
|
+
// src/infrastructure/services/remote-agents/tap-process-stream-writes.ts
|
|
29923
|
+
function tapProcessStreamWrites(onWrite) {
|
|
29924
|
+
const stdoutOriginal = process.stdout.write.bind(process.stdout);
|
|
29925
|
+
const stderrOriginal = process.stderr.write.bind(process.stderr);
|
|
29926
|
+
const wrap = (original) => (...args2) => {
|
|
29927
|
+
onWrite();
|
|
29928
|
+
return original(...args2);
|
|
29929
|
+
};
|
|
29930
|
+
process.stdout.write = wrap(stdoutOriginal);
|
|
29931
|
+
process.stderr.write = wrap(stderrOriginal);
|
|
29932
|
+
return () => {
|
|
29933
|
+
process.stdout.write = stdoutOriginal;
|
|
29934
|
+
process.stderr.write = stderrOriginal;
|
|
29935
|
+
};
|
|
29936
|
+
}
|
|
29937
|
+
|
|
29919
29938
|
// src/infrastructure/services/remote-agents/cursor-sdk/cursor-models.ts
|
|
29920
29939
|
function resolveCursorSdkModel(model) {
|
|
29921
29940
|
const prefix = `${CURSOR_PROVIDER2}/`;
|
|
@@ -30505,56 +30524,66 @@ ${deferredResume}` : deferredResume;
|
|
|
30505
30524
|
isFirstTurn = true;
|
|
30506
30525
|
}
|
|
30507
30526
|
}
|
|
30508
|
-
const
|
|
30509
|
-
|
|
30510
|
-
|
|
30511
|
-
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
const adapter = new CursorSdkStreamAdapter(logPrefix, emitLogLine);
|
|
30515
|
-
wireNativeStreamAdapter({
|
|
30516
|
-
adapter,
|
|
30517
|
-
assistantTextCallbacks,
|
|
30518
|
-
outputCallbacks,
|
|
30519
|
-
agentEndCallbacks,
|
|
30520
|
-
entry
|
|
30521
|
-
});
|
|
30527
|
+
const notifyHarnessOutput = () => {
|
|
30528
|
+
entry.lastOutputAt = Date.now();
|
|
30529
|
+
for (const cb of outputCallbacks)
|
|
30530
|
+
cb();
|
|
30531
|
+
};
|
|
30532
|
+
const restoreStreamTap = tapProcessStreamWrites(notifyHarnessOutput);
|
|
30522
30533
|
try {
|
|
30523
|
-
|
|
30524
|
-
|
|
30525
|
-
|
|
30526
|
-
|
|
30534
|
+
const run3 = await withTimeout(agent.send(nextPrompt, {
|
|
30535
|
+
local: { force: isFirstTurn },
|
|
30536
|
+
idempotencyKey: randomUUID2()
|
|
30537
|
+
}), SEND_TIMEOUT_MS, "agent.send");
|
|
30538
|
+
session2.run = run3;
|
|
30539
|
+
isFirstTurn = false;
|
|
30540
|
+
const adapter = new CursorSdkStreamAdapter(logPrefix, emitLogLine);
|
|
30541
|
+
wireNativeStreamAdapter({
|
|
30542
|
+
adapter,
|
|
30543
|
+
assistantTextCallbacks,
|
|
30544
|
+
outputCallbacks,
|
|
30545
|
+
agentEndCallbacks,
|
|
30546
|
+
entry
|
|
30547
|
+
});
|
|
30548
|
+
try {
|
|
30549
|
+
for await (const message of run3.stream()) {
|
|
30550
|
+
if (session2.aborted)
|
|
30551
|
+
break;
|
|
30552
|
+
adapter.handleMessage(message);
|
|
30553
|
+
}
|
|
30554
|
+
} catch (streamErr) {
|
|
30555
|
+
exitCode = 1;
|
|
30556
|
+
writeSpawnError2(logPrefix, streamErr, emitLogLine);
|
|
30557
|
+
break;
|
|
30527
30558
|
}
|
|
30528
|
-
|
|
30529
|
-
|
|
30530
|
-
|
|
30531
|
-
|
|
30532
|
-
|
|
30533
|
-
|
|
30534
|
-
|
|
30535
|
-
|
|
30536
|
-
|
|
30537
|
-
|
|
30538
|
-
|
|
30539
|
-
|
|
30540
|
-
|
|
30541
|
-
|
|
30542
|
-
|
|
30543
|
-
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
if (result.status === "error") {
|
|
30548
|
-
exitCode = 2;
|
|
30549
|
-
const detail = typeof result.result === "string" && result.result.trim().length > 0 ? result.result.trim() : `no error detail from SDK (run ${result.id})`;
|
|
30550
|
-
const runErrorLine = formatAgentLogLine(logPrefix, "run-error", `run ${result.id} failed: ${detail}`);
|
|
30551
|
-
process.stderr.write(`${runErrorLine}
|
|
30559
|
+
if (session2.aborted) {
|
|
30560
|
+
exitCode = 1;
|
|
30561
|
+
exitSignal = "SIGTERM";
|
|
30562
|
+
break;
|
|
30563
|
+
}
|
|
30564
|
+
let result;
|
|
30565
|
+
try {
|
|
30566
|
+
result = await withTimeout(run3.wait(), RUN_WAIT_TIMEOUT_MS, "run.wait");
|
|
30567
|
+
} catch (waitErr) {
|
|
30568
|
+
exitCode = 1;
|
|
30569
|
+
writeSpawnError2(logPrefix, waitErr, emitLogLine);
|
|
30570
|
+
break;
|
|
30571
|
+
}
|
|
30572
|
+
adapter.flushPendingOutput();
|
|
30573
|
+
if (result.status === "error") {
|
|
30574
|
+
exitCode = 2;
|
|
30575
|
+
const detail = typeof result.result === "string" && result.result.trim().length > 0 ? result.result.trim() : `no error detail from SDK (run ${result.id})`;
|
|
30576
|
+
const runErrorLine = formatAgentLogLine(logPrefix, "run-error", `run ${result.id} failed: ${detail}`);
|
|
30577
|
+
process.stderr.write(`${runErrorLine}
|
|
30552
30578
|
`);
|
|
30553
|
-
|
|
30554
|
-
|
|
30579
|
+
emitLogLine(runErrorLine);
|
|
30580
|
+
break;
|
|
30581
|
+
}
|
|
30582
|
+
adapter.finish();
|
|
30583
|
+
nextPrompt = null;
|
|
30584
|
+
} finally {
|
|
30585
|
+
restoreStreamTap();
|
|
30555
30586
|
}
|
|
30556
|
-
adapter.finish();
|
|
30557
|
-
nextPrompt = null;
|
|
30558
30587
|
} catch (turnErr) {
|
|
30559
30588
|
exitCode = 1;
|
|
30560
30589
|
writeSpawnError2(logPrefix, turnErr, emitLogLine);
|
|
@@ -78962,6 +78991,83 @@ var init_handoff = __esm(() => {
|
|
|
78962
78991
|
init_error_formatting();
|
|
78963
78992
|
});
|
|
78964
78993
|
|
|
78994
|
+
// src/commands/agentic-query/complete.ts
|
|
78995
|
+
var exports_complete = {};
|
|
78996
|
+
__export(exports_complete, {
|
|
78997
|
+
agenticQueryComplete: () => agenticQueryComplete
|
|
78998
|
+
});
|
|
78999
|
+
async function createDefaultDeps9() {
|
|
79000
|
+
const client4 = await getConvexClient();
|
|
79001
|
+
return {
|
|
79002
|
+
backend: {
|
|
79003
|
+
mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
|
|
79004
|
+
query: (endpoint, args2) => client4.query(endpoint, args2)
|
|
79005
|
+
},
|
|
79006
|
+
session: {
|
|
79007
|
+
getSessionId,
|
|
79008
|
+
getConvexUrl,
|
|
79009
|
+
getOtherSessionUrls
|
|
79010
|
+
}
|
|
79011
|
+
};
|
|
79012
|
+
}
|
|
79013
|
+
function handleCompleteError(err) {
|
|
79014
|
+
return exports_Effect.sync(() => {
|
|
79015
|
+
if (err._tag === "NotAuthenticated") {
|
|
79016
|
+
formatAuthError(err.convexUrl, err.otherUrls);
|
|
79017
|
+
process.exit(1);
|
|
79018
|
+
}
|
|
79019
|
+
if (err._tag === "InvalidChatroomId") {
|
|
79020
|
+
formatChatroomIdError(err.id);
|
|
79021
|
+
process.exit(1);
|
|
79022
|
+
}
|
|
79023
|
+
console.error(`
|
|
79024
|
+
❌ ERROR: Agentic query complete failed`);
|
|
79025
|
+
console.error(`
|
|
79026
|
+
${err.errorData?.message ?? err.cause.message}`);
|
|
79027
|
+
process.exit(1);
|
|
79028
|
+
});
|
|
79029
|
+
}
|
|
79030
|
+
async function agenticQueryComplete(chatroomId, options) {
|
|
79031
|
+
const deps = await createDefaultDeps9();
|
|
79032
|
+
await exports_Effect.runPromise(agenticQueryCompleteEffect(chatroomId, options).pipe(exports_Effect.provide(commandServicesLayerFromDeps(deps)), exports_Effect.catchAll(handleCompleteError)));
|
|
79033
|
+
}
|
|
79034
|
+
var agenticQueryCompleteEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
79035
|
+
const backend2 = yield* BackendService;
|
|
79036
|
+
const sessionId = yield* requireSessionIdEffect((a) => ({
|
|
79037
|
+
_tag: "NotAuthenticated",
|
|
79038
|
+
convexUrl: a.convexUrl,
|
|
79039
|
+
otherUrls: a.otherUrls
|
|
79040
|
+
}));
|
|
79041
|
+
yield* validateChatroomIdEffect(chatroomId, (id3) => ({
|
|
79042
|
+
_tag: "InvalidChatroomId",
|
|
79043
|
+
id: id3
|
|
79044
|
+
}));
|
|
79045
|
+
yield* backend2.mutation(api.web.agenticQuery.index.complete, {
|
|
79046
|
+
sessionId,
|
|
79047
|
+
chatroomId,
|
|
79048
|
+
queryId: options.queryId,
|
|
79049
|
+
result: options.result
|
|
79050
|
+
}).pipe(exports_Effect.mapError((cause3) => {
|
|
79051
|
+
let errorData;
|
|
79052
|
+
if (cause3 instanceof ConvexError) {
|
|
79053
|
+
errorData = cause3.data;
|
|
79054
|
+
}
|
|
79055
|
+
return { _tag: "CompleteFailed", cause: cause3, errorData };
|
|
79056
|
+
}));
|
|
79057
|
+
yield* exports_Effect.sync(() => {
|
|
79058
|
+
console.log(`✅ Agentic query ${options.queryId} completed`);
|
|
79059
|
+
});
|
|
79060
|
+
});
|
|
79061
|
+
var init_complete = __esm(() => {
|
|
79062
|
+
init_values();
|
|
79063
|
+
init_esm();
|
|
79064
|
+
init_api3();
|
|
79065
|
+
init_storage();
|
|
79066
|
+
init_client2();
|
|
79067
|
+
init_services();
|
|
79068
|
+
init_error_formatting();
|
|
79069
|
+
});
|
|
79070
|
+
|
|
78965
79071
|
// src/commands/backlog/backlog-fs-service.ts
|
|
78966
79072
|
import * as nodeFs from "node:fs/promises";
|
|
78967
79073
|
var BacklogFsService, BacklogFsServiceLive, BacklogFsServiceFrom = (ops) => exports_Layer.succeed(BacklogFsService, {
|
|
@@ -79068,7 +79174,7 @@ function buildBaseLayer(d) {
|
|
|
79068
79174
|
function buildFsLayer(fs11) {
|
|
79069
79175
|
return fs11 ? BacklogFsServiceFrom(fs11) : BacklogFsServiceLive;
|
|
79070
79176
|
}
|
|
79071
|
-
async function
|
|
79177
|
+
async function createDefaultDeps10() {
|
|
79072
79178
|
const client4 = await getConvexClient();
|
|
79073
79179
|
const fs11 = await import("node:fs/promises");
|
|
79074
79180
|
return {
|
|
@@ -79124,47 +79230,47 @@ function computeContentHash(content) {
|
|
|
79124
79230
|
return createHash("sha256").update(content).digest("hex");
|
|
79125
79231
|
}
|
|
79126
79232
|
async function listBacklog(chatroomId, options, deps) {
|
|
79127
|
-
const d = deps ?? await
|
|
79233
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79128
79234
|
await exports_Effect.runPromise(listBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79129
79235
|
}
|
|
79130
79236
|
async function addBacklog(chatroomId, options, deps) {
|
|
79131
|
-
const d = deps ?? await
|
|
79237
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79132
79238
|
await exports_Effect.runPromise(addBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79133
79239
|
}
|
|
79134
79240
|
async function completeBacklog(chatroomId, options, deps) {
|
|
79135
|
-
const d = deps ?? await
|
|
79241
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79136
79242
|
await exports_Effect.runPromise(completeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79137
79243
|
}
|
|
79138
79244
|
async function reopenBacklog(chatroomId, options, deps) {
|
|
79139
|
-
const d = deps ?? await
|
|
79245
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79140
79246
|
await exports_Effect.runPromise(reopenBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79141
79247
|
}
|
|
79142
79248
|
async function patchBacklog(chatroomId, options, deps) {
|
|
79143
|
-
const d = deps ?? await
|
|
79249
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79144
79250
|
await exports_Effect.runPromise(patchBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79145
79251
|
}
|
|
79146
79252
|
async function scoreBacklog(chatroomId, options, deps) {
|
|
79147
|
-
const d = deps ?? await
|
|
79253
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79148
79254
|
await exports_Effect.runPromise(scoreBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79149
79255
|
}
|
|
79150
79256
|
async function markForReviewBacklog(chatroomId, options, deps) {
|
|
79151
|
-
const d = deps ?? await
|
|
79257
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79152
79258
|
await exports_Effect.runPromise(markForReviewBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79153
79259
|
}
|
|
79154
79260
|
async function historyBacklog(chatroomId, options, deps) {
|
|
79155
|
-
const d = deps ?? await
|
|
79261
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79156
79262
|
await exports_Effect.runPromise(historyBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79157
79263
|
}
|
|
79158
79264
|
async function updateBacklog(chatroomId, options, deps) {
|
|
79159
|
-
const d = deps ?? await
|
|
79265
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79160
79266
|
await exports_Effect.runPromise(updateBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79161
79267
|
}
|
|
79162
79268
|
async function closeBacklog(chatroomId, options, deps) {
|
|
79163
|
-
const d = deps ?? await
|
|
79269
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79164
79270
|
await exports_Effect.runPromise(closeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79165
79271
|
}
|
|
79166
79272
|
async function exportBacklog(chatroomId, options, deps) {
|
|
79167
|
-
const d = deps ?? await
|
|
79273
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79168
79274
|
if (!d.fs) {
|
|
79169
79275
|
console.error("❌ File system operations not available");
|
|
79170
79276
|
process.exit(1);
|
|
@@ -79173,7 +79279,7 @@ async function exportBacklog(chatroomId, options, deps) {
|
|
|
79173
79279
|
await exports_Effect.runPromise(exportBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(exports_Layer.merge(buildBaseLayer(d), buildFsLayer(d.fs)))));
|
|
79174
79280
|
}
|
|
79175
79281
|
async function importBacklog(chatroomId, options, deps) {
|
|
79176
|
-
const d = deps ?? await
|
|
79282
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79177
79283
|
if (!d.fs) {
|
|
79178
79284
|
console.error("❌ File system operations not available");
|
|
79179
79285
|
process.exit(1);
|
|
@@ -79934,7 +80040,7 @@ __export(exports_read, {
|
|
|
79934
80040
|
taskReadEffect: () => taskReadEffect,
|
|
79935
80041
|
taskRead: () => taskRead
|
|
79936
80042
|
});
|
|
79937
|
-
async function
|
|
80043
|
+
async function createDefaultDeps11() {
|
|
79938
80044
|
const client4 = await getConvexClient();
|
|
79939
80045
|
return {
|
|
79940
80046
|
backend: {
|
|
@@ -79976,7 +80082,7 @@ function handleTaskReadError(err) {
|
|
|
79976
80082
|
});
|
|
79977
80083
|
}
|
|
79978
80084
|
async function taskRead(chatroomId, options, deps) {
|
|
79979
|
-
const d = deps ?? await
|
|
80085
|
+
const d = deps ?? await createDefaultDeps11();
|
|
79980
80086
|
const layer = commandServicesLayerFromDeps(d);
|
|
79981
80087
|
await exports_Effect.runPromise(taskReadEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleTaskReadError(err)), exports_Effect.provide(layer)));
|
|
79982
80088
|
}
|
|
@@ -80067,7 +80173,7 @@ __export(exports_skill, {
|
|
|
80067
80173
|
activateSkillEffect: () => activateSkillEffect,
|
|
80068
80174
|
activateSkill: () => activateSkill
|
|
80069
80175
|
});
|
|
80070
|
-
async function
|
|
80176
|
+
async function createDefaultDeps12() {
|
|
80071
80177
|
const client4 = await getConvexClient();
|
|
80072
80178
|
return {
|
|
80073
80179
|
backend: {
|
|
@@ -80136,12 +80242,12 @@ function handleActivateSkillError(err) {
|
|
|
80136
80242
|
});
|
|
80137
80243
|
}
|
|
80138
80244
|
async function listSkills(chatroomId, options, deps) {
|
|
80139
|
-
const d = deps ?? await
|
|
80245
|
+
const d = deps ?? await createDefaultDeps12();
|
|
80140
80246
|
const layer = commandServicesLayerFromDeps(d);
|
|
80141
80247
|
await exports_Effect.runPromise(listSkillsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleListSkillsError(err)), exports_Effect.provide(layer)));
|
|
80142
80248
|
}
|
|
80143
80249
|
async function activateSkill(chatroomId, skillId, options, deps) {
|
|
80144
|
-
const d = deps ?? await
|
|
80250
|
+
const d = deps ?? await createDefaultDeps12();
|
|
80145
80251
|
const layer = commandServicesLayerFromDeps(d);
|
|
80146
80252
|
await exports_Effect.runPromise(activateSkillEffect(chatroomId, skillId, options).pipe(exports_Effect.catchAll((err) => handleActivateSkillError(err)), exports_Effect.provide(layer)));
|
|
80147
80253
|
}
|
|
@@ -80219,7 +80325,7 @@ __export(exports_messages, {
|
|
|
80219
80325
|
listBySenderRoleEffect: () => listBySenderRoleEffect,
|
|
80220
80326
|
listBySenderRole: () => listBySenderRole
|
|
80221
80327
|
});
|
|
80222
|
-
async function
|
|
80328
|
+
async function createDefaultDeps13() {
|
|
80223
80329
|
const client4 = await getConvexClient();
|
|
80224
80330
|
return {
|
|
80225
80331
|
backend: {
|
|
@@ -80280,12 +80386,12 @@ function handleMessagesError(err) {
|
|
|
80280
80386
|
});
|
|
80281
80387
|
}
|
|
80282
80388
|
async function listBySenderRole(chatroomId, options, deps) {
|
|
80283
|
-
const d = deps ?? await
|
|
80389
|
+
const d = deps ?? await createDefaultDeps13();
|
|
80284
80390
|
const layer = commandServicesLayerFromDeps(d);
|
|
80285
80391
|
await exports_Effect.runPromise(listBySenderRoleEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
80286
80392
|
}
|
|
80287
80393
|
async function listSinceMessage(chatroomId, options, deps) {
|
|
80288
|
-
const d = deps ?? await
|
|
80394
|
+
const d = deps ?? await createDefaultDeps13();
|
|
80289
80395
|
const layer = commandServicesLayerFromDeps(d);
|
|
80290
80396
|
await exports_Effect.runPromise(listSinceMessageEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
80291
80397
|
}
|
|
@@ -80415,7 +80521,7 @@ __export(exports_context2, {
|
|
|
80415
80521
|
inspectContextEffect: () => inspectContextEffect,
|
|
80416
80522
|
inspectContext: () => inspectContext
|
|
80417
80523
|
});
|
|
80418
|
-
async function
|
|
80524
|
+
async function createDefaultDeps14() {
|
|
80419
80525
|
const client4 = await getConvexClient();
|
|
80420
80526
|
return {
|
|
80421
80527
|
backend: {
|
|
@@ -80456,17 +80562,17 @@ function handleContextError(err) {
|
|
|
80456
80562
|
});
|
|
80457
80563
|
}
|
|
80458
80564
|
async function readContext(chatroomId, options, deps) {
|
|
80459
|
-
const d = deps ?? await
|
|
80565
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80460
80566
|
const layer = commandServicesLayerFromDeps(d);
|
|
80461
80567
|
await exports_Effect.runPromise(readContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80462
80568
|
}
|
|
80463
80569
|
async function newContext(chatroomId, options, deps) {
|
|
80464
|
-
const d = deps ?? await
|
|
80570
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80465
80571
|
const layer = commandServicesLayerFromDeps(d);
|
|
80466
80572
|
await exports_Effect.runPromise(newContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80467
80573
|
}
|
|
80468
80574
|
async function listContexts(chatroomId, options, deps) {
|
|
80469
|
-
const d = deps ?? await
|
|
80575
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80470
80576
|
const layer = commandServicesLayerFromDeps(d);
|
|
80471
80577
|
await exports_Effect.runPromise(listContextsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80472
80578
|
}
|
|
@@ -80474,7 +80580,7 @@ function viewTemplate() {
|
|
|
80474
80580
|
return getContextViewTemplate();
|
|
80475
80581
|
}
|
|
80476
80582
|
async function inspectContext(chatroomId, options, deps) {
|
|
80477
|
-
const d = deps ?? await
|
|
80583
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80478
80584
|
const layer = commandServicesLayerFromDeps(d);
|
|
80479
80585
|
await exports_Effect.runPromise(inspectContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80480
80586
|
}
|
|
@@ -80715,7 +80821,7 @@ __export(exports_guidelines, {
|
|
|
80715
80821
|
listGuidelineTypesEffect: () => listGuidelineTypesEffect,
|
|
80716
80822
|
listGuidelineTypes: () => listGuidelineTypes
|
|
80717
80823
|
});
|
|
80718
|
-
async function
|
|
80824
|
+
async function createDefaultDeps15() {
|
|
80719
80825
|
const client4 = await getConvexClient();
|
|
80720
80826
|
return {
|
|
80721
80827
|
backend: {
|
|
@@ -80756,12 +80862,12 @@ function handleListGuidelineTypesError(err) {
|
|
|
80756
80862
|
});
|
|
80757
80863
|
}
|
|
80758
80864
|
async function viewGuidelines(options, deps) {
|
|
80759
|
-
const d = deps ?? await
|
|
80865
|
+
const d = deps ?? await createDefaultDeps15();
|
|
80760
80866
|
const layer = layerFromDeps7(d);
|
|
80761
80867
|
await exports_Effect.runPromise(viewGuidelinesEffect(options).pipe(exports_Effect.catchAll((err) => handleViewGuidelinesError(err)), exports_Effect.provide(layer)));
|
|
80762
80868
|
}
|
|
80763
80869
|
async function listGuidelineTypes(deps) {
|
|
80764
|
-
const d = deps ?? await
|
|
80870
|
+
const d = deps ?? await createDefaultDeps15();
|
|
80765
80871
|
const layer = layerFromDeps7(d);
|
|
80766
80872
|
await exports_Effect.runPromise(listGuidelineTypesEffect().pipe(exports_Effect.catchAll((err) => handleListGuidelineTypesError(err)), exports_Effect.provide(layer)));
|
|
80767
80873
|
}
|
|
@@ -80831,7 +80937,7 @@ __export(exports_artifact, {
|
|
|
80831
80937
|
createArtifactEffect: () => createArtifactEffect,
|
|
80832
80938
|
createArtifact: () => createArtifact
|
|
80833
80939
|
});
|
|
80834
|
-
async function
|
|
80940
|
+
async function createDefaultDeps16() {
|
|
80835
80941
|
const client4 = await getConvexClient();
|
|
80836
80942
|
return {
|
|
80837
80943
|
backend: {
|
|
@@ -80853,19 +80959,19 @@ function handleArtifactError(err) {
|
|
|
80853
80959
|
});
|
|
80854
80960
|
}
|
|
80855
80961
|
async function createArtifact(chatroomId, options, deps) {
|
|
80856
|
-
const d = deps ?? await
|
|
80962
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80857
80963
|
const layer = commandServicesLayerFromDeps(d);
|
|
80858
80964
|
return exports_Effect.runPromise(createArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err).pipe(exports_Effect.map(() => {
|
|
80859
80965
|
return;
|
|
80860
80966
|
}))), exports_Effect.provide(layer)));
|
|
80861
80967
|
}
|
|
80862
80968
|
async function viewArtifact(chatroomId, options, deps) {
|
|
80863
|
-
const d = deps ?? await
|
|
80969
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80864
80970
|
const layer = commandServicesLayerFromDeps(d);
|
|
80865
80971
|
await exports_Effect.runPromise(viewArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
80866
80972
|
}
|
|
80867
80973
|
async function viewManyArtifacts(chatroomId, options, deps) {
|
|
80868
|
-
const d = deps ?? await
|
|
80974
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80869
80975
|
const layer = commandServicesLayerFromDeps(d);
|
|
80870
80976
|
await exports_Effect.runPromise(viewManyArtifactsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
80871
80977
|
}
|
|
@@ -81215,7 +81321,7 @@ __export(exports_telegram, {
|
|
|
81215
81321
|
sendMessageEffect: () => sendMessageEffect,
|
|
81216
81322
|
sendMessage: () => sendMessage
|
|
81217
81323
|
});
|
|
81218
|
-
async function
|
|
81324
|
+
async function createDefaultDeps17() {
|
|
81219
81325
|
const client4 = await getConvexClient();
|
|
81220
81326
|
return {
|
|
81221
81327
|
backend: {
|
|
@@ -81297,7 +81403,7 @@ ${err.cause.message}`);
|
|
|
81297
81403
|
});
|
|
81298
81404
|
}
|
|
81299
81405
|
async function sendMessage(options, deps) {
|
|
81300
|
-
const d = deps ?? await
|
|
81406
|
+
const d = deps ?? await createDefaultDeps17();
|
|
81301
81407
|
const layer = layerFromDeps8(d);
|
|
81302
81408
|
await exports_Effect.runPromise(sendMessageEffect(options).pipe(exports_Effect.catchAll((err) => handleSendMessageError(err)), exports_Effect.provide(layer)));
|
|
81303
81409
|
}
|
|
@@ -99216,7 +99322,7 @@ function harnessEventSessionId(event) {
|
|
|
99216
99322
|
|
|
99217
99323
|
class OpencodeSdkHarness {
|
|
99218
99324
|
type = "opencode-sdk";
|
|
99219
|
-
displayName = "
|
|
99325
|
+
displayName = "OpenCode (SDK)";
|
|
99220
99326
|
client;
|
|
99221
99327
|
childProcess;
|
|
99222
99328
|
cwd;
|
|
@@ -100299,6 +100405,24 @@ var init_opencode_session_events = __esm(() => {
|
|
|
100299
100405
|
];
|
|
100300
100406
|
});
|
|
100301
100407
|
|
|
100408
|
+
// src/commands/machine/daemon-start/shared-harness/bind-turn-message-on-event.ts
|
|
100409
|
+
function bindTurnMessageOnEvent(handle, sessionRepository, logPrefix) {
|
|
100410
|
+
let lastBoundKey = null;
|
|
100411
|
+
return () => {
|
|
100412
|
+
const turn = handle.currentTurn;
|
|
100413
|
+
if (!turn)
|
|
100414
|
+
return;
|
|
100415
|
+
const messageId = turn.messageId;
|
|
100416
|
+
if (messageId == null)
|
|
100417
|
+
return;
|
|
100418
|
+
const key = `${turn.turnId}:${messageId}`;
|
|
100419
|
+
if (key === lastBoundKey)
|
|
100420
|
+
return;
|
|
100421
|
+
lastBoundKey = key;
|
|
100422
|
+
sessionRepository.bindTurnMessageId(turn.turnId, messageId).catch((err) => console.warn(`[${logPrefix}] bindTurnMessageId error (resume):`, err));
|
|
100423
|
+
};
|
|
100424
|
+
}
|
|
100425
|
+
|
|
100302
100426
|
// src/commands/machine/daemon-start/direct-harness/prompt-subscriber.ts
|
|
100303
100427
|
function startMessageSubscriber(session2, wsClient2, deps) {
|
|
100304
100428
|
let processing = false;
|
|
@@ -100393,22 +100517,15 @@ function wireResumedSessionEvents(handle, deps, info) {
|
|
|
100393
100517
|
agent: info.lastUsedConfig.agent ?? "build",
|
|
100394
100518
|
model: info.lastUsedConfig.model
|
|
100395
100519
|
};
|
|
100396
|
-
|
|
100520
|
+
const bindTurnMessage = bindTurnMessageOnEvent(handle, deps.sessionRepository, "direct-harness");
|
|
100397
100521
|
handle.session.onEvent((event) => {
|
|
100398
|
-
|
|
100399
|
-
if (turn?.messageId !== null && turn?.messageId !== undefined) {
|
|
100400
|
-
const key = `${turn.turnId}:${turn.messageId}`;
|
|
100401
|
-
if (key !== lastBoundKey) {
|
|
100402
|
-
lastBoundKey = key;
|
|
100403
|
-
deps.sessionRepository.bindTurnMessageId(turn.turnId, turn.messageId).catch((err) => console.warn("[direct-harness] bindTurnMessageId error (resume):", err));
|
|
100404
|
-
}
|
|
100405
|
-
}
|
|
100522
|
+
bindTurnMessage();
|
|
100406
100523
|
if (event.type === OPENCODE_SESSION_EVENT_TYPES[0]) {
|
|
100407
100524
|
handleSessionIdle(handle, handle.journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[direct-harness] idle handler error (resume):", err));
|
|
100408
100525
|
}
|
|
100409
100526
|
});
|
|
100410
100527
|
}
|
|
100411
|
-
async function deliverPendingMessages(handle, deps, rowId, messages, info) {
|
|
100528
|
+
async function deliverPendingMessages(handle, deps, rowId, messages, info, _daemonSession) {
|
|
100412
100529
|
for (const msg of messages) {
|
|
100413
100530
|
const override = info?.lastUsedConfig ?? { agent: "build" };
|
|
100414
100531
|
try {
|
|
@@ -100449,7 +100566,7 @@ async function processSessionMessages(session2, deps, rowId, messages, info) {
|
|
|
100449
100566
|
await deps.sessionRepository.markActive(rowId).catch(() => {});
|
|
100450
100567
|
wireResumedSessionEvents(handle, deps, info);
|
|
100451
100568
|
}
|
|
100452
|
-
await deliverPendingMessages(handle, deps, rowId, messages, info);
|
|
100569
|
+
await deliverPendingMessages(handle, deps, rowId, messages, info, session2);
|
|
100453
100570
|
}
|
|
100454
100571
|
var init_prompt_subscriber = __esm(() => {
|
|
100455
100572
|
init_idle_handler();
|
|
@@ -100459,122 +100576,64 @@ var init_prompt_subscriber = __esm(() => {
|
|
|
100459
100576
|
init_opencode_session_events();
|
|
100460
100577
|
});
|
|
100461
100578
|
|
|
100462
|
-
// src/commands/machine/daemon-start/
|
|
100463
|
-
function
|
|
100464
|
-
const
|
|
100465
|
-
const
|
|
100466
|
-
|
|
100467
|
-
machineId: daemonSession.machineId
|
|
100468
|
-
}, (pendingSessions) => {
|
|
100469
|
-
if (!pendingSessions || pendingSessions.length === 0)
|
|
100470
|
-
return;
|
|
100471
|
-
for (const session2 of pendingSessions) {
|
|
100472
|
-
const rowId = session2._id;
|
|
100473
|
-
if (inFlight.has(rowId))
|
|
100474
|
-
continue;
|
|
100475
|
-
inFlight.add(rowId);
|
|
100476
|
-
processOne(daemonSession, deps, session2).finally(() => inFlight.delete(rowId));
|
|
100477
|
-
}
|
|
100478
|
-
}, (err) => {
|
|
100479
|
-
console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
100480
|
-
});
|
|
100481
|
-
return { stop: unsub };
|
|
100482
|
-
}
|
|
100483
|
-
async function getOrCreateHarness(daemonSession, deps, session2, workspace) {
|
|
100484
|
-
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
100485
|
-
const key = makeHarnessKey(session2.workspaceId, harnessName);
|
|
100486
|
-
let harness = deps.harnesses.get(key);
|
|
100579
|
+
// src/commands/machine/daemon-start/shared-harness/get-or-create-bound-harness.ts
|
|
100580
|
+
async function getOrCreateBoundHarness(params) {
|
|
100581
|
+
const { harnesses, workspaceId, harnessName, workingDir, convexUrl, logPrefix } = params;
|
|
100582
|
+
const key = makeHarnessKey(workspaceId, harnessName);
|
|
100583
|
+
let harness = harnesses.get(key);
|
|
100487
100584
|
if (harness && !harness.isAlive()) {
|
|
100488
|
-
console.warn(
|
|
100585
|
+
console.warn(`${logPrefix} Harness ${harnessName} for workspace ${workspaceId} is no longer alive — restarting`);
|
|
100489
100586
|
harness.close().catch(() => {});
|
|
100490
|
-
|
|
100587
|
+
harnesses.delete(key);
|
|
100491
100588
|
harness = undefined;
|
|
100492
100589
|
}
|
|
100493
100590
|
if (!harness) {
|
|
100494
100591
|
harness = await startBoundHarness({
|
|
100495
100592
|
harnessName,
|
|
100496
|
-
workingDir
|
|
100497
|
-
workspaceId
|
|
100498
|
-
resolvedConvexUrl:
|
|
100593
|
+
workingDir,
|
|
100594
|
+
workspaceId,
|
|
100595
|
+
resolvedConvexUrl: convexUrl
|
|
100499
100596
|
});
|
|
100500
|
-
|
|
100597
|
+
harnesses.set(key, harness);
|
|
100501
100598
|
}
|
|
100502
100599
|
return harness;
|
|
100503
100600
|
}
|
|
100504
|
-
|
|
100505
|
-
|
|
100506
|
-
|
|
100507
|
-
|
|
100508
|
-
|
|
100509
|
-
|
|
100510
|
-
|
|
100511
|
-
|
|
100512
|
-
messageId: chunk2.messageId,
|
|
100513
|
-
partType: chunk2.partType
|
|
100514
|
-
});
|
|
100515
|
-
if (handle.currentTurn && handle.currentTurn.messageId === null) {
|
|
100516
|
-
handle.currentTurn.messageId = chunk2.messageId;
|
|
100517
|
-
deps.sessionRepository.bindTurnMessageId(handle.currentTurn.turnId, chunk2.messageId).catch((err) => console.warn("[direct-harness] bindTurnMessageId error:", err));
|
|
100518
|
-
}
|
|
100519
|
-
}
|
|
100520
|
-
function handleLiveSessionProviderId(event, deps, rowId, handle, liveSession) {
|
|
100521
|
-
if (event.type !== "session.provider_id")
|
|
100522
|
-
return;
|
|
100523
|
-
const sessionId = event.payload.sessionId;
|
|
100524
|
-
if (!sessionId || sessionId === handle.opencodeSessionId)
|
|
100525
|
-
return;
|
|
100526
|
-
deps.sessionRepository.associateOpenCodeSessionId(rowId, sessionId, liveSession.sessionTitle ?? "").catch((err) => console.warn("[direct-harness] associateOpenCodeSessionId (provider id) error:", err));
|
|
100527
|
-
}
|
|
100528
|
-
function handleLiveSessionTitleUpdate(event, deps, rowId, liveSession) {
|
|
100529
|
-
if (!isOpenCodeSessionEventType(event.type))
|
|
100530
|
-
return;
|
|
100531
|
-
if (event.type !== "session.updated") {
|
|
100532
|
-
return;
|
|
100533
|
-
}
|
|
100534
|
-
const info = event.payload.info;
|
|
100535
|
-
const newTitle = info?.title;
|
|
100536
|
-
if (!newTitle || newTitle === liveSession.sessionTitle) {
|
|
100537
|
-
return;
|
|
100538
|
-
}
|
|
100539
|
-
liveSession.setTitle?.(newTitle);
|
|
100540
|
-
deps.sessionRepository.updateSessionTitle(rowId, newTitle).catch((err) => console.warn("[direct-harness] updateSessionTitle error:", err));
|
|
100541
|
-
}
|
|
100542
|
-
function handleLiveSessionEvent(event, ctx) {
|
|
100543
|
-
const { handle, journal, extractChunk, idleConfig, deps, rowId, liveSession } = ctx;
|
|
100544
|
-
recordLiveSessionChunk(event, handle, journal, extractChunk, deps);
|
|
100545
|
-
if (event.type === "session.idle") {
|
|
100546
|
-
handleSessionIdle(handle, journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[direct-harness] idle handler error:", err));
|
|
100547
|
-
}
|
|
100548
|
-
handleLiveSessionTitleUpdate(event, deps, rowId, liveSession);
|
|
100549
|
-
handleLiveSessionProviderId(event, deps, rowId, handle, liveSession);
|
|
100550
|
-
}
|
|
100551
|
-
async function processOne(daemonSession, deps, session2) {
|
|
100552
|
-
const rowId = session2._id;
|
|
100601
|
+
var init_get_or_create_bound_harness = __esm(() => {
|
|
100602
|
+
init_registry4();
|
|
100603
|
+
});
|
|
100604
|
+
|
|
100605
|
+
// src/commands/machine/daemon-start/shared-harness/open-pending-session.ts
|
|
100606
|
+
async function openPendingHarnessSession(daemonSession, deps, input, options) {
|
|
100607
|
+
const { rowId, workspaceId, harnessName, lastUsedConfig } = input;
|
|
100608
|
+
const { logPrefix, handleProviderIdEvents } = options;
|
|
100553
100609
|
try {
|
|
100554
100610
|
const workspace = await daemonSession.backend.query(api.workspaces.getWorkspaceById, {
|
|
100555
100611
|
sessionId: daemonSession.sessionId,
|
|
100556
|
-
workspaceId
|
|
100612
|
+
workspaceId
|
|
100557
100613
|
});
|
|
100558
100614
|
if (!workspace) {
|
|
100559
|
-
console.warn(
|
|
100615
|
+
console.warn(`${logPrefix} Workspace ${workspaceId} not found for session ${rowId}`);
|
|
100560
100616
|
await deps.sessionRepository.markFailed(rowId);
|
|
100561
100617
|
return;
|
|
100562
100618
|
}
|
|
100563
|
-
const
|
|
100564
|
-
|
|
100565
|
-
|
|
100619
|
+
const harness = await getOrCreateBoundHarness({
|
|
100620
|
+
harnesses: deps.harnesses,
|
|
100621
|
+
workspaceId,
|
|
100622
|
+
harnessName,
|
|
100623
|
+
workingDir: workspace.workingDir,
|
|
100624
|
+
convexUrl: daemonSession.convexUrl,
|
|
100625
|
+
logPrefix
|
|
100626
|
+
});
|
|
100627
|
+
const modelConfig = lastUsedConfig.model;
|
|
100566
100628
|
const model = modelConfig ? `${modelConfig.providerID}/${modelConfig.modelID}` : undefined;
|
|
100567
100629
|
const liveSession = await harness.newSession({
|
|
100568
|
-
agent:
|
|
100630
|
+
agent: lastUsedConfig.agent,
|
|
100569
100631
|
model,
|
|
100570
100632
|
harnessSessionId: rowId
|
|
100571
100633
|
});
|
|
100572
100634
|
const journal = deps.journalFactory.create(rowId);
|
|
100573
100635
|
const extractChunk = createChunkExtractor(harness.type);
|
|
100574
|
-
const idleConfig = {
|
|
100575
|
-
agent: session2.opencode?.lastUsedConfig.agent ?? "build",
|
|
100576
|
-
model: session2.opencode?.lastUsedConfig.model
|
|
100577
|
-
};
|
|
100636
|
+
const idleConfig = { agent: lastUsedConfig.agent, model: lastUsedConfig.model };
|
|
100578
100637
|
let unsubscribeEvents = () => {};
|
|
100579
100638
|
let closed = false;
|
|
100580
100639
|
const close2 = async () => {
|
|
@@ -100591,22 +100650,41 @@ async function processOne(daemonSession, deps, session2) {
|
|
|
100591
100650
|
harnessSessionId: rowId,
|
|
100592
100651
|
harnessName,
|
|
100593
100652
|
opencodeSessionId: liveSession.opencodeSessionId,
|
|
100594
|
-
workspaceId
|
|
100653
|
+
workspaceId,
|
|
100595
100654
|
session: liveSession,
|
|
100596
100655
|
journal,
|
|
100597
100656
|
currentTurn: null,
|
|
100598
100657
|
close: close2
|
|
100599
100658
|
};
|
|
100600
100659
|
unsubscribeEvents = liveSession.onEvent((event) => {
|
|
100601
|
-
|
|
100602
|
-
|
|
100603
|
-
journal
|
|
100604
|
-
|
|
100605
|
-
|
|
100606
|
-
|
|
100607
|
-
|
|
100608
|
-
|
|
100609
|
-
|
|
100660
|
+
const chunk2 = extractChunk(event);
|
|
100661
|
+
if (chunk2 !== null) {
|
|
100662
|
+
journal.record({
|
|
100663
|
+
content: chunk2.content,
|
|
100664
|
+
timestamp: Date.now(),
|
|
100665
|
+
messageId: chunk2.messageId,
|
|
100666
|
+
partType: chunk2.partType
|
|
100667
|
+
});
|
|
100668
|
+
if (handle.currentTurn && handle.currentTurn.messageId === null) {
|
|
100669
|
+
handle.currentTurn.messageId = chunk2.messageId;
|
|
100670
|
+
deps.sessionRepository.bindTurnMessageId(handle.currentTurn.turnId, chunk2.messageId).catch((err) => console.warn(`${logPrefix} bindTurnMessageId error:`, err));
|
|
100671
|
+
}
|
|
100672
|
+
}
|
|
100673
|
+
if (event.type === "session.idle") {
|
|
100674
|
+
handleSessionIdle(handle, journal, idleConfig, deps.sessionRepository).catch((err) => console.warn(`${logPrefix} idle handler error:`, err));
|
|
100675
|
+
}
|
|
100676
|
+
if (isOpenCodeSessionEventType(event.type) && event.type === "session.updated") {
|
|
100677
|
+
const info = event.payload.info;
|
|
100678
|
+
if (info?.title) {
|
|
100679
|
+
deps.sessionRepository.updateSessionTitle(rowId, info.title).catch((err) => console.warn(`${logPrefix} updateSessionTitle error:`, err));
|
|
100680
|
+
}
|
|
100681
|
+
}
|
|
100682
|
+
if (handleProviderIdEvents && event.type === "session.provider_id") {
|
|
100683
|
+
const sessionId = event.payload.sessionId;
|
|
100684
|
+
if (sessionId && sessionId !== handle.opencodeSessionId) {
|
|
100685
|
+
deps.sessionRepository.associateOpenCodeSessionId(rowId, sessionId, liveSession.sessionTitle ?? "").catch((err) => console.warn(`${logPrefix} associateOpenCodeSessionId (provider id) error:`, err));
|
|
100686
|
+
}
|
|
100687
|
+
}
|
|
100610
100688
|
});
|
|
100611
100689
|
deps.activeSessions.set(rowId, handle);
|
|
100612
100690
|
try {
|
|
@@ -100616,19 +100694,56 @@ async function processOne(daemonSession, deps, session2) {
|
|
|
100616
100694
|
await liveSession.close().catch(() => {});
|
|
100617
100695
|
throw err;
|
|
100618
100696
|
}
|
|
100619
|
-
console.log(
|
|
100697
|
+
console.log(`${logPrefix} Session opened: ${rowId} agent=${lastUsedConfig.agent} workspace=${workspaceId}`);
|
|
100620
100698
|
} catch (err) {
|
|
100621
|
-
console.warn(
|
|
100699
|
+
console.warn(`${logPrefix} Failed to open session ${rowId}:`, err instanceof Error ? err.message : String(err));
|
|
100622
100700
|
try {
|
|
100623
100701
|
await deps.sessionRepository.markFailed(rowId);
|
|
100624
100702
|
} catch {}
|
|
100625
100703
|
}
|
|
100626
100704
|
}
|
|
100627
|
-
var
|
|
100705
|
+
var init_open_pending_session = __esm(() => {
|
|
100628
100706
|
init_idle_handler();
|
|
100629
100707
|
init_api3();
|
|
100630
100708
|
init_registry4();
|
|
100631
100709
|
init_opencode_session_events();
|
|
100710
|
+
init_get_or_create_bound_harness();
|
|
100711
|
+
});
|
|
100712
|
+
|
|
100713
|
+
// src/commands/machine/daemon-start/direct-harness/session-subscriber.ts
|
|
100714
|
+
function startSessionSubscriber(daemonSession, wsClient2, deps) {
|
|
100715
|
+
const inFlight = new Set;
|
|
100716
|
+
const unsub = wsClient2.onUpdate(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
|
|
100717
|
+
sessionId: daemonSession.sessionId,
|
|
100718
|
+
machineId: daemonSession.machineId
|
|
100719
|
+
}, (pendingSessions) => {
|
|
100720
|
+
if (!pendingSessions || pendingSessions.length === 0)
|
|
100721
|
+
return;
|
|
100722
|
+
for (const session2 of pendingSessions) {
|
|
100723
|
+
const rowId = session2._id;
|
|
100724
|
+
if (inFlight.has(rowId))
|
|
100725
|
+
continue;
|
|
100726
|
+
inFlight.add(rowId);
|
|
100727
|
+
(async () => {
|
|
100728
|
+
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
100729
|
+
const agent = session2.opencode?.lastUsedConfig?.agent ?? "build";
|
|
100730
|
+
const model = session2.opencode?.lastUsedConfig?.model;
|
|
100731
|
+
await openPendingHarnessSession(daemonSession, deps, {
|
|
100732
|
+
rowId: session2._id,
|
|
100733
|
+
workspaceId: session2.workspaceId,
|
|
100734
|
+
harnessName,
|
|
100735
|
+
lastUsedConfig: { agent, ...model ? { model } : {} }
|
|
100736
|
+
}, { logPrefix: "[direct-harness]", handleProviderIdEvents: true });
|
|
100737
|
+
})().finally(() => inFlight.delete(rowId));
|
|
100738
|
+
}
|
|
100739
|
+
}, (err) => {
|
|
100740
|
+
console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
100741
|
+
});
|
|
100742
|
+
return { stop: unsub };
|
|
100743
|
+
}
|
|
100744
|
+
var init_session_subscriber = __esm(() => {
|
|
100745
|
+
init_api3();
|
|
100746
|
+
init_open_pending_session();
|
|
100632
100747
|
});
|
|
100633
100748
|
|
|
100634
100749
|
// src/commands/machine/daemon-start/direct-harness/shutdown-sessions.ts
|
|
@@ -101001,6 +101116,436 @@ var init_start_subscriptions = __esm(() => {
|
|
|
101001
101116
|
init_convex_session_repository();
|
|
101002
101117
|
});
|
|
101003
101118
|
|
|
101119
|
+
// ../../services/backend/prompts/agentic-query/system-prompt.ts
|
|
101120
|
+
function renderAgenticQuerySystemPrompt(params) {
|
|
101121
|
+
const completeCmd = `chatroom agentic-query complete --chatroom-id=${params.chatroomId} --query-id=${params.queryId} << 'CHATROOM_AGENTIC_QUERY_END'
|
|
101122
|
+
## Summary
|
|
101123
|
+
...
|
|
101124
|
+
|
|
101125
|
+
## Results
|
|
101126
|
+
...
|
|
101127
|
+
|
|
101128
|
+
## Grounding
|
|
101129
|
+
...
|
|
101130
|
+
|
|
101131
|
+
## Files
|
|
101132
|
+
...
|
|
101133
|
+
CHATROOM_AGENTIC_QUERY_END`;
|
|
101134
|
+
return [
|
|
101135
|
+
"You answer workspace-scoped search and ask queries by exploring the connected codebase.",
|
|
101136
|
+
"Use tools to read and search files. Prefer evidence over speculation.",
|
|
101137
|
+
"When done, submit results with the CLI heredoc below (markdown body only — no protocol markers like ---RESULT---).",
|
|
101138
|
+
"",
|
|
101139
|
+
"## Required markdown sections",
|
|
101140
|
+
"- ## Summary",
|
|
101141
|
+
"- ## Results",
|
|
101142
|
+
"- ## Grounding (required for ask mode; path:line evidence)",
|
|
101143
|
+
"- ## Files",
|
|
101144
|
+
"",
|
|
101145
|
+
"## Complete command",
|
|
101146
|
+
completeCmd,
|
|
101147
|
+
"",
|
|
101148
|
+
`Convex URL: ${params.convexUrl}`
|
|
101149
|
+
].join(`
|
|
101150
|
+
`);
|
|
101151
|
+
}
|
|
101152
|
+
|
|
101153
|
+
// src/commands/machine/daemon-start/agentic-query/prompt-subscriber.ts
|
|
101154
|
+
async function ensureHarnessAlive(daemonSession, deps, info) {
|
|
101155
|
+
const key = makeHarnessKey(info.workspaceId, info.harnessName);
|
|
101156
|
+
const existing = deps.harnesses.get(key);
|
|
101157
|
+
if (existing?.isAlive())
|
|
101158
|
+
return existing;
|
|
101159
|
+
if (existing) {
|
|
101160
|
+
existing.close().catch(() => {});
|
|
101161
|
+
deps.harnesses.delete(key);
|
|
101162
|
+
}
|
|
101163
|
+
const workspace = await daemonSession.backend.query(api.workspaces.getWorkspaceById, {
|
|
101164
|
+
sessionId: daemonSession.sessionId,
|
|
101165
|
+
workspaceId: info.workspaceId
|
|
101166
|
+
});
|
|
101167
|
+
if (!workspace) {
|
|
101168
|
+
console.warn(`[agentic-query] Cannot resume ${info.runId}: workspace not found`);
|
|
101169
|
+
return null;
|
|
101170
|
+
}
|
|
101171
|
+
const harness = await startBoundHarness({
|
|
101172
|
+
harnessName: info.harnessName,
|
|
101173
|
+
workingDir: workspace.workingDir,
|
|
101174
|
+
workspaceId: info.workspaceId,
|
|
101175
|
+
resolvedConvexUrl: daemonSession.convexUrl
|
|
101176
|
+
});
|
|
101177
|
+
deps.harnesses.set(key, harness);
|
|
101178
|
+
return harness;
|
|
101179
|
+
}
|
|
101180
|
+
function wireResumedIdle(handle, deps, info) {
|
|
101181
|
+
const idleConfig = {
|
|
101182
|
+
agent: info.lastUsedConfig.agent ?? "build",
|
|
101183
|
+
model: info.lastUsedConfig.model
|
|
101184
|
+
};
|
|
101185
|
+
const bindTurnMessage = bindTurnMessageOnEvent(handle, deps.sessionRepository, "agentic-query");
|
|
101186
|
+
handle.session.onEvent((event) => {
|
|
101187
|
+
bindTurnMessage();
|
|
101188
|
+
if (event.type === "session.idle") {
|
|
101189
|
+
handleSessionIdle(handle, handle.journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[agentic-query] idle handler error (resume):", err));
|
|
101190
|
+
}
|
|
101191
|
+
});
|
|
101192
|
+
}
|
|
101193
|
+
async function resolveSessionHandle(daemonSession, deps, info) {
|
|
101194
|
+
const rowId = info.runId;
|
|
101195
|
+
const cached5 = deps.activeSessions.get(rowId);
|
|
101196
|
+
if (cached5)
|
|
101197
|
+
return cached5;
|
|
101198
|
+
if (!info.opencodeSessionId || !info.harnessName) {
|
|
101199
|
+
console.log(`[agentic-query] Session ${rowId} not yet open — waiting for session-subscriber`);
|
|
101200
|
+
return null;
|
|
101201
|
+
}
|
|
101202
|
+
try {
|
|
101203
|
+
const harness = await ensureHarnessAlive(daemonSession, deps, info);
|
|
101204
|
+
if (!harness)
|
|
101205
|
+
return null;
|
|
101206
|
+
const resumed = await resumeSession({
|
|
101207
|
+
harness,
|
|
101208
|
+
journalFactory: deps.journalFactory,
|
|
101209
|
+
chunkExtractor: createChunkExtractor(harness.type)
|
|
101210
|
+
}, {
|
|
101211
|
+
harnessSessionId: rowId,
|
|
101212
|
+
opencodeSessionId: info.opencodeSessionId,
|
|
101213
|
+
workspaceId: info.workspaceId,
|
|
101214
|
+
harnessName: info.harnessName
|
|
101215
|
+
});
|
|
101216
|
+
deps.activeSessions.set(rowId, resumed);
|
|
101217
|
+
wireResumedIdle(resumed, deps, info);
|
|
101218
|
+
console.log(`[agentic-query] Resumed session ${rowId}`);
|
|
101219
|
+
return resumed;
|
|
101220
|
+
} catch (err) {
|
|
101221
|
+
console.warn(`[agentic-query] Resume failed for ${rowId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
101222
|
+
return null;
|
|
101223
|
+
}
|
|
101224
|
+
}
|
|
101225
|
+
async function deliverMessage(deps, daemonSession, existingSession, info, msg) {
|
|
101226
|
+
const rowId = info.runId;
|
|
101227
|
+
await deps.sessionRepository.setGenerating(rowId, true);
|
|
101228
|
+
const { turnId } = await deps.sessionRepository.beginAssistantTurn(rowId);
|
|
101229
|
+
existingSession.currentTurn = { turnId, messageId: null };
|
|
101230
|
+
await existingSession.session.prompt({
|
|
101231
|
+
parts: [{ type: "text", text: msg.content }],
|
|
101232
|
+
agent: info.lastUsedConfig.agent,
|
|
101233
|
+
...info.lastUsedConfig.model ? { model: info.lastUsedConfig.model } : {},
|
|
101234
|
+
system: renderAgenticQuerySystemPrompt({
|
|
101235
|
+
convexUrl: daemonSession.convexUrl,
|
|
101236
|
+
chatroomId: info.chatroomId,
|
|
101237
|
+
queryId: info.agenticQueryId
|
|
101238
|
+
})
|
|
101239
|
+
});
|
|
101240
|
+
try {
|
|
101241
|
+
await deps.sessionRepository.markTurnProcessed(rowId, msg.seq);
|
|
101242
|
+
} catch (err) {
|
|
101243
|
+
console.warn(`[agentic-query] markTurnProcessed failed for session ${rowId} seq=${msg.seq}: ${err}`);
|
|
101244
|
+
}
|
|
101245
|
+
}
|
|
101246
|
+
async function drainPendingBatch(daemonSession, deps, batch) {
|
|
101247
|
+
for (const info of batch.sessions) {
|
|
101248
|
+
const existingSession = await resolveSessionHandle(daemonSession, deps, info);
|
|
101249
|
+
if (!existingSession)
|
|
101250
|
+
continue;
|
|
101251
|
+
const pendingMsgs = batch.messages.filter((m) => m.runId === info.runId).sort((a, b) => a.seq - b.seq);
|
|
101252
|
+
for (const msg of pendingMsgs) {
|
|
101253
|
+
await deliverMessage(deps, daemonSession, existingSession, info, msg);
|
|
101254
|
+
}
|
|
101255
|
+
}
|
|
101256
|
+
}
|
|
101257
|
+
function startPromptSubscriber(daemonSession, wsClient2, deps) {
|
|
101258
|
+
const handle = wsClient2.onUpdate(api.daemon.agenticQuery.messages.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, async (batch) => {
|
|
101259
|
+
if (!batch)
|
|
101260
|
+
return;
|
|
101261
|
+
await drainPendingBatch(daemonSession, deps, batch);
|
|
101262
|
+
});
|
|
101263
|
+
return { stop: handle };
|
|
101264
|
+
}
|
|
101265
|
+
var init_prompt_subscriber2 = __esm(() => {
|
|
101266
|
+
init_api3();
|
|
101267
|
+
init_resume_session();
|
|
101268
|
+
init_registry4();
|
|
101269
|
+
init_idle_handler();
|
|
101270
|
+
});
|
|
101271
|
+
|
|
101272
|
+
// src/commands/machine/daemon-start/agentic-query/session-subscriber.ts
|
|
101273
|
+
function startSessionSubscriber2(daemonSession, wsClient2, deps) {
|
|
101274
|
+
const inFlight = new Set;
|
|
101275
|
+
const unsub = wsClient2.onUpdate(api.daemon.agenticQuery.runs.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, (pendingSessions) => {
|
|
101276
|
+
if (!pendingSessions || pendingSessions.length === 0)
|
|
101277
|
+
return;
|
|
101278
|
+
for (const session2 of pendingSessions) {
|
|
101279
|
+
const rowId = session2.runId;
|
|
101280
|
+
if (inFlight.has(rowId))
|
|
101281
|
+
continue;
|
|
101282
|
+
inFlight.add(rowId);
|
|
101283
|
+
openPendingHarnessSession(daemonSession, deps, {
|
|
101284
|
+
rowId: session2.runId,
|
|
101285
|
+
workspaceId: session2.workspaceId,
|
|
101286
|
+
harnessName: session2.harnessName,
|
|
101287
|
+
lastUsedConfig: session2.lastUsedConfig
|
|
101288
|
+
}, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() => inFlight.delete(rowId));
|
|
101289
|
+
}
|
|
101290
|
+
}, (err) => {
|
|
101291
|
+
console.warn("[agentic-query] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
101292
|
+
});
|
|
101293
|
+
return { stop: unsub };
|
|
101294
|
+
}
|
|
101295
|
+
var init_session_subscriber2 = __esm(() => {
|
|
101296
|
+
init_api3();
|
|
101297
|
+
init_open_pending_session();
|
|
101298
|
+
});
|
|
101299
|
+
|
|
101300
|
+
// src/infrastructure/repos/convex-agentic-query-output-repository.ts
|
|
101301
|
+
class ConvexAgenticQueryOutputRepository {
|
|
101302
|
+
options;
|
|
101303
|
+
constructor(options) {
|
|
101304
|
+
this.options = options;
|
|
101305
|
+
}
|
|
101306
|
+
async appendChunks(runId, chunks) {
|
|
101307
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101308
|
+
if (chunks.length === 0)
|
|
101309
|
+
return;
|
|
101310
|
+
await backend2.mutation(api.daemon.agenticQuery.messages.appendMessages, {
|
|
101311
|
+
sessionId,
|
|
101312
|
+
runId,
|
|
101313
|
+
chunks: chunks.map((c) => ({
|
|
101314
|
+
content: c.content,
|
|
101315
|
+
timestamp: c.timestamp,
|
|
101316
|
+
messageId: c.messageId,
|
|
101317
|
+
partType: c.partType
|
|
101318
|
+
}))
|
|
101319
|
+
});
|
|
101320
|
+
}
|
|
101321
|
+
}
|
|
101322
|
+
var init_convex_agentic_query_output_repository = __esm(() => {
|
|
101323
|
+
init_api3();
|
|
101324
|
+
});
|
|
101325
|
+
|
|
101326
|
+
// src/infrastructure/repos/convex-agentic-query-run-repository.ts
|
|
101327
|
+
class ConvexAgenticQueryRunRepository {
|
|
101328
|
+
options;
|
|
101329
|
+
constructor(options) {
|
|
101330
|
+
this.options = options;
|
|
101331
|
+
}
|
|
101332
|
+
async associateOpenCodeSessionId(harnessSessionId, opencodeSessionId, sessionTitle) {
|
|
101333
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101334
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.associateOpenCodeSessionId, {
|
|
101335
|
+
sessionId,
|
|
101336
|
+
runId: harnessSessionId,
|
|
101337
|
+
opencodeSessionId,
|
|
101338
|
+
sessionTitle
|
|
101339
|
+
});
|
|
101340
|
+
}
|
|
101341
|
+
async getOpenCodeSessionId(harnessSessionId) {
|
|
101342
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101343
|
+
const result = await backend2.query(api.daemon.agenticQuery.runs.getRun, {
|
|
101344
|
+
sessionId,
|
|
101345
|
+
runId: harnessSessionId
|
|
101346
|
+
});
|
|
101347
|
+
return result?.opencode?.opencodeSessionId;
|
|
101348
|
+
}
|
|
101349
|
+
async markClosed(harnessSessionId) {
|
|
101350
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101351
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.closeRun, {
|
|
101352
|
+
sessionId,
|
|
101353
|
+
runId: harnessSessionId
|
|
101354
|
+
});
|
|
101355
|
+
}
|
|
101356
|
+
async markIdle(harnessSessionId) {
|
|
101357
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101358
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markIdle, {
|
|
101359
|
+
sessionId,
|
|
101360
|
+
runId: harnessSessionId
|
|
101361
|
+
});
|
|
101362
|
+
}
|
|
101363
|
+
async markFailed(harnessSessionId) {
|
|
101364
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101365
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markFailed, {
|
|
101366
|
+
sessionId,
|
|
101367
|
+
runId: harnessSessionId
|
|
101368
|
+
});
|
|
101369
|
+
}
|
|
101370
|
+
async markActive(harnessSessionId) {
|
|
101371
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101372
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markActive, {
|
|
101373
|
+
sessionId,
|
|
101374
|
+
runId: harnessSessionId
|
|
101375
|
+
});
|
|
101376
|
+
}
|
|
101377
|
+
async markTurnProcessed(harnessSessionId, turnSeq) {
|
|
101378
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101379
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.markTurnProcessed, {
|
|
101380
|
+
sessionId,
|
|
101381
|
+
runId: harnessSessionId,
|
|
101382
|
+
turnSeq
|
|
101383
|
+
});
|
|
101384
|
+
}
|
|
101385
|
+
async setGenerating(harnessSessionId, isGenerating) {
|
|
101386
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101387
|
+
await backend2.mutation(api.daemon.agenticQuery.queue.setGenerating, {
|
|
101388
|
+
sessionId,
|
|
101389
|
+
runId: harnessSessionId,
|
|
101390
|
+
isGenerating
|
|
101391
|
+
});
|
|
101392
|
+
}
|
|
101393
|
+
async dequeueNext(harnessSessionId) {
|
|
101394
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101395
|
+
await backend2.mutation(api.daemon.agenticQuery.queue.dequeueNext, {
|
|
101396
|
+
sessionId,
|
|
101397
|
+
runId: harnessSessionId
|
|
101398
|
+
});
|
|
101399
|
+
return null;
|
|
101400
|
+
}
|
|
101401
|
+
async beginAssistantTurn(harnessSessionId) {
|
|
101402
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101403
|
+
return backend2.mutation(api.daemon.agenticQuery.turns.beginAssistantTurn, {
|
|
101404
|
+
sessionId,
|
|
101405
|
+
runId: harnessSessionId
|
|
101406
|
+
});
|
|
101407
|
+
}
|
|
101408
|
+
async bindTurnMessageId(turnId, messageId) {
|
|
101409
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101410
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.bindTurnMessageId, {
|
|
101411
|
+
sessionId,
|
|
101412
|
+
turnId,
|
|
101413
|
+
messageId
|
|
101414
|
+
});
|
|
101415
|
+
}
|
|
101416
|
+
async finalizeAssistantTurn(turnId) {
|
|
101417
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101418
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.finalizeAssistantTurn, {
|
|
101419
|
+
sessionId,
|
|
101420
|
+
turnId
|
|
101421
|
+
});
|
|
101422
|
+
}
|
|
101423
|
+
async updateSessionTitle(harnessSessionId, title) {}
|
|
101424
|
+
}
|
|
101425
|
+
var init_convex_agentic_query_run_repository = __esm(() => {
|
|
101426
|
+
init_api3();
|
|
101427
|
+
});
|
|
101428
|
+
|
|
101429
|
+
// src/commands/machine/daemon-start/agentic-query/start-subscriptions.ts
|
|
101430
|
+
function startAgenticQuerySubscriptions(session2, wsClient2, activeSessions, harnesses) {
|
|
101431
|
+
const sessionRepository = new ConvexAgenticQueryRunRepository({
|
|
101432
|
+
backend: session2.backend,
|
|
101433
|
+
sessionId: session2.sessionId
|
|
101434
|
+
});
|
|
101435
|
+
const outputRepository = new ConvexAgenticQueryOutputRepository({
|
|
101436
|
+
backend: session2.backend,
|
|
101437
|
+
sessionId: session2.sessionId
|
|
101438
|
+
});
|
|
101439
|
+
const journalFactory = new BufferedJournalFactory({ outputRepository });
|
|
101440
|
+
const deps = { activeSessions, harnesses, sessionRepository, journalFactory };
|
|
101441
|
+
const pendingPromptSubscriptionHandle = startPromptSubscriber(session2, wsClient2, deps);
|
|
101442
|
+
const pendingHarnessSessionSubscriptionHandle = startSessionSubscriber2(session2, wsClient2, deps);
|
|
101443
|
+
return {
|
|
101444
|
+
pendingPromptSubscriptionHandle,
|
|
101445
|
+
pendingHarnessSessionSubscriptionHandle
|
|
101446
|
+
};
|
|
101447
|
+
}
|
|
101448
|
+
var init_start_subscriptions2 = __esm(() => {
|
|
101449
|
+
init_prompt_subscriber2();
|
|
101450
|
+
init_session_subscriber2();
|
|
101451
|
+
init_convex_agentic_query_output_repository();
|
|
101452
|
+
init_convex_agentic_query_run_repository();
|
|
101453
|
+
});
|
|
101454
|
+
|
|
101455
|
+
// src/commands/machine/daemon-start/file-content-classifier.ts
|
|
101456
|
+
function extensionOf(path3) {
|
|
101457
|
+
const lastDot = path3.lastIndexOf(".");
|
|
101458
|
+
if (lastDot === -1)
|
|
101459
|
+
return null;
|
|
101460
|
+
return path3.slice(lastDot).toLowerCase();
|
|
101461
|
+
}
|
|
101462
|
+
function hasKnownBinaryExtension(path3) {
|
|
101463
|
+
const ext = extensionOf(path3);
|
|
101464
|
+
return ext !== null && BINARY_EXTENSIONS.has(ext);
|
|
101465
|
+
}
|
|
101466
|
+
function hasNulByte(buffer) {
|
|
101467
|
+
return buffer.includes(0);
|
|
101468
|
+
}
|
|
101469
|
+
function hasTooManyControlChars(buffer) {
|
|
101470
|
+
let count3 = 0;
|
|
101471
|
+
const threshold = Math.max(1, Math.floor(buffer.length * 0.01));
|
|
101472
|
+
for (const byte of buffer) {
|
|
101473
|
+
if (byte === 0)
|
|
101474
|
+
return true;
|
|
101475
|
+
if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
|
|
101476
|
+
count3++;
|
|
101477
|
+
if (count3 > threshold)
|
|
101478
|
+
return true;
|
|
101479
|
+
}
|
|
101480
|
+
}
|
|
101481
|
+
return false;
|
|
101482
|
+
}
|
|
101483
|
+
function classifyFileContent(path3, buffer) {
|
|
101484
|
+
if (hasKnownBinaryExtension(path3)) {
|
|
101485
|
+
return { kind: "binary", encoding: "binary" };
|
|
101486
|
+
}
|
|
101487
|
+
if (buffer.length === 0) {
|
|
101488
|
+
return { kind: "text", encoding: "utf8" };
|
|
101489
|
+
}
|
|
101490
|
+
if (hasNulByte(buffer)) {
|
|
101491
|
+
return { kind: "binary", encoding: "binary" };
|
|
101492
|
+
}
|
|
101493
|
+
try {
|
|
101494
|
+
const decoded = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
|
101495
|
+
if (decoded.length === 0) {
|
|
101496
|
+
return { kind: "text", encoding: "utf8" };
|
|
101497
|
+
}
|
|
101498
|
+
if (hasTooManyControlChars(buffer)) {
|
|
101499
|
+
return { kind: "binary", encoding: "binary" };
|
|
101500
|
+
}
|
|
101501
|
+
return { kind: "text", encoding: "utf8" };
|
|
101502
|
+
} catch {
|
|
101503
|
+
return { kind: "binary", encoding: "binary" };
|
|
101504
|
+
}
|
|
101505
|
+
}
|
|
101506
|
+
var BINARY_EXTENSIONS;
|
|
101507
|
+
var init_file_content_classifier = __esm(() => {
|
|
101508
|
+
BINARY_EXTENSIONS = new Set([
|
|
101509
|
+
".png",
|
|
101510
|
+
".jpg",
|
|
101511
|
+
".jpeg",
|
|
101512
|
+
".gif",
|
|
101513
|
+
".webp",
|
|
101514
|
+
".ico",
|
|
101515
|
+
".mp3",
|
|
101516
|
+
".mp4",
|
|
101517
|
+
".wav",
|
|
101518
|
+
".ogg",
|
|
101519
|
+
".webm",
|
|
101520
|
+
".zip",
|
|
101521
|
+
".tar",
|
|
101522
|
+
".gz",
|
|
101523
|
+
".bz2",
|
|
101524
|
+
".7z",
|
|
101525
|
+
".rar",
|
|
101526
|
+
".pdf",
|
|
101527
|
+
".doc",
|
|
101528
|
+
".docx",
|
|
101529
|
+
".xls",
|
|
101530
|
+
".xlsx",
|
|
101531
|
+
".ppt",
|
|
101532
|
+
".pptx",
|
|
101533
|
+
".woff",
|
|
101534
|
+
".woff2",
|
|
101535
|
+
".ttf",
|
|
101536
|
+
".otf",
|
|
101537
|
+
".eot",
|
|
101538
|
+
".exe",
|
|
101539
|
+
".dll",
|
|
101540
|
+
".so",
|
|
101541
|
+
".dylib",
|
|
101542
|
+
".bin",
|
|
101543
|
+
".dat",
|
|
101544
|
+
".db",
|
|
101545
|
+
".sqlite"
|
|
101546
|
+
]);
|
|
101547
|
+
});
|
|
101548
|
+
|
|
101004
101549
|
// src/infrastructure/services/workspace/normalize-working-dir.ts
|
|
101005
101550
|
function normalizeWorkingDirForLookup(workingDir) {
|
|
101006
101551
|
return workingDir.trim().replace(/[/\\]+$/, "");
|
|
@@ -101221,100 +101766,6 @@ var init_workspace_visibility_policy = __esm(() => {
|
|
|
101221
101766
|
];
|
|
101222
101767
|
});
|
|
101223
101768
|
|
|
101224
|
-
// src/commands/machine/daemon-start/file-content-classifier.ts
|
|
101225
|
-
function extensionOf(path3) {
|
|
101226
|
-
const lastDot = path3.lastIndexOf(".");
|
|
101227
|
-
if (lastDot === -1)
|
|
101228
|
-
return null;
|
|
101229
|
-
return path3.slice(lastDot).toLowerCase();
|
|
101230
|
-
}
|
|
101231
|
-
function hasKnownBinaryExtension(path3) {
|
|
101232
|
-
const ext = extensionOf(path3);
|
|
101233
|
-
return ext !== null && BINARY_EXTENSIONS.has(ext);
|
|
101234
|
-
}
|
|
101235
|
-
function hasNulByte(buffer) {
|
|
101236
|
-
return buffer.includes(0);
|
|
101237
|
-
}
|
|
101238
|
-
function hasTooManyControlChars(buffer) {
|
|
101239
|
-
let count3 = 0;
|
|
101240
|
-
const threshold = Math.max(1, Math.floor(buffer.length * 0.01));
|
|
101241
|
-
for (const byte of buffer) {
|
|
101242
|
-
if (byte === 0)
|
|
101243
|
-
return true;
|
|
101244
|
-
if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
|
|
101245
|
-
count3++;
|
|
101246
|
-
if (count3 > threshold)
|
|
101247
|
-
return true;
|
|
101248
|
-
}
|
|
101249
|
-
}
|
|
101250
|
-
return false;
|
|
101251
|
-
}
|
|
101252
|
-
function classifyFileContent(path3, buffer) {
|
|
101253
|
-
if (hasKnownBinaryExtension(path3)) {
|
|
101254
|
-
return { kind: "binary", encoding: "binary" };
|
|
101255
|
-
}
|
|
101256
|
-
if (buffer.length === 0) {
|
|
101257
|
-
return { kind: "text", encoding: "utf8" };
|
|
101258
|
-
}
|
|
101259
|
-
if (hasNulByte(buffer)) {
|
|
101260
|
-
return { kind: "binary", encoding: "binary" };
|
|
101261
|
-
}
|
|
101262
|
-
try {
|
|
101263
|
-
const decoded = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
|
101264
|
-
if (decoded.length === 0) {
|
|
101265
|
-
return { kind: "text", encoding: "utf8" };
|
|
101266
|
-
}
|
|
101267
|
-
if (hasTooManyControlChars(buffer)) {
|
|
101268
|
-
return { kind: "binary", encoding: "binary" };
|
|
101269
|
-
}
|
|
101270
|
-
return { kind: "text", encoding: "utf8" };
|
|
101271
|
-
} catch {
|
|
101272
|
-
return { kind: "binary", encoding: "binary" };
|
|
101273
|
-
}
|
|
101274
|
-
}
|
|
101275
|
-
var BINARY_EXTENSIONS;
|
|
101276
|
-
var init_file_content_classifier = __esm(() => {
|
|
101277
|
-
BINARY_EXTENSIONS = new Set([
|
|
101278
|
-
".png",
|
|
101279
|
-
".jpg",
|
|
101280
|
-
".jpeg",
|
|
101281
|
-
".gif",
|
|
101282
|
-
".webp",
|
|
101283
|
-
".ico",
|
|
101284
|
-
".mp3",
|
|
101285
|
-
".mp4",
|
|
101286
|
-
".wav",
|
|
101287
|
-
".ogg",
|
|
101288
|
-
".webm",
|
|
101289
|
-
".zip",
|
|
101290
|
-
".tar",
|
|
101291
|
-
".gz",
|
|
101292
|
-
".bz2",
|
|
101293
|
-
".7z",
|
|
101294
|
-
".rar",
|
|
101295
|
-
".pdf",
|
|
101296
|
-
".doc",
|
|
101297
|
-
".docx",
|
|
101298
|
-
".xls",
|
|
101299
|
-
".xlsx",
|
|
101300
|
-
".ppt",
|
|
101301
|
-
".pptx",
|
|
101302
|
-
".woff",
|
|
101303
|
-
".woff2",
|
|
101304
|
-
".ttf",
|
|
101305
|
-
".otf",
|
|
101306
|
-
".eot",
|
|
101307
|
-
".exe",
|
|
101308
|
-
".dll",
|
|
101309
|
-
".so",
|
|
101310
|
-
".dylib",
|
|
101311
|
-
".bin",
|
|
101312
|
-
".dat",
|
|
101313
|
-
".db",
|
|
101314
|
-
".sqlite"
|
|
101315
|
-
]);
|
|
101316
|
-
});
|
|
101317
|
-
|
|
101318
101769
|
// src/commands/machine/daemon-start/file-content-fulfillment.ts
|
|
101319
101770
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
101320
101771
|
import { gzipSync as gzipSync2 } from "node:zlib";
|
|
@@ -101347,11 +101798,11 @@ var MAX_CONTENT_BYTES, fulfillFileContentRequestsEffect;
|
|
|
101347
101798
|
var init_file_content_fulfillment = __esm(() => {
|
|
101348
101799
|
init_esm();
|
|
101349
101800
|
init_daemon_services();
|
|
101801
|
+
init_file_content_classifier();
|
|
101350
101802
|
init_api3();
|
|
101351
101803
|
init_assert_registered_working_dir();
|
|
101352
101804
|
init_workspace_path_security();
|
|
101353
101805
|
init_workspace_visibility_policy();
|
|
101354
|
-
init_file_content_classifier();
|
|
101355
101806
|
MAX_CONTENT_BYTES = 500 * 1024;
|
|
101356
101807
|
fulfillFileContentRequestsEffect = exports_Effect.gen(function* () {
|
|
101357
101808
|
const session2 = yield* DaemonSessionService;
|
|
@@ -108436,7 +108887,7 @@ async function discoverModelsForHarness(harness, service3) {
|
|
|
108436
108887
|
async function discoverModels(agentServices) {
|
|
108437
108888
|
return exports_Effect.runPromise(discoverModelsEffect(agentServices));
|
|
108438
108889
|
}
|
|
108439
|
-
function
|
|
108890
|
+
function createDefaultDeps18() {
|
|
108440
108891
|
return {
|
|
108441
108892
|
backend: {
|
|
108442
108893
|
mutation: async () => {
|
|
@@ -108771,7 +109222,7 @@ var init_init2 = __esm(() => {
|
|
|
108771
109222
|
convexUrl,
|
|
108772
109223
|
agentServices,
|
|
108773
109224
|
cachedModels,
|
|
108774
|
-
deps:
|
|
109225
|
+
deps: createDefaultDeps18()
|
|
108775
109226
|
});
|
|
108776
109227
|
yield* registerEventListenersEffect().pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
108777
109228
|
yield* logStartupEffect(cachedModels).pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
@@ -111649,6 +112100,7 @@ var init_command_loop = __esm(() => {
|
|
|
111649
112100
|
init_pid();
|
|
111650
112101
|
init_daemon_services();
|
|
111651
112102
|
init_start_subscriptions();
|
|
112103
|
+
init_start_subscriptions2();
|
|
111652
112104
|
init_file_content_subscription();
|
|
111653
112105
|
init_file_tree_subscription();
|
|
111654
112106
|
init_file_write_subscription();
|
|
@@ -111703,6 +112155,8 @@ var init_command_loop = __esm(() => {
|
|
|
111703
112155
|
let pendingPromptSubscriptionHandle = null;
|
|
111704
112156
|
let pendingHarnessSessionSubscriptionHandle = null;
|
|
111705
112157
|
let commandSubscriptionHandle = null;
|
|
112158
|
+
let aqPendingPromptSubscriptionHandle = null;
|
|
112159
|
+
let aqPendingHarnessSessionSubscriptionHandle = null;
|
|
111706
112160
|
let lifecycleManager = null;
|
|
111707
112161
|
let closeDirectHarnessSessionsOnShutdown = null;
|
|
111708
112162
|
const activeSessions = new Map;
|
|
@@ -111770,6 +112224,8 @@ var init_command_loop = __esm(() => {
|
|
|
111770
112224
|
pendingHarnessSessionSubscriptionHandle?.stop();
|
|
111771
112225
|
commandSubscriptionHandle?.stop();
|
|
111772
112226
|
lifecycleManager?.stopMonitoring();
|
|
112227
|
+
aqPendingPromptSubscriptionHandle?.stop();
|
|
112228
|
+
aqPendingHarnessSessionSubscriptionHandle?.stop();
|
|
111773
112229
|
};
|
|
111774
112230
|
const runDaemonShutdownEffect = async () => {
|
|
111775
112231
|
await withTimeout2(exports_Effect.runPromise(onDaemonShutdownEffect.pipe(exports_Effect.provide(effectContext2))), PROCESS_KILL_TIMEOUT_MS);
|
|
@@ -111823,6 +112279,14 @@ var init_command_loop = __esm(() => {
|
|
|
111823
112279
|
commandSubscriptionHandle = handles.commandSubscriptionHandle;
|
|
111824
112280
|
lifecycleManager = handles.lifecycleManager;
|
|
111825
112281
|
closeDirectHarnessSessionsOnShutdown = handles.closeSessionsOnShutdown;
|
|
112282
|
+
const aqHandles = startAgenticQuerySubscriptions({
|
|
112283
|
+
sessionId: session2.sessionId,
|
|
112284
|
+
machineId: session2.machineId,
|
|
112285
|
+
backend: session2.backend,
|
|
112286
|
+
convexUrl: session2.convexUrl
|
|
112287
|
+
}, wsClient2, activeSessions, harnesses);
|
|
112288
|
+
aqPendingPromptSubscriptionHandle = aqHandles.pendingPromptSubscriptionHandle;
|
|
112289
|
+
aqPendingHarnessSessionSubscriptionHandle = aqHandles.pendingHarnessSessionSubscriptionHandle;
|
|
111826
112290
|
}
|
|
111827
112291
|
console.log(`
|
|
111828
112292
|
Listening for commands...`);
|
|
@@ -112017,7 +112481,7 @@ async function isChatroomInstalledDefault() {
|
|
|
112017
112481
|
return false;
|
|
112018
112482
|
}
|
|
112019
112483
|
}
|
|
112020
|
-
async function
|
|
112484
|
+
async function createDefaultDeps19() {
|
|
112021
112485
|
const client4 = await getConvexClient();
|
|
112022
112486
|
const fs12 = await import("fs/promises");
|
|
112023
112487
|
return {
|
|
@@ -112092,7 +112556,7 @@ After installation, run this command again.`;
|
|
|
112092
112556
|
});
|
|
112093
112557
|
}
|
|
112094
112558
|
async function installTool(options = {}, deps) {
|
|
112095
|
-
const d = deps ?? await
|
|
112559
|
+
const d = deps ?? await createDefaultDeps19();
|
|
112096
112560
|
const layer = layerFromDeps9(d);
|
|
112097
112561
|
return exports_Effect.runPromise(installToolEffect(options).pipe(exports_Effect.catchAll((err) => handleInstallError(err)), exports_Effect.provide(layer)));
|
|
112098
112562
|
}
|
|
@@ -112650,6 +113114,33 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
|
|
|
112650
113114
|
nextRole: options.nextRole
|
|
112651
113115
|
});
|
|
112652
113116
|
});
|
|
113117
|
+
var agenticQueryCommand = program2.command("agentic-query").description("Agentic search/ask query commands");
|
|
113118
|
+
agenticQueryCommand.command("complete").description("Submit the structured agentic query result markdown").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--query-id <id>", "Agentic query identifier").action(async (options) => {
|
|
113119
|
+
await maybeRequireAuth();
|
|
113120
|
+
const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
|
|
113121
|
+
const stdinContent = await readStdin();
|
|
113122
|
+
let result;
|
|
113123
|
+
try {
|
|
113124
|
+
const { AGENTIC_QUERY_STDIN_DELIMITER: AGENTIC_QUERY_STDIN_DELIMITER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
|
|
113125
|
+
const decoded = decode5(stdinContent, { singleParam: "result" });
|
|
113126
|
+
let body = decoded.result;
|
|
113127
|
+
body = body.replace(/^(---RESULT---\s*)+/i, "").trim();
|
|
113128
|
+
validateStdinHeredocBody2(body, AGENTIC_QUERY_STDIN_DELIMITER2);
|
|
113129
|
+
result = body;
|
|
113130
|
+
} catch (err) {
|
|
113131
|
+
console.error(`❌ Failed to decode stdin: ${err.message}`);
|
|
113132
|
+
process.exit(1);
|
|
113133
|
+
}
|
|
113134
|
+
if (!result?.trim()) {
|
|
113135
|
+
console.error("❌ Result body is empty");
|
|
113136
|
+
process.exit(1);
|
|
113137
|
+
}
|
|
113138
|
+
const { agenticQueryComplete: agenticQueryComplete2 } = await Promise.resolve().then(() => (init_complete(), exports_complete));
|
|
113139
|
+
await agenticQueryComplete2(options.chatroomId, {
|
|
113140
|
+
queryId: options.queryId,
|
|
113141
|
+
result
|
|
113142
|
+
});
|
|
113143
|
+
});
|
|
112653
113144
|
var backlogCommand = program2.command("backlog").description("Manage task queue and backlog");
|
|
112654
113145
|
backlogCommand.command("list").description("List backlog items").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").option("--limit <n>", "Maximum number of items to show").option("--sort <sort>", "Sort order: date:desc (default) | priority:desc").option("--filter <filter>", "Filter: unscored (only items without priority score)").action(async (options) => {
|
|
112655
113146
|
await maybeRequireAuth();
|
|
@@ -112934,4 +113425,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
112934
113425
|
});
|
|
112935
113426
|
program2.parse();
|
|
112936
113427
|
|
|
112937
|
-
//# debugId=
|
|
113428
|
+
//# debugId=FD69F45D45D4302D64756E2164756E21
|