chatroom-cli 1.101.1 → 1.101.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -30743,6 +30743,9 @@ var init_codex_sdk_stream_adapter = __esm(() => {
|
|
|
30743
30743
|
|
|
30744
30744
|
// src/daemon/infrastructure/local/harness/services/codex-sdk/codex-sdk-agent-service.ts
|
|
30745
30745
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
30746
|
+
function isAbortError(error) {
|
|
30747
|
+
return error instanceof Error && error.name === "AbortError";
|
|
30748
|
+
}
|
|
30746
30749
|
async function loadSdk2() {
|
|
30747
30750
|
if (_sdkCache2)
|
|
30748
30751
|
return _sdkCache2;
|
|
@@ -31087,7 +31090,7 @@ var init_codex_sdk_agent_service = __esm(() => {
|
|
|
31087
31090
|
const deferredResume = await waitForResumeOrAbort2(session2);
|
|
31088
31091
|
if (deferredResume === null || session2.aborted) {
|
|
31089
31092
|
if (session2.aborted) {
|
|
31090
|
-
exitCode =
|
|
31093
|
+
exitCode = 0;
|
|
31091
31094
|
exitSignal = "SIGTERM";
|
|
31092
31095
|
}
|
|
31093
31096
|
break;
|
|
@@ -31112,12 +31115,14 @@ ${deferredResume}` : deferredResume;
|
|
|
31112
31115
|
});
|
|
31113
31116
|
nextPrompt = null;
|
|
31114
31117
|
} catch (turnErr) {
|
|
31118
|
+
if (session2.aborted && isAbortError(turnErr))
|
|
31119
|
+
break;
|
|
31115
31120
|
exitCode = 1;
|
|
31116
31121
|
writeSpawnError2(logPrefix, turnErr, emitLogLine);
|
|
31117
31122
|
break;
|
|
31118
31123
|
}
|
|
31119
31124
|
if (session2.aborted) {
|
|
31120
|
-
exitCode =
|
|
31125
|
+
exitCode = 0;
|
|
31121
31126
|
exitSignal = "SIGTERM";
|
|
31122
31127
|
break;
|
|
31123
31128
|
}
|
|
@@ -31182,10 +31187,13 @@ ${deferredResume}` : deferredResume;
|
|
|
31182
31187
|
}
|
|
31183
31188
|
}
|
|
31184
31189
|
})(), TURN_TIMEOUT_MS2, "thread.runStreamed");
|
|
31190
|
+
} catch (err) {
|
|
31191
|
+
if (!(session2.aborted && isAbortError(err)))
|
|
31192
|
+
throw err;
|
|
31185
31193
|
} finally {
|
|
31186
31194
|
session2.abortController = undefined;
|
|
31195
|
+
adapter.finish();
|
|
31187
31196
|
}
|
|
31188
|
-
adapter.finish();
|
|
31189
31197
|
}
|
|
31190
31198
|
async spawn(options) {
|
|
31191
31199
|
const variant = decodeCodexVariant(options.model);
|
|
@@ -81031,83 +81039,6 @@ var init_complete = __esm(() => {
|
|
|
81031
81039
|
init_error_formatting();
|
|
81032
81040
|
});
|
|
81033
81041
|
|
|
81034
|
-
// src/commands/enhancer/complete.ts
|
|
81035
|
-
var exports_complete2 = {};
|
|
81036
|
-
__export(exports_complete2, {
|
|
81037
|
-
enhancerComplete: () => enhancerComplete
|
|
81038
|
-
});
|
|
81039
|
-
async function createDefaultDeps12() {
|
|
81040
|
-
const client4 = await getConvexClient();
|
|
81041
|
-
return {
|
|
81042
|
-
backend: {
|
|
81043
|
-
mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
|
|
81044
|
-
query: (endpoint, args2) => client4.query(endpoint, args2)
|
|
81045
|
-
},
|
|
81046
|
-
session: {
|
|
81047
|
-
getSessionId,
|
|
81048
|
-
getConvexUrl,
|
|
81049
|
-
getOtherSessionUrls
|
|
81050
|
-
}
|
|
81051
|
-
};
|
|
81052
|
-
}
|
|
81053
|
-
function handleCompleteError2(err) {
|
|
81054
|
-
return exports_Effect.sync(() => {
|
|
81055
|
-
if (err._tag === "NotAuthenticated") {
|
|
81056
|
-
formatAuthError(err.convexUrl, err.otherUrls);
|
|
81057
|
-
process.exit(1);
|
|
81058
|
-
}
|
|
81059
|
-
if (err._tag === "InvalidChatroomId") {
|
|
81060
|
-
formatChatroomIdError(err.id);
|
|
81061
|
-
process.exit(1);
|
|
81062
|
-
}
|
|
81063
|
-
console.error(`
|
|
81064
|
-
❌ ERROR: Enhancer complete failed`);
|
|
81065
|
-
console.error(`
|
|
81066
|
-
${err.errorData?.message ?? err.cause.message}`);
|
|
81067
|
-
process.exit(1);
|
|
81068
|
-
});
|
|
81069
|
-
}
|
|
81070
|
-
async function enhancerComplete(chatroomId, options) {
|
|
81071
|
-
const deps = await createDefaultDeps12();
|
|
81072
|
-
await exports_Effect.runPromise(enhancerCompleteEffect(chatroomId, options).pipe(exports_Effect.provide(commandServicesLayerFromDeps(deps)), exports_Effect.catchAll(handleCompleteError2)));
|
|
81073
|
-
}
|
|
81074
|
-
var enhancerCompleteEffect = (chatroomId, options) => exports_Effect.gen(function* () {
|
|
81075
|
-
const backend2 = yield* BackendService;
|
|
81076
|
-
const sessionId = yield* requireSessionIdEffect((a) => ({
|
|
81077
|
-
_tag: "NotAuthenticated",
|
|
81078
|
-
convexUrl: a.convexUrl,
|
|
81079
|
-
otherUrls: a.otherUrls
|
|
81080
|
-
}));
|
|
81081
|
-
yield* validateChatroomIdEffect(chatroomId, (id3) => ({
|
|
81082
|
-
_tag: "InvalidChatroomId",
|
|
81083
|
-
id: id3
|
|
81084
|
-
}));
|
|
81085
|
-
yield* backend2.mutation(api.web.enhancer.index.complete, {
|
|
81086
|
-
sessionId,
|
|
81087
|
-
chatroomId,
|
|
81088
|
-
jobId: options.jobId,
|
|
81089
|
-
enhancedContent: options.enhancedContent
|
|
81090
|
-
}).pipe(exports_Effect.mapError((cause3) => {
|
|
81091
|
-
let errorData;
|
|
81092
|
-
if (cause3 instanceof ConvexError) {
|
|
81093
|
-
errorData = cause3.data;
|
|
81094
|
-
}
|
|
81095
|
-
return { _tag: "CompleteFailed", cause: cause3, errorData };
|
|
81096
|
-
}));
|
|
81097
|
-
yield* exports_Effect.sync(() => {
|
|
81098
|
-
console.log(`✅ Enhancer job ${options.jobId} completed`);
|
|
81099
|
-
});
|
|
81100
|
-
});
|
|
81101
|
-
var init_complete2 = __esm(() => {
|
|
81102
|
-
init_values();
|
|
81103
|
-
init_esm();
|
|
81104
|
-
init_api3();
|
|
81105
|
-
init_storage();
|
|
81106
|
-
init_client2();
|
|
81107
|
-
init_services();
|
|
81108
|
-
init_error_formatting();
|
|
81109
|
-
});
|
|
81110
|
-
|
|
81111
81042
|
// src/commands/backlog/backlog-fs-service.ts
|
|
81112
81043
|
import * as nodeFs from "node:fs/promises";
|
|
81113
81044
|
var BacklogFsService, BacklogFsServiceLive, BacklogFsServiceFrom = (ops) => exports_Layer.succeed(BacklogFsService, {
|
|
@@ -81216,7 +81147,7 @@ function buildBaseLayer(d) {
|
|
|
81216
81147
|
function buildFsLayer(fs11) {
|
|
81217
81148
|
return fs11 ? BacklogFsServiceFrom(fs11) : BacklogFsServiceLive;
|
|
81218
81149
|
}
|
|
81219
|
-
async function
|
|
81150
|
+
async function createDefaultDeps12() {
|
|
81220
81151
|
const client4 = await getConvexClient();
|
|
81221
81152
|
const fs11 = await import("node:fs/promises");
|
|
81222
81153
|
return {
|
|
@@ -81272,51 +81203,51 @@ function computeContentHash(content) {
|
|
|
81272
81203
|
return createHash("sha256").update(content).digest("hex");
|
|
81273
81204
|
}
|
|
81274
81205
|
async function listBacklog(chatroomId, options, deps) {
|
|
81275
|
-
const d = deps ?? await
|
|
81206
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81276
81207
|
await exports_Effect.runPromise(listBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81277
81208
|
}
|
|
81278
81209
|
async function addBacklog(chatroomId, options, deps) {
|
|
81279
|
-
const d = deps ?? await
|
|
81210
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81280
81211
|
await exports_Effect.runPromise(addBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81281
81212
|
}
|
|
81282
81213
|
async function completeBacklog(chatroomId, options, deps) {
|
|
81283
|
-
const d = deps ?? await
|
|
81214
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81284
81215
|
await exports_Effect.runPromise(completeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81285
81216
|
}
|
|
81286
81217
|
async function reopenBacklog(chatroomId, options, deps) {
|
|
81287
|
-
const d = deps ?? await
|
|
81218
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81288
81219
|
await exports_Effect.runPromise(reopenBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81289
81220
|
}
|
|
81290
81221
|
async function patchBacklog(chatroomId, options, deps) {
|
|
81291
|
-
const d = deps ?? await
|
|
81222
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81292
81223
|
await exports_Effect.runPromise(patchBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81293
81224
|
}
|
|
81294
81225
|
async function scoreBacklog(chatroomId, options, deps) {
|
|
81295
|
-
const d = deps ?? await
|
|
81226
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81296
81227
|
await exports_Effect.runPromise(scoreBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81297
81228
|
}
|
|
81298
81229
|
async function markForReviewBacklog(chatroomId, options, deps) {
|
|
81299
|
-
const d = deps ?? await
|
|
81230
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81300
81231
|
await exports_Effect.runPromise(markForReviewBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81301
81232
|
}
|
|
81302
81233
|
async function historyBacklog(chatroomId, options, deps) {
|
|
81303
|
-
const d = deps ?? await
|
|
81234
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81304
81235
|
await exports_Effect.runPromise(historyBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81305
81236
|
}
|
|
81306
81237
|
async function updateBacklog(chatroomId, options, deps) {
|
|
81307
|
-
const d = deps ?? await
|
|
81238
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81308
81239
|
await exports_Effect.runPromise(updateBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81309
81240
|
}
|
|
81310
81241
|
async function closeBacklog(chatroomId, options, deps) {
|
|
81311
|
-
const d = deps ?? await
|
|
81242
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81312
81243
|
await exports_Effect.runPromise(closeBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81313
81244
|
}
|
|
81314
81245
|
async function deleteBacklog(chatroomId, options, deps) {
|
|
81315
|
-
const d = deps ?? await
|
|
81246
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81316
81247
|
await exports_Effect.runPromise(deleteBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(buildBaseLayer(d))));
|
|
81317
81248
|
}
|
|
81318
81249
|
async function exportBacklog(chatroomId, options, deps) {
|
|
81319
|
-
const d = deps ?? await
|
|
81250
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81320
81251
|
if (!d.fs) {
|
|
81321
81252
|
console.error("❌ File system operations not available");
|
|
81322
81253
|
process.exit(1);
|
|
@@ -81325,7 +81256,7 @@ async function exportBacklog(chatroomId, options, deps) {
|
|
|
81325
81256
|
await exports_Effect.runPromise(exportBacklogEffect(chatroomId, options).pipe(exports_Effect.catchAll(handleBacklogError), exports_Effect.provide(exports_Layer.merge(buildBaseLayer(d), buildFsLayer(d.fs)))));
|
|
81326
81257
|
}
|
|
81327
81258
|
async function importBacklog(chatroomId, options, deps) {
|
|
81328
|
-
const d = deps ?? await
|
|
81259
|
+
const d = deps ?? await createDefaultDeps12();
|
|
81329
81260
|
if (!d.fs) {
|
|
81330
81261
|
console.error("❌ File system operations not available");
|
|
81331
81262
|
process.exit(1);
|
|
@@ -82112,7 +82043,7 @@ __export(exports_read, {
|
|
|
82112
82043
|
taskReadEffect: () => taskReadEffect,
|
|
82113
82044
|
taskRead: () => taskRead
|
|
82114
82045
|
});
|
|
82115
|
-
async function
|
|
82046
|
+
async function createDefaultDeps13() {
|
|
82116
82047
|
const client4 = await getConvexClient();
|
|
82117
82048
|
return {
|
|
82118
82049
|
backend: {
|
|
@@ -82154,7 +82085,7 @@ function handleTaskReadError(err) {
|
|
|
82154
82085
|
});
|
|
82155
82086
|
}
|
|
82156
82087
|
async function taskRead(chatroomId, options, deps) {
|
|
82157
|
-
const d = deps ?? await
|
|
82088
|
+
const d = deps ?? await createDefaultDeps13();
|
|
82158
82089
|
const layer = commandServicesLayerFromDeps(d);
|
|
82159
82090
|
await exports_Effect.runPromise(taskReadEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleTaskReadError(err)), exports_Effect.provide(layer)));
|
|
82160
82091
|
}
|
|
@@ -82245,7 +82176,7 @@ __export(exports_skill, {
|
|
|
82245
82176
|
activateSkillEffect: () => activateSkillEffect,
|
|
82246
82177
|
activateSkill: () => activateSkill
|
|
82247
82178
|
});
|
|
82248
|
-
async function
|
|
82179
|
+
async function createDefaultDeps14() {
|
|
82249
82180
|
return createConvexCommandDeps();
|
|
82250
82181
|
}
|
|
82251
82182
|
function handleListSkillsError(err) {
|
|
@@ -82303,12 +82234,12 @@ function handleActivateSkillError(err) {
|
|
|
82303
82234
|
});
|
|
82304
82235
|
}
|
|
82305
82236
|
async function listSkills(chatroomId, options, deps) {
|
|
82306
|
-
const d = deps ?? await
|
|
82237
|
+
const d = deps ?? await createDefaultDeps14();
|
|
82307
82238
|
const layer = commandServicesLayerFromDeps(d);
|
|
82308
82239
|
await exports_Effect.runPromise(listSkillsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleListSkillsError(err)), exports_Effect.provide(layer)));
|
|
82309
82240
|
}
|
|
82310
82241
|
async function activateSkill(chatroomId, skillId, options, deps) {
|
|
82311
|
-
const d = deps ?? await
|
|
82242
|
+
const d = deps ?? await createDefaultDeps14();
|
|
82312
82243
|
const layer = commandServicesLayerFromDeps(d);
|
|
82313
82244
|
await exports_Effect.runPromise(activateSkillEffect(chatroomId, skillId, options).pipe(exports_Effect.catchAll((err) => handleActivateSkillError(err)), exports_Effect.provide(layer)));
|
|
82314
82245
|
}
|
|
@@ -82383,7 +82314,7 @@ function normalizeWorkingDirForLookup(workingDir) {
|
|
|
82383
82314
|
}
|
|
82384
82315
|
|
|
82385
82316
|
// src/commands/workspace/file-tree.ts
|
|
82386
|
-
async function
|
|
82317
|
+
async function createDefaultDeps15() {
|
|
82387
82318
|
const client4 = await getConvexClient();
|
|
82388
82319
|
return {
|
|
82389
82320
|
backend: {
|
|
@@ -82400,7 +82331,7 @@ async function requireSession3(deps) {
|
|
|
82400
82331
|
return sessionId;
|
|
82401
82332
|
}
|
|
82402
82333
|
async function requestWorkspaceFileTreeFromCli(machineId, workingDir, options, deps) {
|
|
82403
|
-
const d = deps ?? await
|
|
82334
|
+
const d = deps ?? await createDefaultDeps15();
|
|
82404
82335
|
const sessionId = await requireSession3(d);
|
|
82405
82336
|
const result = await d.backend.mutation(api.workspaceFiles.requestFileTree, {
|
|
82406
82337
|
sessionId,
|
|
@@ -82411,7 +82342,7 @@ async function requestWorkspaceFileTreeFromCli(machineId, workingDir, options, d
|
|
|
82411
82342
|
return result;
|
|
82412
82343
|
}
|
|
82413
82344
|
async function getWorkspaceFileTreeStatusFromCli(machineId, workingDir, deps) {
|
|
82414
|
-
const d = deps ?? await
|
|
82345
|
+
const d = deps ?? await createDefaultDeps15();
|
|
82415
82346
|
const sessionId = await requireSession3(d);
|
|
82416
82347
|
const [checkpoint, manifest, pendingRequests] = await Promise.all([
|
|
82417
82348
|
d.backend.query(api.workspaceFiles.getFileTreeCheckpoint, {
|
|
@@ -82454,7 +82385,7 @@ var exports_send = {};
|
|
|
82454
82385
|
__export(exports_send, {
|
|
82455
82386
|
sendUserMessage: () => sendUserMessage
|
|
82456
82387
|
});
|
|
82457
|
-
async function
|
|
82388
|
+
async function createDefaultDeps16() {
|
|
82458
82389
|
const client4 = await getConvexClient();
|
|
82459
82390
|
return {
|
|
82460
82391
|
backend: {
|
|
@@ -82473,7 +82404,7 @@ async function requireSession4(deps) {
|
|
|
82473
82404
|
async function sendUserMessage(chatroomId, options, deps) {
|
|
82474
82405
|
if (!options.content.trim())
|
|
82475
82406
|
throw new Error("Message content cannot be empty");
|
|
82476
|
-
const d = deps ?? await
|
|
82407
|
+
const d = deps ?? await createDefaultDeps16();
|
|
82477
82408
|
const sessionId = await requireSession4(d);
|
|
82478
82409
|
const chatroom = await d.backend.query(api.chatrooms.get, {
|
|
82479
82410
|
sessionId,
|
|
@@ -82974,7 +82905,7 @@ __export(exports_messages, {
|
|
|
82974
82905
|
anchorMessagesEffect: () => anchorMessagesEffect,
|
|
82975
82906
|
anchorMessages: () => anchorMessages
|
|
82976
82907
|
});
|
|
82977
|
-
async function
|
|
82908
|
+
async function createDefaultDeps17() {
|
|
82978
82909
|
const client4 = await getConvexClient();
|
|
82979
82910
|
return {
|
|
82980
82911
|
backend: {
|
|
@@ -83034,12 +82965,12 @@ function handleMessagesError(err) {
|
|
|
83034
82965
|
});
|
|
83035
82966
|
}
|
|
83036
82967
|
async function listBySenderRole(chatroomId, options, deps) {
|
|
83037
|
-
const d = deps ?? await
|
|
82968
|
+
const d = deps ?? await createDefaultDeps17();
|
|
83038
82969
|
const layer = commandServicesLayerFromDeps(d);
|
|
83039
82970
|
await exports_Effect.runPromise(listBySenderRoleEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
83040
82971
|
}
|
|
83041
82972
|
async function listSinceMessage(chatroomId, options, deps) {
|
|
83042
|
-
const d = deps ?? await
|
|
82973
|
+
const d = deps ?? await createDefaultDeps17();
|
|
83043
82974
|
const layer = commandServicesLayerFromDeps(d);
|
|
83044
82975
|
await exports_Effect.runPromise(listSinceMessageEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleMessagesError(err)), exports_Effect.provide(layer)));
|
|
83045
82976
|
}
|
|
@@ -83165,7 +83096,7 @@ __export(exports_context2, {
|
|
|
83165
83096
|
inspectContextEffect: () => inspectContextEffect,
|
|
83166
83097
|
inspectContext: () => inspectContext
|
|
83167
83098
|
});
|
|
83168
|
-
async function
|
|
83099
|
+
async function createDefaultDeps18() {
|
|
83169
83100
|
return createConvexCommandDeps();
|
|
83170
83101
|
}
|
|
83171
83102
|
function requireAuthenticatedChatroom(chatroomId) {
|
|
@@ -83207,17 +83138,17 @@ function handleContextError(err) {
|
|
|
83207
83138
|
});
|
|
83208
83139
|
}
|
|
83209
83140
|
async function readContext(chatroomId, options, deps) {
|
|
83210
|
-
const d = deps ?? await
|
|
83141
|
+
const d = deps ?? await createDefaultDeps18();
|
|
83211
83142
|
const layer = commandServicesLayerFromDeps(d);
|
|
83212
83143
|
await exports_Effect.runPromise(readContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
83213
83144
|
}
|
|
83214
83145
|
async function newContext(chatroomId, options, deps) {
|
|
83215
|
-
const d = deps ?? await
|
|
83146
|
+
const d = deps ?? await createDefaultDeps18();
|
|
83216
83147
|
const layer = commandServicesLayerFromDeps(d);
|
|
83217
83148
|
await exports_Effect.runPromise(newContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
83218
83149
|
}
|
|
83219
83150
|
async function listContexts(chatroomId, options, deps) {
|
|
83220
|
-
const d = deps ?? await
|
|
83151
|
+
const d = deps ?? await createDefaultDeps18();
|
|
83221
83152
|
const layer = commandServicesLayerFromDeps(d);
|
|
83222
83153
|
await exports_Effect.runPromise(listContextsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
83223
83154
|
}
|
|
@@ -83225,7 +83156,7 @@ function viewTemplate() {
|
|
|
83225
83156
|
return getContextViewTemplate();
|
|
83226
83157
|
}
|
|
83227
83158
|
async function inspectContext(chatroomId, options, deps) {
|
|
83228
|
-
const d = deps ?? await
|
|
83159
|
+
const d = deps ?? await createDefaultDeps18();
|
|
83229
83160
|
const layer = commandServicesLayerFromDeps(d);
|
|
83230
83161
|
await exports_Effect.runPromise(inspectContextEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleContextError(err)), exports_Effect.provide(layer)));
|
|
83231
83162
|
}
|
|
@@ -83418,7 +83349,7 @@ __export(exports_guidelines, {
|
|
|
83418
83349
|
listGuidelineTypesEffect: () => listGuidelineTypesEffect,
|
|
83419
83350
|
listGuidelineTypes: () => listGuidelineTypes
|
|
83420
83351
|
});
|
|
83421
|
-
async function
|
|
83352
|
+
async function createDefaultDeps19() {
|
|
83422
83353
|
const client4 = await getConvexClient();
|
|
83423
83354
|
return {
|
|
83424
83355
|
backend: {
|
|
@@ -83459,12 +83390,12 @@ function handleListGuidelineTypesError(err) {
|
|
|
83459
83390
|
});
|
|
83460
83391
|
}
|
|
83461
83392
|
async function viewGuidelines(options, deps) {
|
|
83462
|
-
const d = deps ?? await
|
|
83393
|
+
const d = deps ?? await createDefaultDeps19();
|
|
83463
83394
|
const layer = layerFromDeps7(d);
|
|
83464
83395
|
await exports_Effect.runPromise(viewGuidelinesEffect(options).pipe(exports_Effect.catchAll((err) => handleViewGuidelinesError(err)), exports_Effect.provide(layer)));
|
|
83465
83396
|
}
|
|
83466
83397
|
async function listGuidelineTypes(deps) {
|
|
83467
|
-
const d = deps ?? await
|
|
83398
|
+
const d = deps ?? await createDefaultDeps19();
|
|
83468
83399
|
const layer = layerFromDeps7(d);
|
|
83469
83400
|
await exports_Effect.runPromise(listGuidelineTypesEffect().pipe(exports_Effect.catchAll((err) => handleListGuidelineTypesError(err)), exports_Effect.provide(layer)));
|
|
83470
83401
|
}
|
|
@@ -83534,7 +83465,7 @@ __export(exports_artifact, {
|
|
|
83534
83465
|
createArtifactEffect: () => createArtifactEffect,
|
|
83535
83466
|
createArtifact: () => createArtifact
|
|
83536
83467
|
});
|
|
83537
|
-
async function
|
|
83468
|
+
async function createDefaultDeps20() {
|
|
83538
83469
|
return createConvexCommandDeps();
|
|
83539
83470
|
}
|
|
83540
83471
|
function handleArtifactError(err) {
|
|
@@ -83545,19 +83476,19 @@ function handleArtifactError(err) {
|
|
|
83545
83476
|
});
|
|
83546
83477
|
}
|
|
83547
83478
|
async function createArtifact(chatroomId, options, deps) {
|
|
83548
|
-
const d = deps ?? await
|
|
83479
|
+
const d = deps ?? await createDefaultDeps20();
|
|
83549
83480
|
const layer = commandServicesLayerFromDeps(d);
|
|
83550
83481
|
return exports_Effect.runPromise(createArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err).pipe(exports_Effect.map(() => {
|
|
83551
83482
|
return;
|
|
83552
83483
|
}))), exports_Effect.provide(layer)));
|
|
83553
83484
|
}
|
|
83554
83485
|
async function viewArtifact(chatroomId, options, deps) {
|
|
83555
|
-
const d = deps ?? await
|
|
83486
|
+
const d = deps ?? await createDefaultDeps20();
|
|
83556
83487
|
const layer = commandServicesLayerFromDeps(d);
|
|
83557
83488
|
await exports_Effect.runPromise(viewArtifactEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
83558
83489
|
}
|
|
83559
83490
|
async function viewManyArtifacts(chatroomId, options, deps) {
|
|
83560
|
-
const d = deps ?? await
|
|
83491
|
+
const d = deps ?? await createDefaultDeps20();
|
|
83561
83492
|
const layer = commandServicesLayerFromDeps(d);
|
|
83562
83493
|
await exports_Effect.runPromise(viewManyArtifactsEffect(chatroomId, options).pipe(exports_Effect.catchAll((err) => handleArtifactError(err)), exports_Effect.provide(layer)));
|
|
83563
83494
|
}
|
|
@@ -83906,7 +83837,7 @@ __export(exports_telegram, {
|
|
|
83906
83837
|
sendMessageEffect: () => sendMessageEffect,
|
|
83907
83838
|
sendMessage: () => sendMessage
|
|
83908
83839
|
});
|
|
83909
|
-
async function
|
|
83840
|
+
async function createDefaultDeps21() {
|
|
83910
83841
|
const client4 = await getConvexClient();
|
|
83911
83842
|
return {
|
|
83912
83843
|
backend: {
|
|
@@ -83988,7 +83919,7 @@ ${err.cause.message}`);
|
|
|
83988
83919
|
});
|
|
83989
83920
|
}
|
|
83990
83921
|
async function sendMessage(options, deps) {
|
|
83991
|
-
const d = deps ?? await
|
|
83922
|
+
const d = deps ?? await createDefaultDeps21();
|
|
83992
83923
|
const layer = layerFromDeps8(d);
|
|
83993
83924
|
await exports_Effect.runPromise(sendMessageEffect(options).pipe(exports_Effect.catchAll((err) => handleSendMessageError(err)), exports_Effect.provide(layer)));
|
|
83994
83925
|
}
|
|
@@ -84269,11 +84200,23 @@ function normalizeAgentLifecycleFact(raw) {
|
|
|
84269
84200
|
emittedAt: Number(rest.emittedAt)
|
|
84270
84201
|
};
|
|
84271
84202
|
}
|
|
84272
|
-
if (kind === "spawned" || kind === "exited") {
|
|
84203
|
+
if (kind === "spawned" || kind === "exited" || kind === "activity") {
|
|
84273
84204
|
return rest;
|
|
84274
84205
|
}
|
|
84275
84206
|
throw new Error(`Unknown agent lifecycle fact kind: ${String(kind)}`);
|
|
84276
84207
|
}
|
|
84208
|
+
function buildActivityLifecycleFact(params) {
|
|
84209
|
+
const emittedAt = params.emittedAt ?? Date.now();
|
|
84210
|
+
return {
|
|
84211
|
+
kind: "activity",
|
|
84212
|
+
chatroomId: params.chatroomId,
|
|
84213
|
+
role: params.role,
|
|
84214
|
+
action: params.action,
|
|
84215
|
+
...params.taskId ? { taskId: params.taskId } : {},
|
|
84216
|
+
revisionKey: buildAgentLifecycleRevisionKey("activity", { ...params, emittedAt }),
|
|
84217
|
+
emittedAt
|
|
84218
|
+
};
|
|
84219
|
+
}
|
|
84277
84220
|
function agentLifecycleDeliveryKey(machineId, fact) {
|
|
84278
84221
|
if (fact.kind === "cleared_all_pids")
|
|
84279
84222
|
return `${machineId}:__machine__`;
|
|
@@ -84320,7 +84263,8 @@ function toConvexLifecycleFact(fact) {
|
|
|
84320
84263
|
return normalized;
|
|
84321
84264
|
return {
|
|
84322
84265
|
...normalized,
|
|
84323
|
-
chatroomId: normalized.chatroomId
|
|
84266
|
+
chatroomId: normalized.chatroomId,
|
|
84267
|
+
...normalized.kind === "activity" && normalized.taskId ? { taskId: normalized.taskId } : {}
|
|
84324
84268
|
};
|
|
84325
84269
|
}
|
|
84326
84270
|
function createAgentLifecycleSend(session2) {
|
|
@@ -84581,14 +84525,11 @@ var init_stop_agent_confirmed_adapter = __esm(() => {
|
|
|
84581
84525
|
});
|
|
84582
84526
|
|
|
84583
84527
|
// ../../services/backend/config/reliability.ts
|
|
84584
|
-
var HARNESS_SESSION_READY_TIMEOUT_MS = 5000, DAEMON_HEARTBEAT_INTERVAL_MS, DAEMON_HEARTBEAT_TTL_MS, AGENT_REQUEST_DEADLINE_MS = 120000, MACHINE_COMMAND_LEASE_RENEWAL_INTERVAL_MS = 20000, MACHINE_COMMAND_DAEMON_ROUTINE_TTL_MS,
|
|
84528
|
+
var HARNESS_SESSION_READY_TIMEOUT_MS = 5000, DAEMON_HEARTBEAT_INTERVAL_MS, DAEMON_HEARTBEAT_TTL_MS, AGENT_REQUEST_DEADLINE_MS = 120000, MACHINE_COMMAND_LEASE_RENEWAL_INTERVAL_MS = 20000, MACHINE_COMMAND_DAEMON_ROUTINE_TTL_MS, OBSERVATION_TTL_MS = 60000, OBSERVED_SAFETY_POLL_MS = 30000, WORKSPACE_LIST_RECONCILE_MS, AGENT_STOP_TERMINAL_RETENTION_MS, SCOPE_TARGET_STOP_TIMEOUT_MS = 1e4, CONNECTION_CLOSE_REQUEST_TTL_MS, ENHANCER_TERMINAL_JOB_RETENTION_MS;
|
|
84585
84529
|
var init_reliability = __esm(() => {
|
|
84586
84530
|
DAEMON_HEARTBEAT_INTERVAL_MS = 5 * 60000;
|
|
84587
84531
|
DAEMON_HEARTBEAT_TTL_MS = 6 * DAEMON_HEARTBEAT_INTERVAL_MS;
|
|
84588
84532
|
MACHINE_COMMAND_DAEMON_ROUTINE_TTL_MS = 5 * 60000;
|
|
84589
|
-
OBSERVED_FULL_PUSH_INTERVAL_MS = 5 * 60000;
|
|
84590
|
-
OBSERVED_SYNC_RECONCILE_MS = 15 * 60000;
|
|
84591
|
-
WORKSPACE_RECENCY_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;
|
|
84592
84533
|
WORKSPACE_LIST_RECONCILE_MS = 60 * 60 * 1000;
|
|
84593
84534
|
AGENT_STOP_TERMINAL_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
84594
84535
|
CONNECTION_CLOSE_REQUEST_TTL_MS = 10 * 60000;
|
|
@@ -84831,7 +84772,7 @@ var init_v_literals_of = __esm(() => {
|
|
|
84831
84772
|
});
|
|
84832
84773
|
|
|
84833
84774
|
// ../../services/backend/src/domain/entities/agent.ts
|
|
84834
|
-
var AGENT_HARNESSES, AgentHarnessEnum, agentHarnessValidator, AGENT_TYPES, AgentTypeEnum, agentTypeValidator, MACHINE_COMMAND_TYPES, MachineCommandTypeEnum, machineCommandTypeValidator, MACHINE_COMMAND_STATUSES, MachineCommandStatusEnum, machineCommandStatusValidator, AGENT_START_REASONS, AgentStartReasonEnum, agentStartReasonValidator, AGENT_STOP_REASONS, agentPostStopDesiredStateValidator, AgentStopReasonEnum, agentStopReasonValidator, isAgentStopReason = (value) => AGENT_STOP_REASONS.includes(value), MODEL_SOURCES, ModelSourceEnum, modelSourceValidator;
|
|
84775
|
+
var AGENT_HARNESSES, AgentHarnessEnum, agentHarnessValidator, AGENT_TYPES, AgentTypeEnum, agentTypeValidator, MACHINE_COMMAND_TYPES, MachineCommandTypeEnum, machineCommandTypeValidator, MACHINE_COMMAND_STATUSES, MachineCommandStatusEnum, machineCommandStatusValidator, AGENT_START_REASONS, AgentStartReasonEnum, agentStartReasonValidator, USER_EXPLICIT_START_REASONS, EXPLICIT_DAEMON_START_REASONS, isExplicitDaemonStart = (reason) => EXPLICIT_DAEMON_START_REASONS.includes(reason), AGENT_STOP_REASONS, agentPostStopDesiredStateValidator, AgentStopReasonEnum, agentStopReasonValidator, isAgentStopReason = (value) => AGENT_STOP_REASONS.includes(value), MODEL_SOURCES, ModelSourceEnum, modelSourceValidator;
|
|
84835
84776
|
var init_agent2 = __esm(() => {
|
|
84836
84777
|
init_values();
|
|
84837
84778
|
init_v_literals_of();
|
|
@@ -84862,6 +84803,10 @@ var init_agent2 = __esm(() => {
|
|
|
84862
84803
|
AGENT_START_REASONS = [
|
|
84863
84804
|
"user.start",
|
|
84864
84805
|
"user.restart",
|
|
84806
|
+
"user.manual_spawn",
|
|
84807
|
+
"platform.task_monitor_nudge",
|
|
84808
|
+
"platform.task_start_in_new_session",
|
|
84809
|
+
"platform.pending_task_wake",
|
|
84865
84810
|
"platform.crash_recovery",
|
|
84866
84811
|
"platform.auto_restart_on_new_context",
|
|
84867
84812
|
"platform.restart_offline_on_user_message",
|
|
@@ -84870,12 +84815,25 @@ var init_agent2 = __esm(() => {
|
|
|
84870
84815
|
];
|
|
84871
84816
|
AgentStartReasonEnum = Object.fromEntries(AGENT_START_REASONS.map((r) => [r, r]));
|
|
84872
84817
|
agentStartReasonValidator = v.union(...toLiteralValidators(AGENT_START_REASONS));
|
|
84818
|
+
USER_EXPLICIT_START_REASONS = [
|
|
84819
|
+
AgentStartReasonEnum["user.start"],
|
|
84820
|
+
AgentStartReasonEnum["user.restart"]
|
|
84821
|
+
];
|
|
84822
|
+
EXPLICIT_DAEMON_START_REASONS = [
|
|
84823
|
+
...USER_EXPLICIT_START_REASONS,
|
|
84824
|
+
AgentStartReasonEnum["user.manual_spawn"],
|
|
84825
|
+
AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
84826
|
+
AgentStartReasonEnum["platform.task_start_in_new_session"],
|
|
84827
|
+
"daemon.respawn"
|
|
84828
|
+
];
|
|
84873
84829
|
AGENT_STOP_REASONS = [
|
|
84874
84830
|
"user.stop",
|
|
84875
84831
|
"user.restart",
|
|
84876
84832
|
"platform.dedup",
|
|
84877
84833
|
"platform.team_switch",
|
|
84878
84834
|
"platform.resume_storm",
|
|
84835
|
+
"platform.task_monitor_nudge",
|
|
84836
|
+
"platform.task_start_in_new_session",
|
|
84879
84837
|
"daemon.respawn",
|
|
84880
84838
|
"daemon.shutdown",
|
|
84881
84839
|
"daemon.stop_timeout",
|
|
@@ -100165,8 +100123,6 @@ var init_assigned_task_snapshot_contract = __esm(() => {
|
|
|
100165
100123
|
createdAt: exports_external.number(),
|
|
100166
100124
|
workingDir: exports_external.string().optional(),
|
|
100167
100125
|
assignedTo: exports_external.string().optional(),
|
|
100168
|
-
lastSeenAction: exports_external.string().nullable().optional(),
|
|
100169
|
-
lastStatus: exports_external.string().nullable().optional(),
|
|
100170
100126
|
sessionAugmentation: sessionAugmentationSchema.optional()
|
|
100171
100127
|
};
|
|
100172
100128
|
assignedTaskSignalSchema = exports_external.object(assignedTaskSignalBootstrapFields);
|
|
@@ -100420,9 +100376,6 @@ function logNativeDeliveryMutexSkip(role, chatroomId, taskId) {
|
|
|
100420
100376
|
function logNativeDeliveryInjecting(role, chatroomId, taskId) {
|
|
100421
100377
|
console.log(`[NativeDelivery:inject] ${role}@${chatroomId} task ${taskId} — starting injection`);
|
|
100422
100378
|
}
|
|
100423
|
-
function logNativeDeliveryNoTasks(role, chatroomId) {
|
|
100424
|
-
console.log(`[NativeDelivery:skip] ${role}@${chatroomId} — no pending tasks for role`);
|
|
100425
|
-
}
|
|
100426
100379
|
|
|
100427
100380
|
// src/daemon/entry/native-delivery/native-stale-turn-phase.ts
|
|
100428
100381
|
function isStaleTurnInFlightWhileWaiting(task, slot) {
|
|
@@ -100430,10 +100383,9 @@ function isStaleTurnInFlightWhileWaiting(task, slot) {
|
|
|
100430
100383
|
return false;
|
|
100431
100384
|
if (task.status !== "pending")
|
|
100432
100385
|
return false;
|
|
100433
|
-
return
|
|
100386
|
+
return true;
|
|
100434
100387
|
}
|
|
100435
100388
|
var init_native_stale_turn_phase = __esm(() => {
|
|
100436
|
-
init_participant();
|
|
100437
100389
|
init_check_agent_slot();
|
|
100438
100390
|
});
|
|
100439
100391
|
|
|
@@ -100591,7 +100543,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100591
100543
|
await deps.agentMgr.stop({
|
|
100592
100544
|
chatroomId,
|
|
100593
100545
|
role,
|
|
100594
|
-
reason: "platform.task_start_in_new_session"
|
|
100546
|
+
reason: AgentStopReasonEnum["platform.task_start_in_new_session"]
|
|
100595
100547
|
});
|
|
100596
100548
|
const spawn3 = await deps.agentMgr.ensureRunning({
|
|
100597
100549
|
chatroomId,
|
|
@@ -100599,7 +100551,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100599
100551
|
agentHarness,
|
|
100600
100552
|
model,
|
|
100601
100553
|
workingDir,
|
|
100602
|
-
reason: "platform.task_start_in_new_session",
|
|
100554
|
+
reason: AgentStartReasonEnum["platform.task_start_in_new_session"],
|
|
100603
100555
|
wantResume: false
|
|
100604
100556
|
});
|
|
100605
100557
|
if (!spawn3.success)
|
|
@@ -100640,6 +100592,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100640
100592
|
}
|
|
100641
100593
|
var init_native_cold_session_before_inject = __esm(() => {
|
|
100642
100594
|
init_reliability();
|
|
100595
|
+
init_agent2();
|
|
100643
100596
|
init_participant();
|
|
100644
100597
|
init_api3();
|
|
100645
100598
|
});
|
|
@@ -100836,13 +100789,7 @@ function injectNativeTaskPrompt(task, deps, harnessSessionId, sessionAugmentatio
|
|
|
100836
100789
|
const { role } = agentConfig;
|
|
100837
100790
|
const { prompt, augmentationMode } = yield* loadNativeInjectionPrompt(task, deps);
|
|
100838
100791
|
yield* exports_Effect.tryPromise({
|
|
100839
|
-
try: () => deps.
|
|
100840
|
-
sessionId: deps.sessionId,
|
|
100841
|
-
chatroomId,
|
|
100842
|
-
role,
|
|
100843
|
-
action: NATIVE_TASK_INJECTED_ACTION,
|
|
100844
|
-
taskId
|
|
100845
|
-
}),
|
|
100792
|
+
try: () => deps.lifecycleOutbox ? deps.lifecycleOutbox.enqueue(buildActivityLifecycleFact({ chatroomId, role, action: NATIVE_TASK_INJECTED_ACTION, taskId })) : Promise.reject(new Error("lifecycle outbox missing")),
|
|
100846
100793
|
catch: (err) => err
|
|
100847
100794
|
});
|
|
100848
100795
|
yield* exports_Effect.tryPromise({
|
|
@@ -100996,25 +100943,7 @@ class NativeTaskDeliveryCoordinator {
|
|
|
100996
100943
|
getRoleDeliveryState().resetDeliveryState(chatroomId, role);
|
|
100997
100944
|
}
|
|
100998
100945
|
tryInjectNextForRole(chatroomId, role) {
|
|
100999
|
-
|
|
101000
|
-
return;
|
|
101001
|
-
const session2 = getNativeDeliverySession();
|
|
101002
|
-
if (!session2)
|
|
101003
|
-
return;
|
|
101004
|
-
const { runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId } = session2;
|
|
101005
|
-
const tasks = session2.taskSnapshotState?.listForRole(chatroomId, role) ?? [];
|
|
101006
|
-
if (tasks.length === 0) {
|
|
101007
|
-
logNativeDeliveryNoTasks(role, chatroomId);
|
|
101008
|
-
return;
|
|
101009
|
-
}
|
|
101010
|
-
this.reconcileAssignedTasks({
|
|
101011
|
-
tasks,
|
|
101012
|
-
runtime: runtime4,
|
|
101013
|
-
effectContext: effectContext2,
|
|
101014
|
-
agentMgr,
|
|
101015
|
-
sessionDeps,
|
|
101016
|
-
machineId
|
|
101017
|
-
});
|
|
100946
|
+
reconcileDeliverableWorkForRole(chatroomId, role);
|
|
101018
100947
|
}
|
|
101019
100948
|
reconcileAssignedTasks(params) {
|
|
101020
100949
|
const tasks = filterSnapshotsExcludingRestartInFlight(params.tasks);
|
|
@@ -101032,7 +100961,7 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101032
100961
|
});
|
|
101033
100962
|
for (const row of pendingFirst) {
|
|
101034
100963
|
const { role } = row.agentConfig;
|
|
101035
|
-
|
|
100964
|
+
let slot = agentMgr.getSlot(row.chatroomId, role);
|
|
101036
100965
|
if (row.status === "pending" && slot?.lastInFlightTaskId === row.taskId) {
|
|
101037
100966
|
exports_Effect.runSync(agentMgr.clearLastInFlightTaskIfMatches(row.chatroomId, role, row.taskId));
|
|
101038
100967
|
}
|
|
@@ -101041,9 +100970,10 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101041
100970
|
exports_Effect.runSync(agentMgr.reconcileNativeTurnPhaseIdle(row.chatroomId, role));
|
|
101042
100971
|
}
|
|
101043
100972
|
logNativeDeliveryFallback("stale-turn-phase", role, row.chatroomId, row.taskId);
|
|
100973
|
+
slot = agentMgr.getSlot(row.chatroomId, role) ?? undefined;
|
|
101044
100974
|
}
|
|
101045
100975
|
const blockReason = explainNativeDeliveryBlock(row, {
|
|
101046
|
-
slot
|
|
100976
|
+
slot
|
|
101047
100977
|
});
|
|
101048
100978
|
if (blockReason) {
|
|
101049
100979
|
if (isDeliverableTaskStatus(row.status)) {
|
|
@@ -101085,11 +101015,15 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101085
101015
|
return;
|
|
101086
101016
|
}
|
|
101087
101017
|
const full = mapAssignedTaskView(backend2);
|
|
101018
|
+
const deliverySession = getNativeDeliverySession();
|
|
101019
|
+
if (!deliverySession?.lifecycleOutbox)
|
|
101020
|
+
return;
|
|
101088
101021
|
yield* runNativeInjectionEffect(full, harnessSessionId, {
|
|
101089
101022
|
sessionId: sessionDeps.sessionId,
|
|
101090
101023
|
machineId: sessionDeps.machineId,
|
|
101091
101024
|
logEvent: sessionDeps.logEvent,
|
|
101092
101025
|
backend: sessionDeps.backend,
|
|
101026
|
+
lifecycleOutbox: deliverySession.lifecycleOutbox,
|
|
101093
101027
|
agentMgr: {
|
|
101094
101028
|
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2)),
|
|
101095
101029
|
stop: (opts) => exports_Effect.runPromise(agentMgr.stop(opts)),
|
|
@@ -101118,6 +101052,25 @@ function getNativeTaskDeliveryCoordinator() {
|
|
|
101118
101052
|
coordinator ??= new NativeTaskDeliveryCoordinator;
|
|
101119
101053
|
return coordinator;
|
|
101120
101054
|
}
|
|
101055
|
+
function reconcileDeliverableWorkForRole(chatroomId, role) {
|
|
101056
|
+
if (isRestartOrchestratorInFlight(chatroomId, role))
|
|
101057
|
+
return;
|
|
101058
|
+
const session2 = getNativeDeliverySession();
|
|
101059
|
+
if (!session2)
|
|
101060
|
+
return;
|
|
101061
|
+
const { runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId, taskSnapshotState } = session2;
|
|
101062
|
+
const tasks = taskSnapshotState?.listForRole(chatroomId, role) ?? [];
|
|
101063
|
+
if (tasks.length === 0)
|
|
101064
|
+
return;
|
|
101065
|
+
getNativeTaskDeliveryCoordinator().reconcileAssignedTasks({
|
|
101066
|
+
tasks,
|
|
101067
|
+
runtime: runtime4,
|
|
101068
|
+
effectContext: effectContext2,
|
|
101069
|
+
agentMgr,
|
|
101070
|
+
sessionDeps,
|
|
101071
|
+
machineId
|
|
101072
|
+
});
|
|
101073
|
+
}
|
|
101121
101074
|
function notifyNativeSessionLost(params) {
|
|
101122
101075
|
getNativeTaskDeliveryCoordinator().onSessionLost(params);
|
|
101123
101076
|
}
|
|
@@ -101128,7 +101081,7 @@ function notifyNativeTurnIdle(params) {
|
|
|
101128
101081
|
if (isRestartOrchestratorInFlight(params.chatroomId, params.role))
|
|
101129
101082
|
return;
|
|
101130
101083
|
logNativeDeliveryPrimary(params.role, params.chatroomId);
|
|
101131
|
-
|
|
101084
|
+
reconcileDeliverableWorkForRole(params.chatroomId, params.role);
|
|
101132
101085
|
}
|
|
101133
101086
|
var coordinator;
|
|
101134
101087
|
var init_native_task_delivery_coordinator = __esm(() => {
|
|
@@ -102687,12 +102640,9 @@ async function emitNativeWaitingAfterSpawn(ctx, harness, opts) {
|
|
|
102687
102640
|
return false;
|
|
102688
102641
|
}
|
|
102689
102642
|
try {
|
|
102690
|
-
|
|
102691
|
-
|
|
102692
|
-
|
|
102693
|
-
role: ctx.role,
|
|
102694
|
-
action: NATIVE_WAITING_ACTION
|
|
102695
|
-
});
|
|
102643
|
+
if (!ctx.lifecycleOutbox)
|
|
102644
|
+
throw new Error("lifecycle outbox missing");
|
|
102645
|
+
await ctx.lifecycleOutbox.enqueue(buildActivityLifecycleFact({ chatroomId: ctx.chatroomId, role: ctx.role, action: NATIVE_WAITING_ACTION }));
|
|
102696
102646
|
return true;
|
|
102697
102647
|
} catch (err) {
|
|
102698
102648
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -102846,16 +102796,13 @@ class AgentProcessManager {
|
|
|
102846
102796
|
slot.expectedStopReason = undefined;
|
|
102847
102797
|
slot.expectedStopPid = undefined;
|
|
102848
102798
|
}
|
|
102849
|
-
isExplicitStartReason(reason) {
|
|
102850
|
-
return reason === "user.start" || reason === "user.manual_spawn" || reason === "user.restart" || reason === "platform.task_monitor_nudge" || reason === "platform.task_start_in_new_session" || reason === "daemon.respawn";
|
|
102851
|
-
}
|
|
102852
102799
|
async ensureRunning(opts) {
|
|
102853
102800
|
if (isChatroomStopScopeActive(opts.chatroomId)) {
|
|
102854
102801
|
return { success: false, error: "stop_in_progress" };
|
|
102855
102802
|
}
|
|
102856
102803
|
const key = agentKey3(opts.chatroomId, opts.role);
|
|
102857
102804
|
const slot = this.getOrCreateSlot(key);
|
|
102858
|
-
if (
|
|
102805
|
+
if (isExplicitDaemonStart(opts.reason)) {
|
|
102859
102806
|
this.bumpStopGeneration(slot);
|
|
102860
102807
|
this.clearStopIntent(slot);
|
|
102861
102808
|
} else if (slot.stopRequested) {
|
|
@@ -104171,7 +104118,8 @@ class AgentProcessManager {
|
|
|
104171
104118
|
backend: this.deps.backend,
|
|
104172
104119
|
sessionId: this.deps.sessionId,
|
|
104173
104120
|
chatroomId,
|
|
104174
|
-
role
|
|
104121
|
+
role,
|
|
104122
|
+
lifecycleOutbox: this.deps.lifecycleOutbox
|
|
104175
104123
|
}, harness, {
|
|
104176
104124
|
onError: (err) => {
|
|
104177
104125
|
console.log(` ⚠️ Failed to emit native:waiting for ${role}: ${err.message}`);
|
|
@@ -104413,6 +104361,7 @@ class AgentProcessManager {
|
|
|
104413
104361
|
var AGENT_EXIT_RETRY_INTERVAL_MS = 1e4, STOPPING_TIMEOUT_MS = 30000;
|
|
104414
104362
|
var init_agent_process_manager = __esm(() => {
|
|
104415
104363
|
init_types();
|
|
104364
|
+
init_agent2();
|
|
104416
104365
|
init_participant();
|
|
104417
104366
|
init_esm();
|
|
104418
104367
|
init_execute_stop_targets_adapter();
|
|
@@ -104457,7 +104406,7 @@ async function discoverModelsForHarness(harness, service3) {
|
|
|
104457
104406
|
async function discoverModels(agentServices) {
|
|
104458
104407
|
return exports_Effect.runPromise(discoverModelsEffect(agentServices));
|
|
104459
104408
|
}
|
|
104460
|
-
function
|
|
104409
|
+
function createDefaultDeps22() {
|
|
104461
104410
|
return {
|
|
104462
104411
|
backend: {
|
|
104463
104412
|
mutation: async () => {
|
|
@@ -104823,7 +104772,7 @@ var init_init_daemon = __esm(() => {
|
|
|
104823
104772
|
convexUrl,
|
|
104824
104773
|
agentServices,
|
|
104825
104774
|
cachedModels,
|
|
104826
|
-
deps:
|
|
104775
|
+
deps: createDefaultDeps22()
|
|
104827
104776
|
});
|
|
104828
104777
|
yield* registerEventListenersEffect().pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
104829
104778
|
yield* logStartupEffect(cachedModels).pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
@@ -105067,7 +105016,10 @@ var init_capabilities_bridge = __esm(() => {
|
|
|
105067
105016
|
});
|
|
105068
105017
|
|
|
105069
105018
|
// ../../services/backend/config/featureFlags.ts
|
|
105070
|
-
function getAllowedSignupMethodsForEnvironment(nodeEnv, convexDeployment) {
|
|
105019
|
+
function getAllowedSignupMethodsForEnvironment(nodeEnv, convexDeployment, e2eSeedingEnabled) {
|
|
105020
|
+
if (e2eSeedingEnabled === "true") {
|
|
105021
|
+
return ["self", "invite"];
|
|
105022
|
+
}
|
|
105071
105023
|
if (convexDeployment?.startsWith("local:")) {
|
|
105072
105024
|
return ["self", "invite"];
|
|
105073
105025
|
}
|
|
@@ -105083,7 +105035,7 @@ var init_featureFlags = __esm(() => {
|
|
|
105083
105035
|
disableLogin: false,
|
|
105084
105036
|
directHarnessWorkers: true,
|
|
105085
105037
|
get allowedSignupMethods() {
|
|
105086
|
-
return getAllowedSignupMethodsForEnvironment("development", process.env.CONVEX_DEPLOYMENT);
|
|
105038
|
+
return getAllowedSignupMethodsForEnvironment("development", process.env.CONVEX_DEPLOYMENT, process.env.E2E_SEEDING_ENABLED);
|
|
105087
105039
|
}
|
|
105088
105040
|
};
|
|
105089
105041
|
});
|
|
@@ -108157,8 +108109,6 @@ async function pushAvailableGitState(ctx, workingDir, stateKey, branchResult) {
|
|
|
108157
108109
|
...pipeline2.toMutationArgs(values3, false)
|
|
108158
108110
|
});
|
|
108159
108111
|
ctx.lastPushedGitState.set(stateKey, stateHash);
|
|
108160
|
-
lastPushedBranch.set(stateKey, branch);
|
|
108161
|
-
lastFullPushMs.set(stateKey, Date.now());
|
|
108162
108112
|
console.log(`[${formatTimestamp()}] \uD83D\uDD00 Git state pushed: ${workingDir} (${branch}${values3.get("isDirty") ? ", dirty" : ", clean"})`);
|
|
108163
108113
|
}
|
|
108164
108114
|
if (ctx.lastPushedGitState.get(commitsKey) !== commitsHash) {
|
|
@@ -108176,17 +108126,13 @@ async function pushAvailableGitState(ctx, workingDir, stateKey, branchResult) {
|
|
|
108176
108126
|
}
|
|
108177
108127
|
}
|
|
108178
108128
|
}
|
|
108179
|
-
|
|
108180
|
-
await exports_Effect.runPromise(pushGitStateEffect.pipe(exports_Effect.provide(effectContext2)));
|
|
108181
|
-
}
|
|
108182
|
-
var lastFullPushMs, lastPushedBranch, branchField, GIT_STATE_FIELDS, pushGitStateEffect, pushSingleWorkspaceGitStateEffect = (workingDir) => exports_Effect.gen(function* () {
|
|
108129
|
+
var branchField, GIT_STATE_FIELDS, pushGitStateEffect, pushSingleWorkspaceGitStateEffect = (workingDir) => exports_Effect.gen(function* () {
|
|
108183
108130
|
const session2 = yield* DaemonSessionService;
|
|
108184
108131
|
const mutable = yield* DaemonMutableStateService;
|
|
108185
108132
|
const lastPushedGitState = yield* exports_Ref.get(mutable.lastPushedGitState);
|
|
108186
108133
|
yield* exports_Effect.promise(() => pushSingleWorkspaceGitStateImpl(buildGitStateDeps(session2, lastPushedGitState), workingDir));
|
|
108187
108134
|
});
|
|
108188
108135
|
var init_git_heartbeat = __esm(() => {
|
|
108189
|
-
init_reliability();
|
|
108190
108136
|
init_esm();
|
|
108191
108137
|
init_api3();
|
|
108192
108138
|
init_daemon_services();
|
|
@@ -108194,8 +108140,6 @@ var init_git_heartbeat = __esm(() => {
|
|
|
108194
108140
|
init_convex_error();
|
|
108195
108141
|
init_git_reader();
|
|
108196
108142
|
init_git_state_pipeline();
|
|
108197
|
-
lastFullPushMs = new Map;
|
|
108198
|
-
lastPushedBranch = new Map;
|
|
108199
108143
|
branchField = {
|
|
108200
108144
|
key: "branch",
|
|
108201
108145
|
includeInSlim: true,
|
|
@@ -108287,6 +108231,47 @@ var init_git_heartbeat = __esm(() => {
|
|
|
108287
108231
|
});
|
|
108288
108232
|
});
|
|
108289
108233
|
|
|
108234
|
+
// src/daemon/entry/workspace-git/workspace-list-subscription.ts
|
|
108235
|
+
function toSyncWorkspaces(workingDirs) {
|
|
108236
|
+
return workingDirs.map((workingDir) => ({ workingDir }));
|
|
108237
|
+
}
|
|
108238
|
+
async function reconcileWorkspaceList(session2) {
|
|
108239
|
+
const workspaces = await session2.backend.query(api.workspaces.listRecentlyObservedWorkspacesForMachine, {
|
|
108240
|
+
sessionId: session2.sessionId,
|
|
108241
|
+
machineId: session2.machineId,
|
|
108242
|
+
recencyWindowMs: OBSERVATION_TTL_MS
|
|
108243
|
+
});
|
|
108244
|
+
if (workspaces == null)
|
|
108245
|
+
return;
|
|
108246
|
+
if (!session2.workspaceListStore) {
|
|
108247
|
+
session2.workspaceListStore = { workspaces: [], updatedAt: 0 };
|
|
108248
|
+
}
|
|
108249
|
+
session2.workspaceListStore.workspaces = toSyncWorkspaces(workspaces);
|
|
108250
|
+
session2.workspaceListStore.updatedAt = Date.now();
|
|
108251
|
+
}
|
|
108252
|
+
var startWorkspaceListSubscriptionEffect = () => exports_Effect.gen(function* () {
|
|
108253
|
+
const session2 = yield* DaemonSessionService;
|
|
108254
|
+
session2.workspaceListStore = { workspaces: [], updatedAt: 0 };
|
|
108255
|
+
yield* exports_Effect.promise(() => reconcileWorkspaceList(session2));
|
|
108256
|
+
const interval = setInterval(() => {
|
|
108257
|
+
reconcileWorkspaceList(session2).catch(() => {
|
|
108258
|
+
return;
|
|
108259
|
+
});
|
|
108260
|
+
}, OBSERVED_SAFETY_POLL_MS);
|
|
108261
|
+
return {
|
|
108262
|
+
stop: () => {
|
|
108263
|
+
clearInterval(interval);
|
|
108264
|
+
session2.workspaceListStore = undefined;
|
|
108265
|
+
}
|
|
108266
|
+
};
|
|
108267
|
+
});
|
|
108268
|
+
var init_workspace_list_subscription = __esm(() => {
|
|
108269
|
+
init_reliability();
|
|
108270
|
+
init_esm();
|
|
108271
|
+
init_api3();
|
|
108272
|
+
init_daemon_services();
|
|
108273
|
+
});
|
|
108274
|
+
|
|
108290
108275
|
// src/daemon/entry/command-event-types.ts
|
|
108291
108276
|
function isDaemonCommandEventType(value) {
|
|
108292
108277
|
return DAEMON_COMMAND_EVENT_TYPES.includes(value);
|
|
@@ -108300,6 +108285,7 @@ var init_command_event_types = __esm(() => {
|
|
|
108300
108285
|
"agent.stopScope",
|
|
108301
108286
|
"daemon.ping",
|
|
108302
108287
|
"daemon.gitRefresh",
|
|
108288
|
+
"daemon.workspaceListChanged",
|
|
108303
108289
|
"daemon.localAction",
|
|
108304
108290
|
"daemon.pickFolder",
|
|
108305
108291
|
"daemon.refreshCapabilities"
|
|
@@ -110230,6 +110216,8 @@ function evictStaleDedupEntries(tracker) {
|
|
|
110230
110216
|
evictStaleEntries(tracker.capabilitiesRefreshIds, evictBefore);
|
|
110231
110217
|
evictStaleEntries(tracker.localActionIds, evictBefore);
|
|
110232
110218
|
evictStaleEntries(tracker.pickFolderIds, evictBefore);
|
|
110219
|
+
if (tracker.workspaceListChangedIds)
|
|
110220
|
+
evictStaleEntries(tracker.workspaceListChangedIds, evictBefore);
|
|
110233
110221
|
processManager.evictStalePendingStops();
|
|
110234
110222
|
}
|
|
110235
110223
|
function createDedupTracker() {
|
|
@@ -110239,9 +110227,21 @@ function createDedupTracker() {
|
|
|
110239
110227
|
gitRefreshIds: new Map,
|
|
110240
110228
|
capabilitiesRefreshIds: new Map,
|
|
110241
110229
|
localActionIds: new Map,
|
|
110242
|
-
pickFolderIds: new Map
|
|
110230
|
+
pickFolderIds: new Map,
|
|
110231
|
+
workspaceListChangedIds: new Map
|
|
110243
110232
|
};
|
|
110244
110233
|
}
|
|
110234
|
+
function handleWorkspaceListChangedCommandEffect(event, tracker) {
|
|
110235
|
+
return exports_Effect.gen(function* () {
|
|
110236
|
+
const eventId = String(event._id);
|
|
110237
|
+
if (tracker.workspaceListChangedIds?.has(eventId))
|
|
110238
|
+
return;
|
|
110239
|
+
const session2 = yield* DaemonSessionService;
|
|
110240
|
+
yield* exports_Effect.promise(() => reconcileWorkspaceList(session2));
|
|
110241
|
+
yield* pushGitStateEffect;
|
|
110242
|
+
(tracker.workspaceListChangedIds ??= new Map).set(eventId, Date.now());
|
|
110243
|
+
});
|
|
110244
|
+
}
|
|
110245
110245
|
function handleRequestStartEffect(event, tracker) {
|
|
110246
110246
|
return exports_Effect.gen(function* () {
|
|
110247
110247
|
const eventId = event._id.toString();
|
|
@@ -110411,6 +110411,7 @@ var init_command_dispatch = __esm(() => {
|
|
|
110411
110411
|
init_reliability();
|
|
110412
110412
|
init_esm();
|
|
110413
110413
|
init_git_heartbeat();
|
|
110414
|
+
init_workspace_list_subscription();
|
|
110414
110415
|
init_api3();
|
|
110415
110416
|
init_capabilities_bridge();
|
|
110416
110417
|
init_command_event_types();
|
|
@@ -110440,6 +110441,7 @@ var init_command_dispatch = __esm(() => {
|
|
|
110440
110441
|
}),
|
|
110441
110442
|
"daemon.ping": handlePingCommandEffect,
|
|
110442
110443
|
"daemon.gitRefresh": handleGitRefreshCommandEffect,
|
|
110444
|
+
"daemon.workspaceListChanged": handleWorkspaceListChangedCommandEffect,
|
|
110443
110445
|
"daemon.localAction": handleLocalActionCommandEffect,
|
|
110444
110446
|
"daemon.pickFolder": handlePickFolderCommandEffect,
|
|
110445
110447
|
"daemon.refreshCapabilities": handleRefreshCapabilitiesEffect
|
|
@@ -111431,6 +111433,9 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111431
111433
|
let service3 = null;
|
|
111432
111434
|
let abortController = null;
|
|
111433
111435
|
let spawnHandle = null;
|
|
111436
|
+
let agentEndSeen = false;
|
|
111437
|
+
let resolveAgentEnd;
|
|
111438
|
+
let agentEndPromise = Promise.resolve();
|
|
111434
111439
|
let log4 = createEnhancerLogWriter(logSink, {
|
|
111435
111440
|
chatroomId: job.chatroomId,
|
|
111436
111441
|
harness: "unknown"
|
|
@@ -111445,9 +111450,10 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111445
111450
|
return;
|
|
111446
111451
|
claimed = true;
|
|
111447
111452
|
log4.write(`claimed job=${job.jobId} chatroom=${job.chatroomId}`);
|
|
111448
|
-
const payload = await backend2.query(api.daemon.enhancer.index.
|
|
111453
|
+
const payload = await backend2.query(api.daemon.enhancer.index.getTaskDeliveryForJob, {
|
|
111449
111454
|
sessionId,
|
|
111450
|
-
jobId: job.jobId
|
|
111455
|
+
jobId: job.jobId,
|
|
111456
|
+
convexUrl
|
|
111451
111457
|
});
|
|
111452
111458
|
chatroomId = payload.chatroomId;
|
|
111453
111459
|
jobId = payload.jobId;
|
|
@@ -111469,7 +111475,7 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111469
111475
|
}
|
|
111470
111476
|
const spawned = await service3.spawn({
|
|
111471
111477
|
workingDir: payload.workingDir,
|
|
111472
|
-
prompt: createSpawnPrompt(payload.
|
|
111478
|
+
prompt: createSpawnPrompt(payload.taskDeliveryOutput),
|
|
111473
111479
|
systemPrompt: payload.systemPrompt,
|
|
111474
111480
|
model: payload.model,
|
|
111475
111481
|
context: {
|
|
@@ -111498,6 +111504,15 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111498
111504
|
spawned.onLogLine?.((line) => {
|
|
111499
111505
|
log4.write(line);
|
|
111500
111506
|
});
|
|
111507
|
+
agentEndPromise = new Promise((resolve5) => {
|
|
111508
|
+
resolveAgentEnd = resolve5;
|
|
111509
|
+
});
|
|
111510
|
+
spawned.onAgentEnd?.(() => {
|
|
111511
|
+
if (agentEndSeen)
|
|
111512
|
+
return;
|
|
111513
|
+
agentEndSeen = true;
|
|
111514
|
+
resolveAgentEnd?.();
|
|
111515
|
+
});
|
|
111501
111516
|
await waitForEnhancerJobResolution({
|
|
111502
111517
|
sessionId,
|
|
111503
111518
|
chatroomId: payload.chatroomId,
|
|
@@ -111543,6 +111558,11 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111543
111558
|
if (spawnHandle)
|
|
111544
111559
|
unregisterEnhancerSpawn(spawnHandle);
|
|
111545
111560
|
if (spawnResult && service3) {
|
|
111561
|
+
if (!agentEndSeen)
|
|
111562
|
+
await Promise.race([
|
|
111563
|
+
agentEndPromise,
|
|
111564
|
+
new Promise((resolve5) => setTimeout(resolve5, ENHANCER_AGENT_END_GRACE_MS))
|
|
111565
|
+
]);
|
|
111546
111566
|
try {
|
|
111547
111567
|
await service3.stop(spawnResult.pid);
|
|
111548
111568
|
} catch {}
|
|
@@ -117490,14 +117510,18 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
117490
117510
|
const { chatroomId, agentConfig, role, workingDir, wantResume } = ctx;
|
|
117491
117511
|
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
117492
117512
|
exports_Runtime.runFork(runtime4)(exports_Effect.gen(function* () {
|
|
117493
|
-
yield* agentMgr.stop({
|
|
117513
|
+
yield* agentMgr.stop({
|
|
117514
|
+
chatroomId,
|
|
117515
|
+
role,
|
|
117516
|
+
reason: AgentStopReasonEnum["platform.task_monitor_nudge"]
|
|
117517
|
+
});
|
|
117494
117518
|
yield* agentMgr.ensureRunning({
|
|
117495
117519
|
chatroomId,
|
|
117496
117520
|
role,
|
|
117497
117521
|
agentHarness: agentConfig.agentHarness,
|
|
117498
117522
|
model: agentConfig.model,
|
|
117499
117523
|
workingDir,
|
|
117500
|
-
reason: "platform.task_monitor_nudge",
|
|
117524
|
+
reason: AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
117501
117525
|
wantResume,
|
|
117502
117526
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117503
117527
|
taskId: task.taskId
|
|
@@ -117544,7 +117568,7 @@ function runNativeReviveEffect(task, runtime4, effectContext2, agentMgr) {
|
|
|
117544
117568
|
agentHarness: agentConfig.agentHarness,
|
|
117545
117569
|
model: agentConfig.model,
|
|
117546
117570
|
workingDir,
|
|
117547
|
-
reason: "platform.task_monitor_nudge",
|
|
117571
|
+
reason: AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
117548
117572
|
wantResume,
|
|
117549
117573
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117550
117574
|
taskId: task.taskId
|
|
@@ -117564,7 +117588,7 @@ function runNativeWakeEffect(task, runtime4, effectContext2, agentMgr) {
|
|
|
117564
117588
|
agentHarness: agentConfig.agentHarness,
|
|
117565
117589
|
model: agentConfig.model,
|
|
117566
117590
|
workingDir,
|
|
117567
|
-
reason: "platform.pending_task_wake",
|
|
117591
|
+
reason: AgentStartReasonEnum["platform.pending_task_wake"],
|
|
117568
117592
|
wantResume,
|
|
117569
117593
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117570
117594
|
taskId: task.taskId
|
|
@@ -117650,6 +117674,7 @@ async function processTasksUpdate(runtime4, effectContext2, cooldown, agentMgr,
|
|
|
117650
117674
|
await nudgeStuckTasks(filteredTasks, now, cooldown, runtime4, effectContext2, agentMgr, sessionDeps, machineId);
|
|
117651
117675
|
}
|
|
117652
117676
|
var init_task_delivery_processor = __esm(() => {
|
|
117677
|
+
init_agent2();
|
|
117653
117678
|
init_parse_session_augmentation();
|
|
117654
117679
|
init_esm();
|
|
117655
117680
|
init_native_task_delivery_coordinator();
|
|
@@ -117989,7 +118014,7 @@ async function bootstrapMachineAssignedTaskSnapshots(deps) {
|
|
|
117989
118014
|
return;
|
|
117990
118015
|
await processTasksUpdate(deps.runtime, deps.effectContext, deps.cooldown, deps.agentMgr, deps.sessionDeps, deps.machineId, "bootstrap", { snapshots: enrichSnapshotsWithOperational(tasks) });
|
|
117991
118016
|
}
|
|
117992
|
-
function
|
|
118017
|
+
function isAbortError2(error51) {
|
|
117993
118018
|
return error51 instanceof Error && error51.name === "AbortError";
|
|
117994
118019
|
}
|
|
117995
118020
|
async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
@@ -117999,7 +118024,7 @@ async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
|
117999
118024
|
await runTaskInbox(options, onUpdate);
|
|
118000
118025
|
return;
|
|
118001
118026
|
} catch (error51) {
|
|
118002
|
-
if (isStopped() ||
|
|
118027
|
+
if (isStopped() || isAbortError2(error51))
|
|
118003
118028
|
return;
|
|
118004
118029
|
console.warn(`[TaskInbox] loop error, restarting in ${backoffMs}ms:`, error51);
|
|
118005
118030
|
await new Promise((resolve8) => setTimeout(resolve8, backoffMs));
|
|
@@ -118010,6 +118035,8 @@ async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
|
118010
118035
|
var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInboxEffect = (wsClient2) => exports_Effect.gen(function* () {
|
|
118011
118036
|
const session2 = yield* DaemonSessionService;
|
|
118012
118037
|
const agentMgr = yield* DaemonAgentProcessManagerService;
|
|
118038
|
+
const lifecycleOutboxService = yield* AgentLifecycleOutboxService;
|
|
118039
|
+
const lifecycleOutbox = { enqueue: (fact) => exports_Effect.runPromise(lifecycleOutboxService.enqueue(fact)) };
|
|
118013
118040
|
const effectContext2 = yield* exports_Effect.context();
|
|
118014
118041
|
const runtime4 = yield* exports_Effect.runtime();
|
|
118015
118042
|
const sessionDeps = {
|
|
@@ -118039,7 +118066,8 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118039
118066
|
sessionDeps,
|
|
118040
118067
|
machineId: session2.machineId,
|
|
118041
118068
|
taskSnapshotState,
|
|
118042
|
-
agentOperationalReadModel
|
|
118069
|
+
agentOperationalReadModel,
|
|
118070
|
+
lifecycleOutbox
|
|
118043
118071
|
});
|
|
118044
118072
|
const cooldown = new RecoveryCooldown;
|
|
118045
118073
|
let inboxUpdateInFlight = false;
|
|
@@ -118119,6 +118147,7 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118119
118147
|
var init_task_inbox_runtime = __esm(() => {
|
|
118120
118148
|
init_esm();
|
|
118121
118149
|
init_daemon_services();
|
|
118150
|
+
init_daemon_services();
|
|
118122
118151
|
init_api3();
|
|
118123
118152
|
init_native_delivery_session_registry();
|
|
118124
118153
|
init_task_delivery_processor();
|
|
@@ -118441,41 +118470,6 @@ var init_git_subscription = __esm(() => {
|
|
|
118441
118470
|
init_daemon_services();
|
|
118442
118471
|
});
|
|
118443
118472
|
|
|
118444
|
-
// src/daemon/entry/workspace-git/workspace-list-subscription.ts
|
|
118445
|
-
function toSyncWorkspaces(workingDirs) {
|
|
118446
|
-
return workingDirs.map((workingDir) => ({ workingDir }));
|
|
118447
|
-
}
|
|
118448
|
-
async function reconcileWorkspaceList(session2) {
|
|
118449
|
-
const workspaces = await session2.backend.query(api.workspaces.listRecentlyObservedWorkspacesForMachine, {
|
|
118450
|
-
sessionId: session2.sessionId,
|
|
118451
|
-
machineId: session2.machineId,
|
|
118452
|
-
recencyWindowMs: WORKSPACE_RECENCY_WINDOW_MS
|
|
118453
|
-
});
|
|
118454
|
-
if (workspaces == null)
|
|
118455
|
-
return;
|
|
118456
|
-
if (!session2.workspaceListStore) {
|
|
118457
|
-
session2.workspaceListStore = { workspaces: [], updatedAt: 0 };
|
|
118458
|
-
}
|
|
118459
|
-
session2.workspaceListStore.workspaces = toSyncWorkspaces(workspaces);
|
|
118460
|
-
session2.workspaceListStore.updatedAt = Date.now();
|
|
118461
|
-
}
|
|
118462
|
-
var startWorkspaceListSubscriptionEffect = () => exports_Effect.gen(function* () {
|
|
118463
|
-
const session2 = yield* DaemonSessionService;
|
|
118464
|
-
session2.workspaceListStore = { workspaces: [], updatedAt: 0 };
|
|
118465
|
-
yield* exports_Effect.promise(() => reconcileWorkspaceList(session2));
|
|
118466
|
-
return {
|
|
118467
|
-
stop: () => {
|
|
118468
|
-
session2.workspaceListStore = undefined;
|
|
118469
|
-
}
|
|
118470
|
-
};
|
|
118471
|
-
});
|
|
118472
|
-
var init_workspace_list_subscription = __esm(() => {
|
|
118473
|
-
init_reliability();
|
|
118474
|
-
init_esm();
|
|
118475
|
-
init_api3();
|
|
118476
|
-
init_daemon_services();
|
|
118477
|
-
});
|
|
118478
|
-
|
|
118479
118473
|
// src/daemon/entry/workspace-git-inbound-registry.ts
|
|
118480
118474
|
function registerWorkspaceGitInboundHandler(h) {
|
|
118481
118475
|
handler6 = h;
|
|
@@ -118504,34 +118498,14 @@ var init_on_daemon_shutdown = __esm(() => {
|
|
|
118504
118498
|
yield* exports_Effect.race(agentPm.whenTurnEndsIdle(), exports_Effect.sleep(SCOPE_TARGET_STOP_TIMEOUT_MS).pipe(exports_Effect.tap(() => exports_Effect.sync(() => console.log("[shutdown] idle wait timed out, proceeding")))));
|
|
118505
118499
|
const activeAgents = agentPm.listActive();
|
|
118506
118500
|
if (activeAgents.length > 0) {
|
|
118507
|
-
console.log(`[${formatTimestamp()}] Stopping ${activeAgents.length} agent(s)...`);
|
|
118508
|
-
const chatroomIds = [...new Set(activeAgents.map(({ chatroomId }) => chatroomId))];
|
|
118501
|
+
console.log(`[${formatTimestamp()}] Stopping ${activeAgents.length} agent(s) locally...`);
|
|
118509
118502
|
let totalStopped = 0;
|
|
118510
118503
|
let totalFailed = 0;
|
|
118511
|
-
yield* exports_Effect.all(
|
|
118512
|
-
|
|
118513
|
-
|
|
118514
|
-
machineId: session2.machineId,
|
|
118515
|
-
chatroomId,
|
|
118516
|
-
scope: { kind: "chatroom" },
|
|
118517
|
-
reason: "daemon.shutdown"
|
|
118518
|
-
});
|
|
118519
|
-
if (!result.inboxCommandId)
|
|
118520
|
-
return;
|
|
118521
|
-
if (!agentPm.executeScopedStopForCommand)
|
|
118522
|
-
return;
|
|
118523
|
-
const summary5 = await exports_Effect.runPromise(agentPm.executeScopedStopForCommand({
|
|
118524
|
-
stopCommandId: result.stopCommandId,
|
|
118525
|
-
chatroomId,
|
|
118526
|
-
scope: { kind: "chatroom" },
|
|
118527
|
-
reason: "daemon.shutdown",
|
|
118528
|
-
inboxCommandId: result.inboxCommandId
|
|
118529
|
-
}));
|
|
118530
|
-
totalStopped += summary5.stoppedCount;
|
|
118531
|
-
totalFailed += summary5.failedCount;
|
|
118532
|
-
}).pipe(exports_Effect.catchAll((e) => exports_Effect.sync(() => {
|
|
118504
|
+
yield* exports_Effect.all(activeAgents.map(({ chatroomId, role }) => agentPm.stop({ chatroomId, role, reason: "daemon.shutdown" }).pipe(exports_Effect.tap(() => exports_Effect.sync(() => {
|
|
118505
|
+
totalStopped += 1;
|
|
118506
|
+
})), exports_Effect.catchAll((e) => exports_Effect.sync(() => {
|
|
118533
118507
|
totalFailed += 1;
|
|
118534
|
-
console.log(` ⚠️ Failed
|
|
118508
|
+
console.log(` ⚠️ Failed to stop ${role}@${chatroomId}: ${e.message}`);
|
|
118535
118509
|
})))), { concurrency: "unbounded" });
|
|
118536
118510
|
if (totalFailed > 0) {
|
|
118537
118511
|
console.log(`[${formatTimestamp()}] Shutdown stops: ${totalStopped} stopped, ${totalFailed} failed`);
|
|
@@ -118691,10 +118665,6 @@ function createDaemonRuntime(deps) {
|
|
|
118691
118665
|
workspaceListSubscriptionHandle = yield* startWorkspaceListSubscriptionEffect();
|
|
118692
118666
|
registerWorkspaceGitInboundHandler(async (event) => {
|
|
118693
118667
|
switch (event.type) {
|
|
118694
|
-
case "workspace.list-changed":
|
|
118695
|
-
await reconcileWorkspaceList(session2);
|
|
118696
|
-
await drainGitStateSync(effectContext2);
|
|
118697
|
-
break;
|
|
118698
118668
|
case "git.request":
|
|
118699
118669
|
if (gitHandle)
|
|
118700
118670
|
await gitHandle.drainPendingGitRequests();
|
|
@@ -118762,7 +118732,6 @@ var init_daemon_runtime = __esm(() => {
|
|
|
118762
118732
|
init_log_observer_sync();
|
|
118763
118733
|
init_init_daemon();
|
|
118764
118734
|
init_task_inbox_runtime();
|
|
118765
|
-
init_git_heartbeat();
|
|
118766
118735
|
init_git_subscription();
|
|
118767
118736
|
init_api3();
|
|
118768
118737
|
init_workspace_list_subscription();
|
|
@@ -119829,36 +119798,6 @@ var init_machine_command_inbox = __esm(() => {
|
|
|
119829
119798
|
init_api3();
|
|
119830
119799
|
});
|
|
119831
119800
|
|
|
119832
|
-
// src/daemon/infrastructure/convex/subscribers/workspace-list.ts
|
|
119833
|
-
function startWorkspaceListSubscriber(deps, onEvent) {
|
|
119834
|
-
let lastSnapshotKey = "";
|
|
119835
|
-
const queryArgs = {
|
|
119836
|
-
sessionId: deps.sessionId,
|
|
119837
|
-
machineId: deps.machineId,
|
|
119838
|
-
recencyWindowMs: WORKSPACE_RECENCY_WINDOW_MS
|
|
119839
|
-
};
|
|
119840
|
-
const unsub = deps.wsClient.onUpdate(api.workspaces.listRecentlyObservedWorkspacesForMachine, queryArgs, (workspaces) => {
|
|
119841
|
-
if (workspaces == null)
|
|
119842
|
-
return;
|
|
119843
|
-
const snapshotKey2 = JSON.stringify(workspaces);
|
|
119844
|
-
if (snapshotKey2 === lastSnapshotKey)
|
|
119845
|
-
return;
|
|
119846
|
-
lastSnapshotKey = snapshotKey2;
|
|
119847
|
-
onEvent({ type: "workspace.list-changed", machineId: deps.machineId });
|
|
119848
|
-
}, (err) => {
|
|
119849
|
-
console.warn(`[daemon] workspace-list subscriber error: ${err instanceof Error ? err.message : String(err)}`);
|
|
119850
|
-
});
|
|
119851
|
-
return {
|
|
119852
|
-
async stop() {
|
|
119853
|
-
unsub();
|
|
119854
|
-
}
|
|
119855
|
-
};
|
|
119856
|
-
}
|
|
119857
|
-
var init_workspace_list = __esm(() => {
|
|
119858
|
-
init_reliability();
|
|
119859
|
-
init_api3();
|
|
119860
|
-
});
|
|
119861
|
-
|
|
119862
119801
|
// src/daemon/entry/subscriber-registry.ts
|
|
119863
119802
|
function startAllSubscribers(deps) {
|
|
119864
119803
|
const onEvent = (event) => {
|
|
@@ -119875,7 +119814,6 @@ function startAllSubscribers(deps) {
|
|
|
119875
119814
|
});
|
|
119876
119815
|
});
|
|
119877
119816
|
const commandRun = startCommandRunSubscriber(deps, onEvent);
|
|
119878
|
-
const workspaceList = startWorkspaceListSubscriber(deps, onEvent);
|
|
119879
119817
|
const gitRequest = startGitRequestSubscriber(deps, onEvent);
|
|
119880
119818
|
const fileTree = startFileTreeRequestSubscriber(deps, onEvent);
|
|
119881
119819
|
const fileTreeRelease = startFileTreeReleaseRequestSubscriber(deps, onEvent);
|
|
@@ -119892,7 +119830,6 @@ function startAllSubscribers(deps) {
|
|
|
119892
119830
|
directHarnessCommand.stop(),
|
|
119893
119831
|
machineCommands.stop(),
|
|
119894
119832
|
commandRun.stop(),
|
|
119895
|
-
workspaceList.stop(),
|
|
119896
119833
|
gitRequest.stop(),
|
|
119897
119834
|
fileTree.stop(),
|
|
119898
119835
|
fileTreeRelease.stop(),
|
|
@@ -119920,7 +119857,6 @@ var init_subscriber_registry = __esm(() => {
|
|
|
119920
119857
|
init_file_write_request();
|
|
119921
119858
|
init_git_request();
|
|
119922
119859
|
init_machine_command_inbox();
|
|
119923
|
-
init_workspace_list();
|
|
119924
119860
|
});
|
|
119925
119861
|
|
|
119926
119862
|
// src/infrastructure/log-server/resolve-env-slug.ts
|
|
@@ -134632,7 +134568,7 @@ async function isChatroomInstalledDefault() {
|
|
|
134632
134568
|
return false;
|
|
134633
134569
|
}
|
|
134634
134570
|
}
|
|
134635
|
-
async function
|
|
134571
|
+
async function createDefaultDeps23() {
|
|
134636
134572
|
const client4 = await getConvexClient();
|
|
134637
134573
|
const fs12 = await import("fs/promises");
|
|
134638
134574
|
return {
|
|
@@ -134707,7 +134643,7 @@ After installation, run this command again.`;
|
|
|
134707
134643
|
});
|
|
134708
134644
|
}
|
|
134709
134645
|
async function installTool(options = {}, deps) {
|
|
134710
|
-
const d = deps ?? await
|
|
134646
|
+
const d = deps ?? await createDefaultDeps23();
|
|
134711
134647
|
const layer = layerFromDeps9(d);
|
|
134712
134648
|
return exports_Effect.runPromise(installToolEffect(options).pipe(exports_Effect.catchAll((err) => handleInstallError(err)), exports_Effect.provide(layer)));
|
|
134713
134649
|
}
|
|
@@ -135328,29 +135264,6 @@ agenticQueryCommand.command("complete").description("Submit the structured agent
|
|
|
135328
135264
|
result
|
|
135329
135265
|
});
|
|
135330
135266
|
});
|
|
135331
|
-
var enhancerCommand = program2.command("enhancer").description("Handoff enhancer commands");
|
|
135332
|
-
enhancerCommand.command("complete").description("Submit the enhanced handoff markdown").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--job-id <id>", "Enhancer job identifier").action(async (options) => {
|
|
135333
|
-
await maybeRequireAuth();
|
|
135334
|
-
const { decode: decode6 } = await Promise.resolve().then(() => exports_decode);
|
|
135335
|
-
const stdinContent = await readStdin();
|
|
135336
|
-
let body;
|
|
135337
|
-
try {
|
|
135338
|
-
const { ENHANCER_STDIN_DELIMITER: ENHANCER_STDIN_DELIMITER2, HANDOFF_MESSAGE_MARKER: HANDOFF_MESSAGE_MARKER2, validateStdinHeredocBody: validateStdinHeredocBody2 } = await Promise.resolve().then(() => (init_stdin_heredoc(), exports_stdin_heredoc));
|
|
135339
|
-
const decoded = decode6(stdinContent, { singleParam: "result" });
|
|
135340
|
-
body = decoded.result;
|
|
135341
|
-
body = body.replace(new RegExp(`^(${HANDOFF_MESSAGE_MARKER2}\\s*)+`, "i"), "").trim();
|
|
135342
|
-
validateStdinHeredocBody2(body, ENHANCER_STDIN_DELIMITER2);
|
|
135343
|
-
} catch (err) {
|
|
135344
|
-
console.error(`❌ Failed to decode stdin: ${err.message}`);
|
|
135345
|
-
process.exit(1);
|
|
135346
|
-
}
|
|
135347
|
-
if (!body?.trim()) {
|
|
135348
|
-
console.error("❌ Enhanced handoff body is empty");
|
|
135349
|
-
process.exit(1);
|
|
135350
|
-
}
|
|
135351
|
-
const { enhancerComplete: enhancerComplete2 } = await Promise.resolve().then(() => (init_complete2(), exports_complete2));
|
|
135352
|
-
await enhancerComplete2(options.chatroomId, { jobId: options.jobId, enhancedContent: body });
|
|
135353
|
-
});
|
|
135354
135267
|
var backlogCommand = program2.command("backlog").description("Manage task queue and backlog");
|
|
135355
135268
|
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) => {
|
|
135356
135269
|
await maybeRequireAuth();
|
|
@@ -135703,4 +135616,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
135703
135616
|
});
|
|
135704
135617
|
program2.parse();
|
|
135705
135618
|
|
|
135706
|
-
//# debugId=
|
|
135619
|
+
//# debugId=7580EDAA7FA535CD64756E2164756E21
|