chatroom-cli 1.96.1 → 1.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +252 -108
- package/dist/index.js.map +12 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -98898,7 +98898,15 @@ var init_team_agent_settings = __esm(() => {
|
|
|
98898
98898
|
});
|
|
98899
98899
|
|
|
98900
98900
|
// ../../services/backend/src/domain/handoff/parse-session-augmentation.ts
|
|
98901
|
-
function
|
|
98901
|
+
function resolveSessionAugmentationForTask(task, role) {
|
|
98902
|
+
if (task.startInNewSession !== undefined)
|
|
98903
|
+
return task.startInNewSession ? "new_session" : "none";
|
|
98904
|
+
return resolveSessionAugmentationForRole(role);
|
|
98905
|
+
}
|
|
98906
|
+
function shouldEmitSessionAugmentation(role, mode) {
|
|
98907
|
+
return roleSupportsSessionAugmentation(role) || mode === "new_session";
|
|
98908
|
+
}
|
|
98909
|
+
function resolveSessionAugmentationForRole(role) {
|
|
98902
98910
|
if (!roleSupportsSessionAugmentation(role))
|
|
98903
98911
|
return "none";
|
|
98904
98912
|
return "new_session";
|
|
@@ -98913,6 +98921,71 @@ var init_parse_session_augmentation = __esm(() => {
|
|
|
98913
98921
|
init_team_agent_settings();
|
|
98914
98922
|
});
|
|
98915
98923
|
|
|
98924
|
+
// src/daemon/entry/native-delivery/native-cold-session-before-inject.ts
|
|
98925
|
+
function sleep5(ms) {
|
|
98926
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
98927
|
+
}
|
|
98928
|
+
async function waitForHarnessSessionId(agentMgr, chatroomId, role) {
|
|
98929
|
+
const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
|
|
98930
|
+
while (Date.now() < deadline) {
|
|
98931
|
+
const id3 = agentMgr.getSlot(chatroomId, role)?.harnessSessionId;
|
|
98932
|
+
if (id3)
|
|
98933
|
+
return id3;
|
|
98934
|
+
await sleep5(100);
|
|
98935
|
+
}
|
|
98936
|
+
return null;
|
|
98937
|
+
}
|
|
98938
|
+
async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
98939
|
+
if (!task.startInNewSession)
|
|
98940
|
+
return null;
|
|
98941
|
+
const { chatroomId, agentConfig, taskId } = task;
|
|
98942
|
+
const { role, agentHarness, model, workingDir } = agentConfig;
|
|
98943
|
+
if (!workingDir || !model)
|
|
98944
|
+
return null;
|
|
98945
|
+
await deps.agentMgr.stop({
|
|
98946
|
+
chatroomId,
|
|
98947
|
+
role,
|
|
98948
|
+
reason: "platform.task_start_in_new_session"
|
|
98949
|
+
});
|
|
98950
|
+
const spawn3 = await deps.agentMgr.ensureRunning({
|
|
98951
|
+
chatroomId,
|
|
98952
|
+
role,
|
|
98953
|
+
agentHarness,
|
|
98954
|
+
model,
|
|
98955
|
+
workingDir,
|
|
98956
|
+
reason: "platform.task_start_in_new_session",
|
|
98957
|
+
wantResume: false
|
|
98958
|
+
});
|
|
98959
|
+
if (!spawn3.success)
|
|
98960
|
+
return null;
|
|
98961
|
+
const harnessSessionId = await waitForHarnessSessionId(deps.agentMgr, chatroomId, role);
|
|
98962
|
+
if (!harnessSessionId)
|
|
98963
|
+
return null;
|
|
98964
|
+
await deps.backend.mutation(api.participants.join, {
|
|
98965
|
+
sessionId: deps.sessionId,
|
|
98966
|
+
chatroomId,
|
|
98967
|
+
role,
|
|
98968
|
+
action: NATIVE_WAITING_ACTION,
|
|
98969
|
+
taskId
|
|
98970
|
+
});
|
|
98971
|
+
await deps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
98972
|
+
sessionId: deps.sessionId,
|
|
98973
|
+
machineId: deps.machineId,
|
|
98974
|
+
chatroomId,
|
|
98975
|
+
role,
|
|
98976
|
+
taskId,
|
|
98977
|
+
mode: "new_session",
|
|
98978
|
+
newSessionStarted: true,
|
|
98979
|
+
harnessSessionId
|
|
98980
|
+
});
|
|
98981
|
+
return harnessSessionId;
|
|
98982
|
+
}
|
|
98983
|
+
var init_native_cold_session_before_inject = __esm(() => {
|
|
98984
|
+
init_reliability();
|
|
98985
|
+
init_participant();
|
|
98986
|
+
init_api3();
|
|
98987
|
+
});
|
|
98988
|
+
|
|
98916
98989
|
// src/daemon/entry/native-delivery/native-task-injector.ts
|
|
98917
98990
|
async function emitTaskDeliveryFailed(deps, args2) {
|
|
98918
98991
|
try {
|
|
@@ -98926,35 +98999,132 @@ async function emitTaskDeliveryFailed(deps, args2) {
|
|
|
98926
98999
|
});
|
|
98927
99000
|
} catch {}
|
|
98928
99001
|
}
|
|
98929
|
-
function
|
|
99002
|
+
function reportDeliveryFailureEffect(deps, args2) {
|
|
99003
|
+
return exports_Effect.tryPromise({
|
|
99004
|
+
try: () => emitTaskDeliveryFailed(deps, args2),
|
|
99005
|
+
catch: () => {
|
|
99006
|
+
return;
|
|
99007
|
+
}
|
|
99008
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99009
|
+
}
|
|
99010
|
+
function applyColdSessionIfRequested(task, deps, chatroomId, role, taskId) {
|
|
99011
|
+
return exports_Effect.gen(function* () {
|
|
99012
|
+
const coldSessionResult = yield* exports_Effect.tryPromise({
|
|
99013
|
+
try: () => ensureColdSessionBeforeNativeInject(task, deps),
|
|
99014
|
+
catch: (err) => err
|
|
99015
|
+
}).pipe(exports_Effect.either);
|
|
99016
|
+
if (coldSessionResult._tag === "Left" || !coldSessionResult.right) {
|
|
99017
|
+
const error51 = coldSessionResult._tag === "Left" ? getErrorMessage(coldSessionResult.left) : "cold session restart failed";
|
|
99018
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99019
|
+
chatroomId,
|
|
99020
|
+
role,
|
|
99021
|
+
taskId,
|
|
99022
|
+
error: error51
|
|
99023
|
+
});
|
|
99024
|
+
return { failed: true, error: error51 };
|
|
99025
|
+
}
|
|
99026
|
+
return { harnessSessionId: coldSessionResult.right };
|
|
99027
|
+
});
|
|
99028
|
+
}
|
|
99029
|
+
function claimPendingTaskIfNeeded(task, deps) {
|
|
98930
99030
|
return exports_Effect.gen(function* () {
|
|
98931
|
-
|
|
99031
|
+
if (task.status !== "pending")
|
|
99032
|
+
return;
|
|
99033
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
98932
99034
|
const { role } = agentConfig;
|
|
98933
|
-
|
|
98934
|
-
|
|
98935
|
-
|
|
98936
|
-
|
|
98937
|
-
|
|
98938
|
-
|
|
98939
|
-
|
|
98940
|
-
|
|
98941
|
-
|
|
98942
|
-
|
|
98943
|
-
|
|
98944
|
-
|
|
98945
|
-
|
|
98946
|
-
|
|
98947
|
-
|
|
98948
|
-
|
|
98949
|
-
|
|
98950
|
-
|
|
98951
|
-
|
|
98952
|
-
|
|
98953
|
-
|
|
98954
|
-
|
|
98955
|
-
|
|
98956
|
-
|
|
99035
|
+
const claimResult = yield* exports_Effect.tryPromise({
|
|
99036
|
+
try: () => deps.backend.mutation(api.tasks.claimTask, {
|
|
99037
|
+
sessionId: deps.sessionId,
|
|
99038
|
+
chatroomId,
|
|
99039
|
+
role,
|
|
99040
|
+
taskId
|
|
99041
|
+
}),
|
|
99042
|
+
catch: (err) => err
|
|
99043
|
+
}).pipe(exports_Effect.either);
|
|
99044
|
+
if (claimResult._tag === "Left") {
|
|
99045
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99046
|
+
chatroomId,
|
|
99047
|
+
role,
|
|
99048
|
+
taskId,
|
|
99049
|
+
error: getErrorMessage(claimResult.left)
|
|
99050
|
+
});
|
|
99051
|
+
return yield* exports_Effect.fail(claimResult.left);
|
|
99052
|
+
}
|
|
99053
|
+
});
|
|
99054
|
+
}
|
|
99055
|
+
function resolveHarnessSessionForInject(task, deps, initialHarnessSessionId) {
|
|
99056
|
+
return exports_Effect.gen(function* () {
|
|
99057
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99058
|
+
const { role } = agentConfig;
|
|
99059
|
+
if (!task.startInNewSession) {
|
|
99060
|
+
return { harnessSessionId: initialHarnessSessionId, sessionAugmentationEmitted: false };
|
|
99061
|
+
}
|
|
99062
|
+
const coldSession = yield* applyColdSessionIfRequested(task, deps, chatroomId, role, taskId);
|
|
99063
|
+
if ("failed" in coldSession) {
|
|
99064
|
+
return yield* exports_Effect.fail(new Error(coldSession.error));
|
|
99065
|
+
}
|
|
99066
|
+
return {
|
|
99067
|
+
harnessSessionId: coldSession.harnessSessionId,
|
|
99068
|
+
sessionAugmentationEmitted: true
|
|
99069
|
+
};
|
|
99070
|
+
});
|
|
99071
|
+
}
|
|
99072
|
+
function emitSessionAugmentationIfNeeded(task, deps, harnessSessionId, sessionAugmentationEmitted, augmentationMode) {
|
|
99073
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99074
|
+
const { role } = agentConfig;
|
|
99075
|
+
if (!shouldEmitSessionAugmentation(role, augmentationMode) || sessionAugmentationEmitted) {
|
|
99076
|
+
return exports_Effect.void;
|
|
99077
|
+
}
|
|
99078
|
+
return exports_Effect.tryPromise({
|
|
99079
|
+
try: () => deps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
99080
|
+
sessionId: deps.sessionId,
|
|
99081
|
+
machineId: deps.machineId,
|
|
99082
|
+
chatroomId,
|
|
99083
|
+
role,
|
|
99084
|
+
taskId,
|
|
99085
|
+
mode: augmentationMode,
|
|
99086
|
+
newSessionStarted: sessionAugmentationNewSessionStarted(augmentationMode),
|
|
99087
|
+
harnessSessionId
|
|
99088
|
+
}),
|
|
99089
|
+
catch: (err) => err
|
|
99090
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99091
|
+
}
|
|
99092
|
+
function resumeHarnessWithPrompt(task, deps, prompt) {
|
|
99093
|
+
return exports_Effect.gen(function* () {
|
|
99094
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99095
|
+
const { role } = agentConfig;
|
|
99096
|
+
const resumeResult = yield* exports_Effect.tryPromise({
|
|
99097
|
+
try: () => deps.agentMgr.resumeTurnForSlot({ chatroomId, role, prompt }),
|
|
99098
|
+
catch: (err) => err
|
|
99099
|
+
}).pipe(exports_Effect.either);
|
|
99100
|
+
if (resumeResult._tag === "Left") {
|
|
99101
|
+
const error51 = getErrorMessage(resumeResult.left);
|
|
99102
|
+
console.warn(`[NativeTaskInjector] resumeTurn failed for ${role}@${chatroomId}: ${error51}`);
|
|
99103
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99104
|
+
chatroomId,
|
|
99105
|
+
role,
|
|
99106
|
+
taskId,
|
|
99107
|
+
error: error51
|
|
99108
|
+
});
|
|
99109
|
+
return;
|
|
98957
99110
|
}
|
|
99111
|
+
yield* exports_Effect.tryPromise({
|
|
99112
|
+
try: () => deps.backend.mutation(api.machines.emitTaskDelivered, {
|
|
99113
|
+
sessionId: deps.sessionId,
|
|
99114
|
+
machineId: deps.machineId,
|
|
99115
|
+
chatroomId,
|
|
99116
|
+
role,
|
|
99117
|
+
taskId
|
|
99118
|
+
}),
|
|
99119
|
+
catch: (err) => err
|
|
99120
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99121
|
+
deps.onTaskDelivered?.({ chatroomId, role, taskId });
|
|
99122
|
+
});
|
|
99123
|
+
}
|
|
99124
|
+
function loadNativeInjectionPrompt(task, deps) {
|
|
99125
|
+
return exports_Effect.gen(function* () {
|
|
99126
|
+
const { chatroomId, taskId, taskContent, agentConfig } = task;
|
|
99127
|
+
const { role } = agentConfig;
|
|
98958
99128
|
const deliveryResult = yield* exports_Effect.tryPromise({
|
|
98959
99129
|
try: () => deps.backend.query(api.messages.getTaskDeliveryPrompt, {
|
|
98960
99130
|
sessionId: deps.sessionId,
|
|
@@ -98966,25 +99136,29 @@ function runNativeInjectionEffect(task, harnessSessionId, deps) {
|
|
|
98966
99136
|
catch: (err) => err
|
|
98967
99137
|
}).pipe(exports_Effect.either);
|
|
98968
99138
|
if (deliveryResult._tag === "Left") {
|
|
98969
|
-
yield*
|
|
98970
|
-
|
|
98971
|
-
|
|
98972
|
-
|
|
98973
|
-
|
|
98974
|
-
|
|
98975
|
-
}),
|
|
98976
|
-
catch: () => {
|
|
98977
|
-
return;
|
|
98978
|
-
}
|
|
98979
|
-
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99139
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99140
|
+
chatroomId,
|
|
99141
|
+
role,
|
|
99142
|
+
taskId,
|
|
99143
|
+
error: getErrorMessage(deliveryResult.left)
|
|
99144
|
+
});
|
|
98980
99145
|
return yield* exports_Effect.fail(deliveryResult.left);
|
|
98981
99146
|
}
|
|
98982
|
-
const
|
|
98983
|
-
|
|
98984
|
-
|
|
98985
|
-
|
|
98986
|
-
|
|
98987
|
-
|
|
99147
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: taskContent, startInNewSession: task.startInNewSession }, role);
|
|
99148
|
+
return {
|
|
99149
|
+
augmentationMode,
|
|
99150
|
+
prompt: buildNativeInjectionPrompt({
|
|
99151
|
+
taskDeliveryOutput: deliveryResult.right.fullCliOutput,
|
|
99152
|
+
augmentationMode
|
|
99153
|
+
})
|
|
99154
|
+
};
|
|
99155
|
+
});
|
|
99156
|
+
}
|
|
99157
|
+
function injectNativeTaskPrompt(task, deps, harnessSessionId, sessionAugmentationEmitted) {
|
|
99158
|
+
return exports_Effect.gen(function* () {
|
|
99159
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99160
|
+
const { role } = agentConfig;
|
|
99161
|
+
const { prompt, augmentationMode } = yield* loadNativeInjectionPrompt(task, deps);
|
|
98988
99162
|
yield* exports_Effect.tryPromise({
|
|
98989
99163
|
try: () => deps.backend.mutation(api.participants.join, {
|
|
98990
99164
|
sessionId: deps.sessionId,
|
|
@@ -99006,59 +99180,22 @@ function runNativeInjectionEffect(task, harnessSessionId, deps) {
|
|
|
99006
99180
|
}),
|
|
99007
99181
|
catch: (err) => err
|
|
99008
99182
|
});
|
|
99009
|
-
|
|
99010
|
-
|
|
99011
|
-
|
|
99012
|
-
|
|
99013
|
-
|
|
99014
|
-
|
|
99015
|
-
|
|
99016
|
-
|
|
99017
|
-
|
|
99018
|
-
newSessionStarted: sessionAugmentationNewSessionStarted(augmentationMode),
|
|
99019
|
-
harnessSessionId
|
|
99020
|
-
}),
|
|
99021
|
-
catch: (err) => err
|
|
99022
|
-
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99023
|
-
}
|
|
99024
|
-
const resumeResult = yield* exports_Effect.tryPromise({
|
|
99025
|
-
try: () => deps.agentMgr.resumeTurnForSlot({ chatroomId, role, prompt }),
|
|
99026
|
-
catch: (err) => err
|
|
99027
|
-
}).pipe(exports_Effect.either);
|
|
99028
|
-
if (resumeResult._tag === "Left") {
|
|
99029
|
-
const error51 = getErrorMessage(resumeResult.left);
|
|
99030
|
-
console.warn(`[NativeTaskInjector] resumeTurn failed for ${role}@${chatroomId}: ${error51}`);
|
|
99031
|
-
yield* exports_Effect.tryPromise({
|
|
99032
|
-
try: () => emitTaskDeliveryFailed(deps, {
|
|
99033
|
-
chatroomId,
|
|
99034
|
-
role,
|
|
99035
|
-
taskId,
|
|
99036
|
-
error: error51
|
|
99037
|
-
}),
|
|
99038
|
-
catch: () => {
|
|
99039
|
-
return;
|
|
99040
|
-
}
|
|
99041
|
-
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99042
|
-
return;
|
|
99043
|
-
}
|
|
99044
|
-
yield* exports_Effect.tryPromise({
|
|
99045
|
-
try: () => deps.backend.mutation(api.machines.emitTaskDelivered, {
|
|
99046
|
-
sessionId: deps.sessionId,
|
|
99047
|
-
machineId: deps.machineId,
|
|
99048
|
-
chatroomId,
|
|
99049
|
-
role,
|
|
99050
|
-
taskId
|
|
99051
|
-
}),
|
|
99052
|
-
catch: (err) => err
|
|
99053
|
-
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99054
|
-
deps.onTaskDelivered?.({ chatroomId, role, taskId });
|
|
99183
|
+
yield* emitSessionAugmentationIfNeeded(task, deps, harnessSessionId, sessionAugmentationEmitted, augmentationMode);
|
|
99184
|
+
yield* resumeHarnessWithPrompt(task, deps, prompt);
|
|
99185
|
+
});
|
|
99186
|
+
}
|
|
99187
|
+
function runNativeInjectionEffect(task, initialHarnessSessionId, deps) {
|
|
99188
|
+
return exports_Effect.gen(function* () {
|
|
99189
|
+
yield* claimPendingTaskIfNeeded(task, deps);
|
|
99190
|
+
const session2 = yield* resolveHarnessSessionForInject(task, deps, initialHarnessSessionId);
|
|
99191
|
+
yield* injectNativeTaskPrompt(task, deps, session2.harnessSessionId, session2.sessionAugmentationEmitted);
|
|
99055
99192
|
});
|
|
99056
99193
|
}
|
|
99057
99194
|
var init_native_task_injector = __esm(() => {
|
|
99058
99195
|
init_participant();
|
|
99059
|
-
init_team_agent_settings();
|
|
99060
99196
|
init_parse_session_augmentation();
|
|
99061
99197
|
init_esm();
|
|
99198
|
+
init_native_cold_session_before_inject();
|
|
99062
99199
|
init_native_task_injector_logic();
|
|
99063
99200
|
init_api3();
|
|
99064
99201
|
init_convex_error();
|
|
@@ -99089,7 +99226,8 @@ function mapAssignedTaskSnapshot(row) {
|
|
|
99089
99226
|
function mapAssignedTaskView(row) {
|
|
99090
99227
|
return {
|
|
99091
99228
|
...mapAssignedTaskSnapshot(row),
|
|
99092
|
-
taskContent: row.taskContent
|
|
99229
|
+
taskContent: row.taskContent,
|
|
99230
|
+
startInNewSession: row.startInNewSession
|
|
99093
99231
|
};
|
|
99094
99232
|
}
|
|
99095
99233
|
function mapAssignedTaskSnapshotList(rows) {
|
|
@@ -99288,7 +99426,10 @@ class NativeTaskDeliveryCoordinator {
|
|
|
99288
99426
|
machineId: sessionDeps.machineId,
|
|
99289
99427
|
backend: sessionDeps.backend,
|
|
99290
99428
|
agentMgr: {
|
|
99291
|
-
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2))
|
|
99429
|
+
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2)),
|
|
99430
|
+
stop: (opts) => exports_Effect.runPromise(agentMgr.stop(opts)),
|
|
99431
|
+
ensureRunning: (opts) => exports_Effect.runPromise(agentMgr.ensureRunning(opts)),
|
|
99432
|
+
getSlot: (chatroomId, role2) => agentMgr.getSlot(chatroomId, role2)
|
|
99292
99433
|
},
|
|
99293
99434
|
convexUrl: sessionDeps.convexUrl,
|
|
99294
99435
|
onTaskDelivered: ({ chatroomId, role: role2, taskId: deliveredTaskId }) => {
|
|
@@ -99363,10 +99504,10 @@ async function emitPhase(deps, event, phase, detail) {
|
|
|
99363
99504
|
detail
|
|
99364
99505
|
});
|
|
99365
99506
|
}
|
|
99366
|
-
function
|
|
99507
|
+
function sleep6(ms) {
|
|
99367
99508
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
99368
99509
|
}
|
|
99369
|
-
async function
|
|
99510
|
+
async function waitForHarnessSessionId2(deps, event, pid) {
|
|
99370
99511
|
const initial = deps.agentMgr.getSlot(event.chatroomId, event.role);
|
|
99371
99512
|
if (initial?.harnessSessionId) {
|
|
99372
99513
|
return initial.harnessSessionId;
|
|
@@ -99377,7 +99518,7 @@ async function waitForHarnessSessionId(deps, event, pid) {
|
|
|
99377
99518
|
if (slot?.harnessSessionId) {
|
|
99378
99519
|
return slot.harnessSessionId;
|
|
99379
99520
|
}
|
|
99380
|
-
await
|
|
99521
|
+
await sleep6(100);
|
|
99381
99522
|
}
|
|
99382
99523
|
await deps.agentMgr.stop({
|
|
99383
99524
|
chatroomId: event.chatroomId,
|
|
@@ -99443,7 +99584,10 @@ async function deliverOneTask(deps, event, snapshot) {
|
|
|
99443
99584
|
agentMgr: {
|
|
99444
99585
|
resumeTurnForSlot: async (args2) => {
|
|
99445
99586
|
await exports_Effect.runPromise(deps.agentMgr.resumeTurnForSlot(args2));
|
|
99446
|
-
}
|
|
99587
|
+
},
|
|
99588
|
+
stop: (opts) => exports_Effect.runPromise(deps.agentMgr.stop(opts)),
|
|
99589
|
+
ensureRunning: (opts) => exports_Effect.runPromise(deps.agentMgr.ensureRunning(opts)),
|
|
99590
|
+
getSlot: (chatroomId, role) => deps.agentMgr.getSlot(chatroomId, role)
|
|
99447
99591
|
},
|
|
99448
99592
|
onTaskDelivered: ({ chatroomId, role, taskId }) => {
|
|
99449
99593
|
deliveredToHarness = true;
|
|
@@ -99500,7 +99644,7 @@ async function runRestartOrchestrator(deps, event) {
|
|
|
99500
99644
|
return;
|
|
99501
99645
|
}
|
|
99502
99646
|
await emitPhase(deps, event, "await_session");
|
|
99503
|
-
const harnessSessionId = await
|
|
99647
|
+
const harnessSessionId = await waitForHarnessSessionId2(deps, event, spawnResult.pid);
|
|
99504
99648
|
if (!harnessSessionId) {
|
|
99505
99649
|
await emitPhase(deps, event, "failed", "harnessSessionId timeout");
|
|
99506
99650
|
return;
|
|
@@ -99764,7 +99908,7 @@ function logWaitingForShutdown(pid) {
|
|
|
99764
99908
|
function logDaemonAlreadyRunning(pid) {
|
|
99765
99909
|
console.error(`❌ Daemon already running for ${getConvexUrl()} (PID: ${pid})`);
|
|
99766
99910
|
}
|
|
99767
|
-
async function waitForLockOrTimeout(deadline, intervalMs,
|
|
99911
|
+
async function waitForLockOrTimeout(deadline, intervalMs, sleep7) {
|
|
99768
99912
|
let loggedWait = false;
|
|
99769
99913
|
while (Date.now() < deadline) {
|
|
99770
99914
|
if (tryAcquireLock()) {
|
|
@@ -99775,16 +99919,16 @@ async function waitForLockOrTimeout(deadline, intervalMs, sleep6) {
|
|
|
99775
99919
|
logWaitingForShutdown(pid);
|
|
99776
99920
|
loggedWait = true;
|
|
99777
99921
|
}
|
|
99778
|
-
await
|
|
99922
|
+
await sleep7(intervalMs);
|
|
99779
99923
|
}
|
|
99780
99924
|
return false;
|
|
99781
99925
|
}
|
|
99782
99926
|
async function acquireLockWithRetry(options) {
|
|
99783
99927
|
const intervalMs = options?.intervalMs ?? LOCK_RETRY_INTERVAL_MS;
|
|
99784
99928
|
const maxWaitMs = options?.maxWaitMs ?? LOCK_RETRY_MAX_WAIT_MS;
|
|
99785
|
-
const
|
|
99929
|
+
const sleep7 = options?.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
|
|
99786
99930
|
const deadline = Date.now() + maxWaitMs;
|
|
99787
|
-
if (await waitForLockOrTimeout(deadline, intervalMs,
|
|
99931
|
+
if (await waitForLockOrTimeout(deadline, intervalMs, sleep7)) {
|
|
99788
99932
|
return true;
|
|
99789
99933
|
}
|
|
99790
99934
|
const { pid } = isDaemonRunning();
|
|
@@ -113937,13 +114081,13 @@ var init_task_monitor_logic = __esm(() => {
|
|
|
113937
114081
|
|
|
113938
114082
|
// src/daemon/entry/task-monitor-runtime.ts
|
|
113939
114083
|
function resolveTaskWantResume(task) {
|
|
113940
|
-
return sessionAugmentationToWantResume(
|
|
114084
|
+
return sessionAugmentationToWantResume(resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, task.agentConfig.role));
|
|
113941
114085
|
}
|
|
113942
114086
|
function buildCliNudgeLogLine(task) {
|
|
113943
114087
|
const { chatroomId, agentConfig } = task;
|
|
113944
114088
|
const { role } = agentConfig;
|
|
113945
114089
|
const lastSeenAction = task.participant?.lastSeenAction ?? "unknown";
|
|
113946
|
-
const augmentationMode =
|
|
114090
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
113947
114091
|
const wantResume = resolveTaskWantResume(task);
|
|
113948
114092
|
return `[TaskMonitor] nudging ${role}@${chatroomId} — pending task ${task.taskId}, lastSeenAction=${lastSeenAction}, session_augmentation=${augmentationMode}, wantResume=${wantResume}`;
|
|
113949
114093
|
}
|
|
@@ -113966,7 +114110,7 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
113966
114110
|
if (!ctx)
|
|
113967
114111
|
return;
|
|
113968
114112
|
const { chatroomId, agentConfig, role, workingDir, wantResume } = ctx;
|
|
113969
|
-
const augmentationMode =
|
|
114113
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
113970
114114
|
exports_Runtime.runFork(runtime4)(exports_Effect.gen(function* () {
|
|
113971
114115
|
yield* agentMgr.stop({ chatroomId, role, reason: "platform.task_monitor_nudge" });
|
|
113972
114116
|
yield* agentMgr.ensureRunning({
|
|
@@ -113978,7 +114122,7 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
113978
114122
|
reason: "platform.task_monitor_nudge",
|
|
113979
114123
|
wantResume
|
|
113980
114124
|
});
|
|
113981
|
-
if (
|
|
114125
|
+
if (shouldEmitSessionAugmentation(role, augmentationMode)) {
|
|
113982
114126
|
yield* exports_Effect.tryPromise({
|
|
113983
114127
|
try: () => sessionDeps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
113984
114128
|
sessionId: sessionDeps.sessionId,
|
|
@@ -114223,7 +114367,7 @@ var startTaskMonitorEffect = (wsClient2) => exports_Effect.gen(function* () {
|
|
|
114223
114367
|
var init_task_monitor_runtime = __esm(() => {
|
|
114224
114368
|
init_reliability();
|
|
114225
114369
|
init_participant();
|
|
114226
|
-
|
|
114370
|
+
init_parse_session_augmentation();
|
|
114227
114371
|
init_parse_session_augmentation();
|
|
114228
114372
|
init_assigned_task_monitor_contract();
|
|
114229
114373
|
init_esm();
|
|
@@ -129009,4 +129153,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
129009
129153
|
});
|
|
129010
129154
|
program2.parse();
|
|
129011
129155
|
|
|
129012
|
-
//# debugId=
|
|
129156
|
+
//# debugId=8169BF8DA0BD25A464756E2164756E21
|