@mmmbuto/nexuscrew 0.9.57 → 0.9.59

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.
@@ -118,8 +118,10 @@ function execTmux(execFileImpl, tmuxBin, args, timeout = 5000) {
118
118
  // risolto prima del paste e verificato di nuovo prima dell'Enter, evitando
119
119
  // prefix match e il riuso del solo nome sessione.
120
120
  async function submitToSession(tmuxBin, session, text, opts = {}) {
121
+ let pasteAttempted = false;
122
+ const failed = reason => ({ submitted: false, outcome: pasteAttempted ? 'delivery-unknown' : 'failed-pre-paste', reason });
121
123
  if (!isValidSession(session) || !submitTextOk(text)) {
122
- return { submitted: false, reason: 'input non valido' };
124
+ return failed('input non valido');
123
125
  }
124
126
  const execFileImpl = opts.execFileImpl || execFile;
125
127
  const fsImpl = opts.fsImpl || fs;
@@ -128,7 +130,7 @@ async function submitToSession(tmuxBin, session, text, opts = {}) {
128
130
  ? opts.delay : (ms) => new Promise((resolve) => setTimeout(resolve, ms));
129
131
  const codexComposer = /^(?:codex|codex-vl)(?:\.|$)/.test(String(opts.engine || ''));
130
132
  const nonce = (opts.nonce || crypto.randomBytes(8).toString('hex')).replace(/[^a-f0-9]/g, '').slice(0, 32);
131
- if (!nonce) return { submitted: false, reason: 'invio non disponibile' };
133
+ if (!nonce) return failed('invio non disponibile');
132
134
  const buffer = `ncmsg-${nonce}`;
133
135
  const tmp = path.join(tmpRoot, `.nexuscrew-message-${nonce}.txt`);
134
136
  let loaded = false;
@@ -139,14 +141,15 @@ async function submitToSession(tmuxBin, session, text, opts = {}) {
139
141
  ['display-message', '-p', '-t', `=${session}:`, '#{pane_id}']);
140
142
  const paneId = pane.stdout.trim();
141
143
  if (!pane.ok || !/^%[0-9]+$/.test(paneId)) {
142
- return { submitted: false, reason: 'sessione non raggiungibile' };
144
+ return failed('sessione non raggiungibile');
143
145
  }
144
146
  const load = await execTmux(execFileImpl, tmuxBin, ['load-buffer', '-b', buffer, tmp]);
145
- if (!load.ok) return { submitted: false, reason: 'buffer non disponibile' };
147
+ if (!load.ok) return failed('buffer non disponibile');
146
148
  loaded = true;
149
+ pasteAttempted = true;
147
150
  const paste = await execTmux(execFileImpl, tmuxBin,
148
151
  ['paste-buffer', '-p', '-t', paneId, '-b', buffer]);
149
- if (!paste.ok) return { submitted: false, reason: 'consegna non riuscita' };
152
+ if (!paste.ok) return failed('consegna non riuscita');
150
153
  const paneAlive = async () => {
151
154
  const verify = await execTmux(execFileImpl, tmuxBin,
152
155
  ['display-message', '-p', '-t', paneId, '#{session_name}\t#{pane_dead}\t#{pane_id}']);
@@ -190,20 +193,20 @@ async function submitToSession(tmuxBin, session, text, opts = {}) {
190
193
  // messaggio lungo conviene verificare che la cella si sia mossa.
191
194
  const attesaBase = codexComposer ? 400 : 150;
192
195
  await delay(attesaBase + Math.floor(text.length / 500) * 150);
193
- if (!(await paneAlive())) return { submitted: false, reason: 'sessione terminata durante la consegna' };
196
+ if (!(await paneAlive())) return failed('sessione terminata durante la consegna');
194
197
  if (codexComposer) {
195
198
  const flush = await execTmux(execFileImpl, tmuxBin, ['send-keys', '-t', paneId, 'C-e']);
196
- if (!flush.ok) return { submitted: false, reason: 'testo consegnato ma flush composer non riuscito' };
199
+ if (!flush.ok) return failed('testo consegnato ma flush composer non riuscito');
197
200
  await delay(300);
198
- if (!(await paneAlive())) return { submitted: false, reason: 'sessione terminata durante la consegna' };
201
+ if (!(await paneAlive())) return failed('sessione terminata durante la consegna');
199
202
  }
200
203
  const enter = await execTmux(execFileImpl, tmuxBin, ['send-keys', '-t', paneId, 'Enter']);
201
- if (!enter.ok) return { submitted: false, reason: 'testo consegnato ma invio non riuscito' };
202
- return { submitted: true, reason: codexComposer
204
+ if (!enter.ok) return failed('testo consegnato ma invio non riuscito');
205
+ return { submitted: true, outcome: 'submitted', reason: codexComposer
203
206
  ? 'bracketed paste + burst flush + Enter separati'
204
207
  : 'bracketed paste + Enter separato' };
205
208
  } catch (_) {
206
- return { submitted: false, reason: 'consegna non riuscita' };
209
+ return failed('consegna non riuscita');
207
210
  } finally {
208
211
  if (loaded) await execTmux(execFileImpl, tmuxBin, ['delete-buffer', '-b', buffer]);
209
212
  try { fsImpl.unlinkSync(tmp); } catch (_) { /* cleanup best-effort */ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/nexuscrew",
3
- "version": "0.9.57",
3
+ "version": "0.9.59",
4
4
  "description": "Faithful browser tmux client — attach to live sessions over a real PTY, localhost-only, mobile-easy",
5
5
  "main": "lib/server.js",
6
6
  "bin": {