shellpuppet 0.3.0 → 0.4.1
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/README.md +4 -4
- package/dist/agents/claude/liveResumeId.d.ts +6 -0
- package/dist/agents/claude/liveResumeId.js +101 -0
- package/dist/agents/claude/liveResumeId.js.map +1 -0
- package/dist/agents/codex/draft.d.ts +3 -0
- package/dist/agents/codex/draft.js +88 -0
- package/dist/agents/codex/draft.js.map +1 -0
- package/dist/agents/codex/index.js +2 -0
- package/dist/agents/codex/index.js.map +1 -1
- package/dist/agents/codex/lineBreaks.d.ts +6 -0
- package/dist/agents/codex/lineBreaks.js +105 -0
- package/dist/agents/codex/lineBreaks.js.map +1 -0
- package/dist/agents/codex/nudge.js +7 -8
- package/dist/agents/codex/nudge.js.map +1 -1
- package/dist/agents/grok/nudge.js +8 -3
- package/dist/agents/grok/nudge.js.map +1 -1
- package/dist/agents/hermes/frame.d.ts +25 -0
- package/dist/agents/hermes/frame.js +145 -0
- package/dist/agents/hermes/frame.js.map +1 -0
- package/dist/agents/hermes/index.d.ts +2 -0
- package/dist/agents/hermes/index.js +20 -0
- package/dist/agents/hermes/index.js.map +1 -0
- package/dist/agents/hermes/nudge.d.ts +5 -0
- package/dist/agents/hermes/nudge.js +76 -0
- package/dist/agents/hermes/nudge.js.map +1 -0
- package/dist/agents/hermes/prompts.d.ts +7 -0
- package/dist/agents/hermes/prompts.js +101 -0
- package/dist/agents/hermes/prompts.js.map +1 -0
- package/dist/agents/hermes/reading.d.ts +7 -0
- package/dist/agents/hermes/reading.js +102 -0
- package/dist/agents/hermes/reading.js.map +1 -0
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +5 -3
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/mimo/nudge.js +4 -3
- package/dist/agents/mimo/nudge.js.map +1 -1
- package/dist/agents/nudgeReading.d.ts +3 -3
- package/dist/agents/nudgeReading.js +10 -20
- package/dist/agents/nudgeReading.js.map +1 -1
- package/dist/agents/opencode/nudge.js +3 -1
- package/dist/agents/opencode/nudge.js.map +1 -1
- package/dist/agents/types.d.ts +15 -0
- package/dist/cli/index.js +35 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/client/http.d.ts +3 -1
- package/dist/client/http.js +144 -51
- package/dist/client/http.js.map +1 -1
- package/dist/core/cron.d.ts +6 -0
- package/dist/core/cron.js +63 -0
- package/dist/core/cron.js.map +1 -0
- package/dist/core/environment.d.ts +6 -0
- package/dist/core/environment.js +35 -0
- package/dist/core/environment.js.map +1 -0
- package/dist/core/mailbox.d.ts +1 -0
- package/dist/core/mailbox.js +4 -0
- package/dist/core/mailbox.js.map +1 -1
- package/dist/core/manager.d.ts +1 -0
- package/dist/core/manager.js +3 -0
- package/dist/core/manager.js.map +1 -1
- package/dist/core/nudge.d.ts +1 -1
- package/dist/core/nudge.js +5 -2
- package/dist/core/nudge.js.map +1 -1
- package/dist/core/promptDetector.js +2 -0
- package/dist/core/promptDetector.js.map +1 -1
- package/dist/core/reasoning.js +12 -3
- package/dist/core/reasoning.js.map +1 -1
- package/dist/core/renderer.js +3 -1
- package/dist/core/renderer.js.map +1 -1
- package/dist/core/session.d.ts +17 -7
- package/dist/core/session.js +70 -47
- package/dist/core/session.js.map +1 -1
- package/dist/core/stringWidth.d.ts +2 -0
- package/dist/core/stringWidth.js +13 -0
- package/dist/core/stringWidth.js.map +1 -0
- package/dist/core/types.d.ts +2 -0
- package/dist/core/types.js.map +1 -1
- package/dist/daemon/auth.d.ts +14 -13
- package/dist/daemon/auth.js +42 -25
- package/dist/daemon/auth.js.map +1 -1
- package/dist/daemon/config.d.ts +2 -0
- package/dist/daemon/config.js +7 -0
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/index.js +4 -0
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/launchProfiles.js +12 -8
- package/dist/daemon/launchProfiles.js.map +1 -1
- package/dist/daemon/logger.js +1 -1
- package/dist/daemon/logger.js.map +1 -1
- package/dist/daemon/paths.d.ts +1 -1
- package/dist/daemon/paths.js +52 -9
- package/dist/daemon/paths.js.map +1 -1
- package/dist/daemon/restartHold.js +16 -15
- package/dist/daemon/restartHold.js.map +1 -1
- package/dist/daemon/schedules.d.ts +57 -0
- package/dist/daemon/schedules.js +181 -0
- package/dist/daemon/schedules.js.map +1 -0
- package/dist/daemon/screenshot.d.ts +4 -2
- package/dist/daemon/screenshot.js +10 -1
- package/dist/daemon/screenshot.js.map +1 -1
- package/dist/daemon/server.d.ts +20 -15
- package/dist/daemon/server.js +221 -132
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/viewerLauncher.js +3 -2
- package/dist/daemon/viewerLauncher.js.map +1 -1
- package/dist/daemon/wrappedLaunch.d.ts +1 -0
- package/dist/daemon/wrappedLaunch.js +38 -0
- package/dist/daemon/wrappedLaunch.js.map +1 -0
- package/dist/daemon/wrappedStart.d.ts +13 -0
- package/dist/daemon/wrappedStart.js +113 -0
- package/dist/daemon/wrappedStart.js.map +1 -0
- package/dist/daemon/wrappedSupervisor.d.ts +1 -0
- package/dist/daemon/wrappedSupervisor.js +55 -0
- package/dist/daemon/wrappedSupervisor.js.map +1 -0
- package/dist/mcp/index.js +16 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.js +4 -2
- package/dist/mcp/tools.js.map +1 -1
- package/package.json +1 -1
package/dist/core/session.js
CHANGED
|
@@ -20,6 +20,7 @@ import { execFile } from 'node:child_process';
|
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import * as os from 'node:os';
|
|
22
22
|
import * as path from 'node:path';
|
|
23
|
+
import { childEnv, setEnvValue } from './environment.js';
|
|
23
24
|
import { ensureSpawnHelperExecutable, explainSpawnFailure, loadNodePty } from './nativePty.js';
|
|
24
25
|
import { ScreenRenderer } from './renderer.js';
|
|
25
26
|
import { commandLine } from './policy.js';
|
|
@@ -115,6 +116,8 @@ export const NUDGE_SUBMIT_DELAY_MS = 150;
|
|
|
115
116
|
/** How long a nudge may wait after that pause for the program to paint its line. */
|
|
116
117
|
export const NUDGE_SUBMIT_WAIT_MS = 2000;
|
|
117
118
|
const NUDGE_SUBMIT_POLL_MS = 50;
|
|
119
|
+
/** How long ordinary input may still be buffered behind an empty composer. */
|
|
120
|
+
const RECENT_INPUT_MS = 10_000;
|
|
118
121
|
/** Rows at the foot of the screen that hold a composer, its frame and its footer. */
|
|
119
122
|
const COMPOSER_BLOCK_ROWS = 5;
|
|
120
123
|
/** A horizontal rule or frame edge drawn around a composer. */
|
|
@@ -386,6 +389,7 @@ function resolveExecutable(command, platform, cwd) {
|
|
|
386
389
|
* it had, so passing it on would hand that client's secrets to every session.
|
|
387
390
|
*/
|
|
388
391
|
export const DEFAULT_SESSION_ENV = 'clean';
|
|
392
|
+
export { setEnvValue as setSessionEnvValue } from './environment.js';
|
|
389
393
|
/**
|
|
390
394
|
* The minimal functional variable set for `sessionEnv: "clean"`: enough for
|
|
391
395
|
* shells and ordinary programs to work, without the daemon's secrets. Windows
|
|
@@ -544,27 +548,8 @@ export function buildSessionEnv(mode, platform, source = process.env, passed = {
|
|
|
544
548
|
}
|
|
545
549
|
}
|
|
546
550
|
}
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
if (!isReserved(name))
|
|
550
|
-
setOnly(name, value);
|
|
551
|
-
}
|
|
552
|
-
// Always injected (§7): Windows sets no TERM, and TUIs then assume a dumb
|
|
553
|
-
// terminal and disable colour. On Windows any other casing goes first, or
|
|
554
|
-
// the child would see that copy's value instead of these.
|
|
555
|
-
setOnly('TERM', 'xterm-256color');
|
|
556
|
-
setOnly('COLORTERM', 'truecolor');
|
|
557
|
-
return env;
|
|
558
|
-
}
|
|
559
|
-
/** Assign a daemon-owned value with the same Windows name collapsing as buildSessionEnv. */
|
|
560
|
-
export function setSessionEnvValue(env, platform, name, value) {
|
|
561
|
-
if (platform === 'win32') {
|
|
562
|
-
for (const key of Object.keys(env)) {
|
|
563
|
-
if (key.toUpperCase() === name.toUpperCase())
|
|
564
|
-
delete env[key];
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
env[name] = value;
|
|
551
|
+
const overrides = Object.fromEntries(Object.entries(passed).filter(([name]) => !isReserved(name)));
|
|
552
|
+
return childEnv(platform, env, overrides, { TERM: 'xterm-256color', COLORTERM: 'truecolor' });
|
|
568
553
|
}
|
|
569
554
|
export class Session {
|
|
570
555
|
id;
|
|
@@ -578,10 +563,12 @@ export class Session {
|
|
|
578
563
|
/** The pre-wrap command as given by the caller. */
|
|
579
564
|
command;
|
|
580
565
|
args;
|
|
566
|
+
cwd;
|
|
581
567
|
/** The agent it was started as, which chooses how its screen is read. */
|
|
582
568
|
launchProfile;
|
|
583
569
|
inheritedResumeIds = [];
|
|
584
570
|
observedResumeId;
|
|
571
|
+
observedFileResumeId;
|
|
585
572
|
agent;
|
|
586
573
|
agentSource;
|
|
587
574
|
agentModule;
|
|
@@ -642,6 +629,8 @@ export class Session {
|
|
|
642
629
|
inputQueueVersion = 0;
|
|
643
630
|
/** A nudge body accepted by the PTY without a confirmed submit. */
|
|
644
631
|
pendingNudgeLine = null;
|
|
632
|
+
nudgeSchedule;
|
|
633
|
+
writingNudge = false;
|
|
645
634
|
pendingNudgeIds = [];
|
|
646
635
|
/** Any input from outside the daemon permanently claims this pending composer. */
|
|
647
636
|
pendingNudgeTouched = false;
|
|
@@ -659,6 +648,7 @@ export class Session {
|
|
|
659
648
|
lastChange = Date.now();
|
|
660
649
|
/** When input was last written to the PTY. */
|
|
661
650
|
lastInputAt = 0;
|
|
651
|
+
recentInputUntil = 0;
|
|
662
652
|
/** Sticky: the rendered screen has shown something at least once. */
|
|
663
653
|
painted = false;
|
|
664
654
|
/**
|
|
@@ -693,6 +683,7 @@ export class Session {
|
|
|
693
683
|
this.id = id;
|
|
694
684
|
this.command = options.command;
|
|
695
685
|
this.args = options.args ?? [];
|
|
686
|
+
this.cwd = path.resolve(options.cwd ?? '.');
|
|
696
687
|
this.label = options.label ?? options.command;
|
|
697
688
|
this.launchProfile = options.launchProfile;
|
|
698
689
|
this.role = (options.parent === undefined || options.launchProfile !== undefined) && options.role === 'chair' ? 'chair' : 'delegate';
|
|
@@ -749,7 +740,7 @@ export class Session {
|
|
|
749
740
|
this.logger.info('session spawn', {
|
|
750
741
|
id,
|
|
751
742
|
command: this.command,
|
|
752
|
-
args: this.args,
|
|
743
|
+
args: this.args.map(arg => arg === this.launchProfile?.resumeId ? '[redacted]' : arg),
|
|
753
744
|
wrapped: file !== this.command,
|
|
754
745
|
// Names only: the values are secrets more often than not.
|
|
755
746
|
...(options.env !== undefined ? { envNames: Object.keys(options.env) } : {}),
|
|
@@ -772,27 +763,26 @@ export class Session {
|
|
|
772
763
|
const trackConsoleHost = this.platform === 'win32';
|
|
773
764
|
const consoleHostT0 = trackConsoleHost ? Date.now() : 0;
|
|
774
765
|
const sessionEnv = buildSessionEnv(deps.sessionEnv ?? DEFAULT_SESSION_ENV, this.platform, process.env, options.env);
|
|
775
|
-
if (
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
? Object.fromEntries(Object.entries(sessionEnv).map(([key, value]) => [key.toUpperCase(), value]))
|
|
779
|
-
: sessionEnv;
|
|
780
|
-
this.inheritedResumeIds = agentResumeIds(this.agentModule, original);
|
|
766
|
+
if (this.launchProfile) {
|
|
767
|
+
if (deps.identity && this.agentModule?.resumeIdMarkers) {
|
|
768
|
+
this.inheritedResumeIds = agentResumeIds(this.agentModule, sessionEnv, this.platform);
|
|
781
769
|
sessionEnv['SHELLPUPPET_PROFILE_AGENT'] = this.agent;
|
|
782
770
|
}
|
|
771
|
+
}
|
|
772
|
+
if (deps.identity !== undefined) {
|
|
783
773
|
sessionEnv['SHELLPUPPET_SESSION'] = id;
|
|
784
774
|
sessionEnv['SHELLPUPPET_SESSION_TOKEN'] = deps.identity.token;
|
|
785
775
|
sessionEnv['SHELLPUPPET_DAEMON_INSTANCE'] = deps.identity.instanceId;
|
|
786
776
|
sessionEnv['SHELLPUPPET_CLI'] = deps.identity.cliPath;
|
|
787
777
|
if (deps.identity.home !== undefined) {
|
|
788
|
-
|
|
778
|
+
setEnvValue(sessionEnv, this.platform, 'SHELLPUPPET_HOME', deps.identity.home);
|
|
789
779
|
}
|
|
790
780
|
}
|
|
791
781
|
const spawnOptions = {
|
|
792
782
|
name: 'xterm-256color',
|
|
793
783
|
cols,
|
|
794
784
|
rows,
|
|
795
|
-
cwd:
|
|
785
|
+
cwd: this.cwd,
|
|
796
786
|
// The daemon always passes the mode it resolved and reports; this
|
|
797
787
|
// default serves code that uses SessionManager or Session directly.
|
|
798
788
|
env: sessionEnv,
|
|
@@ -969,7 +959,7 @@ export class Session {
|
|
|
969
959
|
if (!wantShell) {
|
|
970
960
|
return {
|
|
971
961
|
// The same absolute path is checked and started. See `shell` on SessionOptions.
|
|
972
|
-
file: resolveExecutable(options.command, this.platform,
|
|
962
|
+
file: resolveExecutable(options.command, this.platform, this.cwd),
|
|
973
963
|
// node-pty's array serialiser skips outer quoting for an argument
|
|
974
964
|
// which itself begins and ends with quotes. A quoted value containing
|
|
975
965
|
// a space then splits in the child. Its string form is passed through
|
|
@@ -1138,7 +1128,9 @@ export class Session {
|
|
|
1138
1128
|
this.submissionsQueued++;
|
|
1139
1129
|
const queued = this.writeChain.then(async () => {
|
|
1140
1130
|
const result = { before: '', submitRetried: false };
|
|
1141
|
-
result.before = (await this.writeInput(data, options.terminalReport === true, undefined, undefined,
|
|
1131
|
+
result.before = (await this.writeInput(data, options.terminalReport === true, undefined, undefined, undefined, [], () => 'line-not-seen', (outcome) => Object.assign(result, outcome))) ?? '';
|
|
1132
|
+
if (result.submitted === true)
|
|
1133
|
+
this.recentInputUntil = 0;
|
|
1142
1134
|
return result;
|
|
1143
1135
|
});
|
|
1144
1136
|
// The chain must survive a failed write, or one rejection would wedge every
|
|
@@ -1154,13 +1146,15 @@ export class Session {
|
|
|
1154
1146
|
return result === 'sent' || result === 'wait' ? result : 'aborted';
|
|
1155
1147
|
}
|
|
1156
1148
|
/** Queue a daemon nudge, reporting why a typed body could not be submitted. */
|
|
1157
|
-
writeNudgeWithReason(data, ready, messageIds = [], failedCheck = () => 'line-not-seen') {
|
|
1149
|
+
writeNudgeWithReason(data, ready, messageIds = [], failedCheck = () => 'line-not-seen', schedule, queuedDelivery = false) {
|
|
1158
1150
|
let abortReason = null;
|
|
1159
1151
|
const queued = this.writeChain.then(async () => {
|
|
1160
1152
|
try {
|
|
1161
1153
|
if (this.pendingNudgeLine !== null)
|
|
1162
1154
|
return 'wait';
|
|
1163
|
-
|
|
1155
|
+
this.nudgeSchedule = schedule;
|
|
1156
|
+
this.writingNudge = true;
|
|
1157
|
+
const result = await this.writeInput(data, false, ready, (reason) => { abortReason = reason; }, this.nudgeSubmit(queuedDelivery), messageIds, failedCheck);
|
|
1164
1158
|
return abortReason !== null ? `aborted-${abortReason}`
|
|
1165
1159
|
: result === null ? 'wait' : 'sent';
|
|
1166
1160
|
}
|
|
@@ -1169,11 +1163,15 @@ export class Session {
|
|
|
1169
1163
|
return `aborted-${abortReason}`;
|
|
1170
1164
|
throw error;
|
|
1171
1165
|
}
|
|
1166
|
+
finally {
|
|
1167
|
+
this.writingNudge = false;
|
|
1168
|
+
}
|
|
1172
1169
|
});
|
|
1173
1170
|
this.writeChain = queued.then(() => undefined, () => undefined);
|
|
1174
1171
|
return queued;
|
|
1175
1172
|
}
|
|
1176
1173
|
nudgePendingLine() { return this.pendingNudgeLine; }
|
|
1174
|
+
pendingSchedule() { return this.pendingNudgeLine === null ? undefined : this.nudgeSchedule; }
|
|
1177
1175
|
nudgePendingIds() { return this.pendingNudgeIds; }
|
|
1178
1176
|
nudgePendingUntouched() { return !this.pendingNudgeTouched; }
|
|
1179
1177
|
nudgePendingTouchRefusal() {
|
|
@@ -1184,9 +1182,12 @@ export class Session {
|
|
|
1184
1182
|
}
|
|
1185
1183
|
/** Clear after an observed submitted turn or a whole quiet period of proven emptiness. */
|
|
1186
1184
|
async clearConsumedNudge() {
|
|
1187
|
-
if (this.pendingNudgeLine === null)
|
|
1185
|
+
if (this.pendingNudgeLine === null || this.writingNudge)
|
|
1188
1186
|
return false;
|
|
1187
|
+
const line = this.pendingNudgeLine;
|
|
1189
1188
|
await this.renderer.flush();
|
|
1189
|
+
if (this.pendingNudgeLine !== line || this.writingNudge)
|
|
1190
|
+
return false;
|
|
1190
1191
|
const verdict = this.pendingComposerVerdict();
|
|
1191
1192
|
if (!verdict.ready && verdict.reason === 'busy' && this.pendingTurnSubmitted)
|
|
1192
1193
|
this.pendingTurnBusy = true;
|
|
@@ -1230,12 +1231,13 @@ export class Session {
|
|
|
1230
1231
|
nudgeReady(now) {
|
|
1231
1232
|
return this.nudgeState(now).ready;
|
|
1232
1233
|
}
|
|
1234
|
+
get recentInput() { return Date.now() < this.recentInputUntil; }
|
|
1233
1235
|
/**
|
|
1234
1236
|
* Whether a nudge may be typed now, and whether it would be queued behind a
|
|
1235
1237
|
* running turn. Each call also measures how long the composer block (the
|
|
1236
1238
|
* last rows on screen) has stayed the same, which a queued nudge waits on.
|
|
1237
1239
|
*/
|
|
1238
|
-
nudgeState(now) {
|
|
1240
|
+
nudgeState(now, whenBusy) {
|
|
1239
1241
|
const view = this.nudgeView();
|
|
1240
1242
|
const nudge = this.agentModule?.nudge;
|
|
1241
1243
|
const pane = nudge?.idlePane?.(view);
|
|
@@ -1244,18 +1246,23 @@ export class Session {
|
|
|
1244
1246
|
this.nudgeComposerKey = key;
|
|
1245
1247
|
this.nudgeComposerSince = now;
|
|
1246
1248
|
}
|
|
1249
|
+
if (this.recentInput) {
|
|
1250
|
+
return { ready: false, reason: 'recent-input', queued: false, paneQuiet: pane !== undefined, regionKey: key };
|
|
1251
|
+
}
|
|
1247
1252
|
const verdict = nudgeVerdict(this.agentModule, {
|
|
1248
1253
|
...view,
|
|
1254
|
+
whenBusy,
|
|
1249
1255
|
stall: this.getStalled(),
|
|
1250
1256
|
unchangedMs: now - (pane === undefined ? this.lastChangeAt() : this.nudgeComposerSince),
|
|
1251
1257
|
composerUnchangedMs: now - this.nudgeComposerSince,
|
|
1252
1258
|
});
|
|
1253
1259
|
const queued = verdict.ready && verdict.queued === true;
|
|
1254
|
-
return {
|
|
1260
|
+
return { ...verdict, queued, paneQuiet: pane !== undefined, regionKey: key };
|
|
1255
1261
|
}
|
|
1256
1262
|
nudgeView() {
|
|
1257
1263
|
const styled = this.renderer.styledLines().lines;
|
|
1258
|
-
return { styled, rows: styled.map(line => line.text), cursor: this.renderer.cursor,
|
|
1264
|
+
return { styled, rows: styled.map(line => line.text), cursor: this.renderer.cursor,
|
|
1265
|
+
viewportRows: this.renderer.rows, viewportCols: this.renderer.cols,
|
|
1259
1266
|
untrimmedRow: (y) => this.renderer.untrimmedRow(y) };
|
|
1260
1267
|
}
|
|
1261
1268
|
pendingComposerVerdict() {
|
|
@@ -1282,16 +1289,19 @@ export class Session {
|
|
|
1282
1289
|
const before = row.slice(0, view.cursor.x).replace(/\s+$/u, '');
|
|
1283
1290
|
return SHELL_PROMPTS.some((pattern) => pattern.test(before));
|
|
1284
1291
|
}
|
|
1285
|
-
nudgeSubmit() {
|
|
1292
|
+
nudgeSubmit(queued = false) {
|
|
1293
|
+
if (queued && this.agentModule?.nudge?.queueKey !== undefined)
|
|
1294
|
+
return this.agentModule.nudge.queueKey;
|
|
1286
1295
|
return this.agentModule?.input?.submit?.key ?? '\r';
|
|
1287
1296
|
}
|
|
1288
1297
|
nudgeInputVersion() { return this.inputVersion; }
|
|
1289
1298
|
nudgeQueuedInputVersion() { return this.inputQueueVersion; }
|
|
1290
1299
|
nudgeScreenRevision() { return this.screenRevision; }
|
|
1291
|
-
nudgeReadyWithLine(line) {
|
|
1300
|
+
nudgeReadyWithLine(line, queued = false, whenBusy) {
|
|
1292
1301
|
return nudgeVerdict(this.agentModule, {
|
|
1293
1302
|
...this.nudgeView(),
|
|
1294
|
-
stall: this.getStalled(), unchangedMs: 0, expectedDraft: line,
|
|
1303
|
+
stall: this.getStalled(), unchangedMs: 0, expectedDraft: line, whenBusy,
|
|
1304
|
+
queueDraft: queued && this.agentModule?.nudge?.queueKey !== undefined,
|
|
1295
1305
|
}).ready;
|
|
1296
1306
|
}
|
|
1297
1307
|
/** Paste placeholders on the viewport before this body is written. */
|
|
@@ -1309,10 +1319,11 @@ export class Session {
|
|
|
1309
1319
|
}
|
|
1310
1320
|
/** The exact draft or a new, length-matched paste placeholder. */
|
|
1311
1321
|
typedDraftVisible(body, placeholdersBefore) {
|
|
1312
|
-
const
|
|
1313
|
-
if (
|
|
1322
|
+
const submit = this.agentModule?.input?.submit;
|
|
1323
|
+
if (submit?.pastePlaceholder !== undefined && placeholdersBefore !== null &&
|
|
1324
|
+
submit.pastePlaceholderBody?.test(body) !== false) {
|
|
1314
1325
|
for (const line of this.renderer.styledLines().lines) {
|
|
1315
|
-
const match =
|
|
1326
|
+
const match = submit.pastePlaceholder.exec(line.text);
|
|
1316
1327
|
if (match?.[1] === undefined || !this.nudgeReadyWithLine(match[1]))
|
|
1317
1328
|
continue;
|
|
1318
1329
|
const shownChars = match.groups?.['chars'];
|
|
@@ -1346,7 +1357,8 @@ export class Session {
|
|
|
1346
1357
|
const submit = this.agentModule?.input?.submit;
|
|
1347
1358
|
return submit?.delayMs !== undefined && submit.matches?.(data) === true;
|
|
1348
1359
|
}
|
|
1349
|
-
async writeInput(data, terminalReport, ready, onNudgeAbort,
|
|
1360
|
+
async writeInput(data, terminalReport, ready, onNudgeAbort, nudgeKey, messageIds = [], failedCheck = () => 'line-not-seen', onTypedSubmit) {
|
|
1361
|
+
const nudge = nudgeKey !== undefined;
|
|
1350
1362
|
this.refuseIfInputFailed();
|
|
1351
1363
|
if (ready !== undefined)
|
|
1352
1364
|
await this.renderer.flush();
|
|
@@ -1368,6 +1380,9 @@ export class Session {
|
|
|
1368
1380
|
// input is answering: the waiter's stale-prompt guard needs that prompt,
|
|
1369
1381
|
// and its echo guard needs the input itself.
|
|
1370
1382
|
this.lastInputData = data;
|
|
1383
|
+
if (!nudge && !terminalReport && data.length > 0) {
|
|
1384
|
+
this.recentInputUntil = Date.now() + RECENT_INPUT_MS;
|
|
1385
|
+
}
|
|
1371
1386
|
if (!terminalReport && data.length > 0) {
|
|
1372
1387
|
// Discovery may still be queued. Capture the screen this input answers
|
|
1373
1388
|
// before suppressing it, so a delayed check cannot announce that old turn.
|
|
@@ -1389,7 +1404,7 @@ export class Session {
|
|
|
1389
1404
|
this.stalePrompts.noteInput(screen, this.agent, this.renderer.promptStyles(lines));
|
|
1390
1405
|
if (nudge || this.delayedSubmission(data)) {
|
|
1391
1406
|
const submit = this.agentModule?.input?.submit;
|
|
1392
|
-
const key =
|
|
1407
|
+
const key = nudgeKey ?? submit.key;
|
|
1393
1408
|
const body = data.slice(0, -key.length);
|
|
1394
1409
|
const delayMs = nudge ? Math.max(NUDGE_SUBMIT_DELAY_MS, submit?.delayMs ?? 0)
|
|
1395
1410
|
: Math.max(submit.delayMs, Math.ceil(Array.from(body).length * (submit?.perCharacterMs ?? 0)));
|
|
@@ -1732,8 +1747,15 @@ export class Session {
|
|
|
1732
1747
|
if (own !== undefined)
|
|
1733
1748
|
this.observedResumeId = own;
|
|
1734
1749
|
}
|
|
1750
|
+
/** Claude's validated live session file takes precedence over environment markers. */
|
|
1751
|
+
observeClaudeFileResumeId(id) {
|
|
1752
|
+
if (this.agent !== 'claude' || !this.launchProfile || !validResumeId(id))
|
|
1753
|
+
return false;
|
|
1754
|
+
this.observedFileResumeId = id;
|
|
1755
|
+
return true;
|
|
1756
|
+
}
|
|
1735
1757
|
get resumeId() {
|
|
1736
|
-
return this.observedResumeId ?? this.launchProfile?.resumeId ?? null;
|
|
1758
|
+
return this.observedFileResumeId ?? this.observedResumeId ?? this.launchProfile?.resumeId ?? null;
|
|
1737
1759
|
}
|
|
1738
1760
|
getStalled() { return this.stallState; }
|
|
1739
1761
|
noteStallResize(changed) {
|
|
@@ -2087,6 +2109,7 @@ export class Session {
|
|
|
2087
2109
|
agent: this.agent,
|
|
2088
2110
|
command: this.command,
|
|
2089
2111
|
args: this.args,
|
|
2112
|
+
cwd: this.cwd,
|
|
2090
2113
|
cols: this.cols,
|
|
2091
2114
|
rows: this.rows,
|
|
2092
2115
|
ready: this.readyFlag,
|