shennian 0.5.13 → 0.5.15

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 (45) hide show
  1. package/dist/publish-build-manifest.json +121 -51
  2. package/dist/src/agents/acp/adapter.js +2 -2
  3. package/dist/src/agents/acp/discovery.js +1 -1
  4. package/dist/src/agents/adapter.js +2 -1
  5. package/dist/src/agents/claude-permission-bridge.js +3 -0
  6. package/dist/src/agents/claude-permission-protocol.js +1 -0
  7. package/dist/src/agents/claude-permission-relay-server.js +3 -0
  8. package/dist/src/agents/claude.js +7 -7
  9. package/dist/src/agents/codex-managed-room-tools.js +1 -1
  10. package/dist/src/agents/codex-runtime.js +7 -7
  11. package/dist/src/agents/codex.js +3 -3
  12. package/dist/src/agents/project-client.js +1 -0
  13. package/dist/src/agents/public-delivery-client.js +1 -1
  14. package/dist/src/agents/workbuddy.js +3 -2
  15. package/dist/src/commands/daemon.js +9 -9
  16. package/dist/src/commands/pair-browser.js +1 -1
  17. package/dist/src/commands/pair.js +11 -11
  18. package/dist/src/commands/project.js +4 -0
  19. package/dist/src/commands/setup.js +4 -0
  20. package/dist/src/commands/steward.js +3 -0
  21. package/dist/src/daemon-ipc/agent-readiness.js +1 -1
  22. package/dist/src/daemon-ipc/control.js +1 -1
  23. package/dist/src/index.js +3 -3
  24. package/dist/src/session/conversation-export.js +1 -0
  25. package/dist/src/session/handlers/chat-adapter-config.js +1 -1
  26. package/dist/src/session/handlers/chat-events.js +2 -2
  27. package/dist/src/session/handlers/chat-session-lifecycle.js +1 -1
  28. package/dist/src/session/handlers/chat.js +1 -1
  29. package/dist/src/session/handlers/steward.js +1 -0
  30. package/dist/src/session/manager.js +1 -1
  31. package/dist/src/session/queue.js +1 -1
  32. package/dist/src/session/store.js +2 -2
  33. package/dist/src/skill/hosts.js +1 -0
  34. package/dist/src/skill/updater.js +1 -1
  35. package/dist/src/steward/session.js +2 -0
  36. package/dist/src/steward/templates.js +66 -0
  37. package/dist/src/steward/workspace.js +1 -0
  38. package/dist/src/upgrade/engine.js +2 -2
  39. package/dist/src/upgrade/npm-command.js +1 -0
  40. package/dist/src/upgrade/updater-launcher.js +3 -3
  41. package/node_modules/@shennian/wire/dist/message-payload.js +5 -5
  42. package/node_modules/@shennian/wire/dist/session.js +1 -1
  43. package/node_modules/ws/lib/websocket.js +17 -3
  44. package/node_modules/ws/package.json +1 -1
  45. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- const E=/^\s*::git-[a-z-]+\{[^\n]*\}\s*$/gm,g=/^\s*\{\s*"v"\s*:\s*1\s*,\s*"type"\s*:\s*"(tool|tool_use|tool_result)"/,R=/^\s*<environment_context>\s*[^]*?<\/environment_context>\s*$/i,x=/<(cwd|shell|current_date|timezone)>[^<]*<\/\1>/gi,h=/^\s*<recommended_plugins>[^]*?<\/recommended_plugins>\s*/i,T=/^\s*<turn_aborted>[^]*?<\/turn_aborted>\s*$/i,P=/^\s*<codex_internal_context\b[^>]*>[^]*?<\/codex_internal_context>\s*$/i,b=/^\s*# AGENTS\.md instructions for [^\n]+\n+\s*<INSTRUCTIONS>\s*[^]*?<\/INSTRUCTIONS>\s*(?:<environment_context>[^]*?<\/environment_context>)?\s*$/i,N=/^\s*\{\s*"v"\s*:\s*1\s*,\s*"type"\s*:\s*"approval_pending"/,A=/(?:<\/?(?:environment_context|instructions|system|developer|codex_internal_context|recommended_plugins)\b|#\s*AGENTS\.md instructions\b)/i,I=/\bdata:[a-z0-9.+-]+\/[a-z0-9.+-]+;base64,[a-z0-9+/=\s]+/i,S=/(?:^|\s)(?=[A-Za-z0-9+/]{80,}={0,2}(?=\s|$))(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*[0-9])[A-Za-z0-9+/]{80,}={0,2}(?=\s|$)/,v=new Set(["tool","tool_use","tool_result","thinking","system","developer","context","environment_context","channel_delivery_status"]);function C(e){return e.replace(/[[\]\\]/g,"\\$&")}function O(e){const t=C(e.name);return e.kind==="image"?`![${t}](<${e.path}>)`:`[${t}](<${e.path}>)`}function D(e,t){if(!t?.length)return e;const n=new Set(t.map(O));return e.split(`
1
+ const g=/^\s*::git-[a-z-]+\{[^\n]*\}\s*$/gm,E=/^\s*\{\s*"v"\s*:\s*1\s*,\s*"type"\s*:\s*"(tool|tool_use|tool_result)"/,x=/^\s*<environment_context>\s*[^]*?<\/environment_context>\s*$/i,b=/<(cwd|shell|current_date|timezone)>[^<]*<\/\1>/gi,R=/^\s*<recommended_plugins>[^]*?<\/recommended_plugins>\s*/i,P=/^\s*<turn_aborted>[^]*?<\/turn_aborted>\s*$/i,h=/^\s*<codex_internal_context\b[^>]*>[^]*?<\/codex_internal_context>\s*$/i,S=/^\s*# AGENTS\.md instructions for [^\n]+\n+\s*<INSTRUCTIONS>\s*[^]*?<\/INSTRUCTIONS>\s*(?:<environment_context>[^]*?<\/environment_context>)?\s*$/i,T=/^\s*\{\s*"v"\s*:\s*1\s*,\s*"type"\s*:\s*"approval_pending"/,v=/(?:<\/?(?:environment_context|instructions|system|developer|codex_internal_context|recommended_plugins)\b|#\s*AGENTS\.md instructions\b)/i,N=/\bdata:[a-z0-9.+-]+\/[a-z0-9.+-]+;base64,[a-z0-9+/=\s]+/i,A=/(?:^|\s)(?=[A-Za-z0-9+/]{80,}={0,2}(?=\s|$))(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*[0-9])[A-Za-z0-9+/]{80,}={0,2}(?=\s|$)/,I=new Set(["tool","tool_use","tool_result","thinking","system","developer","context","environment_context","channel_delivery_status"]);function C(e){return e.replace(/[[\]\\]/g,"\\$&")}function O(e){const t=C(e.name);return e.kind==="image"?`![${t}](<${e.path}>)`:`[${t}](<${e.path}>)`}function w(e,t){if(!t?.length)return e;const n=new Set(t.map(O));return e.split(`
2
2
  `).filter(s=>!n.has(s.trim())).join(`
3
3
  `).replace(/\n{3,}/g,`
4
4
 
5
- `).trim()}function u(e){if(!e||e[0]!=="{")return null;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return t}catch{}return null}function z(e){if(typeof e!="object"||e===null)return null;const t=e,n=typeof t.path=="string"?t.path:"",r=typeof t.name=="string"?t.name:"",s=typeof t.mimeType=="string"?t.mimeType:"",l=t.kind==="image"||t.kind==="file"||t.kind==="folder"?t.kind:null;if(!n||!r||!s||!l)return null;const f=typeof t.previewData=="string"&&t.previewData.trim()?t.previewData.trim():void 0,p=typeof t.byteSize=="number"&&Number.isSafeInteger(t.byteSize)&&t.byteSize>=0?t.byteSize:void 0,d=typeof t.sha256=="string"&&/^[a-f0-9]{64}$/i.test(t.sha256)?t.sha256.toLowerCase():void 0;return{path:n,name:r,mimeType:s,kind:l,...p!==void 0?{byteSize:p}:{},...d?{sha256:d}:{},...f?{previewData:f}:{}}}function o(e){const t=u(e);if(!t||t.v!==1)return null;if(t.type==="user"&&typeof t.content=="string"){const n=Array.isArray(t.attachments)?t.attachments.map(z).filter(r=>r!=null):void 0;return{v:1,type:"user",content:t.content,...n?.length?{attachments:n}:{}}}return t}function w(e){const t=o(e);return t?.type==="user"?t:null}function L(e,t){return t?.length?JSON.stringify({v:1,type:"user",content:e,attachments:t}):e}function $(e){if(g.test(e))return!0;const t=o(e);return!t||typeof t!="object"?!1:t.type==="tool"||t.type==="tool_use"||t.type==="tool_result"}function V(e){return N.test(e)?!0:o(e)?.type==="approval_pending"}function M(e){return U(e)?.agentVisible===!1}function U(e){const t=o(e);if(!t||t.type!=="channel_delivery_status")return null;const n=t;if(n.v!==1||n.channel!=="wechat"||n.agentVisible!==!1)return null;const r=typeof n.status=="string"&&n.status.trim()?n.status.trim():"";if(!r)return null;const s=typeof n.content=="string"&&n.content.trim()?n.content:r==="manual_review"?"\u53D1\u9001\u72B6\u6001\u4E0D\u786E\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u5FAE\u4FE1":"\u672A\u80FD\u81EA\u52A8\u53D1\u9001\u5230\u5FAE\u4FE1";return{v:1,type:"channel_delivery_status",channel:"wechat",status:r,agentVisible:!1,content:s,replyId:i(n.replyId),idempotencyKey:i(n.idempotencyKey),bindingId:i(n.bindingId),reasonCode:i(n.reasonCode),copyText:i(n.copyText),copyableContentRef:i(n.copyableContentRef),errorSummary:i(n.errorSummary)}}function j(e){return JSON.stringify({v:1,type:"approval_pending",title:e?.title?.trim()||"\u9700\u8981\u7528\u6237\u786E\u8BA4",content:e?.content?.trim()||"Codex \u6B63\u5728\u7B49\u5F85\u7528\u6237\u786E\u8BA4\u540E\u7EE7\u7EED\u3002",source:e?.source?.trim()||"codex",actionHint:e?.permission?e?.actionHint?.trim():e?.actionHint?.trim()||"\u5F53\u524D\u795E\u5FF5\u6682\u4E0D\u652F\u6301\u8FDC\u7A0B\u786E\u8BA4\uFF0C\u8BF7\u56DE\u5230\u8FD0\u884C Codex \u7684\u7535\u8111/\u7EC8\u7AEF\u5B8C\u6210\u786E\u8BA4\u3002",...e?.permission?{permission:e.permission}:{}})}function _(e){if(!R.test(e))return!1;const t=new Set;for(const n of e.matchAll(x))n[1]&&t.add(n[1].toLowerCase());return t.has("current_date")&&t.has("timezone")&&e.includes("<workspace_roots>")?!0:t.has("cwd")&&t.has("shell")&&t.has("current_date")&&t.has("timezone")}function X(e){return T.test(e)}function m(e){return b.test(e)}function k(e){const t=e.match(h);if(t){const n=e.slice(t[0].length).trim();return!n||_(n)||m(n)}return _(e)||X(e)||P.test(e)||m(e)}function c(e){if(!e)return"";const t=e.replace(/\r\n/g,`
6
- `);if(!/(^|\n)\s*::git-[a-z-]+\{[^\n]*\}\s*(?=\n|$)/.test(t))return t;const r=t.replace(E,"");return r.trim()?r.replace(/[ \t]+\n/g,`
7
- `).replace(/\n+$/g,""):""}function y(e){if(!e)return"";const t=w(e);if(t)return D(t.content,t.attachments);const n=o(e);if(n){if(typeof n.content=="string")return c(n.content);if("text"in n&&typeof n.text=="string")return c(n.text)}try{const r=JSON.parse(e);if(typeof r=="string")return r;if(typeof r=="object"&&r!==null){const s=r;if(typeof s.content=="string")return c(s.content);if(typeof s.text=="string")return c(s.text)}}catch{}return c(e)}function a(e,t=160){if(typeof e!="string"||!Number.isSafeInteger(t)||t<1)return null;const n=e.replace(/\r\n/g,`
8
- `).trim();if(!n||A.test(n)||I.test(n)||S.test(n)||u(n))return null;const r=n.replace(/\s+/g," ");return r.length>t?`${r.slice(0,t)}\u2026`:r}function G(e,t=160){if(!e||$(e)||k(e))return null;if(V(e))return a("\u9700\u8981\u7528\u6237\u786E\u8BA4",t);const n=o(e);if(n){const r=typeof n.type=="string"?n.type.toLowerCase():"";return!r||v.has(r)?null:a(y(e),t)}return u(e)?null:a(y(e),t)}function i(e){return typeof e=="string"&&e.trim()?e:void 0}export{j as buildApprovalPendingPayload,L as buildUserMessagePayload,y as extractPayloadText,M as isAgentHiddenPayload,V as isApprovalPendingPayload,m as isCodexProjectInstructionsPayload,X as isCodexTurnAbortedPayload,k as isSystemControlPayload,_ as isSystemEnvironmentContextPayload,$ as isToolPayload,U as parseChannelDeliveryStatusPayload,o as parseStructuredMessagePayload,w as parseUserMessagePayload,a as sanitizeSessionPreview,G as sessionPreviewFromPayload,c as stripGitDirectiveArtifacts};
5
+ `).trim()}function u(e){if(!e||e[0]!=="{")return null;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null)return t}catch{}return null}function D(e){if(typeof e!="object"||e===null)return null;const t=e,n=typeof t.path=="string"?t.path:"",r=typeof t.name=="string"?t.name:"",s=typeof t.mimeType=="string"?t.mimeType:"",l=t.kind==="image"||t.kind==="file"||t.kind==="folder"?t.kind:null;if(!n||!r||!s||!l)return null;const f=typeof t.previewData=="string"&&t.previewData.trim()?t.previewData.trim():void 0,p=typeof t.byteSize=="number"&&Number.isSafeInteger(t.byteSize)&&t.byteSize>=0?t.byteSize:void 0,d=typeof t.sha256=="string"&&/^[a-f0-9]{64}$/i.test(t.sha256)?t.sha256.toLowerCase():void 0;return{path:n,name:r,mimeType:s,kind:l,...p!==void 0?{byteSize:p}:{},...d?{sha256:d}:{},...f?{previewData:f}:{}}}function o(e){const t=u(e);if(!t||t.v!==1)return null;if(t.type==="user"&&typeof t.content=="string"){const n=Array.isArray(t.attachments)?t.attachments.map(D).filter(r=>r!=null):void 0;return{v:1,type:"user",content:t.content,...n?.length?{attachments:n}:{}}}return t}function z(e){const t=o(e);return t?.type==="user"?t:null}function M(e,t){return t?.length?JSON.stringify({v:1,type:"user",content:e,attachments:t}):e}function $(e){if(E.test(e))return!0;const t=o(e);return!t||typeof t!="object"?!1:t.type==="tool"||t.type==="tool_use"||t.type==="tool_result"}function k(e){return T.test(e)?!0:o(e)?.type==="approval_pending"}function j(e,t="say"){return JSON.stringify({v:1,type:"steward_say",content:e,source:t})}function G(e){const t=o(e);if(!t||t.type!=="steward_say")return null;const n=t;return typeof n.content!="string"||!n.content.trim()?null:{v:1,type:"steward_say",content:n.content,source:n.source==="fallback"?"fallback":"say"}}function J(e){return V(e)?.agentVisible===!1}function V(e){const t=o(e);if(!t||t.type!=="channel_delivery_status")return null;const n=t;if(n.v!==1||n.channel!=="wechat"||n.agentVisible!==!1)return null;const r=typeof n.status=="string"&&n.status.trim()?n.status.trim():"";if(!r)return null;const s=typeof n.content=="string"&&n.content.trim()?n.content:r==="manual_review"?"\u53D1\u9001\u72B6\u6001\u4E0D\u786E\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u5FAE\u4FE1":"\u672A\u80FD\u81EA\u52A8\u53D1\u9001\u5230\u5FAE\u4FE1";return{v:1,type:"channel_delivery_status",channel:"wechat",status:r,agentVisible:!1,content:s,replyId:i(n.replyId),idempotencyKey:i(n.idempotencyKey),bindingId:i(n.bindingId),reasonCode:i(n.reasonCode),copyText:i(n.copyText),copyableContentRef:i(n.copyableContentRef),errorSummary:i(n.errorSummary)}}function U(e){const t=e?.trim();return`${!t||t==="codex"?"Codex":t==="workbuddy"?"WorkBuddy":t} \u6B63\u5728\u7B49\u5F85\u7528\u6237\u786E\u8BA4\u540E\u7EE7\u7EED\u3002`}function Z(e){return JSON.stringify({v:1,type:"approval_pending",title:e?.title?.trim()||"\u9700\u8981\u7528\u6237\u786E\u8BA4",content:e?.content?.trim()||U(e?.source),source:e?.source?.trim()||"codex",actionHint:e?.permission?e?.actionHint?.trim():e?.actionHint?.trim()||"\u5F53\u524D\u795E\u5FF5\u6682\u4E0D\u652F\u6301\u8FDC\u7A0B\u786E\u8BA4\uFF0C\u8BF7\u56DE\u5230\u8FD0\u884C Codex \u7684\u7535\u8111/\u7EC8\u7AEF\u5B8C\u6210\u786E\u8BA4\u3002",...e?.permission?{permission:e.permission}:{}})}function y(e){if(!x.test(e))return!1;const t=new Set;for(const n of e.matchAll(b))n[1]&&t.add(n[1].toLowerCase());return t.has("current_date")&&t.has("timezone")&&e.includes("<workspace_roots>")?!0:t.has("cwd")&&t.has("shell")&&t.has("current_date")&&t.has("timezone")}function X(e){return P.test(e)}function _(e){return S.test(e)}function L(e){const t=e.match(R);if(t){const n=e.slice(t[0].length).trim();return!n||y(n)||_(n)}return y(e)||X(e)||h.test(e)||_(e)}function c(e){if(!e)return"";const t=e.replace(/\r\n/g,`
6
+ `);if(!/(^|\n)\s*::git-[a-z-]+\{[^\n]*\}\s*(?=\n|$)/.test(t))return t;const r=t.replace(g,"");return r.trim()?r.replace(/[ \t]+\n/g,`
7
+ `).replace(/\n+$/g,""):""}function m(e){if(!e)return"";const t=z(e);if(t)return w(t.content,t.attachments);const n=o(e);if(n){if(typeof n.content=="string")return c(n.content);if("text"in n&&typeof n.text=="string")return c(n.text)}try{const r=JSON.parse(e);if(typeof r=="string")return r;if(typeof r=="object"&&r!==null){const s=r;if(typeof s.content=="string")return c(s.content);if(typeof s.text=="string")return c(s.text)}}catch{}return c(e)}function a(e,t=160){if(typeof e!="string"||!Number.isSafeInteger(t)||t<1)return null;const n=e.replace(/\r\n/g,`
8
+ `).trim();if(!n||v.test(n)||N.test(n)||A.test(n)||u(n))return null;const r=n.replace(/\s+/g," ");return r.length>t?`${r.slice(0,t)}\u2026`:r}function B(e,t=160){if(!e||$(e)||L(e))return null;if(k(e))return a("\u9700\u8981\u7528\u6237\u786E\u8BA4",t);const n=o(e);if(n){const r=typeof n.type=="string"?n.type.toLowerCase():"";return!r||I.has(r)?null:a(m(e),t)}return u(e)?null:a(m(e),t)}function i(e){return typeof e=="string"&&e.trim()?e:void 0}export{Z as buildApprovalPendingPayload,j as buildStewardSayPayload,M as buildUserMessagePayload,m as extractPayloadText,J as isAgentHiddenPayload,k as isApprovalPendingPayload,_ as isCodexProjectInstructionsPayload,X as isCodexTurnAbortedPayload,L as isSystemControlPayload,y as isSystemEnvironmentContextPayload,$ as isToolPayload,V as parseChannelDeliveryStatusPayload,G as parseStewardSayPayload,o as parseStructuredMessagePayload,z as parseUserMessagePayload,a as sanitizeSessionPreview,B as sessionPreviewFromPayload,c as stripGitDirectiveArtifacts};
@@ -1 +1 @@
1
- const p="codex_desktop_send_unavailable",a=["gemini","openclaw"],i=["claude","codex","workbuddy","cursor","opencode","pi","pi-coding-agent"],s=new Set(i);function c(e){return typeof e.supportsAgent=="boolean"?e.supportsAgent:e.supportsManagedAgent===!0||e.supportsManagedNativeFull===!0}function A(e,n){return Array.isArray(e.supportedAgentExecutionModes)?e.supportedAgentExecutionModes.includes(n):n==="native-full"?e.supportsManagedNativeFull===!0:e.supportsManagedAgent===!0}function u(e){return s.has(e)}function r(e){return e.startsWith("custom:")||/^acp:[a-z0-9][a-z0-9._-]{0,63}$/.test(e)||u(e)}function l(e){const n=[],o=new Set;for(const t of e)!r(t)||o.has(t)||(o.add(t),n.push(t));return n}function d(e){if(!e?.length)return[];const n=[],o=new Set;for(const t of e)!r(t.type)||o.has(t.type)||(o.add(t.type),n.push(t));return n}function f(e){return e.nativeSessionVisibility==="internal"||e.id.startsWith("sess_worker_")||e.agentType==="manager"||e.sessionMode==="manager"||!!e.agentIdentityId}export{i as AVAILABLE_BUILTIN_AGENT_TYPES,p as CODEX_DESKTOP_SEND_UNAVAILABLE,a as DISABLED_BUILTIN_AGENT_TYPES,c as agentInfoSupportsAgent,A as agentInfoSupportsExecutionMode,d as filterAvailableAgentInfos,l as filterAvailableAgentTypes,r as isAvailableAgentType,u as isAvailableBuiltinAgentType,f as isInternalSession};
1
+ const a="codex_desktop_send_unavailable",c=["gemini","openclaw"],i=["claude","codex","workbuddy","cursor","opencode","pi","pi-coding-agent"],s=new Set(i);function d(e){return typeof e.supportsAgent=="boolean"?e.supportsAgent:e.supportsManagedAgent===!0||e.supportsManagedNativeFull===!0}function A(e,n){return Array.isArray(e.supportedAgentExecutionModes)?e.supportedAgentExecutionModes.includes(n):n==="native-full"?e.supportsManagedNativeFull===!0:e.supportsManagedAgent===!0}function u(e){return e.sessionScope==="steward"}function p(e){return s.has(e)}function r(e){return e.startsWith("custom:")||/^acp:[a-z0-9][a-z0-9._-]{0,63}$/.test(e)||p(e)}function l(e){const n=[],o=new Set;for(const t of e)!r(t)||o.has(t)||(o.add(t),n.push(t));return n}function f(e){if(!e?.length)return[];const n=[],o=new Set;for(const t of e)!r(t.type)||o.has(t.type)||(o.add(t.type),n.push(t));return n}function g(e){return e.nativeSessionVisibility==="internal"||u(e)||e.id.startsWith("sess_worker_")||e.agentType==="manager"||e.sessionMode==="manager"||!!e.agentIdentityId}export{i as AVAILABLE_BUILTIN_AGENT_TYPES,a as CODEX_DESKTOP_SEND_UNAVAILABLE,c as DISABLED_BUILTIN_AGENT_TYPES,d as agentInfoSupportsAgent,A as agentInfoSupportsExecutionMode,f as filterAvailableAgentInfos,l as filterAvailableAgentTypes,r as isAvailableAgentType,p as isAvailableBuiltinAgentType,g as isInternalSession,u as isStewardSession};
@@ -75,11 +75,24 @@ class WebSocket extends EventEmitter {
75
75
  this._redirects = 0;
76
76
 
77
77
  if (protocols === undefined) {
78
- protocols = [];
78
+ if (!options || options.protocols === undefined) {
79
+ protocols = [];
80
+ } else if (Array.isArray(options.protocols)) {
81
+ protocols = options.protocols;
82
+ } else {
83
+ protocols = [options.protocols];
84
+ }
79
85
  } else if (!Array.isArray(protocols)) {
80
86
  if (typeof protocols === 'object' && protocols !== null) {
81
87
  options = protocols;
82
- protocols = [];
88
+
89
+ if (options.protocols === undefined) {
90
+ protocols = [];
91
+ } else if (Array.isArray(options.protocols)) {
92
+ protocols = options.protocols;
93
+ } else {
94
+ protocols = [options.protocols];
95
+ }
83
96
  } else {
84
97
  protocols = [protocols];
85
98
  }
@@ -318,7 +331,6 @@ class WebSocket extends EventEmitter {
318
331
  return;
319
332
  }
320
333
 
321
- this._readyState = WebSocket.CLOSING;
322
334
  this._sender.close(code, data, !this._isServer, (err) => {
323
335
  //
324
336
  // This error is handled by the `'error'` listener on the socket. We only
@@ -336,6 +348,7 @@ class WebSocket extends EventEmitter {
336
348
  }
337
349
  });
338
350
 
351
+ this._readyState = WebSocket.CLOSING;
339
352
  setCloseTimer(this);
340
353
  }
341
354
 
@@ -681,6 +694,7 @@ function initAsClient(websocket, address, protocols, options) {
681
694
  socketPath: undefined,
682
695
  hostname: undefined,
683
696
  protocol: undefined,
697
+ protocols: undefined,
684
698
  timeout: undefined,
685
699
  method: 'GET',
686
700
  host: undefined,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws",
3
- "version": "8.21.3",
3
+ "version": "8.22.0",
4
4
  "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
5
  "keywords": [
6
6
  "HyBi",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shennian",
3
- "version": "0.5.13",
3
+ "version": "0.5.15",
4
4
  "description": "Shennian \u2014 AI Agent Control Plane CLI",
5
5
  "type": "module",
6
6
  "bin": {