@xopcai/xopc 0.0.484 → 0.0.485
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +4 -6
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +2 -1
- package/dist/gateway/server/chunks.bin +842 -830
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B1Ri4sh8.js → automations-page-uY_wmZY1.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CNSza6ir.js → automations-workspace-DyQq55Rh.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-EENl65YY.js → capabilities-page-WCl7Fdce.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-LOR5JxDh.js → chat-page-3fVhP77N.js} +30 -30
- package/dist/gateway/static/root/assets/command-palette-api-UrqPvWR1.js +1 -0
- package/dist/gateway/static/root/assets/{index-DE6GguFZ.js → index-790PGhZb.js} +4 -4
- package/dist/gateway/static/root/assets/{note-detail-panel-DXzfoiyk.js → note-detail-panel-Bwm_aehq.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-BNTgiHSk.js → notes-page-DkZWV3Ds.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-D7zTHQ0K.js → personal-page-cauym9hr.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-Dgs8ImMC.js → project-detail-page-D9WKZe3z.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-7WVrzJca.js → route-preload-DF8LOfKW.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-BOzzOS6k.js → settings-page-Cd9WZ-Ac.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-gGU0LZ5e.js → skills-page-kL8E5zgi.js} +1 -1
- package/dist/gateway/static/root/assets/{space-page-CKVuhV2i.js → space-page-DlJB7GT1.js} +2 -2
- package/dist/gateway/static/root/assets/{task-detail-page-DEpYIaok.js → task-detail-page-BFa0Px-B.js} +1 -1
- package/dist/gateway/static/root/assets/{task-header-title-Cdgp2rCs.js → task-header-title-qzNctGl5.js} +1 -1
- package/dist/gateway/static/root/assets/{use-personal-work-Dd2jRUpz.js → use-personal-work-B1DWeBnm.js} +1 -1
- package/dist/gateway/static/root/index.html +6 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
- package/dist/src/agent/mcp/connection-drafts.js +24 -11
- package/dist/src/agent/mcp/connection-setup.js +13 -10
- package/dist/src/agent/mcp/native-mcp.js +1 -0
- package/dist/src/agent/mcp/network-policy.d.ts +6 -0
- package/dist/src/agent/mcp/network-policy.js +49 -0
- package/dist/src/agent/mcp/transport.js +14 -7
- package/dist/src/agent/messaging/message-router.js +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +9 -24
- package/dist/src/chat-commands/command-parse.d.ts +1 -0
- package/dist/src/chat-commands/command-parse.js +8 -10
- package/dist/src/chat-commands/registry.d.ts +5 -0
- package/dist/src/chat-commands/registry.js +8 -0
- package/dist/src/config/schema.d.ts +54 -4
- package/dist/src/config/schema.js +3 -1
- package/dist/src/gateway/hono/routes/home.js +1 -1
- package/dist/src/gateway/hono/routes/mobile-capability-panels.d.ts +67 -0
- package/dist/src/gateway/hono/routes/mobile-capability-panels.js +16 -131
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.d.ts +9 -0
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.js +929 -0
- package/dist/src/gateway/hono/routes/session-command-handler.js +1 -4
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -4
- package/dist/src/gateway/next-turn-suggestions/generator.js +16 -2
- package/dist/src/gateway/next-turn-suggestions/service.d.ts +2 -1
- package/dist/src/gateway/next-turn-suggestions/service.js +17 -5
- package/dist/src/gateway/next-turn-suggestions/snapshot.d.ts +11 -0
- package/dist/src/gateway/next-turn-suggestions/snapshot.js +31 -2
- package/dist/src/gateway/service/config-coordinator.d.ts +14 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/home-intelligence/host.js +5 -5
- package/dist/src/media/generation-changes.d.ts +4 -0
- package/dist/src/media/generation-changes.js +37 -0
- package/dist/src/music-generation/repository.js +12 -6
- package/dist/src/session/reset-triggers.js +1 -1
- package/dist/src/tui/tui-commands.d.ts +2 -1
- package/dist/src/tui/tui-commands.js +3 -3
- package/dist/src/tui/tui-submit.d.ts +1 -1
- package/dist/src/tui/tui-submit.js +2 -4
- package/dist/src/video-generation/drafts.js +2 -0
- package/dist/src/video-generation/repository.js +13 -6
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/command-palette-api-YP0zV_Ol.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,l as i,o as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./createLucideIcon-DPHK1VkS.js";import{I as s}from"./chat-page-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,l as i,o as a}from"./locale-store-CHjsq5NR.js";import{t as o}from"./createLucideIcon-DPHK1VkS.js";import{I as s}from"./chat-page-3fVhP77N.js";import{i as c,t as l}from"./vendor-swr-CdRzEUwF.js";import{c as u}from"./composer-payload-handoff-ClWsunJ2.js";var d=o(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),f=n(),p=e(t(),1),m=10;function h(e){return r(`/api/personal-agent/activity?view=work&limit=${m}&offset=${e}`)}async function g([e]){return(await a(e)).payload}function _(e){let t=(0,f.c)(3),n=i(v),r;return t[0]!==e||t[1]!==n?(r=e?[h(0),e,n]:null,t[0]=e,t[1]=n,t[2]=r):r=t[2],c(r,g)}function v(e){return e.conversationId}function y(e,t,n){let r=(0,f.c)(36),a=i(S),[o,s]=(0,p.useState)(!1),c=t?.total??0,u;r[0]!==a||r[1]!==e||r[2]!==o||r[3]!==c?(u=(t,n)=>{let r=(t+1)*m;return!o||r>=c||n&&n.items.length<m?null:[h(r),e,a]},r[0]=a,r[1]=e,r[2]=o,r[3]=c,r[4]=u):u=r[4];let d;r[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateFirstPage:!1,shouldRetryOnError:!1},r[5]=d):d=r[5];let{data:_,error:v,isValidating:y,size:C,setSize:w,mutate:T}=l(u,g,d),E;r[6]!==t?.items||r[7]!==c?(E=JSON.stringify([c,t?.items.map(x)]),r[6]=t?.items,r[7]=c,r[8]=E):E=r[8];let D=E,O=(0,p.useRef)(D),k,A;r[9]!==D||r[10]!==T||r[11]!==o?(k=()=>{let e=O.current!==D;O.current=D,e&&o&&T()},A=[D,T,o],r[9]=D,r[10]=T,r[11]=o,r[12]=k,r[13]=A):(k=r[12],A=r[13]),(0,p.useEffect)(k,A);let j=_?.length??0,M;r[14]!==_||r[15]!==j||r[16]!==c?(M=(j+1)*m<c&&(j===0||_?.at(-1)?.items.length===m),r[14]=_,r[15]=j,r[16]=c,r[17]=M):M=r[17];let N=M,P=o&&!v&&N&&(y||C>j),F;r[18]!==w||r[19]!==C||r[20]!==o?(F=()=>{o?w(C+1):s(!0)},r[18]=w,r[19]=C,r[20]=o,r[21]=F):F=r[21];let I=F,L;r[22]===t?.items?L=r[23]:(L=t?.items??[],r[22]=t?.items,r[23]=L);let R;r[24]!==_||r[25]!==L?(R=[...L,...(_??[]).flatMap(b)],r[24]=_,r[25]=L,r[26]=R):R=r[26];let z=n?v:void 0,B=n&&N,V=n&&P,H;r[27]===T?H=r[28]:(H=()=>void T(),r[27]=T,r[28]=H);let U;return r[29]!==I||r[30]!==B||r[31]!==V||r[32]!==H||r[33]!==R||r[34]!==z?(U={items:R,error:z,hasMore:B,loading:V,loadMore:I,retry:H},r[29]=I,r[30]=B,r[31]=V,r[32]=H,r[33]=R,r[34]=z,r[35]=U):U=r[35],U}function b(e){return e.items}function x(e){return e.id}function S(e){return e.conversationId}function C(e){let t=(0,f.c)(6),n=i(T),a=`/api/sessions/${encodeURIComponent(e??``)}/clarification`,o;t[0]===a?o=t[1]:(o=r(a),t[0]=a,t[1]=o);let s=o,l;return t[2]!==e||t[3]!==n||t[4]!==s?(l=e?[s,e,n]:null,t[2]=e,t[3]=n,t[4]=s,t[5]=l):l=t[5],c(l,w)}async function w(e){let[t]=e;return(await a(t)).payload?.clarification??null}function T(e){return e.conversationId}function E(e){return!!e.attention||e.presentation.status===`needsUser`||e.presentation.status===`review`}function D(e,t,n){let r=(0,f.c)(5),i,a;r[0]!==e||r[1]!==n||r[2]!==t?(i=()=>{if(!e)return;let r,i=()=>{window.clearTimeout(r),r=window.setTimeout(()=>{Promise.allSettled([t(),n?.()])},120)},a=[`task-changed-v2`,`task-updated`,`clarification-updated`,`gateway-realtime-connected`],o=t=>{t.detail?.key===e&&i()};a.forEach(e=>window.addEventListener(e,i)),window.addEventListener(`session-transcript-updated`,o);let s=window.setInterval(()=>{document.visibilityState===`visible`&&i()},15e3);return()=>{window.clearTimeout(r),window.clearInterval(s),a.forEach(e=>window.removeEventListener(e,i)),window.removeEventListener(`session-transcript-updated`,o)}},a=[e,t,n],r[0]=e,r[1]=n,r[2]=t,r[3]=i,r[4]=a):(i=r[3],a=r[4]),(0,p.useEffect)(i,a)}function O(e,t){let n=(0,f.c)(5),r=(0,p.useRef)(null),i=(0,p.useRef)(null),a,o;n[0]!==e||n[1]!==t?(a=()=>{let n=r.current,a=i.current;if(!e||!n||!a||typeof IntersectionObserver>`u`)return;let o=new IntersectionObserver(e=>{e.some(k)&&t()},{root:n,rootMargin:`0px 0px 120px`});return o.observe(a),()=>o.disconnect()},o=[e,t],n[0]=e,n[1]=t,n[2]=a,n[3]=o):(a=n[2],o=n[3]),(0,p.useEffect)(a,o);let s;return n[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={listRef:r,loadMoreRef:i},n[4]=s):s=n[4],s}function k(e){return e.isIntersecting}function A(e){return e?.status===`open`&&(e.expiresAt===void 0||e.expiresAt>Date.now())}function j(e,t){let{status:n}=e.presentation,r=n===`failed`?`bg-danger`:[`needsUser`,`review`,`waiting`,`blocked`,`paused`].includes(n)?`bg-warning`:[`running`,`verifying`,`completed`].includes(n)?`bg-accent`:`bg-fg-subtle`;return[u(t?`zh`:`en`).detailStatuses[n],r]}function M(e,t){let n=(0,f.c)(26),r;n[0]===e?r=n[1]:(r=t=>e?t.runs[e]:void 0,n[0]=e,n[1]=r);let i=s(r),{data:a,mutate:o,error:c}=_(e),{data:l,mutate:u,error:d}=C(e),m,h,g,v;if(n[2]!==l||n[3]!==a?.current){m=a?.current??[];let e=m.filter(E);v=e.length,h=Number,g=A(l)&&!e.some(e=>e.prompt?.id===l.id),n[2]=l,n[3]=a?.current,n[4]=m,n[5]=h,n[6]=g,n[7]=v}else m=n[4],h=n[5],g=n[6],v=n[7];let y=v+h(g),b;n[8]===m?b=n[9]:(b=m.filter(F),n[8]=m,n[9]=b);let x=b,S;n[10]===m?S=n[11]:(S=m.filter(P),n[10]=m,n[11]=S);let w=S,T;n[12]===a?.items?T=n[13]:(T=a?.items.find(N)?.updatedAt,n[12]=a?.items,n[13]=T);let D=T,[O,k]=(0,p.useState)(),j,M;n[14]===D?(j=n[15],M=n[16]):(j=()=>{if(D===void 0)return;let e=D+4e3-Date.now();if(e<=0)return;k(D);let t=window.setTimeout(()=>k(void 0),e);return()=>window.clearTimeout(t)},M=[D],n[14]=D,n[15]=j,n[16]=M),(0,p.useEffect)(j,M);let I=O!==void 0&&O===D,L=y?`waiting`:x.length||w.length||i?.status===`running`?`working`:i?.status===`waiting`?`waiting`:I?`delivered`:`idle`,R=``;y?R=t?`有 ${y} 项待你处理`:`${y} to review`:x.length>1?R=t?`有 ${x.length} 项正在推进`:`${x.length} in progress`:x[0]?R=t?`正在推进 · ${x[0].title}`:`Working · ${x[0].title}`:i?.status===`running`?R=t?`正在回复`:`Responding`:w.length?R=t?`有 ${w.length} 项等待开始`:`${w.length} queued`:i?.status===`waiting`?R=t?`等待继续`:`Waiting to resume`:I?R=t?`刚刚完成交付`:`Just delivered`:(c||d)&&(R=t?`暂时无法更新状态`:`Status unavailable`);let z;return n[17]!==y||n[18]!==L||n[19]!==l||n[20]!==u||n[21]!==o||n[22]!==R||n[23]!==a||n[24]!==c?(z={work:a,workError:c,prompt:l,avatarState:L,summary:R,attentionCount:y,refreshWork:o,refreshPrompt:u},n[17]=y,n[18]=L,n[19]=l,n[20]=u,n[21]=o,n[22]=R,n[23]=a,n[24]=c,n[25]=z):z=n[25],z}function N(e){return e.resolution===`done`}function P(e){return e.operationalState===`queued`||e.operationalState===`allocating`}function F(e){return e.operationalState===`running`||e.operationalState===`verifying`}export{y as a,d as c,O as i,E as n,M as o,j as r,D as s,A as t};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260910-1" />
|
|
12
12
|
<link rel="manifest" href="/site.webmanifest?v=20260910-1" />
|
|
13
13
|
<title>XOPC — Keep what matters moving.</title>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-790PGhZb.js"></script>
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/marked.esm-8VXEA2AD.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
<link rel="modulepreload" crossorigin href="/assets/use-composer-attachments-DJsIzJ1c.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="/assets/skill-api-utils-C7V4JVXM.js">
|
|
214
214
|
<link rel="modulepreload" crossorigin href="/assets/skill-list-api-B26hHnXq.js">
|
|
215
|
-
<link rel="modulepreload" crossorigin href="/assets/command-palette-api-
|
|
215
|
+
<link rel="modulepreload" crossorigin href="/assets/command-palette-api-UrqPvWR1.js">
|
|
216
216
|
<link rel="modulepreload" crossorigin href="/assets/automation-display-DaVDNZz8.js">
|
|
217
217
|
<link rel="modulepreload" crossorigin href="/assets/message-circle-Badhj-4D.js">
|
|
218
218
|
<link rel="modulepreload" crossorigin href="/assets/calendar-days-hw_Y-g-s.js">
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
<link rel="modulepreload" crossorigin href="/assets/page-context-draft-Bk7jVvAG.js">
|
|
232
232
|
<link rel="modulepreload" crossorigin href="/assets/management-api-FVu7eYXD.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="/assets/side-chat-shortcut-BIw-1TTD.js">
|
|
234
|
-
<link rel="modulepreload" crossorigin href="/assets/chat-page-
|
|
234
|
+
<link rel="modulepreload" crossorigin href="/assets/chat-page-3fVhP77N.js">
|
|
235
235
|
<link rel="modulepreload" crossorigin href="/assets/arrow-right-DSSvoX71.js">
|
|
236
236
|
<link rel="modulepreload" crossorigin href="/assets/map-pin-BFRLhzQ9.js">
|
|
237
237
|
<link rel="modulepreload" crossorigin href="/assets/bell-BlYch9Vg.js">
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
<link rel="modulepreload" crossorigin href="/assets/panel-right-CFGrHTsD.js">
|
|
292
292
|
<link rel="modulepreload" crossorigin href="/assets/panels-top-left-BKvp2Dag.js">
|
|
293
293
|
<link rel="modulepreload" crossorigin href="/assets/wand-sparkles-CkSL-3Fy.js">
|
|
294
|
-
<link rel="modulepreload" crossorigin href="/assets/use-personal-work-
|
|
294
|
+
<link rel="modulepreload" crossorigin href="/assets/use-personal-work-B1DWeBnm.js">
|
|
295
295
|
<link rel="modulepreload" crossorigin href="/assets/plug-DKYPEgkR.js">
|
|
296
296
|
<link rel="modulepreload" crossorigin href="/assets/power-ZI-pBczI.js">
|
|
297
297
|
<link rel="modulepreload" crossorigin href="/assets/puzzle-BptcPjKI.js">
|
|
@@ -313,7 +313,7 @@
|
|
|
313
313
|
<link rel="modulepreload" crossorigin href="/assets/preference-select-fields-B-yK91If.js">
|
|
314
314
|
<link rel="modulepreload" crossorigin href="/assets/navigation-ByOzYT0t.js">
|
|
315
315
|
<link rel="modulepreload" crossorigin href="/assets/page-tabs-DoYMKhVO.js">
|
|
316
|
-
<link rel="modulepreload" crossorigin href="/assets/route-preload-
|
|
316
|
+
<link rel="modulepreload" crossorigin href="/assets/route-preload-DF8LOfKW.js">
|
|
317
317
|
<link rel="modulepreload" crossorigin href="/assets/use-personal-profile-D4gLM6Wi.js">
|
|
318
318
|
<link rel="modulepreload" crossorigin href="/assets/personal-avatar-1TVnHakL.js">
|
|
319
319
|
<link rel="modulepreload" crossorigin href="/assets/session-channel-icon-CJAPoVO-.js">
|
|
@@ -323,7 +323,7 @@
|
|
|
323
323
|
<link rel="modulepreload" crossorigin href="/assets/workspace-file-preview-dialog-DwVWTehC.js">
|
|
324
324
|
<link rel="modulepreload" crossorigin href="/assets/use-workspace-tree-LCIT1H-D.js">
|
|
325
325
|
<link rel="modulepreload" crossorigin href="/assets/date-formatters-DukWSVwc.js">
|
|
326
|
-
<link rel="modulepreload" crossorigin href="/assets/task-header-title-
|
|
326
|
+
<link rel="modulepreload" crossorigin href="/assets/task-header-title-qzNctGl5.js">
|
|
327
327
|
<link rel="modulepreload" crossorigin href="/assets/date-time-picker-ChG1CqR1.js">
|
|
328
328
|
<link rel="modulepreload" crossorigin href="/assets/settings-mode-store-CCQVvItG.js">
|
|
329
329
|
<link rel="modulepreload" crossorigin href="/assets/global-defaults-api-B7suATYU.js">
|
package/dist/package.js
CHANGED
|
@@ -26,7 +26,9 @@ export declare class McpConnectionDrafts {
|
|
|
26
26
|
conflict?: boolean;
|
|
27
27
|
}>;
|
|
28
28
|
});
|
|
29
|
-
create(owner: string, input: McpDraftInput,
|
|
29
|
+
create(owner: string, input: McpDraftInput, options?: {
|
|
30
|
+
protectCredentials?: boolean;
|
|
31
|
+
}): Promise<{
|
|
30
32
|
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
31
33
|
serverId: string;
|
|
32
34
|
expiresAt: number;
|
|
@@ -33,7 +33,7 @@ var McpConnectionDrafts = class {
|
|
|
33
33
|
constructor(options) {
|
|
34
34
|
this.options = options;
|
|
35
35
|
}
|
|
36
|
-
async create(owner, input,
|
|
36
|
+
async create(owner, input, options) {
|
|
37
37
|
const current = this.options.readConfig();
|
|
38
38
|
if (!/^[a-zA-Z0-9_-]+$/.test(input.serverId) || input.sourceServerId && input.sourceServerId !== input.serverId) throw new McpDraftError(400, "Invalid or changed MCP server ID.");
|
|
39
39
|
const source = Object.hasOwn(current.mcp?.servers ?? {}, input.serverId) ? current.mcp?.servers?.[input.serverId] : void 0;
|
|
@@ -54,8 +54,7 @@ var McpConnectionDrafts = class {
|
|
|
54
54
|
const config = structuredClone(current);
|
|
55
55
|
config.mcp = { servers: { [input.serverId]: {
|
|
56
56
|
...server,
|
|
57
|
-
enabled: true
|
|
58
|
-
...bearerToken ? { headers: { Authorization: `Bearer ${bearerToken}` } } : {}
|
|
57
|
+
enabled: true
|
|
59
58
|
} } };
|
|
60
59
|
const credentials = await createNativeMcpCredentials(true);
|
|
61
60
|
if (this.drafts.size >= 100 || [...this.drafts.values()].filter((draft) => draft.owner === owner).length >= 8) throw new McpDraftError(429, "Too many unsaved MCP connection tests.");
|
|
@@ -75,7 +74,7 @@ var McpConnectionDrafts = class {
|
|
|
75
74
|
server,
|
|
76
75
|
config,
|
|
77
76
|
credentials,
|
|
78
|
-
|
|
77
|
+
protectCredentials: options?.protectCredentials === true,
|
|
79
78
|
controller: new AbortController(),
|
|
80
79
|
timer,
|
|
81
80
|
expiresAt: Date.now() + TTL_MS,
|
|
@@ -189,16 +188,30 @@ var McpConnectionDrafts = class {
|
|
|
189
188
|
draft.committing = true;
|
|
190
189
|
let alias;
|
|
191
190
|
let durable;
|
|
192
|
-
|
|
191
|
+
const protectedProviders = [];
|
|
192
|
+
const resolver = draft.protectCredentials ? new CredentialResolver() : void 0;
|
|
193
193
|
let published = false;
|
|
194
194
|
try {
|
|
195
195
|
const server = structuredClone(draft.server);
|
|
196
196
|
if (enable) server.enabled = true;
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
if (resolver) {
|
|
198
|
+
const protect = async (field, value, prefix) => {
|
|
199
|
+
const reference = createConnectorSecretReference(`mcp-draft-${id}`, field, { prefix });
|
|
200
|
+
const provider = reference.xopcSecretRef.provider;
|
|
201
|
+
protectedProviders.push(provider);
|
|
202
|
+
await resolver.saveApiKey(provider, value.slice(prefix?.length ?? 0));
|
|
203
|
+
return reference;
|
|
204
|
+
};
|
|
205
|
+
for (const [index, [name, value]] of Object.entries(server.headers ?? {}).entries()) {
|
|
206
|
+
if (typeof value !== "string") continue;
|
|
207
|
+
const prefix = name.toLowerCase() === "authorization" ? /^Bearer /i.exec(value)?.[0] : void 0;
|
|
208
|
+
server.headers[name] = await protect(`header-${index}`, value, prefix);
|
|
209
|
+
}
|
|
210
|
+
for (const [index, [name, value]] of Object.entries(server.env ?? {}).entries()) {
|
|
211
|
+
if (typeof value !== "string" || value === "") continue;
|
|
212
|
+
server.env[name] = await protect(`env-${index}`, value);
|
|
213
|
+
}
|
|
214
|
+
if (typeof server.oauth?.clientSecret === "string") server.oauth.clientSecret = await protect("oauth-client-secret", server.oauth.clientSecret);
|
|
202
215
|
}
|
|
203
216
|
if (typeof server.url === "string") {
|
|
204
217
|
const state = await draft.credentials.forServer(draft.serverId, server.url).load();
|
|
@@ -252,7 +265,7 @@ var McpConnectionDrafts = class {
|
|
|
252
265
|
draft.committing = false;
|
|
253
266
|
if (alias && this.options.readConfig().mcp?.servers?.[draft.serverId]?.xopcOAuthCredentialId === alias) published = true;
|
|
254
267
|
if (!published && alias && durable && typeof draft.server.url === "string") durable.remove(alias, draft.server.url);
|
|
255
|
-
if (!published &&
|
|
268
|
+
if (!published && resolver) await Promise.allSettled(protectedProviders.map((provider) => resolver.deleteProfile(`${provider}:default`)));
|
|
256
269
|
if (this.drafts.has(id) && draft.expiresAt <= Date.now()) this.dispose(draft);
|
|
257
270
|
}
|
|
258
271
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
-
import { checkUrlSafety } from "../tools/url-safety.js";
|
|
4
3
|
import { isManagedConnectorServer } from "../../connectors/materialize.js";
|
|
5
4
|
import { resolveMcpSetupConfig } from "./effective-server.js";
|
|
6
5
|
import { classifyMcpConnectionError } from "./connection-errors.js";
|
|
7
6
|
import { prepareNativeMcpConfig } from "./native-mcp.js";
|
|
8
7
|
import { McpAuthenticationRequiredError, discoverMcpTools, signInNativeMcp } from "./tool-catalog.js";
|
|
8
|
+
import { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget } from "./network-policy.js";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { lookup } from "node:dns";
|
|
11
11
|
import { Agent } from "undici";
|
|
@@ -17,9 +17,10 @@ function httpUrl(value) {
|
|
|
17
17
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new Error("Use an HTTP or HTTPS MCP address without embedded credentials.");
|
|
18
18
|
return url;
|
|
19
19
|
}
|
|
20
|
-
async function metadata(url, endpoint, signal, publicOnly = false) {
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
async function metadata(url, endpoint, signal, publicOnly = false, privateNetwork = false) {
|
|
21
|
+
const local = endpoint.origin === url.origin && !publicOnly;
|
|
22
|
+
const privateOrigin = local && privateNetwork;
|
|
23
|
+
if (privateOrigin ? !isPrivateMcpTarget(url) : !local && !isPublicMcpTarget(url)) return { state: "invalid" };
|
|
23
24
|
const { retryAfter } = await import("./transport.js");
|
|
24
25
|
signal?.throwIfAborted();
|
|
25
26
|
const dispatcher = new Agent({ connect: { lookup(host, options, callback) {
|
|
@@ -28,8 +29,9 @@ async function metadata(url, endpoint, signal, publicOnly = false) {
|
|
|
28
29
|
callback(error, "", 4);
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const allowed = privateOrigin ? isPrivateMcpIp : isPublicMcpIp;
|
|
33
|
+
if ((!local || privateOrigin) && addresses.some((address) => !allowed(address.address))) {
|
|
34
|
+
callback(/* @__PURE__ */ new Error("Authorization metadata resolved outside its approved network"), "", 4);
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
if (options.all) callback(null, addresses);
|
|
@@ -90,15 +92,16 @@ async function authentication(config, workspace, serverId, failure, options) {
|
|
|
90
92
|
options?.signal?.throwIfAborted();
|
|
91
93
|
const url = httpUrl(entry.config.url);
|
|
92
94
|
const publicOnly = config.mcp?.servers?.[serverId]?.xopcPublicOnly === true;
|
|
95
|
+
const privateNetwork = config.mcp?.servers?.[serverId]?.xopcPrivateNetwork === true;
|
|
93
96
|
const allowedIssuer = (value) => {
|
|
94
97
|
try {
|
|
95
98
|
if (typeof value !== "string") return false;
|
|
96
99
|
const issuer = httpUrl(value);
|
|
97
|
-
return !issuer.hash && (issuer.protocol === "https:" &&
|
|
100
|
+
return !issuer.hash && (issuer.protocol === "https:" && isPublicMcpTarget(issuer) || !publicOnly && issuer.origin === url.origin && (privateNetwork ? issuer.protocol === "https:" && isPrivateMcpTarget(issuer) : [
|
|
98
101
|
"localhost",
|
|
99
102
|
"127.0.0.1",
|
|
100
103
|
"[::1]"
|
|
101
|
-
].includes(issuer.hostname));
|
|
104
|
+
].includes(issuer.hostname)));
|
|
102
105
|
} catch {
|
|
103
106
|
return false;
|
|
104
107
|
}
|
|
@@ -119,11 +122,11 @@ async function authentication(config, workspace, serverId, failure, options) {
|
|
|
119
122
|
method: "GET",
|
|
120
123
|
stage: "authorization_metadata"
|
|
121
124
|
});
|
|
122
|
-
return metadata(target, url, options?.signal, publicOnly);
|
|
125
|
+
return metadata(target, url, options?.signal, publicOnly, privateNetwork);
|
|
123
126
|
};
|
|
124
127
|
let issuer;
|
|
125
128
|
for (const candidate of new Map(candidates.map((c) => [c.href, c])).values()) {
|
|
126
|
-
if (!allowedIssuer(candidate.href)) {
|
|
129
|
+
if (!(privateNetwork && candidate.origin === url.origin && !candidate.username && !candidate.password && !candidate.hash && isPrivateMcpTarget(candidate)) && !allowedIssuer(candidate.href)) {
|
|
127
130
|
state = "invalid";
|
|
128
131
|
continue;
|
|
129
132
|
}
|
|
@@ -69,6 +69,7 @@ async function prepareNativeMcpConfig(config, workspaceDir, agentId) {
|
|
|
69
69
|
"toolExposure",
|
|
70
70
|
"description",
|
|
71
71
|
"xopcPublicOnly",
|
|
72
|
+
"xopcPrivateNetwork",
|
|
72
73
|
"xopcManagedStdio"
|
|
73
74
|
].filter((key) => value[key] !== void 0).map((key) => [key, value[key]]));
|
|
74
75
|
if (typeof value.displayName === "string" && value.displayName.trim()) projected.description = `Service: ${value.displayName.trim()}. ${typeof value.description === "string" ? value.description : ""}`.trim();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function mcpHostname(hostname: string): string;
|
|
2
|
+
export declare function isPrivateMcpIp(value: string): boolean;
|
|
3
|
+
export declare function suggestsPrivateMcpHostname(value: string): boolean;
|
|
4
|
+
export declare function isPrivateMcpTarget(url: URL): boolean;
|
|
5
|
+
export declare function isPublicMcpTarget(url: URL): boolean;
|
|
6
|
+
export declare function isPublicMcpIp(address: string): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { checkUrlSafety } from "../tools/url-safety.js";
|
|
2
|
+
import { BlockList, isIP } from "node:net";
|
|
3
|
+
//#region src/agent/mcp/network-policy.ts
|
|
4
|
+
const privateIps = new BlockList();
|
|
5
|
+
for (const [prefix, bits] of [
|
|
6
|
+
["10.0.0.0", 8],
|
|
7
|
+
["127.0.0.0", 8],
|
|
8
|
+
["172.16.0.0", 12],
|
|
9
|
+
["192.168.0.0", 16],
|
|
10
|
+
["100.64.0.0", 10]
|
|
11
|
+
]) privateIps.addSubnet(prefix, bits);
|
|
12
|
+
privateIps.addAddress("::1", "ipv6");
|
|
13
|
+
privateIps.addSubnet("fc00::", 7, "ipv6");
|
|
14
|
+
const blockedIpv6 = new BlockList();
|
|
15
|
+
blockedIpv6.addSubnet("::ffff:0:0", 96, "ipv6");
|
|
16
|
+
blockedIpv6.addAddress("::", "ipv6");
|
|
17
|
+
blockedIpv6.addSubnet("fe80::", 10, "ipv6");
|
|
18
|
+
blockedIpv6.addSubnet("ff00::", 8, "ipv6");
|
|
19
|
+
function mcpHostname(hostname) {
|
|
20
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
21
|
+
}
|
|
22
|
+
function isPrivateMcpIp(value) {
|
|
23
|
+
const host = mcpHostname(value);
|
|
24
|
+
const family = isIP(host);
|
|
25
|
+
const type = family === 6 ? "ipv6" : "ipv4";
|
|
26
|
+
return family !== 0 && host !== "100.100.100.200" && (family !== 6 || !blockedIpv6.check(host, "ipv6")) && privateIps.check(host, type);
|
|
27
|
+
}
|
|
28
|
+
function suggestsPrivateMcpHostname(value) {
|
|
29
|
+
const host = mcpHostname(value);
|
|
30
|
+
return isPrivateMcpIp(host) || isIP(host) === 0 && (!host.includes(".") || /\.(?:localhost|local|lan|internal|home\.arpa)$/.test(host));
|
|
31
|
+
}
|
|
32
|
+
function isPrivateMcpTarget(url) {
|
|
33
|
+
const host = mcpHostname(url.hostname);
|
|
34
|
+
if (host === "metadata.google.internal" || host === "metadata.goog") return false;
|
|
35
|
+
return isIP(host) ? isPrivateMcpIp(host) : Boolean(host);
|
|
36
|
+
}
|
|
37
|
+
function isPublicMcpTarget(url) {
|
|
38
|
+
const host = mcpHostname(url.hostname);
|
|
39
|
+
const family = isIP(host);
|
|
40
|
+
if (suggestsPrivateMcpHostname(host) || family === 6 && blockedIpv6.check(host, "ipv6")) return false;
|
|
41
|
+
const normalized = new URL(url);
|
|
42
|
+
if (host !== url.hostname && isIP(host) !== 6) normalized.hostname = host;
|
|
43
|
+
return checkUrlSafety(normalized.href).safe;
|
|
44
|
+
}
|
|
45
|
+
function isPublicMcpIp(address) {
|
|
46
|
+
return isPublicMcpTarget(new URL(`http://${isIP(address) === 6 ? `[${address}]` : address}`));
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget, mcpHostname, suggestsPrivateMcpHostname };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPrivateMcpIp, isPrivateMcpTarget, isPublicMcpIp, isPublicMcpTarget, mcpHostname } from "./network-policy.js";
|
|
2
2
|
import { mcpStdioSupervisor } from "../../process/mcp-stdio-supervisor.js";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { lookup } from "node:dns";
|
|
@@ -73,14 +73,18 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
73
73
|
}
|
|
74
74
|
const url = new URL(String(config.url));
|
|
75
75
|
const headers = config.headers;
|
|
76
|
-
const
|
|
76
|
+
const privateNetwork = config.xopcPrivateNetwork === true;
|
|
77
|
+
const publicOnly = config.xopcPublicOnly === true;
|
|
78
|
+
const makeDispatcher = (policy) => new Agent({ connect: { lookup(host, options, callback) {
|
|
77
79
|
lookup(host, { all: true }, (error, addresses) => {
|
|
78
80
|
if (error) {
|
|
79
81
|
callback(error, "", 4);
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
const local = policy === "legacy" && mcpHostname(host) === mcpHostname(url.hostname);
|
|
85
|
+
const allowed = policy === "private" ? isPrivateMcpIp : isPublicMcpIp;
|
|
86
|
+
if (!local && addresses.some((address) => !allowed(address.address))) {
|
|
87
|
+
callback(/* @__PURE__ */ new Error("MCP destination resolved outside its approved network"), "", 4);
|
|
84
88
|
return;
|
|
85
89
|
}
|
|
86
90
|
if (options.all) callback(null, addresses);
|
|
@@ -88,6 +92,8 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
88
92
|
else callback(/* @__PURE__ */ new Error("MCP destination has no address"), "", 4);
|
|
89
93
|
});
|
|
90
94
|
} } });
|
|
95
|
+
const dispatcher = makeDispatcher(privateNetwork ? "private" : publicOnly ? "public" : "legacy");
|
|
96
|
+
const externalDispatcher = privateNetwork ? makeDispatcher("public") : void 0;
|
|
91
97
|
const fetcher = async (input, init) => {
|
|
92
98
|
const method = init?.method ?? "GET";
|
|
93
99
|
let stage = method === "GET" ? "stream" : "request";
|
|
@@ -99,11 +105,12 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
99
105
|
stage
|
|
100
106
|
});
|
|
101
107
|
const target = new URL(input);
|
|
102
|
-
|
|
108
|
+
const sameOrigin = target.origin === url.origin;
|
|
109
|
+
if (!(privateNetwork && sameOrigin ? isPrivateMcpTarget(target) : !sameOrigin || publicOnly ? isPublicMcpTarget(target) && (!privateNetwork || target.protocol === "https:") : true)) throw new Error("MCP network policy refused this destination");
|
|
103
110
|
const response = await fetch(input, {
|
|
104
111
|
...init,
|
|
105
112
|
redirect: "error",
|
|
106
|
-
dispatcher
|
|
113
|
+
dispatcher: sameOrigin ? dispatcher : externalDispatcher ?? dispatcher
|
|
107
114
|
});
|
|
108
115
|
const media = (response.headers.get("content-type") ?? "").split(";")[0].toLowerCase();
|
|
109
116
|
diagnostics.observe?.({
|
|
@@ -135,7 +142,7 @@ function createXopcMcpTransport(diagnostics = {}, assertPluginCallAccess) {
|
|
|
135
142
|
try {
|
|
136
143
|
await close();
|
|
137
144
|
} finally {
|
|
138
|
-
await dispatcher.close();
|
|
145
|
+
await Promise.all([dispatcher.close(), externalDispatcher?.close()]);
|
|
139
146
|
}
|
|
140
147
|
};
|
|
141
148
|
return guard(transport);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
2
2
|
//#region src/agent/messaging/message-router.ts
|
|
3
3
|
var MessageRouter = class {
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ var MessageRouter = class {
|
|
|
13
13
|
senderId: msg.metadata?.senderId || msg.sender_id,
|
|
14
14
|
isGroup: msg.metadata?.isGroup || false
|
|
15
15
|
};
|
|
16
|
-
const commandInfo =
|
|
16
|
+
const commandInfo = commandRegistry.parseRegisteredSlashCommand(msg.content);
|
|
17
17
|
return {
|
|
18
18
|
context,
|
|
19
19
|
isCommand: commandInfo !== null,
|
|
@@ -8,10 +8,8 @@ import { phoneResumeForRun } from "../../phone/assistance.js";
|
|
|
8
8
|
import { buildDelegatedTaskDirective, buildTaskExecutionDirective } from "../../tasks/task-context-assembler.js";
|
|
9
9
|
import { getMcpSetupResumeInput } from "../mcp/continuation-input.js";
|
|
10
10
|
import { shouldSkipResetOverlapCommand } from "../../session/reset-triggers.js";
|
|
11
|
-
import { parseSlashCommand } from "../../chat-commands/command-parse.js";
|
|
12
11
|
import { personalCommandRejection } from "../../chat-commands/personal-command-policy.js";
|
|
13
12
|
import { commandRegistry } from "../../chat-commands/registry.js";
|
|
14
|
-
import "../../chat-commands/index.js";
|
|
15
13
|
import { getTaskContinuation } from "../../tasks/task-continuation.js";
|
|
16
14
|
import { runEmbeddedTurnForSession } from "../embedded/run-for-session.js";
|
|
17
15
|
import crypto from "node:crypto";
|
|
@@ -42,18 +40,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
42
40
|
aggregatedText: ""
|
|
43
41
|
};
|
|
44
42
|
const personal = isPersonalConversation(ctx.conversationId);
|
|
45
|
-
const parsed =
|
|
43
|
+
const parsed = commandRegistry.parseRegisteredSlashCommand(personal ? content.trim().split(/\r?\n/, 1)[0] : content);
|
|
46
44
|
if (!parsed) return {
|
|
47
45
|
matched: false,
|
|
48
46
|
aggregatedText: ""
|
|
49
47
|
};
|
|
50
48
|
if (personal) {
|
|
51
|
-
const
|
|
52
|
-
if (!command && !parsed.command.startsWith("skill:")) return {
|
|
53
|
-
matched: false,
|
|
54
|
-
aggregatedText: ""
|
|
55
|
-
};
|
|
56
|
-
const rejection = personalCommandRejection(ctx.conversationId, command?.id ?? "skill.invoke", parsed.command);
|
|
49
|
+
const rejection = personalCommandRejection(ctx.conversationId, parsed.definition.id, parsed.command);
|
|
57
50
|
if (rejection) return {
|
|
58
51
|
matched: true,
|
|
59
52
|
aggregatedText: rejection,
|
|
@@ -64,25 +57,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
64
57
|
matched: false,
|
|
65
58
|
aggregatedText: ""
|
|
66
59
|
};
|
|
67
|
-
if (!
|
|
68
|
-
if (parsed.command.startsWith("skill:")) return {
|
|
69
|
-
matched: false,
|
|
70
|
-
aggregatedText: ""
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
matched: true,
|
|
74
|
-
aggregatedText: `Unknown command: /${parsed.command}\nType /help to see available commands.`,
|
|
75
|
-
command: parsed.command
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
const command = commandRegistry.findByName(parsed.command);
|
|
79
|
-
if (options?.sourceContexts?.length && !command?.acceptsContext) return {
|
|
60
|
+
if (options?.sourceContexts?.length && !parsed.definition.acceptsContext) return {
|
|
80
61
|
matched: true,
|
|
81
62
|
aggregatedText: `Command /${parsed.command} does not accept Note context. Remove the Note reference or use it with a regular prompt.`,
|
|
82
63
|
command: parsed.command
|
|
83
64
|
};
|
|
84
65
|
try {
|
|
85
|
-
const { aggregatedText, metadata } = await deps.commandHandler.executeCommandAndAggregateReply(parsed.command, parsed.args, {
|
|
66
|
+
const { handled, aggregatedText, metadata } = await deps.commandHandler.executeCommandAndAggregateReply(parsed.command, parsed.args, {
|
|
86
67
|
conversationId: ctx.conversationId,
|
|
87
68
|
channel: ctx.channel,
|
|
88
69
|
chatId: ctx.chatId,
|
|
@@ -91,9 +72,13 @@ async function tryRunSlashCommand(deps, ctx, content, options) {
|
|
|
91
72
|
inboundMetadata: ctx.inboundMetadata ?? {},
|
|
92
73
|
sourceContexts: options?.sourceContexts
|
|
93
74
|
}, { emitEvent: options?.emitEvent });
|
|
75
|
+
if (!handled) return {
|
|
76
|
+
matched: false,
|
|
77
|
+
aggregatedText: ""
|
|
78
|
+
};
|
|
94
79
|
return {
|
|
95
80
|
matched: true,
|
|
96
|
-
aggregatedText
|
|
81
|
+
aggregatedText,
|
|
97
82
|
command: parsed.command,
|
|
98
83
|
metadata
|
|
99
84
|
};
|
|
@@ -7,6 +7,7 @@ export declare function normalizeTelegramCommandName(command: string): string;
|
|
|
7
7
|
* Parse a `/command` from message text. Handles:
|
|
8
8
|
* - `/cmd@BotName` and arguments
|
|
9
9
|
* - Multiline: voice STT text before a line that starts with `/` (Telegram caption after transcript)
|
|
10
|
+
* A leading path or bare slash leaves the message as ordinary input.
|
|
10
11
|
*/
|
|
11
12
|
export declare function parseSlashCommand(text: string): {
|
|
12
13
|
command: string;
|
|
@@ -11,6 +11,7 @@ function normalizeTelegramCommandName(command) {
|
|
|
11
11
|
* Parse a `/command` from message text. Handles:
|
|
12
12
|
* - `/cmd@BotName` and arguments
|
|
13
13
|
* - Multiline: voice STT text before a line that starts with `/` (Telegram caption after transcript)
|
|
14
|
+
* A leading path or bare slash leaves the message as ordinary input.
|
|
14
15
|
*/
|
|
15
16
|
function parseSlashCommand(text) {
|
|
16
17
|
const trimmed = text.trim();
|
|
@@ -18,16 +19,13 @@ function parseSlashCommand(text) {
|
|
|
18
19
|
for (const part of trimmed.split(/\r?\n/)) {
|
|
19
20
|
const line = part.trim();
|
|
20
21
|
if (!line.startsWith("/")) continue;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
command: normalizeTelegramCommandName(withoutPrefix.slice(0, whitespaceIndex)),
|
|
29
|
-
args: withoutPrefix.slice(whitespaceIndex + 1).trim()
|
|
30
|
-
};
|
|
22
|
+
const match = /^\/([^/\s]+)(?:\s+([\s\S]*))?$/.exec(line);
|
|
23
|
+
if (!match) return null;
|
|
24
|
+
const command = normalizeTelegramCommandName(match[1]);
|
|
25
|
+
return command ? {
|
|
26
|
+
command,
|
|
27
|
+
args: match[2]?.trim() ?? ""
|
|
28
|
+
} : null;
|
|
31
29
|
}
|
|
32
30
|
return null;
|
|
33
31
|
}
|
|
@@ -30,6 +30,11 @@ export declare class CommandRegistry {
|
|
|
30
30
|
* Check if a command exists (by name or alias)
|
|
31
31
|
*/
|
|
32
32
|
has(name: string): boolean;
|
|
33
|
+
parseRegisteredSlashCommand(text: string): {
|
|
34
|
+
command: string;
|
|
35
|
+
args: string;
|
|
36
|
+
definition: CommandDefinition;
|
|
37
|
+
} | null;
|
|
33
38
|
/**
|
|
34
39
|
* Get all registered commands
|
|
35
40
|
*/
|
|
@@ -71,6 +71,14 @@ var CommandRegistry = class CommandRegistry {
|
|
|
71
71
|
has(name) {
|
|
72
72
|
return !!this.findByName(name);
|
|
73
73
|
}
|
|
74
|
+
parseRegisteredSlashCommand(text) {
|
|
75
|
+
const parsed = parseSlashCommand(text);
|
|
76
|
+
const definition = parsed && this.findByName(parsed.command);
|
|
77
|
+
return parsed && definition ? {
|
|
78
|
+
...parsed,
|
|
79
|
+
definition
|
|
80
|
+
} : null;
|
|
81
|
+
}
|
|
74
82
|
/**
|
|
75
83
|
* Get all registered commands
|
|
76
84
|
*/
|