chatroom-cli 1.96.1 → 1.97.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 +258 -113
- package/dist/index.js.map +14 -13
- package/dist/node-launch.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -31649,7 +31649,8 @@ function waitForResumeOrAbort3(session2) {
|
|
|
31649
31649
|
function buildLocalAgentOptions(cwd) {
|
|
31650
31650
|
return {
|
|
31651
31651
|
cwd,
|
|
31652
|
-
settingSources: []
|
|
31652
|
+
settingSources: [],
|
|
31653
|
+
enableAgentRetries: true
|
|
31653
31654
|
};
|
|
31654
31655
|
}
|
|
31655
31656
|
function writeSpawnError3(logPrefix, err, emitLogLine) {
|
|
@@ -31662,8 +31663,8 @@ function writeSpawnError3(logPrefix, err, emitLogLine) {
|
|
|
31662
31663
|
var NO_SUBAGENT_DIRECTIVE2 = "NEVER spawn subagents. Follow the chatroom instructions strictly.", _sdkCache3, _sdkLoadError3, CURSOR_SDK_COMMAND = "cursor-sdk", AGENT_CREATE_TIMEOUT_MS = 60000, SEND_TIMEOUT_MS = 60000, RUN_WAIT_TIMEOUT_MS = 3600000, RUN_CANCEL_TIMEOUT_MS = 5000, cachedSdkPackageVersion3, CursorSdkAgentService;
|
|
31663
31664
|
var init_cursor_sdk_agent_service = __esm(() => {
|
|
31664
31665
|
init_esm();
|
|
31665
|
-
init_cursor_sdk_model_catalog();
|
|
31666
31666
|
init_cursor_models();
|
|
31667
|
+
init_cursor_sdk_model_catalog();
|
|
31667
31668
|
init_cursor_sdk_package();
|
|
31668
31669
|
init_cursor_sdk_stream_adapter();
|
|
31669
31670
|
init_base_cli_agent_service();
|
|
@@ -98898,7 +98899,15 @@ var init_team_agent_settings = __esm(() => {
|
|
|
98898
98899
|
});
|
|
98899
98900
|
|
|
98900
98901
|
// ../../services/backend/src/domain/handoff/parse-session-augmentation.ts
|
|
98901
|
-
function
|
|
98902
|
+
function resolveSessionAugmentationForTask(task, role) {
|
|
98903
|
+
if (task.startInNewSession !== undefined)
|
|
98904
|
+
return task.startInNewSession ? "new_session" : "none";
|
|
98905
|
+
return resolveSessionAugmentationForRole(role);
|
|
98906
|
+
}
|
|
98907
|
+
function shouldEmitSessionAugmentation(role, mode) {
|
|
98908
|
+
return roleSupportsSessionAugmentation(role) || mode === "new_session";
|
|
98909
|
+
}
|
|
98910
|
+
function resolveSessionAugmentationForRole(role) {
|
|
98902
98911
|
if (!roleSupportsSessionAugmentation(role))
|
|
98903
98912
|
return "none";
|
|
98904
98913
|
return "new_session";
|
|
@@ -98913,6 +98922,71 @@ var init_parse_session_augmentation = __esm(() => {
|
|
|
98913
98922
|
init_team_agent_settings();
|
|
98914
98923
|
});
|
|
98915
98924
|
|
|
98925
|
+
// src/daemon/entry/native-delivery/native-cold-session-before-inject.ts
|
|
98926
|
+
function sleep5(ms) {
|
|
98927
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
98928
|
+
}
|
|
98929
|
+
async function waitForHarnessSessionId(agentMgr, chatroomId, role) {
|
|
98930
|
+
const deadline = Date.now() + HARNESS_SESSION_READY_TIMEOUT_MS;
|
|
98931
|
+
while (Date.now() < deadline) {
|
|
98932
|
+
const id3 = agentMgr.getSlot(chatroomId, role)?.harnessSessionId;
|
|
98933
|
+
if (id3)
|
|
98934
|
+
return id3;
|
|
98935
|
+
await sleep5(100);
|
|
98936
|
+
}
|
|
98937
|
+
return null;
|
|
98938
|
+
}
|
|
98939
|
+
async function ensureColdSessionBeforeNativeInject(task, deps) {
|
|
98940
|
+
if (!task.startInNewSession)
|
|
98941
|
+
return null;
|
|
98942
|
+
const { chatroomId, agentConfig, taskId } = task;
|
|
98943
|
+
const { role, agentHarness, model, workingDir } = agentConfig;
|
|
98944
|
+
if (!workingDir || !model)
|
|
98945
|
+
return null;
|
|
98946
|
+
await deps.agentMgr.stop({
|
|
98947
|
+
chatroomId,
|
|
98948
|
+
role,
|
|
98949
|
+
reason: "platform.task_start_in_new_session"
|
|
98950
|
+
});
|
|
98951
|
+
const spawn3 = await deps.agentMgr.ensureRunning({
|
|
98952
|
+
chatroomId,
|
|
98953
|
+
role,
|
|
98954
|
+
agentHarness,
|
|
98955
|
+
model,
|
|
98956
|
+
workingDir,
|
|
98957
|
+
reason: "platform.task_start_in_new_session",
|
|
98958
|
+
wantResume: false
|
|
98959
|
+
});
|
|
98960
|
+
if (!spawn3.success)
|
|
98961
|
+
return null;
|
|
98962
|
+
const harnessSessionId = await waitForHarnessSessionId(deps.agentMgr, chatroomId, role);
|
|
98963
|
+
if (!harnessSessionId)
|
|
98964
|
+
return null;
|
|
98965
|
+
await deps.backend.mutation(api.participants.join, {
|
|
98966
|
+
sessionId: deps.sessionId,
|
|
98967
|
+
chatroomId,
|
|
98968
|
+
role,
|
|
98969
|
+
action: NATIVE_WAITING_ACTION,
|
|
98970
|
+
taskId
|
|
98971
|
+
});
|
|
98972
|
+
await deps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
98973
|
+
sessionId: deps.sessionId,
|
|
98974
|
+
machineId: deps.machineId,
|
|
98975
|
+
chatroomId,
|
|
98976
|
+
role,
|
|
98977
|
+
taskId,
|
|
98978
|
+
mode: "new_session",
|
|
98979
|
+
newSessionStarted: true,
|
|
98980
|
+
harnessSessionId
|
|
98981
|
+
});
|
|
98982
|
+
return harnessSessionId;
|
|
98983
|
+
}
|
|
98984
|
+
var init_native_cold_session_before_inject = __esm(() => {
|
|
98985
|
+
init_reliability();
|
|
98986
|
+
init_participant();
|
|
98987
|
+
init_api3();
|
|
98988
|
+
});
|
|
98989
|
+
|
|
98916
98990
|
// src/daemon/entry/native-delivery/native-task-injector.ts
|
|
98917
98991
|
async function emitTaskDeliveryFailed(deps, args2) {
|
|
98918
98992
|
try {
|
|
@@ -98926,35 +99000,132 @@ async function emitTaskDeliveryFailed(deps, args2) {
|
|
|
98926
99000
|
});
|
|
98927
99001
|
} catch {}
|
|
98928
99002
|
}
|
|
98929
|
-
function
|
|
99003
|
+
function reportDeliveryFailureEffect(deps, args2) {
|
|
99004
|
+
return exports_Effect.tryPromise({
|
|
99005
|
+
try: () => emitTaskDeliveryFailed(deps, args2),
|
|
99006
|
+
catch: () => {
|
|
99007
|
+
return;
|
|
99008
|
+
}
|
|
99009
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99010
|
+
}
|
|
99011
|
+
function applyColdSessionIfRequested(task, deps, chatroomId, role, taskId) {
|
|
99012
|
+
return exports_Effect.gen(function* () {
|
|
99013
|
+
const coldSessionResult = yield* exports_Effect.tryPromise({
|
|
99014
|
+
try: () => ensureColdSessionBeforeNativeInject(task, deps),
|
|
99015
|
+
catch: (err) => err
|
|
99016
|
+
}).pipe(exports_Effect.either);
|
|
99017
|
+
if (coldSessionResult._tag === "Left" || !coldSessionResult.right) {
|
|
99018
|
+
const error51 = coldSessionResult._tag === "Left" ? getErrorMessage(coldSessionResult.left) : "cold session restart failed";
|
|
99019
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99020
|
+
chatroomId,
|
|
99021
|
+
role,
|
|
99022
|
+
taskId,
|
|
99023
|
+
error: error51
|
|
99024
|
+
});
|
|
99025
|
+
return { failed: true, error: error51 };
|
|
99026
|
+
}
|
|
99027
|
+
return { harnessSessionId: coldSessionResult.right };
|
|
99028
|
+
});
|
|
99029
|
+
}
|
|
99030
|
+
function claimPendingTaskIfNeeded(task, deps) {
|
|
98930
99031
|
return exports_Effect.gen(function* () {
|
|
98931
|
-
|
|
99032
|
+
if (task.status !== "pending")
|
|
99033
|
+
return;
|
|
99034
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
98932
99035
|
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
|
-
|
|
99036
|
+
const claimResult = yield* exports_Effect.tryPromise({
|
|
99037
|
+
try: () => deps.backend.mutation(api.tasks.claimTask, {
|
|
99038
|
+
sessionId: deps.sessionId,
|
|
99039
|
+
chatroomId,
|
|
99040
|
+
role,
|
|
99041
|
+
taskId
|
|
99042
|
+
}),
|
|
99043
|
+
catch: (err) => err
|
|
99044
|
+
}).pipe(exports_Effect.either);
|
|
99045
|
+
if (claimResult._tag === "Left") {
|
|
99046
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99047
|
+
chatroomId,
|
|
99048
|
+
role,
|
|
99049
|
+
taskId,
|
|
99050
|
+
error: getErrorMessage(claimResult.left)
|
|
99051
|
+
});
|
|
99052
|
+
return yield* exports_Effect.fail(claimResult.left);
|
|
99053
|
+
}
|
|
99054
|
+
});
|
|
99055
|
+
}
|
|
99056
|
+
function resolveHarnessSessionForInject(task, deps, initialHarnessSessionId) {
|
|
99057
|
+
return exports_Effect.gen(function* () {
|
|
99058
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99059
|
+
const { role } = agentConfig;
|
|
99060
|
+
if (!task.startInNewSession) {
|
|
99061
|
+
return { harnessSessionId: initialHarnessSessionId, sessionAugmentationEmitted: false };
|
|
99062
|
+
}
|
|
99063
|
+
const coldSession = yield* applyColdSessionIfRequested(task, deps, chatroomId, role, taskId);
|
|
99064
|
+
if ("failed" in coldSession) {
|
|
99065
|
+
return yield* exports_Effect.fail(new Error(coldSession.error));
|
|
99066
|
+
}
|
|
99067
|
+
return {
|
|
99068
|
+
harnessSessionId: coldSession.harnessSessionId,
|
|
99069
|
+
sessionAugmentationEmitted: true
|
|
99070
|
+
};
|
|
99071
|
+
});
|
|
99072
|
+
}
|
|
99073
|
+
function emitSessionAugmentationIfNeeded(task, deps, harnessSessionId, sessionAugmentationEmitted, augmentationMode) {
|
|
99074
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99075
|
+
const { role } = agentConfig;
|
|
99076
|
+
if (!shouldEmitSessionAugmentation(role, augmentationMode) || sessionAugmentationEmitted) {
|
|
99077
|
+
return exports_Effect.void;
|
|
99078
|
+
}
|
|
99079
|
+
return exports_Effect.tryPromise({
|
|
99080
|
+
try: () => deps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
99081
|
+
sessionId: deps.sessionId,
|
|
99082
|
+
machineId: deps.machineId,
|
|
99083
|
+
chatroomId,
|
|
99084
|
+
role,
|
|
99085
|
+
taskId,
|
|
99086
|
+
mode: augmentationMode,
|
|
99087
|
+
newSessionStarted: sessionAugmentationNewSessionStarted(augmentationMode),
|
|
99088
|
+
harnessSessionId
|
|
99089
|
+
}),
|
|
99090
|
+
catch: (err) => err
|
|
99091
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99092
|
+
}
|
|
99093
|
+
function resumeHarnessWithPrompt(task, deps, prompt) {
|
|
99094
|
+
return exports_Effect.gen(function* () {
|
|
99095
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99096
|
+
const { role } = agentConfig;
|
|
99097
|
+
const resumeResult = yield* exports_Effect.tryPromise({
|
|
99098
|
+
try: () => deps.agentMgr.resumeTurnForSlot({ chatroomId, role, prompt }),
|
|
99099
|
+
catch: (err) => err
|
|
99100
|
+
}).pipe(exports_Effect.either);
|
|
99101
|
+
if (resumeResult._tag === "Left") {
|
|
99102
|
+
const error51 = getErrorMessage(resumeResult.left);
|
|
99103
|
+
console.warn(`[NativeTaskInjector] resumeTurn failed for ${role}@${chatroomId}: ${error51}`);
|
|
99104
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99105
|
+
chatroomId,
|
|
99106
|
+
role,
|
|
99107
|
+
taskId,
|
|
99108
|
+
error: error51
|
|
99109
|
+
});
|
|
99110
|
+
return;
|
|
98957
99111
|
}
|
|
99112
|
+
yield* exports_Effect.tryPromise({
|
|
99113
|
+
try: () => deps.backend.mutation(api.machines.emitTaskDelivered, {
|
|
99114
|
+
sessionId: deps.sessionId,
|
|
99115
|
+
machineId: deps.machineId,
|
|
99116
|
+
chatroomId,
|
|
99117
|
+
role,
|
|
99118
|
+
taskId
|
|
99119
|
+
}),
|
|
99120
|
+
catch: (err) => err
|
|
99121
|
+
}).pipe(exports_Effect.catchAll(() => exports_Effect.void));
|
|
99122
|
+
deps.onTaskDelivered?.({ chatroomId, role, taskId });
|
|
99123
|
+
});
|
|
99124
|
+
}
|
|
99125
|
+
function loadNativeInjectionPrompt(task, deps) {
|
|
99126
|
+
return exports_Effect.gen(function* () {
|
|
99127
|
+
const { chatroomId, taskId, taskContent, agentConfig } = task;
|
|
99128
|
+
const { role } = agentConfig;
|
|
98958
99129
|
const deliveryResult = yield* exports_Effect.tryPromise({
|
|
98959
99130
|
try: () => deps.backend.query(api.messages.getTaskDeliveryPrompt, {
|
|
98960
99131
|
sessionId: deps.sessionId,
|
|
@@ -98966,25 +99137,29 @@ function runNativeInjectionEffect(task, harnessSessionId, deps) {
|
|
|
98966
99137
|
catch: (err) => err
|
|
98967
99138
|
}).pipe(exports_Effect.either);
|
|
98968
99139
|
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));
|
|
99140
|
+
yield* reportDeliveryFailureEffect(deps, {
|
|
99141
|
+
chatroomId,
|
|
99142
|
+
role,
|
|
99143
|
+
taskId,
|
|
99144
|
+
error: getErrorMessage(deliveryResult.left)
|
|
99145
|
+
});
|
|
98980
99146
|
return yield* exports_Effect.fail(deliveryResult.left);
|
|
98981
99147
|
}
|
|
98982
|
-
const
|
|
98983
|
-
|
|
98984
|
-
|
|
98985
|
-
|
|
98986
|
-
|
|
98987
|
-
|
|
99148
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: taskContent, startInNewSession: task.startInNewSession }, role);
|
|
99149
|
+
return {
|
|
99150
|
+
augmentationMode,
|
|
99151
|
+
prompt: buildNativeInjectionPrompt({
|
|
99152
|
+
taskDeliveryOutput: deliveryResult.right.fullCliOutput,
|
|
99153
|
+
augmentationMode
|
|
99154
|
+
})
|
|
99155
|
+
};
|
|
99156
|
+
});
|
|
99157
|
+
}
|
|
99158
|
+
function injectNativeTaskPrompt(task, deps, harnessSessionId, sessionAugmentationEmitted) {
|
|
99159
|
+
return exports_Effect.gen(function* () {
|
|
99160
|
+
const { chatroomId, taskId, agentConfig } = task;
|
|
99161
|
+
const { role } = agentConfig;
|
|
99162
|
+
const { prompt, augmentationMode } = yield* loadNativeInjectionPrompt(task, deps);
|
|
98988
99163
|
yield* exports_Effect.tryPromise({
|
|
98989
99164
|
try: () => deps.backend.mutation(api.participants.join, {
|
|
98990
99165
|
sessionId: deps.sessionId,
|
|
@@ -99006,59 +99181,22 @@ function runNativeInjectionEffect(task, harnessSessionId, deps) {
|
|
|
99006
99181
|
}),
|
|
99007
99182
|
catch: (err) => err
|
|
99008
99183
|
});
|
|
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 });
|
|
99184
|
+
yield* emitSessionAugmentationIfNeeded(task, deps, harnessSessionId, sessionAugmentationEmitted, augmentationMode);
|
|
99185
|
+
yield* resumeHarnessWithPrompt(task, deps, prompt);
|
|
99186
|
+
});
|
|
99187
|
+
}
|
|
99188
|
+
function runNativeInjectionEffect(task, initialHarnessSessionId, deps) {
|
|
99189
|
+
return exports_Effect.gen(function* () {
|
|
99190
|
+
yield* claimPendingTaskIfNeeded(task, deps);
|
|
99191
|
+
const session2 = yield* resolveHarnessSessionForInject(task, deps, initialHarnessSessionId);
|
|
99192
|
+
yield* injectNativeTaskPrompt(task, deps, session2.harnessSessionId, session2.sessionAugmentationEmitted);
|
|
99055
99193
|
});
|
|
99056
99194
|
}
|
|
99057
99195
|
var init_native_task_injector = __esm(() => {
|
|
99058
99196
|
init_participant();
|
|
99059
|
-
init_team_agent_settings();
|
|
99060
99197
|
init_parse_session_augmentation();
|
|
99061
99198
|
init_esm();
|
|
99199
|
+
init_native_cold_session_before_inject();
|
|
99062
99200
|
init_native_task_injector_logic();
|
|
99063
99201
|
init_api3();
|
|
99064
99202
|
init_convex_error();
|
|
@@ -99089,7 +99227,8 @@ function mapAssignedTaskSnapshot(row) {
|
|
|
99089
99227
|
function mapAssignedTaskView(row) {
|
|
99090
99228
|
return {
|
|
99091
99229
|
...mapAssignedTaskSnapshot(row),
|
|
99092
|
-
taskContent: row.taskContent
|
|
99230
|
+
taskContent: row.taskContent,
|
|
99231
|
+
startInNewSession: row.startInNewSession
|
|
99093
99232
|
};
|
|
99094
99233
|
}
|
|
99095
99234
|
function mapAssignedTaskSnapshotList(rows) {
|
|
@@ -99288,7 +99427,10 @@ class NativeTaskDeliveryCoordinator {
|
|
|
99288
99427
|
machineId: sessionDeps.machineId,
|
|
99289
99428
|
backend: sessionDeps.backend,
|
|
99290
99429
|
agentMgr: {
|
|
99291
|
-
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2))
|
|
99430
|
+
resumeTurnForSlot: (args2) => exports_Effect.runPromise(agentMgr.resumeTurnForSlot(args2)),
|
|
99431
|
+
stop: (opts) => exports_Effect.runPromise(agentMgr.stop(opts)),
|
|
99432
|
+
ensureRunning: (opts) => exports_Effect.runPromise(agentMgr.ensureRunning(opts)),
|
|
99433
|
+
getSlot: (chatroomId, role2) => agentMgr.getSlot(chatroomId, role2)
|
|
99292
99434
|
},
|
|
99293
99435
|
convexUrl: sessionDeps.convexUrl,
|
|
99294
99436
|
onTaskDelivered: ({ chatroomId, role: role2, taskId: deliveredTaskId }) => {
|
|
@@ -99363,10 +99505,10 @@ async function emitPhase(deps, event, phase, detail) {
|
|
|
99363
99505
|
detail
|
|
99364
99506
|
});
|
|
99365
99507
|
}
|
|
99366
|
-
function
|
|
99508
|
+
function sleep6(ms) {
|
|
99367
99509
|
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
99368
99510
|
}
|
|
99369
|
-
async function
|
|
99511
|
+
async function waitForHarnessSessionId2(deps, event, pid) {
|
|
99370
99512
|
const initial = deps.agentMgr.getSlot(event.chatroomId, event.role);
|
|
99371
99513
|
if (initial?.harnessSessionId) {
|
|
99372
99514
|
return initial.harnessSessionId;
|
|
@@ -99377,7 +99519,7 @@ async function waitForHarnessSessionId(deps, event, pid) {
|
|
|
99377
99519
|
if (slot?.harnessSessionId) {
|
|
99378
99520
|
return slot.harnessSessionId;
|
|
99379
99521
|
}
|
|
99380
|
-
await
|
|
99522
|
+
await sleep6(100);
|
|
99381
99523
|
}
|
|
99382
99524
|
await deps.agentMgr.stop({
|
|
99383
99525
|
chatroomId: event.chatroomId,
|
|
@@ -99443,7 +99585,10 @@ async function deliverOneTask(deps, event, snapshot) {
|
|
|
99443
99585
|
agentMgr: {
|
|
99444
99586
|
resumeTurnForSlot: async (args2) => {
|
|
99445
99587
|
await exports_Effect.runPromise(deps.agentMgr.resumeTurnForSlot(args2));
|
|
99446
|
-
}
|
|
99588
|
+
},
|
|
99589
|
+
stop: (opts) => exports_Effect.runPromise(deps.agentMgr.stop(opts)),
|
|
99590
|
+
ensureRunning: (opts) => exports_Effect.runPromise(deps.agentMgr.ensureRunning(opts)),
|
|
99591
|
+
getSlot: (chatroomId, role) => deps.agentMgr.getSlot(chatroomId, role)
|
|
99447
99592
|
},
|
|
99448
99593
|
onTaskDelivered: ({ chatroomId, role, taskId }) => {
|
|
99449
99594
|
deliveredToHarness = true;
|
|
@@ -99500,7 +99645,7 @@ async function runRestartOrchestrator(deps, event) {
|
|
|
99500
99645
|
return;
|
|
99501
99646
|
}
|
|
99502
99647
|
await emitPhase(deps, event, "await_session");
|
|
99503
|
-
const harnessSessionId = await
|
|
99648
|
+
const harnessSessionId = await waitForHarnessSessionId2(deps, event, spawnResult.pid);
|
|
99504
99649
|
if (!harnessSessionId) {
|
|
99505
99650
|
await emitPhase(deps, event, "failed", "harnessSessionId timeout");
|
|
99506
99651
|
return;
|
|
@@ -99764,7 +99909,7 @@ function logWaitingForShutdown(pid) {
|
|
|
99764
99909
|
function logDaemonAlreadyRunning(pid) {
|
|
99765
99910
|
console.error(`❌ Daemon already running for ${getConvexUrl()} (PID: ${pid})`);
|
|
99766
99911
|
}
|
|
99767
|
-
async function waitForLockOrTimeout(deadline, intervalMs,
|
|
99912
|
+
async function waitForLockOrTimeout(deadline, intervalMs, sleep7) {
|
|
99768
99913
|
let loggedWait = false;
|
|
99769
99914
|
while (Date.now() < deadline) {
|
|
99770
99915
|
if (tryAcquireLock()) {
|
|
@@ -99775,16 +99920,16 @@ async function waitForLockOrTimeout(deadline, intervalMs, sleep6) {
|
|
|
99775
99920
|
logWaitingForShutdown(pid);
|
|
99776
99921
|
loggedWait = true;
|
|
99777
99922
|
}
|
|
99778
|
-
await
|
|
99923
|
+
await sleep7(intervalMs);
|
|
99779
99924
|
}
|
|
99780
99925
|
return false;
|
|
99781
99926
|
}
|
|
99782
99927
|
async function acquireLockWithRetry(options) {
|
|
99783
99928
|
const intervalMs = options?.intervalMs ?? LOCK_RETRY_INTERVAL_MS;
|
|
99784
99929
|
const maxWaitMs = options?.maxWaitMs ?? LOCK_RETRY_MAX_WAIT_MS;
|
|
99785
|
-
const
|
|
99930
|
+
const sleep7 = options?.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
|
|
99786
99931
|
const deadline = Date.now() + maxWaitMs;
|
|
99787
|
-
if (await waitForLockOrTimeout(deadline, intervalMs,
|
|
99932
|
+
if (await waitForLockOrTimeout(deadline, intervalMs, sleep7)) {
|
|
99788
99933
|
return true;
|
|
99789
99934
|
}
|
|
99790
99935
|
const { pid } = isDaemonRunning();
|
|
@@ -106446,7 +106591,7 @@ class CursorSdkHarness {
|
|
|
106446
106591
|
const agent = await withTimeout(Agent.create({
|
|
106447
106592
|
apiKey,
|
|
106448
106593
|
model: modelSelection,
|
|
106449
|
-
local: { cwd: this.cwd, settingSources: [] }
|
|
106594
|
+
local: { cwd: this.cwd, settingSources: [], enableAgentRetries: true }
|
|
106450
106595
|
}), AGENT_CREATE_TIMEOUT_MS2, "Agent.create");
|
|
106451
106596
|
const session2 = new CursorSdkSession({
|
|
106452
106597
|
agent,
|
|
@@ -106470,7 +106615,7 @@ class CursorSdkHarness {
|
|
|
106470
106615
|
const agent = await withTimeout(Agent.resume(sessionId, {
|
|
106471
106616
|
apiKey,
|
|
106472
106617
|
model: resolveCursorSdkSpawnModelSelection(DEFAULT_MODEL2),
|
|
106473
|
-
local: { cwd: this.cwd, settingSources: [] }
|
|
106618
|
+
local: { cwd: this.cwd, settingSources: [], enableAgentRetries: true }
|
|
106474
106619
|
}), AGENT_CREATE_TIMEOUT_MS2, "Agent.resume");
|
|
106475
106620
|
const session2 = new CursorSdkSession({
|
|
106476
106621
|
agent,
|
|
@@ -106509,8 +106654,8 @@ var DEFAULT_MODEL2 = "composer-2.5", AGENT_CREATE_TIMEOUT_MS2 = 60000, _sdkCache
|
|
|
106509
106654
|
};
|
|
106510
106655
|
var init_cursor_harness = __esm(() => {
|
|
106511
106656
|
init_cursor_session();
|
|
106512
|
-
init_cursor_sdk_model_catalog();
|
|
106513
106657
|
init_cursor_models();
|
|
106658
|
+
init_cursor_sdk_model_catalog();
|
|
106514
106659
|
init_cursor_sdk_package();
|
|
106515
106660
|
});
|
|
106516
106661
|
|
|
@@ -113937,13 +114082,13 @@ var init_task_monitor_logic = __esm(() => {
|
|
|
113937
114082
|
|
|
113938
114083
|
// src/daemon/entry/task-monitor-runtime.ts
|
|
113939
114084
|
function resolveTaskWantResume(task) {
|
|
113940
|
-
return sessionAugmentationToWantResume(
|
|
114085
|
+
return sessionAugmentationToWantResume(resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, task.agentConfig.role));
|
|
113941
114086
|
}
|
|
113942
114087
|
function buildCliNudgeLogLine(task) {
|
|
113943
114088
|
const { chatroomId, agentConfig } = task;
|
|
113944
114089
|
const { role } = agentConfig;
|
|
113945
114090
|
const lastSeenAction = task.participant?.lastSeenAction ?? "unknown";
|
|
113946
|
-
const augmentationMode =
|
|
114091
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
113947
114092
|
const wantResume = resolveTaskWantResume(task);
|
|
113948
114093
|
return `[TaskMonitor] nudging ${role}@${chatroomId} — pending task ${task.taskId}, lastSeenAction=${lastSeenAction}, session_augmentation=${augmentationMode}, wantResume=${wantResume}`;
|
|
113949
114094
|
}
|
|
@@ -113966,7 +114111,7 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
113966
114111
|
if (!ctx)
|
|
113967
114112
|
return;
|
|
113968
114113
|
const { chatroomId, agentConfig, role, workingDir, wantResume } = ctx;
|
|
113969
|
-
const augmentationMode =
|
|
114114
|
+
const augmentationMode = resolveSessionAugmentationForTask({ content: task.taskContent ?? "", startInNewSession: task.startInNewSession }, role);
|
|
113970
114115
|
exports_Runtime.runFork(runtime4)(exports_Effect.gen(function* () {
|
|
113971
114116
|
yield* agentMgr.stop({ chatroomId, role, reason: "platform.task_monitor_nudge" });
|
|
113972
114117
|
yield* agentMgr.ensureRunning({
|
|
@@ -113978,7 +114123,7 @@ function executeCliNudge(task, runtime4, effectContext2, agentMgr, sessionDeps,
|
|
|
113978
114123
|
reason: "platform.task_monitor_nudge",
|
|
113979
114124
|
wantResume
|
|
113980
114125
|
});
|
|
113981
|
-
if (
|
|
114126
|
+
if (shouldEmitSessionAugmentation(role, augmentationMode)) {
|
|
113982
114127
|
yield* exports_Effect.tryPromise({
|
|
113983
114128
|
try: () => sessionDeps.backend.mutation(api.machines.emitSessionAugmented, {
|
|
113984
114129
|
sessionId: sessionDeps.sessionId,
|
|
@@ -114223,7 +114368,7 @@ var startTaskMonitorEffect = (wsClient2) => exports_Effect.gen(function* () {
|
|
|
114223
114368
|
var init_task_monitor_runtime = __esm(() => {
|
|
114224
114369
|
init_reliability();
|
|
114225
114370
|
init_participant();
|
|
114226
|
-
|
|
114371
|
+
init_parse_session_augmentation();
|
|
114227
114372
|
init_parse_session_augmentation();
|
|
114228
114373
|
init_assigned_task_monitor_contract();
|
|
114229
114374
|
init_esm();
|
|
@@ -129009,4 +129154,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
129009
129154
|
});
|
|
129010
129155
|
program2.parse();
|
|
129011
129156
|
|
|
129012
|
-
//# debugId=
|
|
129157
|
+
//# debugId=8802CE1D5113F46664756E2164756E21
|