clisbot 0.1.45-beta.10 → 0.1.45-beta.11
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/main.js +52 -12
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -69100,6 +69100,14 @@ class TmuxSubmitUnconfirmedError extends Error {
|
|
|
69100
69100
|
}
|
|
69101
69101
|
}
|
|
69102
69102
|
async function submitTmuxSessionInput(params) {
|
|
69103
|
+
if (params.trustPrompt) {
|
|
69104
|
+
await acceptTmuxTrustPromptIfPresent({
|
|
69105
|
+
tmux: params.tmux,
|
|
69106
|
+
sessionName: params.sessionName,
|
|
69107
|
+
captureLines: params.trustPrompt.captureLines,
|
|
69108
|
+
startupDelayMs: params.trustPrompt.startupDelayMs
|
|
69109
|
+
});
|
|
69110
|
+
}
|
|
69103
69111
|
const prePasteState = await params.tmux.getPaneState(params.sessionName);
|
|
69104
69112
|
const captureLines = estimatePasteCaptureLines(params.text);
|
|
69105
69113
|
const prePasteSnapshot = normalizePaneText(await params.tmux.capturePane(params.sessionName, captureLines));
|
|
@@ -69153,6 +69161,12 @@ async function submitTmuxSessionInput(params) {
|
|
|
69153
69161
|
throw new TmuxSubmitUnconfirmedError;
|
|
69154
69162
|
}
|
|
69155
69163
|
async function captureTmuxSessionIdentity(params) {
|
|
69164
|
+
await acceptTmuxTrustPromptIfPresent({
|
|
69165
|
+
tmux: params.tmux,
|
|
69166
|
+
sessionName: params.sessionName,
|
|
69167
|
+
captureLines: params.captureLines,
|
|
69168
|
+
startupDelayMs: params.timeoutMs
|
|
69169
|
+
});
|
|
69156
69170
|
let statusSubmission = await submitTmuxSessionInput({
|
|
69157
69171
|
tmux: params.tmux,
|
|
69158
69172
|
sessionName: params.sessionName,
|
|
@@ -69176,7 +69190,7 @@ async function captureTmuxSessionIdentity(params) {
|
|
|
69176
69190
|
throw error;
|
|
69177
69191
|
}
|
|
69178
69192
|
if (tmuxPaneHasTrustPrompt(snapshot)) {
|
|
69179
|
-
await
|
|
69193
|
+
await acceptTrustPrompt({
|
|
69180
69194
|
tmux: params.tmux,
|
|
69181
69195
|
sessionName: params.sessionName,
|
|
69182
69196
|
captureLines: params.captureLines
|
|
@@ -69233,7 +69247,7 @@ function extractSessionIdFromCaptureCandidates(candidates, pattern) {
|
|
|
69233
69247
|
}
|
|
69234
69248
|
return null;
|
|
69235
69249
|
}
|
|
69236
|
-
async function
|
|
69250
|
+
async function acceptTmuxTrustPromptIfPresent(params) {
|
|
69237
69251
|
const deadline = Date.now() + Math.max(TRUST_PROMPT_MAX_WAIT_MS, params.startupDelayMs);
|
|
69238
69252
|
while (Date.now() <= deadline) {
|
|
69239
69253
|
let snapshot = "";
|
|
@@ -69256,7 +69270,7 @@ async function dismissTmuxTrustPromptIfPresent(params) {
|
|
|
69256
69270
|
if (!tmuxPaneHasTrustPrompt(snapshot)) {
|
|
69257
69271
|
return;
|
|
69258
69272
|
}
|
|
69259
|
-
await
|
|
69273
|
+
await acceptTrustPrompt({
|
|
69260
69274
|
tmux: params.tmux,
|
|
69261
69275
|
sessionName: params.sessionName,
|
|
69262
69276
|
captureLines: params.captureLines
|
|
@@ -69288,7 +69302,7 @@ async function waitForTmuxSessionBootstrap(params) {
|
|
|
69288
69302
|
if (snapshot) {
|
|
69289
69303
|
lastSnapshot = snapshot;
|
|
69290
69304
|
if (params.trustWorkspace && tmuxPaneHasTrustPrompt(snapshot)) {
|
|
69291
|
-
await
|
|
69305
|
+
await acceptTrustPrompt({
|
|
69292
69306
|
tmux: params.tmux,
|
|
69293
69307
|
sessionName: params.sessionName,
|
|
69294
69308
|
captureLines: params.captureLines
|
|
@@ -69321,7 +69335,7 @@ async function waitForTmuxSessionBootstrap(params) {
|
|
|
69321
69335
|
snapshot: lastSnapshot
|
|
69322
69336
|
};
|
|
69323
69337
|
}
|
|
69324
|
-
async function
|
|
69338
|
+
async function acceptTrustPrompt(params) {
|
|
69325
69339
|
await params.tmux.sendKey(params.sessionName, "Enter");
|
|
69326
69340
|
const deadline = Date.now() + TRUST_PROMPT_MAX_WAIT_MS;
|
|
69327
69341
|
while (Date.now() <= deadline) {
|
|
@@ -69970,7 +69984,7 @@ class RunnerService {
|
|
|
69970
69984
|
try {
|
|
69971
69985
|
const snapshot = await this.captureSessionSnapshot(resolved);
|
|
69972
69986
|
if (tmuxPaneHasTrustPrompt(snapshot)) {
|
|
69973
|
-
await this.
|
|
69987
|
+
await this.acceptVisibleWorkspaceTrustPrompt(resolved);
|
|
69974
69988
|
continue;
|
|
69975
69989
|
}
|
|
69976
69990
|
return;
|
|
@@ -70041,6 +70055,7 @@ class RunnerService {
|
|
|
70041
70055
|
});
|
|
70042
70056
|
try {
|
|
70043
70057
|
await clearRunnerExitRecord(this.loadedConfig.stateDir, resolved.sessionName);
|
|
70058
|
+
await this.acceptWorkspaceTrustPromptIfPresent(resolved);
|
|
70044
70059
|
await this.syncStoredSessionIdForResolvedTarget(resolved);
|
|
70045
70060
|
} catch (error) {
|
|
70046
70061
|
throw await this.mapSessionError(error, resolved.sessionName, "during startup");
|
|
@@ -70124,7 +70139,7 @@ class RunnerService {
|
|
|
70124
70139
|
return resolved;
|
|
70125
70140
|
}
|
|
70126
70141
|
async finalizeSessionStartup(resolved, params) {
|
|
70127
|
-
await this.
|
|
70142
|
+
await this.acceptWorkspaceTrustPromptIfPresent(resolved);
|
|
70128
70143
|
await this.verifySessionReady(resolved);
|
|
70129
70144
|
if (params.storedOrExplicitSessionId) {
|
|
70130
70145
|
await this.persistStoredSessionIdBestEffort(resolved, params.storedOrExplicitSessionId, params.runnerCommand);
|
|
@@ -70158,14 +70173,14 @@ class RunnerService {
|
|
|
70158
70173
|
return;
|
|
70159
70174
|
}
|
|
70160
70175
|
}
|
|
70161
|
-
async
|
|
70176
|
+
async acceptWorkspaceTrustPromptIfPresent(resolved) {
|
|
70162
70177
|
if (!resolved.runner.trustWorkspace) {
|
|
70163
70178
|
return;
|
|
70164
70179
|
}
|
|
70165
|
-
await this.
|
|
70180
|
+
await this.acceptVisibleWorkspaceTrustPrompt(resolved);
|
|
70166
70181
|
}
|
|
70167
|
-
async
|
|
70168
|
-
await
|
|
70182
|
+
async acceptVisibleWorkspaceTrustPrompt(resolved) {
|
|
70183
|
+
await acceptTmuxTrustPromptIfPresent({
|
|
70169
70184
|
tmux: this.tmux,
|
|
70170
70185
|
sessionName: resolved.sessionName,
|
|
70171
70186
|
captureLines: resolved.stream.captureLines,
|
|
@@ -70246,6 +70261,7 @@ class RunnerService {
|
|
|
70246
70261
|
async triggerNewSessionInLiveRunner(resolved) {
|
|
70247
70262
|
const oldSessionId = (await this.sessionMapping.get(resolved.sessionKey))?.sessionId;
|
|
70248
70263
|
const command = this.resolveNewSessionCommand(resolved);
|
|
70264
|
+
await this.acceptWorkspaceTrustPromptIfPresent(resolved);
|
|
70249
70265
|
await this.submitNewSessionCommand(resolved, command);
|
|
70250
70266
|
const sessionId = await this.captureNewSessionIdentityAfterTrigger(resolved, oldSessionId);
|
|
70251
70267
|
if (!sessionId) {
|
|
@@ -70422,6 +70438,7 @@ class RunnerService {
|
|
|
70422
70438
|
if (!await this.tmux.hasSession(resolved.sessionName)) {
|
|
70423
70439
|
throw new Error(`tmux session "${resolved.sessionName}" does not exist`);
|
|
70424
70440
|
}
|
|
70441
|
+
await this.acceptWorkspaceTrustPromptIfPresent(resolved);
|
|
70425
70442
|
await submitTmuxSessionInput({
|
|
70426
70443
|
tmux: this.tmux,
|
|
70427
70444
|
sessionName: resolved.sessionName,
|
|
@@ -70500,6 +70517,14 @@ async function monitorTmuxRun(params) {
|
|
|
70500
70517
|
let firstMeaningfulDeltaLogged = false;
|
|
70501
70518
|
let noOutputThresholdLogged = false;
|
|
70502
70519
|
if (params.prompt) {
|
|
70520
|
+
if (params.trustWorkspace) {
|
|
70521
|
+
await acceptTmuxTrustPromptIfPresent({
|
|
70522
|
+
tmux: params.tmux,
|
|
70523
|
+
sessionName: params.sessionName,
|
|
70524
|
+
captureLines: params.captureLines,
|
|
70525
|
+
startupDelayMs: params.startupDelayMs ?? 0
|
|
70526
|
+
});
|
|
70527
|
+
}
|
|
70503
70528
|
logLatencyDebug("tmux-submit-start", params.timingContext, {
|
|
70504
70529
|
sessionName: params.sessionName,
|
|
70505
70530
|
promptSubmitDelayMs: params.promptSubmitDelayMs
|
|
@@ -71242,6 +71267,8 @@ class SessionService {
|
|
|
71242
71267
|
sessionName: run.resolved.sessionName,
|
|
71243
71268
|
prompt: params.prompt,
|
|
71244
71269
|
promptSubmitDelayMs: run.resolved.runner.promptSubmitDelayMs,
|
|
71270
|
+
trustWorkspace: run.resolved.runner.trustWorkspace,
|
|
71271
|
+
startupDelayMs: run.resolved.runner.startupDelayMs,
|
|
71245
71272
|
captureLines: run.resolved.stream.captureLines,
|
|
71246
71273
|
updateIntervalMs: run.resolved.stream.updateIntervalMs,
|
|
71247
71274
|
idleTimeoutMs: run.resolved.stream.idleTimeoutMs,
|
|
@@ -86200,6 +86227,8 @@ async function withStartupTimeout(name, start2) {
|
|
|
86200
86227
|
}
|
|
86201
86228
|
|
|
86202
86229
|
// src/control/runtime-management-cli.ts
|
|
86230
|
+
var RESTART_STOP_STATUS_RECHECK_TIMEOUT_MS = 2000;
|
|
86231
|
+
var RESTART_STOP_STATUS_RECHECK_INTERVAL_MS = 100;
|
|
86203
86232
|
function getOperatorConfigPath() {
|
|
86204
86233
|
return expandHomePath(process.env.CLISBOT_CONFIG_PATH || DEFAULT_CONFIG_PATH);
|
|
86205
86234
|
}
|
|
@@ -86439,6 +86468,7 @@ async function stop(hard = false) {
|
|
|
86439
86468
|
async function restart(dependencies = {
|
|
86440
86469
|
stopDetachedRuntime,
|
|
86441
86470
|
getRuntimeStatus,
|
|
86471
|
+
sleep,
|
|
86442
86472
|
warn: (message) => console.error(message)
|
|
86443
86473
|
}) {
|
|
86444
86474
|
const configPath = getOperatorConfigPath();
|
|
@@ -86448,7 +86478,7 @@ async function restart(dependencies = {
|
|
|
86448
86478
|
hard: false
|
|
86449
86479
|
});
|
|
86450
86480
|
} catch (error) {
|
|
86451
|
-
const status = await
|
|
86481
|
+
const status = await waitForStoppedRuntimeAfterStopError(configPath, dependencies);
|
|
86452
86482
|
if (status.running) {
|
|
86453
86483
|
throw error;
|
|
86454
86484
|
}
|
|
@@ -86456,6 +86486,16 @@ async function restart(dependencies = {
|
|
|
86456
86486
|
dependencies.warn(`warning: clisbot stop reported an error, but status now shows the service is stopped; continuing with start. Stop error: ${message}`);
|
|
86457
86487
|
}
|
|
86458
86488
|
}
|
|
86489
|
+
async function waitForStoppedRuntimeAfterStopError(configPath, dependencies) {
|
|
86490
|
+
const deadline = Date.now() + RESTART_STOP_STATUS_RECHECK_TIMEOUT_MS;
|
|
86491
|
+
while (true) {
|
|
86492
|
+
const status = await dependencies.getRuntimeStatus({ configPath });
|
|
86493
|
+
if (!status.running || Date.now() >= deadline) {
|
|
86494
|
+
return status;
|
|
86495
|
+
}
|
|
86496
|
+
await dependencies.sleep(RESTART_STOP_STATUS_RECHECK_INTERVAL_MS);
|
|
86497
|
+
}
|
|
86498
|
+
}
|
|
86459
86499
|
async function status() {
|
|
86460
86500
|
await printStatusSummary();
|
|
86461
86501
|
}
|