@supen-ai/cli 1.4.0 → 1.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.
@@ -23,13 +23,14 @@ import { buildDaemonOpenApiSpec } from '../../channels/http-routes.js';
23
23
  import { writeJson, writeProtocolError, readJsonBody } from '../response.js';
24
24
  import { listRecentThreadEventsAfter, readThreadEventLogHead, } from '../../core/thread-event-log.js';
25
25
  import { projectThreadRuntimeState } from '../../core/thread-runtime-state.js';
26
+ import { attachThreadContextToChunk, readThreadContext, } from '../../core/thread-context.js';
26
27
  import { addThreadStreamClient, removeThreadStreamClient, writeThreadStreamEvent } from '../thread-stream.js';
27
28
  const DEFAULT_TOKEN_TTL_MINUTES = 20;
28
29
  const SPACE_LOG_EVENT_LIMIT = 200;
29
30
  const SPACE_LOG_STREAM_POLL_MS = 1000;
30
31
  const SPACE_LOG_STREAM_PING_MS = 15000;
31
32
  const MIRRORED_THREAD_LIMIT = 80;
32
- const MIRRORED_THREAD_HISTORY_LIMIT = 100;
33
+ const MIRRORED_THREAD_HISTORY_LIMIT = 200;
33
34
  const MIRRORED_THREAD_HISTORY_MAX_BYTES = 256 * 1024 * 1024;
34
35
  const MIRRORED_THREAD_PROJECTION_VERSION = 2;
35
36
  const MIRRORED_THREAD_TEXT_LIMIT = 48_000;
@@ -1354,7 +1355,7 @@ function collapseCompletedAssistantProgressMessages(input) {
1354
1355
  .map(({ phase: _phase, internal: _internal, ...message }) => message);
1355
1356
  }
1356
1357
  export function readCodexThreadHistory(threadId, limit = MIRRORED_THREAD_HISTORY_LIMIT, options = {}) {
1357
- const safeLimit = Math.max(1, Math.min(limit, 500));
1358
+ const safeLimit = Math.max(1, Math.min(limit, 1000));
1358
1359
  const sessionPath = walkSessionFiles(path.join(localAgentHome(), 'sessions')).get(threadId);
1359
1360
  if (!sessionPath)
1360
1361
  return null;
@@ -1363,7 +1364,7 @@ export function readCodexThreadHistory(threadId, limit = MIRRORED_THREAD_HISTORY
1363
1364
  const workspacePath = mirroredThreadWorkspacePath(sessionPath, stateEntry);
1364
1365
  const indexEntry = readThreadIndexEntry(threadId);
1365
1366
  const eventLogHead = readThreadEventLogHead(eventLogThreadId);
1366
- const historyLineTarget = Math.min(120, Math.max(3, Math.ceil(safeLimit / 4)));
1367
+ const historyLineTarget = Math.min(250, Math.max(3, Math.ceil(safeLimit / 4)));
1367
1368
  const lines = readRecentCodexHistoryLines(sessionPath, historyLineTarget);
1368
1369
  const messages = [];
1369
1370
  const events = [];
@@ -1574,6 +1575,11 @@ export function readCodexThreadHistory(threadId, limit = MIRRORED_THREAD_HISTORY
1574
1575
  const slicedEvents = events.slice(-safeLimit * 8);
1575
1576
  const status = readMirroredThreadStatus(eventLogThreadId, sessionPath);
1576
1577
  const latestGoalContext = recentGoalContext;
1578
+ const context = readThreadContext({
1579
+ threadId,
1580
+ eventLogThreadId,
1581
+ workspace: workspacePath,
1582
+ });
1577
1583
  return {
1578
1584
  session: {
1579
1585
  task_id: threadId,
@@ -1600,6 +1606,7 @@ export function readCodexThreadHistory(threadId, limit = MIRRORED_THREAD_HISTORY
1600
1606
  updated_at: latestTimestamp || undefined,
1601
1607
  },
1602
1608
  },
1609
+ context,
1603
1610
  has_more: collapsedMessages.length > safeLimit || lines.length >= historyLineTarget,
1604
1611
  ...(latestGoalContext ? { goal_context: latestGoalContext } : {}),
1605
1612
  };
@@ -2973,12 +2980,13 @@ export async function handleSystemRoutes(req, res, url, pathname, method) {
2973
2980
  let jsonlOffset = sessionPath && fs.existsSync(sessionPath) ? fs.statSync(sessionPath).size : 0;
2974
2981
  let jsonlEventIndex = 0;
2975
2982
  const workspacePath = readThreadWorkspacePath(sessionPath) || process.cwd();
2983
+ const withThreadContext = (chunk) => attachThreadContextToChunk(chunk, readThreadContext({ threadId, workspace: workspacePath }));
2976
2984
  const stopCodexObserver = process.env.NODE_ENV === 'test'
2977
2985
  ? () => { }
2978
2986
  : startCodexThreadObserver({
2979
2987
  threadId,
2980
2988
  cwd: workspacePath,
2981
- write: (chunk, id) => writeThreadStreamEvent(res, chunk, id ? { id } : {}),
2989
+ write: (chunk, id) => writeThreadStreamEvent(res, withThreadContext(chunk), id ? { id } : {}),
2982
2990
  });
2983
2991
  const pingTimer = setInterval(() => {
2984
2992
  writeSse(res);
@@ -2998,7 +3006,7 @@ export async function handleSystemRoutes(req, res, url, pathname, method) {
2998
3006
  if (isCodexJsonlMessageRecord(parsed))
2999
3007
  continue;
3000
3008
  jsonlEventIndex += 1;
3001
- writeThreadStreamEvent(res, codexJsonlEventChunk(parsed), {
3009
+ writeThreadStreamEvent(res, withThreadContext(codexJsonlEventChunk(parsed)), {
3002
3010
  id: `jsonl-${jsonlOffset}-${jsonlEventIndex}`,
3003
3011
  });
3004
3012
  }
@@ -3025,7 +3033,7 @@ export async function handleSystemRoutes(req, res, url, pathname, method) {
3025
3033
  const chunk = threadStreamChunkForEvent(event);
3026
3034
  if (!chunk)
3027
3035
  continue;
3028
- writeThreadStreamEvent(res, chunk, { id: event.sequence });
3036
+ writeThreadStreamEvent(res, withThreadContext(chunk), { id: event.sequence });
3029
3037
  }
3030
3038
  res.flush?.();
3031
3039
  return true;