chatroom-cli 1.68.4 → 1.69.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 +1028 -490
- package/dist/index.js.map +30 -19
- 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---"
|
|
@@ -77106,6 +77109,40 @@ function getFileReferenceProofOfCompletionExample() {
|
|
|
77106
77109
|
- \`apps/webapp/src/path/to/file.ts\` — <what changed and why>`;
|
|
77107
77110
|
}
|
|
77108
77111
|
|
|
77112
|
+
// ../../services/backend/prompts/utils/handoff-quality-principles.ts
|
|
77113
|
+
function getHandoffQualityPrinciplesCommentBlock() {
|
|
77114
|
+
const bullets = HANDOFF_QUALITY_PRINCIPLES.map((p) => `- ${p.name}: ${p.description}`).join(`
|
|
77115
|
+
`);
|
|
77116
|
+
return `<!-- Demonstrate adherence to:
|
|
77117
|
+
${bullets}
|
|
77118
|
+
-->`;
|
|
77119
|
+
}
|
|
77120
|
+
var HANDOFF_QUALITY_PRINCIPLES, PROOF_OF_PRINCIPLES_HEADING_H2 = "## Proof of Principles", PROOF_OF_PRINCIPLES_HEADING_H3 = "### Proof of Principles";
|
|
77121
|
+
var init_handoff_quality_principles = __esm(() => {
|
|
77122
|
+
HANDOFF_QUALITY_PRINCIPLES = [
|
|
77123
|
+
{
|
|
77124
|
+
name: "Semantic Consistency",
|
|
77125
|
+
description: "the organization of the code, the code and the functionality of the code use a consistent and well maintained set of terms."
|
|
77126
|
+
},
|
|
77127
|
+
{
|
|
77128
|
+
name: "Organization & Maintainability",
|
|
77129
|
+
description: "a small change in requirements should result in a small change in code in a small number of files and folders."
|
|
77130
|
+
},
|
|
77131
|
+
{
|
|
77132
|
+
name: "Static Evaluability and Provability",
|
|
77133
|
+
description: "the system's behavior should be provably correct by looking at the source code, then automated tests, then manual tests, in this order."
|
|
77134
|
+
},
|
|
77135
|
+
{
|
|
77136
|
+
name: "No Revisit",
|
|
77137
|
+
description: "implemented in a way so the user does not have to revisit this implementation again."
|
|
77138
|
+
},
|
|
77139
|
+
{
|
|
77140
|
+
name: "Leave It Better",
|
|
77141
|
+
description: "leave the code in a slightly better state than before when touching files."
|
|
77142
|
+
}
|
|
77143
|
+
];
|
|
77144
|
+
});
|
|
77145
|
+
|
|
77109
77146
|
// ../../services/backend/prompts/cli/role-guidance/command.ts
|
|
77110
77147
|
function roleGuidanceCommand(params = {}) {
|
|
77111
77148
|
const prefix = params.cliEnvPrefix ?? "";
|
|
@@ -77140,13 +77177,8 @@ function getBuilderToPlannerHandoffTemplate(roleGuidanceContext) {
|
|
|
77140
77177
|
- [ ] I confirm that I have seen this template at the start of this task, before implementing or modifying any code
|
|
77141
77178
|
${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
|
|
77142
77179
|
|
|
77143
|
-
|
|
77144
|
-
|
|
77145
|
-
- Organization & Maintainability: a small change in requirements should result in a small change in code in a small number of files and folders.
|
|
77146
|
-
- Static Evaluability and Provability: the system's behavior should be provably correct by looking at the source code, then automated tests, then manual tests, in this order.
|
|
77147
|
-
- No Revisit: implemented in a way so the user does not have to revisit this implementation again.
|
|
77148
|
-
- Leave It Better: leave the code in a slightly better state than before when touching files.
|
|
77149
|
-
-->
|
|
77180
|
+
${PROOF_OF_PRINCIPLES_HEADING_H2}
|
|
77181
|
+
${getHandoffQualityPrinciplesCommentBlock()}
|
|
77150
77182
|
<how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
|
|
77151
77183
|
|
|
77152
77184
|
## Proof of Completion
|
|
@@ -77165,6 +77197,7 @@ ${CODE_CHANGE_VERIFICATION_CONFIRMATION}
|
|
|
77165
77197
|
\`\`\``;
|
|
77166
77198
|
}
|
|
77167
77199
|
var init_builder_to_planner = __esm(() => {
|
|
77200
|
+
init_handoff_quality_principles();
|
|
77168
77201
|
init_role_guidance_disclosure();
|
|
77169
77202
|
});
|
|
77170
77203
|
|
|
@@ -77303,13 +77336,8 @@ ${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
|
|
|
77303
77336
|
## What changed
|
|
77304
77337
|
<high-level view of what changed since the user's message before the detailed proofs below>
|
|
77305
77338
|
|
|
77306
|
-
|
|
77307
|
-
|
|
77308
|
-
- Organization & Maintainability: a small change in requirements should result in a small change in code in a small number of files and folders.
|
|
77309
|
-
- Static Evaluability and Provability: the system's behavior should be provably correct by looking at the source code, then automated tests, then manual tests, in this order.
|
|
77310
|
-
- No Revisit: implemented in a way so the user does not have to revisit this implementation again.
|
|
77311
|
-
- Leave It Better: leave the code in a slightly better state than before when touching files.
|
|
77312
|
-
-->
|
|
77339
|
+
${PROOF_OF_PRINCIPLES_HEADING_H3}
|
|
77340
|
+
${getHandoffQualityPrinciplesCommentBlock()}
|
|
77313
77341
|
<how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
|
|
77314
77342
|
|
|
77315
77343
|
### Proof of Completion
|
|
@@ -77354,6 +77382,7 @@ ${getUnresolvedDecisionsSectionBlock()}
|
|
|
77354
77382
|
}
|
|
77355
77383
|
var init_planner_to_user = __esm(() => {
|
|
77356
77384
|
init_context_disclosure();
|
|
77385
|
+
init_handoff_quality_principles();
|
|
77357
77386
|
init_role_guidance_disclosure();
|
|
77358
77387
|
});
|
|
77359
77388
|
|
|
@@ -77405,13 +77434,8 @@ ${getRoleGuidanceDisclosureBlock(roleGuidanceContext)}
|
|
|
77405
77434
|
## What changed
|
|
77406
77435
|
<high-level view of what changed since the user's message before the detailed proofs below>
|
|
77407
77436
|
|
|
77408
|
-
|
|
77409
|
-
|
|
77410
|
-
- Organization & Maintainability: a small change in requirements should result in a small change in code in a small number of files and folders.
|
|
77411
|
-
- Static Evaluability and Provability: the system's behavior should be provably correct by looking at the source code, then automated tests, then manual tests, in this order.
|
|
77412
|
-
- No Revisit: implemented in a way so the user does not have to revisit this implementation again.
|
|
77413
|
-
- Leave It Better: leave the code in a slightly better state than before when touching files.
|
|
77414
|
-
-->
|
|
77437
|
+
${PROOF_OF_PRINCIPLES_HEADING_H3}
|
|
77438
|
+
${getHandoffQualityPrinciplesCommentBlock()}
|
|
77415
77439
|
<how this work follows the principles above — localized changes, readable structure, correctness provable from source then tests>
|
|
77416
77440
|
|
|
77417
77441
|
### Proof of Completion
|
|
@@ -77456,6 +77480,7 @@ ${getUnresolvedDecisionsSectionBlock()}
|
|
|
77456
77480
|
}
|
|
77457
77481
|
var init_solo_to_user = __esm(() => {
|
|
77458
77482
|
init_context_disclosure();
|
|
77483
|
+
init_handoff_quality_principles();
|
|
77459
77484
|
init_role_guidance_disclosure();
|
|
77460
77485
|
});
|
|
77461
77486
|
|
|
@@ -78940,6 +78965,83 @@ var init_handoff = __esm(() => {
|
|
|
78940
78965
|
init_error_formatting();
|
|
78941
78966
|
});
|
|
78942
78967
|
|
|
78968
|
+
// src/commands/agentic-query/complete.ts
|
|
78969
|
+
var exports_complete = {};
|
|
78970
|
+
__export(exports_complete, {
|
|
78971
|
+
agenticQueryComplete: () => agenticQueryComplete
|
|
78972
|
+
});
|
|
78973
|
+
async function createDefaultDeps9() {
|
|
78974
|
+
const client4 = await getConvexClient();
|
|
78975
|
+
return {
|
|
78976
|
+
backend: {
|
|
78977
|
+
mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
|
|
78978
|
+
query: (endpoint, args2) => client4.query(endpoint, args2)
|
|
78979
|
+
},
|
|
78980
|
+
session: {
|
|
78981
|
+
getSessionId,
|
|
78982
|
+
getConvexUrl,
|
|
78983
|
+
getOtherSessionUrls
|
|
78984
|
+
}
|
|
78985
|
+
};
|
|
78986
|
+
}
|
|
78987
|
+
function handleCompleteError(err) {
|
|
78988
|
+
return exports_Effect.sync(() => {
|
|
78989
|
+
if (err._tag === "NotAuthenticated") {
|
|
78990
|
+
formatAuthError(err.convexUrl, err.otherUrls);
|
|
78991
|
+
process.exit(1);
|
|
78992
|
+
}
|
|
78993
|
+
if (err._tag === "InvalidChatroomId") {
|
|
78994
|
+
formatChatroomIdError(err.id);
|
|
78995
|
+
process.exit(1);
|
|
78996
|
+
}
|
|
78997
|
+
console.error(`
|
|
78998
|
+
❌ ERROR: Agentic query complete failed`);
|
|
78999
|
+
console.error(`
|
|
79000
|
+
${err.errorData?.message ?? err.cause.message}`);
|
|
79001
|
+
process.exit(1);
|
|
79002
|
+
});
|
|
79003
|
+
}
|
|
79004
|
+
async function agenticQueryComplete(chatroomId, options) {
|
|
79005
|
+
const deps = await createDefaultDeps9();
|
|
79006
|
+
await exports_Effect.runPromise(agenticQueryCompleteEffect(chatroomId, options).pipe(exports_Effect.provide(commandServicesLayerFromDeps(deps)), exports_Effect.catchAll(handleCompleteError)));
|
|
79007
|
+
}
|
|
79008
|
+
var agenticQueryCompleteEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
79009
|
+
const backend2 = yield* BackendService;
|
|
79010
|
+
const sessionId = yield* requireSessionIdEffect((a) => ({
|
|
79011
|
+
_tag: "NotAuthenticated",
|
|
79012
|
+
convexUrl: a.convexUrl,
|
|
79013
|
+
otherUrls: a.otherUrls
|
|
79014
|
+
}));
|
|
79015
|
+
yield* validateChatroomIdEffect(chatroomId, (id3) => ({
|
|
79016
|
+
_tag: "InvalidChatroomId",
|
|
79017
|
+
id: id3
|
|
79018
|
+
}));
|
|
79019
|
+
yield* backend2.mutation(api.web.agenticQuery.index.complete, {
|
|
79020
|
+
sessionId,
|
|
79021
|
+
chatroomId,
|
|
79022
|
+
queryId: options.queryId,
|
|
79023
|
+
result: options.result
|
|
79024
|
+
}).pipe(exports_Effect.mapError((cause3) => {
|
|
79025
|
+
let errorData;
|
|
79026
|
+
if (cause3 instanceof ConvexError) {
|
|
79027
|
+
errorData = cause3.data;
|
|
79028
|
+
}
|
|
79029
|
+
return { _tag: "CompleteFailed", cause: cause3, errorData };
|
|
79030
|
+
}));
|
|
79031
|
+
yield* exports_Effect.sync(() => {
|
|
79032
|
+
console.log(`✅ Agentic query ${options.queryId} completed`);
|
|
79033
|
+
});
|
|
79034
|
+
});
|
|
79035
|
+
var init_complete = __esm(() => {
|
|
79036
|
+
init_values();
|
|
79037
|
+
init_esm();
|
|
79038
|
+
init_api3();
|
|
79039
|
+
init_storage();
|
|
79040
|
+
init_client2();
|
|
79041
|
+
init_services();
|
|
79042
|
+
init_error_formatting();
|
|
79043
|
+
});
|
|
79044
|
+
|
|
78943
79045
|
// src/commands/backlog/backlog-fs-service.ts
|
|
78944
79046
|
import * as nodeFs from "node:fs/promises";
|
|
78945
79047
|
var BacklogFsService, BacklogFsServiceLive, BacklogFsServiceFrom = (ops) => exports_Layer.succeed(BacklogFsService, {
|
|
@@ -79046,7 +79148,7 @@ function buildBaseLayer(d) {
|
|
|
79046
79148
|
function buildFsLayer(fs11) {
|
|
79047
79149
|
return fs11 ? BacklogFsServiceFrom(fs11) : BacklogFsServiceLive;
|
|
79048
79150
|
}
|
|
79049
|
-
async function
|
|
79151
|
+
async function createDefaultDeps10() {
|
|
79050
79152
|
const client4 = await getConvexClient();
|
|
79051
79153
|
const fs11 = await import("node:fs/promises");
|
|
79052
79154
|
return {
|
|
@@ -79102,47 +79204,47 @@ function computeContentHash(content) {
|
|
|
79102
79204
|
return createHash("sha256").update(content).digest("hex");
|
|
79103
79205
|
}
|
|
79104
79206
|
async function listBacklog(chatroomId, options, deps) {
|
|
79105
|
-
const d = deps ?? await
|
|
79207
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79106
79208
|
await exports_Effect.runPromise(listBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79107
79209
|
}
|
|
79108
79210
|
async function addBacklog(chatroomId, options, deps) {
|
|
79109
|
-
const d = deps ?? await
|
|
79211
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79110
79212
|
await exports_Effect.runPromise(addBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79111
79213
|
}
|
|
79112
79214
|
async function completeBacklog(chatroomId, options, deps) {
|
|
79113
|
-
const d = deps ?? await
|
|
79215
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79114
79216
|
await exports_Effect.runPromise(completeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79115
79217
|
}
|
|
79116
79218
|
async function reopenBacklog(chatroomId, options, deps) {
|
|
79117
|
-
const d = deps ?? await
|
|
79219
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79118
79220
|
await exports_Effect.runPromise(reopenBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79119
79221
|
}
|
|
79120
79222
|
async function patchBacklog(chatroomId, options, deps) {
|
|
79121
|
-
const d = deps ?? await
|
|
79223
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79122
79224
|
await exports_Effect.runPromise(patchBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79123
79225
|
}
|
|
79124
79226
|
async function scoreBacklog(chatroomId, options, deps) {
|
|
79125
|
-
const d = deps ?? await
|
|
79227
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79126
79228
|
await exports_Effect.runPromise(scoreBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79127
79229
|
}
|
|
79128
79230
|
async function markForReviewBacklog(chatroomId, options, deps) {
|
|
79129
|
-
const d = deps ?? await
|
|
79231
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79130
79232
|
await exports_Effect.runPromise(markForReviewBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79131
79233
|
}
|
|
79132
79234
|
async function historyBacklog(chatroomId, options, deps) {
|
|
79133
|
-
const d = deps ?? await
|
|
79235
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79134
79236
|
await exports_Effect.runPromise(historyBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79135
79237
|
}
|
|
79136
79238
|
async function updateBacklog(chatroomId, options, deps) {
|
|
79137
|
-
const d = deps ?? await
|
|
79239
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79138
79240
|
await exports_Effect.runPromise(updateBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79139
79241
|
}
|
|
79140
79242
|
async function closeBacklog(chatroomId, options, deps) {
|
|
79141
|
-
const d = deps ?? await
|
|
79243
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79142
79244
|
await exports_Effect.runPromise(closeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
79143
79245
|
}
|
|
79144
79246
|
async function exportBacklog(chatroomId, options, deps) {
|
|
79145
|
-
const d = deps ?? await
|
|
79247
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79146
79248
|
if (!d.fs) {
|
|
79147
79249
|
console.error("❌ File system operations not available");
|
|
79148
79250
|
process.exit(1);
|
|
@@ -79151,7 +79253,7 @@ async function exportBacklog(chatroomId, options, deps) {
|
|
|
79151
79253
|
await exports_Effect.runPromise(exportBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(exports_Layer.merge(buildBaseLayer(d), buildFsLayer(d.fs)))));
|
|
79152
79254
|
}
|
|
79153
79255
|
async function importBacklog(chatroomId, options, deps) {
|
|
79154
|
-
const d = deps ?? await
|
|
79256
|
+
const d = deps ?? await createDefaultDeps10();
|
|
79155
79257
|
if (!d.fs) {
|
|
79156
79258
|
console.error("❌ File system operations not available");
|
|
79157
79259
|
process.exit(1);
|
|
@@ -79912,7 +80014,7 @@ __export(exports_read, {
|
|
|
79912
80014
|
taskReadEffect: () => taskReadEffect,
|
|
79913
80015
|
taskRead: () => taskRead
|
|
79914
80016
|
});
|
|
79915
|
-
async function
|
|
80017
|
+
async function createDefaultDeps11() {
|
|
79916
80018
|
const client4 = await getConvexClient();
|
|
79917
80019
|
return {
|
|
79918
80020
|
backend: {
|
|
@@ -79954,7 +80056,7 @@ function handleTaskReadError(err) {
|
|
|
79954
80056
|
});
|
|
79955
80057
|
}
|
|
79956
80058
|
async function taskRead(chatroomId, options, deps) {
|
|
79957
|
-
const d = deps ?? await
|
|
80059
|
+
const d = deps ?? await createDefaultDeps11();
|
|
79958
80060
|
const layer = commandServicesLayerFromDeps(d);
|
|
79959
80061
|
await exports_Effect.runPromise(taskReadEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleTaskReadError(err)), exports_Effect.provide(layer)));
|
|
79960
80062
|
}
|
|
@@ -80045,7 +80147,7 @@ __export(exports_skill, {
|
|
|
80045
80147
|
activateSkillEffect: () => activateSkillEffect,
|
|
80046
80148
|
activateSkill: () => activateSkill
|
|
80047
80149
|
});
|
|
80048
|
-
async function
|
|
80150
|
+
async function createDefaultDeps12() {
|
|
80049
80151
|
const client4 = await getConvexClient();
|
|
80050
80152
|
return {
|
|
80051
80153
|
backend: {
|
|
@@ -80114,12 +80216,12 @@ function handleActivateSkillError(err) {
|
|
|
80114
80216
|
});
|
|
80115
80217
|
}
|
|
80116
80218
|
async function listSkills(chatroomId, options, deps) {
|
|
80117
|
-
const d = deps ?? await
|
|
80219
|
+
const d = deps ?? await createDefaultDeps12();
|
|
80118
80220
|
const layer = commandServicesLayerFromDeps(d);
|
|
80119
80221
|
await exports_Effect.runPromise(listSkillsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleListSkillsError(err)), exports_Effect.provide(layer)));
|
|
80120
80222
|
}
|
|
80121
80223
|
async function activateSkill(chatroomId, skillId, options, deps) {
|
|
80122
|
-
const d = deps ?? await
|
|
80224
|
+
const d = deps ?? await createDefaultDeps12();
|
|
80123
80225
|
const layer = commandServicesLayerFromDeps(d);
|
|
80124
80226
|
await exports_Effect.runPromise(activateSkillEffect(chatroomId, skillId, options).pipe(exports_Effect.catchAll((err) => handleActivateSkillError(err)), exports_Effect.provide(layer)));
|
|
80125
80227
|
}
|
|
@@ -80197,7 +80299,7 @@ __export(exports_messages, {
|
|
|
80197
80299
|
listBySenderRoleEffect: () => listBySenderRoleEffect,
|
|
80198
80300
|
listBySenderRole: () => listBySenderRole
|
|
80199
80301
|
});
|
|
80200
|
-
async function
|
|
80302
|
+
async function createDefaultDeps13() {
|
|
80201
80303
|
const client4 = await getConvexClient();
|
|
80202
80304
|
return {
|
|
80203
80305
|
backend: {
|
|
@@ -80258,12 +80360,12 @@ function handleMessagesError(err) {
|
|
|
80258
80360
|
});
|
|
80259
80361
|
}
|
|
80260
80362
|
async function listBySenderRole(chatroomId, options, deps) {
|
|
80261
|
-
const d = deps ?? await
|
|
80363
|
+
const d = deps ?? await createDefaultDeps13();
|
|
80262
80364
|
const layer = commandServicesLayerFromDeps(d);
|
|
80263
80365
|
await exports_Effect.runPromise(listBySenderRoleEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
80264
80366
|
}
|
|
80265
80367
|
async function listSinceMessage(chatroomId, options, deps) {
|
|
80266
|
-
const d = deps ?? await
|
|
80368
|
+
const d = deps ?? await createDefaultDeps13();
|
|
80267
80369
|
const layer = commandServicesLayerFromDeps(d);
|
|
80268
80370
|
await exports_Effect.runPromise(listSinceMessageEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
80269
80371
|
}
|
|
@@ -80393,7 +80495,7 @@ __export(exports_context2, {
|
|
|
80393
80495
|
inspectContextEffect: () => inspectContextEffect,
|
|
80394
80496
|
inspectContext: () => inspectContext
|
|
80395
80497
|
});
|
|
80396
|
-
async function
|
|
80498
|
+
async function createDefaultDeps14() {
|
|
80397
80499
|
const client4 = await getConvexClient();
|
|
80398
80500
|
return {
|
|
80399
80501
|
backend: {
|
|
@@ -80434,17 +80536,17 @@ function handleContextError(err) {
|
|
|
80434
80536
|
});
|
|
80435
80537
|
}
|
|
80436
80538
|
async function readContext(chatroomId, options, deps) {
|
|
80437
|
-
const d = deps ?? await
|
|
80539
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80438
80540
|
const layer = commandServicesLayerFromDeps(d);
|
|
80439
80541
|
await exports_Effect.runPromise(readContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80440
80542
|
}
|
|
80441
80543
|
async function newContext(chatroomId, options, deps) {
|
|
80442
|
-
const d = deps ?? await
|
|
80544
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80443
80545
|
const layer = commandServicesLayerFromDeps(d);
|
|
80444
80546
|
await exports_Effect.runPromise(newContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80445
80547
|
}
|
|
80446
80548
|
async function listContexts(chatroomId, options, deps) {
|
|
80447
|
-
const d = deps ?? await
|
|
80549
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80448
80550
|
const layer = commandServicesLayerFromDeps(d);
|
|
80449
80551
|
await exports_Effect.runPromise(listContextsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80450
80552
|
}
|
|
@@ -80452,7 +80554,7 @@ function viewTemplate() {
|
|
|
80452
80554
|
return getContextViewTemplate();
|
|
80453
80555
|
}
|
|
80454
80556
|
async function inspectContext(chatroomId, options, deps) {
|
|
80455
|
-
const d = deps ?? await
|
|
80557
|
+
const d = deps ?? await createDefaultDeps14();
|
|
80456
80558
|
const layer = commandServicesLayerFromDeps(d);
|
|
80457
80559
|
await exports_Effect.runPromise(inspectContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
80458
80560
|
}
|
|
@@ -80693,7 +80795,7 @@ __export(exports_guidelines, {
|
|
|
80693
80795
|
listGuidelineTypesEffect: () => listGuidelineTypesEffect,
|
|
80694
80796
|
listGuidelineTypes: () => listGuidelineTypes
|
|
80695
80797
|
});
|
|
80696
|
-
async function
|
|
80798
|
+
async function createDefaultDeps15() {
|
|
80697
80799
|
const client4 = await getConvexClient();
|
|
80698
80800
|
return {
|
|
80699
80801
|
backend: {
|
|
@@ -80734,12 +80836,12 @@ function handleListGuidelineTypesError(err) {
|
|
|
80734
80836
|
});
|
|
80735
80837
|
}
|
|
80736
80838
|
async function viewGuidelines(options, deps) {
|
|
80737
|
-
const d = deps ?? await
|
|
80839
|
+
const d = deps ?? await createDefaultDeps15();
|
|
80738
80840
|
const layer = layerFromDeps7(d);
|
|
80739
80841
|
await exports_Effect.runPromise(viewGuidelinesEffect(options).pipe(exports_Effect.catchAll((err) => handleViewGuidelinesError(err)), exports_Effect.provide(layer)));
|
|
80740
80842
|
}
|
|
80741
80843
|
async function listGuidelineTypes(deps) {
|
|
80742
|
-
const d = deps ?? await
|
|
80844
|
+
const d = deps ?? await createDefaultDeps15();
|
|
80743
80845
|
const layer = layerFromDeps7(d);
|
|
80744
80846
|
await exports_Effect.runPromise(listGuidelineTypesEffect().pipe(exports_Effect.catchAll((err) => handleListGuidelineTypesError(err)), exports_Effect.provide(layer)));
|
|
80745
80847
|
}
|
|
@@ -80809,7 +80911,7 @@ __export(exports_artifact, {
|
|
|
80809
80911
|
createArtifactEffect: () => createArtifactEffect,
|
|
80810
80912
|
createArtifact: () => createArtifact
|
|
80811
80913
|
});
|
|
80812
|
-
async function
|
|
80914
|
+
async function createDefaultDeps16() {
|
|
80813
80915
|
const client4 = await getConvexClient();
|
|
80814
80916
|
return {
|
|
80815
80917
|
backend: {
|
|
@@ -80831,19 +80933,19 @@ function handleArtifactError(err) {
|
|
|
80831
80933
|
});
|
|
80832
80934
|
}
|
|
80833
80935
|
async function createArtifact(chatroomId, options, deps) {
|
|
80834
|
-
const d = deps ?? await
|
|
80936
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80835
80937
|
const layer = commandServicesLayerFromDeps(d);
|
|
80836
80938
|
return exports_Effect.runPromise(createArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err).pipe(exports_Effect.map(() => {
|
|
80837
80939
|
return;
|
|
80838
80940
|
}))), exports_Effect.provide(layer)));
|
|
80839
80941
|
}
|
|
80840
80942
|
async function viewArtifact(chatroomId, options, deps) {
|
|
80841
|
-
const d = deps ?? await
|
|
80943
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80842
80944
|
const layer = commandServicesLayerFromDeps(d);
|
|
80843
80945
|
await exports_Effect.runPromise(viewArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
80844
80946
|
}
|
|
80845
80947
|
async function viewManyArtifacts(chatroomId, options, deps) {
|
|
80846
|
-
const d = deps ?? await
|
|
80948
|
+
const d = deps ?? await createDefaultDeps16();
|
|
80847
80949
|
const layer = commandServicesLayerFromDeps(d);
|
|
80848
80950
|
await exports_Effect.runPromise(viewManyArtifactsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
80849
80951
|
}
|
|
@@ -81193,7 +81295,7 @@ __export(exports_telegram, {
|
|
|
81193
81295
|
sendMessageEffect: () => sendMessageEffect,
|
|
81194
81296
|
sendMessage: () => sendMessage
|
|
81195
81297
|
});
|
|
81196
|
-
async function
|
|
81298
|
+
async function createDefaultDeps17() {
|
|
81197
81299
|
const client4 = await getConvexClient();
|
|
81198
81300
|
return {
|
|
81199
81301
|
backend: {
|
|
@@ -81275,7 +81377,7 @@ ${err.cause.message}`);
|
|
|
81275
81377
|
});
|
|
81276
81378
|
}
|
|
81277
81379
|
async function sendMessage(options, deps) {
|
|
81278
|
-
const d = deps ?? await
|
|
81380
|
+
const d = deps ?? await createDefaultDeps17();
|
|
81279
81381
|
const layer = layerFromDeps8(d);
|
|
81280
81382
|
await exports_Effect.runPromise(sendMessageEffect(options).pipe(exports_Effect.catchAll((err) => handleSendMessageError(err)), exports_Effect.provide(layer)));
|
|
81281
81383
|
}
|
|
@@ -99194,7 +99296,7 @@ function harnessEventSessionId(event) {
|
|
|
99194
99296
|
|
|
99195
99297
|
class OpencodeSdkHarness {
|
|
99196
99298
|
type = "opencode-sdk";
|
|
99197
|
-
displayName = "
|
|
99299
|
+
displayName = "OpenCode (SDK)";
|
|
99198
99300
|
client;
|
|
99199
99301
|
childProcess;
|
|
99200
99302
|
cwd;
|
|
@@ -100277,6 +100379,24 @@ var init_opencode_session_events = __esm(() => {
|
|
|
100277
100379
|
];
|
|
100278
100380
|
});
|
|
100279
100381
|
|
|
100382
|
+
// src/commands/machine/daemon-start/shared-harness/bind-turn-message-on-event.ts
|
|
100383
|
+
function bindTurnMessageOnEvent(handle, sessionRepository, logPrefix) {
|
|
100384
|
+
let lastBoundKey = null;
|
|
100385
|
+
return () => {
|
|
100386
|
+
const turn = handle.currentTurn;
|
|
100387
|
+
if (!turn)
|
|
100388
|
+
return;
|
|
100389
|
+
const messageId = turn.messageId;
|
|
100390
|
+
if (messageId == null)
|
|
100391
|
+
return;
|
|
100392
|
+
const key = `${turn.turnId}:${messageId}`;
|
|
100393
|
+
if (key === lastBoundKey)
|
|
100394
|
+
return;
|
|
100395
|
+
lastBoundKey = key;
|
|
100396
|
+
sessionRepository.bindTurnMessageId(turn.turnId, messageId).catch((err) => console.warn(`[${logPrefix}] bindTurnMessageId error (resume):`, err));
|
|
100397
|
+
};
|
|
100398
|
+
}
|
|
100399
|
+
|
|
100280
100400
|
// src/commands/machine/daemon-start/direct-harness/prompt-subscriber.ts
|
|
100281
100401
|
function startMessageSubscriber(session2, wsClient2, deps) {
|
|
100282
100402
|
let processing = false;
|
|
@@ -100371,22 +100491,15 @@ function wireResumedSessionEvents(handle, deps, info) {
|
|
|
100371
100491
|
agent: info.lastUsedConfig.agent ?? "build",
|
|
100372
100492
|
model: info.lastUsedConfig.model
|
|
100373
100493
|
};
|
|
100374
|
-
|
|
100494
|
+
const bindTurnMessage = bindTurnMessageOnEvent(handle, deps.sessionRepository, "direct-harness");
|
|
100375
100495
|
handle.session.onEvent((event) => {
|
|
100376
|
-
|
|
100377
|
-
if (turn?.messageId !== null && turn?.messageId !== undefined) {
|
|
100378
|
-
const key = `${turn.turnId}:${turn.messageId}`;
|
|
100379
|
-
if (key !== lastBoundKey) {
|
|
100380
|
-
lastBoundKey = key;
|
|
100381
|
-
deps.sessionRepository.bindTurnMessageId(turn.turnId, turn.messageId).catch((err) => console.warn("[direct-harness] bindTurnMessageId error (resume):", err));
|
|
100382
|
-
}
|
|
100383
|
-
}
|
|
100496
|
+
bindTurnMessage();
|
|
100384
100497
|
if (event.type === OPENCODE_SESSION_EVENT_TYPES[0]) {
|
|
100385
100498
|
handleSessionIdle(handle, handle.journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[direct-harness] idle handler error (resume):", err));
|
|
100386
100499
|
}
|
|
100387
100500
|
});
|
|
100388
100501
|
}
|
|
100389
|
-
async function deliverPendingMessages(handle, deps, rowId, messages, info) {
|
|
100502
|
+
async function deliverPendingMessages(handle, deps, rowId, messages, info, _daemonSession) {
|
|
100390
100503
|
for (const msg of messages) {
|
|
100391
100504
|
const override = info?.lastUsedConfig ?? { agent: "build" };
|
|
100392
100505
|
try {
|
|
@@ -100427,7 +100540,7 @@ async function processSessionMessages(session2, deps, rowId, messages, info) {
|
|
|
100427
100540
|
await deps.sessionRepository.markActive(rowId).catch(() => {});
|
|
100428
100541
|
wireResumedSessionEvents(handle, deps, info);
|
|
100429
100542
|
}
|
|
100430
|
-
await deliverPendingMessages(handle, deps, rowId, messages, info);
|
|
100543
|
+
await deliverPendingMessages(handle, deps, rowId, messages, info, session2);
|
|
100431
100544
|
}
|
|
100432
100545
|
var init_prompt_subscriber = __esm(() => {
|
|
100433
100546
|
init_idle_handler();
|
|
@@ -100437,122 +100550,64 @@ var init_prompt_subscriber = __esm(() => {
|
|
|
100437
100550
|
init_opencode_session_events();
|
|
100438
100551
|
});
|
|
100439
100552
|
|
|
100440
|
-
// src/commands/machine/daemon-start/
|
|
100441
|
-
function
|
|
100442
|
-
const
|
|
100443
|
-
const
|
|
100444
|
-
|
|
100445
|
-
machineId: daemonSession.machineId
|
|
100446
|
-
}, (pendingSessions) => {
|
|
100447
|
-
if (!pendingSessions || pendingSessions.length === 0)
|
|
100448
|
-
return;
|
|
100449
|
-
for (const session2 of pendingSessions) {
|
|
100450
|
-
const rowId = session2._id;
|
|
100451
|
-
if (inFlight.has(rowId))
|
|
100452
|
-
continue;
|
|
100453
|
-
inFlight.add(rowId);
|
|
100454
|
-
processOne(daemonSession, deps, session2).finally(() => inFlight.delete(rowId));
|
|
100455
|
-
}
|
|
100456
|
-
}, (err) => {
|
|
100457
|
-
console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
100458
|
-
});
|
|
100459
|
-
return { stop: unsub };
|
|
100460
|
-
}
|
|
100461
|
-
async function getOrCreateHarness(daemonSession, deps, session2, workspace) {
|
|
100462
|
-
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
100463
|
-
const key = makeHarnessKey(session2.workspaceId, harnessName);
|
|
100464
|
-
let harness = deps.harnesses.get(key);
|
|
100553
|
+
// src/commands/machine/daemon-start/shared-harness/get-or-create-bound-harness.ts
|
|
100554
|
+
async function getOrCreateBoundHarness(params) {
|
|
100555
|
+
const { harnesses, workspaceId, harnessName, workingDir, convexUrl, logPrefix } = params;
|
|
100556
|
+
const key = makeHarnessKey(workspaceId, harnessName);
|
|
100557
|
+
let harness = harnesses.get(key);
|
|
100465
100558
|
if (harness && !harness.isAlive()) {
|
|
100466
|
-
console.warn(
|
|
100559
|
+
console.warn(`${logPrefix} Harness ${harnessName} for workspace ${workspaceId} is no longer alive — restarting`);
|
|
100467
100560
|
harness.close().catch(() => {});
|
|
100468
|
-
|
|
100561
|
+
harnesses.delete(key);
|
|
100469
100562
|
harness = undefined;
|
|
100470
100563
|
}
|
|
100471
100564
|
if (!harness) {
|
|
100472
100565
|
harness = await startBoundHarness({
|
|
100473
100566
|
harnessName,
|
|
100474
|
-
workingDir
|
|
100475
|
-
workspaceId
|
|
100476
|
-
resolvedConvexUrl:
|
|
100567
|
+
workingDir,
|
|
100568
|
+
workspaceId,
|
|
100569
|
+
resolvedConvexUrl: convexUrl
|
|
100477
100570
|
});
|
|
100478
|
-
|
|
100571
|
+
harnesses.set(key, harness);
|
|
100479
100572
|
}
|
|
100480
100573
|
return harness;
|
|
100481
100574
|
}
|
|
100482
|
-
|
|
100483
|
-
|
|
100484
|
-
|
|
100485
|
-
|
|
100486
|
-
|
|
100487
|
-
|
|
100488
|
-
|
|
100489
|
-
|
|
100490
|
-
messageId: chunk2.messageId,
|
|
100491
|
-
partType: chunk2.partType
|
|
100492
|
-
});
|
|
100493
|
-
if (handle.currentTurn && handle.currentTurn.messageId === null) {
|
|
100494
|
-
handle.currentTurn.messageId = chunk2.messageId;
|
|
100495
|
-
deps.sessionRepository.bindTurnMessageId(handle.currentTurn.turnId, chunk2.messageId).catch((err) => console.warn("[direct-harness] bindTurnMessageId error:", err));
|
|
100496
|
-
}
|
|
100497
|
-
}
|
|
100498
|
-
function handleLiveSessionProviderId(event, deps, rowId, handle, liveSession) {
|
|
100499
|
-
if (event.type !== "session.provider_id")
|
|
100500
|
-
return;
|
|
100501
|
-
const sessionId = event.payload.sessionId;
|
|
100502
|
-
if (!sessionId || sessionId === handle.opencodeSessionId)
|
|
100503
|
-
return;
|
|
100504
|
-
deps.sessionRepository.associateOpenCodeSessionId(rowId, sessionId, liveSession.sessionTitle ?? "").catch((err) => console.warn("[direct-harness] associateOpenCodeSessionId (provider id) error:", err));
|
|
100505
|
-
}
|
|
100506
|
-
function handleLiveSessionTitleUpdate(event, deps, rowId, liveSession) {
|
|
100507
|
-
if (!isOpenCodeSessionEventType(event.type))
|
|
100508
|
-
return;
|
|
100509
|
-
if (event.type !== "session.updated") {
|
|
100510
|
-
return;
|
|
100511
|
-
}
|
|
100512
|
-
const info = event.payload.info;
|
|
100513
|
-
const newTitle = info?.title;
|
|
100514
|
-
if (!newTitle || newTitle === liveSession.sessionTitle) {
|
|
100515
|
-
return;
|
|
100516
|
-
}
|
|
100517
|
-
liveSession.setTitle?.(newTitle);
|
|
100518
|
-
deps.sessionRepository.updateSessionTitle(rowId, newTitle).catch((err) => console.warn("[direct-harness] updateSessionTitle error:", err));
|
|
100519
|
-
}
|
|
100520
|
-
function handleLiveSessionEvent(event, ctx) {
|
|
100521
|
-
const { handle, journal, extractChunk, idleConfig, deps, rowId, liveSession } = ctx;
|
|
100522
|
-
recordLiveSessionChunk(event, handle, journal, extractChunk, deps);
|
|
100523
|
-
if (event.type === "session.idle") {
|
|
100524
|
-
handleSessionIdle(handle, journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[direct-harness] idle handler error:", err));
|
|
100525
|
-
}
|
|
100526
|
-
handleLiveSessionTitleUpdate(event, deps, rowId, liveSession);
|
|
100527
|
-
handleLiveSessionProviderId(event, deps, rowId, handle, liveSession);
|
|
100528
|
-
}
|
|
100529
|
-
async function processOne(daemonSession, deps, session2) {
|
|
100530
|
-
const rowId = session2._id;
|
|
100575
|
+
var init_get_or_create_bound_harness = __esm(() => {
|
|
100576
|
+
init_registry4();
|
|
100577
|
+
});
|
|
100578
|
+
|
|
100579
|
+
// src/commands/machine/daemon-start/shared-harness/open-pending-session.ts
|
|
100580
|
+
async function openPendingHarnessSession(daemonSession, deps, input, options) {
|
|
100581
|
+
const { rowId, workspaceId, harnessName, lastUsedConfig } = input;
|
|
100582
|
+
const { logPrefix, handleProviderIdEvents } = options;
|
|
100531
100583
|
try {
|
|
100532
100584
|
const workspace = await daemonSession.backend.query(api.workspaces.getWorkspaceById, {
|
|
100533
100585
|
sessionId: daemonSession.sessionId,
|
|
100534
|
-
workspaceId
|
|
100586
|
+
workspaceId
|
|
100535
100587
|
});
|
|
100536
100588
|
if (!workspace) {
|
|
100537
|
-
console.warn(
|
|
100589
|
+
console.warn(`${logPrefix} Workspace ${workspaceId} not found for session ${rowId}`);
|
|
100538
100590
|
await deps.sessionRepository.markFailed(rowId);
|
|
100539
100591
|
return;
|
|
100540
100592
|
}
|
|
100541
|
-
const
|
|
100542
|
-
|
|
100543
|
-
|
|
100593
|
+
const harness = await getOrCreateBoundHarness({
|
|
100594
|
+
harnesses: deps.harnesses,
|
|
100595
|
+
workspaceId,
|
|
100596
|
+
harnessName,
|
|
100597
|
+
workingDir: workspace.workingDir,
|
|
100598
|
+
convexUrl: daemonSession.convexUrl,
|
|
100599
|
+
logPrefix
|
|
100600
|
+
});
|
|
100601
|
+
const modelConfig = lastUsedConfig.model;
|
|
100544
100602
|
const model = modelConfig ? `${modelConfig.providerID}/${modelConfig.modelID}` : undefined;
|
|
100545
100603
|
const liveSession = await harness.newSession({
|
|
100546
|
-
agent:
|
|
100604
|
+
agent: lastUsedConfig.agent,
|
|
100547
100605
|
model,
|
|
100548
100606
|
harnessSessionId: rowId
|
|
100549
100607
|
});
|
|
100550
100608
|
const journal = deps.journalFactory.create(rowId);
|
|
100551
100609
|
const extractChunk = createChunkExtractor(harness.type);
|
|
100552
|
-
const idleConfig = {
|
|
100553
|
-
agent: session2.opencode?.lastUsedConfig.agent ?? "build",
|
|
100554
|
-
model: session2.opencode?.lastUsedConfig.model
|
|
100555
|
-
};
|
|
100610
|
+
const idleConfig = { agent: lastUsedConfig.agent, model: lastUsedConfig.model };
|
|
100556
100611
|
let unsubscribeEvents = () => {};
|
|
100557
100612
|
let closed = false;
|
|
100558
100613
|
const close2 = async () => {
|
|
@@ -100569,22 +100624,41 @@ async function processOne(daemonSession, deps, session2) {
|
|
|
100569
100624
|
harnessSessionId: rowId,
|
|
100570
100625
|
harnessName,
|
|
100571
100626
|
opencodeSessionId: liveSession.opencodeSessionId,
|
|
100572
|
-
workspaceId
|
|
100627
|
+
workspaceId,
|
|
100573
100628
|
session: liveSession,
|
|
100574
100629
|
journal,
|
|
100575
100630
|
currentTurn: null,
|
|
100576
100631
|
close: close2
|
|
100577
100632
|
};
|
|
100578
100633
|
unsubscribeEvents = liveSession.onEvent((event) => {
|
|
100579
|
-
|
|
100580
|
-
|
|
100581
|
-
journal
|
|
100582
|
-
|
|
100583
|
-
|
|
100584
|
-
|
|
100585
|
-
|
|
100586
|
-
|
|
100587
|
-
|
|
100634
|
+
const chunk2 = extractChunk(event);
|
|
100635
|
+
if (chunk2 !== null) {
|
|
100636
|
+
journal.record({
|
|
100637
|
+
content: chunk2.content,
|
|
100638
|
+
timestamp: Date.now(),
|
|
100639
|
+
messageId: chunk2.messageId,
|
|
100640
|
+
partType: chunk2.partType
|
|
100641
|
+
});
|
|
100642
|
+
if (handle.currentTurn && handle.currentTurn.messageId === null) {
|
|
100643
|
+
handle.currentTurn.messageId = chunk2.messageId;
|
|
100644
|
+
deps.sessionRepository.bindTurnMessageId(handle.currentTurn.turnId, chunk2.messageId).catch((err) => console.warn(`${logPrefix} bindTurnMessageId error:`, err));
|
|
100645
|
+
}
|
|
100646
|
+
}
|
|
100647
|
+
if (event.type === "session.idle") {
|
|
100648
|
+
handleSessionIdle(handle, journal, idleConfig, deps.sessionRepository).catch((err) => console.warn(`${logPrefix} idle handler error:`, err));
|
|
100649
|
+
}
|
|
100650
|
+
if (isOpenCodeSessionEventType(event.type) && event.type === "session.updated") {
|
|
100651
|
+
const info = event.payload.info;
|
|
100652
|
+
if (info?.title) {
|
|
100653
|
+
deps.sessionRepository.updateSessionTitle(rowId, info.title).catch((err) => console.warn(`${logPrefix} updateSessionTitle error:`, err));
|
|
100654
|
+
}
|
|
100655
|
+
}
|
|
100656
|
+
if (handleProviderIdEvents && event.type === "session.provider_id") {
|
|
100657
|
+
const sessionId = event.payload.sessionId;
|
|
100658
|
+
if (sessionId && sessionId !== handle.opencodeSessionId) {
|
|
100659
|
+
deps.sessionRepository.associateOpenCodeSessionId(rowId, sessionId, liveSession.sessionTitle ?? "").catch((err) => console.warn(`${logPrefix} associateOpenCodeSessionId (provider id) error:`, err));
|
|
100660
|
+
}
|
|
100661
|
+
}
|
|
100588
100662
|
});
|
|
100589
100663
|
deps.activeSessions.set(rowId, handle);
|
|
100590
100664
|
try {
|
|
@@ -100594,19 +100668,56 @@ async function processOne(daemonSession, deps, session2) {
|
|
|
100594
100668
|
await liveSession.close().catch(() => {});
|
|
100595
100669
|
throw err;
|
|
100596
100670
|
}
|
|
100597
|
-
console.log(
|
|
100671
|
+
console.log(`${logPrefix} Session opened: ${rowId} agent=${lastUsedConfig.agent} workspace=${workspaceId}`);
|
|
100598
100672
|
} catch (err) {
|
|
100599
|
-
console.warn(
|
|
100673
|
+
console.warn(`${logPrefix} Failed to open session ${rowId}:`, err instanceof Error ? err.message : String(err));
|
|
100600
100674
|
try {
|
|
100601
100675
|
await deps.sessionRepository.markFailed(rowId);
|
|
100602
100676
|
} catch {}
|
|
100603
100677
|
}
|
|
100604
100678
|
}
|
|
100605
|
-
var
|
|
100679
|
+
var init_open_pending_session = __esm(() => {
|
|
100606
100680
|
init_idle_handler();
|
|
100607
100681
|
init_api3();
|
|
100608
100682
|
init_registry4();
|
|
100609
100683
|
init_opencode_session_events();
|
|
100684
|
+
init_get_or_create_bound_harness();
|
|
100685
|
+
});
|
|
100686
|
+
|
|
100687
|
+
// src/commands/machine/daemon-start/direct-harness/session-subscriber.ts
|
|
100688
|
+
function startSessionSubscriber(daemonSession, wsClient2, deps) {
|
|
100689
|
+
const inFlight = new Set;
|
|
100690
|
+
const unsub = wsClient2.onUpdate(api.daemon.directHarness.sessions.listPendingSessionsForMachine, {
|
|
100691
|
+
sessionId: daemonSession.sessionId,
|
|
100692
|
+
machineId: daemonSession.machineId
|
|
100693
|
+
}, (pendingSessions) => {
|
|
100694
|
+
if (!pendingSessions || pendingSessions.length === 0)
|
|
100695
|
+
return;
|
|
100696
|
+
for (const session2 of pendingSessions) {
|
|
100697
|
+
const rowId = session2._id;
|
|
100698
|
+
if (inFlight.has(rowId))
|
|
100699
|
+
continue;
|
|
100700
|
+
inFlight.add(rowId);
|
|
100701
|
+
(async () => {
|
|
100702
|
+
const harnessName = session2.opencode?.harnessName ?? "opencode-sdk";
|
|
100703
|
+
const agent = session2.opencode?.lastUsedConfig?.agent ?? "build";
|
|
100704
|
+
const model = session2.opencode?.lastUsedConfig?.model;
|
|
100705
|
+
await openPendingHarnessSession(daemonSession, deps, {
|
|
100706
|
+
rowId: session2._id,
|
|
100707
|
+
workspaceId: session2.workspaceId,
|
|
100708
|
+
harnessName,
|
|
100709
|
+
lastUsedConfig: { agent, ...model ? { model } : {} }
|
|
100710
|
+
}, { logPrefix: "[direct-harness]", handleProviderIdEvents: true });
|
|
100711
|
+
})().finally(() => inFlight.delete(rowId));
|
|
100712
|
+
}
|
|
100713
|
+
}, (err) => {
|
|
100714
|
+
console.warn("[direct-harness] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
100715
|
+
});
|
|
100716
|
+
return { stop: unsub };
|
|
100717
|
+
}
|
|
100718
|
+
var init_session_subscriber = __esm(() => {
|
|
100719
|
+
init_api3();
|
|
100720
|
+
init_open_pending_session();
|
|
100610
100721
|
});
|
|
100611
100722
|
|
|
100612
100723
|
// src/commands/machine/daemon-start/direct-harness/shutdown-sessions.ts
|
|
@@ -100979,6 +101090,436 @@ var init_start_subscriptions = __esm(() => {
|
|
|
100979
101090
|
init_convex_session_repository();
|
|
100980
101091
|
});
|
|
100981
101092
|
|
|
101093
|
+
// ../../services/backend/prompts/agentic-query/system-prompt.ts
|
|
101094
|
+
function renderAgenticQuerySystemPrompt(params) {
|
|
101095
|
+
const completeCmd = `chatroom agentic-query complete --chatroom-id=${params.chatroomId} --query-id=${params.queryId} << 'CHATROOM_AGENTIC_QUERY_END'
|
|
101096
|
+
## Summary
|
|
101097
|
+
...
|
|
101098
|
+
|
|
101099
|
+
## Results
|
|
101100
|
+
...
|
|
101101
|
+
|
|
101102
|
+
## Grounding
|
|
101103
|
+
...
|
|
101104
|
+
|
|
101105
|
+
## Files
|
|
101106
|
+
...
|
|
101107
|
+
CHATROOM_AGENTIC_QUERY_END`;
|
|
101108
|
+
return [
|
|
101109
|
+
"You answer workspace-scoped search and ask queries by exploring the connected codebase.",
|
|
101110
|
+
"Use tools to read and search files. Prefer evidence over speculation.",
|
|
101111
|
+
"When done, submit results with the CLI heredoc below (markdown body only — no protocol markers like ---RESULT---).",
|
|
101112
|
+
"",
|
|
101113
|
+
"## Required markdown sections",
|
|
101114
|
+
"- ## Summary",
|
|
101115
|
+
"- ## Results",
|
|
101116
|
+
"- ## Grounding (required for ask mode; path:line evidence)",
|
|
101117
|
+
"- ## Files",
|
|
101118
|
+
"",
|
|
101119
|
+
"## Complete command",
|
|
101120
|
+
completeCmd,
|
|
101121
|
+
"",
|
|
101122
|
+
`Convex URL: ${params.convexUrl}`
|
|
101123
|
+
].join(`
|
|
101124
|
+
`);
|
|
101125
|
+
}
|
|
101126
|
+
|
|
101127
|
+
// src/commands/machine/daemon-start/agentic-query/prompt-subscriber.ts
|
|
101128
|
+
async function ensureHarnessAlive(daemonSession, deps, info) {
|
|
101129
|
+
const key = makeHarnessKey(info.workspaceId, info.harnessName);
|
|
101130
|
+
const existing = deps.harnesses.get(key);
|
|
101131
|
+
if (existing?.isAlive())
|
|
101132
|
+
return existing;
|
|
101133
|
+
if (existing) {
|
|
101134
|
+
existing.close().catch(() => {});
|
|
101135
|
+
deps.harnesses.delete(key);
|
|
101136
|
+
}
|
|
101137
|
+
const workspace = await daemonSession.backend.query(api.workspaces.getWorkspaceById, {
|
|
101138
|
+
sessionId: daemonSession.sessionId,
|
|
101139
|
+
workspaceId: info.workspaceId
|
|
101140
|
+
});
|
|
101141
|
+
if (!workspace) {
|
|
101142
|
+
console.warn(`[agentic-query] Cannot resume ${info.runId}: workspace not found`);
|
|
101143
|
+
return null;
|
|
101144
|
+
}
|
|
101145
|
+
const harness = await startBoundHarness({
|
|
101146
|
+
harnessName: info.harnessName,
|
|
101147
|
+
workingDir: workspace.workingDir,
|
|
101148
|
+
workspaceId: info.workspaceId,
|
|
101149
|
+
resolvedConvexUrl: daemonSession.convexUrl
|
|
101150
|
+
});
|
|
101151
|
+
deps.harnesses.set(key, harness);
|
|
101152
|
+
return harness;
|
|
101153
|
+
}
|
|
101154
|
+
function wireResumedIdle(handle, deps, info) {
|
|
101155
|
+
const idleConfig = {
|
|
101156
|
+
agent: info.lastUsedConfig.agent ?? "build",
|
|
101157
|
+
model: info.lastUsedConfig.model
|
|
101158
|
+
};
|
|
101159
|
+
const bindTurnMessage = bindTurnMessageOnEvent(handle, deps.sessionRepository, "agentic-query");
|
|
101160
|
+
handle.session.onEvent((event) => {
|
|
101161
|
+
bindTurnMessage();
|
|
101162
|
+
if (event.type === "session.idle") {
|
|
101163
|
+
handleSessionIdle(handle, handle.journal, idleConfig, deps.sessionRepository).catch((err) => console.warn("[agentic-query] idle handler error (resume):", err));
|
|
101164
|
+
}
|
|
101165
|
+
});
|
|
101166
|
+
}
|
|
101167
|
+
async function resolveSessionHandle(daemonSession, deps, info) {
|
|
101168
|
+
const rowId = info.runId;
|
|
101169
|
+
const cached5 = deps.activeSessions.get(rowId);
|
|
101170
|
+
if (cached5)
|
|
101171
|
+
return cached5;
|
|
101172
|
+
if (!info.opencodeSessionId || !info.harnessName) {
|
|
101173
|
+
console.log(`[agentic-query] Session ${rowId} not yet open — waiting for session-subscriber`);
|
|
101174
|
+
return null;
|
|
101175
|
+
}
|
|
101176
|
+
try {
|
|
101177
|
+
const harness = await ensureHarnessAlive(daemonSession, deps, info);
|
|
101178
|
+
if (!harness)
|
|
101179
|
+
return null;
|
|
101180
|
+
const resumed = await resumeSession({
|
|
101181
|
+
harness,
|
|
101182
|
+
journalFactory: deps.journalFactory,
|
|
101183
|
+
chunkExtractor: createChunkExtractor(harness.type)
|
|
101184
|
+
}, {
|
|
101185
|
+
harnessSessionId: rowId,
|
|
101186
|
+
opencodeSessionId: info.opencodeSessionId,
|
|
101187
|
+
workspaceId: info.workspaceId,
|
|
101188
|
+
harnessName: info.harnessName
|
|
101189
|
+
});
|
|
101190
|
+
deps.activeSessions.set(rowId, resumed);
|
|
101191
|
+
wireResumedIdle(resumed, deps, info);
|
|
101192
|
+
console.log(`[agentic-query] Resumed session ${rowId}`);
|
|
101193
|
+
return resumed;
|
|
101194
|
+
} catch (err) {
|
|
101195
|
+
console.warn(`[agentic-query] Resume failed for ${rowId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
101196
|
+
return null;
|
|
101197
|
+
}
|
|
101198
|
+
}
|
|
101199
|
+
async function deliverMessage(deps, daemonSession, existingSession, info, msg) {
|
|
101200
|
+
const rowId = info.runId;
|
|
101201
|
+
await deps.sessionRepository.setGenerating(rowId, true);
|
|
101202
|
+
const { turnId } = await deps.sessionRepository.beginAssistantTurn(rowId);
|
|
101203
|
+
existingSession.currentTurn = { turnId, messageId: null };
|
|
101204
|
+
await existingSession.session.prompt({
|
|
101205
|
+
parts: [{ type: "text", text: msg.content }],
|
|
101206
|
+
agent: info.lastUsedConfig.agent,
|
|
101207
|
+
...info.lastUsedConfig.model ? { model: info.lastUsedConfig.model } : {},
|
|
101208
|
+
system: renderAgenticQuerySystemPrompt({
|
|
101209
|
+
convexUrl: daemonSession.convexUrl,
|
|
101210
|
+
chatroomId: info.chatroomId,
|
|
101211
|
+
queryId: info.agenticQueryId
|
|
101212
|
+
})
|
|
101213
|
+
});
|
|
101214
|
+
try {
|
|
101215
|
+
await deps.sessionRepository.markTurnProcessed(rowId, msg.seq);
|
|
101216
|
+
} catch (err) {
|
|
101217
|
+
console.warn(`[agentic-query] markTurnProcessed failed for session ${rowId} seq=${msg.seq}: ${err}`);
|
|
101218
|
+
}
|
|
101219
|
+
}
|
|
101220
|
+
async function drainPendingBatch(daemonSession, deps, batch) {
|
|
101221
|
+
for (const info of batch.sessions) {
|
|
101222
|
+
const existingSession = await resolveSessionHandle(daemonSession, deps, info);
|
|
101223
|
+
if (!existingSession)
|
|
101224
|
+
continue;
|
|
101225
|
+
const pendingMsgs = batch.messages.filter((m) => m.runId === info.runId).sort((a, b) => a.seq - b.seq);
|
|
101226
|
+
for (const msg of pendingMsgs) {
|
|
101227
|
+
await deliverMessage(deps, daemonSession, existingSession, info, msg);
|
|
101228
|
+
}
|
|
101229
|
+
}
|
|
101230
|
+
}
|
|
101231
|
+
function startPromptSubscriber(daemonSession, wsClient2, deps) {
|
|
101232
|
+
const handle = wsClient2.onUpdate(api.daemon.agenticQuery.messages.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, async (batch) => {
|
|
101233
|
+
if (!batch)
|
|
101234
|
+
return;
|
|
101235
|
+
await drainPendingBatch(daemonSession, deps, batch);
|
|
101236
|
+
});
|
|
101237
|
+
return { stop: handle };
|
|
101238
|
+
}
|
|
101239
|
+
var init_prompt_subscriber2 = __esm(() => {
|
|
101240
|
+
init_api3();
|
|
101241
|
+
init_resume_session();
|
|
101242
|
+
init_registry4();
|
|
101243
|
+
init_idle_handler();
|
|
101244
|
+
});
|
|
101245
|
+
|
|
101246
|
+
// src/commands/machine/daemon-start/agentic-query/session-subscriber.ts
|
|
101247
|
+
function startSessionSubscriber2(daemonSession, wsClient2, deps) {
|
|
101248
|
+
const inFlight = new Set;
|
|
101249
|
+
const unsub = wsClient2.onUpdate(api.daemon.agenticQuery.runs.pendingForMachine, { sessionId: daemonSession.sessionId, machineId: daemonSession.machineId }, (pendingSessions) => {
|
|
101250
|
+
if (!pendingSessions || pendingSessions.length === 0)
|
|
101251
|
+
return;
|
|
101252
|
+
for (const session2 of pendingSessions) {
|
|
101253
|
+
const rowId = session2.runId;
|
|
101254
|
+
if (inFlight.has(rowId))
|
|
101255
|
+
continue;
|
|
101256
|
+
inFlight.add(rowId);
|
|
101257
|
+
openPendingHarnessSession(daemonSession, deps, {
|
|
101258
|
+
rowId: session2.runId,
|
|
101259
|
+
workspaceId: session2.workspaceId,
|
|
101260
|
+
harnessName: session2.harnessName,
|
|
101261
|
+
lastUsedConfig: session2.lastUsedConfig
|
|
101262
|
+
}, { logPrefix: "[agentic-query]", handleProviderIdEvents: false }).finally(() => inFlight.delete(rowId));
|
|
101263
|
+
}
|
|
101264
|
+
}, (err) => {
|
|
101265
|
+
console.warn("[agentic-query] Session subscription error:", err instanceof Error ? err.message : String(err));
|
|
101266
|
+
});
|
|
101267
|
+
return { stop: unsub };
|
|
101268
|
+
}
|
|
101269
|
+
var init_session_subscriber2 = __esm(() => {
|
|
101270
|
+
init_api3();
|
|
101271
|
+
init_open_pending_session();
|
|
101272
|
+
});
|
|
101273
|
+
|
|
101274
|
+
// src/infrastructure/repos/convex-agentic-query-output-repository.ts
|
|
101275
|
+
class ConvexAgenticQueryOutputRepository {
|
|
101276
|
+
options;
|
|
101277
|
+
constructor(options) {
|
|
101278
|
+
this.options = options;
|
|
101279
|
+
}
|
|
101280
|
+
async appendChunks(runId, chunks) {
|
|
101281
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101282
|
+
if (chunks.length === 0)
|
|
101283
|
+
return;
|
|
101284
|
+
await backend2.mutation(api.daemon.agenticQuery.messages.appendMessages, {
|
|
101285
|
+
sessionId,
|
|
101286
|
+
runId,
|
|
101287
|
+
chunks: chunks.map((c) => ({
|
|
101288
|
+
content: c.content,
|
|
101289
|
+
timestamp: c.timestamp,
|
|
101290
|
+
messageId: c.messageId,
|
|
101291
|
+
partType: c.partType
|
|
101292
|
+
}))
|
|
101293
|
+
});
|
|
101294
|
+
}
|
|
101295
|
+
}
|
|
101296
|
+
var init_convex_agentic_query_output_repository = __esm(() => {
|
|
101297
|
+
init_api3();
|
|
101298
|
+
});
|
|
101299
|
+
|
|
101300
|
+
// src/infrastructure/repos/convex-agentic-query-run-repository.ts
|
|
101301
|
+
class ConvexAgenticQueryRunRepository {
|
|
101302
|
+
options;
|
|
101303
|
+
constructor(options) {
|
|
101304
|
+
this.options = options;
|
|
101305
|
+
}
|
|
101306
|
+
async associateOpenCodeSessionId(harnessSessionId, opencodeSessionId, sessionTitle) {
|
|
101307
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101308
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.associateOpenCodeSessionId, {
|
|
101309
|
+
sessionId,
|
|
101310
|
+
runId: harnessSessionId,
|
|
101311
|
+
opencodeSessionId,
|
|
101312
|
+
sessionTitle
|
|
101313
|
+
});
|
|
101314
|
+
}
|
|
101315
|
+
async getOpenCodeSessionId(harnessSessionId) {
|
|
101316
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101317
|
+
const result = await backend2.query(api.daemon.agenticQuery.runs.getRun, {
|
|
101318
|
+
sessionId,
|
|
101319
|
+
runId: harnessSessionId
|
|
101320
|
+
});
|
|
101321
|
+
return result?.opencode?.opencodeSessionId;
|
|
101322
|
+
}
|
|
101323
|
+
async markClosed(harnessSessionId) {
|
|
101324
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101325
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.closeRun, {
|
|
101326
|
+
sessionId,
|
|
101327
|
+
runId: harnessSessionId
|
|
101328
|
+
});
|
|
101329
|
+
}
|
|
101330
|
+
async markIdle(harnessSessionId) {
|
|
101331
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101332
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markIdle, {
|
|
101333
|
+
sessionId,
|
|
101334
|
+
runId: harnessSessionId
|
|
101335
|
+
});
|
|
101336
|
+
}
|
|
101337
|
+
async markFailed(harnessSessionId) {
|
|
101338
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101339
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markFailed, {
|
|
101340
|
+
sessionId,
|
|
101341
|
+
runId: harnessSessionId
|
|
101342
|
+
});
|
|
101343
|
+
}
|
|
101344
|
+
async markActive(harnessSessionId) {
|
|
101345
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101346
|
+
await backend2.mutation(api.daemon.agenticQuery.runs.markActive, {
|
|
101347
|
+
sessionId,
|
|
101348
|
+
runId: harnessSessionId
|
|
101349
|
+
});
|
|
101350
|
+
}
|
|
101351
|
+
async markTurnProcessed(harnessSessionId, turnSeq) {
|
|
101352
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101353
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.markTurnProcessed, {
|
|
101354
|
+
sessionId,
|
|
101355
|
+
runId: harnessSessionId,
|
|
101356
|
+
turnSeq
|
|
101357
|
+
});
|
|
101358
|
+
}
|
|
101359
|
+
async setGenerating(harnessSessionId, isGenerating) {
|
|
101360
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101361
|
+
await backend2.mutation(api.daemon.agenticQuery.queue.setGenerating, {
|
|
101362
|
+
sessionId,
|
|
101363
|
+
runId: harnessSessionId,
|
|
101364
|
+
isGenerating
|
|
101365
|
+
});
|
|
101366
|
+
}
|
|
101367
|
+
async dequeueNext(harnessSessionId) {
|
|
101368
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101369
|
+
await backend2.mutation(api.daemon.agenticQuery.queue.dequeueNext, {
|
|
101370
|
+
sessionId,
|
|
101371
|
+
runId: harnessSessionId
|
|
101372
|
+
});
|
|
101373
|
+
return null;
|
|
101374
|
+
}
|
|
101375
|
+
async beginAssistantTurn(harnessSessionId) {
|
|
101376
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101377
|
+
return backend2.mutation(api.daemon.agenticQuery.turns.beginAssistantTurn, {
|
|
101378
|
+
sessionId,
|
|
101379
|
+
runId: harnessSessionId
|
|
101380
|
+
});
|
|
101381
|
+
}
|
|
101382
|
+
async bindTurnMessageId(turnId, messageId) {
|
|
101383
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101384
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.bindTurnMessageId, {
|
|
101385
|
+
sessionId,
|
|
101386
|
+
turnId,
|
|
101387
|
+
messageId
|
|
101388
|
+
});
|
|
101389
|
+
}
|
|
101390
|
+
async finalizeAssistantTurn(turnId) {
|
|
101391
|
+
const { backend: backend2, sessionId } = this.options;
|
|
101392
|
+
await backend2.mutation(api.daemon.agenticQuery.turns.finalizeAssistantTurn, {
|
|
101393
|
+
sessionId,
|
|
101394
|
+
turnId
|
|
101395
|
+
});
|
|
101396
|
+
}
|
|
101397
|
+
async updateSessionTitle(harnessSessionId, title) {}
|
|
101398
|
+
}
|
|
101399
|
+
var init_convex_agentic_query_run_repository = __esm(() => {
|
|
101400
|
+
init_api3();
|
|
101401
|
+
});
|
|
101402
|
+
|
|
101403
|
+
// src/commands/machine/daemon-start/agentic-query/start-subscriptions.ts
|
|
101404
|
+
function startAgenticQuerySubscriptions(session2, wsClient2, activeSessions, harnesses) {
|
|
101405
|
+
const sessionRepository = new ConvexAgenticQueryRunRepository({
|
|
101406
|
+
backend: session2.backend,
|
|
101407
|
+
sessionId: session2.sessionId
|
|
101408
|
+
});
|
|
101409
|
+
const outputRepository = new ConvexAgenticQueryOutputRepository({
|
|
101410
|
+
backend: session2.backend,
|
|
101411
|
+
sessionId: session2.sessionId
|
|
101412
|
+
});
|
|
101413
|
+
const journalFactory = new BufferedJournalFactory({ outputRepository });
|
|
101414
|
+
const deps = { activeSessions, harnesses, sessionRepository, journalFactory };
|
|
101415
|
+
const pendingPromptSubscriptionHandle = startPromptSubscriber(session2, wsClient2, deps);
|
|
101416
|
+
const pendingHarnessSessionSubscriptionHandle = startSessionSubscriber2(session2, wsClient2, deps);
|
|
101417
|
+
return {
|
|
101418
|
+
pendingPromptSubscriptionHandle,
|
|
101419
|
+
pendingHarnessSessionSubscriptionHandle
|
|
101420
|
+
};
|
|
101421
|
+
}
|
|
101422
|
+
var init_start_subscriptions2 = __esm(() => {
|
|
101423
|
+
init_prompt_subscriber2();
|
|
101424
|
+
init_session_subscriber2();
|
|
101425
|
+
init_convex_agentic_query_output_repository();
|
|
101426
|
+
init_convex_agentic_query_run_repository();
|
|
101427
|
+
});
|
|
101428
|
+
|
|
101429
|
+
// src/commands/machine/daemon-start/file-content-classifier.ts
|
|
101430
|
+
function extensionOf(path3) {
|
|
101431
|
+
const lastDot = path3.lastIndexOf(".");
|
|
101432
|
+
if (lastDot === -1)
|
|
101433
|
+
return null;
|
|
101434
|
+
return path3.slice(lastDot).toLowerCase();
|
|
101435
|
+
}
|
|
101436
|
+
function hasKnownBinaryExtension(path3) {
|
|
101437
|
+
const ext = extensionOf(path3);
|
|
101438
|
+
return ext !== null && BINARY_EXTENSIONS.has(ext);
|
|
101439
|
+
}
|
|
101440
|
+
function hasNulByte(buffer) {
|
|
101441
|
+
return buffer.includes(0);
|
|
101442
|
+
}
|
|
101443
|
+
function hasTooManyControlChars(buffer) {
|
|
101444
|
+
let count3 = 0;
|
|
101445
|
+
const threshold = Math.max(1, Math.floor(buffer.length * 0.01));
|
|
101446
|
+
for (const byte of buffer) {
|
|
101447
|
+
if (byte === 0)
|
|
101448
|
+
return true;
|
|
101449
|
+
if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
|
|
101450
|
+
count3++;
|
|
101451
|
+
if (count3 > threshold)
|
|
101452
|
+
return true;
|
|
101453
|
+
}
|
|
101454
|
+
}
|
|
101455
|
+
return false;
|
|
101456
|
+
}
|
|
101457
|
+
function classifyFileContent(path3, buffer) {
|
|
101458
|
+
if (hasKnownBinaryExtension(path3)) {
|
|
101459
|
+
return { kind: "binary", encoding: "binary" };
|
|
101460
|
+
}
|
|
101461
|
+
if (buffer.length === 0) {
|
|
101462
|
+
return { kind: "text", encoding: "utf8" };
|
|
101463
|
+
}
|
|
101464
|
+
if (hasNulByte(buffer)) {
|
|
101465
|
+
return { kind: "binary", encoding: "binary" };
|
|
101466
|
+
}
|
|
101467
|
+
try {
|
|
101468
|
+
const decoded = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
|
101469
|
+
if (decoded.length === 0) {
|
|
101470
|
+
return { kind: "text", encoding: "utf8" };
|
|
101471
|
+
}
|
|
101472
|
+
if (hasTooManyControlChars(buffer)) {
|
|
101473
|
+
return { kind: "binary", encoding: "binary" };
|
|
101474
|
+
}
|
|
101475
|
+
return { kind: "text", encoding: "utf8" };
|
|
101476
|
+
} catch {
|
|
101477
|
+
return { kind: "binary", encoding: "binary" };
|
|
101478
|
+
}
|
|
101479
|
+
}
|
|
101480
|
+
var BINARY_EXTENSIONS;
|
|
101481
|
+
var init_file_content_classifier = __esm(() => {
|
|
101482
|
+
BINARY_EXTENSIONS = new Set([
|
|
101483
|
+
".png",
|
|
101484
|
+
".jpg",
|
|
101485
|
+
".jpeg",
|
|
101486
|
+
".gif",
|
|
101487
|
+
".webp",
|
|
101488
|
+
".ico",
|
|
101489
|
+
".mp3",
|
|
101490
|
+
".mp4",
|
|
101491
|
+
".wav",
|
|
101492
|
+
".ogg",
|
|
101493
|
+
".webm",
|
|
101494
|
+
".zip",
|
|
101495
|
+
".tar",
|
|
101496
|
+
".gz",
|
|
101497
|
+
".bz2",
|
|
101498
|
+
".7z",
|
|
101499
|
+
".rar",
|
|
101500
|
+
".pdf",
|
|
101501
|
+
".doc",
|
|
101502
|
+
".docx",
|
|
101503
|
+
".xls",
|
|
101504
|
+
".xlsx",
|
|
101505
|
+
".ppt",
|
|
101506
|
+
".pptx",
|
|
101507
|
+
".woff",
|
|
101508
|
+
".woff2",
|
|
101509
|
+
".ttf",
|
|
101510
|
+
".otf",
|
|
101511
|
+
".eot",
|
|
101512
|
+
".exe",
|
|
101513
|
+
".dll",
|
|
101514
|
+
".so",
|
|
101515
|
+
".dylib",
|
|
101516
|
+
".bin",
|
|
101517
|
+
".dat",
|
|
101518
|
+
".db",
|
|
101519
|
+
".sqlite"
|
|
101520
|
+
]);
|
|
101521
|
+
});
|
|
101522
|
+
|
|
100982
101523
|
// src/infrastructure/services/workspace/normalize-working-dir.ts
|
|
100983
101524
|
function normalizeWorkingDirForLookup(workingDir) {
|
|
100984
101525
|
return workingDir.trim().replace(/[/\\]+$/, "");
|
|
@@ -101119,8 +101660,31 @@ function gunzipBase64Payload(base643, maxBytes) {
|
|
|
101119
101660
|
var init_workspace_path_security = () => {};
|
|
101120
101661
|
|
|
101121
101662
|
// src/infrastructure/services/workspace/workspace-visibility-policy.ts
|
|
101663
|
+
function isHiddenDirName(name) {
|
|
101664
|
+
return HIDDEN_DIR_NAMES.has(name);
|
|
101665
|
+
}
|
|
101666
|
+
function isShallowSyncDirName(name) {
|
|
101667
|
+
return SHALLOW_SYNC_DIR_NAMES.has(name);
|
|
101668
|
+
}
|
|
101122
101669
|
function isAlwaysExcludedDirName(name) {
|
|
101123
|
-
return
|
|
101670
|
+
return isHiddenDirName(name) || isShallowSyncDirName(name);
|
|
101671
|
+
}
|
|
101672
|
+
function shouldShallowSyncByHeuristics(context5) {
|
|
101673
|
+
if (context5.immediateChildCount >= SHALLOW_HEURISTIC_MIN_CHILD_COUNT)
|
|
101674
|
+
return true;
|
|
101675
|
+
if (!context5.relativePath.includes("/") && context5.immediateSiblingCount >= 300) {
|
|
101676
|
+
return context5.immediateChildCount >= 100;
|
|
101677
|
+
}
|
|
101678
|
+
return false;
|
|
101679
|
+
}
|
|
101680
|
+
function classifyDirectorySyncMode(dirName, context5) {
|
|
101681
|
+
if (isHiddenDirName(dirName))
|
|
101682
|
+
return "hidden";
|
|
101683
|
+
if (isShallowSyncDirName(dirName))
|
|
101684
|
+
return "shallow";
|
|
101685
|
+
if (shouldShallowSyncByHeuristics(context5))
|
|
101686
|
+
return "shallow";
|
|
101687
|
+
return "full";
|
|
101124
101688
|
}
|
|
101125
101689
|
function isSecretPath(relativePath) {
|
|
101126
101690
|
const normalized = relativePath.replace(/\\/g, "/");
|
|
@@ -101128,7 +101692,15 @@ function isSecretPath(relativePath) {
|
|
|
101128
101692
|
}
|
|
101129
101693
|
function hasExcludedDirSegment(relativePath) {
|
|
101130
101694
|
const segments = relativePath.split("/");
|
|
101131
|
-
|
|
101695
|
+
const lastIndex = segments.length - 1;
|
|
101696
|
+
for (let index = 0;index < segments.length; index++) {
|
|
101697
|
+
const name = segments[index];
|
|
101698
|
+
if (isHiddenDirName(name))
|
|
101699
|
+
return true;
|
|
101700
|
+
if (isShallowSyncDirName(name) && index < lastIndex)
|
|
101701
|
+
return true;
|
|
101702
|
+
}
|
|
101703
|
+
return false;
|
|
101132
101704
|
}
|
|
101133
101705
|
function isPathVisible(relativePath) {
|
|
101134
101706
|
if (!relativePath)
|
|
@@ -101138,11 +101710,11 @@ function isPathVisible(relativePath) {
|
|
|
101138
101710
|
function isPathContentReadable(relativePath) {
|
|
101139
101711
|
return isPathVisible(relativePath);
|
|
101140
101712
|
}
|
|
101141
|
-
var ALWAYS_EXCLUDE_DIR_NAMES, SECRET_PATH_PATTERNS;
|
|
101713
|
+
var HIDDEN_DIR_NAMES, SHALLOW_SYNC_DIR_NAMES, ALWAYS_EXCLUDE_DIR_NAMES, SECRET_PATH_PATTERNS, SHALLOW_HEURISTIC_MIN_CHILD_COUNT = 500;
|
|
101142
101714
|
var init_workspace_visibility_policy = __esm(() => {
|
|
101143
|
-
|
|
101715
|
+
HIDDEN_DIR_NAMES = new Set([".git"]);
|
|
101716
|
+
SHALLOW_SYNC_DIR_NAMES = new Set([
|
|
101144
101717
|
"node_modules",
|
|
101145
|
-
".git",
|
|
101146
101718
|
"dist",
|
|
101147
101719
|
"build",
|
|
101148
101720
|
".next",
|
|
@@ -101155,6 +101727,7 @@ var init_workspace_visibility_policy = __esm(() => {
|
|
|
101155
101727
|
"_generated",
|
|
101156
101728
|
".vercel"
|
|
101157
101729
|
]);
|
|
101730
|
+
ALWAYS_EXCLUDE_DIR_NAMES = new Set([...HIDDEN_DIR_NAMES, ...SHALLOW_SYNC_DIR_NAMES]);
|
|
101158
101731
|
SECRET_PATH_PATTERNS = [
|
|
101159
101732
|
/^\.env$/,
|
|
101160
101733
|
/^\.env\./,
|
|
@@ -101167,100 +101740,6 @@ var init_workspace_visibility_policy = __esm(() => {
|
|
|
101167
101740
|
];
|
|
101168
101741
|
});
|
|
101169
101742
|
|
|
101170
|
-
// src/commands/machine/daemon-start/file-content-classifier.ts
|
|
101171
|
-
function extensionOf(path3) {
|
|
101172
|
-
const lastDot = path3.lastIndexOf(".");
|
|
101173
|
-
if (lastDot === -1)
|
|
101174
|
-
return null;
|
|
101175
|
-
return path3.slice(lastDot).toLowerCase();
|
|
101176
|
-
}
|
|
101177
|
-
function hasKnownBinaryExtension(path3) {
|
|
101178
|
-
const ext = extensionOf(path3);
|
|
101179
|
-
return ext !== null && BINARY_EXTENSIONS.has(ext);
|
|
101180
|
-
}
|
|
101181
|
-
function hasNulByte(buffer) {
|
|
101182
|
-
return buffer.includes(0);
|
|
101183
|
-
}
|
|
101184
|
-
function hasTooManyControlChars(buffer) {
|
|
101185
|
-
let count3 = 0;
|
|
101186
|
-
const threshold = Math.max(1, Math.floor(buffer.length * 0.01));
|
|
101187
|
-
for (const byte of buffer) {
|
|
101188
|
-
if (byte === 0)
|
|
101189
|
-
return true;
|
|
101190
|
-
if (byte < 32 && byte !== 9 && byte !== 10 && byte !== 13) {
|
|
101191
|
-
count3++;
|
|
101192
|
-
if (count3 > threshold)
|
|
101193
|
-
return true;
|
|
101194
|
-
}
|
|
101195
|
-
}
|
|
101196
|
-
return false;
|
|
101197
|
-
}
|
|
101198
|
-
function classifyFileContent(path3, buffer) {
|
|
101199
|
-
if (hasKnownBinaryExtension(path3)) {
|
|
101200
|
-
return { kind: "binary", encoding: "binary" };
|
|
101201
|
-
}
|
|
101202
|
-
if (buffer.length === 0) {
|
|
101203
|
-
return { kind: "text", encoding: "utf8" };
|
|
101204
|
-
}
|
|
101205
|
-
if (hasNulByte(buffer)) {
|
|
101206
|
-
return { kind: "binary", encoding: "binary" };
|
|
101207
|
-
}
|
|
101208
|
-
try {
|
|
101209
|
-
const decoded = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
|
101210
|
-
if (decoded.length === 0) {
|
|
101211
|
-
return { kind: "text", encoding: "utf8" };
|
|
101212
|
-
}
|
|
101213
|
-
if (hasTooManyControlChars(buffer)) {
|
|
101214
|
-
return { kind: "binary", encoding: "binary" };
|
|
101215
|
-
}
|
|
101216
|
-
return { kind: "text", encoding: "utf8" };
|
|
101217
|
-
} catch {
|
|
101218
|
-
return { kind: "binary", encoding: "binary" };
|
|
101219
|
-
}
|
|
101220
|
-
}
|
|
101221
|
-
var BINARY_EXTENSIONS;
|
|
101222
|
-
var init_file_content_classifier = __esm(() => {
|
|
101223
|
-
BINARY_EXTENSIONS = new Set([
|
|
101224
|
-
".png",
|
|
101225
|
-
".jpg",
|
|
101226
|
-
".jpeg",
|
|
101227
|
-
".gif",
|
|
101228
|
-
".webp",
|
|
101229
|
-
".ico",
|
|
101230
|
-
".mp3",
|
|
101231
|
-
".mp4",
|
|
101232
|
-
".wav",
|
|
101233
|
-
".ogg",
|
|
101234
|
-
".webm",
|
|
101235
|
-
".zip",
|
|
101236
|
-
".tar",
|
|
101237
|
-
".gz",
|
|
101238
|
-
".bz2",
|
|
101239
|
-
".7z",
|
|
101240
|
-
".rar",
|
|
101241
|
-
".pdf",
|
|
101242
|
-
".doc",
|
|
101243
|
-
".docx",
|
|
101244
|
-
".xls",
|
|
101245
|
-
".xlsx",
|
|
101246
|
-
".ppt",
|
|
101247
|
-
".pptx",
|
|
101248
|
-
".woff",
|
|
101249
|
-
".woff2",
|
|
101250
|
-
".ttf",
|
|
101251
|
-
".otf",
|
|
101252
|
-
".eot",
|
|
101253
|
-
".exe",
|
|
101254
|
-
".dll",
|
|
101255
|
-
".so",
|
|
101256
|
-
".dylib",
|
|
101257
|
-
".bin",
|
|
101258
|
-
".dat",
|
|
101259
|
-
".db",
|
|
101260
|
-
".sqlite"
|
|
101261
|
-
]);
|
|
101262
|
-
});
|
|
101263
|
-
|
|
101264
101743
|
// src/commands/machine/daemon-start/file-content-fulfillment.ts
|
|
101265
101744
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
101266
101745
|
import { gzipSync as gzipSync2 } from "node:zlib";
|
|
@@ -101293,11 +101772,11 @@ var MAX_CONTENT_BYTES, fulfillFileContentRequestsEffect;
|
|
|
101293
101772
|
var init_file_content_fulfillment = __esm(() => {
|
|
101294
101773
|
init_esm();
|
|
101295
101774
|
init_daemon_services();
|
|
101775
|
+
init_file_content_classifier();
|
|
101296
101776
|
init_api3();
|
|
101297
101777
|
init_assert_registered_working_dir();
|
|
101298
101778
|
init_workspace_path_security();
|
|
101299
101779
|
init_workspace_visibility_policy();
|
|
101300
|
-
init_file_content_classifier();
|
|
101301
101780
|
MAX_CONTENT_BYTES = 500 * 1024;
|
|
101302
101781
|
fulfillFileContentRequestsEffect = exports_Effect.gen(function* () {
|
|
101303
101782
|
const session2 = yield* DaemonSessionService;
|
|
@@ -101928,29 +102407,41 @@ async function isWorkspacePathIgnored(rootDir, relativePath) {
|
|
|
101928
102407
|
const ruleSets = await loadApplicableIgnoreRuleSets(rootDir, relativePath);
|
|
101929
102408
|
return isPathIgnoredByRuleSets(ruleSets, relativePath);
|
|
101930
102409
|
}
|
|
102410
|
+
function mergeWorkspaceIgnoreRuleSets(inheritedRuleSets, localRuleSets) {
|
|
102411
|
+
return localRuleSets.length === 0 ? [...inheritedRuleSets] : [...inheritedRuleSets, ...localRuleSets];
|
|
102412
|
+
}
|
|
102413
|
+
async function readWorkspaceDirectoryDirents(rootDir, relDir) {
|
|
102414
|
+
const absDir = relDir ? path3.join(rootDir, relDir) : rootDir;
|
|
102415
|
+
try {
|
|
102416
|
+
return await fsPromises.readdir(absDir, { withFileTypes: true });
|
|
102417
|
+
} catch {
|
|
102418
|
+
return null;
|
|
102419
|
+
}
|
|
102420
|
+
}
|
|
101931
102421
|
async function loadAllWorkspaceIgnoreRuleSets(rootDir) {
|
|
101932
102422
|
const collected = [];
|
|
101933
102423
|
async function visit(relDir, inheritedRuleSets) {
|
|
101934
102424
|
const localRuleSets = await loadDirectoryIgnoreRuleSets(rootDir, relDir);
|
|
101935
|
-
const ruleSets =
|
|
102425
|
+
const ruleSets = mergeWorkspaceIgnoreRuleSets(inheritedRuleSets, localRuleSets);
|
|
101936
102426
|
collected.push(...localRuleSets);
|
|
101937
|
-
const
|
|
101938
|
-
|
|
101939
|
-
try {
|
|
101940
|
-
dirents = await fsPromises.readdir(absDir, { withFileTypes: true });
|
|
101941
|
-
} catch {
|
|
102427
|
+
const dirents = await readWorkspaceDirectoryDirents(rootDir, relDir);
|
|
102428
|
+
if (!dirents)
|
|
101942
102429
|
return;
|
|
101943
|
-
}
|
|
101944
102430
|
for (const ent of dirents) {
|
|
101945
102431
|
if (!ent.isDirectory())
|
|
101946
102432
|
continue;
|
|
101947
|
-
if (isAlwaysExcludedDirName(ent.name))
|
|
101948
|
-
continue;
|
|
101949
102433
|
const relativePath = relDir ? `${relDir}/${ent.name}` : ent.name;
|
|
101950
102434
|
if (!isPathVisible(relativePath))
|
|
101951
102435
|
continue;
|
|
101952
102436
|
if (isPathIgnoredByRuleSets(ruleSets, relativePath))
|
|
101953
102437
|
continue;
|
|
102438
|
+
const syncMode = classifyDirectorySyncMode(ent.name, {
|
|
102439
|
+
relativePath,
|
|
102440
|
+
immediateSiblingCount: dirents.length,
|
|
102441
|
+
immediateChildCount: 0
|
|
102442
|
+
});
|
|
102443
|
+
if (syncMode !== "full")
|
|
102444
|
+
continue;
|
|
101954
102445
|
await visit(relativePath, ruleSets);
|
|
101955
102446
|
}
|
|
101956
102447
|
}
|
|
@@ -101965,40 +102456,43 @@ var init_workspace_ignore = __esm(() => {
|
|
|
101965
102456
|
});
|
|
101966
102457
|
|
|
101967
102458
|
// src/infrastructure/services/workspace/workspace-file-walk.ts
|
|
101968
|
-
import { promises as fsPromises2 } from "node:fs";
|
|
101969
|
-
import path4 from "node:path";
|
|
101970
102459
|
async function walkWorkspaceFiles(rootDir, options) {
|
|
101971
102460
|
const maxFilePaths = options?.maxFilePaths ?? 1e4;
|
|
101972
102461
|
const filePaths = [];
|
|
102462
|
+
const directoryStubs = [];
|
|
101973
102463
|
let truncated = false;
|
|
101974
|
-
async function visitDir(relDir, inheritedRuleSets) {
|
|
102464
|
+
async function visitDir(relDir, inheritedRuleSets, siblingCount) {
|
|
101975
102465
|
if (truncated || filePaths.length >= maxFilePaths) {
|
|
101976
102466
|
truncated = true;
|
|
101977
102467
|
return;
|
|
101978
102468
|
}
|
|
101979
102469
|
const localRuleSets = await loadDirectoryIgnoreRuleSets(rootDir, relDir);
|
|
101980
|
-
const ruleSets =
|
|
101981
|
-
const
|
|
101982
|
-
|
|
101983
|
-
try {
|
|
101984
|
-
dirents = await fsPromises2.readdir(absDir, { withFileTypes: true });
|
|
101985
|
-
} catch {
|
|
102470
|
+
const ruleSets = mergeWorkspaceIgnoreRuleSets(inheritedRuleSets, localRuleSets);
|
|
102471
|
+
const dirents = await readWorkspaceDirectoryDirents(rootDir, relDir);
|
|
102472
|
+
if (!dirents)
|
|
101986
102473
|
return;
|
|
101987
|
-
}
|
|
101988
102474
|
for (const ent of dirents) {
|
|
101989
102475
|
if (truncated || filePaths.length >= maxFilePaths) {
|
|
101990
102476
|
truncated = true;
|
|
101991
102477
|
return;
|
|
101992
102478
|
}
|
|
101993
|
-
if (isAlwaysExcludedDirName(ent.name))
|
|
101994
|
-
continue;
|
|
101995
102479
|
const relativePath = relDir ? `${relDir}/${ent.name}` : ent.name;
|
|
101996
102480
|
if (!isPathVisible(relativePath))
|
|
101997
102481
|
continue;
|
|
101998
102482
|
if (ent.isDirectory()) {
|
|
101999
102483
|
if (isPathIgnoredByRuleSets(ruleSets, relativePath))
|
|
102000
102484
|
continue;
|
|
102001
|
-
|
|
102485
|
+
const syncMode = classifyDirectorySyncMode(ent.name, {
|
|
102486
|
+
relativePath,
|
|
102487
|
+
immediateSiblingCount: siblingCount,
|
|
102488
|
+
immediateChildCount: dirents.length
|
|
102489
|
+
});
|
|
102490
|
+
if (syncMode === "hidden")
|
|
102491
|
+
continue;
|
|
102492
|
+
directoryStubs.push(relativePath);
|
|
102493
|
+
if (syncMode === "shallow")
|
|
102494
|
+
continue;
|
|
102495
|
+
await visitDir(relativePath, ruleSets, dirents.length);
|
|
102002
102496
|
} else if (ent.isFile()) {
|
|
102003
102497
|
if (isPathIgnoredByRuleSets(ruleSets, relativePath))
|
|
102004
102498
|
continue;
|
|
@@ -102008,8 +102502,8 @@ async function walkWorkspaceFiles(rootDir, options) {
|
|
|
102008
102502
|
}
|
|
102009
102503
|
}
|
|
102010
102504
|
}
|
|
102011
|
-
await visitDir("", []);
|
|
102012
|
-
return { filePaths, truncated };
|
|
102505
|
+
await visitDir("", [], 0);
|
|
102506
|
+
return { filePaths, directoryStubs, truncated };
|
|
102013
102507
|
}
|
|
102014
102508
|
var init_workspace_file_walk = __esm(() => {
|
|
102015
102509
|
init_workspace_ignore();
|
|
@@ -102022,7 +102516,8 @@ async function scanFileTree(rootDir, options) {
|
|
|
102022
102516
|
const scannedAt = Date.now();
|
|
102023
102517
|
const walk = await walkWorkspaceFiles(rootDir, { maxFilePaths: maxEntries });
|
|
102024
102518
|
const filteredPaths = walk.filePaths.filter((p) => !isExcluded(p));
|
|
102025
|
-
const
|
|
102519
|
+
const filteredStubs = walk.directoryStubs.filter((p) => !isExcluded(p));
|
|
102520
|
+
const entries2 = buildEntries(filteredPaths, filteredStubs, maxEntries);
|
|
102026
102521
|
return {
|
|
102027
102522
|
entries: entries2,
|
|
102028
102523
|
scannedAt,
|
|
@@ -102032,28 +102527,31 @@ async function scanFileTree(rootDir, options) {
|
|
|
102032
102527
|
function isExcluded(filePath) {
|
|
102033
102528
|
return hasExcludedDirSegment(filePath);
|
|
102034
102529
|
}
|
|
102035
|
-
function
|
|
102036
|
-
|
|
102530
|
+
function entryDepth(entryPath) {
|
|
102531
|
+
return entryPath.split("/").length;
|
|
102532
|
+
}
|
|
102533
|
+
function buildEntries(filePaths, directoryStubs, maxEntries) {
|
|
102534
|
+
const directories = new Set(directoryStubs);
|
|
102037
102535
|
for (const filePath of filePaths) {
|
|
102038
102536
|
const parts2 = filePath.split("/");
|
|
102039
102537
|
for (let i2 = 1;i2 < parts2.length; i2++) {
|
|
102040
102538
|
directories.add(parts2.slice(0, i2).join("/"));
|
|
102041
102539
|
}
|
|
102042
102540
|
}
|
|
102043
|
-
const entries2 = [
|
|
102044
|
-
|
|
102045
|
-
|
|
102046
|
-
|
|
102047
|
-
|
|
102048
|
-
|
|
102049
|
-
|
|
102050
|
-
const sortedFiles = filePaths.slice().sort();
|
|
102051
|
-
for (const file2 of sortedFiles) {
|
|
102052
|
-
if (entries2.length >= maxEntries)
|
|
102053
|
-
break;
|
|
102054
|
-
entries2.push({ path: file2, type: "file" });
|
|
102541
|
+
const entries2 = [
|
|
102542
|
+
...Array.from(directories).map((dir) => ({ path: dir, type: "directory" })),
|
|
102543
|
+
...filePaths.map((file2) => ({ path: file2, type: "file" }))
|
|
102544
|
+
];
|
|
102545
|
+
const uniqueByPath = new Map;
|
|
102546
|
+
for (const entry of entries2) {
|
|
102547
|
+
uniqueByPath.set(entry.path, entry);
|
|
102055
102548
|
}
|
|
102056
|
-
return
|
|
102549
|
+
return Array.from(uniqueByPath.values()).sort((left3, right3) => {
|
|
102550
|
+
const depthDelta = entryDepth(left3.path) - entryDepth(right3.path);
|
|
102551
|
+
if (depthDelta !== 0)
|
|
102552
|
+
return depthDelta;
|
|
102553
|
+
return left3.path.localeCompare(right3.path);
|
|
102554
|
+
}).slice(0, maxEntries);
|
|
102057
102555
|
}
|
|
102058
102556
|
var DEFAULT_MAX_ENTRIES = 1e4;
|
|
102059
102557
|
var init_file_tree_scanner = __esm(() => {
|
|
@@ -102063,7 +102561,7 @@ var init_file_tree_scanner = __esm(() => {
|
|
|
102063
102561
|
|
|
102064
102562
|
// src/infrastructure/services/workspace/git-workspace-porcelain.ts
|
|
102065
102563
|
import { existsSync as existsSync7 } from "node:fs";
|
|
102066
|
-
import
|
|
102564
|
+
import path4 from "node:path";
|
|
102067
102565
|
function isEmptyRepoHeadError(error51) {
|
|
102068
102566
|
const message = error51.message.toLowerCase();
|
|
102069
102567
|
return message.includes("unknown revision") || message.includes("bad revision") || message.includes("ambiguous argument") || message.includes("needed a single revision");
|
|
@@ -102262,7 +102760,7 @@ function porcelainUntrackedDeletedEvents(args2) {
|
|
|
102262
102760
|
const prevEntry = prevByWsPath.get(wsPath);
|
|
102263
102761
|
if (prevEntry?.xy !== "??")
|
|
102264
102762
|
continue;
|
|
102265
|
-
const absPath =
|
|
102763
|
+
const absPath = path4.join(args2.node.workTree, prevEntry.path);
|
|
102266
102764
|
if (!exists3(absPath)) {
|
|
102267
102765
|
events.push({
|
|
102268
102766
|
kind: prevEntry.path.endsWith("/") ? "unlinkDir" : "unlink",
|
|
@@ -102529,8 +103027,8 @@ var init_git_workspace_change_source = __esm(() => {
|
|
|
102529
103027
|
});
|
|
102530
103028
|
|
|
102531
103029
|
// src/infrastructure/services/workspace/git-workspace-hierarchy.ts
|
|
102532
|
-
import { promises as
|
|
102533
|
-
import
|
|
103030
|
+
import { promises as fsPromises2 } from "node:fs";
|
|
103031
|
+
import path5 from "node:path";
|
|
102534
103032
|
function normalizeRel(p) {
|
|
102535
103033
|
return p.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
102536
103034
|
}
|
|
@@ -102545,15 +103043,15 @@ async function resolveGitDir(workTree) {
|
|
|
102545
103043
|
const raw = await revParse(workTree, "--git-dir");
|
|
102546
103044
|
if (!raw)
|
|
102547
103045
|
return null;
|
|
102548
|
-
return
|
|
103046
|
+
return path5.isAbsolute(raw) ? raw : path5.resolve(workTree, raw);
|
|
102549
103047
|
}
|
|
102550
103048
|
async function findNestedWorkTrees(workspaceRoot) {
|
|
102551
103049
|
const found = [];
|
|
102552
103050
|
async function visit(relDir) {
|
|
102553
|
-
const absDir = relDir ?
|
|
103051
|
+
const absDir = relDir ? path5.join(workspaceRoot, relDir) : workspaceRoot;
|
|
102554
103052
|
let dirents;
|
|
102555
103053
|
try {
|
|
102556
|
-
dirents = await
|
|
103054
|
+
dirents = await fsPromises2.readdir(absDir, { withFileTypes: true });
|
|
102557
103055
|
} catch {
|
|
102558
103056
|
return;
|
|
102559
103057
|
}
|
|
@@ -102562,7 +103060,7 @@ async function findNestedWorkTrees(workspaceRoot) {
|
|
|
102562
103060
|
const relativePath = relDir ? `${relDir}/${name}` : name;
|
|
102563
103061
|
if (name === ".git") {
|
|
102564
103062
|
if (relDir) {
|
|
102565
|
-
found.push(
|
|
103063
|
+
found.push(path5.resolve(workspaceRoot, relDir));
|
|
102566
103064
|
}
|
|
102567
103065
|
continue;
|
|
102568
103066
|
}
|
|
@@ -102576,12 +103074,12 @@ async function findNestedWorkTrees(workspaceRoot) {
|
|
|
102576
103074
|
}
|
|
102577
103075
|
}
|
|
102578
103076
|
await visit("");
|
|
102579
|
-
return [...new Set(found.map((p) =>
|
|
103077
|
+
return [...new Set(found.map((p) => path5.resolve(p)))].sort((a, b) => a.length - b.length || a.localeCompare(b));
|
|
102580
103078
|
}
|
|
102581
103079
|
async function discoverGitWorkspaceHierarchy(workingDir) {
|
|
102582
103080
|
let workspaceRoot;
|
|
102583
103081
|
try {
|
|
102584
|
-
workspaceRoot = await
|
|
103082
|
+
workspaceRoot = await fsPromises2.realpath(workingDir);
|
|
102585
103083
|
} catch {
|
|
102586
103084
|
return null;
|
|
102587
103085
|
}
|
|
@@ -102592,8 +103090,8 @@ async function discoverGitWorkspaceHierarchy(workingDir) {
|
|
|
102592
103090
|
const gitDir = await resolveGitDir(workspaceRoot);
|
|
102593
103091
|
if (!toplevelRaw || !gitDir)
|
|
102594
103092
|
return null;
|
|
102595
|
-
const toplevel =
|
|
102596
|
-
const relFromToplevel = normalizeRel(
|
|
103093
|
+
const toplevel = path5.resolve(toplevelRaw);
|
|
103094
|
+
const relFromToplevel = normalizeRel(path5.relative(toplevel, workspaceRoot));
|
|
102597
103095
|
if (relFromToplevel.startsWith(".."))
|
|
102598
103096
|
return null;
|
|
102599
103097
|
const pathspec = relFromToplevel && toplevel !== workspaceRoot ? [relFromToplevel] : [];
|
|
@@ -102606,7 +103104,7 @@ async function discoverGitWorkspaceHierarchy(workingDir) {
|
|
|
102606
103104
|
nestedNodes.push({
|
|
102607
103105
|
workTree,
|
|
102608
103106
|
gitDir: nestedGitDir,
|
|
102609
|
-
relativePath: normalizeRel(
|
|
103107
|
+
relativePath: normalizeRel(path5.relative(workspaceRoot, workTree)),
|
|
102610
103108
|
pathspec: [],
|
|
102611
103109
|
children: []
|
|
102612
103110
|
});
|
|
@@ -102624,7 +103122,7 @@ async function discoverGitWorkspaceHierarchy(workingDir) {
|
|
|
102624
103122
|
for (const candidate of sorted) {
|
|
102625
103123
|
if (candidate === node)
|
|
102626
103124
|
continue;
|
|
102627
|
-
const prefix = candidate.workTree.endsWith(
|
|
103125
|
+
const prefix = candidate.workTree.endsWith(path5.sep) ? candidate.workTree : candidate.workTree + path5.sep;
|
|
102628
103126
|
if (node.workTree.startsWith(prefix) && candidate.workTree.length >= parent.workTree.length) {
|
|
102629
103127
|
parent = candidate;
|
|
102630
103128
|
}
|
|
@@ -102736,7 +103234,7 @@ var init_readdirp = __esm(() => {
|
|
|
102736
103234
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
102737
103235
|
const statMethod = opts.lstat ? lstat : stat2;
|
|
102738
103236
|
if (wantBigintFsStats) {
|
|
102739
|
-
this._stat = (
|
|
103237
|
+
this._stat = (path6) => statMethod(path6, { bigint: true });
|
|
102740
103238
|
} else {
|
|
102741
103239
|
this._stat = statMethod;
|
|
102742
103240
|
}
|
|
@@ -102761,8 +103259,8 @@ var init_readdirp = __esm(() => {
|
|
|
102761
103259
|
const par2 = this.parent;
|
|
102762
103260
|
const fil = par2 && par2.files;
|
|
102763
103261
|
if (fil && fil.length > 0) {
|
|
102764
|
-
const { path:
|
|
102765
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
103262
|
+
const { path: path6, depth } = par2;
|
|
103263
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path6));
|
|
102766
103264
|
const awaited = await Promise.all(slice);
|
|
102767
103265
|
for (const entry of awaited) {
|
|
102768
103266
|
if (!entry)
|
|
@@ -102802,20 +103300,20 @@ var init_readdirp = __esm(() => {
|
|
|
102802
103300
|
this.reading = false;
|
|
102803
103301
|
}
|
|
102804
103302
|
}
|
|
102805
|
-
async _exploreDir(
|
|
103303
|
+
async _exploreDir(path6, depth) {
|
|
102806
103304
|
let files;
|
|
102807
103305
|
try {
|
|
102808
|
-
files = await readdir(
|
|
103306
|
+
files = await readdir(path6, this._rdOptions);
|
|
102809
103307
|
} catch (error51) {
|
|
102810
103308
|
this._onError(error51);
|
|
102811
103309
|
}
|
|
102812
|
-
return { files, depth, path:
|
|
103310
|
+
return { files, depth, path: path6 };
|
|
102813
103311
|
}
|
|
102814
|
-
async _formatEntry(dirent,
|
|
103312
|
+
async _formatEntry(dirent, path6) {
|
|
102815
103313
|
let entry;
|
|
102816
103314
|
const basename2 = this._isDirent ? dirent.name : dirent;
|
|
102817
103315
|
try {
|
|
102818
|
-
const fullPath = presolve(pjoin(
|
|
103316
|
+
const fullPath = presolve(pjoin(path6, basename2));
|
|
102819
103317
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename2 };
|
|
102820
103318
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
102821
103319
|
} catch (err) {
|
|
@@ -102875,16 +103373,16 @@ import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
|
|
|
102875
103373
|
import { realpath as fsrealpath, lstat as lstat2, open, stat as stat3 } from "node:fs/promises";
|
|
102876
103374
|
import { type as osType } from "node:os";
|
|
102877
103375
|
import * as sp from "node:path";
|
|
102878
|
-
function createFsWatchInstance(
|
|
103376
|
+
function createFsWatchInstance(path6, options, listener, errHandler, emitRaw) {
|
|
102879
103377
|
const handleEvent = (rawEvent, evPath) => {
|
|
102880
|
-
listener(
|
|
102881
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
102882
|
-
if (evPath &&
|
|
102883
|
-
fsWatchBroadcast(sp.resolve(
|
|
103378
|
+
listener(path6);
|
|
103379
|
+
emitRaw(rawEvent, evPath, { watchedPath: path6 });
|
|
103380
|
+
if (evPath && path6 !== evPath) {
|
|
103381
|
+
fsWatchBroadcast(sp.resolve(path6, evPath), KEY_LISTENERS, sp.join(path6, evPath));
|
|
102884
103382
|
}
|
|
102885
103383
|
};
|
|
102886
103384
|
try {
|
|
102887
|
-
return fs_watch(
|
|
103385
|
+
return fs_watch(path6, {
|
|
102888
103386
|
persistent: options.persistent
|
|
102889
103387
|
}, handleEvent);
|
|
102890
103388
|
} catch (error51) {
|
|
@@ -102900,13 +103398,13 @@ class NodeFsHandler {
|
|
|
102900
103398
|
this.fsw = fsW;
|
|
102901
103399
|
this._boundHandleError = (error51) => fsW._handleError(error51);
|
|
102902
103400
|
}
|
|
102903
|
-
_watchWithNodeFs(
|
|
103401
|
+
_watchWithNodeFs(path6, listener) {
|
|
102904
103402
|
const opts = this.fsw.options;
|
|
102905
|
-
const directory = sp.dirname(
|
|
102906
|
-
const basename3 = sp.basename(
|
|
103403
|
+
const directory = sp.dirname(path6);
|
|
103404
|
+
const basename3 = sp.basename(path6);
|
|
102907
103405
|
const parent = this.fsw._getWatchedDir(directory);
|
|
102908
103406
|
parent.add(basename3);
|
|
102909
|
-
const absolutePath = sp.resolve(
|
|
103407
|
+
const absolutePath = sp.resolve(path6);
|
|
102910
103408
|
const options = {
|
|
102911
103409
|
persistent: opts.persistent
|
|
102912
103410
|
};
|
|
@@ -102916,12 +103414,12 @@ class NodeFsHandler {
|
|
|
102916
103414
|
if (opts.usePolling) {
|
|
102917
103415
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
102918
103416
|
options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
102919
|
-
closer = setFsWatchFileListener(
|
|
103417
|
+
closer = setFsWatchFileListener(path6, absolutePath, options, {
|
|
102920
103418
|
listener,
|
|
102921
103419
|
rawEmitter: this.fsw._emitRaw
|
|
102922
103420
|
});
|
|
102923
103421
|
} else {
|
|
102924
|
-
closer = setFsWatchListener(
|
|
103422
|
+
closer = setFsWatchListener(path6, absolutePath, options, {
|
|
102925
103423
|
listener,
|
|
102926
103424
|
errHandler: this._boundHandleError,
|
|
102927
103425
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -102939,7 +103437,7 @@ class NodeFsHandler {
|
|
|
102939
103437
|
let prevStats = stats;
|
|
102940
103438
|
if (parent.has(basename3))
|
|
102941
103439
|
return;
|
|
102942
|
-
const listener = async (
|
|
103440
|
+
const listener = async (path6, newStats) => {
|
|
102943
103441
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
102944
103442
|
return;
|
|
102945
103443
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -102953,11 +103451,11 @@ class NodeFsHandler {
|
|
|
102953
103451
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
102954
103452
|
}
|
|
102955
103453
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
102956
|
-
this.fsw._closeFile(
|
|
103454
|
+
this.fsw._closeFile(path6);
|
|
102957
103455
|
prevStats = newStats2;
|
|
102958
103456
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
102959
103457
|
if (closer2)
|
|
102960
|
-
this.fsw._addPathCloser(
|
|
103458
|
+
this.fsw._addPathCloser(path6, closer2);
|
|
102961
103459
|
} else {
|
|
102962
103460
|
prevStats = newStats2;
|
|
102963
103461
|
}
|
|
@@ -102981,7 +103479,7 @@ class NodeFsHandler {
|
|
|
102981
103479
|
}
|
|
102982
103480
|
return closer;
|
|
102983
103481
|
}
|
|
102984
|
-
async _handleSymlink(entry, directory,
|
|
103482
|
+
async _handleSymlink(entry, directory, path6, item) {
|
|
102985
103483
|
if (this.fsw.closed) {
|
|
102986
103484
|
return;
|
|
102987
103485
|
}
|
|
@@ -102991,7 +103489,7 @@ class NodeFsHandler {
|
|
|
102991
103489
|
this.fsw._incrReadyCount();
|
|
102992
103490
|
let linkPath;
|
|
102993
103491
|
try {
|
|
102994
|
-
linkPath = await fsrealpath(
|
|
103492
|
+
linkPath = await fsrealpath(path6);
|
|
102995
103493
|
} catch (e) {
|
|
102996
103494
|
this.fsw._emitReady();
|
|
102997
103495
|
return true;
|
|
@@ -103001,12 +103499,12 @@ class NodeFsHandler {
|
|
|
103001
103499
|
if (dir.has(item)) {
|
|
103002
103500
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
103003
103501
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
103004
|
-
this.fsw._emit(EV.CHANGE,
|
|
103502
|
+
this.fsw._emit(EV.CHANGE, path6, entry.stats);
|
|
103005
103503
|
}
|
|
103006
103504
|
} else {
|
|
103007
103505
|
dir.add(item);
|
|
103008
103506
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
103009
|
-
this.fsw._emit(EV.ADD,
|
|
103507
|
+
this.fsw._emit(EV.ADD, path6, entry.stats);
|
|
103010
103508
|
}
|
|
103011
103509
|
this.fsw._emitReady();
|
|
103012
103510
|
return true;
|
|
@@ -103036,9 +103534,9 @@ class NodeFsHandler {
|
|
|
103036
103534
|
return;
|
|
103037
103535
|
}
|
|
103038
103536
|
const item = entry.path;
|
|
103039
|
-
let
|
|
103537
|
+
let path6 = sp.join(directory, item);
|
|
103040
103538
|
current.add(item);
|
|
103041
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
103539
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path6, item)) {
|
|
103042
103540
|
return;
|
|
103043
103541
|
}
|
|
103044
103542
|
if (this.fsw.closed) {
|
|
@@ -103047,8 +103545,8 @@ class NodeFsHandler {
|
|
|
103047
103545
|
}
|
|
103048
103546
|
if (item === target || !target && !previous.has(item)) {
|
|
103049
103547
|
this.fsw._incrReadyCount();
|
|
103050
|
-
|
|
103051
|
-
this._addToNodeFs(
|
|
103548
|
+
path6 = sp.join(dir, sp.relative(dir, path6));
|
|
103549
|
+
this._addToNodeFs(path6, initialAdd, wh, depth + 1);
|
|
103052
103550
|
}
|
|
103053
103551
|
}).on(EV.ERROR, this._boundHandleError);
|
|
103054
103552
|
return new Promise((resolve6, reject) => {
|
|
@@ -103097,13 +103595,13 @@ class NodeFsHandler {
|
|
|
103097
103595
|
}
|
|
103098
103596
|
return closer;
|
|
103099
103597
|
}
|
|
103100
|
-
async _addToNodeFs(
|
|
103598
|
+
async _addToNodeFs(path6, initialAdd, priorWh, depth, target) {
|
|
103101
103599
|
const ready = this.fsw._emitReady;
|
|
103102
|
-
if (this.fsw._isIgnored(
|
|
103600
|
+
if (this.fsw._isIgnored(path6) || this.fsw.closed) {
|
|
103103
103601
|
ready();
|
|
103104
103602
|
return false;
|
|
103105
103603
|
}
|
|
103106
|
-
const wh = this.fsw._getWatchHelpers(
|
|
103604
|
+
const wh = this.fsw._getWatchHelpers(path6);
|
|
103107
103605
|
if (priorWh) {
|
|
103108
103606
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
103109
103607
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -103119,8 +103617,8 @@ class NodeFsHandler {
|
|
|
103119
103617
|
const follow = this.fsw.options.followSymlinks;
|
|
103120
103618
|
let closer;
|
|
103121
103619
|
if (stats.isDirectory()) {
|
|
103122
|
-
const absPath = sp.resolve(
|
|
103123
|
-
const targetPath = follow ? await fsrealpath(
|
|
103620
|
+
const absPath = sp.resolve(path6);
|
|
103621
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
103124
103622
|
if (this.fsw.closed)
|
|
103125
103623
|
return;
|
|
103126
103624
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -103130,29 +103628,29 @@ class NodeFsHandler {
|
|
|
103130
103628
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
103131
103629
|
}
|
|
103132
103630
|
} else if (stats.isSymbolicLink()) {
|
|
103133
|
-
const targetPath = follow ? await fsrealpath(
|
|
103631
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
103134
103632
|
if (this.fsw.closed)
|
|
103135
103633
|
return;
|
|
103136
103634
|
const parent = sp.dirname(wh.watchPath);
|
|
103137
103635
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
103138
103636
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
103139
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
103637
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path6, wh, targetPath);
|
|
103140
103638
|
if (this.fsw.closed)
|
|
103141
103639
|
return;
|
|
103142
103640
|
if (targetPath !== undefined) {
|
|
103143
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
103641
|
+
this.fsw._symlinkPaths.set(sp.resolve(path6), targetPath);
|
|
103144
103642
|
}
|
|
103145
103643
|
} else {
|
|
103146
103644
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
103147
103645
|
}
|
|
103148
103646
|
ready();
|
|
103149
103647
|
if (closer)
|
|
103150
|
-
this.fsw._addPathCloser(
|
|
103648
|
+
this.fsw._addPathCloser(path6, closer);
|
|
103151
103649
|
return false;
|
|
103152
103650
|
} catch (error51) {
|
|
103153
103651
|
if (this.fsw._handleError(error51)) {
|
|
103154
103652
|
ready();
|
|
103155
|
-
return
|
|
103653
|
+
return path6;
|
|
103156
103654
|
}
|
|
103157
103655
|
}
|
|
103158
103656
|
}
|
|
@@ -103190,12 +103688,12 @@ var STR_DATA = "data", STR_END = "end", STR_CLOSE = "close", EMPTY_FN = () => {}
|
|
|
103190
103688
|
foreach(cont[listenerType], (listener) => {
|
|
103191
103689
|
listener(val1, val2, val3);
|
|
103192
103690
|
});
|
|
103193
|
-
}, setFsWatchListener = (
|
|
103691
|
+
}, setFsWatchListener = (path6, fullPath, options, handlers) => {
|
|
103194
103692
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
103195
103693
|
let cont = FsWatchInstances.get(fullPath);
|
|
103196
103694
|
let watcher;
|
|
103197
103695
|
if (!options.persistent) {
|
|
103198
|
-
watcher = createFsWatchInstance(
|
|
103696
|
+
watcher = createFsWatchInstance(path6, options, listener, errHandler, rawEmitter);
|
|
103199
103697
|
if (!watcher)
|
|
103200
103698
|
return;
|
|
103201
103699
|
return watcher.close.bind(watcher);
|
|
@@ -103205,7 +103703,7 @@ var STR_DATA = "data", STR_END = "end", STR_CLOSE = "close", EMPTY_FN = () => {}
|
|
|
103205
103703
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
103206
103704
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
103207
103705
|
} else {
|
|
103208
|
-
watcher = createFsWatchInstance(
|
|
103706
|
+
watcher = createFsWatchInstance(path6, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
103209
103707
|
if (!watcher)
|
|
103210
103708
|
return;
|
|
103211
103709
|
watcher.on(EV.ERROR, async (error51) => {
|
|
@@ -103214,7 +103712,7 @@ var STR_DATA = "data", STR_END = "end", STR_CLOSE = "close", EMPTY_FN = () => {}
|
|
|
103214
103712
|
cont.watcherUnusable = true;
|
|
103215
103713
|
if (isWindows && error51.code === "EPERM") {
|
|
103216
103714
|
try {
|
|
103217
|
-
const fd = await open(
|
|
103715
|
+
const fd = await open(path6, "r");
|
|
103218
103716
|
await fd.close();
|
|
103219
103717
|
broadcastErr(error51);
|
|
103220
103718
|
} catch (err) {}
|
|
@@ -103242,7 +103740,7 @@ var STR_DATA = "data", STR_END = "end", STR_CLOSE = "close", EMPTY_FN = () => {}
|
|
|
103242
103740
|
Object.freeze(cont);
|
|
103243
103741
|
}
|
|
103244
103742
|
};
|
|
103245
|
-
}, FsWatchFileInstances, setFsWatchFileListener = (
|
|
103743
|
+
}, FsWatchFileInstances, setFsWatchFileListener = (path6, fullPath, options, handlers) => {
|
|
103246
103744
|
const { listener, rawEmitter } = handlers;
|
|
103247
103745
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
103248
103746
|
const copts = cont && cont.options;
|
|
@@ -103264,7 +103762,7 @@ var STR_DATA = "data", STR_END = "end", STR_CLOSE = "close", EMPTY_FN = () => {}
|
|
|
103264
103762
|
});
|
|
103265
103763
|
const currmtime = curr.mtimeMs;
|
|
103266
103764
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
103267
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
103765
|
+
foreach(cont.listeners, (listener2) => listener2(path6, curr));
|
|
103268
103766
|
}
|
|
103269
103767
|
})
|
|
103270
103768
|
};
|
|
@@ -103600,24 +104098,24 @@ function createPattern(matcher) {
|
|
|
103600
104098
|
}
|
|
103601
104099
|
return () => false;
|
|
103602
104100
|
}
|
|
103603
|
-
function normalizePath(
|
|
103604
|
-
if (typeof
|
|
104101
|
+
function normalizePath(path6) {
|
|
104102
|
+
if (typeof path6 !== "string")
|
|
103605
104103
|
throw new Error("string expected");
|
|
103606
|
-
|
|
103607
|
-
|
|
104104
|
+
path6 = sp2.normalize(path6);
|
|
104105
|
+
path6 = path6.replace(/\\/g, "/");
|
|
103608
104106
|
let prepend4 = false;
|
|
103609
|
-
if (
|
|
104107
|
+
if (path6.startsWith("//"))
|
|
103610
104108
|
prepend4 = true;
|
|
103611
|
-
|
|
104109
|
+
path6 = path6.replace(DOUBLE_SLASH_RE, "/");
|
|
103612
104110
|
if (prepend4)
|
|
103613
|
-
|
|
103614
|
-
return
|
|
104111
|
+
path6 = "/" + path6;
|
|
104112
|
+
return path6;
|
|
103615
104113
|
}
|
|
103616
104114
|
function matchPatterns(patterns, testString, stats) {
|
|
103617
|
-
const
|
|
104115
|
+
const path6 = normalizePath(testString);
|
|
103618
104116
|
for (let index = 0;index < patterns.length; index++) {
|
|
103619
104117
|
const pattern = patterns[index];
|
|
103620
|
-
if (pattern(
|
|
104118
|
+
if (pattern(path6, stats)) {
|
|
103621
104119
|
return true;
|
|
103622
104120
|
}
|
|
103623
104121
|
}
|
|
@@ -103698,10 +104196,10 @@ class WatchHelper {
|
|
|
103698
104196
|
dirParts;
|
|
103699
104197
|
followSymlinks;
|
|
103700
104198
|
statMethod;
|
|
103701
|
-
constructor(
|
|
104199
|
+
constructor(path6, follow, fsw) {
|
|
103702
104200
|
this.fsw = fsw;
|
|
103703
|
-
const watchPath =
|
|
103704
|
-
this.path =
|
|
104201
|
+
const watchPath = path6;
|
|
104202
|
+
this.path = path6 = path6.replace(REPLACER_RE, "");
|
|
103705
104203
|
this.watchPath = watchPath;
|
|
103706
104204
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
103707
104205
|
this.dirParts = [];
|
|
@@ -103748,17 +104246,17 @@ var SLASH = "/", SLASH_SLASH = "//", ONE_DOT = ".", TWO_DOTS = "..", STRING_TYPE
|
|
|
103748
104246
|
str = SLASH + str;
|
|
103749
104247
|
}
|
|
103750
104248
|
return str;
|
|
103751
|
-
}, normalizePathToUnix = (
|
|
103752
|
-
if (typeof
|
|
103753
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
104249
|
+
}, normalizePathToUnix = (path6) => toUnix(sp2.normalize(toUnix(path6))), normalizeIgnored = (cwd = "") => (path6) => {
|
|
104250
|
+
if (typeof path6 === "string") {
|
|
104251
|
+
return normalizePathToUnix(sp2.isAbsolute(path6) ? path6 : sp2.join(cwd, path6));
|
|
103754
104252
|
} else {
|
|
103755
|
-
return
|
|
104253
|
+
return path6;
|
|
103756
104254
|
}
|
|
103757
|
-
}, getAbsolutePath = (
|
|
103758
|
-
if (sp2.isAbsolute(
|
|
103759
|
-
return
|
|
104255
|
+
}, getAbsolutePath = (path6, cwd) => {
|
|
104256
|
+
if (sp2.isAbsolute(path6)) {
|
|
104257
|
+
return path6;
|
|
103760
104258
|
}
|
|
103761
|
-
return sp2.join(cwd,
|
|
104259
|
+
return sp2.join(cwd, path6);
|
|
103762
104260
|
}, EMPTY_SET, STAT_METHOD_F = "stat", STAT_METHOD_L = "lstat", FSWatcher;
|
|
103763
104261
|
var init_chokidar = __esm(() => {
|
|
103764
104262
|
init_readdirp();
|
|
@@ -103874,20 +104372,20 @@ var init_chokidar = __esm(() => {
|
|
|
103874
104372
|
this._closePromise = undefined;
|
|
103875
104373
|
let paths = unifyPaths(paths_);
|
|
103876
104374
|
if (cwd) {
|
|
103877
|
-
paths = paths.map((
|
|
103878
|
-
const absPath = getAbsolutePath(
|
|
104375
|
+
paths = paths.map((path6) => {
|
|
104376
|
+
const absPath = getAbsolutePath(path6, cwd);
|
|
103879
104377
|
return absPath;
|
|
103880
104378
|
});
|
|
103881
104379
|
}
|
|
103882
|
-
paths.forEach((
|
|
103883
|
-
this._removeIgnoredPath(
|
|
104380
|
+
paths.forEach((path6) => {
|
|
104381
|
+
this._removeIgnoredPath(path6);
|
|
103884
104382
|
});
|
|
103885
104383
|
this._userIgnored = undefined;
|
|
103886
104384
|
if (!this._readyCount)
|
|
103887
104385
|
this._readyCount = 0;
|
|
103888
104386
|
this._readyCount += paths.length;
|
|
103889
|
-
Promise.all(paths.map(async (
|
|
103890
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
104387
|
+
Promise.all(paths.map(async (path6) => {
|
|
104388
|
+
const res = await this._nodeFsHandler._addToNodeFs(path6, !_internal, undefined, 0, _origAdd);
|
|
103891
104389
|
if (res)
|
|
103892
104390
|
this._emitReady();
|
|
103893
104391
|
return res;
|
|
@@ -103906,17 +104404,17 @@ var init_chokidar = __esm(() => {
|
|
|
103906
104404
|
return this;
|
|
103907
104405
|
const paths = unifyPaths(paths_);
|
|
103908
104406
|
const { cwd } = this.options;
|
|
103909
|
-
paths.forEach((
|
|
103910
|
-
if (!sp2.isAbsolute(
|
|
104407
|
+
paths.forEach((path6) => {
|
|
104408
|
+
if (!sp2.isAbsolute(path6) && !this._closers.has(path6)) {
|
|
103911
104409
|
if (cwd)
|
|
103912
|
-
|
|
103913
|
-
|
|
104410
|
+
path6 = sp2.join(cwd, path6);
|
|
104411
|
+
path6 = sp2.resolve(path6);
|
|
103914
104412
|
}
|
|
103915
|
-
this._closePath(
|
|
103916
|
-
this._addIgnoredPath(
|
|
103917
|
-
if (this._watched.has(
|
|
104413
|
+
this._closePath(path6);
|
|
104414
|
+
this._addIgnoredPath(path6);
|
|
104415
|
+
if (this._watched.has(path6)) {
|
|
103918
104416
|
this._addIgnoredPath({
|
|
103919
|
-
path:
|
|
104417
|
+
path: path6,
|
|
103920
104418
|
recursive: true
|
|
103921
104419
|
});
|
|
103922
104420
|
}
|
|
@@ -103965,38 +104463,38 @@ var init_chokidar = __esm(() => {
|
|
|
103965
104463
|
if (event !== EVENTS.ERROR)
|
|
103966
104464
|
this.emit(EVENTS.ALL, event, ...args2);
|
|
103967
104465
|
}
|
|
103968
|
-
async _emit(event,
|
|
104466
|
+
async _emit(event, path6, stats) {
|
|
103969
104467
|
if (this.closed)
|
|
103970
104468
|
return;
|
|
103971
104469
|
const opts = this.options;
|
|
103972
104470
|
if (isWindows)
|
|
103973
|
-
|
|
104471
|
+
path6 = sp2.normalize(path6);
|
|
103974
104472
|
if (opts.cwd)
|
|
103975
|
-
|
|
103976
|
-
const args2 = [
|
|
104473
|
+
path6 = sp2.relative(opts.cwd, path6);
|
|
104474
|
+
const args2 = [path6];
|
|
103977
104475
|
if (stats != null)
|
|
103978
104476
|
args2.push(stats);
|
|
103979
104477
|
const awf = opts.awaitWriteFinish;
|
|
103980
104478
|
let pw;
|
|
103981
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
104479
|
+
if (awf && (pw = this._pendingWrites.get(path6))) {
|
|
103982
104480
|
pw.lastChange = new Date;
|
|
103983
104481
|
return this;
|
|
103984
104482
|
}
|
|
103985
104483
|
if (opts.atomic) {
|
|
103986
104484
|
if (event === EVENTS.UNLINK) {
|
|
103987
|
-
this._pendingUnlinks.set(
|
|
104485
|
+
this._pendingUnlinks.set(path6, [event, ...args2]);
|
|
103988
104486
|
setTimeout(() => {
|
|
103989
|
-
this._pendingUnlinks.forEach((entry,
|
|
104487
|
+
this._pendingUnlinks.forEach((entry, path7) => {
|
|
103990
104488
|
this.emit(...entry);
|
|
103991
104489
|
this.emit(EVENTS.ALL, ...entry);
|
|
103992
|
-
this._pendingUnlinks.delete(
|
|
104490
|
+
this._pendingUnlinks.delete(path7);
|
|
103993
104491
|
});
|
|
103994
104492
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
103995
104493
|
return this;
|
|
103996
104494
|
}
|
|
103997
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
104495
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path6)) {
|
|
103998
104496
|
event = EVENTS.CHANGE;
|
|
103999
|
-
this._pendingUnlinks.delete(
|
|
104497
|
+
this._pendingUnlinks.delete(path6);
|
|
104000
104498
|
}
|
|
104001
104499
|
}
|
|
104002
104500
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -104014,16 +104512,16 @@ var init_chokidar = __esm(() => {
|
|
|
104014
104512
|
this.emitWithAll(event, args2);
|
|
104015
104513
|
}
|
|
104016
104514
|
};
|
|
104017
|
-
this._awaitWriteFinish(
|
|
104515
|
+
this._awaitWriteFinish(path6, awf.stabilityThreshold, event, awfEmit);
|
|
104018
104516
|
return this;
|
|
104019
104517
|
}
|
|
104020
104518
|
if (event === EVENTS.CHANGE) {
|
|
104021
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
104519
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path6, 50);
|
|
104022
104520
|
if (isThrottled)
|
|
104023
104521
|
return this;
|
|
104024
104522
|
}
|
|
104025
104523
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
104026
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
104524
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path6) : path6;
|
|
104027
104525
|
let stats2;
|
|
104028
104526
|
try {
|
|
104029
104527
|
stats2 = await stat4(fullPath);
|
|
@@ -104042,23 +104540,23 @@ var init_chokidar = __esm(() => {
|
|
|
104042
104540
|
}
|
|
104043
104541
|
return error51 || this.closed;
|
|
104044
104542
|
}
|
|
104045
|
-
_throttle(actionType,
|
|
104543
|
+
_throttle(actionType, path6, timeout3) {
|
|
104046
104544
|
if (!this._throttled.has(actionType)) {
|
|
104047
104545
|
this._throttled.set(actionType, new Map);
|
|
104048
104546
|
}
|
|
104049
104547
|
const action = this._throttled.get(actionType);
|
|
104050
104548
|
if (!action)
|
|
104051
104549
|
throw new Error("invalid throttle");
|
|
104052
|
-
const actionPath = action.get(
|
|
104550
|
+
const actionPath = action.get(path6);
|
|
104053
104551
|
if (actionPath) {
|
|
104054
104552
|
actionPath.count++;
|
|
104055
104553
|
return false;
|
|
104056
104554
|
}
|
|
104057
104555
|
let timeoutObject;
|
|
104058
104556
|
const clear = () => {
|
|
104059
|
-
const item = action.get(
|
|
104557
|
+
const item = action.get(path6);
|
|
104060
104558
|
const count3 = item ? item.count : 0;
|
|
104061
|
-
action.delete(
|
|
104559
|
+
action.delete(path6);
|
|
104062
104560
|
clearTimeout(timeoutObject);
|
|
104063
104561
|
if (item)
|
|
104064
104562
|
clearTimeout(item.timeoutObject);
|
|
@@ -104066,50 +104564,50 @@ var init_chokidar = __esm(() => {
|
|
|
104066
104564
|
};
|
|
104067
104565
|
timeoutObject = setTimeout(clear, timeout3);
|
|
104068
104566
|
const thr = { timeoutObject, clear, count: 0 };
|
|
104069
|
-
action.set(
|
|
104567
|
+
action.set(path6, thr);
|
|
104070
104568
|
return thr;
|
|
104071
104569
|
}
|
|
104072
104570
|
_incrReadyCount() {
|
|
104073
104571
|
return this._readyCount++;
|
|
104074
104572
|
}
|
|
104075
|
-
_awaitWriteFinish(
|
|
104573
|
+
_awaitWriteFinish(path6, threshold, event, awfEmit) {
|
|
104076
104574
|
const awf = this.options.awaitWriteFinish;
|
|
104077
104575
|
if (typeof awf !== "object")
|
|
104078
104576
|
return;
|
|
104079
104577
|
const pollInterval = awf.pollInterval;
|
|
104080
104578
|
let timeoutHandler;
|
|
104081
|
-
let fullPath =
|
|
104082
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
104083
|
-
fullPath = sp2.join(this.options.cwd,
|
|
104579
|
+
let fullPath = path6;
|
|
104580
|
+
if (this.options.cwd && !sp2.isAbsolute(path6)) {
|
|
104581
|
+
fullPath = sp2.join(this.options.cwd, path6);
|
|
104084
104582
|
}
|
|
104085
104583
|
const now = new Date;
|
|
104086
104584
|
const writes = this._pendingWrites;
|
|
104087
104585
|
function awaitWriteFinishFn(prevStat) {
|
|
104088
104586
|
statcb(fullPath, (err, curStat) => {
|
|
104089
|
-
if (err || !writes.has(
|
|
104587
|
+
if (err || !writes.has(path6)) {
|
|
104090
104588
|
if (err && err.code !== "ENOENT")
|
|
104091
104589
|
awfEmit(err);
|
|
104092
104590
|
return;
|
|
104093
104591
|
}
|
|
104094
104592
|
const now2 = Number(new Date);
|
|
104095
104593
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
104096
|
-
writes.get(
|
|
104594
|
+
writes.get(path6).lastChange = now2;
|
|
104097
104595
|
}
|
|
104098
|
-
const pw = writes.get(
|
|
104596
|
+
const pw = writes.get(path6);
|
|
104099
104597
|
const df = now2 - pw.lastChange;
|
|
104100
104598
|
if (df >= threshold) {
|
|
104101
|
-
writes.delete(
|
|
104599
|
+
writes.delete(path6);
|
|
104102
104600
|
awfEmit(undefined, curStat);
|
|
104103
104601
|
} else {
|
|
104104
104602
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
104105
104603
|
}
|
|
104106
104604
|
});
|
|
104107
104605
|
}
|
|
104108
|
-
if (!writes.has(
|
|
104109
|
-
writes.set(
|
|
104606
|
+
if (!writes.has(path6)) {
|
|
104607
|
+
writes.set(path6, {
|
|
104110
104608
|
lastChange: now,
|
|
104111
104609
|
cancelWait: () => {
|
|
104112
|
-
writes.delete(
|
|
104610
|
+
writes.delete(path6);
|
|
104113
104611
|
clearTimeout(timeoutHandler);
|
|
104114
104612
|
return event;
|
|
104115
104613
|
}
|
|
@@ -104117,8 +104615,8 @@ var init_chokidar = __esm(() => {
|
|
|
104117
104615
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
104118
104616
|
}
|
|
104119
104617
|
}
|
|
104120
|
-
_isIgnored(
|
|
104121
|
-
if (this.options.atomic && DOT_RE.test(
|
|
104618
|
+
_isIgnored(path6, stats) {
|
|
104619
|
+
if (this.options.atomic && DOT_RE.test(path6))
|
|
104122
104620
|
return true;
|
|
104123
104621
|
if (!this._userIgnored) {
|
|
104124
104622
|
const { cwd } = this.options;
|
|
@@ -104128,13 +104626,13 @@ var init_chokidar = __esm(() => {
|
|
|
104128
104626
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
104129
104627
|
this._userIgnored = anymatch(list, undefined);
|
|
104130
104628
|
}
|
|
104131
|
-
return this._userIgnored(
|
|
104629
|
+
return this._userIgnored(path6, stats);
|
|
104132
104630
|
}
|
|
104133
|
-
_isntIgnored(
|
|
104134
|
-
return !this._isIgnored(
|
|
104631
|
+
_isntIgnored(path6, stat5) {
|
|
104632
|
+
return !this._isIgnored(path6, stat5);
|
|
104135
104633
|
}
|
|
104136
|
-
_getWatchHelpers(
|
|
104137
|
-
return new WatchHelper(
|
|
104634
|
+
_getWatchHelpers(path6) {
|
|
104635
|
+
return new WatchHelper(path6, this.options.followSymlinks, this);
|
|
104138
104636
|
}
|
|
104139
104637
|
_getWatchedDir(directory) {
|
|
104140
104638
|
const dir = sp2.resolve(directory);
|
|
@@ -104148,57 +104646,57 @@ var init_chokidar = __esm(() => {
|
|
|
104148
104646
|
return Boolean(Number(stats.mode) & 256);
|
|
104149
104647
|
}
|
|
104150
104648
|
_remove(directory, item, isDirectory) {
|
|
104151
|
-
const
|
|
104152
|
-
const fullPath = sp2.resolve(
|
|
104153
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
104154
|
-
if (!this._throttle("remove",
|
|
104649
|
+
const path6 = sp2.join(directory, item);
|
|
104650
|
+
const fullPath = sp2.resolve(path6);
|
|
104651
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path6) || this._watched.has(fullPath);
|
|
104652
|
+
if (!this._throttle("remove", path6, 100))
|
|
104155
104653
|
return;
|
|
104156
104654
|
if (!isDirectory && this._watched.size === 1) {
|
|
104157
104655
|
this.add(directory, item, true);
|
|
104158
104656
|
}
|
|
104159
|
-
const wp = this._getWatchedDir(
|
|
104657
|
+
const wp = this._getWatchedDir(path6);
|
|
104160
104658
|
const nestedDirectoryChildren = wp.getChildren();
|
|
104161
|
-
nestedDirectoryChildren.forEach((nested2) => this._remove(
|
|
104659
|
+
nestedDirectoryChildren.forEach((nested2) => this._remove(path6, nested2));
|
|
104162
104660
|
const parent = this._getWatchedDir(directory);
|
|
104163
104661
|
const wasTracked = parent.has(item);
|
|
104164
104662
|
parent.remove(item);
|
|
104165
104663
|
if (this._symlinkPaths.has(fullPath)) {
|
|
104166
104664
|
this._symlinkPaths.delete(fullPath);
|
|
104167
104665
|
}
|
|
104168
|
-
let relPath =
|
|
104666
|
+
let relPath = path6;
|
|
104169
104667
|
if (this.options.cwd)
|
|
104170
|
-
relPath = sp2.relative(this.options.cwd,
|
|
104668
|
+
relPath = sp2.relative(this.options.cwd, path6);
|
|
104171
104669
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
104172
104670
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
104173
104671
|
if (event === EVENTS.ADD)
|
|
104174
104672
|
return;
|
|
104175
104673
|
}
|
|
104176
|
-
this._watched.delete(
|
|
104674
|
+
this._watched.delete(path6);
|
|
104177
104675
|
this._watched.delete(fullPath);
|
|
104178
104676
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
104179
|
-
if (wasTracked && !this._isIgnored(
|
|
104180
|
-
this._emit(eventName,
|
|
104181
|
-
this._closePath(
|
|
104677
|
+
if (wasTracked && !this._isIgnored(path6))
|
|
104678
|
+
this._emit(eventName, path6);
|
|
104679
|
+
this._closePath(path6);
|
|
104182
104680
|
}
|
|
104183
|
-
_closePath(
|
|
104184
|
-
this._closeFile(
|
|
104185
|
-
const dir = sp2.dirname(
|
|
104186
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
104681
|
+
_closePath(path6) {
|
|
104682
|
+
this._closeFile(path6);
|
|
104683
|
+
const dir = sp2.dirname(path6);
|
|
104684
|
+
this._getWatchedDir(dir).remove(sp2.basename(path6));
|
|
104187
104685
|
}
|
|
104188
|
-
_closeFile(
|
|
104189
|
-
const closers = this._closers.get(
|
|
104686
|
+
_closeFile(path6) {
|
|
104687
|
+
const closers = this._closers.get(path6);
|
|
104190
104688
|
if (!closers)
|
|
104191
104689
|
return;
|
|
104192
104690
|
closers.forEach((closer) => closer());
|
|
104193
|
-
this._closers.delete(
|
|
104691
|
+
this._closers.delete(path6);
|
|
104194
104692
|
}
|
|
104195
|
-
_addPathCloser(
|
|
104693
|
+
_addPathCloser(path6, closer) {
|
|
104196
104694
|
if (!closer)
|
|
104197
104695
|
return;
|
|
104198
|
-
let list = this._closers.get(
|
|
104696
|
+
let list = this._closers.get(path6);
|
|
104199
104697
|
if (!list) {
|
|
104200
104698
|
list = [];
|
|
104201
|
-
this._closers.set(
|
|
104699
|
+
this._closers.set(path6, list);
|
|
104202
104700
|
}
|
|
104203
104701
|
list.push(closer);
|
|
104204
104702
|
}
|
|
@@ -104223,7 +104721,7 @@ var init_chokidar = __esm(() => {
|
|
|
104223
104721
|
});
|
|
104224
104722
|
|
|
104225
104723
|
// src/infrastructure/services/workspace/workspace-fs-watcher.ts
|
|
104226
|
-
import
|
|
104724
|
+
import path6 from "node:path";
|
|
104227
104725
|
function isTooManyOpenFilesError(error51) {
|
|
104228
104726
|
if (!(error51 instanceof Error))
|
|
104229
104727
|
return false;
|
|
@@ -104231,10 +104729,10 @@ function isTooManyOpenFilesError(error51) {
|
|
|
104231
104729
|
return errno === "EMFILE" || errno === "ENOSPC" || error51.message.includes("EMFILE");
|
|
104232
104730
|
}
|
|
104233
104731
|
function toRelativePath(rootDir, absolutePath) {
|
|
104234
|
-
return
|
|
104732
|
+
return path6.relative(rootDir, absolutePath).replace(/\\/g, "/").replace(/^\.?\//, "");
|
|
104235
104733
|
}
|
|
104236
104734
|
function createWorkspaceFsWatcher(options) {
|
|
104237
|
-
const absWorkingDir =
|
|
104735
|
+
const absWorkingDir = path6.resolve(options.workingDir);
|
|
104238
104736
|
const debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
104239
104737
|
let stopped = false;
|
|
104240
104738
|
let debounceTimer = null;
|
|
@@ -104330,16 +104828,16 @@ function diffPathIndexes(previous, next4) {
|
|
|
104330
104828
|
const removed = [];
|
|
104331
104829
|
const typeChanged = [];
|
|
104332
104830
|
const prev = previous ?? {};
|
|
104333
|
-
for (const [
|
|
104334
|
-
if (!(
|
|
104335
|
-
added.push(
|
|
104336
|
-
} else if (prev[
|
|
104337
|
-
typeChanged.push(
|
|
104831
|
+
for (const [path7, type] of Object.entries(next4)) {
|
|
104832
|
+
if (!(path7 in prev)) {
|
|
104833
|
+
added.push(path7);
|
|
104834
|
+
} else if (prev[path7] !== type) {
|
|
104835
|
+
typeChanged.push(path7);
|
|
104338
104836
|
}
|
|
104339
104837
|
}
|
|
104340
|
-
for (const
|
|
104341
|
-
if (!(
|
|
104342
|
-
removed.push(
|
|
104838
|
+
for (const path7 of Object.keys(prev)) {
|
|
104839
|
+
if (!(path7 in next4)) {
|
|
104840
|
+
removed.push(path7);
|
|
104343
104841
|
}
|
|
104344
104842
|
}
|
|
104345
104843
|
added.sort();
|
|
@@ -104425,7 +104923,7 @@ function createManifestFromTree(args2) {
|
|
|
104425
104923
|
};
|
|
104426
104924
|
}
|
|
104427
104925
|
function entriesFromPathIndex(paths) {
|
|
104428
|
-
return Object.entries(paths).map(([
|
|
104926
|
+
return Object.entries(paths).map(([path7, type]) => ({ path: path7, type })).sort((a, b) => a.path.localeCompare(b.path));
|
|
104429
104927
|
}
|
|
104430
104928
|
var SYNC_STATE_VERSION = "2", SYNC_STATE_DIR;
|
|
104431
104929
|
var init_workspace_sync_state = __esm(() => {
|
|
@@ -104434,7 +104932,7 @@ var init_workspace_sync_state = __esm(() => {
|
|
|
104434
104932
|
|
|
104435
104933
|
// src/infrastructure/services/workspace/workspace-file-tree-coordinator.ts
|
|
104436
104934
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
104437
|
-
import
|
|
104935
|
+
import path7 from "node:path";
|
|
104438
104936
|
function deltaEntry(paths, pathValue) {
|
|
104439
104937
|
const type = paths[pathValue];
|
|
104440
104938
|
if (type === undefined)
|
|
@@ -104500,7 +104998,7 @@ async function addDirectorySubtree(rootDir, relativeDir, paths) {
|
|
|
104500
104998
|
return;
|
|
104501
104999
|
ensureParentDirectories(paths, relativeDir);
|
|
104502
105000
|
paths[relativeDir] = "directory";
|
|
104503
|
-
const subtree = await scanFileTree(
|
|
105001
|
+
const subtree = await scanFileTree(path7.join(rootDir, relativeDir));
|
|
104504
105002
|
for (const entry of subtree.entries) {
|
|
104505
105003
|
const prefixedPath = `${relativeDir}/${entry.path}`;
|
|
104506
105004
|
if (await isWorkspacePathIgnored(rootDir, prefixedPath))
|
|
@@ -108363,7 +108861,7 @@ async function discoverModelsForHarness(harness, service3) {
|
|
|
108363
108861
|
async function discoverModels(agentServices) {
|
|
108364
108862
|
return exports_Effect.runPromise(discoverModelsEffect(agentServices));
|
|
108365
108863
|
}
|
|
108366
|
-
function
|
|
108864
|
+
function createDefaultDeps18() {
|
|
108367
108865
|
return {
|
|
108368
108866
|
backend: {
|
|
108369
108867
|
mutation: async () => {
|
|
@@ -108698,7 +109196,7 @@ var init_init2 = __esm(() => {
|
|
|
108698
109196
|
convexUrl,
|
|
108699
109197
|
agentServices,
|
|
108700
109198
|
cachedModels,
|
|
108701
|
-
deps:
|
|
109199
|
+
deps: createDefaultDeps18()
|
|
108702
109200
|
});
|
|
108703
109201
|
yield* registerEventListenersEffect().pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
108704
109202
|
yield* logStartupEffect(cachedModels).pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
@@ -111576,6 +112074,7 @@ var init_command_loop = __esm(() => {
|
|
|
111576
112074
|
init_pid();
|
|
111577
112075
|
init_daemon_services();
|
|
111578
112076
|
init_start_subscriptions();
|
|
112077
|
+
init_start_subscriptions2();
|
|
111579
112078
|
init_file_content_subscription();
|
|
111580
112079
|
init_file_tree_subscription();
|
|
111581
112080
|
init_file_write_subscription();
|
|
@@ -111630,6 +112129,8 @@ var init_command_loop = __esm(() => {
|
|
|
111630
112129
|
let pendingPromptSubscriptionHandle = null;
|
|
111631
112130
|
let pendingHarnessSessionSubscriptionHandle = null;
|
|
111632
112131
|
let commandSubscriptionHandle = null;
|
|
112132
|
+
let aqPendingPromptSubscriptionHandle = null;
|
|
112133
|
+
let aqPendingHarnessSessionSubscriptionHandle = null;
|
|
111633
112134
|
let lifecycleManager = null;
|
|
111634
112135
|
let closeDirectHarnessSessionsOnShutdown = null;
|
|
111635
112136
|
const activeSessions = new Map;
|
|
@@ -111697,6 +112198,8 @@ var init_command_loop = __esm(() => {
|
|
|
111697
112198
|
pendingHarnessSessionSubscriptionHandle?.stop();
|
|
111698
112199
|
commandSubscriptionHandle?.stop();
|
|
111699
112200
|
lifecycleManager?.stopMonitoring();
|
|
112201
|
+
aqPendingPromptSubscriptionHandle?.stop();
|
|
112202
|
+
aqPendingHarnessSessionSubscriptionHandle?.stop();
|
|
111700
112203
|
};
|
|
111701
112204
|
const runDaemonShutdownEffect = async () => {
|
|
111702
112205
|
await withTimeout2(exports_Effect.runPromise(onDaemonShutdownEffect.pipe(exports_Effect.provide(effectContext2))), PROCESS_KILL_TIMEOUT_MS);
|
|
@@ -111750,6 +112253,14 @@ var init_command_loop = __esm(() => {
|
|
|
111750
112253
|
commandSubscriptionHandle = handles.commandSubscriptionHandle;
|
|
111751
112254
|
lifecycleManager = handles.lifecycleManager;
|
|
111752
112255
|
closeDirectHarnessSessionsOnShutdown = handles.closeSessionsOnShutdown;
|
|
112256
|
+
const aqHandles = startAgenticQuerySubscriptions({
|
|
112257
|
+
sessionId: session2.sessionId,
|
|
112258
|
+
machineId: session2.machineId,
|
|
112259
|
+
backend: session2.backend,
|
|
112260
|
+
convexUrl: session2.convexUrl
|
|
112261
|
+
}, wsClient2, activeSessions, harnesses);
|
|
112262
|
+
aqPendingPromptSubscriptionHandle = aqHandles.pendingPromptSubscriptionHandle;
|
|
112263
|
+
aqPendingHarnessSessionSubscriptionHandle = aqHandles.pendingHarnessSessionSubscriptionHandle;
|
|
111753
112264
|
}
|
|
111754
112265
|
console.log(`
|
|
111755
112266
|
Listening for commands...`);
|
|
@@ -111934,7 +112445,7 @@ __export(exports_opencode_install, {
|
|
|
111934
112445
|
installTool: () => installTool
|
|
111935
112446
|
});
|
|
111936
112447
|
import * as os2 from "os";
|
|
111937
|
-
import * as
|
|
112448
|
+
import * as path8 from "path";
|
|
111938
112449
|
async function isChatroomInstalledDefault() {
|
|
111939
112450
|
try {
|
|
111940
112451
|
const { execSync: execSync3 } = await import("child_process");
|
|
@@ -111944,7 +112455,7 @@ async function isChatroomInstalledDefault() {
|
|
|
111944
112455
|
return false;
|
|
111945
112456
|
}
|
|
111946
112457
|
}
|
|
111947
|
-
async function
|
|
112458
|
+
async function createDefaultDeps19() {
|
|
111948
112459
|
const client4 = await getConvexClient();
|
|
111949
112460
|
const fs12 = await import("fs/promises");
|
|
111950
112461
|
return {
|
|
@@ -112019,7 +112530,7 @@ After installation, run this command again.`;
|
|
|
112019
112530
|
});
|
|
112020
112531
|
}
|
|
112021
112532
|
async function installTool(options = {}, deps) {
|
|
112022
|
-
const d = deps ?? await
|
|
112533
|
+
const d = deps ?? await createDefaultDeps19();
|
|
112023
112534
|
const layer = layerFromDeps9(d);
|
|
112024
112535
|
return exports_Effect.runPromise(installToolEffect(options).pipe(exports_Effect.catchAll((err) => handleInstallError(err)), exports_Effect.provide(layer)));
|
|
112025
112536
|
}
|
|
@@ -112304,9 +112815,9 @@ After logging in, try this command again.\`;
|
|
|
112304
112815
|
const fsService = yield* OpenCodeInstallFsService;
|
|
112305
112816
|
const { checkExisting = true } = options;
|
|
112306
112817
|
const homeDir = os2.homedir();
|
|
112307
|
-
const toolDir =
|
|
112308
|
-
const toolPath =
|
|
112309
|
-
const handoffToolPath =
|
|
112818
|
+
const toolDir = path8.join(homeDir, ".config", "opencode", "tool");
|
|
112819
|
+
const toolPath = path8.join(toolDir, "chatroom.ts");
|
|
112820
|
+
const handoffToolPath = path8.join(toolDir, "chatroom-handoff.ts");
|
|
112310
112821
|
if (checkExisting) {
|
|
112311
112822
|
const existingFiles = [];
|
|
112312
112823
|
const toolExists = yield* fsService.access(toolPath);
|
|
@@ -112577,6 +113088,33 @@ handoffCommandGroup.requiredOption("--chatroom-id <id>", "Chatroom identifier").
|
|
|
112577
113088
|
nextRole: options.nextRole
|
|
112578
113089
|
});
|
|
112579
113090
|
});
|
|
113091
|
+
var agenticQueryCommand = program2.command("agentic-query").description("Agentic search/ask query commands");
|
|
113092
|
+
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) => {
|
|
113093
|
+
await maybeRequireAuth();
|
|
113094
|
+
const { decode: decode5 } = await Promise.resolve().then(() => exports_decode);
|
|
113095
|
+
const stdinContent = await readStdin();
|
|
113096
|
+
let result;
|
|
113097
|
+
try {
|
|
113098
|
+
const { AGENTIC_QUERY_STDIN_DELIMITER: AGENTIC_QUERY_STDIN_DELIMITER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
|
|
113099
|
+
const decoded = decode5(stdinContent, { singleParam: "result" });
|
|
113100
|
+
let body = decoded.result;
|
|
113101
|
+
body = body.replace(/^(---RESULT---\s*)+/i, "").trim();
|
|
113102
|
+
validateStdinHeredocBody2(body, AGENTIC_QUERY_STDIN_DELIMITER2);
|
|
113103
|
+
result = body;
|
|
113104
|
+
} catch (err) {
|
|
113105
|
+
console.error(`❌ Failed to decode stdin: ${err.message}`);
|
|
113106
|
+
process.exit(1);
|
|
113107
|
+
}
|
|
113108
|
+
if (!result?.trim()) {
|
|
113109
|
+
console.error("❌ Result body is empty");
|
|
113110
|
+
process.exit(1);
|
|
113111
|
+
}
|
|
113112
|
+
const { agenticQueryComplete: agenticQueryComplete2 } = await Promise.resolve().then(() => (init_complete(), exports_complete));
|
|
113113
|
+
await agenticQueryComplete2(options.chatroomId, {
|
|
113114
|
+
queryId: options.queryId,
|
|
113115
|
+
result
|
|
113116
|
+
});
|
|
113117
|
+
});
|
|
112580
113118
|
var backlogCommand = program2.command("backlog").description("Manage task queue and backlog");
|
|
112581
113119
|
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) => {
|
|
112582
113120
|
await maybeRequireAuth();
|
|
@@ -112861,4 +113399,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
112861
113399
|
});
|
|
112862
113400
|
program2.parse();
|
|
112863
113401
|
|
|
112864
|
-
//# debugId=
|
|
113402
|
+
//# debugId=766A192ADD34FFEC64756E2164756E21
|