@xcanwin/manyoyo 7.0.4 → 7.0.5

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/lib/web/server.js CHANGED
@@ -442,7 +442,7 @@ function getWebAgentSession(history, agentId, options = {}) {
442
442
  }
443
443
  const requestedAgentId = String(agentId || WEB_DEFAULT_AGENT_ID).trim() || WEB_DEFAULT_AGENT_ID;
444
444
  const existing = sessionHistory.agents[requestedAgentId];
445
- if (isVisibleWebAgentSession(existing)) {
445
+ if (isVisibleWebAgentSession(existing) || (options.includeArchived === true && Boolean(existing))) {
446
446
  return existing;
447
447
  }
448
448
  if (options.create === true) {
@@ -460,7 +460,7 @@ function listWebAgentSessions(history, options = {}) {
460
460
  : {};
461
461
  const visibleSessions = Object.keys(agents)
462
462
  .map(agentId => agents[agentId])
463
- .filter(isVisibleWebAgentSession);
463
+ .filter(agentSession => isVisibleWebAgentSession(agentSession) || (options.includeArchived === true && Boolean(agentSession)));
464
464
  if (!visibleSessions.length && options.includeSyntheticDefault === true) {
465
465
  return [{ ...createEmptyWebAgentSession(WEB_DEFAULT_AGENT_ID), synthetic: true }];
466
466
  }
@@ -522,7 +522,7 @@ function appendWebSessionMessage(webHistoryDir, sessionRefOrContainerName, role,
522
522
  ? { containerName: sessionRefOrContainerName, agentId: WEB_DEFAULT_AGENT_ID }
523
523
  : sessionRefOrContainerName;
524
524
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
525
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
525
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
526
526
  const timestamp = new Date().toISOString();
527
527
  const message = {
528
528
  id: createWebSessionMessageId(),
@@ -548,7 +548,7 @@ function appendWebSessionMessage(webHistoryDir, sessionRefOrContainerName, role,
548
548
 
549
549
  function appendWebSessionControlEvent(webHistoryDir, sessionRef, type, data = {}) {
550
550
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
551
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
551
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
552
552
  const events = Array.isArray(agentSession.events) ? agentSession.events : [];
553
553
  const lastEvent = events.length ? events[events.length - 1] : null;
554
554
  const event = createControlEvent({
@@ -589,7 +589,7 @@ function patchWebSessionMessage(webHistoryDir, sessionRefOrContainerName, messag
589
589
  return null;
590
590
  }
591
591
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
592
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
592
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
593
593
  const nextPatch = patch && typeof patch === 'object' ? patch : {};
594
594
  const message = agentSession.messages.find(item => item && String(item.id || '') === targetId);
595
595
  if (!message) {
@@ -617,7 +617,7 @@ function removeWebSessionMessage(webHistoryDir, sessionRefOrContainerName, messa
617
617
  return null;
618
618
  }
619
619
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
620
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
620
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
621
621
  const index = agentSession.messages.findIndex(item => item && String(item.id || '') === targetId);
622
622
  if (index === -1) {
623
623
  return null;
@@ -644,7 +644,7 @@ function setWebAgentSessionPromptCommand(webHistoryDir, sessionRefOrContainerNam
644
644
  throw new Error('默认 AGENT 请直接修改容器级 agentPromptCommand');
645
645
  }
646
646
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
647
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
647
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
648
648
  agentSession.agentPromptCommand = normalizeAgentPromptCommandTemplate(
649
649
  agentPromptCommand,
650
650
  `agents.${sessionRef.agentId}.agentPromptCommand`
@@ -728,7 +728,7 @@ function patchWebAgentSessionState(webHistoryDir, sessionRefOrContainerName, pat
728
728
  ? { containerName: sessionRefOrContainerName, agentId: WEB_DEFAULT_AGENT_ID }
729
729
  : sessionRefOrContainerName;
730
730
  const history = loadWebSessionHistory(webHistoryDir, sessionRef.containerName);
731
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
731
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
732
732
  if (!patch || typeof patch !== 'object') {
733
733
  return agentSession;
734
734
  }
@@ -1991,7 +1991,7 @@ function prepareCodexTraceEvent(payload) {
1991
1991
 
1992
1992
  async function prepareWebAgentExecution(ctx, state, sessionRef, prompt) {
1993
1993
  const history = loadWebSessionHistory(state.webHistoryDir, sessionRef.containerName);
1994
- const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true });
1994
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { create: true, includeArchived: true });
1995
1995
  const containerMap = listWebManyoyoContainers(ctx);
1996
1996
  const containerInfo = containerMap[sessionRef.containerName] || {};
1997
1997
  const normalizedContainerTemplate = normalizeAgentPromptCommandTemplate(history.agentPromptCommand, 'agentPromptCommand');
@@ -3846,7 +3846,7 @@ function buildSessionSummary(ctx, state, containerMap, sessionRef) {
3846
3846
  const containerName = sessionRef && sessionRef.containerName ? sessionRef.containerName : '';
3847
3847
  const agentId = sessionRef && sessionRef.agentId ? sessionRef.agentId : WEB_DEFAULT_AGENT_ID;
3848
3848
  const history = loadWebSessionHistory(state.webHistoryDir, containerName);
3849
- const realAgentSession = getWebAgentSession(history, agentId);
3849
+ const realAgentSession = getWebAgentSession(history, agentId, { includeArchived: true });
3850
3850
  const agentSession = realAgentSession
3851
3851
  || (agentId === WEB_DEFAULT_AGENT_ID ? createEmptyWebAgentSession(WEB_DEFAULT_AGENT_ID) : null);
3852
3852
  if (!agentSession) {
@@ -3890,6 +3890,7 @@ function buildSessionSummary(ctx, state, containerMap, sessionRef) {
3890
3890
  model: agentSession.model || '',
3891
3891
  hostPath: applied.hostPath || '',
3892
3892
  containerPath: applied.containerPath || '',
3893
+ archived: agentSession.archived === true,
3893
3894
  ...(synthetic ? { synthetic: true } : {})
3894
3895
  };
3895
3896
  }
@@ -3942,7 +3943,7 @@ function buildSessionDetail(ctx, state, containerMap, name) {
3942
3943
  containerInfo.defaultCommand
3943
3944
  );
3944
3945
  const summary = buildSessionSummary(ctx, state, containerMap, sessionRef);
3945
- const agentSession = getWebAgentSession(history, sessionRef.agentId)
3946
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { includeArchived: true })
3946
3947
  || (sessionRef.agentId === WEB_DEFAULT_AGENT_ID ? createEmptyWebAgentSession(WEB_DEFAULT_AGENT_ID) : null);
3947
3948
  const latestMessage = agentSession && agentSession.messages.length
3948
3949
  ? agentSession.messages[agentSession.messages.length - 1]
@@ -3982,7 +3983,7 @@ function buildSessionDetail(ctx, state, containerMap, name) {
3982
3983
 
3983
3984
  function buildSessionAudit(ctx, state, sessionRef) {
3984
3985
  const history = loadWebSessionHistory(state.webHistoryDir, sessionRef.containerName);
3985
- const agentSession = getWebAgentSession(history, sessionRef.agentId)
3986
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { includeArchived: true })
3986
3987
  || createEmptyWebAgentSession(sessionRef.agentId);
3987
3988
  const events = loadWebSessionControlEvents(state.webHistoryDir, sessionRef, agentSession.events);
3988
3989
  const applied = history.applied && typeof history.applied === 'object' && !Array.isArray(history.applied)
@@ -4517,7 +4518,7 @@ async function handleWebApi(req, res, pathname, ctx, state) {
4517
4518
  const sessions = Array.from(names)
4518
4519
  .flatMap(name => {
4519
4520
  const history = loadWebSessionHistory(state.webHistoryDir, name);
4520
- return listWebAgentSessions(history, { includeSyntheticDefault: true })
4521
+ return listWebAgentSessions(history, { includeSyntheticDefault: true, includeArchived: true })
4521
4522
  .map(agentSession => buildSessionSummary(ctx, state, containerMap, {
4522
4523
  containerName: name,
4523
4524
  agentId: agentSession.agentId
@@ -4667,7 +4668,7 @@ async function handleWebApi(req, res, pathname, ctx, state) {
4667
4668
  return;
4668
4669
  }
4669
4670
  const history = loadWebSessionHistory(state.webHistoryDir, sessionRef.containerName);
4670
- const agentSession = getWebAgentSession(history, sessionRef.agentId)
4671
+ const agentSession = getWebAgentSession(history, sessionRef.agentId, { includeArchived: true })
4671
4672
  || createEmptyWebAgentSession(sessionRef.agentId);
4672
4673
  sendJson(res, 200, {
4673
4674
  name: buildWebSessionKey(sessionRef.containerName, sessionRef.agentId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "7.0.4",
3
+ "version": "7.0.5",
4
4
  "imageVersion": "1.9.1-common",
5
5
  "playwrightCliVersion": "0.1.18",
6
6
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",