@xmanrui/dsh-im 3.0.1 → 3.0.2

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/client.js CHANGED
@@ -47,7 +47,7 @@ var React20 = __toESM(require("react"), 1);
47
47
  // package.json
48
48
  var package_default = {
49
49
  name: "@xmanrui/dsh-im",
50
- version: "3.0.1",
50
+ version: "3.0.2",
51
51
  description: "\u628A\u4E5D\u79CD IM \u673A\u5668\u4EBA\u548C\u516C\u7F51 AI Office \u63A5\u5165\u672C\u673A DeepSeek Harness\u3002 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",
52
52
  keywords: [
53
53
  "deepseek-harness",
@@ -10329,13 +10329,11 @@ var CSS11 = String.raw`
10329
10329
  }
10330
10330
  .dim-page *, .dim-page *::before, .dim-page *::after { box-sizing: border-box; }
10331
10331
  .dim-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
10332
- .dim-brand { position: relative; min-width: 0; width: max-content; max-width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin: -2px -6px; padding: 2px 6px; border-radius: 8px; cursor: help; }
10333
- .dim-brand:focus-visible { outline: 2px solid color-mix(in srgb, var(--dim-blue) 70%, white); outline-offset: 2px; }
10332
+ .dim-brand { min-width: 0; width: max-content; max-width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin: -2px -6px; padding: 2px 6px; border-radius: 8px; }
10333
+ .dim-brandHeading { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
10334
10334
  .dim-brandName { color: var(--dsw-alias-label-primary, #1f2329); font-size: 20px; line-height: 24px; font-weight: 800; letter-spacing: .04em; }
10335
+ .dim-brandVersion { color: var(--dsw-alias-label-tertiary, #8f959e); font: 500 10px/16px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; }
10335
10336
  .dim-title p { margin: 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap; }
10336
- .dim-versionTooltip { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: max-content; max-width: min(220px, 80vw); display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 7px; color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-bg-layer-3, #fff); box-shadow: 0 8px 24px rgb(31 35 41 / 14%); font-size: 11px; line-height: 16px; font-weight: 500; white-space: nowrap; opacity: 0; visibility: hidden; transform: translateY(-3px); pointer-events: none; transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
10337
- .dim-versionTooltip strong { color: var(--dsw-alias-label-primary, #1f2329); font: 600 11px/16px ui-monospace, SFMono-Regular, Menlo, monospace; }
10338
- .dim-brand:hover .dim-versionTooltip, .dim-brand:focus .dim-versionTooltip { opacity: 1; visibility: visible; transform: translateY(0); }
10339
10337
  .dim-githubAction { position: relative; display: inline-flex; flex: none; }
10340
10338
  .dim-githubLink { min-height: 30px; display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 0 10px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 8px; color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-bg-layer-1, #fff); font-size: 12px; line-height: normal; font-weight: 560; text-decoration: none; transition: border-color .15s ease, color .15s ease, background .15s ease; }
10341
10339
  .dim-githubLink:hover { border-color: #aeb3bb; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
@@ -10755,7 +10753,6 @@ function IMSettingsTab({
10755
10753
  }) {
10756
10754
  const [selected, setSelected] = React20.useState("weixin");
10757
10755
  const [loopbackRecovery, setLoopbackRecovery] = React20.useState(null);
10758
- const versionTooltipId = React20.useId();
10759
10756
  const githubTooltipId = React20.useId();
10760
10757
  const active = CHANNELS.find((channel4) => channel4.id === selected) ?? CHANNELS[0];
10761
10758
  const reportLoopbackRecovery = React20.useCallback((recovery) => {
@@ -10800,23 +10797,14 @@ function IMSettingsTab({
10800
10797
  { className: "dim-title" },
10801
10798
  h2(
10802
10799
  "div",
10803
- {
10804
- className: "dim-brand",
10805
- tabIndex: 0,
10806
- "aria-describedby": versionTooltipId
10807
- },
10808
- h2("strong", { className: "dim-brandName" }, "DSH-IM"),
10809
- h2("p", null, "\u8BA9 DeepSeek Harness \u89E6\u624B\u53EF\u53CA"),
10800
+ { className: "dim-brand" },
10810
10801
  h2(
10811
- "span",
10812
- {
10813
- id: versionTooltipId,
10814
- className: "dim-versionTooltip",
10815
- role: "tooltip"
10816
- },
10817
- h2("span", null, "\u5F53\u524D\u7248\u672C"),
10818
- h2("strong", null, `v${IM_PLUGIN_VERSION}`)
10819
- )
10802
+ "div",
10803
+ { className: "dim-brandHeading" },
10804
+ h2("strong", { className: "dim-brandName" }, "DSH-IM"),
10805
+ h2("span", { className: "dim-brandVersion" }, `v${IM_PLUGIN_VERSION}`)
10806
+ ),
10807
+ h2("p", null, "\u8BA9 DeepSeek Harness \u89E6\u624B\u53EF\u53CA")
10820
10808
  ),
10821
10809
  h2(
10822
10810
  "span",
package/lib/index.js CHANGED
@@ -143,7 +143,7 @@ ${D("\u9519\u8BEF\u7801\uFF1A{code}\uFF1B\u53C2\u8003\u53F7\uFF1A{referenceId}",
143
143
  `:/^\s{0,3}(?:[-*+] |\d+[.)] |#{1,6} |\||> )/.test(o[a+1])?`${e}
144
144
  `:`${e}<br>`}).join("")}function _b(n,t){if(!n||typeof n!="object"||n.errcode!==0)throw new gt("registration-rejected",`\u9489\u9489\u626B\u7801${t}\u5931\u8D25\u3002`);return n}function Tb(n,t){let o=Number(n);return Number.isFinite(o)&&o>0?o:t}function kH({fetchImpl:n=fetch,registrationBaseUrl:t=process.env.DINGTALK_REGISTRATION_BASE_URL||bH,registrationSource:o=process.env.DINGTALK_REGISTRATION_SOURCE||Jge,now:i=()=>Date.now(),cardMinIntervalMs:e=50,cardBackoffMs:a=1e3,delay:A=tce}={}){if(typeof n!="function")throw new TypeError("fetchImpl must be a function");if(typeof i!="function")throw new TypeError("now must be a function");if(!Number.isFinite(e)||e<0)throw new TypeError("cardMinIntervalMs must be a non-negative number");if(!Number.isFinite(a)||a<0)throw new TypeError("cardBackoffMs must be a non-negative number");if(typeof A!="function")throw new TypeError("delay must be a function");let r=Nb(t,{label:"\u9489\u9489\u6CE8\u518C\u670D\u52A1",requireSubdomain:!1}),s=new URL(jge),g=WA(o);if(!g)throw new TypeError("registrationSource is required");let c=new Map,I=new Map,d=new Map,B=Promise.resolve(),f=0,Q=(H,J)=>new URL(J.replace(/^\//,""),H);async function y({clientId:H,clientSecret:J,signal:q,requestKind:U="normal"}){let R=WA(H),V=WA(J);if(!R||!V)throw new TypeError("clientId and clientSecret are required");let L=c.get(R);if(L&&L.expiresAt>i())return L.token;let T=U==="reaction"?d:I;if(T.has(R))return T.get(R);let W=(async()=>{let ie=await bn(n,Q(s,"v1.0/oauth2/accessToken"),{body:{appKey:R,appSecret:V},signal:q,action:"\u9274\u6743"}),ge=WA(ie?.accessToken);if(!ge)throw new gt("invalid-access-token","\u9489\u9489\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE\u8BBF\u95EE\u4EE4\u724C\u3002");let Se=Tb(ie?.expireIn??ie?.expiresIn,7200),de=Math.max(1e3,(Se-60)*1e3);return c.set(R,{token:ge,expiresAt:i()+de}),ge})().finally(()=>T.delete(R));return T.set(R,W),W}async function m({clientId:H,clientSecret:J,robotCode:q,messageId:U,conversationId:R,reactionName:V=zc,signal:L},T){let k=WA(H),W=WA(J),ie=WA(q)??k,ge=WA(U),Se=WA(R),de=WA(V);if(!k||!W)throw new TypeError("clientId and clientSecret are required");if(!ie)throw new TypeError("robotCode is required");if(!ge||!Se)throw new TypeError("messageId and conversationId are required");if(!de)throw new TypeError("reactionName is required");let De=await y({clientId:k,clientSecret:W,signal:L,requestKind:"reaction"}),fe=await bn(n,Q(s,`v1.0/robot/emotion/${T}`),{body:{robotCode:ie,openMsgId:ge,openConversationId:Se,emotionType:2,emotionName:de,textEmotion:{emotionId:Wge,emotionName:de,text:de,backgroundId:Zge}},headers:{"x-acs-dingtalk-access-token":De},signal:L,timeoutMs:Vge,action:T==="reply"?"\u6D88\u606F\u72B6\u6001\u6DFB\u52A0":"\u6D88\u606F\u72B6\u6001\u64A4\u56DE"}),ve=fe?.success===!1?qh(fe?.code??fe?.errcode)??"rejected":bb(fe);if(ve)throw new gt("reaction-rejected","\u9489\u9489\u670D\u52A1\u62D2\u7EDD\u4E86\u6D88\u606F\u72B6\u6001\u8BF7\u6C42\u3002",{providerCode:ve});return!0}async function _({clientId:H,clientSecret:J,robotCode:q,downloadCode:U,signal:R,kind:V}){let L=WA(q),T=WA(U);if(!L||!T)throw new TypeError("robotCode and downloadCode are required");let k=await y({clientId:H,clientSecret:J,signal:R}),W;try{W=await bn(n,Q(s,"v1.0/robot/messageFiles/download"),{body:{downloadCode:T,robotCode:L},headers:{"x-acs-dingtalk-access-token":k},signal:R,action:`${V==="image"?"\u56FE\u7247":"\u6587\u4EF6"}\u4E0B\u8F7D\u5730\u5740`})}catch(ge){throw R?.aborted?ge:new gt(`${V}-download-address-failed`,`\u9489\u9489${V==="image"?"\u56FE\u7247":"\u6587\u4EF6"}\u4E0B\u8F7D\u5730\u5740\u83B7\u53D6\u5931\u8D25\u3002`,{cause:ge,status:ge?.status,providerCode:ge?.providerCode})}let ie=WA(W?.downloadUrl??W?.download_url);if(!ie)throw new gt(`invalid-${V}-download`,`\u9489\u9489\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE${V==="image"?"\u56FE\u7247":"\u6587\u4EF6"}\u4E0B\u8F7D\u5730\u5740\u3002`);return Ace(ie)}function N(H){let J=async()=>{let U=Math.max(0,f-i());U>0&&await A(U,H),f=Math.max(f,i())+e},q=B.then(J,J);return B=q.catch(()=>{}),q}async function G(H,J){await N(J.signal);try{return await bn(n,Q(s,H),J)}catch(q){if(!(q instanceof gt)||q.status!==403)throw q;return await A(a,J.signal),await N(J.signal),bn(n,Q(s,H),J)}}async function Y({clientId:H,clientSecret:J,cardInstanceId:q,text:U,signal:R}){let V=WA(q),L=WA(U);if(!V)throw new TypeError("cardInstanceId is required");if(!L)throw new TypeError("text is required");let k={"x-acs-dingtalk-access-token":await y({clientId:H,clientSecret:J,signal:R})},W=[G("v1.0/card/streaming",{method:"PUT",body:{outTrackId:V,guid:Yh(),key:"msgContent",content:Jh(L),isFull:!0,isFinalize:!1,isError:!0},headers:k,signal:R,action:"AI Card \u5931\u8D25\u6536\u53E3"}),G("v1.0/card/instances",{method:"PUT",body:{outTrackId:V,cardData:Mb(L,"5"),cardUpdateOptions:{updateCardDataByKey:!0}},headers:k,signal:R,action:"AI Card \u5931\u8D25\u72B6\u6001"})],ie=await Promise.allSettled(W);if(ie.every(({status:ge})=>ge==="rejected"))throw ie[0].reason;return!0}async function j({clientId:H,clientSecret:J,target:q,file:U,signal:R},{uploadType:V,messageKey:L,createMessageParams:T}){if(!U||typeof U!="object"||typeof U.fileName!="string"||!U.fileName||!Buffer.isBuffer(U.bytes))throw new TypeError("A DingTalk file is required");let k=ace(q),W;try{W=await y({clientId:H,clientSecret:J,signal:R})}catch(Re){if(R?.aborted)throw Mn(R);let AA=Number(Re?.status),ue=Re?.code==="http-error"&&AA>=400&&AA<500?"artifact-provider-rejected":"artifact-provider-failed";throw jh(Re,{fallback:ue})}let ie=new URL("media/upload",bH);ie.searchParams.set("access_token",W),ie.searchParams.set("type",V);let ge=new FormData;ge.append("media",new Blob([U.bytes],{type:U.mediaType??"application/octet-stream"}),U.fileName);let Se;try{Se=await rce(n,ie,{body:ge,signal:R})}catch(Re){if(R?.aborted)throw Mn(R);let AA=Number(Re?.status),ue=Re?.code==="http-error"&&AA>=400&&AA<500?"artifact-provider-rejected":"artifact-provider-failed";throw jh(Re,{fallback:ue})}let de=bb(Se),De=WA(Se?.media_id);if(de||!De)throw jh(new gt("upload-rejected","\u9489\u9489\u670D\u52A1\u62D2\u7EDD\u4E86\u6587\u4EF6\u4E0A\u4F20\u3002",{providerCode:de??"missing-media-id"}));R?.throwIfAborted();let fe={robotCode:k.robotCode,msgKey:L,msgParam:JSON.stringify(T(De,U)),...k.type==="group"?{openConversationId:k.openConversationId}:{userIds:[k.userId]}},ve=k.type==="group"?"v1.0/robot/groupMessages/send":"v1.0/robot/oToMessages/batchSend",eA;try{eA=await bn(n,Q(s,ve),{body:fe,headers:{"x-acs-dingtalk-access-token":W},signal:R,action:"\u6587\u4EF6\u6D88\u606F\u53D1\u9001"})}catch(Re){throw ece(Re,R)}let iA=bb(eA);if(iA)throw jh(new gt("send-rejected","\u9489\u9489\u670D\u52A1\u62D2\u7EDD\u4E86\u6587\u4EF6\u6D88\u606F\u3002",{providerCode:iA}));return eA}return Object.freeze({async beginRegistration({signal:H}={}){let J=_b(await bn(n,Q(r,"app/registration/init"),{body:{source:g},signal:H,action:"\u521D\u59CB\u5316"}),"\u521D\u59CB\u5316"),q=WA(J.nonce);if(!q)throw new gt("invalid-registration","\u9489\u9489\u626B\u7801\u521D\u59CB\u5316\u7F3A\u5C11 nonce\u3002");let U=_b(await bn(n,Q(r,"app/registration/begin"),{body:{nonce:q},signal:H,action:"\u521B\u5EFA"}),"\u521B\u5EFA"),R=WA(U.device_code),V=WA(U.verification_uri_complete);if(!R||!V)throw new gt("invalid-registration","\u9489\u9489\u626B\u7801\u670D\u52A1\u8FD4\u56DE\u7684\u4FE1\u606F\u4E0D\u5B8C\u6574\u3002");let L=Nb(V,{label:"\u9489\u9489\u626B\u7801",requireSubdomain:!1}).toString();return{deviceCode:R,userCode:WA(U.user_code)??void 0,verificationUri:WA(U.verification_uri)??void 0,verificationUriComplete:L,expiresInSeconds:Tb(U.expires_in,7200),intervalSeconds:Tb(U.interval,5)}},async pollRegistration({deviceCode:H,signal:J}={}){let q=WA(H);if(!q)throw new TypeError("deviceCode is required");let U=_b(await bn(n,Q(r,"app/registration/poll"),{body:{device_code:q},signal:J,action:"\u72B6\u6001\u67E5\u8BE2"}),"\u72B6\u6001\u67E5\u8BE2"),R=WA(U.status)?.toUpperCase();if(!R||!Xge.has(R))throw new gt("invalid-registration-status","\u9489\u9489\u626B\u7801\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u72B6\u6001\u3002");let V={status:R,failReason:WA(U.fail_reason)??void 0};if(R==="SUCCESS"&&(V.clientId=WA(U.client_id)??void 0,V.clientSecret=WA(U.client_secret)??void 0,!V.clientId||!V.clientSecret))throw new gt("missing-credentials","\u9489\u9489\u626B\u7801\u5DF2\u786E\u8BA4\uFF0C\u4F46\u6CA1\u6709\u8FD4\u56DE\u673A\u5668\u4EBA\u51ED\u636E\u3002");return V},accessToken:y,async addReaction(H){return m(H,"reply")},async recallReaction(H){return m(H,"recall")},async addThinkingReaction(H){return m({...H,reactionName:zc},"reply")},async recallThinkingReaction(H){return m({...H,reactionName:zc},"recall")},async downloadImage({clientId:H,clientSecret:J,robotCode:q,downloadCode:U,signal:R,maxBytes:V}){let L=await _({clientId:H,clientSecret:J,robotCode:q,downloadCode:U,signal:R,kind:"image"});try{return await no(L,{fetchImpl:n,signal:R,maxBytes:V})}catch(T){throw R?.aborted||T instanceof ut?T:new gt("image-content-download-failed","\u9489\u9489\u56FE\u7247\u5185\u5BB9\u4E0B\u8F7D\u5931\u8D25\u3002",{cause:T})}},async downloadFile({clientId:H,clientSecret:J,robotCode:q,downloadCode:U,signal:R}){let V=await _({clientId:H,clientSecret:J,robotCode:q,downloadCode:U,signal:R,kind:"file"});if(V.protocol!=="https:")throw new gt("invalid-file-download","\u9489\u9489\u670D\u52A1\u8FD4\u56DE\u4E86\u65E0\u6548\u7684\u6587\u4EF6\u4E0B\u8F7D\u5730\u5740\u3002");try{let L=await n(V,{method:"GET",redirect:"follow",signal:R});if(!L?.ok)throw await L?.body?.cancel?.().catch?.(()=>{}),new gt("file-content-download-failed",`\u9489\u9489\u6587\u4EF6\u5185\u5BB9\u4E0B\u8F7D\u5931\u8D25\uFF08HTTP ${L?.status??"unknown"}\uFF09\u3002`,{status:L?.status});return Buffer.from(await L.arrayBuffer())}catch(L){throw R?.aborted?Mn(R):L instanceof gt?L:new gt("file-content-download-failed","\u9489\u9489\u6587\u4EF6\u5185\u5BB9\u4E0B\u8F7D\u5931\u8D25\u3002",{cause:L})}},async createAiCard({clientId:H,clientSecret:J,target:q,initialText:U,signal:R}){let V=WA(H),L=WA(J),T=WA(U);if(!V||!L)throw new TypeError("clientId and clientSecret are required");if(!T)throw new TypeError("initialText is required");let k=oce(q),W=await y({clientId:V,clientSecret:L,signal:R}),ie=`dsh_${Yh()}`,ge={"x-acs-dingtalk-access-token":W},Se=!1;try{await G("v1.0/card/instances",{body:{cardTemplateId:qge,outTrackId:ie,cardData:{cardParamMap:{config:JSON.stringify({autoLayout:!0})}},callbackType:"STREAM",imGroupOpenSpaceModel:{supportForward:!0},imRobotOpenSpaceModel:{supportForward:!0}},headers:ge,signal:R,action:"AI Card \u521B\u5EFA"}),await G("v1.0/card/instances/deliver",{body:nce(ie,k,V),headers:ge,signal:R,action:"AI Card \u6295\u653E"}),Se=!0,await G("v1.0/card/instances",{method:"PUT",body:{outTrackId:ie,cardData:Mb(T,"2")},headers:ge,signal:R,action:"AI Card \u542F\u52A8"}),await G("v1.0/card/streaming",{method:"PUT",body:{outTrackId:ie,guid:Yh(),key:"msgContent",content:Jh(T).replace(/\n+$/,""),isFull:!0,isFinalize:!1,isError:!1},headers:ge,signal:R,action:"AI Card \u542F\u52A8"})}catch(de){if(Se){let De=AbortSignal.timeout(5e3);await Y({clientId:V,clientSecret:L,cardInstanceId:ie,text:D("\u5361\u7247\u5DF2\u7ED3\u675F\uFF0C\u8BF7\u67E5\u770B\u540E\u7EED\u6D88\u606F\u3002"),signal:De}).catch(()=>{})}throw de}return{cardInstanceId:ie}},async updateAiCard({clientId:H,clientSecret:J,cardInstanceId:q,text:U,signal:R}){let V=WA(q),L=WA(U);if(!V)throw new TypeError("cardInstanceId is required");if(!L)throw new TypeError("text is required");let T=await y({clientId:H,clientSecret:J,signal:R});return await G("v1.0/card/streaming",{method:"PUT",body:{outTrackId:V,guid:Yh(),key:"msgContent",content:Jh(L).replace(/\n+$/,""),isFull:!0,isFinalize:!1,isError:!1},headers:{"x-acs-dingtalk-access-token":T},signal:R,action:"AI Card \u66F4\u65B0"}),!0},async finishAiCard({clientId:H,clientSecret:J,cardInstanceId:q,text:U,signal:R}){let V=WA(q),L=WA(U);if(!V)throw new TypeError("cardInstanceId is required");if(!L)throw new TypeError("text is required");let k={"x-acs-dingtalk-access-token":await y({clientId:H,clientSecret:J,signal:R})},W=Jh(L);await G("v1.0/card/streaming",{method:"PUT",body:{outTrackId:V,guid:Yh(),key:"msgContent",content:W,isFull:!0,isFinalize:!0,isError:!1},headers:k,signal:R,action:"AI Card \u5B8C\u6210"});let ie=!0,ge={method:"PUT",body:{outTrackId:V,cardData:Mb(L,"3"),cardUpdateOptions:{updateCardDataByKey:!0}},headers:k,signal:R,action:"AI Card \u6536\u53E3"};try{await G("v1.0/card/instances",ge)}catch{try{await G("v1.0/card/instances",ge)}catch{ie=!1}}return{delivered:!0,completed:ie}},failAiCard:Y,async sendText({clientId:H,clientSecret:J,sessionWebhook:q,text:U,signal:R}){let V=WA(U);if(!V)throw new TypeError("text is required");let L=Rg(q),T=await y({clientId:H,clientSecret:J,signal:R}),k=await bn(n,L,{body:{msgtype:"text",text:{content:V}},headers:{"x-acs-dingtalk-access-token":T},signal:R,action:"\u6D88\u606F\u56DE\u590D"});if(k?.errcode!==void 0&&k.errcode!==0||k?.code!==void 0&&k.code!==0)throw new gt("send-rejected","\u9489\u9489\u670D\u52A1\u62D2\u7EDD\u4E86\u56DE\u590D\u6D88\u606F\u3002");return!0},async sendFile(H){return j(H,{uploadType:"file",messageKey:"sampleFile",createMessageParams:(J,q)=>({mediaId:J,fileName:q.fileName,fileType:ice(q.fileName)})})},async sendImage(H){return j(H,{uploadType:"image",messageKey:"sampleImageMsg",createMessageParams:J=>({photoURL:J})})},clearAccessToken(H){let J=WA(H);J&&c.delete(J)}})}var sce=500,gce="\u5361\u7247\u5DF2\u7ED3\u675F\uFF0C\u8BF7\u67E5\u770B\u540E\u7EED\u6D88\u606F\u3002";function Rb(n,t){if(typeof n!="string")throw new TypeError(`${t} must be a string`);return n}function vH(n,t){if(typeof n!="string"||!n.trim())throw new TypeError(`${t} is required`);return n.trim()}function PH({api:n,clientId:t,clientSecret:o,target:i,signal:e,logger:a=console,updateIntervalMs:A=sce,clock:r=()=>Date.now(),timer:s={setTimeout:(g,c)=>globalThis.setTimeout(g,c),clearTimeout:g=>globalThis.clearTimeout(g)}}={}){if(!n||typeof n.createAiCard!="function"||typeof n.updateAiCard!="function"||typeof n.finishAiCard!="function")throw new TypeError("DingTalk AI Card API is required");let g=vH(t,"clientId"),c=vH(o,"clientSecret");if(i==null)throw new TypeError("target is required");if(!Number.isFinite(A)||A<0)throw new TypeError("updateIntervalMs must be a non-negative number");if(typeof r!="function")throw new TypeError("clock must be a function");if(typeof s?.setTimeout!="function"||typeof s?.clearTimeout!="function")throw new TypeError("timer must provide setTimeout and clearTimeout");let I=()=>{let T=r();if(!Number.isFinite(T))throw new TypeError("clock must return a finite timestamp");return T};I();let d=e?.aborted?"aborted":"idle",B=null,f=null,Q=null,y=null,m=null,_=null,N=0,G=()=>{Q!==null&&(s.clearTimeout(Q),Q=null)},Y=()=>e?.removeEventListener("abort",q),j=T=>{d=T,f=null,G(),Y()},H=()=>!B||typeof n.failAiCard!="function"?Promise.resolve(!1):(_||(_=n.failAiCard({...B,text:D(gce),signal:AbortSignal.timeout(5e3)}).then(()=>!0,()=>!1)),_),J=T=>{d==="failed"||d==="finished"||d==="aborted"||(H(),j("failed"),a?.error?.(`[dsh-dingtalk] AI Card ${T} failed`))};function q(){d==="finished"||d==="failed"||d==="aborted"||(H(),j("aborted"))}d!=="aborted"&&e?.addEventListener("abort",q,{once:!0});let U=()=>{if(d!=="active"||y||f===null)return;let T=Math.max(0,N+A-I());if(T>0){Q=s.setTimeout(()=>{Q=null,U()},T);return}let k=f;f=null,y=(async()=>{try{await n.updateAiCard({...B,text:k,finished:!1}),N=I()}catch{if(e?.aborted||d==="aborted")return;J("update")}})().finally(()=>{y=null,d==="active"&&f!==null&&U()})};return Object.freeze({start:async T=>{if(Rb(T,"initialText"),d!=="idle")return!1;d="starting";try{let k=await n.createAiCard({clientId:g,clientSecret:c,target:i,initialText:T,signal:e}),W=typeof k?.cardInstanceId=="string"?k.cardInstanceId.trim():"";if(!W)throw new TypeError("DingTalk did not return a card instance id");return B=Object.freeze({clientId:g,clientSecret:c,target:i,cardInstanceId:W,signal:e}),d!=="starting"?(H(),!1):(N=I(),d="active",!0)}catch{return e?.aborted||d==="aborted"?(j("aborted"),!1):(J("creation"),!1)}},push:T=>{Rb(T,"progressText"),d==="active"&&(f=T,!Q&&!y&&U())},finish:T=>{if(Rb(T,"finalText"),d==="finished")return Promise.resolve(!0);if(d==="finishing")return m;if(d!=="active")return Promise.resolve(!1);d="finishing",f=null,G();let k=y;return m=(async()=>{if(k&&await k,d!=="finishing")return!1;try{return await n.finishAiCard({...B,text:T}),d!=="finishing"?!1:(j("finished"),!0)}catch{return e?.aborted||d==="aborted"?(j("aborted"),!1):(J("finish"),!1)}})(),m}})}function lf(n){return typeof n=="string"&&n.trim()?n.trim():null}function ti(n){return n&&typeof n.id=="string"&&typeof n.question=="string"&&(n.header===void 0||typeof n.header=="string")&&(n.detail===void 0||typeof n.detail=="string")&&(n.multiSelect===void 0||typeof n.multiSelect=="boolean")&&(n.options===void 0||Array.isArray(n.options)&&n.options.every(t=>t&&typeof t.label=="string"&&(t.description===void 0||typeof t.description=="string")))}function ri(n,t,o,{requiresMention:i=!1}={}){let e=[],a=o>1?`\uFF08${t+1}/${o}\uFF09`:"";e.push(D("DeepSeek Harness \u9700\u8981\u4F60\u8865\u5145\u4FE1\u606F{progress}\uFF1A",{progress:a})),lf(n.header)&&e.push("",n.header.trim()),e.push("",lf(n.question)??D("\u8BF7\u8F93\u5165\u4F60\u7684\u56DE\u7B54\u3002")),lf(n.detail)&&e.push("",n.detail.trim());let A=Array.isArray(n.options)?n.options:[];return A.length>0?(e.push(""),A.forEach((r,s)=>{let g=typeof r?.label=="string"?r.label:"",c=lf(r?.description);e.push(`${s+1}. ${g}${c?` \u2014 ${c}`:""}`)}),e.push("",n.multiSelect===!0?D("\u8BF7\u56DE\u590D\u9009\u9879\u5E8F\u53F7\u6216\u6587\u5B57\uFF1B\u591A\u9009\u7528\u9017\u53F7\u5206\u9694\uFF0C\u4E5F\u53EF\u8865\u5145\u5176\u4ED6\u5185\u5BB9\u3002"):D("\u8BF7\u56DE\u590D\u4E00\u4E2A\u9009\u9879\u5E8F\u53F7\u6216\u6587\u5B57\uFF0C\u4E5F\u53EF\u76F4\u63A5\u8F93\u5165\u5176\u4ED6\u7B54\u6848\u3002"))):e.push("",D("\u8BF7\u76F4\u63A5\u56DE\u590D\u4F60\u7684\u7B54\u6848\u3002")),i&&e.push("",D("\u7FA4\u804A\u4E2D\u8BF7 @\u673A\u5668\u4EBA \u540E\u53D1\u9001\u7B54\u6848\u3002")),e.join(`
145
145
  `)}function GH(n,t){let o=n.trim();if(!o)return null;if(/^\d+$/.test(o)){let e=t[Number(o)-1];return typeof e?.label=="string"?e.label:null}let i=t.find(e=>e?.label===o);return typeof i?.label=="string"?i.label:null}function ai(n,t){let o=Array.isArray(n.options)?n.options:[];if(o.length===0)return{id:n.id,selected:[],custom:t};let i=GH(t,o);if(n.multiSelect!==!0)return i?{id:n.id,selected:[i]}:{id:n.id,selected:[],custom:t};if(i)return{id:n.id,selected:[i]};let e=[],a=[];for(let A of t.split(/[,,、;;\n]+/)){let r=A.trim();if(!r)continue;let s=GH(r,o);s?e.includes(s)||e.push(s):a.push(r)}return{id:n.id,selected:e,...a.length>0?{custom:a.join("\u3001")}:{}}}var cce=new Map([["\u6279\u51C6","allowed-once"],["\u540C\u610F","allowed-once"],["yes","allowed-once"],["\u62D2\u7EDD","rejected"],["\u4E0D\u540C\u610F","rejected"],["no","rejected"]]),kb="\u8BF7\u7CBE\u51C6\u56DE\u590D\u300C\u6279\u51C6\u300D\u6216\u300C\u62D2\u7EDD\u300D\uFF08\u4E5F\u652F\u6301\uFF1A\u540C\u610F / \u4E0D\u540C\u610F / yes / no\uFF09\u3002",Ice="\u8BF7\u5148\u5B8C\u6210\u5F53\u524D\u95EE\u9898\uFF0C\u518D\u7CBE\u51C6\u56DE\u590D\u300C\u6279\u51C6\u300D\u6216\u300C\u62D2\u7EDD\u300D\u3002",Gl="\u8BE5\u5BA1\u6279\u5DF2\u5904\u7406\uFF0C\u65E0\u9700\u518D\u6B21\u56DE\u590D\u3002",lce=5*6e4,pce=2048;function wa(n){return typeof n=="string"?n.trim():""}function vb(n){return wa(n).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g,"")}function dce(n){return cce.get(wa(n).toLowerCase())??null}function LH(n){return n?.type==="approval/requested"&&!!wa(n.sessionId)&&!!wa(n.approvalId)&&!!wa(n.toolName)&&(n.callId===void 0||!!wa(n.callId))&&(n.reason===void 0||typeof n.reason=="string")}function hce(n){let t=n?.arguments;if(t!==null&&typeof t=="object")try{return JSON.stringify(t,null,2)}catch{return null}if(typeof t!="string")return null;let o=vb(t);if(!o)return t===""?"{}":null;try{return JSON.stringify(JSON.parse(o),null,2)}catch{return o}}function Pb(n,{toolCall:t,requiresMention:o=!1,maxArgumentsLength:i=6e3}={}){if(!LH(n))return null;let e=wa(n.callId);if(!e||wa(t?.callId)!==e||wa(t?.name)!==wa(n.toolName))return null;let a=hce(t);if(!a||a.length>i)return null;let A=[D("DeepSeek Harness \u9700\u8981\u4F60\u7684\u5BA1\u6279\uFF1A"),"",D("\u5DE5\u5177\uFF1A{tool}",{tool:vb(n.toolName)}),D("\u64CD\u4F5C\u53C2\u6570\uFF1A"),a],r=vb(n.reason);return r&&A.push(D("\u539F\u56E0\uFF1A{reason}",{reason:r})),A.push("",D(kb)),o&&A.push("",D("\u7FA4\u804A\u4E2D\u8BF7 @\u673A\u5668\u4EBA \u540E\u53D1\u9001\u5BA1\u6279\u51B3\u5B9A\u3002")),A.join(`
146
- `)}function FH(n,t){return{ok:!0,value:{sessionId:n.sessionId,approvalId:n.approvalId,outcome:t}}}function pf(n){return n==="allowed-once"?D("\u5DF2\u6279\u51C6\uFF0C\u4EC5\u5BF9\u672C\u6B21\u64CD\u4F5C\u6709\u6548\u3002"):n==="rejected"?D("\u5DF2\u62D2\u7EDD\u6B64\u6B21\u64CD\u4F5C\u3002"):D(Gl)}var ii=class{#e;#A;#t=new Map;#r=new Map;#a=new Map;constructor({label:t="IM",logger:o=console}={}){this.#e=t,this.#A=o}hasPending(t){return this.#r.get(t)?.items.some(o=>!o.inactive)===!0}claimReply({key:t,actor:o,text:i,addressed:e=!0,hasPendingQuestion:a=!1,questionCompletion:A,isQuestionPending:r,send:s}){let c=this.#r.get(t)?.items[0],I=dce(i),d=(f,Q=!1)=>({...Q?{resolved:!0}:{},process:async y=>{typeof y=="function"&&await y()===!1||await s(f)}}),B=a&&c&&A&&typeof A.then=="function";return a&&!B?null:!c||c.inactive?(this.#a.get(t)??0)<=Date.now()?(this.#a.delete(t),null):I?d(D(Gl),!0):null:c.actor!==o||c.requiresMention&&e!==!0?I?d(D("\u53EA\u6709\u53D1\u8D77\u5F53\u524D\u4EFB\u52A1\u7684\u7528\u6237\u53EF\u4EE5\u5904\u7406\u8FD9\u6761\u5BA1\u6279\u3002")):null:{process:async f=>{let Q=c.presented,m=(c.replyTail??Promise.resolve()).catch(()=>{}).then(async()=>{if(!(typeof f=="function"&&await f()===!1)){if(B){if(await A.catch(()=>{}),c.inactive||c.resolving)return;if(typeof r=="function"&&r()){await s(D(Ice));return}}if(await c.activationTask?.catch(()=>{}),await c.presentationTask?.catch(()=>{}),c.inactive||c.resolving){await s(D(Gl));return}if(c.send=s,!Q||!c.presented){if(c.presented||await this.#i(c),c.inactive||c.resolving)return;await s(D(kb));return}if(c.submitting){await s(D("\u5BA1\u6279\u51B3\u5B9A\u6B63\u5728\u63D0\u4EA4\uFF0C\u8BF7\u7A0D\u5019\u3002"));return}if(!I){await s(D(kb));return}await this.#c(c,I)}});c.replyTail=m;try{await m}finally{c.replyTail===m&&(c.replyTail=null)}}}}async handleRequested(t,o){if(t?.kind!=="approval")return!1;let i=t.payload,e=wa(i?.approvalId);if(!wa(t.rpcId)||!wa(t.sessionId)||!e||!LH(i)||i.sessionId!==t.sessionId||typeof t.respond!="function")return this.#A.warn?.(`[dsh-im:${this.#e}] ignored an invalid Harness approval`),!0;if(t.recovered===!0)return await this.#g(t,i),!0;let a=this.#t.get(e);if(a)return a.interaction=t,a.toolCall=t.toolCall,a.presented||await this.#i(a),!0;let A=o?.send,r=wa(o?.key),s=wa(o?.actor);if(!r||!s||typeof A!="function")return this.#A.warn?.(`[dsh-im:${this.#e}] ignored an approval without a reply route`),await this.#g(t,i),!0;let g=Pb(i,{toolCall:t.toolCall,requiresMention:o.requiresMention===!0});if(!g){let d=await this.#g(t,i);return await A(d?D("\u65E0\u6CD5\u5B8C\u6574\u5C55\u793A\u8FD9\u6B21\u64CD\u4F5C\uFF0C\u5DF2\u5B89\u5168\u62D2\u7EDD\u6B64\u6B21\u5BA1\u6279\u3002"):D(Gl)),!0}let c={approvalId:e,sessionId:t.sessionId,interaction:t,toolCall:t.toolCall,key:r,actor:s,requiresMention:o.requiresMention===!0,send:A,text:g,presented:!1,presentationTask:null,deliveryCompleted:!1,replyTail:null,submitting:!1,inactive:!1,resolving:!1,closedOutcome:null,resolutionNotified:!1,activationTask:null};this.#t.set(e,c);let I=this.#r.get(r)??{items:[]};return I.items.push(c),this.#r.set(r,I),I.items[0]===c&&await this.#i(c),!0}async handleResolved(t){if(t?.kind!=="approval")return!1;let o=this.#t.get(wa(t.interactionId));if(!o||(o.resolving=!0,o.activationTask&&await o.activationTask.catch(()=>{}),o.inactive||this.#t.get(o.approvalId)!==o))return!0;let i=o.presentationTask,e=o.presented||i,a=o.send,A=this.#o(o);return await this.#s(A,async()=>{let r=o.presented;i&&(r=await i.then(()=>!0,()=>!1)),e&&r&&(o.resolutionNotified=!0,await a(pf(t.outcome)).catch(()=>{}))}),!0}async closeRoute(t){let o=this.#r.get(t);if(!o)return;let i=[...o.items];for(let e of i)this.#o(e);await Promise.all(i.map(async e=>{try{await e.interaction.respond(FH(e,"rejected"),{signal:AbortSignal.timeout(5e3)}),e.closedOutcome="rejected",(e.presented||e.deliveryCompleted)&&!e.resolutionNotified&&(e.resolutionNotified=!0,await e.send(pf("rejected")).catch(()=>{}))}catch(a){a?.code==="interaction-not-pending"?(e.closedOutcome="resolved",(e.presented||e.deliveryCompleted)&&!e.resolutionNotified&&(e.resolutionNotified=!0,await e.send(D(Gl)).catch(()=>{}))):this.#A.warn?.(`[dsh-im:${this.#e}] failed to reject a closing approval:`,a)}}))}async#i(t){if(this.#r.get(t.key)?.items[0]!==t||t.inactive||t.resolving||t.presented||(await t.activationTask?.catch(()=>{}),this.#r.get(t.key)?.items[0]!==t||t.inactive||t.resolving||t.presented))return;if(t.presentationTask)return t.presentationTask;let o=Promise.resolve().then(()=>t.send(t.text));t.presentationTask=o;try{await o,t.deliveryCompleted=!0,t.inactive?t.closedOutcome&&!t.resolutionNotified&&(t.resolutionNotified=!0,await t.send(pf(t.closedOutcome)).catch(()=>{})):t.presented=!0}finally{t.presentationTask===o&&(t.presentationTask=null)}}async#c(t,o){t.submitting=!0;try{await t.interaction.respond(FH(t,o))}catch(a){if(a?.code==="interaction-not-pending"){let A=t.send,r=this.#o(t);await this.#s(r,async()=>{t.resolutionNotified||await A(D(Gl)).catch(()=>{})});return}if(t.inactive)return;t.submitting=!1,this.#A.error?.(`[dsh-im:${this.#e}] failed to submit an approval:`,a),await t.send(D("\u5BA1\u6279\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u56DE\u590D\u300C\u6279\u51C6\u300D\u6216\u300C\u62D2\u7EDD\u300D\u3002")).catch(()=>{});return}let i=t.send,e=this.#o(t);await this.#s(e,async()=>{t.resolutionNotified||await i(pf(o)).catch(()=>{})})}async#s(t,o){let i,e=new Promise(a=>{i=a});t&&(t.activationTask=e);try{await o()}finally{i(),t?.activationTask===e&&(t.activationTask=null)}await this.#I(t)}async#I(t){if(t)try{await this.#i(t)}catch(o){this.#A.error?.(`[dsh-im:${this.#e}] failed to present the next approval:`,o);try{t.interaction.reconnect?.()}catch{}}}#o(t){if(t.inactive)return null;t.inactive=!0,this.#n(t.key),this.#t.delete(t.approvalId);let o=this.#r.get(t.key);if(!o)return null;let i=o.items[0]===t,e=o.items.indexOf(t);return e!==-1&&o.items.splice(e,1),o.items.length===0?(this.#r.delete(t.key),null):i?o.items[0]:null}#n(t){let o=Date.now();for(let[i,e]of this.#a)e<=o&&this.#a.delete(i);for(this.#a.delete(t),this.#a.set(t,o+lce);this.#a.size>pce;)this.#a.delete(this.#a.keys().next().value)}async#g(t,o){try{return await t.respond({ok:!0,value:{sessionId:t.sessionId,approvalId:o.approvalId,outcome:"rejected"}},{signal:AbortSignal.timeout(5e3)}),!0}catch(i){if(i?.code==="interaction-not-pending")return!1;throw i}}};var Gb=new WeakMap;function Ece(n){let t=Gb.get(n);return t||(t=new Map,Gb.set(n,t)),t}async function Vc(n,t,o){let i=typeof n;if(i!=="object"&&i!=="function"||n===null)throw new TypeError("state is required");if(typeof t!="string"||!t)throw new TypeError("conversation key is required");if(typeof o!="function")throw new TypeError("operation is required");let e=Ece(n),a=e.get(t)??Promise.resolve(),A,r=new Promise(s=>{A=s});e.set(t,r),await a;try{return await o()}finally{A(),e.get(t)===r&&(e.delete(t),e.size===0&&Gb.delete(n))}}var oi="workspace-session-stale";function UH(n,t){return typeof n.workspaceSession=="function"?n.workspaceSession(t):Object.freeze({sessionId:t,sessionExists:(...o)=>n.sessionExists(t,...o),models:(...o)=>n.getSessionModels(t,...o),selectModel:(...o)=>n.selectSessionModel(t,...o),isRunning:(...o)=>n.isSessionRunning(t,...o),hasActiveTurn:(...o)=>n.hasActiveTurn(t,...o),stopActiveTurn:(...o)=>n.stopActiveTurn(t,...o),steerActiveTurn:(...o)=>n.steerActiveTurn(t,...o),ask:(...o)=>n.ask(t,...o)})}async function Cce(n,t){return t===void 0?n.sessionExists():n.sessionExists(t)}async function uce(n,t){return t===void 0?n.createSession():n.createSession(t)}async function ni({harness:n,state:t,key:o,text:i,content:e,createOptions:a,existsOptions:A,askOptions:r}){for(;;)try{let s=await Vc(t,o,async()=>{let B=t.sessionFor(o),f=B?UH(n,B):null;if(!f||!await Cce(f,A)){if(B=await uce(n,a),await t.setSession(o,B)===!1)return null;f=UH(n,B)}return{sessionId:B,session:f}});if(!s)continue;let g=[],c=typeof r=="object"&&typeof r?.onArtifact=="function"?r.onArtifact:null,I=typeof r=="number"?{timeoutMs:r}:{...r};I.onArtifact=async B=>{g.push(B),await c?.(B)};let d=await s.session.ask(e??i,I);return{sessionId:s.sessionId,answer:d,...g.length>0?{artifacts:g}:{}}}catch(s){if(s?.code!==oi)throw s}}var Bce=/^\/compact(?=$|\s)([\s\S]*)$/i,fce="\u7528\u6CD5\uFF1A/compact\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",HH=new Map([["No compactable history yet.","\u6682\u65E0\u53EF\u538B\u7F29\u7684\u5386\u53F2\u8BB0\u5F55\u3002"],["Compaction is unavailable because this process has an active compaction, or the agent is not idle.","\u5F53\u524D\u4F1A\u8BDD\u6B63\u5728\u751F\u6210\u56DE\u590D\u6216\u6267\u884C\u538B\u7F29\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"],["Compaction cancelled.","\u4E0A\u4E0B\u6587\u538B\u7F29\u5DF2\u53D6\u6D88\u3002"],["The history selected for compaction changed before it could be replaced. The conversation is unchanged; the attempt is recorded in the session log.","\u538B\u7F29\u671F\u95F4\u4F1A\u8BDD\u5386\u53F2\u53D1\u751F\u53D8\u5316\uFF0C\u672C\u6B21\u672A\u4FEE\u6539\u4F1A\u8BDD\uFF0C\u8BF7\u91CD\u8BD5\u3002"],["Compaction could not produce a useful summary. The conversation is unchanged; the attempt is recorded in the session log.","\u672A\u80FD\u751F\u6210\u6709\u6548\u7684\u538B\u7F29\u6458\u8981\uFF0C\u672C\u6B21\u672A\u4FEE\u6539\u4F1A\u8BDD\u3002"],["Compaction did not finish cleanly; some session history may have changed. Inspect the current session state before retrying.","\u4E0A\u4E0B\u6587\u538B\u7F29\u672A\u6B63\u5E38\u5B8C\u6210\uFF0C\u90E8\u5206\u4F1A\u8BDD\u5386\u53F2\u53EF\u80FD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u68C0\u67E5\u4F1A\u8BDD\u540E\u518D\u91CD\u8BD5\u3002"],["Compaction finished, but the session could not be saved.","\u4E0A\u4E0B\u6587\u5DF2\u538B\u7F29\uFF0C\u4F46\u4F1A\u8BDD\u4FDD\u5B58\u5931\u8D25\u3002"]]);function Wc(n){return{handled:!0,message:n,messages:[n]}}function Qce(n){if(!n||typeof n!="object"||!["success","error"].includes(n.kind)||n.text!==void 0&&typeof n.text!="string")throw new TypeError("Harness returned an invalid /compact result");let t=n.text?.trim()??"",o=/^Compacted (\d+) history items \(~(\d+) tokens\)\.$/u.exec(t);return o?D("\u5DF2\u538B\u7F29 {count} \u6761\u5386\u53F2\u8BB0\u5F55\uFF08\u7EA6 {tokens} \u4E2A token\uFF09\u3002",{count:o[1],tokens:o[2]}):HH.has(t)?D(HH.get(t)):t||(n.kind==="success"?D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210\u3002"):D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\u3002"))}function yce(n){let t=n?.code??n?.failure?.code;return t==="session-not-found"?D("\u5F53\u524D\u804A\u5929\u7ED1\u5B9A\u7684\u4F1A\u8BDD\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u53D1\u9001\u65B0\u6D88\u606F\u5F00\u542F\u4F1A\u8BDD\u3002"):t==="agent-busy"?D("\u5F53\u524D\u4F1A\u8BDD\u6B63\u5728\u751F\u6210\u56DE\u590D\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"):t==="cancelled"||n?.name==="AbortError"?D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5DF2\u53D6\u6D88\u3002"):t===oi||t==="workspace-bot-not-found"?D("\u5DE5\u4F5C\u533A\u6216\u673A\u5668\u4EBA\u72B6\u6001\u5DF2\u53D1\u751F\u53D8\u5316\uFF0C\u8BF7\u91CD\u8BD5\u3002"):t==="commands-unavailable"?D("\u5F53\u524D Harness \u6682\u4E0D\u652F\u6301\u4ECE\u673A\u5668\u4EBA\u6267\u884C\u4E0A\u4E0B\u6587\u538B\u7F29\u3002"):D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002")}async function si(n,t,o,i,e={}){if(typeof n!="string")return null;let a=Bce.exec(n.trim());if(!a)return null;if(a[1].trim())return Wc(D(fce));if(typeof o?.sessionFor!="function")return Wc(D("\u5F53\u524D\u673A\u5668\u4EBA\u6CA1\u6709\u53EF\u7528\u7684\u4F1A\u8BDD\u72B6\u6001\u3002"));let A=o.sessionFor(i);if(typeof A!="string"||!A)return Wc(D("\u5F53\u524D\u804A\u5929\u8FD8\u6CA1\u6709\u53EF\u538B\u7F29\u7684\u4F1A\u8BDD\uFF0C\u8BF7\u5148\u53D1\u9001\u4E00\u6761\u6D88\u606F\u3002"));if(typeof t?.executeCommand!="function")return Wc(D("\u5F53\u524D\u673A\u5668\u4EBA\u6682\u4E0D\u652F\u6301\u4E0A\u4E0B\u6587\u538B\u7F29\u3002"));try{let r=await t.executeCommand(A,"/compact",e);return Wc(r===void 0?D("\u5F53\u524D Harness \u672A\u6CE8\u518C /compact \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4\u4E0A\u4E0B\u6587\u538B\u7F29\u7EC4\u4EF6\u5DF2\u542F\u7528\u3002"):Qce(r?.result))}catch(r){return Wc(yce(r))}}var KH={name:"@xmanrui/dsh-im",version:"3.0.1",description:"\u628A\u4E5D\u79CD IM \u673A\u5668\u4EBA\u548C\u516C\u7F51 AI Office \u63A5\u5165\u672C\u673A DeepSeek Harness\u3002 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",keywords:["deepseek-harness","dsh","dsh-plugin","ai-agent","im","instant-messaging","chatbot","feishu","lark","wechat","wecom","dingtalk","qq","slack","telegram","discord","whatsapp","ai-office"],author:{name:"xmanrui",url:"https://github.com/xmanrui"},contributors:[{name:"C3H3-AI",url:"https://github.com/C3H3-AI"}],license:"MIT",type:"module",repository:{type:"git",url:"git+https://github.com/xmanrui/dsh-im.git"},homepage:"https://github.com/xmanrui/dsh-im#readme",bugs:"https://github.com/xmanrui/dsh-im/issues",publishConfig:{access:"public"},bin:{"dsh-im":"bin/dsh-im.mjs"},main:"./lib/index.js",exports:{".":"./lib/index.js","./client":"./lib/client.js","./package.json":"./package.json"},files:["assets","bin","cordis.patch.yml","lib","plugin-src","scripts","src","LICENSE","README.md","README.en.md","THIRD_PARTY_NOTICES.md"],dsh:{bundle:{patch:"./cordis.patch.yml"},client:{inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-runtime","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-slots","@deepseek-ai/dsh-client-locale"],platform:"web"}},scripts:{build:"node plugin-src/client/build.mjs && node plugin-src/host/build.mjs",test:"node --test test/*.test.mjs test/channels/*/*.test.mjs",check:"npm run build && npm test && node scripts/verify-package.mjs"},engines:{node:">=22.19"},dependencies:{"@tencent-connect/qqbot-connector":"1.2.0","@tencent-connect/qqbot-nodejs":"1.0.4","@wecom/aibot-node-sdk":"1.0.7","dingtalk-stream":"2.1.4",qrcode:"1.5.4"},devDependencies:{"@larksuiteoapi/node-sdk":"1.73.0","@whiskeysockets/baileys":"7.0.0-rc14",esbuild:"0.25.9","https-proxy-agent":"5.0.1",react:"18.3.1","react-dom":"18.3.1","react-test-renderer":"18.3.1"}};var Sce=/^\/(?:stop|steer|version)(?=$|\s)/iu,Dce=/^\/stop(?=$|\s)/iu,wce=/^\/version(?=$|\s)/iu,Oce="\u7528\u6CD5\uFF1A/stop\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",bce="\u7528\u6CD5\uFF1A/version\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",Mce="\u7528\u6CD5\uFF1A/steer <\u8865\u5145\u6307\u4EE4>",_ce="\u63A7\u5236\u547D\u4EE4\u4EC5\u652F\u6301\u7EAF\u6587\u5B57\uFF0C\u8BF7\u79FB\u9664\u56FE\u7247\u540E\u91CD\u8BD5\u3002";function co(n,t={}){return{message:n,...t}}function xH(n){return n?{signal:n}:{}}function YH(n,t,o){if(typeof t?.sessionFor!="function")return null;let i=t.sessionFor(o);if(typeof i!="string"||!i)return null;if(typeof n?.workspaceSession!="function")throw new TypeError("Harness does not support workspace sessions");let e=n.workspaceSession(i);if(!e||typeof e!="object")throw new TypeError("Harness returned an invalid workspace session");return e}function Pi(n){return typeof n=="string"&&Sce.test(n.trim())}async function gi(n,t,o,i,{signal:e,hasImages:a=!1,pendingInteraction:A=!1,control:r}={}){if(!Pi(n))return null;let s=n.trim(),g=Dce.test(s),c=wce.test(s);if(a)return co(D(_ce));if(c)return/^\/version$/iu.test(s)?co(`dsh-im v${KH.version}`):co(D(bce));if(g){if(!/^\/stop$/iu.test(s))return co(D(Oce));let Q=YH(t,o,i);if(!Q)return co(D("\u5F53\u524D\u804A\u5929\u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u3002"));if(typeof Q.stopActiveTurn!="function")throw new TypeError("Harness session does not support stopping active turns");return await Q.stopActiveTurn(r,xH(e))?co(D("\u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u4EFB\u52A1\u3002"),{stopped:!0}):co(D("\u5F53\u524D\u804A\u5929\u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u3002"))}let d=/^\/steer(?:\s+([\s\S]*))?$/iu.exec(s)?.[1]?.trim()??"";if(!d)return co(D(Mce));if(A)return co([D("\u5F53\u524D\u4EFB\u52A1\u6B63\u5728\u7B49\u5F85\u4F60\u7684\u56DE\u7B54\u6216\u5BA1\u6279\u3002"),"",D("\u8BF7\u5148\u5904\u7406\u5F53\u524D\u8BF7\u6C42\uFF0C\u6216\u8005\u53D1\u9001 /stop \u505C\u6B62\u4EFB\u52A1\u3002")].join(`
146
+ `)}function FH(n,t){return{ok:!0,value:{sessionId:n.sessionId,approvalId:n.approvalId,outcome:t}}}function pf(n){return n==="allowed-once"?D("\u5DF2\u6279\u51C6\uFF0C\u4EC5\u5BF9\u672C\u6B21\u64CD\u4F5C\u6709\u6548\u3002"):n==="rejected"?D("\u5DF2\u62D2\u7EDD\u6B64\u6B21\u64CD\u4F5C\u3002"):D(Gl)}var ii=class{#e;#A;#t=new Map;#r=new Map;#a=new Map;constructor({label:t="IM",logger:o=console}={}){this.#e=t,this.#A=o}hasPending(t){return this.#r.get(t)?.items.some(o=>!o.inactive)===!0}claimReply({key:t,actor:o,text:i,addressed:e=!0,hasPendingQuestion:a=!1,questionCompletion:A,isQuestionPending:r,send:s}){let c=this.#r.get(t)?.items[0],I=dce(i),d=(f,Q=!1)=>({...Q?{resolved:!0}:{},process:async y=>{typeof y=="function"&&await y()===!1||await s(f)}}),B=a&&c&&A&&typeof A.then=="function";return a&&!B?null:!c||c.inactive?(this.#a.get(t)??0)<=Date.now()?(this.#a.delete(t),null):I?d(D(Gl),!0):null:c.actor!==o||c.requiresMention&&e!==!0?I?d(D("\u53EA\u6709\u53D1\u8D77\u5F53\u524D\u4EFB\u52A1\u7684\u7528\u6237\u53EF\u4EE5\u5904\u7406\u8FD9\u6761\u5BA1\u6279\u3002")):null:{process:async f=>{let Q=c.presented,m=(c.replyTail??Promise.resolve()).catch(()=>{}).then(async()=>{if(!(typeof f=="function"&&await f()===!1)){if(B){if(await A.catch(()=>{}),c.inactive||c.resolving)return;if(typeof r=="function"&&r()){await s(D(Ice));return}}if(await c.activationTask?.catch(()=>{}),await c.presentationTask?.catch(()=>{}),c.inactive||c.resolving){await s(D(Gl));return}if(c.send=s,!Q||!c.presented){if(c.presented||await this.#i(c),c.inactive||c.resolving)return;await s(D(kb));return}if(c.submitting){await s(D("\u5BA1\u6279\u51B3\u5B9A\u6B63\u5728\u63D0\u4EA4\uFF0C\u8BF7\u7A0D\u5019\u3002"));return}if(!I){await s(D(kb));return}await this.#c(c,I)}});c.replyTail=m;try{await m}finally{c.replyTail===m&&(c.replyTail=null)}}}}async handleRequested(t,o){if(t?.kind!=="approval")return!1;let i=t.payload,e=wa(i?.approvalId);if(!wa(t.rpcId)||!wa(t.sessionId)||!e||!LH(i)||i.sessionId!==t.sessionId||typeof t.respond!="function")return this.#A.warn?.(`[dsh-im:${this.#e}] ignored an invalid Harness approval`),!0;if(t.recovered===!0)return await this.#g(t,i),!0;let a=this.#t.get(e);if(a)return a.interaction=t,a.toolCall=t.toolCall,a.presented||await this.#i(a),!0;let A=o?.send,r=wa(o?.key),s=wa(o?.actor);if(!r||!s||typeof A!="function")return this.#A.warn?.(`[dsh-im:${this.#e}] ignored an approval without a reply route`),await this.#g(t,i),!0;let g=Pb(i,{toolCall:t.toolCall,requiresMention:o.requiresMention===!0});if(!g){let d=await this.#g(t,i);return await A(d?D("\u65E0\u6CD5\u5B8C\u6574\u5C55\u793A\u8FD9\u6B21\u64CD\u4F5C\uFF0C\u5DF2\u5B89\u5168\u62D2\u7EDD\u6B64\u6B21\u5BA1\u6279\u3002"):D(Gl)),!0}let c={approvalId:e,sessionId:t.sessionId,interaction:t,toolCall:t.toolCall,key:r,actor:s,requiresMention:o.requiresMention===!0,send:A,text:g,presented:!1,presentationTask:null,deliveryCompleted:!1,replyTail:null,submitting:!1,inactive:!1,resolving:!1,closedOutcome:null,resolutionNotified:!1,activationTask:null};this.#t.set(e,c);let I=this.#r.get(r)??{items:[]};return I.items.push(c),this.#r.set(r,I),I.items[0]===c&&await this.#i(c),!0}async handleResolved(t){if(t?.kind!=="approval")return!1;let o=this.#t.get(wa(t.interactionId));if(!o||(o.resolving=!0,o.activationTask&&await o.activationTask.catch(()=>{}),o.inactive||this.#t.get(o.approvalId)!==o))return!0;let i=o.presentationTask,e=o.presented||i,a=o.send,A=this.#o(o);return await this.#s(A,async()=>{let r=o.presented;i&&(r=await i.then(()=>!0,()=>!1)),e&&r&&(o.resolutionNotified=!0,await a(pf(t.outcome)).catch(()=>{}))}),!0}async closeRoute(t){let o=this.#r.get(t);if(!o)return;let i=[...o.items];for(let e of i)this.#o(e);await Promise.all(i.map(async e=>{try{await e.interaction.respond(FH(e,"rejected"),{signal:AbortSignal.timeout(5e3)}),e.closedOutcome="rejected",(e.presented||e.deliveryCompleted)&&!e.resolutionNotified&&(e.resolutionNotified=!0,await e.send(pf("rejected")).catch(()=>{}))}catch(a){a?.code==="interaction-not-pending"?(e.closedOutcome="resolved",(e.presented||e.deliveryCompleted)&&!e.resolutionNotified&&(e.resolutionNotified=!0,await e.send(D(Gl)).catch(()=>{}))):this.#A.warn?.(`[dsh-im:${this.#e}] failed to reject a closing approval:`,a)}}))}async#i(t){if(this.#r.get(t.key)?.items[0]!==t||t.inactive||t.resolving||t.presented||(await t.activationTask?.catch(()=>{}),this.#r.get(t.key)?.items[0]!==t||t.inactive||t.resolving||t.presented))return;if(t.presentationTask)return t.presentationTask;let o=Promise.resolve().then(()=>t.send(t.text));t.presentationTask=o;try{await o,t.deliveryCompleted=!0,t.inactive?t.closedOutcome&&!t.resolutionNotified&&(t.resolutionNotified=!0,await t.send(pf(t.closedOutcome)).catch(()=>{})):t.presented=!0}finally{t.presentationTask===o&&(t.presentationTask=null)}}async#c(t,o){t.submitting=!0;try{await t.interaction.respond(FH(t,o))}catch(a){if(a?.code==="interaction-not-pending"){let A=t.send,r=this.#o(t);await this.#s(r,async()=>{t.resolutionNotified||await A(D(Gl)).catch(()=>{})});return}if(t.inactive)return;t.submitting=!1,this.#A.error?.(`[dsh-im:${this.#e}] failed to submit an approval:`,a),await t.send(D("\u5BA1\u6279\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u56DE\u590D\u300C\u6279\u51C6\u300D\u6216\u300C\u62D2\u7EDD\u300D\u3002")).catch(()=>{});return}let i=t.send,e=this.#o(t);await this.#s(e,async()=>{t.resolutionNotified||await i(pf(o)).catch(()=>{})})}async#s(t,o){let i,e=new Promise(a=>{i=a});t&&(t.activationTask=e);try{await o()}finally{i(),t?.activationTask===e&&(t.activationTask=null)}await this.#I(t)}async#I(t){if(t)try{await this.#i(t)}catch(o){this.#A.error?.(`[dsh-im:${this.#e}] failed to present the next approval:`,o);try{t.interaction.reconnect?.()}catch{}}}#o(t){if(t.inactive)return null;t.inactive=!0,this.#n(t.key),this.#t.delete(t.approvalId);let o=this.#r.get(t.key);if(!o)return null;let i=o.items[0]===t,e=o.items.indexOf(t);return e!==-1&&o.items.splice(e,1),o.items.length===0?(this.#r.delete(t.key),null):i?o.items[0]:null}#n(t){let o=Date.now();for(let[i,e]of this.#a)e<=o&&this.#a.delete(i);for(this.#a.delete(t),this.#a.set(t,o+lce);this.#a.size>pce;)this.#a.delete(this.#a.keys().next().value)}async#g(t,o){try{return await t.respond({ok:!0,value:{sessionId:t.sessionId,approvalId:o.approvalId,outcome:"rejected"}},{signal:AbortSignal.timeout(5e3)}),!0}catch(i){if(i?.code==="interaction-not-pending")return!1;throw i}}};var Gb=new WeakMap;function Ece(n){let t=Gb.get(n);return t||(t=new Map,Gb.set(n,t)),t}async function Vc(n,t,o){let i=typeof n;if(i!=="object"&&i!=="function"||n===null)throw new TypeError("state is required");if(typeof t!="string"||!t)throw new TypeError("conversation key is required");if(typeof o!="function")throw new TypeError("operation is required");let e=Ece(n),a=e.get(t)??Promise.resolve(),A,r=new Promise(s=>{A=s});e.set(t,r),await a;try{return await o()}finally{A(),e.get(t)===r&&(e.delete(t),e.size===0&&Gb.delete(n))}}var oi="workspace-session-stale";function UH(n,t){return typeof n.workspaceSession=="function"?n.workspaceSession(t):Object.freeze({sessionId:t,sessionExists:(...o)=>n.sessionExists(t,...o),models:(...o)=>n.getSessionModels(t,...o),selectModel:(...o)=>n.selectSessionModel(t,...o),isRunning:(...o)=>n.isSessionRunning(t,...o),hasActiveTurn:(...o)=>n.hasActiveTurn(t,...o),stopActiveTurn:(...o)=>n.stopActiveTurn(t,...o),steerActiveTurn:(...o)=>n.steerActiveTurn(t,...o),ask:(...o)=>n.ask(t,...o)})}async function Cce(n,t){return t===void 0?n.sessionExists():n.sessionExists(t)}async function uce(n,t){return t===void 0?n.createSession():n.createSession(t)}async function ni({harness:n,state:t,key:o,text:i,content:e,createOptions:a,existsOptions:A,askOptions:r}){for(;;)try{let s=await Vc(t,o,async()=>{let B=t.sessionFor(o),f=B?UH(n,B):null;if(!f||!await Cce(f,A)){if(B=await uce(n,a),await t.setSession(o,B)===!1)return null;f=UH(n,B)}return{sessionId:B,session:f}});if(!s)continue;let g=[],c=typeof r=="object"&&typeof r?.onArtifact=="function"?r.onArtifact:null,I=typeof r=="number"?{timeoutMs:r}:{...r};I.onArtifact=async B=>{g.push(B),await c?.(B)};let d=await s.session.ask(e??i,I);return{sessionId:s.sessionId,answer:d,...g.length>0?{artifacts:g}:{}}}catch(s){if(s?.code!==oi)throw s}}var Bce=/^\/compact(?=$|\s)([\s\S]*)$/i,fce="\u7528\u6CD5\uFF1A/compact\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",HH=new Map([["No compactable history yet.","\u6682\u65E0\u53EF\u538B\u7F29\u7684\u5386\u53F2\u8BB0\u5F55\u3002"],["Compaction is unavailable because this process has an active compaction, or the agent is not idle.","\u5F53\u524D\u4F1A\u8BDD\u6B63\u5728\u751F\u6210\u56DE\u590D\u6216\u6267\u884C\u538B\u7F29\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"],["Compaction cancelled.","\u4E0A\u4E0B\u6587\u538B\u7F29\u5DF2\u53D6\u6D88\u3002"],["The history selected for compaction changed before it could be replaced. The conversation is unchanged; the attempt is recorded in the session log.","\u538B\u7F29\u671F\u95F4\u4F1A\u8BDD\u5386\u53F2\u53D1\u751F\u53D8\u5316\uFF0C\u672C\u6B21\u672A\u4FEE\u6539\u4F1A\u8BDD\uFF0C\u8BF7\u91CD\u8BD5\u3002"],["Compaction could not produce a useful summary. The conversation is unchanged; the attempt is recorded in the session log.","\u672A\u80FD\u751F\u6210\u6709\u6548\u7684\u538B\u7F29\u6458\u8981\uFF0C\u672C\u6B21\u672A\u4FEE\u6539\u4F1A\u8BDD\u3002"],["Compaction did not finish cleanly; some session history may have changed. Inspect the current session state before retrying.","\u4E0A\u4E0B\u6587\u538B\u7F29\u672A\u6B63\u5E38\u5B8C\u6210\uFF0C\u90E8\u5206\u4F1A\u8BDD\u5386\u53F2\u53EF\u80FD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u68C0\u67E5\u4F1A\u8BDD\u540E\u518D\u91CD\u8BD5\u3002"],["Compaction finished, but the session could not be saved.","\u4E0A\u4E0B\u6587\u5DF2\u538B\u7F29\uFF0C\u4F46\u4F1A\u8BDD\u4FDD\u5B58\u5931\u8D25\u3002"]]);function Wc(n){return{handled:!0,message:n,messages:[n]}}function Qce(n){if(!n||typeof n!="object"||!["success","error"].includes(n.kind)||n.text!==void 0&&typeof n.text!="string")throw new TypeError("Harness returned an invalid /compact result");let t=n.text?.trim()??"",o=/^Compacted (\d+) history items \(~(\d+) tokens\)\.$/u.exec(t);return o?D("\u5DF2\u538B\u7F29 {count} \u6761\u5386\u53F2\u8BB0\u5F55\uFF08\u7EA6 {tokens} \u4E2A token\uFF09\u3002",{count:o[1],tokens:o[2]}):HH.has(t)?D(HH.get(t)):t||(n.kind==="success"?D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210\u3002"):D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\u3002"))}function yce(n){let t=n?.code??n?.failure?.code;return t==="session-not-found"?D("\u5F53\u524D\u804A\u5929\u7ED1\u5B9A\u7684\u4F1A\u8BDD\u5DF2\u4E0D\u5B58\u5728\uFF0C\u8BF7\u53D1\u9001\u65B0\u6D88\u606F\u5F00\u542F\u4F1A\u8BDD\u3002"):t==="agent-busy"?D("\u5F53\u524D\u4F1A\u8BDD\u6B63\u5728\u751F\u6210\u56DE\u590D\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"):t==="cancelled"||n?.name==="AbortError"?D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5DF2\u53D6\u6D88\u3002"):t===oi||t==="workspace-bot-not-found"?D("\u5DE5\u4F5C\u533A\u6216\u673A\u5668\u4EBA\u72B6\u6001\u5DF2\u53D1\u751F\u53D8\u5316\uFF0C\u8BF7\u91CD\u8BD5\u3002"):t==="commands-unavailable"?D("\u5F53\u524D Harness \u6682\u4E0D\u652F\u6301\u4ECE\u673A\u5668\u4EBA\u6267\u884C\u4E0A\u4E0B\u6587\u538B\u7F29\u3002"):D("\u4E0A\u4E0B\u6587\u538B\u7F29\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002")}async function si(n,t,o,i,e={}){if(typeof n!="string")return null;let a=Bce.exec(n.trim());if(!a)return null;if(a[1].trim())return Wc(D(fce));if(typeof o?.sessionFor!="function")return Wc(D("\u5F53\u524D\u673A\u5668\u4EBA\u6CA1\u6709\u53EF\u7528\u7684\u4F1A\u8BDD\u72B6\u6001\u3002"));let A=o.sessionFor(i);if(typeof A!="string"||!A)return Wc(D("\u5F53\u524D\u804A\u5929\u8FD8\u6CA1\u6709\u53EF\u538B\u7F29\u7684\u4F1A\u8BDD\uFF0C\u8BF7\u5148\u53D1\u9001\u4E00\u6761\u6D88\u606F\u3002"));if(typeof t?.executeCommand!="function")return Wc(D("\u5F53\u524D\u673A\u5668\u4EBA\u6682\u4E0D\u652F\u6301\u4E0A\u4E0B\u6587\u538B\u7F29\u3002"));try{let r=await t.executeCommand(A,"/compact",e);return Wc(r===void 0?D("\u5F53\u524D Harness \u672A\u6CE8\u518C /compact \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4\u4E0A\u4E0B\u6587\u538B\u7F29\u7EC4\u4EF6\u5DF2\u542F\u7528\u3002"):Qce(r?.result))}catch(r){return Wc(yce(r))}}var KH={name:"@xmanrui/dsh-im",version:"3.0.2",description:"\u628A\u4E5D\u79CD IM \u673A\u5668\u4EBA\u548C\u516C\u7F51 AI Office \u63A5\u5165\u672C\u673A DeepSeek Harness\u3002 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",keywords:["deepseek-harness","dsh","dsh-plugin","ai-agent","im","instant-messaging","chatbot","feishu","lark","wechat","wecom","dingtalk","qq","slack","telegram","discord","whatsapp","ai-office"],author:{name:"xmanrui",url:"https://github.com/xmanrui"},contributors:[{name:"C3H3-AI",url:"https://github.com/C3H3-AI"}],license:"MIT",type:"module",repository:{type:"git",url:"git+https://github.com/xmanrui/dsh-im.git"},homepage:"https://github.com/xmanrui/dsh-im#readme",bugs:"https://github.com/xmanrui/dsh-im/issues",publishConfig:{access:"public"},bin:{"dsh-im":"bin/dsh-im.mjs"},main:"./lib/index.js",exports:{".":"./lib/index.js","./client":"./lib/client.js","./package.json":"./package.json"},files:["assets","bin","cordis.patch.yml","lib","plugin-src","scripts","src","LICENSE","README.md","README.en.md","THIRD_PARTY_NOTICES.md"],dsh:{bundle:{patch:"./cordis.patch.yml"},client:{inject:["@deepseek-ai/dsh-client-connection","@deepseek-ai/dsh-client-runtime","@deepseek-ai/dsh-client-ui-settings","@deepseek-ai/dsh-client-ui-slots","@deepseek-ai/dsh-client-locale"],platform:"web"}},scripts:{build:"node plugin-src/client/build.mjs && node plugin-src/host/build.mjs",test:"node --test test/*.test.mjs test/channels/*/*.test.mjs",check:"npm run build && npm test && node scripts/verify-package.mjs"},engines:{node:">=22.19"},dependencies:{"@tencent-connect/qqbot-connector":"1.2.0","@tencent-connect/qqbot-nodejs":"1.0.4","@wecom/aibot-node-sdk":"1.0.7","dingtalk-stream":"2.1.4",qrcode:"1.5.4"},devDependencies:{"@larksuiteoapi/node-sdk":"1.73.0","@whiskeysockets/baileys":"7.0.0-rc14",esbuild:"0.25.9","https-proxy-agent":"5.0.1",react:"18.3.1","react-dom":"18.3.1","react-test-renderer":"18.3.1"}};var Sce=/^\/(?:stop|steer|version)(?=$|\s)/iu,Dce=/^\/stop(?=$|\s)/iu,wce=/^\/version(?=$|\s)/iu,Oce="\u7528\u6CD5\uFF1A/stop\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",bce="\u7528\u6CD5\uFF1A/version\uFF08\u4E0D\u5E26\u53C2\u6570\uFF09",Mce="\u7528\u6CD5\uFF1A/steer <\u8865\u5145\u6307\u4EE4>",_ce="\u63A7\u5236\u547D\u4EE4\u4EC5\u652F\u6301\u7EAF\u6587\u5B57\uFF0C\u8BF7\u79FB\u9664\u56FE\u7247\u540E\u91CD\u8BD5\u3002";function co(n,t={}){return{message:n,...t}}function xH(n){return n?{signal:n}:{}}function YH(n,t,o){if(typeof t?.sessionFor!="function")return null;let i=t.sessionFor(o);if(typeof i!="string"||!i)return null;if(typeof n?.workspaceSession!="function")throw new TypeError("Harness does not support workspace sessions");let e=n.workspaceSession(i);if(!e||typeof e!="object")throw new TypeError("Harness returned an invalid workspace session");return e}function Pi(n){return typeof n=="string"&&Sce.test(n.trim())}async function gi(n,t,o,i,{signal:e,hasImages:a=!1,pendingInteraction:A=!1,control:r}={}){if(!Pi(n))return null;let s=n.trim(),g=Dce.test(s),c=wce.test(s);if(a)return co(D(_ce));if(c)return/^\/version$/iu.test(s)?co(`dsh-im v${KH.version}`):co(D(bce));if(g){if(!/^\/stop$/iu.test(s))return co(D(Oce));let Q=YH(t,o,i);if(!Q)return co(D("\u5F53\u524D\u804A\u5929\u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u3002"));if(typeof Q.stopActiveTurn!="function")throw new TypeError("Harness session does not support stopping active turns");return await Q.stopActiveTurn(r,xH(e))?co(D("\u5DF2\u8BF7\u6C42\u505C\u6B62\u5F53\u524D\u4EFB\u52A1\u3002"),{stopped:!0}):co(D("\u5F53\u524D\u804A\u5929\u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\u3002"))}let d=/^\/steer(?:\s+([\s\S]*))?$/iu.exec(s)?.[1]?.trim()??"";if(!d)return co(D(Mce));if(A)return co([D("\u5F53\u524D\u4EFB\u52A1\u6B63\u5728\u7B49\u5F85\u4F60\u7684\u56DE\u7B54\u6216\u5BA1\u6279\u3002"),"",D("\u8BF7\u5148\u5904\u7406\u5F53\u524D\u8BF7\u6C42\uFF0C\u6216\u8005\u53D1\u9001 /stop \u505C\u6B62\u4EFB\u52A1\u3002")].join(`
147
147
  `));let B=YH(t,o,i);if(!B)return co(D("\u5F53\u524D\u804A\u5929\u6CA1\u6709\u7ED1\u5B9A\u4F1A\u8BDD\uFF0C\u65E0\u6CD5\u8865\u5145\u6307\u4EE4\u3002\u8BF7\u5148\u7ED1\u5B9A\u4F1A\u8BDD\u3002"));if(typeof B.steerActiveTurn!="function")throw new TypeError("Harness session does not support steering active turns");let f=await B.steerActiveTurn(d,r,xH(e));return co(f?D("\u5DF2\u63D0\u4EA4\u8865\u5145\u6307\u4EE4\uFF0CAgent \u4F1A\u5728\u4E0B\u4E00\u6B65\u8BFB\u53D6\u3002"):D("\u4EFB\u52A1\u5DF2\u7ED3\u675F\uFF0C\u6CA1\u6709\u6B63\u5728\u8FD0\u884C\u7684\u4EFB\u52A1\uFF0C\u65E0\u6CD5\u8865\u5145\u6307\u4EE4\u3002\u8BF7\u76F4\u63A5\u53D1\u9001\u6D88\u606F\u5F00\u59CB\u65B0\u4EFB\u52A1\u3002"))}import{realpath as qH,stat as zH}from"node:fs/promises";import{isAbsolute as VH,resolve as Tce}from"node:path";var Nce=/^\/workspace(?:\s+([\s\S]+))?$/i,Rce=/^\/workspacelist(?:\s+([\s\S]+))?$/i,kce=/^\/sessionlist(?:\s+([\s\S]+))?$/i,vce=/^\/session(?=$|\s)/i,Pce=/^\/session[ \t]+([^\s]+)$/i,Gce=4096,Fce=1800,Lce=256,WH=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u,Uce=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+/gu,ZH="\u7528\u6CD5\uFF1A/session Session ID \u6216\u5F53\u524D\u5DE5\u4F5C\u533A\u5E8F\u53F7\uFF08/session N\uFF09",Fl=["\u7528\u6CD5\uFF1A","/sessionlist \u5217\u51FA\u5F53\u524D\u5DE5\u4F5C\u533A\u4F1A\u8BDD","/sessionlist \u5DE5\u4F5C\u533A\u5E8F\u53F7 \u6309 /workspacelist \u5E8F\u53F7\u5217\u51FA\u4F1A\u8BDD","/sessionlist \u5DE5\u4F5C\u533A\u7EDD\u5BF9\u8DEF\u5F84 \u5217\u51FA\u6307\u5B9A\u5DE5\u4F5C\u533A\u4F1A\u8BDD"].join(`
148
148
  `);function Pt(n,t=[n]){return{handled:!0,message:n,messages:t}}function Ll(n){return typeof n!="string"||n.length>Gce||!VH(n)||WH.test(n)?null:Tce(n)}function df(n){return typeof n!="string"?"":n.replace(Uce," ").replace(/\s+/gu," ").trim()}function jH(n){return typeof n=="string"&&n.length>0&&n.length<=Lce&&!new RegExp("\\p{White_Space}","u").test(n)&&!WH.test(n)}async function Fb(n){let t=await Promise.all(n.map(async o=>{let i=Ll(o);if(!i)return null;try{return(await zH(i)).isDirectory()?Ll(await qH(i)):null}catch{return null}}));return[...new Set(t.filter(Boolean))]}async function Lb(n){if(typeof n!="string"||!VH(n.trim()))return{error:D(`\u5DE5\u4F5C\u533A\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84\u3002
149
149
  {usage}`,{usage:D(Fl)})};let t=Ll(n.trim());if(!t)return{error:D(`\u5DE5\u4F5C\u533A\u8DEF\u5F84\u5305\u542B\u4E0D\u652F\u6301\u7684\u5B57\u7B26\u6216\u957F\u5EA6\u8D85\u8FC7\u9650\u5236\u3002
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmanrui/dsh-im",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "把九种 IM 机器人和公网 AI Office 接入本机 DeepSeek Harness。 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
@@ -161,7 +161,6 @@ export function IMSettingsTab({
161
161
  }) {
162
162
  const [selected, setSelected] = React.useState('weixin');
163
163
  const [loopbackRecovery, setLoopbackRecovery] = React.useState(null);
164
- const versionTooltipId = React.useId();
165
164
  const githubTooltipId = React.useId();
166
165
  const active = CHANNELS.find((channel) => channel.id === selected) ?? CHANNELS[0];
167
166
  const reportLoopbackRecovery = React.useCallback((recovery) => {
@@ -198,20 +197,11 @@ export function IMSettingsTab({
198
197
  return h(WorkspaceDirectoryPickerContext.Provider, { value: workspaceDirectoryPicker },
199
198
  h('section', { className: 'dim-page', 'aria-label': 'IM机器人设置' },
200
199
  h('header', { className: 'dim-title' },
201
- h('div', {
202
- className: 'dim-brand',
203
- tabIndex: 0,
204
- 'aria-describedby': versionTooltipId,
205
- },
206
- h('strong', { className: 'dim-brandName' }, 'DSH-IM'),
207
- h('p', null, '让 DeepSeek Harness 触手可及'),
208
- h('span', {
209
- id: versionTooltipId,
210
- className: 'dim-versionTooltip',
211
- role: 'tooltip',
212
- },
213
- h('span', null, '当前版本'),
214
- h('strong', null, `v${IM_PLUGIN_VERSION}`))),
200
+ h('div', { className: 'dim-brand' },
201
+ h('div', { className: 'dim-brandHeading' },
202
+ h('strong', { className: 'dim-brandName' }, 'DSH-IM'),
203
+ h('span', { className: 'dim-brandVersion' }, `v${IM_PLUGIN_VERSION}`)),
204
+ h('p', null, '让 DeepSeek Harness 触手可及')),
215
205
  h('span', { className: 'dim-githubAction' },
216
206
  h('a', {
217
207
  className: 'dim-githubLink',
@@ -12,13 +12,11 @@ const CSS = String.raw`
12
12
  }
13
13
  .dim-page *, .dim-page *::before, .dim-page *::after { box-sizing: border-box; }
14
14
  .dim-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 18px; }
15
- .dim-brand { position: relative; min-width: 0; width: max-content; max-width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin: -2px -6px; padding: 2px 6px; border-radius: 8px; cursor: help; }
16
- .dim-brand:focus-visible { outline: 2px solid color-mix(in srgb, var(--dim-blue) 70%, white); outline-offset: 2px; }
15
+ .dim-brand { min-width: 0; width: max-content; max-width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; margin: -2px -6px; padding: 2px 6px; border-radius: 8px; }
16
+ .dim-brandHeading { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
17
17
  .dim-brandName { color: var(--dsw-alias-label-primary, #1f2329); font-size: 20px; line-height: 24px; font-weight: 800; letter-spacing: .04em; }
18
+ .dim-brandVersion { color: var(--dsw-alias-label-tertiary, #8f959e); font: 500 10px/16px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; }
18
19
  .dim-title p { margin: 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap; }
19
- .dim-versionTooltip { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; width: max-content; max-width: min(220px, 80vw); display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 7px; color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-bg-layer-3, #fff); box-shadow: 0 8px 24px rgb(31 35 41 / 14%); font-size: 11px; line-height: 16px; font-weight: 500; white-space: nowrap; opacity: 0; visibility: hidden; transform: translateY(-3px); pointer-events: none; transition: opacity .15s ease, transform .15s ease, visibility .15s ease; }
20
- .dim-versionTooltip strong { color: var(--dsw-alias-label-primary, #1f2329); font: 600 11px/16px ui-monospace, SFMono-Regular, Menlo, monospace; }
21
- .dim-brand:hover .dim-versionTooltip, .dim-brand:focus .dim-versionTooltip { opacity: 1; visibility: visible; transform: translateY(0); }
22
20
  .dim-githubAction { position: relative; display: inline-flex; flex: none; }
23
21
  .dim-githubLink { min-height: 30px; display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 0 10px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 8px; color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-bg-layer-1, #fff); font-size: 12px; line-height: normal; font-weight: 560; text-decoration: none; transition: border-color .15s ease, color .15s ease, background .15s ease; }
24
22
  .dim-githubLink:hover { border-color: #aeb3bb; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }