@kanyun-ai-infra/band-cli 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/examples/aitutor-tool/band/views/release/package.json +1 -1
- package/bundled/examples/aitutor-tool/band/views/tool-preview/package.json +1 -1
- package/bundled/examples/analysis/band/views/intake/package.json +1 -1
- package/bundled/examples/compliance/band/views/compliance/package.json +1 -1
- package/bundled/examples/content-review/band/views/checklist/package.json +1 -1
- package/bundled/examples/rush-site/band/views/rush-db/package.json +1 -1
- package/bundled/examples/rush-site/band/views/rush-deploy/package.json +1 -1
- package/bundled/examples/video/band/views/timeline/package.json +1 -1
- package/bundled/kernel/fixture.js +1 -1
- package/bundled/kernel/index.js +1 -1
- package/bundled/official/activity/package.json +4 -4
- package/bundled/official/approval/package.json +4 -4
- package/bundled/official/artifacts/package.json +4 -4
- package/bundled/official/chat/dist/index.js +1 -1
- package/bundled/official/chat/package.json +4 -4
- package/bundled/official/chunks/chunk-7XYETT7C.js +1 -0
- package/bundled/official/comment/dist/index.js +1 -1
- package/bundled/official/comment/package.json +4 -4
- package/bundled/official/header/package.json +4 -4
- package/bundled/official/home/dist/index.js +1 -1
- package/bundled/official/home/package.json +4 -4
- package/bundled/official/layouts/package.json +4 -4
- package/bundled/official/library/dist/index.js +1 -1
- package/bundled/official/library/package.json +4 -4
- package/bundled/official/members/dist/index.js +1 -1
- package/bundled/official/members/package.json +4 -4
- package/bundled/official/memory/package.json +4 -4
- package/bundled/official/native/package.json +2 -2
- package/bundled/official/params-form/package.json +4 -4
- package/bundled/official/plugins/package.json +4 -4
- package/bundled/official/project/dist/index.js +1 -1
- package/bundled/official/project/package.json +4 -4
- package/bundled/official/queue/package.json +4 -4
- package/bundled/official/settings/dist/index.js +1 -1
- package/bundled/official/settings/package.json +4 -4
- package/bundled/official/shell/dist/index.js +1 -1
- package/bundled/official/shell/package.json +4 -4
- package/bundled/official/stages/package.json +4 -4
- package/bundled/official/threads/dist/index.js +1 -1
- package/bundled/official/threads/package.json +4 -4
- package/bundled/official/turn-bar/package.json +4 -4
- package/bundled/official/turn-trace/package.json +4 -4
- package/bundled/official/version-switch/dist/index.js +1 -1
- package/bundled/official/version-switch/package.json +4 -4
- package/bundled/official/viewer-entity/package.json +2 -2
- package/bundled/official/viewer-external/package.json +2 -2
- package/bundled/official/viewer-image/package.json +2 -2
- package/bundled/official/viewer-media/package.json +2 -2
- package/bundled/official/viewer-storyboard/package.json +2 -2
- package/bundled/official/viewer-text/package.json +4 -4
- package/bundled/official/viewer-tool/package.json +2 -2
- package/bundled/official/viewer-web/package.json +2 -2
- package/bundled/official/viewer-web-app/package.json +2 -2
- package/bundled/official/workshops/dist/index.js +2 -2
- package/bundled/official/workshops/package.json +4 -4
- package/bundled/official/workshops/plugin.yaml +2 -2
- package/bundled/skills/band-plugin/references/code.md +2 -2
- package/bundled/skills/band-plugin/references/manifest.md +2 -2
- package/bundled/skills/band-plugin/references/rules.md +1 -0
- package/bundled/skills/band-plugin/references/testing-publish.md +1 -1
- package/bundled/skills/band-plugin/templates/panel/package.json +1 -1
- package/bundled/tokens/components.css +1 -1
- package/dev-host/app.tsx +32 -12
- package/dev-host/host.css +7 -0
- package/dist/bin.js +3 -3
- package/dist/build-plugin.d.ts +1 -1
- package/dist/build-plugin.js +1 -1
- package/dist/{chunk-VTAJX7NN.js → chunk-FGPWXAOA.js} +165 -26
- package/dist/{chunk-TQHHHXXU.js → chunk-LGYGWMSY.js} +18 -16
- package/dist/{chunk-JWZU3NOD.js → chunk-XPLYTHNX.js} +1 -1
- package/dist/{dev-server-SB5FMSVP.js → dev-server-IBR3PKDE.js} +33 -5
- package/dist/fixture.d.ts +11 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -3
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/{workshop-repo-Uq6blxyt.d.ts → workshop-repo-DqoVdcGu.d.ts} +9 -9
- package/package.json +10 -7
- package/src/dev-managers.ts +16 -0
- package/src/inspector-default.ts +9 -0
- package/bundled/official/chunks/chunk-SB74RUTN.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanyun-ai-infra/band-artifacts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "产物列表:列出项目的产物,点一个在中间打开,意见栏跟着筛选",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@kanyun-ai-infra/band-plugin-sdk": "^1.
|
|
11
|
-
"react": "^
|
|
12
|
-
"react-dom": "^
|
|
10
|
+
"@kanyun-ai-infra/band-plugin-sdk": "^2.1.0",
|
|
11
|
+
"react": "^19.0.0",
|
|
12
|
+
"react-dom": "^19.0.0",
|
|
13
13
|
"@kanyun-ai-infra/band-project": "*"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunks/chunk-JFPQMFKF.js";import{AgentAvatar,Avatar,ErrorNote,InfoNote,MemoryNote,Message,PaneHeader,STATUS_CHIP,StatusMessage,THREAD_EVENTS,TurnStopped,VersionReference,agentLabel,anchorQuote,isThreadTail,memberName,memberOrder,queueSlot,queuedMessages,quoteFace,reactMount,readComments,receiptFileNames,receiptFooter,shortTime,statusText,threadConfirmation,turnStoppedOf,useCtxData,useHandToAgent,useMembers,useMessageList,useReactionPatches,useSelectedArtifact,useVersionReferences,versionReferenceLabel,versionReferenceText,wasStopped}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useCallback,useEffect,useRef}from"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/chat.css */\n.band-chat {\n min-width: 0;\n display: flex;\n flex-direction: column;\n min-height: 0;\n flex: 1;\n}\n.band-chat-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-chat-list {\n min-width: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 16px 4px 16px;\n display: grid;\n gap: 16px;\n align-content: start;\n flex: 1;\n min-height: 0;\n}\n.band-chat-empty {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-chat-msg {\n min-width: 0;\n display: grid;\n gap: 6px;\n}\n.band-chat-meta {\n font-size: var(--fs-caption);\n color: var(--muted);\n display: flex;\n gap: 4px 6px;\n align-items: center;\n flex-wrap: wrap;\n min-width: 0;\n}\n.band-chat-time {\n flex: none;\n white-space: nowrap;\n}\n.band-chat-author {\n flex: 0 0.2 auto;\n min-width: 2em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-chat-anchor.anchor-chip {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-chat-chip-btn.chip {\n border: 0;\n font: inherit;\n cursor: pointer;\n}\n.band-chat-check {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: var(--fs-meta);\n color: var(--muted);\n margin-left: auto;\n flex: none;\n cursor: pointer;\n}\n.band-chat-check-text {\n display: none;\n}\n.band-chat-check-text:where(.band-chat-msg:hover *, .band-chat-msg:focus-within *, .band-chat-check:has(:checked) *) {\n display: inline;\n}\n@media (hover: none) {\n .band-chat-check-text {\n display: inline;\n }\n}\n.band-chat-bubble {\n display: block;\n width: auto;\n max-width: 100%;\n justify-self: start;\n padding: 9px 13px;\n border: 0;\n border-radius: 14px;\n background: var(--sunk);\n color: inherit;\n text-align: left;\n font: inherit;\n font-size: var(--fs-row);\n overflow-wrap: anywhere;\n}\n:where(.band-chat-msg.mine) .band-chat-bubble {\n background: var(--fill-2);\n}\n.band-chat-bubble:where(:hover) {\n box-shadow: 0 0 0 1.5px var(--rule-strong);\n}\n.band-chat-comment {\n font-size: var(--fs-ui);\n padding: 6px 10px;\n border-radius: 8px;\n background: var(--panel);\n overflow-wrap: anywhere;\n}\n.band-chat-receipt {\n min-width: 0;\n padding: 0 2px 0 4px;\n font-size: var(--fs-row);\n display: grid;\n gap: 4px;\n}\n.band-chat-receipt-head {\n white-space: nowrap;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 6px;\n font-family: var(--mono);\n font-size: var(--fs-meta);\n color: var(--accent-text);\n}\n.band-chat-receipt-files {\n font-size: var(--fs-dense);\n color: var(--muted);\n font-family: var(--mono);\n}\n.band-chat-act {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n}\n.band-chat-receipt-foot {\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-chat-ask {\n margin: 6px 0 0;\n padding: 8px 10px;\n border-radius: var(--r);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-meta);\n}\n.band-chat-ask b {\n display: block;\n color: var(--warn);\n font-weight: 500;\n margin-bottom: 2px;\n}\n.band-chat-bulk {\n padding: 10px 14px 12px 16px;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n flex-wrap: wrap;\n}\n.band-chat-refs {\n min-width: 0;\n display: grid;\n gap: 6px;\n}\n.band-chat-quote {\n box-sizing: border-box;\n grid-template-columns: minmax(0, 1fr);\n min-width: 0;\n display: grid;\n gap: 2px;\n justify-self: start;\n max-width: 100%;\n padding: 6px 10px;\n border: 0;\n border-left: 2px solid var(--rule-strong);\n border-radius: 0 8px 8px 0;\n background: var(--fill);\n color: inherit;\n text-align: left;\n font: inherit;\n}\n.band-chat-quote:where(button) {\n cursor: pointer;\n}\n.band-chat-quote:where(button:hover) {\n border-left-color: var(--accent);\n}\n.band-chat-quote:where(:focus-visible) {\n outline: none;\n box-shadow: 0 0 0 2px var(--accent);\n}\n.band-chat-quote-label {\n min-width: 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-chat-quote-text {\n display: -webkit-box;\n overflow: hidden;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-chat"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-chat");document.head.prepend(el)}el.textContent=css}var src_default=definePlugin({surfaces:{chat:reactMount(ctx=>jsx(Chat,{ctx}))}});async function loadMessages(ctx,artifactId){const threads=artifactId?(await Promise.all([ctx.threads.list({artifactId}),ctx.threads.list({anchorKind:"project"})])).flat():await ctx.threads.list({});const sorted=[...threads].sort((a,b)=>a.mark-b.mark);const ids=sorted.map(t=>t.id);const byThread=await readComments(ctx,ids);return{messages:sorted.map(thread=>({thread,comments:byThread[thread.id]??[]}))}}function elementLabel(t){return t.anchor?anchorText(t.anchor).label:null}function anchorText(a){if(a.kind==="artifact"||a.kind==="project")return{label:null,quote:null,face:null};const label=a.payload.label;return{label:typeof label==="string"&&label?label:a.kind,quote:anchorQuote(a),face:quoteFace(a)}}function RefCard({ctx,item,threads,versions,artifactId}){const t=item.threadId?threads.get(item.threadId):void 0;const anchor=item.anchor??t?.anchor;const face=anchor?quoteFace(anchor):null;const hasText=anchor?anchorQuote(anchor)!==null:false;const aside=hasText?null:t?t.excerpt:item.anchor?null:item.text?.replace(/\s+/g," ").trim()??null;const versionId=item.versionId??item.anchor?.versionId;const label=versionId?versionReferenceText(item.label,versions,versionId,artifactId):item.label;const body=face?jsx("span",{className:"band-chat-quote-text",children:face}):jsxs(Fragment,{children:[jsx("span",{className:"band-chat-quote-label",children:jsx(VersionReference,{label})}),aside&&!label.includes(aside)&&jsx("span",{className:"band-chat-quote-text",children:aside})]});const threadId=item.threadId;return threadId?jsx("button",{type:"button",className:"band-chat-quote",onClick:()=>ctx.threads.open(threadId),"aria-label":`\u6253\u5F00\u5F15\u7528\uFF1A${label}`,children:body}):jsx("div",{className:"band-chat-quote",children:body})}function ChipTag({className,open,title,children}){return open?jsx("button",{type:"button",className:`${className} band-chat-chip-btn`,onClick:open,title,children}):jsx("span",{className,children})}function TurnProgress({ctx,turn,members,stage,queued=0}){const stopTurn=ctx.turns.requestStop;return jsx(StatusMessage,{turn,members,context:`${stage?`\u5728\u6539\u300C${stage}\u300D \xB7 `:""}\u56DE\u5408 #${turn.number}`,stop:stopTurn&&{run:()=>stopTurn(turn.changeRequestId),can:ctx.member.can("submit-change"),queued}})}var NEAR_BOTTOM_PX=48;function latestOwnCommentId(list,me){let latest;for(const m of list)for(const c of m.comments)if(c.author.id===me&&(!latest||c.createdAt>=latest.createdAt))latest=c;return latest?.id}function useFollowBottom(ref,key,count,mine){const pinned=useRef(true);const seen=useRef(null);const stick=useCallback(()=>{const el=ref.current;if(el)el.scrollTop=el.scrollHeight},[ref]);useEffect(()=>{const el=ref.current;if(!el)return;const onScroll=()=>{if(el.clientHeight===0)return;pinned.current=el.scrollHeight-el.scrollTop-el.clientHeight<=NEAR_BOTTOM_PX};el.addEventListener("scroll",onScroll,{passive:true});return()=>el.removeEventListener("scroll",onScroll)},[ref]);useEffect(()=>{const prev=seen.current;seen.current={key,mine};if(!prev||prev.key!==key||mine!==void 0&&mine!==prev.mine)pinned.current=true;if(pinned.current&&count>0)stick()},[key,count,mine,stick]);useEffect(()=>{const el=ref.current;if(!el||count===0||typeof ResizeObserver==="undefined")return;const observer=new ResizeObserver(()=>{if(pinned.current)stick()});observer.observe(el);for(const child of el.children)observer.observe(child);return()=>observer.disconnect()},[ref,count,stick])}function Chat({ctx}){const artifactId=useSelectedArtifact(ctx);const msgs=useCtxData(ctx,()=>loadMessages(ctx,artifactId),[artifactId],THREAD_EVENTS);const turn=useCtxData(ctx,()=>ctx.turns.state(),[],THREAD_EVENTS).data;const members=useMembers(ctx);const stages=useCtxData(ctx,async()=>{const[arts,stages2]=await Promise.all([ctx.artifacts.list(),ctx.stages.list()]);const names=new Map(stages2.map(x=>[x.stage,x.name??x.stage]));const key=artifactId?arts.find(a=>a.id===artifactId)?.stage:void 0;return{current:key?names.get(key):void 0,names,hasVersion:arts.some(a=>a.id===artifactId&&a.latest!==void 0)}},[artifactId],["stage.*","version.*","artifact.*"]).data;const stageName=key=>stages?.names.get(key)??key;const list=msgs.data?.messages??[];const{selected:sel,picked,anchor,toggle,send,sendOne,busy,error,notice,canSend}=useHandToAgent(ctx,list.map(m=>m.thread),agentLabel(members,ctx.project.agent));const versionRefs=useVersionReferences(ctx);const labels=versionRefs.data;const byId=new Map(list.map(m=>[m.thread.id,m.thread]));const running=turn?.current;const progressAt=running?list.findLast(m=>running.threadIds.includes(m.thread.id))?.thread.id:void 0;const stage=running?.stage?stageName(running.stage):stages?.current;const nav=useMessageList();const scroller=nav.ref;const reactionsOf=useReactionPatches(ctx,msgs.data);const count=list.reduce((n,m)=>n+1+m.comments.length,0);const me=ctx.member.id;useFollowBottom(scroller,artifactId,count,latestOwnCommentId(list,me));const dialog=ctx.services.find("@kanyun-ai-infra/band-project/artifact-dialog");const order=memberOrder(members);return jsxs("section",{className:"band-chat","aria-label":"\u5BF9\u8BDD",children:[jsx(PaneHeader,{title:"\u5BF9\u8BDD",children:jsx("span",{className:"band-chat-hint",children:"\u5BF9\u6574\u4EFD\u4EA7\u7269\u8BF4\uFF1B\u5143\u7D20\u4E0A\u7684\u610F\u89C1\u5728\u5185\u5BB9\u4E0A\u6807"})}),jsxs("div",{className:"band-chat-list",ref:scroller,"data-band-messages":"",onKeyDown:nav.onKeyDown,onFocus:nav.onFocus,children:[jsx(ErrorNote,{retry:msgs.reload,children:msgs.error}),msgs.data!==void 0&&list.length===0&&!msgs.error&&jsx("div",{className:"band-chat-empty",children:stages?.hasVersion?"\u8FD8\u6CA1\u6709\u5BF9\u8BDD\u3002\u6574\u4F53\u8981\u600E\u4E48\u6539\uFF0C\u5728\u4E0B\u9762\u8BF4\u3002":"\u8FD8\u6CA1\u6709\u5BF9\u8BDD\u3002"}),list.map(({thread:t,comments})=>{const first=comments.find(c=>c.kind==="comment");const tail=comments.filter(c=>c!==first&&(c.kind==="comment"||isThreadTail(c)));const el=elementLabel(t);const{quote,face}=t.anchor?anchorText(t.anchor):{quote:null,face:null};const refs=first?.refs??[];const working=running&&t.id===progressAt?running:null;const author=memberName(members,t.createdBy.id);const confirmation=threadConfirmation(t,ctx.member,members);return jsxs("article",{className:`band-chat-msg${t.createdBy.id===me?" mine":""}`,"aria-label":`\u6D88\u606F #${t.mark}`,"data-band-guide-keep":"hard",children:[jsxs("div",{className:"band-chat-meta",children:[jsx(Avatar,{id:t.createdBy.id,name:author,agent:t.createdBy.kind==="agent",order,decorative:true}),jsx("span",{className:"band-chat-author",children:author}),jsx("span",{className:"band-chat-time",children:shortTime(t.createdAt)}),el&&!quote&&jsx("span",{className:"anchor-chip band-chat-anchor",children:el}),t.status!=="resolved"&&!working&&jsx(ChipTag,{className:`chip ${STATUS_CHIP[t.status]}`,...t.status==="queued"?{open:()=>ctx.threads.open(t.id),title:"\u6253\u5F00\u8FD9\u6761\u6D88\u606F\uFF0C\u53EF\u64A4\u56DE"}:{},children:statusText(t.status,{...t.status==="queued"?queueSlot(turn,t.id):{},...t.agent?{agent:memberName(members,t.agent)}:{},...t.status==="open"&&wasStopped(comments)?{stopped:true}:{}})}),canSend&&t.status==="open"&&jsx("button",{type:"button",className:"btn ghost sm","data-band-guide":"hand-to-agent",disabled:busy,onClick:()=>void sendOne(t.id),children:`\u4EA4\u7ED9 ${agentLabel(members,ctx.project.agent)}`}),canSend&&t.status==="open"&&jsxs("label",{className:"band-chat-check",children:[jsx("span",{className:"band-chat-check-text",children:"\u9009\u4E2D"}),jsx("input",{className:"checkbox",type:"checkbox",checked:sel.has(t.id),onChange:()=>toggle(t.id),"aria-label":`\u9009\u4E2D #${t.mark}`})]})]}),t.id===anchor&&jsxs("div",{className:"band-chat-act",children:[jsx(ErrorNote,{children:error}),jsx(InfoNote,{children:notice}),jsx("button",{type:"button",className:"btn primary sm",disabled:busy,onClick:send,children:`${turn?.current?"\u6392\u5230\u4E0B\u4E00\u56DE\u5408":`\u4EA4\u7ED9 ${agentLabel(members,ctx.project.agent)}`}\uFF08${picked.length} \u6761\uFF09`})]}),el&"e&&jsx("button",{type:"button",className:"band-chat-quote",onClick:()=>ctx.threads.open(t.id),"aria-label":`\u5F15\u7528\u539F\u6587\uFF1A${el}`,children:face?jsx("span",{className:"band-chat-quote-text",children:face}):jsx("span",{className:"band-chat-quote-label",children:el})}),refs.length>0&&jsx("div",{className:"band-chat-refs",children:refs.map((r,i)=>jsx(RefCard,{ctx,item:r,threads:byId,versions:labels,artifactId},i))}),first?jsx(Message,{ctx,threadId:t.id,comment:first,members,reactions:reactionsOf(first),label:`${author}\u7684\u6D88\u606F`,fit:"bubble",children:jsx("button",{type:"button",className:"band-chat-bubble",onClick:()=>ctx.threads.open(t.id),children:first.body})}):jsx("button",{type:"button",className:"band-chat-bubble",onClick:()=>ctx.threads.open(t.id),children:t.excerpt}),tail.map(c=>{if(c.kind==="comment"){const who2=memberName(members,c.author.id);return jsx(Message,{ctx,threadId:t.id,comment:c,members,reactions:reactionsOf(c),label:`${who2}\u7684\u56DE\u590D`,fit:"bubble",children:jsxs("div",{className:"band-chat-comment",children:[jsx("b",{children:who2})," ",c.body]})},c.id)}const stopped=turnStoppedOf(c);if(stopped)return jsx(TurnStopped,{event:stopped,members},c.id);const who=memberName(members,c.author.id);const versionId=c.receipt?.versionId;const version=versionId?versionReferenceLabel(labels,versionId,artifactId):void 0;const owner=versionId?labels?.versions.get(versionId)?.version.artifactId:void 0;const open=dialog&&versionId&&owner?()=>dialog.open({artifactId:owner,versionId}):void 0;return jsx(Message,{ctx,threadId:t.id,comment:c,members,reactions:reactionsOf(c),label:`${who}\u7684\u56DE\u6267`,...version?{version:{label:version,...open?{open}:{}}}:{},children:jsxs("div",{className:"band-chat-receipt",children:[jsxs("span",{className:"band-chat-receipt-head",children:[jsx(AgentAvatar,{id:c.author.id,members,decorative:true}),who,version&&" \xB7 ",version&&jsx(VersionReference,{label:version,open})]}),jsx("span",{children:c.body}),c.receipt?.outcome==="needs-input"&&c.receipt.question&&jsxs("p",{className:"band-chat-ask",children:[jsxs("b",{children:[who," \u5728\u95EE\u4F60"]}),c.receipt.question]}),c.receipt&&c.receipt.files.length>0&&jsx("span",{className:"band-chat-receipt-files",children:receiptFileNames(c.receipt.files).join(" ")}),receiptFooter(c,stageName)&&jsx("span",{className:"band-chat-receipt-foot",children:receiptFooter(c,stageName)}),c.receipt&&jsx(MemoryNote,{ctx,turnId:c.receipt.turnId})]})},c.id)}),t.status==="awaiting_confirm"&&jsx("div",{children:confirmation.allowed?jsx("button",{type:"button",className:"btn primary sm",onClick:()=>ctx.threads.open(t.id),children:"\u786E\u8BA4\u662F\u5426\u89E3\u51B3"}):jsx("span",{className:"band-chat-hint",children:confirmation.hint})}),working&&jsx(TurnProgress,{ctx,turn:working,members,stage,queued:queuedMessages(turn?.queue??[])})]},t.id)})]}),!anchor&&(error||notice)&&jsxs("div",{className:"band-chat-bulk",children:[jsx(ErrorNote,{children:error}),jsx(InfoNote,{children:notice})]})]})}export{TurnProgress,anchorText,src_default as default,latestOwnCommentId,loadMessages};
|
|
1
|
+
import"../../chunks/chunk-JFPQMFKF.js";import{AgentAvatar,Avatar,ErrorNote,InfoNote,MemoryNote,Message,PaneHeader,STATUS_CHIP,StatusMessage,THREAD_EVENTS,TurnStopped,VersionReference,agentLabel,anchorQuote,isThreadTail,memberName,memberOrder,queueSlot,queuedMessages,quoteFace,reactMount,readComments,receiptFileNames,receiptFooter,shortTime,statusText,threadConfirmation,turnStoppedOf,useCtxData,useHandToAgent,useMembers,useMessageList,useReactionPatches,useSelectedArtifact,useVersionReferences,versionReferenceLabel,versionReferenceText,wasStopped}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useCallback,useEffect,useRef}from"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/chat.css */\n.band-chat {\n min-width: 0;\n display: flex;\n flex-direction: column;\n min-height: 0;\n flex: 1;\n}\n.band-chat-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-chat-list {\n min-width: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 16px 4px 16px;\n display: grid;\n gap: 16px;\n align-content: start;\n flex: 1;\n min-height: 0;\n}\n.band-chat-empty {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-chat-msg {\n min-width: 0;\n display: grid;\n gap: 6px;\n}\n.band-chat-meta {\n font-size: var(--fs-caption);\n color: var(--muted);\n display: flex;\n gap: 4px 6px;\n align-items: center;\n flex-wrap: wrap;\n min-width: 0;\n}\n.band-chat-time {\n flex: none;\n white-space: nowrap;\n}\n.band-chat-author {\n flex: 0 0.2 auto;\n min-width: 2em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-chat-anchor.anchor-chip {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-chat-chip-btn.chip {\n border: 0;\n font: inherit;\n cursor: pointer;\n}\n.band-chat-check {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n font-size: var(--fs-meta);\n color: var(--muted);\n margin-left: auto;\n flex: none;\n cursor: pointer;\n}\n.band-chat-check-text {\n display: none;\n}\n.band-chat-check-text:where(.band-chat-msg:hover *, .band-chat-msg:focus-within *, .band-chat-check:has(:checked) *) {\n display: inline;\n}\n@media (hover: none) {\n .band-chat-check-text {\n display: inline;\n }\n}\n.band-chat-bubble {\n display: block;\n width: auto;\n max-width: 100%;\n justify-self: start;\n padding: 9px 13px;\n border: 0;\n border-radius: 14px;\n background: var(--sunk);\n color: inherit;\n text-align: left;\n font: inherit;\n font-size: var(--fs-row);\n overflow-wrap: anywhere;\n}\n:where(.band-chat-msg.mine) .band-chat-bubble {\n background: var(--fill-2);\n}\n.band-chat-bubble:where(:hover) {\n box-shadow: 0 0 0 1.5px var(--rule-strong);\n}\n.band-chat-comment {\n font-size: var(--fs-ui);\n padding: 6px 10px;\n border-radius: 8px;\n background: var(--panel);\n overflow-wrap: anywhere;\n}\n.band-chat-receipt {\n min-width: 0;\n padding: 0 2px 0 4px;\n font-size: var(--fs-row);\n display: grid;\n gap: 4px;\n}\n.band-chat-receipt-head {\n white-space: nowrap;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 6px;\n font-family: var(--mono);\n font-size: var(--fs-meta);\n color: var(--accent-text);\n}\n.band-chat-receipt-files {\n font-size: var(--fs-dense);\n color: var(--muted);\n font-family: var(--mono);\n}\n.band-chat-act {\n display: flex;\n justify-content: flex-end;\n align-items: center;\n gap: 8px;\n}\n.band-chat-receipt-foot {\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-chat-ask {\n margin: 6px 0 0;\n padding: 8px 10px;\n border-radius: var(--r);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-meta);\n}\n.band-chat-ask b {\n display: block;\n color: var(--warn);\n font-weight: 500;\n margin-bottom: 2px;\n}\n.band-chat-bulk {\n padding: 10px 14px 12px 16px;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n flex-wrap: wrap;\n}\n.band-chat-refs {\n min-width: 0;\n display: grid;\n gap: 6px;\n}\n.band-chat-quote {\n box-sizing: border-box;\n grid-template-columns: minmax(0, 1fr);\n min-width: 0;\n display: grid;\n gap: 2px;\n justify-self: start;\n max-width: 100%;\n padding: 6px 10px;\n border: 0;\n border-left: 2px solid var(--rule-strong);\n border-radius: 0 8px 8px 0;\n background: var(--fill);\n color: inherit;\n text-align: left;\n font: inherit;\n}\n.band-chat-quote:where(button) {\n cursor: pointer;\n}\n.band-chat-quote:where(button:hover) {\n border-left-color: var(--accent);\n}\n.band-chat-quote:where(:focus-visible) {\n outline: none;\n box-shadow: 0 0 0 2px var(--accent);\n}\n.band-chat-quote-label {\n min-width: 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-chat-quote-text {\n display: -webkit-box;\n overflow: hidden;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 2;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-chat"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-chat");document.head.prepend(el)}el.textContent=css}var src_default=definePlugin({surfaces:{chat:reactMount(ctx=>jsx(Chat,{ctx}))}});async function loadMessages(ctx,artifactId){const threads=artifactId?(await Promise.all([ctx.threads.list({artifactId}),ctx.threads.list({anchorKind:"project"})])).flat():await ctx.threads.list({});const sorted=[...threads].sort((a,b)=>a.mark-b.mark);const ids=sorted.map(t=>t.id);const byThread=await readComments(ctx,ids);return{messages:sorted.map(thread=>({thread,comments:byThread[thread.id]??[]}))}}function elementLabel(t){return t.anchor?anchorText(t.anchor).label:null}function anchorText(a){if(a.kind==="artifact"||a.kind==="project")return{label:null,quote:null,face:null};const label=a.payload.label;return{label:typeof label==="string"&&label?label:a.kind,quote:anchorQuote(a),face:quoteFace(a)}}function RefCard({ctx,item,threads,versions,artifactId}){const t=item.threadId?threads.get(item.threadId):void 0;const anchor=item.anchor??t?.anchor;const face=anchor?quoteFace(anchor):null;const hasText=anchor?anchorQuote(anchor)!==null:false;const aside=hasText?null:t?t.excerpt:item.anchor?null:item.text?.replace(/\s+/g," ").trim()??null;const versionId=item.versionId??item.anchor?.versionId;const label=versionId?versionReferenceText(item.label,versions,versionId,artifactId):item.label;const body=face?jsx("span",{className:"band-chat-quote-text",children:face}):jsxs(Fragment,{children:[jsx("span",{className:"band-chat-quote-label",children:jsx(VersionReference,{label})}),aside&&!label.includes(aside)&&jsx("span",{className:"band-chat-quote-text",children:aside})]});const threadId=item.threadId;return threadId?jsx("button",{type:"button",className:"band-chat-quote",onClick:()=>ctx.threads.open(threadId),"aria-label":`\u6253\u5F00\u5F15\u7528\uFF1A${label}`,children:body}):jsx("div",{className:"band-chat-quote",children:body})}function ChipTag({className,open,title,children}){return open?jsx("button",{type:"button",className:`${className} band-chat-chip-btn`,onClick:open,title,children}):jsx("span",{className,children})}function TurnProgress({ctx,turn,members,stage,queued=0}){const stopTurn=ctx.turns.requestStop;return jsx(StatusMessage,{turn,members,context:`${stage?`\u5728\u6539\u300C${stage}\u300D \xB7 `:""}\u56DE\u5408 #${turn.number}`,stop:stopTurn&&{run:()=>stopTurn(turn.changeRequestId),can:ctx.member.can("submit-change"),queued}})}var NEAR_BOTTOM_PX=48;function latestOwnCommentId(list,me){let latest;for(const m of list)for(const c of m.comments)if(c.author.id===me&&(!latest||c.createdAt>=latest.createdAt))latest=c;return latest?.id}function useFollowBottom(ref,key,count,mine){const pinned=useRef(true);const seen=useRef(null);const stick=useCallback(()=>{const el=ref.current;if(el)el.scrollTop=el.scrollHeight},[ref]);useEffect(()=>{const el=ref.current;if(!el)return;const onScroll=()=>{if(el.clientHeight===0)return;pinned.current=el.scrollHeight-el.scrollTop-el.clientHeight<=NEAR_BOTTOM_PX};el.addEventListener("scroll",onScroll,{passive:true});return()=>el.removeEventListener("scroll",onScroll)},[ref]);useEffect(()=>{const prev=seen.current;seen.current={key,mine};if(!prev||prev.key!==key||mine!==void 0&&mine!==prev.mine)pinned.current=true;if(pinned.current&&count>0)stick()},[key,count,mine,stick]);useEffect(()=>{const el=ref.current;if(!el||count===0||typeof ResizeObserver==="undefined")return;const observer=new ResizeObserver(()=>{if(pinned.current)stick()});observer.observe(el);for(const child of el.children)observer.observe(child);return()=>observer.disconnect()},[ref,count,stick])}function Chat({ctx}){const artifactId=useSelectedArtifact(ctx);const msgs=useCtxData(ctx,()=>loadMessages(ctx,artifactId),[artifactId],THREAD_EVENTS);const turn=useCtxData(ctx,()=>ctx.turns.state(),[],THREAD_EVENTS).data;const members=useMembers(ctx);const stages=useCtxData(ctx,async()=>{const[arts,stages2]=await Promise.all([ctx.artifacts.list(),ctx.stages.list()]);const names=new Map(stages2.map(x=>[x.stage,x.name??x.stage]));const key=artifactId?arts.find(a=>a.id===artifactId)?.stage:void 0;return{current:key?names.get(key):void 0,names,hasVersion:arts.some(a=>a.id===artifactId&&a.latest!==void 0)}},[artifactId],["stage.*","version.*","artifact.*"]).data;const stageName=key=>stages?.names.get(key)??key;const list=msgs.data?.messages??[];const{selected:sel,picked,anchor,toggle,send,sendOne,busy,error,notice,canSend}=useHandToAgent(ctx,list.map(m=>m.thread),agentLabel(members,ctx.project.agent));const versionRefs=useVersionReferences(ctx);const labels=versionRefs.data;const byId=new Map(list.map(m=>[m.thread.id,m.thread]));const running=turn?.current;const progressAt=running?list.findLast(m=>running.threadIds.includes(m.thread.id))?.thread.id:void 0;const stage=running?.stage?stageName(running.stage):stages?.current;const nav=useMessageList();const scroller=nav.ref;const reactionsOf=useReactionPatches(ctx,msgs.data);const count=list.reduce((n,m)=>n+1+m.comments.length,0);const me=ctx.member.id;useFollowBottom(scroller,artifactId,count,latestOwnCommentId(list,me));const dialog=ctx.services.find("@kanyun-ai-infra/band-project/artifact-dialog");const order=memberOrder(members);return jsxs("section",{className:"band-chat","aria-label":"\u5BF9\u8BDD",children:[jsx(PaneHeader,{title:"\u5BF9\u8BDD",children:jsx("span",{className:"band-chat-hint",children:"\u5BF9\u6574\u4EFD\u4EA7\u7269\u8BF4\uFF1B\u5143\u7D20\u4E0A\u7684\u610F\u89C1\u5728\u5185\u5BB9\u4E0A\u6807"})}),jsxs("div",{className:"band-chat-list",ref:scroller,"data-band-messages":"",onKeyDown:nav.onKeyDown,onFocus:nav.onFocus,children:[jsx(ErrorNote,{retry:msgs.reload,children:msgs.error}),msgs.data!==void 0&&list.length===0&&!msgs.error&&jsx("div",{className:"band-chat-empty",children:stages?.hasVersion?"\u8FD8\u6CA1\u6709\u5BF9\u8BDD\u3002\u6574\u4F53\u8981\u600E\u4E48\u6539\uFF0C\u5728\u4E0B\u9762\u8BF4\u3002":"\u8FD8\u6CA1\u6709\u5BF9\u8BDD\u3002"}),list.map(({thread:t,comments})=>{const first=comments.find(c=>c.kind==="comment");const tail=comments.filter(c=>c!==first&&(c.kind==="comment"||isThreadTail(c)));const el=elementLabel(t);const{quote,face}=t.anchor?anchorText(t.anchor):{quote:null,face:null};const refs=first?.refs??[];const working=running&&t.id===progressAt?running:null;const author=memberName(members,t.createdBy.id);const confirmation=threadConfirmation(t,ctx.member,members);return jsxs("article",{className:`band-chat-msg${t.createdBy.id===me?" mine":""}`,"aria-label":`\u6D88\u606F #${t.mark}`,"data-band-guide-keep":"hard",children:[jsxs("div",{className:"band-chat-meta",children:[jsx(Avatar,{id:t.createdBy.id,name:author,agent:t.createdBy.kind==="agent",order,decorative:true}),jsx("span",{className:"band-chat-author",children:author}),jsx("span",{className:"band-chat-time",children:shortTime(t.createdAt)}),el&&!quote&&jsx("span",{className:"anchor-chip band-chat-anchor",children:el}),t.status!=="resolved"&&!working&&jsx(ChipTag,{className:`chip ${STATUS_CHIP[t.status]}`,...t.status==="queued"?{open:()=>ctx.threads.open(t.id),title:"\u6253\u5F00\u8FD9\u6761\u6D88\u606F\uFF0C\u53EF\u64A4\u56DE"}:{},children:statusText(t.status,{...t.status==="queued"?queueSlot(turn,t.id):{},...t.agent?{agent:memberName(members,t.agent)}:{},...t.status==="open"&&wasStopped(comments)?{stopped:true}:{}})}),canSend&&t.status==="open"&&jsx("button",{type:"button",className:"btn ghost sm","data-band-guide":"hand-to-agent",disabled:busy,onClick:()=>void sendOne(t.id),children:`\u4EA4\u7ED9 ${agentLabel(members,ctx.project.agent)}`}),canSend&&t.status==="open"&&jsxs("label",{className:"band-chat-check",children:[jsx("span",{className:"band-chat-check-text",children:"\u9009\u4E2D"}),jsx("input",{className:"checkbox",type:"checkbox",checked:sel.has(t.id),onChange:()=>toggle(t.id),"aria-label":`\u9009\u4E2D #${t.mark}`})]})]}),t.id===anchor&&jsxs("div",{className:"band-chat-act",children:[jsx(ErrorNote,{children:error}),jsx(InfoNote,{children:notice}),jsx("button",{type:"button",className:"btn primary sm",disabled:busy,onClick:send,children:`${turn?.current?"\u6392\u5230\u4E0B\u4E00\u56DE\u5408":`\u4EA4\u7ED9 ${agentLabel(members,ctx.project.agent)}`}\uFF08${picked.length} \u6761\uFF09`})]}),el&"e&&jsx("button",{type:"button",className:"band-chat-quote",onClick:()=>ctx.threads.open(t.id),"aria-label":`\u5F15\u7528\u539F\u6587\uFF1A${el}`,children:face?jsx("span",{className:"band-chat-quote-text",children:face}):jsx("span",{className:"band-chat-quote-label",children:el})}),refs.length>0&&jsx("div",{className:"band-chat-refs",children:refs.map((r,i)=>jsx(RefCard,{ctx,item:r,threads:byId,versions:labels,artifactId},i))}),first?jsx(Message,{ctx,threadId:t.id,comment:first,members,reactions:reactionsOf(first),label:`${author}\u7684\u6D88\u606F`,fit:"bubble",children:jsx("button",{type:"button",className:"band-chat-bubble",onClick:()=>ctx.threads.open(t.id),children:first.body})}):jsx("button",{type:"button",className:"band-chat-bubble",onClick:()=>ctx.threads.open(t.id),children:t.excerpt}),tail.map(c=>{if(c.kind==="comment"){const who2=memberName(members,c.author.id);return jsx(Message,{ctx,threadId:t.id,comment:c,members,reactions:reactionsOf(c),label:`${who2}\u7684\u56DE\u590D`,fit:"bubble",children:jsxs("div",{className:"band-chat-comment",children:[jsx("b",{children:who2})," ",c.body]})},c.id)}const stopped=turnStoppedOf(c);if(stopped)return jsx(TurnStopped,{event:stopped,members},c.id);const who=memberName(members,c.author.id);const versionId=c.receipt?.versionId;const version=versionId?versionReferenceLabel(labels,versionId,artifactId):void 0;const owner=versionId?labels?.versions.get(versionId)?.version.artifactId:void 0;const open=dialog&&versionId&&owner?()=>dialog.open({artifactId:owner,versionId}):void 0;return jsx(Message,{ctx,threadId:t.id,comment:c,members,reactions:reactionsOf(c),label:`${who}\u7684\u56DE\u6267`,...version?{version:{label:version,...open?{open}:{}}}:{},children:jsxs("div",{className:"band-chat-receipt",children:[jsxs("span",{className:"band-chat-receipt-head",children:[jsx(AgentAvatar,{id:c.author.id,members,decorative:true}),who,version&&" \xB7 ",version&&jsx(VersionReference,{label:version,open})]}),jsx("span",{children:c.body}),c.receipt?.outcome==="needs-input"&&c.receipt.question&&jsxs("p",{className:"band-chat-ask",children:[jsxs("b",{children:[who," \u5728\u95EE\u4F60"]}),c.receipt.question]}),c.receipt&&c.receipt.files.length>0&&jsx("span",{className:"band-chat-receipt-files",children:receiptFileNames(c.receipt.files).join(" ")}),receiptFooter(c,stageName)&&jsx("span",{className:"band-chat-receipt-foot",children:receiptFooter(c,stageName)}),c.receipt&&jsx(MemoryNote,{ctx,turnId:c.receipt.turnId})]})},c.id)}),t.status==="awaiting_confirm"&&jsx("div",{children:confirmation.allowed?jsx("button",{type:"button",className:"btn primary sm",onClick:()=>ctx.threads.open(t.id),children:"\u6807\u4E3A\u5DF2\u89E3\u51B3\uFF0C\u6216\u6253\u56DE"}):jsx("span",{className:"band-chat-hint",children:confirmation.hint})}),working&&jsx(TurnProgress,{ctx,turn:working,members,stage,queued:queuedMessages(turn?.queue??[])})]},t.id)})]}),!anchor&&(error||notice)&&jsxs("div",{className:"band-chat-bulk",children:[jsx(ErrorNote,{children:error}),jsx(InfoNote,{children:notice})]})]})}export{TurnProgress,anchorText,src_default as default,latestOwnCommentId,loadMessages};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanyun-ai-infra/band-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "和 Agent 的对话流,按意见编号列意见与回执,勾选交给 Agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@kanyun-ai-infra/band-plugin-sdk": "^1.
|
|
11
|
-
"react": "^
|
|
12
|
-
"react-dom": "^
|
|
10
|
+
"@kanyun-ai-infra/band-plugin-sdk": "^2.1.0",
|
|
11
|
+
"react": "^19.0.0",
|
|
12
|
+
"react-dom": "^19.0.0",
|
|
13
13
|
"@kanyun-ai-infra/band-project": "*"
|
|
14
14
|
}
|
|
15
15
|
}
|