replit-tools 1.2.37 → 1.2.39

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replit-tools",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "description": "DATA Tools - One command to set up Claude Code and Codex CLI on Replit with full persistence",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -130,22 +130,6 @@ get_recent_sessions() {
130
130
  const id = meta.payload.id;
131
131
  const firstTs = Date.parse(meta.payload.timestamp || meta.timestamp);
132
132
 
133
- const cleanUser = (raw) => {
134
- if (!raw) return '';
135
- let t = raw
136
- .replace(/<environment_context>[\s\S]*?<\/environment_context>/g, '')
137
- .replace(/<user_instructions>[\s\S]*?<\/user_instructions>/g, '')
138
- .replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '')
139
- .replace(/<command-name>[\s\S]*?<\/command-name>/g, '')
140
- .replace(/<command-message>[\s\S]*?<\/command-message>/g, '')
141
- .replace(/<command-args>[\s\S]*?<\/command-args>/g, '')
142
- .replace(/<local-command-stdout>[\s\S]*?<\/local-command-stdout>/g, '')
143
- .replace(/<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g, '')
144
- .trim();
145
- if (t.startsWith('# AGENTS.md')) return '';
146
- return t;
147
- };
148
-
149
133
  let lastTs = firstTs;
150
134
  let firstPrompt = '';
151
135
  let lastPrompt = '';
@@ -154,9 +138,9 @@ get_recent_sessions() {
154
138
  try {
155
139
  const j = JSON.parse(ln);
156
140
  if (j.timestamp) lastTs = Math.max(lastTs, Date.parse(j.timestamp));
157
- if (j.type === 'response_item' && j.payload && j.payload.role === 'user' && Array.isArray(j.payload.content)) {
158
- const raw = (j.payload.content.find(c => c.type === 'input_text') || {}).text || '';
159
- const text = cleanUser(raw);
141
+ // event_msg.user_message = actual user-typed input only (no AGENTS.md, no env_context)
142
+ if (j.type === 'event_msg' && j.payload && j.payload.type === 'user_message') {
143
+ const text = (j.payload.message || '').trim();
160
144
  if (text) {
161
145
  if (!firstPrompt) firstPrompt = text;
162
146
  lastPrompt = text;
@@ -166,8 +150,12 @@ get_recent_sessions() {
166
150
  } catch(e) {}
167
151
  }
168
152
 
169
- // Skip sessions with no real user input (sub-agents, programmatic runs)
153
+ // Skip sessions with no real user-typed input
170
154
  if (msgCount === 0 || !firstPrompt) continue;
155
+ // Skip sub-agent sessions: first message is an agent system prompt
156
+ if (/^(you are |you're |\\*\\*role\\*\\*|<role>|## role)/i.test(firstPrompt)) continue;
157
+ // Skip if first message is suspiciously long single-shot agent task (no follow-ups)
158
+ if (msgCount === 1 && firstPrompt.length > 500) continue;
171
159
 
172
160
  const stat = fs.statSync(f);
173
161
  sessionData.set('codex:' + id, {
@@ -395,22 +383,6 @@ get_recent_24h_sessions() {
395
383
  const id = meta.payload.id;
396
384
  const firstTs = Date.parse(meta.payload.timestamp || meta.timestamp);
397
385
 
398
- const cleanUser = (raw) => {
399
- if (!raw) return '';
400
- let t = raw
401
- .replace(/<environment_context>[\s\S]*?<\/environment_context>/g, '')
402
- .replace(/<user_instructions>[\s\S]*?<\/user_instructions>/g, '')
403
- .replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '')
404
- .replace(/<command-name>[\s\S]*?<\/command-name>/g, '')
405
- .replace(/<command-message>[\s\S]*?<\/command-message>/g, '')
406
- .replace(/<command-args>[\s\S]*?<\/command-args>/g, '')
407
- .replace(/<local-command-stdout>[\s\S]*?<\/local-command-stdout>/g, '')
408
- .replace(/<local-command-caveat>[\s\S]*?<\/local-command-caveat>/g, '')
409
- .trim();
410
- if (t.startsWith('# AGENTS.md')) return '';
411
- return t;
412
- };
413
-
414
386
  let lastTs = firstTs;
415
387
  let firstPrompt = '';
416
388
  let realMsgCount = 0;
@@ -418,8 +390,9 @@ get_recent_24h_sessions() {
418
390
  try {
419
391
  const j = JSON.parse(ln);
420
392
  if (j.timestamp) lastTs = Math.max(lastTs, Date.parse(j.timestamp));
421
- if (j.type === 'response_item' && j.payload && j.payload.role === 'user' && Array.isArray(j.payload.content)) {
422
- const text = cleanUser((j.payload.content.find(c => c.type === 'input_text') || {}).text || '');
393
+ // event_msg.user_message = actual user-typed input only
394
+ if (j.type === 'event_msg' && j.payload && j.payload.type === 'user_message') {
395
+ const text = (j.payload.message || '').trim();
423
396
  if (text) {
424
397
  if (!firstPrompt) firstPrompt = text;
425
398
  realMsgCount++;
@@ -428,8 +401,11 @@ get_recent_24h_sessions() {
428
401
  } catch(e) {}
429
402
  }
430
403
 
431
- // Skip sub-agent / programmatic sessions with no real user prompt
404
+ // Skip sub-agent / programmatic sessions
432
405
  if (realMsgCount === 0 || !firstPrompt) continue;
406
+ // Skip sub-agent sessions: first message is an agent system prompt
407
+ if (/^(you are |you're |\\*\\*role\\*\\*|<role>|## role)/i.test(firstPrompt)) continue;
408
+ if (realMsgCount === 1 && firstPrompt.length > 500) continue;
433
409
 
434
410
  sessions.set('codex:' + id, { tool: 'codex', id, firstSeen: firstTs, lastSeen: lastTs, firstPrompt });
435
411
  } catch(e) {}