chatroom-cli 1.101.1 → 1.101.2
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 +172 -236
- package/dist/index.js.map +24 -25
- package/package.json +1 -1
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) {
|
|
@@ -84831,7 +84775,7 @@ var init_v_literals_of = __esm(() => {
|
|
|
84831
84775
|
});
|
|
84832
84776
|
|
|
84833
84777
|
// ../../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;
|
|
84778
|
+
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
84779
|
var init_agent2 = __esm(() => {
|
|
84836
84780
|
init_values();
|
|
84837
84781
|
init_v_literals_of();
|
|
@@ -84862,6 +84806,10 @@ var init_agent2 = __esm(() => {
|
|
|
84862
84806
|
AGENT_START_REASONS = [
|
|
84863
84807
|
"user.start",
|
|
84864
84808
|
"user.restart",
|
|
84809
|
+
"user.manual_spawn",
|
|
84810
|
+
"platform.task_monitor_nudge",
|
|
84811
|
+
"platform.task_start_in_new_session",
|
|
84812
|
+
"platform.pending_task_wake",
|
|
84865
84813
|
"platform.crash_recovery",
|
|
84866
84814
|
"platform.auto_restart_on_new_context",
|
|
84867
84815
|
"platform.restart_offline_on_user_message",
|
|
@@ -84870,12 +84818,25 @@ var init_agent2 = __esm(() => {
|
|
|
84870
84818
|
];
|
|
84871
84819
|
AgentStartReasonEnum = Object.fromEntries(AGENT_START_REASONS.map((r) => [r, r]));
|
|
84872
84820
|
agentStartReasonValidator = v.union(...toLiteralValidators(AGENT_START_REASONS));
|
|
84821
|
+
USER_EXPLICIT_START_REASONS = [
|
|
84822
|
+
AgentStartReasonEnum["user.start"],
|
|
84823
|
+
AgentStartReasonEnum["user.restart"]
|
|
84824
|
+
];
|
|
84825
|
+
EXPLICIT_DAEMON_START_REASONS = [
|
|
84826
|
+
...USER_EXPLICIT_START_REASONS,
|
|
84827
|
+
AgentStartReasonEnum["user.manual_spawn"],
|
|
84828
|
+
AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
84829
|
+
AgentStartReasonEnum["platform.task_start_in_new_session"],
|
|
84830
|
+
"daemon.respawn"
|
|
84831
|
+
];
|
|
84873
84832
|
AGENT_STOP_REASONS = [
|
|
84874
84833
|
"user.stop",
|
|
84875
84834
|
"user.restart",
|
|
84876
84835
|
"platform.dedup",
|
|
84877
84836
|
"platform.team_switch",
|
|
84878
84837
|
"platform.resume_storm",
|
|
84838
|
+
"platform.task_monitor_nudge",
|
|
84839
|
+
"platform.task_start_in_new_session",
|
|
84879
84840
|
"daemon.respawn",
|
|
84880
84841
|
"daemon.shutdown",
|
|
84881
84842
|
"daemon.stop_timeout",
|
|
@@ -100165,8 +100126,6 @@ var init_assigned_task_snapshot_contract = __esm(() => {
|
|
|
100165
100126
|
createdAt: exports_external.number(),
|
|
100166
100127
|
workingDir: exports_external.string().optional(),
|
|
100167
100128
|
assignedTo: exports_external.string().optional(),
|
|
100168
|
-
lastSeenAction: exports_external.string().nullable().optional(),
|
|
100169
|
-
lastStatus: exports_external.string().nullable().optional(),
|
|
100170
100129
|
sessionAugmentation: sessionAugmentationSchema.optional()
|
|
100171
100130
|
};
|
|
100172
100131
|
assignedTaskSignalSchema = exports_external.object(assignedTaskSignalBootstrapFields);
|
|
@@ -100420,9 +100379,6 @@ function logNativeDeliveryMutexSkip(role, chatroomId, taskId) {
|
|
|
100420
100379
|
function logNativeDeliveryInjecting(role, chatroomId, taskId) {
|
|
100421
100380
|
console.log(`[NativeDelivery:inject] ${role}@${chatroomId} task ${taskId} — starting injection`);
|
|
100422
100381
|
}
|
|
100423
|
-
function logNativeDeliveryNoTasks(role, chatroomId) {
|
|
100424
|
-
console.log(`[NativeDelivery:skip] ${role}@${chatroomId} — no pending tasks for role`);
|
|
100425
|
-
}
|
|
100426
100382
|
|
|
100427
100383
|
// src/daemon/entry/native-delivery/native-stale-turn-phase.ts
|
|
100428
100384
|
function isStaleTurnInFlightWhileWaiting(task, slot) {
|
|
@@ -100430,10 +100386,9 @@ function isStaleTurnInFlightWhileWaiting(task, slot) {
|
|
|
100430
100386
|
return false;
|
|
100431
100387
|
if (task.status !== "pending")
|
|
100432
100388
|
return false;
|
|
100433
|
-
return
|
|
100389
|
+
return true;
|
|
100434
100390
|
}
|
|
100435
100391
|
var init_native_stale_turn_phase = __esm(() => {
|
|
100436
|
-
init_participant();
|
|
100437
100392
|
init_check_agent_slot();
|
|
100438
100393
|
});
|
|
100439
100394
|
|
|
@@ -100591,7 +100546,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100591
100546
|
await deps.agentMgr.stop({
|
|
100592
100547
|
chatroomId,
|
|
100593
100548
|
role,
|
|
100594
|
-
reason: "platform.task_start_in_new_session"
|
|
100549
|
+
reason: AgentStopReasonEnum["platform.task_start_in_new_session"]
|
|
100595
100550
|
});
|
|
100596
100551
|
const spawn3 = await deps.agentMgr.ensureRunning({
|
|
100597
100552
|
chatroomId,
|
|
@@ -100599,7 +100554,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100599
100554
|
agentHarness,
|
|
100600
100555
|
model,
|
|
100601
100556
|
workingDir,
|
|
100602
|
-
reason: "platform.task_start_in_new_session",
|
|
100557
|
+
reason: AgentStartReasonEnum["platform.task_start_in_new_session"],
|
|
100603
100558
|
wantResume: false
|
|
100604
100559
|
});
|
|
100605
100560
|
if (!spawn3.success)
|
|
@@ -100640,6 +100595,7 @@ async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
|
100640
100595
|
}
|
|
100641
100596
|
var init_native_cold_session_before_inject = __esm(() => {
|
|
100642
100597
|
init_reliability();
|
|
100598
|
+
init_agent2();
|
|
100643
100599
|
init_participant();
|
|
100644
100600
|
init_api3();
|
|
100645
100601
|
});
|
|
@@ -100836,13 +100792,7 @@ function injectNativeTaskPrompt(task, deps, harnessSessionId, sessionAugmentatio
|
|
|
100836
100792
|
const { role } = agentConfig;
|
|
100837
100793
|
const { prompt, augmentationMode } = yield* loadNativeInjectionPrompt(task, deps);
|
|
100838
100794
|
yield* exports_Effect.tryPromise({
|
|
100839
|
-
try: () => deps.
|
|
100840
|
-
sessionId: deps.sessionId,
|
|
100841
|
-
chatroomId,
|
|
100842
|
-
role,
|
|
100843
|
-
action: NATIVE_TASK_INJECTED_ACTION,
|
|
100844
|
-
taskId
|
|
100845
|
-
}),
|
|
100795
|
+
try: () => deps.lifecycleOutbox ? deps.lifecycleOutbox.enqueue(buildActivityLifecycleFact({ chatroomId, role, action: NATIVE_TASK_INJECTED_ACTION, taskId })) : Promise.reject(new Error("lifecycle outbox missing")),
|
|
100846
100796
|
catch: (err) => err
|
|
100847
100797
|
});
|
|
100848
100798
|
yield* exports_Effect.tryPromise({
|
|
@@ -100996,25 +100946,7 @@ class NativeTaskDeliveryCoordinator {
|
|
|
100996
100946
|
getRoleDeliveryState().resetDeliveryState(chatroomId, role);
|
|
100997
100947
|
}
|
|
100998
100948
|
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
|
-
});
|
|
100949
|
+
reconcileDeliverableWorkForRole(chatroomId, role);
|
|
101018
100950
|
}
|
|
101019
100951
|
reconcileAssignedTasks(params) {
|
|
101020
100952
|
const tasks = filterSnapshotsExcludingRestartInFlight(params.tasks);
|
|
@@ -101032,7 +100964,7 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101032
100964
|
});
|
|
101033
100965
|
for (const row of pendingFirst) {
|
|
101034
100966
|
const { role } = row.agentConfig;
|
|
101035
|
-
|
|
100967
|
+
let slot = agentMgr.getSlot(row.chatroomId, role);
|
|
101036
100968
|
if (row.status === "pending" && slot?.lastInFlightTaskId === row.taskId) {
|
|
101037
100969
|
exports_Effect.runSync(agentMgr.clearLastInFlightTaskIfMatches(row.chatroomId, role, row.taskId));
|
|
101038
100970
|
}
|
|
@@ -101041,9 +100973,10 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101041
100973
|
exports_Effect.runSync(agentMgr.reconcileNativeTurnPhaseIdle(row.chatroomId, role));
|
|
101042
100974
|
}
|
|
101043
100975
|
logNativeDeliveryFallback("stale-turn-phase", role, row.chatroomId, row.taskId);
|
|
100976
|
+
slot = agentMgr.getSlot(row.chatroomId, role) ?? undefined;
|
|
101044
100977
|
}
|
|
101045
100978
|
const blockReason = explainNativeDeliveryBlock(row, {
|
|
101046
|
-
slot
|
|
100979
|
+
slot
|
|
101047
100980
|
});
|
|
101048
100981
|
if (blockReason) {
|
|
101049
100982
|
if (isDeliverableTaskStatus(row.status)) {
|
|
@@ -101085,11 +101018,15 @@ class NativeTaskDeliveryCoordinator {
|
|
|
101085
101018
|
return;
|
|
101086
101019
|
}
|
|
101087
101020
|
const full = mapAssignedTaskView(backend2);
|
|
101021
|
+
const deliverySession = getNativeDeliverySession();
|
|
101022
|
+
if (!deliverySession?.lifecycleOutbox)
|
|
101023
|
+
return;
|
|
101088
101024
|
yield* runNativeInjectionEffect(full, harnessSessionId, {
|
|
101089
101025
|
sessionId: sessionDeps.sessionId,
|
|
101090
101026
|
machineId: sessionDeps.machineId,
|
|
101091
101027
|
logEvent: sessionDeps.logEvent,
|
|
101092
101028
|
backend: sessionDeps.backend,
|
|
101029
|
+
lifecycleOutbox: deliverySession.lifecycleOutbox,
|
|
101093
101030
|
agentMgr: {
|
|
101094
101031
|
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2)),
|
|
101095
101032
|
stop: (opts) => exports_Effect.runPromise(agentMgr.stop(opts)),
|
|
@@ -101118,6 +101055,25 @@ function getNativeTaskDeliveryCoordinator() {
|
|
|
101118
101055
|
coordinator ??= new NativeTaskDeliveryCoordinator;
|
|
101119
101056
|
return coordinator;
|
|
101120
101057
|
}
|
|
101058
|
+
function reconcileDeliverableWorkForRole(chatroomId, role) {
|
|
101059
|
+
if (isRestartOrchestratorInFlight(chatroomId, role))
|
|
101060
|
+
return;
|
|
101061
|
+
const session2 = getNativeDeliverySession();
|
|
101062
|
+
if (!session2)
|
|
101063
|
+
return;
|
|
101064
|
+
const { runtime: runtime4, effectContext: effectContext2, agentMgr, sessionDeps, machineId, taskSnapshotState } = session2;
|
|
101065
|
+
const tasks = taskSnapshotState?.listForRole(chatroomId, role) ?? [];
|
|
101066
|
+
if (tasks.length === 0)
|
|
101067
|
+
return;
|
|
101068
|
+
getNativeTaskDeliveryCoordinator().reconcileAssignedTasks({
|
|
101069
|
+
tasks,
|
|
101070
|
+
runtime: runtime4,
|
|
101071
|
+
effectContext: effectContext2,
|
|
101072
|
+
agentMgr,
|
|
101073
|
+
sessionDeps,
|
|
101074
|
+
machineId
|
|
101075
|
+
});
|
|
101076
|
+
}
|
|
101121
101077
|
function notifyNativeSessionLost(params) {
|
|
101122
101078
|
getNativeTaskDeliveryCoordinator().onSessionLost(params);
|
|
101123
101079
|
}
|
|
@@ -101128,7 +101084,7 @@ function notifyNativeTurnIdle(params) {
|
|
|
101128
101084
|
if (isRestartOrchestratorInFlight(params.chatroomId, params.role))
|
|
101129
101085
|
return;
|
|
101130
101086
|
logNativeDeliveryPrimary(params.role, params.chatroomId);
|
|
101131
|
-
|
|
101087
|
+
reconcileDeliverableWorkForRole(params.chatroomId, params.role);
|
|
101132
101088
|
}
|
|
101133
101089
|
var coordinator;
|
|
101134
101090
|
var init_native_task_delivery_coordinator = __esm(() => {
|
|
@@ -102687,12 +102643,9 @@ async function emitNativeWaitingAfterSpawn(ctx, harness, opts) {
|
|
|
102687
102643
|
return false;
|
|
102688
102644
|
}
|
|
102689
102645
|
try {
|
|
102690
|
-
|
|
102691
|
-
|
|
102692
|
-
|
|
102693
|
-
role: ctx.role,
|
|
102694
|
-
action: NATIVE_WAITING_ACTION
|
|
102695
|
-
});
|
|
102646
|
+
if (!ctx.lifecycleOutbox)
|
|
102647
|
+
throw new Error("lifecycle outbox missing");
|
|
102648
|
+
await ctx.lifecycleOutbox.enqueue(buildActivityLifecycleFact({ chatroomId: ctx.chatroomId, role: ctx.role, action: NATIVE_WAITING_ACTION }));
|
|
102696
102649
|
return true;
|
|
102697
102650
|
} catch (err) {
|
|
102698
102651
|
const error51 = err instanceof Error ? err : new Error(String(err));
|
|
@@ -102846,16 +102799,13 @@ class AgentProcessManager {
|
|
|
102846
102799
|
slot.expectedStopReason = undefined;
|
|
102847
102800
|
slot.expectedStopPid = undefined;
|
|
102848
102801
|
}
|
|
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
102802
|
async ensureRunning(opts) {
|
|
102853
102803
|
if (isChatroomStopScopeActive(opts.chatroomId)) {
|
|
102854
102804
|
return { success: false, error: "stop_in_progress" };
|
|
102855
102805
|
}
|
|
102856
102806
|
const key = agentKey3(opts.chatroomId, opts.role);
|
|
102857
102807
|
const slot = this.getOrCreateSlot(key);
|
|
102858
|
-
if (
|
|
102808
|
+
if (isExplicitDaemonStart(opts.reason)) {
|
|
102859
102809
|
this.bumpStopGeneration(slot);
|
|
102860
102810
|
this.clearStopIntent(slot);
|
|
102861
102811
|
} else if (slot.stopRequested) {
|
|
@@ -104171,7 +104121,8 @@ class AgentProcessManager {
|
|
|
104171
104121
|
backend: this.deps.backend,
|
|
104172
104122
|
sessionId: this.deps.sessionId,
|
|
104173
104123
|
chatroomId,
|
|
104174
|
-
role
|
|
104124
|
+
role,
|
|
104125
|
+
lifecycleOutbox: this.deps.lifecycleOutbox
|
|
104175
104126
|
}, harness, {
|
|
104176
104127
|
onError: (err) => {
|
|
104177
104128
|
console.log(` ⚠️ Failed to emit native:waiting for ${role}: ${err.message}`);
|
|
@@ -104413,6 +104364,7 @@ class AgentProcessManager {
|
|
|
104413
104364
|
var AGENT_EXIT_RETRY_INTERVAL_MS = 1e4, STOPPING_TIMEOUT_MS = 30000;
|
|
104414
104365
|
var init_agent_process_manager = __esm(() => {
|
|
104415
104366
|
init_types();
|
|
104367
|
+
init_agent2();
|
|
104416
104368
|
init_participant();
|
|
104417
104369
|
init_esm();
|
|
104418
104370
|
init_execute_stop_targets_adapter();
|
|
@@ -104457,7 +104409,7 @@ async function discoverModelsForHarness(harness, service3) {
|
|
|
104457
104409
|
async function discoverModels(agentServices) {
|
|
104458
104410
|
return exports_Effect.runPromise(discoverModelsEffect(agentServices));
|
|
104459
104411
|
}
|
|
104460
|
-
function
|
|
104412
|
+
function createDefaultDeps22() {
|
|
104461
104413
|
return {
|
|
104462
104414
|
backend: {
|
|
104463
104415
|
mutation: async () => {
|
|
@@ -104823,7 +104775,7 @@ var init_init_daemon = __esm(() => {
|
|
|
104823
104775
|
convexUrl,
|
|
104824
104776
|
agentServices,
|
|
104825
104777
|
cachedModels,
|
|
104826
|
-
deps:
|
|
104778
|
+
deps: createDefaultDeps22()
|
|
104827
104779
|
});
|
|
104828
104780
|
yield* registerEventListenersEffect().pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
104829
104781
|
yield* logStartupEffect(cachedModels).pipe(exports_Effect.provide(daemonSessionToLayers(init2)));
|
|
@@ -111431,6 +111383,9 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111431
111383
|
let service3 = null;
|
|
111432
111384
|
let abortController = null;
|
|
111433
111385
|
let spawnHandle = null;
|
|
111386
|
+
let agentEndSeen = false;
|
|
111387
|
+
let resolveAgentEnd;
|
|
111388
|
+
let agentEndPromise = Promise.resolve();
|
|
111434
111389
|
let log4 = createEnhancerLogWriter(logSink, {
|
|
111435
111390
|
chatroomId: job.chatroomId,
|
|
111436
111391
|
harness: "unknown"
|
|
@@ -111445,9 +111400,10 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111445
111400
|
return;
|
|
111446
111401
|
claimed = true;
|
|
111447
111402
|
log4.write(`claimed job=${job.jobId} chatroom=${job.chatroomId}`);
|
|
111448
|
-
const payload = await backend2.query(api.daemon.enhancer.index.
|
|
111403
|
+
const payload = await backend2.query(api.daemon.enhancer.index.getTaskDeliveryForJob, {
|
|
111449
111404
|
sessionId,
|
|
111450
|
-
jobId: job.jobId
|
|
111405
|
+
jobId: job.jobId,
|
|
111406
|
+
convexUrl
|
|
111451
111407
|
});
|
|
111452
111408
|
chatroomId = payload.chatroomId;
|
|
111453
111409
|
jobId = payload.jobId;
|
|
@@ -111469,7 +111425,7 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111469
111425
|
}
|
|
111470
111426
|
const spawned = await service3.spawn({
|
|
111471
111427
|
workingDir: payload.workingDir,
|
|
111472
|
-
prompt: createSpawnPrompt(payload.
|
|
111428
|
+
prompt: createSpawnPrompt(payload.taskDeliveryOutput),
|
|
111473
111429
|
systemPrompt: payload.systemPrompt,
|
|
111474
111430
|
model: payload.model,
|
|
111475
111431
|
context: {
|
|
@@ -111498,6 +111454,15 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111498
111454
|
spawned.onLogLine?.((line) => {
|
|
111499
111455
|
log4.write(line);
|
|
111500
111456
|
});
|
|
111457
|
+
agentEndPromise = new Promise((resolve5) => {
|
|
111458
|
+
resolveAgentEnd = resolve5;
|
|
111459
|
+
});
|
|
111460
|
+
spawned.onAgentEnd?.(() => {
|
|
111461
|
+
if (agentEndSeen)
|
|
111462
|
+
return;
|
|
111463
|
+
agentEndSeen = true;
|
|
111464
|
+
resolveAgentEnd?.();
|
|
111465
|
+
});
|
|
111501
111466
|
await waitForEnhancerJobResolution({
|
|
111502
111467
|
sessionId,
|
|
111503
111468
|
chatroomId: payload.chatroomId,
|
|
@@ -111543,6 +111508,11 @@ async function processEnhancerJobForSpawn(sessionId, machineId, convexUrl, wsCli
|
|
|
111543
111508
|
if (spawnHandle)
|
|
111544
111509
|
unregisterEnhancerSpawn(spawnHandle);
|
|
111545
111510
|
if (spawnResult && service3) {
|
|
111511
|
+
if (!agentEndSeen)
|
|
111512
|
+
await Promise.race([
|
|
111513
|
+
agentEndPromise,
|
|
111514
|
+
new Promise((resolve5) => setTimeout(resolve5, ENHANCER_AGENT_END_GRACE_MS))
|
|
111515
|
+
]);
|
|
111546
111516
|
try {
|
|
111547
111517
|
await service3.stop(spawnResult.pid);
|
|
111548
111518
|
} catch {}
|
|
@@ -117490,14 +117460,18 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
117490
117460
|
const { chatroomId, agentConfig, role, workingDir, wantResume } = ctx;
|
|
117491
117461
|
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
117492
117462
|
exports_Runtime.runFork(runtime4)(exports_Effect.gen(function* () {
|
|
117493
|
-
yield* agentMgr.stop({
|
|
117463
|
+
yield* agentMgr.stop({
|
|
117464
|
+
chatroomId,
|
|
117465
|
+
role,
|
|
117466
|
+
reason: AgentStopReasonEnum["platform.task_monitor_nudge"]
|
|
117467
|
+
});
|
|
117494
117468
|
yield* agentMgr.ensureRunning({
|
|
117495
117469
|
chatroomId,
|
|
117496
117470
|
role,
|
|
117497
117471
|
agentHarness: agentConfig.agentHarness,
|
|
117498
117472
|
model: agentConfig.model,
|
|
117499
117473
|
workingDir,
|
|
117500
|
-
reason: "platform.task_monitor_nudge",
|
|
117474
|
+
reason: AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
117501
117475
|
wantResume,
|
|
117502
117476
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117503
117477
|
taskId: task.taskId
|
|
@@ -117544,7 +117518,7 @@ function runNativeReviveEffect(task, runtime4, effectContext2, agentMgr) {
|
|
|
117544
117518
|
agentHarness: agentConfig.agentHarness,
|
|
117545
117519
|
model: agentConfig.model,
|
|
117546
117520
|
workingDir,
|
|
117547
|
-
reason: "platform.task_monitor_nudge",
|
|
117521
|
+
reason: AgentStartReasonEnum["platform.task_monitor_nudge"],
|
|
117548
117522
|
wantResume,
|
|
117549
117523
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117550
117524
|
taskId: task.taskId
|
|
@@ -117564,7 +117538,7 @@ function runNativeWakeEffect(task, runtime4, effectContext2, agentMgr) {
|
|
|
117564
117538
|
agentHarness: agentConfig.agentHarness,
|
|
117565
117539
|
model: agentConfig.model,
|
|
117566
117540
|
workingDir,
|
|
117567
|
-
reason: "platform.pending_task_wake",
|
|
117541
|
+
reason: AgentStartReasonEnum["platform.pending_task_wake"],
|
|
117568
117542
|
wantResume,
|
|
117569
117543
|
lifecycleRevision: task.agentConfig.configLifecycleRevision,
|
|
117570
117544
|
taskId: task.taskId
|
|
@@ -117650,6 +117624,7 @@ async function processTasksUpdate(runtime4, effectContext2, cooldown, agentMgr,
|
|
|
117650
117624
|
await nudgeStuckTasks(filteredTasks, now, cooldown, runtime4, effectContext2, agentMgr, sessionDeps, machineId);
|
|
117651
117625
|
}
|
|
117652
117626
|
var init_task_delivery_processor = __esm(() => {
|
|
117627
|
+
init_agent2();
|
|
117653
117628
|
init_parse_session_augmentation();
|
|
117654
117629
|
init_esm();
|
|
117655
117630
|
init_native_task_delivery_coordinator();
|
|
@@ -117989,7 +117964,7 @@ async function bootstrapMachineAssignedTaskSnapshots(deps) {
|
|
|
117989
117964
|
return;
|
|
117990
117965
|
await processTasksUpdate(deps.runtime, deps.effectContext, deps.cooldown, deps.agentMgr, deps.sessionDeps, deps.machineId, "bootstrap", { snapshots: enrichSnapshotsWithOperational(tasks) });
|
|
117991
117966
|
}
|
|
117992
|
-
function
|
|
117967
|
+
function isAbortError2(error51) {
|
|
117993
117968
|
return error51 instanceof Error && error51.name === "AbortError";
|
|
117994
117969
|
}
|
|
117995
117970
|
async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
@@ -117999,7 +117974,7 @@ async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
|
117999
117974
|
await runTaskInbox(options, onUpdate);
|
|
118000
117975
|
return;
|
|
118001
117976
|
} catch (error51) {
|
|
118002
|
-
if (isStopped() ||
|
|
117977
|
+
if (isStopped() || isAbortError2(error51))
|
|
118003
117978
|
return;
|
|
118004
117979
|
console.warn(`[TaskInbox] loop error, restarting in ${backoffMs}ms:`, error51);
|
|
118005
117980
|
await new Promise((resolve8) => setTimeout(resolve8, backoffMs));
|
|
@@ -118010,6 +117985,8 @@ async function runInboxLoopWithRestart(options, onUpdate, isStopped) {
|
|
|
118010
117985
|
var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_RESTART_MAX_MS = 30000, startTaskInboxEffect = (wsClient2) => exports_Effect.gen(function* () {
|
|
118011
117986
|
const session2 = yield* DaemonSessionService;
|
|
118012
117987
|
const agentMgr = yield* DaemonAgentProcessManagerService;
|
|
117988
|
+
const lifecycleOutboxService = yield* AgentLifecycleOutboxService;
|
|
117989
|
+
const lifecycleOutbox = { enqueue: (fact) => exports_Effect.runPromise(lifecycleOutboxService.enqueue(fact)) };
|
|
118013
117990
|
const effectContext2 = yield* exports_Effect.context();
|
|
118014
117991
|
const runtime4 = yield* exports_Effect.runtime();
|
|
118015
117992
|
const sessionDeps = {
|
|
@@ -118039,7 +118016,8 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118039
118016
|
sessionDeps,
|
|
118040
118017
|
machineId: session2.machineId,
|
|
118041
118018
|
taskSnapshotState,
|
|
118042
|
-
agentOperationalReadModel
|
|
118019
|
+
agentOperationalReadModel,
|
|
118020
|
+
lifecycleOutbox
|
|
118043
118021
|
});
|
|
118044
118022
|
const cooldown = new RecoveryCooldown;
|
|
118045
118023
|
let inboxUpdateInFlight = false;
|
|
@@ -118119,6 +118097,7 @@ var NATIVE_DELIVERY_RECONCILE_MS = 1e4, INBOX_RESTART_INITIAL_MS = 1000, INBOX_R
|
|
|
118119
118097
|
var init_task_inbox_runtime = __esm(() => {
|
|
118120
118098
|
init_esm();
|
|
118121
118099
|
init_daemon_services();
|
|
118100
|
+
init_daemon_services();
|
|
118122
118101
|
init_api3();
|
|
118123
118102
|
init_native_delivery_session_registry();
|
|
118124
118103
|
init_task_delivery_processor();
|
|
@@ -118504,34 +118483,14 @@ var init_on_daemon_shutdown = __esm(() => {
|
|
|
118504
118483
|
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
118484
|
const activeAgents = agentPm.listActive();
|
|
118506
118485
|
if (activeAgents.length > 0) {
|
|
118507
|
-
console.log(`[${formatTimestamp()}] Stopping ${activeAgents.length} agent(s)...`);
|
|
118508
|
-
const chatroomIds = [...new Set(activeAgents.map(({ chatroomId }) => chatroomId))];
|
|
118486
|
+
console.log(`[${formatTimestamp()}] Stopping ${activeAgents.length} agent(s) locally...`);
|
|
118509
118487
|
let totalStopped = 0;
|
|
118510
118488
|
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(() => {
|
|
118489
|
+
yield* exports_Effect.all(activeAgents.map(({ chatroomId, role }) => agentPm.stop({ chatroomId, role, reason: "daemon.shutdown" }).pipe(exports_Effect.tap(() => exports_Effect.sync(() => {
|
|
118490
|
+
totalStopped += 1;
|
|
118491
|
+
})), exports_Effect.catchAll((e) => exports_Effect.sync(() => {
|
|
118533
118492
|
totalFailed += 1;
|
|
118534
|
-
console.log(` ⚠️ Failed
|
|
118493
|
+
console.log(` ⚠️ Failed to stop ${role}@${chatroomId}: ${e.message}`);
|
|
118535
118494
|
})))), { concurrency: "unbounded" });
|
|
118536
118495
|
if (totalFailed > 0) {
|
|
118537
118496
|
console.log(`[${formatTimestamp()}] Shutdown stops: ${totalStopped} stopped, ${totalFailed} failed`);
|
|
@@ -134632,7 +134591,7 @@ async function isChatroomInstalledDefault() {
|
|
|
134632
134591
|
return false;
|
|
134633
134592
|
}
|
|
134634
134593
|
}
|
|
134635
|
-
async function
|
|
134594
|
+
async function createDefaultDeps23() {
|
|
134636
134595
|
const client4 = await getConvexClient();
|
|
134637
134596
|
const fs12 = await import("fs/promises");
|
|
134638
134597
|
return {
|
|
@@ -134707,7 +134666,7 @@ After installation, run this command again.`;
|
|
|
134707
134666
|
});
|
|
134708
134667
|
}
|
|
134709
134668
|
async function installTool(options = {}, deps) {
|
|
134710
|
-
const d = deps ?? await
|
|
134669
|
+
const d = deps ?? await createDefaultDeps23();
|
|
134711
134670
|
const layer = layerFromDeps9(d);
|
|
134712
134671
|
return exports_Effect.runPromise(installToolEffect(options).pipe(exports_Effect.catchAll((err) => handleInstallError(err)), exports_Effect.provide(layer)));
|
|
134713
134672
|
}
|
|
@@ -135328,29 +135287,6 @@ agenticQueryCommand.command("complete").description("Submit the structured agent
|
|
|
135328
135287
|
result
|
|
135329
135288
|
});
|
|
135330
135289
|
});
|
|
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
135290
|
var backlogCommand = program2.command("backlog").description("Manage task queue and backlog");
|
|
135355
135291
|
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
135292
|
await maybeRequireAuth();
|
|
@@ -135703,4 +135639,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
135703
135639
|
});
|
|
135704
135640
|
program2.parse();
|
|
135705
135641
|
|
|
135706
|
-
//# debugId=
|
|
135642
|
+
//# debugId=FD452FCC0B1266C364756E2164756E21
|