@xcanwin/manyoyo 5.11.16 → 6.0.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.
Files changed (2) hide show
  1. package/lib/web/server.js +31 -9
  2. package/package.json +1 -1
package/lib/web/server.js CHANGED
@@ -34,8 +34,8 @@ const WEB_TERMINAL_MIN_ROWS = 12;
34
34
  const WEB_AGENT_CONTEXT_MAX_MESSAGES = 24;
35
35
  const WEB_AGENT_CONTEXT_MAX_CHARS = 6000;
36
36
  const WEB_AGENT_CONTEXT_PER_MESSAGE_MAX_CHARS = 600;
37
- // Claude 与 Codex 都按 Web Agent 保存的引擎会话 ID 原生续接,避免历史文本被截断。
38
- const NATIVE_SESSION_RESUME_PROGRAMS = new Set(['claude', 'codex']);
37
+ // 支持按 Web Agent 保存的引擎会话 ID 原生续接,避免历史文本被截断。
38
+ const NATIVE_SESSION_RESUME_PROGRAMS = new Set(['claude', 'codex', 'opencode']);
39
39
  const WEB_FILE_PREVIEW_MAX_BYTES = 512 * 1024;
40
40
  const WEB_FILE_EDIT_MAX_BYTES = 2 * 1024 * 1024;
41
41
  const WEB_AUTH_COOKIE_NAME = 'manyoyo_web_auth';
@@ -763,14 +763,22 @@ function buildGeminiAgentExecCommand(template, prompt) {
763
763
  : renderAgentPromptCommand(geminiTemplate, prompt);
764
764
  }
765
765
 
766
- function buildOpenCodeAgentExecCommand(template, prompt) {
766
+ function buildOpenCodeAgentExecCommand(template, prompt, options = {}) {
767
767
  const templateText = normalizeAgentPromptCommandTemplate(template, 'agentPromptCommand');
768
+ const sessionId = options && typeof options.sessionId === 'string' ? options.sessionId.trim() : '';
769
+ const flagSpecs = [
770
+ { flag: '--format json', pattern: /(?:^|\s)--format(?:\s|$)/ }
771
+ ];
772
+ if (sessionId) {
773
+ flagSpecs.push({
774
+ flag: `--session ${quoteBashSingleValue(sessionId)}`,
775
+ pattern: /(?:^|\s)(?:--session|-s)(?:\s|$)/
776
+ });
777
+ }
768
778
  const opencodeTemplate = prependAgentFlags(
769
779
  templateText,
770
- /^(((?:(?:[A-Za-z_][A-Za-z0-9_]*=)(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s]+)\s+)*)opencode\s+run\b)(.*)$/,
771
- [
772
- { flag: '--format json', pattern: /(?:^|\s)--format(?:\s|$)/ }
773
- ]
780
+ /^(((?:(?:[A-Za-z_][A-Za-z0-9_]*=)(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|[^\s]+)\s+)*)opencode\b.*?\s+run\b)(.*)$/,
781
+ flagSpecs
774
782
  );
775
783
  return opencodeTemplate === templateText
776
784
  ? renderAgentPromptCommand(templateText, prompt)
@@ -786,7 +794,7 @@ function buildWebAgentExecCommand(template, prompt, agentProgram, options = {})
786
794
  case 'codex':
787
795
  return buildCodexAgentExecCommand(template, prompt, options);
788
796
  case 'opencode':
789
- return buildOpenCodeAgentExecCommand(template, prompt);
797
+ return buildOpenCodeAgentExecCommand(template, prompt, options);
790
798
  default:
791
799
  break;
792
800
  }
@@ -890,7 +898,7 @@ function extractOpenCodeAgentMessage(text) {
890
898
  if (role && role !== 'assistant') {
891
899
  continue;
892
900
  }
893
- const content = collectStructuredText(message.content || payload.content || payload.text || payload);
901
+ const content = collectStructuredText(message.content || payload.content || payload.text || payload.part || payload);
894
902
  if (!content) {
895
903
  continue;
896
904
  }
@@ -941,6 +949,17 @@ function extractClaudeSessionId(text) {
941
949
  return '';
942
950
  }
943
951
 
952
+ function extractOpenCodeSessionId(text) {
953
+ for (const rawLine of String(text || '').split('\n')) {
954
+ const payload = parseJsonObjectLine(rawLine);
955
+ const sessionId = payload && pickFirstString(payload.sessionID, payload.session_id);
956
+ if (sessionId) {
957
+ return sessionId;
958
+ }
959
+ }
960
+ return '';
961
+ }
962
+
944
963
  function extractEngineSessionId(agentProgram, text) {
945
964
  if (agentProgram === 'codex') {
946
965
  return extractCodexThreadId(text);
@@ -948,6 +967,9 @@ function extractEngineSessionId(agentProgram, text) {
948
967
  if (agentProgram === 'claude') {
949
968
  return extractClaudeSessionId(text);
950
969
  }
970
+ if (agentProgram === 'opencode') {
971
+ return extractOpenCodeSessionId(text);
972
+ }
951
973
  return '';
952
974
  }
953
975
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "5.11.16",
3
+ "version": "6.0.1",
4
4
  "imageVersion": "1.9.1-common",
5
5
  "playwrightCliVersion": "0.1.14",
6
6
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",