@kanyun-ai-infra/band-cli 0.2.0 → 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/official/activity/package.json +1 -1
- package/bundled/official/approval/package.json +1 -1
- package/bundled/official/artifacts/package.json +1 -1
- package/bundled/official/chat/dist/index.js +1 -1
- package/bundled/official/chat/package.json +2 -2
- package/bundled/official/chunks/chunk-7XYETT7C.js +1 -0
- package/bundled/official/comment/package.json +1 -1
- package/bundled/official/header/package.json +1 -1
- package/bundled/official/home/dist/index.js +1 -1
- package/bundled/official/home/package.json +2 -2
- package/bundled/official/layouts/package.json +1 -1
- package/bundled/official/library/package.json +1 -1
- package/bundled/official/members/dist/index.js +1 -1
- package/bundled/official/members/package.json +2 -2
- package/bundled/official/memory/package.json +1 -1
- package/bundled/official/native/package.json +1 -1
- package/bundled/official/params-form/package.json +1 -1
- package/bundled/official/plugins/package.json +1 -1
- package/bundled/official/project/dist/index.js +1 -1
- package/bundled/official/project/package.json +2 -2
- package/bundled/official/queue/package.json +1 -1
- package/bundled/official/settings/dist/index.js +1 -1
- package/bundled/official/settings/package.json +2 -2
- package/bundled/official/shell/dist/index.js +1 -1
- package/bundled/official/shell/package.json +2 -2
- package/bundled/official/stages/package.json +1 -1
- package/bundled/official/threads/dist/index.js +1 -1
- package/bundled/official/threads/package.json +2 -2
- package/bundled/official/turn-bar/package.json +1 -1
- package/bundled/official/turn-trace/package.json +1 -1
- package/bundled/official/version-switch/dist/index.js +1 -1
- package/bundled/official/version-switch/package.json +1 -1
- package/bundled/official/viewer-entity/package.json +1 -1
- package/bundled/official/viewer-external/package.json +1 -1
- package/bundled/official/viewer-image/package.json +1 -1
- package/bundled/official/viewer-media/package.json +1 -1
- package/bundled/official/viewer-storyboard/package.json +1 -1
- package/bundled/official/viewer-text/package.json +1 -1
- package/bundled/official/viewer-tool/package.json +1 -1
- package/bundled/official/viewer-web/package.json +1 -1
- package/bundled/official/viewer-web-app/package.json +1 -1
- package/bundled/official/workshops/dist/index.js +2 -2
- package/bundled/official/workshops/package.json +2 -2
- package/bundled/tokens/components.css +1 -1
- package/dev-host/app.tsx +23 -7
- package/dev-host/host.css +7 -0
- package/dist/bin.js +1 -1
- package/dist/{chunk-Q2XJXNVH.js → chunk-FGPWXAOA.js} +151 -19
- package/dist/{dev-server-Q7NTJ3QD.js → dev-server-IBR3PKDE.js} +14 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/package.json +5 -4
- package/src/inspector-default.ts +9 -0
- package/bundled/official/chunks/chunk-DIL5YSVK.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunks/chunk-JFPQMFKF.js";import{ATTACHMENT_LIMITS}from"@kanyun-ai-infra/band-contracts";import{isAlerting as isAlerting2}from"@kanyun-ai-infra/band-contracts/needs-me";import{ErrorNote,Glyph,MODELS_FOR_PAGE,NoKeyNotice,PromptInput,REPO_URL_EXAMPLE,TargetRepoNote,WorkshopIcon,composerSpendLine,emptyDraft,errorRepo,errorRequestAccessUrl,errorText,failedBecause,isModelRequired,modelHintText,personalImportSources,popoverLeft,provisionConsentText,reactMount,repoFieldHint,saveDraft,scrollIntoPanel,shortWhen,targetRepoErrorId,useAppData,useRoute,useSettledText,withImeGuard}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect,useId as useId2,useLayoutEffect,useMemo,useRef,useState,useSyncExternalStore}from"react";import{useId}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{agentDisplayName}from"@kanyun-ai-infra/band-contracts";import{FirstMessageSchema,NAME_FROM_NEED_MAX,projectNameFromNeed}from"@kanyun-ai-infra/band-contracts/api";import{isAlerting}from"@kanyun-ai-infra/band-contracts/needs-me";import{gateRule,inline}from"@kanyun-ai-infra/band-plugin-react";import{Fragment,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/home.css */\n.band-home {\n box-sizing: border-box;\n width: 100%;\n max-width: 760px;\n margin: 0 auto;\n padding: 64px 32px 72px;\n display: grid;\n gap: 16px;\n align-content: start;\n}\n.band-home-hello {\n font-family: var(--font-display);\n font-size: var(--fs-display);\n font-weight: 600;\n letter-spacing: -0.005em;\n line-height: 1.25;\n margin-bottom: 6px;\n}\n.band-home-hello small {\n display: block;\n font-family: var(--font);\n font-size: var(--fs-body);\n font-weight: 400;\n color: var(--muted);\n margin-top: 8px;\n letter-spacing: 0;\n}\n.band-home-h {\n margin: 18px 0 0;\n font-size: var(--fs-meta);\n font-weight: 400;\n color: var(--muted);\n letter-spacing: 0.04em;\n}\n.band-home-composer {\n position: relative;\n}\n.band-home-composer textarea:disabled {\n color: var(--muted);\n}\n.band-home-composer .composer-bar {\n flex-wrap: nowrap;\n min-width: 0;\n}\n.band-home-picker-wrap {\n position: relative;\n min-width: 0;\n}\n.band-home-picker {\n max-width: 100%;\n overflow: hidden;\n}\n.band-home-picker button {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n flex: none;\n}\n.band-home-caret {\n width: 0;\n height: 0;\n margin-left: 1px;\n border-left: 3.5px solid transparent;\n border-right: 3.5px solid transparent;\n border-top: 4px solid currentColor;\n opacity: 0.6;\n}\n.band-home-menu {\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 10;\n display: grid;\n gap: 6px;\n width: min(280px, calc(100vw - 32px));\n padding: 6px;\n border-radius: var(--r-lg);\n background: var(--panel);\n box-shadow: var(--shadow-pop);\n}\n.band-home-menu .band-home-menu-list {\n max-height: 260px;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 0;\n background: none;\n box-shadow: none;\n}\n.band-home-menu-empty {\n padding: 6px 8px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-home-rec {\n margin-left: 2px;\n font-size: var(--fs-badge);\n color: var(--accent-text);\n font-weight: 500;\n}\n.band-home-notes {\n display: grid;\n gap: 2px;\n padding: 0 16px 10px;\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n}\n.band-home-notes:not(:has(:not(:empty))) {\n display: none;\n}\n.band-home-hint:empty {\n display: none;\n}\n.band-home-hint-err {\n color: var(--bad);\n}\n.band-home-spend {\n margin: 0;\n text-align: end;\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-home-spend-note:not([data-action]) {\n display: none;\n}\n@media (max-width: 860px) {\n .band-home-spend {\n display: none;\n }\n .band-home-spend-note:not([data-action]) {\n display: block;\n }\n}\nbutton.band-home-ib {\n border: 0;\n background: none;\n width: 100%;\n text-align: left;\n color: inherit;\n font: inherit;\n cursor: pointer;\n grid-template-columns: 16px minmax(0, 1fr) auto;\n}\n.band-home-ib .ib-t,\n.band-home-ib .ib-d {\n display: block;\n}\n.band-home-when {\n color: var(--muted);\n}\n.band-home-act {\n font-size: var(--fs-dense);\n color: var(--ink);\n background: var(--fill-2);\n border-radius: 7px;\n padding: 2px 10px;\n white-space: nowrap;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-home-ib:hover .band-home-act {\n background: var(--fill-3);\n}\n.band-home-act.quiet {\n background: none;\n color: var(--muted);\n}\n.band-home-ib:hover .band-home-act.quiet {\n background: none;\n color: var(--ink);\n}\n.band-home-rest {\n padding: 18px 0 6px;\n justify-items: start;\n}\n.band-home-skeleton {\n display: grid;\n gap: 14px;\n padding: 10px 0;\n}\n.band-home-skeleton i {\n display: block;\n height: 14px;\n border-radius: 7px;\n background: var(--fill-2);\n animation: band-home-breathe 1.6s var(--ease) infinite alternate;\n}\n.band-home-skeleton i:nth-child(2) {\n width: 64%;\n}\n@keyframes band-home-breathe {\n to {\n opacity: 0.45;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .band-home-skeleton i {\n animation: none;\n }\n}\n@media (max-width: 860px) {\n .band-home {\n padding: 28px 16px 48px;\n }\n .band-home-hello {\n font-size: var(--fs-h1);\n }\n}\n.band-home-repo {\n display: grid;\n gap: 2px;\n padding: 0 16px 12px;\n font-size: var(--fs-ui);\n}\n.band-home-repo-field {\n display: grid;\n gap: 6px;\n}\n.band-home-repo-req,\n.band-home-repo-opt {\n margin-left: 6px;\n font-style: normal;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-home-composer {\n --shadow-float-focus: var(--shadow-float), 0 0 0 2px var(--accent);\n}\n.band-home-repo-input {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n border: 0;\n outline: none;\n box-shadow: none;\n background: none;\n color: var(--ink);\n padding: 8px 0;\n font: inherit;\n font-size: var(--fs-row);\n}\n.band-home-repo-input:focus-visible {\n outline: none;\n}\n.band-home-repo-input::placeholder {\n color: var(--muted);\n}\n.band-home-repo-input[aria-invalid=true] {\n box-shadow: inset 0 -2px 0 var(--bad);\n}\n.band-home-repo-input[aria-invalid=true]::placeholder {\n color: var(--bad);\n}\n.band-home-repo-input:disabled {\n color: var(--muted);\n cursor: not-allowed;\n}\n.band-home-intro {\n display: grid;\n gap: 10px;\n}\n.band-home-intro-lede {\n margin: 0;\n font-size: var(--fs-body);\n line-height: 1.6;\n color: var(--ink);\n}\n.band-home-intro-h {\n margin: 4px 0 0;\n}\n.band-home-samples {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 10px;\n}\nbutton.band-home-sample {\n display: grid;\n align-content: start;\n gap: 4px;\n padding: 10px 12px;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n background: var(--panel);\n color: var(--ink);\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\nbutton.band-home-sample:hover {\n border-color: var(--rule-strong);\n}\nbutton.band-home-sample:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--accent);\n}\n.band-home-sample b {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-home-sample span {\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n}\n@media (max-width: 860px) {\n .band-home-samples {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-home"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-home");document.head.prepend(el)}el.textContent=css}var FREEFORM_ID="freeform";var FREEFORM_INTRO="\u6211\u662F Rondo\uFF0CBand \u7684\u9ED8\u8BA4 Agent\u3002\u544A\u8BC9\u6211\u8981\u505A\u4EC0\u4E48\uFF0C\u6211\u5148\u505A\u51FA\u7B2C\u4E00\u7248\uFF0C\u4F60\u5728\u4E0A\u9762\u63D0\u610F\u89C1\uFF0C\u6211\u63A5\u7740\u6539\u3002\u6D77\u62A5\u3001\u7F51\u9875\u3001\u6587\u7AE0\u3001\u5C0F\u5DE5\u5177\u90FD\u53EF\u4EE5\u3002";var FREEFORM_SAMPLES=[{title:"\u6D3B\u52A8\u6D77\u62A5",text:"\u7ED9\u8BFB\u4E66\u4F1A\u505A\u4E00\u5F20\u6D77\u62A5\uFF0C\u4E3B\u9898\u662F\u300A\u5C0F\u738B\u5B50\u300B\uFF0C\u5468\u516D\u4E0B\u5348\u4E24\u70B9\uFF0C\u793E\u533A\u56FE\u4E66\u9986\u4E8C\u697C"},{title:"\u5355\u9875\u7F51\u7AD9",text:"\u505A\u4E00\u4E2A\u4ECB\u7ECD\u6211\u4EEC\u5496\u5561\u5E97\u7684\u5355\u9875\u7F51\u7AD9\uFF1A\u5E97\u540D\u3001\u8425\u4E1A\u65F6\u95F4\u3001\u4E09\u6B3E\u62DB\u724C\u996E\u54C1\u3001\u5730\u5740\u548C\u5730\u56FE"},{title:"\u6587\u7AE0",text:"\u5199\u4E00\u7BC7 800 \u5B57\u5DE6\u53F3\u7684\u516C\u4F17\u53F7\u6587\u7AE0\uFF0C\u4ECB\u7ECD\u5BB6\u91CC\u600E\u4E48\u5206\u7C7B\u5783\u573E\uFF0C\u8BED\u6C14\u8F7B\u677E\uFF0C\u914D\u4E09\u4E2A\u5C0F\u6807\u9898"}];var WORKSHOP_SAMPLES={[FREEFORM_ID]:FREEFORM_SAMPLES,"teaching-tool":[{title:"\u5206\u6570",text:"\u4E09\u5E74\u7EA7\u5206\u6570\u7684\u610F\u4E49\uFF1A\u62D6\u52A8\u628A\u4E00\u5757\u997C\u5E73\u5747\u5206\u6210\u51E0\u4EFD\uFF0C\u5B66\u751F\u81EA\u5DF1\u6570\u4E00\u4EFD\u662F\u51E0\u5206\u4E4B\u4E00"},{title:"\u52FE\u80A1\u5B9A\u7406",text:"\u516B\u5E74\u7EA7\u52FE\u80A1\u5B9A\u7406\uFF1A\u56DB\u4E2A\u76F4\u89D2\u4E09\u89D2\u5F62\u62FC\u8FDB\u5927\u6B63\u65B9\u5F62\uFF0C\u6362\u4E24\u79CD\u6446\u6CD5\uFF0C\u8BA9\u5B66\u751F\u770B\u51FA a\xB2 + b\xB2 = c\xB2"},{title:"\u949F\u8868",text:"\u4E00\u5E74\u7EA7\u8BA4\u8BC6\u949F\u8868\uFF1A\u62D6\u52A8\u65F6\u9488\u5206\u9488\u62E8\u5230\u6307\u5B9A\u65F6\u95F4\uFF0C\u62E8\u5BF9\u4E86\u7ED9\u63D0\u793A\uFF0C\u80FD\u6362\u4E09\u9053\u9898"}],video:[{title:"\u4EA7\u54C1\u4ECB\u7ECD",text:"\u505A\u4E00\u6BB5 60 \u79D2\u7684\u4EA7\u54C1\u4ECB\u7ECD\u89C6\u9891\uFF1A\u6211\u4EEC\u7684\u8BB0\u8D26 App \u80FD\u62CD\u5C0F\u7968\u81EA\u52A8\u8BB0\u8D26\uFF0C\u9762\u5411\u521A\u5DE5\u4F5C\u7684\u5E74\u8F7B\u4EBA"},{title:"\u79D1\u666E\u77ED\u7247",text:"\u505A\u4E00\u6BB5 90 \u79D2\u7684\u79D1\u666E\u77ED\u7247\uFF0C\u8BB2\u4E3A\u4EC0\u4E48\u5929\u7A7A\u662F\u84DD\u8272\u7684\uFF0C\u7ED9\u5C0F\u5B66\u9AD8\u5E74\u7EA7\u770B\uFF0C\u8BED\u6C14\u8F7B\u677E"},{title:"\u6D3B\u52A8\u56DE\u987E",text:"\u505A\u4E00\u6BB5 45 \u79D2\u7684\u8BFB\u4E66\u4F1A\u6D3B\u52A8\u56DE\u987E\uFF0C\u4ECB\u7ECD\u8FD9\u6B21\u8BFB\u4E86\u4EC0\u4E48\u3001\u5927\u5BB6\u804A\u4E86\u4EC0\u4E48\u3001\u4E0B\u6B21\u4EC0\u4E48\u65F6\u5019\u89C1"}]};function showsSamples(o){return o.workshop!==void 0&&WORKSHOP_SAMPLES[o.workshop]!==void 0&&o.projects!==void 0&&o.projects.length===0&&o.draftEmpty}function FreeformIntro({onPick,workshop=FREEFORM_ID}){const titleId=useId();const samples=WORKSHOP_SAMPLES[workshop]??FREEFORM_SAMPLES;return jsxs("section",{className:"band-home-intro","aria-labelledby":titleId,"data-band-guide-keep":"",children:[workshop===FREEFORM_ID&&jsx("p",{className:"band-home-intro-lede",children:FREEFORM_INTRO}),jsx("h2",{id:titleId,className:"band-home-h band-home-intro-h",children:"\u53EF\u4EE5\u4ECE\u8FD9\u4E9B\u5F00\u59CB"}),jsx("div",{className:"band-home-samples",children:samples.map(s=>jsxs("button",{type:"button",className:"band-home-sample",onClick:()=>onPick(s.text),children:[jsx("b",{children:s.title}),jsx("span",{children:s.text})]},s.title))})]})}function greet(hour){return hour<5?"\u591C\u6DF1\u4E86":hour<11?"\u65E9\u4E0A\u597D":hour<13?"\u4E2D\u5348\u597D":hour<18?"\u4E0B\u5348\u597D":"\u665A\u4E0A\u597D"}function inboxLine(i){const mark=i.mark===void 0?"":` #${i.mark}`;const stage=i.stageName??i.stage;const role=r=>i.roleLabels?.[r]??r;const agent=i.agentName??"Rondo";switch(i.kind){case"model_consent":return{glyph:"needs",text:i.text??"\u786E\u8BA4\u8FD9\u4E2A\u9879\u76EE\u6240\u6709\u4EBA\u7684\u56DE\u5408\u82B1\u4F60\u7684 ModelGate \u4E2A\u4EBA\u989D\u5EA6",sub:i.projectName,verb:"\u786E\u8BA4\u4F7F\u7528\u4E2A\u4EBA\u989D\u5EA6"};case"model_rebound":return{glyph:"needs",text:i.text??"\u8FD9\u4E2A\u9879\u76EE\u5DF2\u8865\u7ED1\u4F60\u7684\u6A21\u578B\u914D\u7F6E\uFF0C\u82B1\u8D39\u8BB0\u5728\u4F60\u7684\u4E2A\u4EBA\u989D\u5EA6",sub:i.projectName,verb:"\u67E5\u770B\u6A21\u578B\u4E0E\u51ED\u636E"};case"confirm":return{glyph:"waiting",text:i.requirement?`${agent} \u505A\u597D\u4E86\u7B2C\u4E00\u7248\uFF0C\u770B\u770B\u662F\u5426\u7B26\u5408\u4F60\u7684\u9700\u6C42`:`${agent} \u6539\u597D\u4E86\u4F60\u7684\u610F\u89C1${mark}\uFF0C\u786E\u8BA4\u662F\u5426\u89E3\u51B3`,sub:i.projectName,verb:"\u53BB\u786E\u8BA4"};case"approve":{const roles=(i.approveBy??[]).map(role);return{glyph:"needs",text:`\u300C${stage??"\u9636\u6BB5"}\u300D\u7B49\u4F60${i.role?`\u4EE5${inline(role(i.role))}\u8EAB\u4EFD`:""}\u6279\u51C6`,sub:roles.length?`${i.projectName} \xB7 \u9700\u8981${gateRule(roles,i.gateMode)}`:i.projectName,verb:"\u53BB\u6279\u51C6"}}case"publish":return{glyph:"queued",text:`\u300C${stage??"\u9636\u6BB5"}\u300D\u53EF\u4EE5\u5F00\u59CB\u4E86`,sub:i.projectName,verb:"\u53BB\u53D1\u5E03"};case"mention":return{glyph:"needs",text:`${i.by??"\u6709\u4EBA"} \u5728${mark?`${mark} `:"\u4E00\u6761\u610F\u89C1\u91CC"}\u63D0\u5230\u4F60`,sub:i.projectName,verb:"\u53BB\u56DE\u590D"};case"unsent":return{glyph:"queued",text:`\u4F60\u63D0\u7684 ${i.count??1} \u6761\u610F\u89C1\u8FD8\u6CA1\u4EA4\u7ED9 ${agent}`,sub:i.projectName,verb:`\u53BB\u4EA4\u7ED9 ${agent}`};case"question":return{glyph:"needs",text:`${i.by??agent} \u5728${mark?`${mark} `:"\u4E00\u6761\u610F\u89C1\u91CC"}\u95EE\u4F60\uFF1A${i.text??"\u9700\u8981\u4F60\u8865\u5145"}`,sub:i.projectName,verb:"\u53BB\u56DE\u7B54"};case"turn_failed":return{glyph:"failed",text:`${agent} \u8FD9\u4E00\u8F6E\u6CA1\u505A\u5B8C`,sub:i.text?`${i.projectName} \xB7 ${i.text}`:i.projectName,verb:"\u53BB\u770B\u770B"};case"stage_stalled":return{glyph:"failed",text:`${agent} \u5728\u300C${stage??"\u9636\u6BB5"}\u300D\u8FDE\u7EED\u5931\u8D25 ${i.attempts??3} \u6B21\uFF0C\u81EA\u52A8\u91CD\u8BD5\u5DF2\u505C`,sub:i.projectName,verb:"\u53BB\u91CD\u8BD5"};case"turn_stalled":return{glyph:"needs",text:`${agent} \u8FD9\u4E00\u8F6E\u5DF2\u7ECF ${minutesText(i.noProgressMs)}\u6CA1\u6709\u65B0\u8FDB\u5C55`,sub:`${i.projectName} \xB7 \u53EF\u4EE5\u53BB\u770B\u770B\u8FDB\u5EA6\uFF0C\u6216\u8005\u505C\u4E0B\u91CD\u53D1`,verb:"\u53BB\u770B\u770B"}}}function minutesText(ms){if(ms===void 0)return"\u597D\u4E00\u9635";return`${Math.max(1,Math.floor(ms/6e4))} \u5206\u949F`}function workshopInboxLine(i){if(i.kind==="upgrade_rollback")return{glyph:"failed",text:`${i.projectName??"\u9879\u76EE"}\u7684\u5347\u7EA7\u5DF2\u56DE\u6EDA`,sub:`${i.workshopName}\u5DE5\u574A \xB7 ${i.plugin} \xB7 ${i.reason}`,verb:"\u53BB\u5DE5\u574A"};const plugin=i.version?`${i.plugin}@${i.version}`:i.plugin;return{glyph:"failed",text:`${plugin} \u5DF2\u88AB\u5E73\u53F0\u5C01\u7981\uFF0C\u6362\u4E00\u4E2A\u7248\u672C\u518D\u53D1\u5E03`,sub:`${i.workshopName}\u5DE5\u574A \xB7 ${i.reason}`,verb:"\u53BB\u5DE5\u574A"}}function workshopInboxActionName(i){return`${workshopInboxLine(i).verb}\uFF1A${i.workshopName} \xB7 ${i.plugin}`}function copyBlockedLine(i,workshopName){return{glyph:"failed",text:"\u6709\u4EBA\u590D\u5236\u8FD9\u4E2A\u5DE5\u574A\u65F6\uFF0C\u8FD9\u4E00\u7248\u88AB\u67E5\u51FA\u7591\u4F3C\u5BC6\u94A5\uFF0C\u590D\u5236\u88AB\u62D2\u7EDD",sub:workshopName?`${workshopName}\u5DE5\u574A \xB7 \u6539\u6389\u7591\u4F3C\u5BC6\u94A5\u518D\u53D1\u5E03\uFF0C\u522B\u4EBA\u624D\u80FD\u590D\u5236`:"\u6539\u6389\u7591\u4F3C\u5BC6\u94A5\u518D\u53D1\u5E03\uFF0C\u522B\u4EBA\u624D\u80FD\u590D\u5236",verb:"\u53BB\u5DE5\u574A"}}function copyBlockedActionName(i,workshopName){return`${copyBlockedLine(i,workshopName).verb}\uFF1A${workshopName??i.workshopId} \xB7 \u590D\u5236\u88AB\u5BC6\u94A5\u626B\u63CF\u62D2\u7EDD`}function inboxActionName(i){const which=i.mark!==void 0?`#${i.mark}`:i.kind==="unsent"?void 0:i.stageName??i.stage;return`${inboxLine(i).verb}\uFF1A${i.projectName}${which?` \xB7 ${which}`:""}`}function progressActionName(p){return`\u53BB\u770B\uFF1A${p.projectName} \xB7 ${p.stageName??p.stage}`}function distinctNames(names){const total=new Map;for(const n of names)total.set(n,(total.get(n)??0)+1);const seen=new Map;return names.map(n=>{if((total.get(n)??0)<2)return n;const k=(seen.get(n)??0)+1;seen.set(n,k);return`${n} \xB7 \u7B2C ${k} \u4E2A`})}function progressLine(p){const stage=p.stageName??p.stage;return p.status==="running"?{glyph:"working",sub:`${p.agentName??agentDisplayName(p.agent)} \xB7 ${stage}`}:{glyph:"queued",sub:`${p.position?`\u6392\u961F\u7B2C ${p.position} \u4F4D`:"\u6392\u961F\u4E2D"} \xB7 ${stage}`}}var nameFrom=projectNameFromNeed;function firstMessageOf(draft){const body=draft.trim();if(body==="")return void 0;return FirstMessageSchema.safeParse({body}).success?{body}:null}function takesFirstMessage(w){return w.stages?.some(s=>s.kind==="agent")??false}function emptyComposerCopy(o){if(o.nameOnly){return{placeholder:"\u7ED9\u8FD9\u4E2A\u9879\u76EE\u8D77\u4E2A\u540D\u5B57\uFF0C\u6BD4\u5982\u300C\u4E09\u5E74\u7EA7\u6559\u5177\u300D\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA",hint:"\u5199\u4E0B\u9879\u76EE\u540D\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA"}}return{placeholder:o.scopeName?`\u60F3\u5728${o.scopeName}\u5DE5\u574A\u91CC\u505A\u70B9\u4EC0\u4E48\uFF1F\u5199\u4E00\u53E5\u9700\u6C42\uFF0C\u56DE\u8F66\u5C31\u65B0\u5EFA\u9879\u76EE`:"\u60F3\u505A\u70B9\u4EC0\u4E48\uFF1F\u6BD4\u5982\u300C\u7ED9\u4E94\u5E74\u7EA7\u505A\u4E00\u4E2A\u5206\u6570\u7684\u610F\u4E49\u7684\u6559\u5177\u300D\uFF0C\u6216\u8005\u300C\u7ED9\u6625\u62DB\u505A\u4E00\u4E2A\u6D3B\u52A8\u9875\u300D",hint:"\u5199\u4E0B\u8981\u505A\u4EC0\u4E48\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA"}}function missingFieldCopy(o){const what=o.nameOnly?"\u9879\u76EE\u540D":"\u8981\u505A\u4EC0\u4E48";if(o.missingName&&o.missingRepo)return`\u5199\u4E0B${what}\u3001\u586B\u597D\u4ED3\u5E93\u5730\u5740\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE`;if(o.missingRepo)return"\u8BF7\u5148\u586B\u5199\u4ED3\u5E93\u5730\u5740\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE";if(o.missingName)return`\u5199\u4E0B${what}\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE`;throw new Error("missingFieldCopy\uFF1A\u4E24\u683C\u90FD\u4E0D\u7F3A")}function recommend(draft,workshops){const text=draft.trim();if(text==="")return null;return workshops.find(w=>text.includes(w.name))?.id??null}var FREEFORM="freeform";function composerChoices(workshops){return[...workshops].sort((a,b)=>Number(b.id===FREEFORM)-Number(a.id===FREEFORM))}function composerPick(draft,choices,scope,picked){if(picked!==null)return picked;if(scope!==void 0)return scope;return recommend(draft,choices)??(choices.some(w=>w.id===FREEFORM)?FREEFORM:null)}var ROW_MAX=4;function recentWorkshops(projects,me){const mine=projects.filter(p=>p.project.createdBy===me).sort((a,b)=>b.project.createdAt.localeCompare(a.project.createdAt));const joined=[...projects].sort((a,b)=>b.lastActivityAt.localeCompare(a.lastActivityAt));const out=[];for(const p of[...mine,...joined]){const id=p.workshop.id;if(id!==FREEFORM&&!out.includes(id))out.push(id)}return out}var RECOMMENDED_WORKSHOPS=["teaching-tool","video"];function leadingWorkshops(recent){return recent.length>0?recent:RECOMMENDED_WORKSHOPS}function pickerRow(choices,recent,max=ROW_MAX){const others=choices.filter(w=>w.id!==FREEFORM);const byId=new Map(others.map(w=>[w.id,w]));const shown=[];for(const id of recent){const w=byId.get(id);if(w&&shown.length<max)shown.push(w)}for(const w of others)if(shown.length<max&&!shown.includes(w))shown.push(w);const free=choices.filter(w=>w.id===FREEFORM);return{row:[...free,...shown],rest:others.filter(w=>!shown.includes(w))}}function searchWorkshops(workshops,query){const q=query.trim().toLowerCase();if(q==="")return[...workshops];return workshops.filter(w=>w.name.toLowerCase().includes(q)||w.id.toLowerCase().includes(q))}function modelNeeds(workshops){return workshops.filter(w=>w.canAdmin&&w.model!==void 0&&w.model.state!=="not_provisioned"&&w.userModelKey!=="require"&&w.model?.state!=="configured")}function splitInbox(items){return{needs:items.filter(i=>i.kind!=="unsent"&&i.kind!=="publish"&&isAlerting(i)),publish:items.filter(i=>i.kind==="publish"),other:items.filter(i=>i.kind!=="unsent"&&i.kind!=="publish"&&!isAlerting(i)),unsent:items.filter(i=>i.kind==="unsent")}}var src_default=definePlugin({surfaces:{home:reactMount((ctx,{owner})=>jsx2(Home,{ctx,owner}))}});function Home({ctx,owner,now=()=>new Date}){const route=useRoute(ctx);const scope=route.workshop;const filter=scope===void 0?void 0:{workshop:scope};const{data,error,reload}=useAppData(ctx,async d=>{const[inbox,projects,workshops]=await Promise.all([d.inbox(filter),d.projects(filter),d.workshops(filter)]);return{inbox,projects,workshops}},[scope]);const{data:unscoped}=useAppData(ctx,d=>scope===void 0?Promise.resolve(null):d.projects(),[scope]);const allProjects=scope===void 0?data?.projects:unscoped??void 0;const me=ctx.app.member;const rowId=useId2();const[modelNotice,setModelNotice]=useState(null);const[confirmingProject,setConfirmingProject]=useState(null);const projectPage=owner.page("project");const workshopOf=new Map(data?.projects.map(p=>[p.project.id,p.workshop.id]));const openProject=(projectId,thread)=>{const ws=workshopOf.get(projectId);if(!projectPage)return;ctx.app.navigate({page:projectPage,params:{project:projectId,...ws?{workshop:ws}:{},...thread?{thread}:{}}})};const open=i=>{const models2=ctx.app.data.write?.projectAgentModels;if(i.kind==="model_consent"&&models2?.confirmProvisionUse){setConfirmingProject(i.projectId);setModelNotice(null);models2.confirmProvisionUse(i.projectId).then(()=>{setModelNotice("\u5DF2\u786E\u8BA4\uFF0C\u8BF7\u9879\u76EE\u6210\u5458\u91CD\u65B0\u53D1\u9001\u56DE\u5408\u3002");reload()}).catch(e=>setModelNotice(failedBecause(e,"\u786E\u8BA4\u6CA1\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5"))).finally(()=>setConfirmingProject(null));return}if(i.kind==="model_rebound"||i.kind==="model_consent"){if(i.kind==="model_rebound")models2?.markReboundRead?.(i.projectId).catch(()=>{});ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/settings",params:{project:i.projectId,tab:"models",...workshopOf.get(i.projectId)?{workshop:workshopOf.get(i.projectId)}:{}}});return}if(i.kind==="mention"&&i.commentId){ctx.app.data.write?.markRead(i.commentId).catch(()=>{})}openProject(i.projectId,i.threadId)};const{needs,publish,other,unsent}=splitInbox(data?.inbox.needsYou??[]);const wsNeeds=(data?.inbox.workshops??[]).filter(isAlerting2);const wsNameOf=new Map((data?.workshops??[]).map(w=>[w.id,w.name]));const copyBlocked=(data?.inbox.workshopCopyBlocked??[]).map(item=>({item,name:wsNameOf.get(item.workshopId)}));const copyBlockedNeeds=copyBlocked.filter(c=>isAlerting2(c.item));const copyBlockedQuiet=copyBlocked.filter(c=>!isAlerting2(c.item));const models=modelNeeds(data?.workshops??[]);const progress=data?.inbox.inProgress??[];const needNames=distinctNames(needs.map(inboxActionName));const publishNames=distinctNames(publish.map(inboxActionName));const otherNames=distinctNames(other.map(inboxActionName));const unsentNames=distinctNames(unsent.map(inboxActionName));const wsNeedNames=distinctNames(wsNeeds.map(workshopInboxActionName));const copyBlockedNames=distinctNames(copyBlocked.map(c=>copyBlockedActionName(c.item,c.name)));const copyBlockedIndexOf=new Map(copyBlocked.map((c,i)=>[c.item.workshopId,i]));const aboutPage=owner.page("about");const needCount=needs.length+wsNeeds.length+copyBlockedNeeds.length+models.length;const progressNames=distinctNames(progress.map(progressActionName));const running=progress.filter(p=>p.status==="running").length;const t=now();const scopeCard=scope?data?.workshops.find(w=>w.id===scope):void 0;const inboxRow=(i,n,prefix,names,glyph)=>{const line=inboxLine(i);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":names[n],"aria-describedby":`${rowId}-${prefix}${n}`,onClick:()=>open(i),disabled:confirmingProject===i.projectId,children:[jsx2(Glyph,{kind:glyph??line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-${prefix}${n}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(i.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},[prefix,i.kind,i.projectId,i.commentId,i.threadId,i.runId,i.stage,i.role].join(":"))};if(scope!==void 0&&data&&!scopeCard){return jsxs2("main",{className:"band-home",children:[jsxs2("div",{className:"band-home-hello",children:["\u6CA1\u6709\u300C",scope,"\u300D\u8FD9\u4E2A\u5DE5\u574A",jsx2("small",{children:"\u53EF\u80FD\u662F\u5730\u5740\u6253\u9519\u4E86\uFF0C\u6216\u8005\u5DE5\u574A\u5DF2\u7ECF\u4E0B\u7EBF\u3002"})]}),jsx2("div",{children:jsx2("button",{type:"button",className:"btn",onClick:()=>{const home=ctx.app.route().page;if(home)ctx.app.navigate({page:home})},children:"\u56DE\u5230\u5F85\u6211\u5904\u7406"})})]})}return jsxs2("main",{className:"band-home",children:[modelNotice&&jsx2("output",{children:modelNotice}),jsxs2("div",{className:"band-home-hello",children:[greet(t.getHours()),"\uFF0C",me.displayName,jsx2("small",{children:!data?scopeCard?`${scopeCard.name}\u5DE5\u574A`:"\xA0":needCount?`${scopeCard?`${scopeCard.name}\u5DE5\u574A\u91CC\uFF0C`:""}${needCount} \u4EF6\u4E8B\u5728\u7B49\u4F60${running?`\uFF0C${running} \u4E2A\u56DE\u5408\u6B63\u5728\u8FDB\u884C`:""}\u3002`:running?`${scopeCard?`${scopeCard.name}\u5DE5\u574A\u91CC\uFF0C`:""}${running} \u4E2A\u56DE\u5408\u6B63\u5728\u8FDB\u884C\u3002`:scopeCard?`${scopeCard.name}\u5DE5\u574A`:" "})]}),jsx2(Composer,{ctx,workshops:data?.workshops,projects:data?.projects,allProjects,scope,projectPage:owner.page("project")}),error&&jsxs2(ErrorNote,{retry:reload,children:["\u5F85\u6211\u5904\u7406\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}),jsx2("h2",{className:"band-home-h",children:"\u9700\u8981\u4F60"}),!data&&!error?jsxs2("div",{className:"band-home-skeleton","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx2("i",{}),jsx2("i",{})]}):needCount?jsxs2("div",{className:"inbox",children:[models.map(w=>jsxs2("button",{type:"button",className:"ib band-home-ib","aria-describedby":`${rowId}-m-${w.id}`,onClick:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-workshops/model",params:{workshop:w.id}}),children:[jsx2(Glyph,{kind:"needs"}),jsxs2("span",{className:"ib-m",id:`${rowId}-m-${w.id}`,children:[jsxs2("span",{className:"ib-t",children:[w.name," \u8FD8\u6CA1\u914D\u6A21\u578B"]}),jsx2("span",{className:"ib-d",children:"\u5DE5\u574A \xB7 \u4F60\u662F\u7BA1\u7406\u5458\uFF0C\u914D\u597D\u4E4B\u524D\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE"})]}),jsx2("span",{className:"band-home-act",children:"\u53BB\u914D\u7F6E"})]},`model:${w.id}`)),wsNeeds.map((i,n)=>{const line=workshopInboxLine(i);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":wsNeedNames[n],"aria-describedby":`${rowId}-w${n}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:i.workshopId}})},children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-w${n}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(i.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},[i.kind,i.workshopId,i.recordId??i.plugin,i.version].join(":"))}),copyBlockedNeeds.map(({item,name},n)=>{const line=copyBlockedLine(item,name);const idx=copyBlockedIndexOf.get(item.workshopId)??0;return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":copyBlockedNames[idx],"aria-describedby":`${rowId}-c${idx}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:item.workshopId}})},children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-c${idx}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(item.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},`copy_blocked:${item.workshopId}`)}),needs.map((i,n)=>inboxRow(i,n,"",needNames))]}):data?jsxs2("div",{className:"rest band-home-rest",children:[jsx2("i",{}),"\u6CA1\u6709\u7B49\u4F60\u7684\u4E8B\u3002"]}):null,publish.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u53EF\u4EE5\u53D1\u5E03"}),jsx2("div",{className:"inbox quiet",children:publish.map((i,n)=>inboxRow(i,n,"pub",publishNames))})]}),other.length>0||copyBlockedQuiet.length>0?jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u5176\u4ED6\u5F85\u5904\u7406"}),jsxs2("div",{className:"inbox quiet",children:[other.map((i,n)=>inboxRow(i,n,"o",otherNames,"queued")),copyBlockedQuiet.map(({item,name})=>{const idx=copyBlockedIndexOf.get(item.workshopId)??0;const line=copyBlockedLine(item,name);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":copyBlockedNames[idx],"aria-describedby":`${rowId}-cq${idx}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:item.workshopId}})},children:[jsx2(Glyph,{kind:"queued"}),jsxs2("span",{className:"ib-m",id:`${rowId}-cq${idx}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(item.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},`copy_blocked_q:${item.workshopId}`)})]})]}):null,unsent.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u8FD8\u6CA1\u4EA4\u51FA\u53BB"}),jsx2("div",{className:"inbox quiet",children:unsent.map((i,n)=>inboxRow(i,n,"u",unsentNames))})]}),progress.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u6B63\u5728\u8FDB\u884C"}),jsx2("div",{className:"inbox quiet",children:progress.map((p,n)=>{const line=progressLine(p);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":progressNames[n],"aria-describedby":`${rowId}-p${n}`,onClick:()=>openProject(p.projectId),children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-p${n}`,children:[jsx2("span",{className:"ib-t",children:p.projectName}),jsx2("span",{className:"ib-d",children:line.sub})]}),jsx2("span",{className:"band-home-act quiet",children:"\u53BB\u770B"})]},`${p.projectId}:${p.runId}:${p.stage}:${p.status}`)})})]})]})}function Composer(props){const write=props.ctx.app.data.write;return write?jsx2(RepositoryComposer,{...props,write}):null}function RepositoryComposer({ctx,workshops,projects,allProjects,scope,projectPage,write}){const[draft,setDraft]=useState(emptyDraft);const[picked,setPicked]=useState(null);const[busy,setBusy]=useState(false);const[repoUrls,setRepoUrls]=useState({});const[flaggedFor,setFlaggedFor]=useState(null);const[repoError,setRepoError]=useState(null);const[noKey,setNoKey]=useState(false);const repoInputs=useRef({});useEffect(()=>{if(repoError)repoInputs.current[repoError.repo]?.focus()},[repoError]);const composerRef=useRef(null);const focusAfterFill=useRef(false);useEffect(()=>{if(!focusAfterFill.current)return;focusAfterFill.current=false;const box=composerRef.current?.querySelector("textarea");box?.focus();box?.setSelectionRange(draft.text.length,draft.text.length)},[draft.text]);const choices=composerChoices(workshops??[]);const recent=leadingWorkshops(recentWorkshops(projects??[],ctx.app.member.id));const rec=scope===void 0?recommend(draft.text,choices):null;const pick=composerPick(draft.text,choices,scope,picked);const name=nameFrom(draft.text);const pickedCard=choices.find(w=>w.id===pick);const intro=showsSamples({workshop:pickedCard?.id,projects:allProjects,draftEmpty:draft.text.trim()===""&&draft.items.length===0});const{data:detail,error:detailError,reload:reloadDetail}=useAppData(ctx,data=>pickedCard?data.workshop(pickedCard.id):Promise.resolve(null),[pickedCard?.id]);const requiredRepos=(detail?.repos??[]).filter(repo=>repo.needsUrl);const modelPolicy=detail?.userModelKey;useEffect(()=>{setNoKey(false)},[pickedCard?.id,modelPolicy]);const modelApi=write.modelCredentials;const modelActive=!!modelApi&&(modelPolicy==="allow"||modelPolicy==="require");const modelRead=useAppData(ctx,async()=>({workshop:pickedCard?.id,policy:modelPolicy,list:modelActive&&modelApi?await modelApi.list():null}),[pickedCard?.id,modelPolicy,modelApi]);const modelList=modelRead.data?.workshop===pickedCard?.id&&modelRead.data?.policy===modelPolicy?modelRead.data?.list:void 0;const defaultModel=modelActive?modelList?.credentials.find(c=>c.isDefault):void 0;const provision=modelList?.credentials.length===0?modelList.provision:void 0;const consentQuota=modelActive&&modelPolicy==="require"&&provision&&(provision.status==="none"||provision.status==="pending")?provision.quotaUsd:void 0;const modelLoading=modelActive&&modelList===void 0&&!modelRead.error;const modelMissing=modelActive&&modelList!==void 0&&modelList!==null&&modelPolicy==="require"&&!defaultModel&&consentQuota===void 0;const modelHint=modelList?modelHintText(modelPolicy,defaultModel??null):null;const spendLine=defaultModel?composerSpendLine(defaultModel):null;const spendDetail=modelHint?.text;const urls=repoUrls[pickedCard?.id??""]??{};const missingRepo=requiredRepos.some(repo=>!urls[repo.name]?.trim());const asForm=requiredRepos.length>0;const scopeName=scope===void 0?void 0:choices.find(w=>w.id===scope)?.name;const carries=pickedCard!==void 0&&takesFirstMessage(pickedCard);const first=carries?firstMessageOf(draft.text):void 0;const files=draft.items.filter(i=>i.kind==="file");const carriesItems=draft.items.every(i=>i.kind==="file");const strandedFiles=!carries&&files.length>0;const ready=!busy&&(name!==""||asForm)&&pickedCard!==void 0&&first!==null&&detail?.id===pickedCard.id&&!detailError&&!modelLoading&&!(modelActive&&modelRead.error)&&!modelMissing&&!strandedFiles&&carriesItems;const attach=useMemo(()=>ctx.app.attachments.available?{limits:ATTACHMENT_LIMITS,upload:(file,o)=>ctx.app.attachments.upload(file,{signal:o.signal,onProgress:o.onProgress}).then(a=>({attachmentId:a.id,size:a.size,name:a.name,mime:a.mime,...a.existing?{existing:true}:{}}))}:void 0,[ctx]);const externalImport=useMemo(()=>personalImportSources(ctx,ctx.app.attachments),[ctx]);const emptyCopy=emptyComposerCopy({nameOnly:pickedCard!==void 0&&!carries,scopeName});const doneAttachments=d=>[...new Set(d.items.flatMap(i=>i.kind==="file"&&i.state==="done"&&i.attachmentId?[i.attachmentId]:[]))];const submit=async sent=>{if(!ready||!pickedCard||name==="")return false;if(missingRepo){setFlaggedFor(pickedCard.id);const empty=requiredRepos.find(repo=>!urls[repo.name]?.trim());if(empty)repoInputs.current[empty.name]?.focus();return false}setBusy(true);setRepoError(null);setNoKey(false);const attachments=doneAttachments(sent);let id;try{({id}=await write.createProject({workshop:pickedCard.id,name,...defaultModel?{modelCredentialId:defaultModel.id}:{},...consentQuota!==void 0?{modelProvisionConsent:true}:{},...first?{firstMessage:{...first,...attachments.length>0?{attachments}:{}}}:{},...requiredRepos.length?{repos:Object.fromEntries(requiredRepos.map(repo=>[repo.name,urls[repo.name]?.trim()??""]))}:{}}))}catch(e){setBusy(false);if(isModelRequired(e)){setNoKey(true);return false}const repo=errorRepo(e);if(repo!==void 0&&requiredRepos.some(r=>r.name===repo)){setRepoError({workshop:pickedCard.id,repo,value:urls[repo]?.trim()??"",message:errorText(e),requestAccessUrl:errorRequestAccessUrl(e)});return false}setBusy(false);throw new Error(`\u6CA1\u5EFA\u6210\uFF1A${errorText(e)}`)}setBusy(false);if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:pickedCard.id,project:id}})};const goConfigure=()=>{if(!pickedCard)return;const attachments=doneAttachments(draft);saveDraft(pickedCard.id,{name,need:draft.text,repoUrls:repoUrls[pickedCard.id]??{},formValues:{},formAcked:[],...attachments.length>0?{attachments}:{}});ctx.app.navigate({page:MODELS_FOR_PAGE,params:{workshop:pickedCard.id}})};const notes=jsxs2("div",{className:"band-home-notes",children:[noKey?jsx2(NoKeyNotice,{id:"band-home-no-key",onGo:goConfigure}):modelLoading?jsx2("p",{className:"band-plugin-react-model-hint",children:"\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u914D\u7F6E\u2026"}):modelActive&&modelRead.error?jsx2(ErrorNote,{retry:modelRead.reload,children:"\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF0C\u8BF7\u91CD\u8BD5\u3002"}):consentQuota!==void 0?jsxs2("p",{className:"band-plugin-react-model-hint",children:[provisionConsentText(consentQuota)," ",jsx2("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u6539\u7528\u81EA\u5DF1\u7684 key"})]}):modelHint&&jsxs2("p",{className:"band-plugin-react-model-hint band-home-spend-note",...modelHint.action?{"data-action":""}:{},children:[modelHint.text," ",modelHint.action&&jsx2("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u53BB\u4E2A\u4EBA\u8BBE\u7F6E"})]}),spendLine&&!noKey&&!modelLoading&&consentQuota===void 0&&jsx2("p",{className:"band-home-spend",children:jsx2("span",{title:spendDetail??void 0,children:spendLine})}),jsx2("div",{className:"band-home-hint","aria-live":"polite",children:detailError?null:busy?"\u6B63\u5728\u65B0\u5EFA\u9879\u76EE\u2026":pickedCard&&!detail?"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u8981\u6C42\u2026":missingRepo?missingFieldCopy({nameOnly:pickedCard!==void 0&&!carries,missingName:name==="",missingRepo:true}):asForm&&!name?missingFieldCopy({nameOnly:pickedCard!==void 0&&!carries,missingName:true,missingRepo:false}):first===null?jsx2("span",{className:"band-home-hint-err",children:"\u9700\u6C42\u592A\u957F\u4E86\uFF0C\u5220\u77ED\u4E00\u4E9B\u518D\u5EFA"}):strandedFiles&&pickedCard?jsxs2("span",{className:"band-home-hint-err",children:[pickedCard.name,"\u5DE5\u574A\u7684\u6D41\u7A0B\u91CC\u6CA1\u6709 Agent\uFF0C\u9644\u4EF6\u5E26\u4E0D\u8FDB\u9879\u76EE\uFF0C\u5148\u79FB\u9664\u9644\u4EF6\u518D\u5EFA"]}):modelMissing?null:name&&pickedCard?.id===FREEFORM?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u4E0D\u8D70\u6D41\u7A0B\uFF0C\u8FD9\u6BB5\u8BDD\u76F4\u63A5\u4EA4\u7ED9 Rondo\uFF0C\u4F1A\u5F00\u59CB\u4E00\u4E2A\u56DE\u5408"]}):name&&pickedCard&&!carries?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u7528 ",pickedCard.name," \u5DE5\u574A\uFF08\u6D41\u7A0B\u91CC\u6CA1\u6709 Agent\uFF0C\u8FD9\u6BB5\u8BDD\u4E0D\u5E26\u8FDB\u9879\u76EE\uFF09"]}):name&&pickedCard?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u7528 ",pickedCard.name," \u5DE5\u574A\uFF0C\u4F1A\u5F00\u59CB\u4E00\u4E2A\u56DE\u5408"]}):name?"\u9009\u4E00\u4E2A\u5DE5\u574A\u5F00\u59CB":jsx2(Fragment,{children:emptyCopy.hint})})]});return jsxs2(Fragment,{children:[jsxs2("div",{className:"band-home-composer",ref:composerRef,"data-band-guide":"request","data-band-guide-keep":"","data-band-guide-workshop":pickedCard?.id??"",children:[jsx2(PromptInput,{externalImport:carries?externalImport:void 0,draft,onDraft:setDraft,onSubmit:submit,variant:"prompt",label:"\u65B0\u7684\u9700\u6C42",foldPaste:false,placeholder:emptyCopy.placeholder,busy:!ready,required:asForm,onMissing:()=>setFlaggedFor(pickedCard?.id??null),submitLabel:"\u65B0\u5EFA\u9879\u76EE",hint:" ",...attach&&(carries||files.length>0)?{attach}:{},footerStart:jsx2(WorkshopPicker,{choices,recent,pick,rec:picked===null?rec:null,scope,disabled:busy,onPick:id=>setPicked(picked===id?null:id)}),fields:jsxs2(Fragment,{children:[requiredRepos.length>0&&requiredRepos.map(repo=>{const noteId=`band-home-repo-${repo.name}-note`;const rejected=repoError?.workshop===pickedCard?.id&&repoError?.repo===repo.name&&repoError?.value===(urls[repo.name]?.trim()??"")?repoError?.message:void 0;return jsxs2("div",{className:"band-home-repo",children:[jsxs2("label",{className:"band-home-repo-field",children:[jsxs2("span",{children:["\u4ED3\u5E93\u5730\u5740 ",jsx2("em",{className:"band-home-repo-req",children:"\u5FC5\u586B"})," ",jsx2("em",{className:"band-home-repo-opt",children:repoFieldHint(repo)})]}),jsx2("input",{ref:el=>{repoInputs.current[repo.name]=el},className:"band-home-repo-input",type:"text",value:urls[repo.name]??"",required:true,maxLength:500,disabled:busy,placeholder:REPO_URL_EXAMPLE,"aria-invalid":flaggedFor===pickedCard?.id&&!urls[repo.name]?.trim()||rejected?true:void 0,"aria-describedby":rejected?`${targetRepoErrorId(noteId)} ${noteId}`:noteId,onChange:e=>{const id=pickedCard?.id;const value=e.target.value;if(id)setRepoUrls(current=>({...current,[id]:{...current[id],[repo.name]:value}}))}})]}),jsx2(TargetRepoNote,{id:noteId,error:rejected,requestAccessUrl:rejected?repoError?.requestAccessUrl:void 0})]},repo.name)}),notes]})}),detailError&&jsxs2(ErrorNote,{retry:reloadDetail,children:["\u5DE5\u574A\u8981\u6C42\u6CA1\u8BFB\u51FA\u6765\uFF1A",detailError]})]}),intro&&jsx2(FreeformIntro,{workshop:pickedCard?.id,onPick:text=>{focusAfterFill.current=true;if(scope===void 0&&pickedCard)setPicked(pickedCard.id);setDraft({...draft,text})}})]})}var NARROW="(max-width: 860px)";function useNarrow(){return useSyncExternalStore(fn=>{const m=window.matchMedia?.(NARROW);m?.addEventListener("change",fn);return()=>m?.removeEventListener("change",fn)},()=>window.matchMedia?.(NARROW).matches??false)}function WorkshopPicker({choices,recent,pick,rec,scope,disabled,onPick}){const narrow=useNarrow();const[open,setOpen]=useState(false);const[fit,setFit]=useState({n:ROW_MAX});const seg=useRef(null);const trigger=useRef(null);useLayoutEffect(()=>{const el=seg.current;if(el&&fit.n>0&&el.scrollWidth>el.clientWidth)setFit({n:fit.n-1})});useEffect(()=>{const bar=seg.current?.closest(".composer-bar");if(!bar||typeof ResizeObserver==="undefined")return;let width=bar.clientWidth;const ro=new ResizeObserver(()=>{if(bar.clientWidth===width)return;width=bar.clientWidth;setFit({n:ROW_MAX})});ro.observe(bar);return()=>ro.disconnect()},[]);const close=back=>{setOpen(false);if(back)trigger.current?.focus()};if(scope!==void 0){const w=choices.find(c=>c.id===scope);return jsx2("div",{className:"seg band-home-picker",role:"group","aria-label":"\u7528\u54EA\u4E2A\u5DE5\u574A",children:w&&jsxs2("button",{type:"button","aria-pressed":true,children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),w.name]})})}const picked=choices.find(w=>w.id===pick);const{row,rest}=pickerRow(choices,recent,fit.n);const inRest=picked!==void 0&&rest.includes(picked);const tag=w=>jsxs2(Fragment,{children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),w.name,rec===w.id&&jsx2("span",{className:"band-home-rec",children:"\u63A8\u8350"})]});const opener={ref:trigger,type:"button","aria-haspopup":"listbox","aria-expanded":open,disabled,onMouseDown:e=>{if(open)e.preventDefault()},onClick:()=>open?close(true):setOpen(true)};return jsxs2("div",{className:"band-home-picker-wrap",children:[jsx2("div",{className:"seg band-home-picker",role:"group","aria-label":"\u7528\u54EA\u4E2A\u5DE5\u574A",ref:seg,children:narrow?jsxs2("button",{...opener,"data-band-guide":"workshop-pick",children:[picked?tag(picked):"\u9009\u5DE5\u574A",jsx2("span",{className:"band-home-caret","aria-hidden":"true"})]}):jsxs2(Fragment,{children:[row.map(w=>jsx2("button",{type:"button","aria-pressed":pick===w.id,disabled,onClick:()=>onPick(w.id),"data-band-guide":"workshop-pick","data-band-guide-workshop":w.id,children:tag(w)},w.id)),rest.length>0&&jsxs2("button",{...opener,"aria-pressed":inRest,children:[inRest&&picked?tag(picked):"\u66F4\u591A\u5DE5\u574A",jsx2("span",{className:"band-home-caret","aria-hidden":"true"})]})]})}),open&&jsx2(WorkshopMenu,{anchor:trigger,items:narrow?choices:rest,pick,onPick:id=>{onPick(id);close(true)},onClose:close})]})}function WorkshopMenu({anchor,items,pick,onPick,onClose}){const box=useRef(null);const[left,setLeft]=useState();useLayoutEffect(()=>{const el=box.current;const wrap=el?.offsetParent;const button=anchor.current;if(!el||!button||!(wrap instanceof HTMLElement))return;const at2=popoverLeft(button.getBoundingClientRect(),el.offsetWidth,document.documentElement.clientWidth);setLeft(at2-wrap.getBoundingClientRect().left)},[anchor]);const[query,setQuery]=useState("");const{settled,imeProps}=useSettledText(query);const[active,setActive]=useState(0);const listId=useId2();const shown=searchWorkshops(items,settled);const at=Math.min(active,Math.max(shown.length-1,0));const activeId=shown[at]?`${listId}-${shown[at].id}`:void 0;useEffect(()=>{const el=activeId?document.getElementById(activeId):null;if(el)scrollIntoPanel(el)},[activeId]);return jsxs2("div",{className:"band-home-menu field-host",ref:box,style:left===void 0?void 0:{left},children:[jsx2("input",{className:"field bare",type:"text",autoFocus:true,role:"combobox","aria-label":"\u641C\u7D22\u5DE5\u574A","aria-expanded":true,"aria-controls":listId,"aria-activedescendant":activeId,placeholder:"\u641C\u7D22\u5DE5\u574A",value:query,onChange:e=>{setQuery(e.target.value);setActive(0)},...imeProps,onBlur:()=>onClose(false),onKeyDown:withImeGuard(e=>{if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const n=shown.length;if(n)setActive((at+(e.key==="ArrowDown"?1:n-1))%n)}else if(e.key==="Enter"){e.preventDefault();const w=shown[at];if(w)onPick(w.id)}else if(e.key==="Escape"){e.preventDefault();onClose(true)}})}),jsxs2("div",{className:"mention band-home-menu-list",id:listId,role:"listbox","aria-label":"\u5DE5\u574A",onMouseDown:e=>e.preventDefault(),children:[shown.length===0&&jsxs2("div",{className:"band-home-menu-empty",children:["\u6CA1\u6709\u53EB\u300C",settled.trim(),"\u300D\u7684\u5DE5\u574A"]}),shown.map((w,i)=>jsxs2("button",{type:"button",id:`${listId}-${w.id}`,role:"option",tabIndex:-1,"aria-selected":i===at,onMouseEnter:()=>setActive(i),onClick:()=>onPick(w.id),children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),jsx2("span",{children:w.name}),jsx2("span",{className:"d",children:w.id===pick?"\u5F53\u524D":""})]},w.id))]})]})}export{Home,src_default as default};
|
|
1
|
+
import"../../chunks/chunk-JFPQMFKF.js";import{ATTACHMENT_LIMITS}from"@kanyun-ai-infra/band-contracts";import{isAlerting as isAlerting2}from"@kanyun-ai-infra/band-contracts/needs-me";import{ErrorNote,Glyph,MODELS_FOR_PAGE,NoKeyNotice,PromptInput,REPO_URL_EXAMPLE,TargetRepoNote,WorkshopIcon,composerSpendLine,emptyDraft,errorRepo,errorRequestAccessUrl,errorText,failedBecause,isModelRequired,modelHintText,personalImportSources,popoverLeft,provisionConsentText,reactMount,repoFieldHint,saveDraft,scrollIntoPanel,shortWhen,targetRepoErrorId,useAppData,useRoute,useSettledText,withImeGuard}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect,useId as useId2,useLayoutEffect,useMemo,useRef,useState,useSyncExternalStore}from"react";import{useId}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{agentDisplayName}from"@kanyun-ai-infra/band-contracts";import{FirstMessageSchema,NAME_FROM_NEED_MAX,projectNameFromNeed}from"@kanyun-ai-infra/band-contracts/api";import{isAlerting}from"@kanyun-ai-infra/band-contracts/needs-me";import{gateRule,inline}from"@kanyun-ai-infra/band-plugin-react";import{Fragment,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/home.css */\n.band-home {\n box-sizing: border-box;\n width: 100%;\n max-width: 760px;\n margin: 0 auto;\n padding: 64px 32px 72px;\n display: grid;\n gap: 16px;\n align-content: start;\n}\n.band-home-hello {\n font-family: var(--font-display);\n font-size: var(--fs-display);\n font-weight: 600;\n letter-spacing: -0.005em;\n line-height: 1.25;\n margin-bottom: 6px;\n}\n.band-home-hello small {\n display: block;\n font-family: var(--font);\n font-size: var(--fs-body);\n font-weight: 400;\n color: var(--muted);\n margin-top: 8px;\n letter-spacing: 0;\n}\n.band-home-h {\n margin: 18px 0 0;\n font-size: var(--fs-meta);\n font-weight: 400;\n color: var(--muted);\n letter-spacing: 0.04em;\n}\n.band-home-composer {\n position: relative;\n}\n.band-home-composer textarea:disabled {\n color: var(--muted);\n}\n.band-home-composer .composer-bar {\n flex-wrap: nowrap;\n min-width: 0;\n}\n.band-home-picker-wrap {\n position: relative;\n min-width: 0;\n}\n.band-home-picker {\n max-width: 100%;\n overflow: hidden;\n}\n.band-home-picker button {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n flex: none;\n}\n.band-home-caret {\n width: 0;\n height: 0;\n margin-left: 1px;\n border-left: 3.5px solid transparent;\n border-right: 3.5px solid transparent;\n border-top: 4px solid currentColor;\n opacity: 0.6;\n}\n.band-home-menu {\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 10;\n display: grid;\n gap: 6px;\n width: min(280px, calc(100vw - 32px));\n padding: 6px;\n border-radius: var(--r-lg);\n background: var(--panel);\n box-shadow: var(--shadow-pop);\n}\n.band-home-menu .band-home-menu-list {\n max-height: 260px;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 0;\n background: none;\n box-shadow: none;\n}\n.band-home-menu-empty {\n padding: 6px 8px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-home-rec {\n margin-left: 2px;\n font-size: var(--fs-badge);\n color: var(--accent-text);\n font-weight: 500;\n}\n.band-home-notes {\n display: grid;\n gap: 2px;\n padding: 0 16px 10px;\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n}\n.band-home-notes:not(:has(:not(:empty))) {\n display: none;\n}\n.band-home-hint:empty {\n display: none;\n}\n.band-home-hint-err {\n color: var(--bad);\n}\n.band-home-spend {\n margin: 0;\n text-align: end;\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-home-spend-note:not([data-action]) {\n display: none;\n}\n@media (max-width: 860px) {\n .band-home-spend {\n display: none;\n }\n .band-home-spend-note:not([data-action]) {\n display: block;\n }\n}\nbutton.band-home-ib {\n border: 0;\n background: none;\n width: 100%;\n text-align: left;\n color: inherit;\n font: inherit;\n cursor: pointer;\n grid-template-columns: 16px minmax(0, 1fr) auto;\n}\n.band-home-ib .ib-t,\n.band-home-ib .ib-d {\n display: block;\n}\n.band-home-when {\n color: var(--muted);\n}\n.band-home-act {\n font-size: var(--fs-dense);\n color: var(--ink);\n background: var(--fill-2);\n border-radius: 7px;\n padding: 2px 10px;\n white-space: nowrap;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-home-ib:hover .band-home-act {\n background: var(--fill-3);\n}\n.band-home-act.quiet {\n background: none;\n color: var(--muted);\n}\n.band-home-ib:hover .band-home-act.quiet {\n background: none;\n color: var(--ink);\n}\n.band-home-rest {\n padding: 18px 0 6px;\n justify-items: start;\n}\n.band-home-skeleton {\n display: grid;\n gap: 14px;\n padding: 10px 0;\n}\n.band-home-skeleton i {\n display: block;\n height: 14px;\n border-radius: 7px;\n background: var(--fill-2);\n animation: band-home-breathe 1.6s var(--ease) infinite alternate;\n}\n.band-home-skeleton i:nth-child(2) {\n width: 64%;\n}\n@keyframes band-home-breathe {\n to {\n opacity: 0.45;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .band-home-skeleton i {\n animation: none;\n }\n}\n@media (max-width: 860px) {\n .band-home {\n padding: 28px 16px 48px;\n }\n .band-home-hello {\n font-size: var(--fs-h1);\n }\n}\n.band-home-repo {\n display: grid;\n gap: 2px;\n padding: 0 16px 12px;\n font-size: var(--fs-ui);\n}\n.band-home-repo-field {\n display: grid;\n gap: 6px;\n}\n.band-home-repo-req,\n.band-home-repo-opt {\n margin-left: 6px;\n font-style: normal;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-home-composer {\n --shadow-float-focus: var(--shadow-float), 0 0 0 2px var(--accent);\n}\n.band-home-repo-input {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n border: 0;\n outline: none;\n box-shadow: none;\n background: none;\n color: var(--ink);\n padding: 8px 0;\n font: inherit;\n font-size: var(--fs-row);\n}\n.band-home-repo-input:focus-visible {\n outline: none;\n}\n.band-home-repo-input::placeholder {\n color: var(--muted);\n}\n.band-home-repo-input[aria-invalid=true] {\n box-shadow: inset 0 -2px 0 var(--bad);\n}\n.band-home-repo-input[aria-invalid=true]::placeholder {\n color: var(--bad);\n}\n.band-home-repo-input:disabled {\n color: var(--muted);\n cursor: not-allowed;\n}\n.band-home-intro {\n display: grid;\n gap: 10px;\n}\n.band-home-intro-lede {\n margin: 0;\n font-size: var(--fs-body);\n line-height: 1.6;\n color: var(--ink);\n}\n.band-home-intro-h {\n margin: 4px 0 0;\n}\n.band-home-samples {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 10px;\n}\nbutton.band-home-sample {\n display: grid;\n align-content: start;\n gap: 4px;\n padding: 10px 12px;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n background: var(--panel);\n color: var(--ink);\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\nbutton.band-home-sample:hover {\n border-color: var(--rule-strong);\n}\nbutton.band-home-sample:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--accent);\n}\n.band-home-sample b {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-home-sample span {\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--muted);\n}\n@media (max-width: 860px) {\n .band-home-samples {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-home"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-home");document.head.prepend(el)}el.textContent=css}var FREEFORM_ID="freeform";var FREEFORM_INTRO="\u6211\u662F Rondo\uFF0CBand \u7684\u9ED8\u8BA4 Agent\u3002\u544A\u8BC9\u6211\u8981\u505A\u4EC0\u4E48\uFF0C\u6211\u5148\u505A\u51FA\u7B2C\u4E00\u7248\uFF0C\u4F60\u5728\u4E0A\u9762\u63D0\u610F\u89C1\uFF0C\u6211\u63A5\u7740\u6539\u3002\u6D77\u62A5\u3001\u7F51\u9875\u3001\u6587\u7AE0\u3001\u5C0F\u5DE5\u5177\u90FD\u53EF\u4EE5\u3002";var FREEFORM_SAMPLES=[{title:"\u6D3B\u52A8\u6D77\u62A5",text:"\u7ED9\u8BFB\u4E66\u4F1A\u505A\u4E00\u5F20\u6D77\u62A5\uFF0C\u4E3B\u9898\u662F\u300A\u5C0F\u738B\u5B50\u300B\uFF0C\u5468\u516D\u4E0B\u5348\u4E24\u70B9\uFF0C\u793E\u533A\u56FE\u4E66\u9986\u4E8C\u697C"},{title:"\u5355\u9875\u7F51\u7AD9",text:"\u505A\u4E00\u4E2A\u4ECB\u7ECD\u6211\u4EEC\u5496\u5561\u5E97\u7684\u5355\u9875\u7F51\u7AD9\uFF1A\u5E97\u540D\u3001\u8425\u4E1A\u65F6\u95F4\u3001\u4E09\u6B3E\u62DB\u724C\u996E\u54C1\u3001\u5730\u5740\u548C\u5730\u56FE"},{title:"\u6587\u7AE0",text:"\u5199\u4E00\u7BC7 800 \u5B57\u5DE6\u53F3\u7684\u516C\u4F17\u53F7\u6587\u7AE0\uFF0C\u4ECB\u7ECD\u5BB6\u91CC\u600E\u4E48\u5206\u7C7B\u5783\u573E\uFF0C\u8BED\u6C14\u8F7B\u677E\uFF0C\u914D\u4E09\u4E2A\u5C0F\u6807\u9898"}];var WORKSHOP_SAMPLES={[FREEFORM_ID]:FREEFORM_SAMPLES,"teaching-tool":[{title:"\u5206\u6570",text:"\u4E09\u5E74\u7EA7\u5206\u6570\u7684\u610F\u4E49\uFF1A\u62D6\u52A8\u628A\u4E00\u5757\u997C\u5E73\u5747\u5206\u6210\u51E0\u4EFD\uFF0C\u5B66\u751F\u81EA\u5DF1\u6570\u4E00\u4EFD\u662F\u51E0\u5206\u4E4B\u4E00"},{title:"\u52FE\u80A1\u5B9A\u7406",text:"\u516B\u5E74\u7EA7\u52FE\u80A1\u5B9A\u7406\uFF1A\u56DB\u4E2A\u76F4\u89D2\u4E09\u89D2\u5F62\u62FC\u8FDB\u5927\u6B63\u65B9\u5F62\uFF0C\u6362\u4E24\u79CD\u6446\u6CD5\uFF0C\u8BA9\u5B66\u751F\u770B\u51FA a\xB2 + b\xB2 = c\xB2"},{title:"\u949F\u8868",text:"\u4E00\u5E74\u7EA7\u8BA4\u8BC6\u949F\u8868\uFF1A\u62D6\u52A8\u65F6\u9488\u5206\u9488\u62E8\u5230\u6307\u5B9A\u65F6\u95F4\uFF0C\u62E8\u5BF9\u4E86\u7ED9\u63D0\u793A\uFF0C\u80FD\u6362\u4E09\u9053\u9898"}],video:[{title:"\u4EA7\u54C1\u4ECB\u7ECD",text:"\u505A\u4E00\u6BB5 60 \u79D2\u7684\u4EA7\u54C1\u4ECB\u7ECD\u89C6\u9891\uFF1A\u6211\u4EEC\u7684\u8BB0\u8D26 App \u80FD\u62CD\u5C0F\u7968\u81EA\u52A8\u8BB0\u8D26\uFF0C\u9762\u5411\u521A\u5DE5\u4F5C\u7684\u5E74\u8F7B\u4EBA"},{title:"\u79D1\u666E\u77ED\u7247",text:"\u505A\u4E00\u6BB5 90 \u79D2\u7684\u79D1\u666E\u77ED\u7247\uFF0C\u8BB2\u4E3A\u4EC0\u4E48\u5929\u7A7A\u662F\u84DD\u8272\u7684\uFF0C\u7ED9\u5C0F\u5B66\u9AD8\u5E74\u7EA7\u770B\uFF0C\u8BED\u6C14\u8F7B\u677E"},{title:"\u6D3B\u52A8\u56DE\u987E",text:"\u505A\u4E00\u6BB5 45 \u79D2\u7684\u8BFB\u4E66\u4F1A\u6D3B\u52A8\u56DE\u987E\uFF0C\u4ECB\u7ECD\u8FD9\u6B21\u8BFB\u4E86\u4EC0\u4E48\u3001\u5927\u5BB6\u804A\u4E86\u4EC0\u4E48\u3001\u4E0B\u6B21\u4EC0\u4E48\u65F6\u5019\u89C1"}]};function showsSamples(o){return o.workshop!==void 0&&WORKSHOP_SAMPLES[o.workshop]!==void 0&&o.projects!==void 0&&o.projects.length===0&&o.draftEmpty}function FreeformIntro({onPick,workshop=FREEFORM_ID}){const titleId=useId();const samples=WORKSHOP_SAMPLES[workshop]??FREEFORM_SAMPLES;return jsxs("section",{className:"band-home-intro","aria-labelledby":titleId,"data-band-guide-keep":"",children:[workshop===FREEFORM_ID&&jsx("p",{className:"band-home-intro-lede",children:FREEFORM_INTRO}),jsx("h2",{id:titleId,className:"band-home-h band-home-intro-h",children:"\u53EF\u4EE5\u4ECE\u8FD9\u4E9B\u5F00\u59CB"}),jsx("div",{className:"band-home-samples",children:samples.map(s=>jsxs("button",{type:"button",className:"band-home-sample",onClick:()=>onPick(s.text),children:[jsx("b",{children:s.title}),jsx("span",{children:s.text})]},s.title))})]})}function greet(hour){return hour<5?"\u591C\u6DF1\u4E86":hour<11?"\u65E9\u4E0A\u597D":hour<13?"\u4E2D\u5348\u597D":hour<18?"\u4E0B\u5348\u597D":"\u665A\u4E0A\u597D"}function inboxLine(i){const mark=i.mark===void 0?"":` #${i.mark}`;const stage=i.stageName??i.stage;const role=r=>i.roleLabels?.[r]??r;const agent=i.agentName??"Rondo";switch(i.kind){case"model_consent":return{glyph:"needs",text:i.text??"\u786E\u8BA4\u8FD9\u4E2A\u9879\u76EE\u6240\u6709\u4EBA\u7684\u56DE\u5408\u82B1\u4F60\u7684 ModelGate \u4E2A\u4EBA\u989D\u5EA6",sub:i.projectName,verb:"\u786E\u8BA4\u4F7F\u7528\u4E2A\u4EBA\u989D\u5EA6"};case"model_rebound":return{glyph:"needs",text:i.text??"\u8FD9\u4E2A\u9879\u76EE\u5DF2\u8865\u7ED1\u4F60\u7684\u6A21\u578B\u914D\u7F6E\uFF0C\u82B1\u8D39\u8BB0\u5728\u4F60\u7684\u4E2A\u4EBA\u989D\u5EA6",sub:i.projectName,verb:"\u67E5\u770B\u6A21\u578B\u4E0E\u51ED\u636E"};case"confirm":return{glyph:"waiting",text:i.requirement?`${agent} \u505A\u597D\u4E86\u7B2C\u4E00\u7248\uFF0C\u770B\u770B\u662F\u5426\u7B26\u5408\u4F60\u7684\u9700\u6C42`:`${agent} \u6539\u597D\u4E86\u4F60\u7684\u610F\u89C1${mark}\uFF0C\u786E\u8BA4\u662F\u5426\u89E3\u51B3`,sub:i.projectName,verb:"\u53BB\u786E\u8BA4"};case"approve":{const roles=(i.approveBy??[]).map(role);return{glyph:"needs",text:`\u300C${stage??"\u9636\u6BB5"}\u300D\u7B49\u4F60${i.role?`\u4EE5${inline(role(i.role))}\u8EAB\u4EFD`:""}\u6279\u51C6`,sub:roles.length?`${i.projectName} \xB7 \u9700\u8981${gateRule(roles,i.gateMode)}`:i.projectName,verb:"\u53BB\u6279\u51C6"}}case"publish":return{glyph:"queued",text:`\u300C${stage??"\u9636\u6BB5"}\u300D\u53EF\u4EE5\u5F00\u59CB\u4E86`,sub:i.projectName,verb:"\u53BB\u53D1\u5E03"};case"mention":return{glyph:"needs",text:`${i.by??"\u6709\u4EBA"} \u5728${mark?`${mark} `:"\u4E00\u6761\u610F\u89C1\u91CC"}\u63D0\u5230\u4F60`,sub:i.projectName,verb:"\u53BB\u56DE\u590D"};case"unsent":return{glyph:"queued",text:`\u4F60\u63D0\u7684 ${i.count??1} \u6761\u610F\u89C1\u8FD8\u6CA1\u4EA4\u7ED9 ${agent}`,sub:i.projectName,verb:`\u53BB\u4EA4\u7ED9 ${agent}`};case"question":return{glyph:"needs",text:`${i.by??agent} \u5728${mark?`${mark} `:"\u4E00\u6761\u610F\u89C1\u91CC"}\u95EE\u4F60\uFF1A${i.text??"\u9700\u8981\u4F60\u8865\u5145"}`,sub:i.projectName,verb:"\u53BB\u56DE\u7B54"};case"turn_failed":return{glyph:"failed",text:`${agent} \u8FD9\u4E00\u8F6E\u6CA1\u505A\u5B8C`,sub:i.text?`${i.projectName} \xB7 ${i.text}`:i.projectName,verb:"\u53BB\u770B\u770B"};case"stage_stalled":return{glyph:"failed",text:`${agent} \u5728\u300C${stage??"\u9636\u6BB5"}\u300D\u8FDE\u7EED\u5931\u8D25 ${i.attempts??3} \u6B21\uFF0C\u81EA\u52A8\u91CD\u8BD5\u5DF2\u505C`,sub:i.projectName,verb:"\u53BB\u91CD\u8BD5"};case"turn_stalled":return{glyph:"needs",text:`${agent} \u8FD9\u4E00\u8F6E\u5DF2\u7ECF ${minutesText(i.noProgressMs)}\u6CA1\u6709\u65B0\u8FDB\u5C55`,sub:`${i.projectName} \xB7 \u53EF\u4EE5\u53BB\u770B\u770B\u8FDB\u5EA6\uFF0C\u6216\u8005\u505C\u4E0B\u91CD\u53D1`,verb:"\u53BB\u770B\u770B"}}}function minutesText(ms){if(ms===void 0)return"\u597D\u4E00\u9635";return`${Math.max(1,Math.floor(ms/6e4))} \u5206\u949F`}function workshopInboxLine(i){if(i.kind==="upgrade_rollback")return{glyph:"failed",text:`${i.projectName??"\u9879\u76EE"}\u7684\u5347\u7EA7\u5DF2\u56DE\u6EDA`,sub:`${i.workshopName}\u5DE5\u574A \xB7 ${i.plugin} \xB7 ${i.reason}`,verb:"\u53BB\u5DE5\u574A"};const plugin=i.version?`${i.plugin}@${i.version}`:i.plugin;return{glyph:"failed",text:`${plugin} \u5DF2\u88AB\u5E73\u53F0\u5C01\u7981\uFF0C\u6362\u4E00\u4E2A\u7248\u672C\u518D\u53D1\u5E03`,sub:`${i.workshopName}\u5DE5\u574A \xB7 ${i.reason}`,verb:"\u53BB\u5DE5\u574A"}}function workshopInboxActionName(i){return`${workshopInboxLine(i).verb}\uFF1A${i.workshopName} \xB7 ${i.plugin}`}function copyBlockedLine(i,workshopName){return{glyph:"failed",text:"\u6709\u4EBA\u590D\u5236\u8FD9\u4E2A\u5DE5\u574A\u65F6\uFF0C\u8FD9\u4E00\u7248\u88AB\u67E5\u51FA\u7591\u4F3C\u5BC6\u94A5\uFF0C\u590D\u5236\u88AB\u62D2\u7EDD",sub:workshopName?`${workshopName}\u5DE5\u574A \xB7 \u6539\u6389\u7591\u4F3C\u5BC6\u94A5\u518D\u53D1\u5E03\uFF0C\u522B\u4EBA\u624D\u80FD\u590D\u5236`:"\u6539\u6389\u7591\u4F3C\u5BC6\u94A5\u518D\u53D1\u5E03\uFF0C\u522B\u4EBA\u624D\u80FD\u590D\u5236",verb:"\u53BB\u5DE5\u574A"}}function copyBlockedActionName(i,workshopName){return`${copyBlockedLine(i,workshopName).verb}\uFF1A${workshopName??i.workshopId} \xB7 \u590D\u5236\u88AB\u5BC6\u94A5\u626B\u63CF\u62D2\u7EDD`}function inboxActionName(i){const which=i.mark!==void 0?`#${i.mark}`:i.kind==="unsent"?void 0:i.stageName??i.stage;return`${inboxLine(i).verb}\uFF1A${i.projectName}${which?` \xB7 ${which}`:""}`}function progressActionName(p){return`\u53BB\u770B\uFF1A${p.projectName} \xB7 ${p.stageName??p.stage}`}function distinctNames(names){const total=new Map;for(const n of names)total.set(n,(total.get(n)??0)+1);const seen=new Map;return names.map(n=>{if((total.get(n)??0)<2)return n;const k=(seen.get(n)??0)+1;seen.set(n,k);return`${n} \xB7 \u7B2C ${k} \u4E2A`})}function progressLine(p){const stage=p.stageName??p.stage;return p.status==="running"?{glyph:"working",sub:`${p.agentName??agentDisplayName(p.agent)} \xB7 ${stage}`}:{glyph:"queued",sub:`${p.position?`\u6392\u961F\u7B2C ${p.position} \u4F4D`:"\u6392\u961F\u4E2D"} \xB7 ${stage}`}}var nameFrom=projectNameFromNeed;function firstMessageOf(draft){const body=draft.trim();if(body==="")return void 0;return FirstMessageSchema.safeParse({body}).success?{body}:null}function takesFirstMessage(w){return w.stages?.some(s=>s.kind==="agent")??false}function emptyComposerCopy(o){if(o.nameOnly){return{placeholder:"\u7ED9\u8FD9\u4E2A\u9879\u76EE\u8D77\u4E2A\u540D\u5B57\uFF0C\u6BD4\u5982\u300C\u4E09\u5E74\u7EA7\u6559\u5177\u300D\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA",hint:"\u5199\u4E0B\u9879\u76EE\u540D\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA"}}return{placeholder:o.scopeName?`\u60F3\u5728${o.scopeName}\u5DE5\u574A\u91CC\u505A\u70B9\u4EC0\u4E48\uFF1F\u5199\u4E00\u53E5\u9700\u6C42\uFF0C\u56DE\u8F66\u5C31\u65B0\u5EFA\u9879\u76EE`:"\u60F3\u505A\u70B9\u4EC0\u4E48\uFF1F\u6BD4\u5982\u300C\u7ED9\u4E94\u5E74\u7EA7\u505A\u4E00\u4E2A\u5206\u6570\u7684\u610F\u4E49\u7684\u6559\u5177\u300D\uFF0C\u6216\u8005\u300C\u7ED9\u6625\u62DB\u505A\u4E00\u4E2A\u6D3B\u52A8\u9875\u300D",hint:"\u5199\u4E0B\u8981\u505A\u4EC0\u4E48\uFF0C\u6309\u56DE\u8F66\u65B0\u5EFA"}}function missingFieldCopy(o){const what=o.nameOnly?"\u9879\u76EE\u540D":"\u8981\u505A\u4EC0\u4E48";if(o.missingName&&o.missingRepo)return`\u5199\u4E0B${what}\u3001\u586B\u597D\u4ED3\u5E93\u5730\u5740\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE`;if(o.missingRepo)return"\u8BF7\u5148\u586B\u5199\u4ED3\u5E93\u5730\u5740\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE";if(o.missingName)return`\u5199\u4E0B${what}\uFF0C\u518D\u65B0\u5EFA\u9879\u76EE`;throw new Error("missingFieldCopy\uFF1A\u4E24\u683C\u90FD\u4E0D\u7F3A")}function recommend(draft,workshops){const text=draft.trim();if(text==="")return null;return workshops.find(w=>text.includes(w.name))?.id??null}var FREEFORM="freeform";function composerChoices(workshops){return[...workshops].sort((a,b)=>Number(b.id===FREEFORM)-Number(a.id===FREEFORM))}function composerPick(draft,choices,scope,picked){if(picked!==null)return picked;if(scope!==void 0)return scope;return recommend(draft,choices)??(choices.some(w=>w.id===FREEFORM)?FREEFORM:null)}var ROW_MAX=4;function recentWorkshops(projects,me){const mine=projects.filter(p=>p.project.createdBy===me).sort((a,b)=>b.project.createdAt.localeCompare(a.project.createdAt));const joined=[...projects].sort((a,b)=>b.lastActivityAt.localeCompare(a.lastActivityAt));const out=[];for(const p of[...mine,...joined]){const id=p.workshop.id;if(id!==FREEFORM&&!out.includes(id))out.push(id)}return out}var RECOMMENDED_WORKSHOPS=["teaching-tool","video"];function leadingWorkshops(recent){return recent.length>0?recent:RECOMMENDED_WORKSHOPS}function pickerRow(choices,recent,max=ROW_MAX){const others=choices.filter(w=>w.id!==FREEFORM);const byId=new Map(others.map(w=>[w.id,w]));const shown=[];for(const id of recent){const w=byId.get(id);if(w&&shown.length<max)shown.push(w)}for(const w of others)if(shown.length<max&&!shown.includes(w))shown.push(w);const free=choices.filter(w=>w.id===FREEFORM);return{row:[...free,...shown],rest:others.filter(w=>!shown.includes(w))}}function searchWorkshops(workshops,query){const q=query.trim().toLowerCase();if(q==="")return[...workshops];return workshops.filter(w=>w.name.toLowerCase().includes(q)||w.id.toLowerCase().includes(q))}function provisionFailed(model){return model?.state==="configured"&&model.agent==="failed"}function modelNeeds(workshops){return workshops.filter(w=>w.canAdmin&&w.model!==void 0&&w.model.state!=="not_provisioned"&&w.userModelKey!=="require"&&(w.model.state!=="configured"||provisionFailed(w.model)))}function modelNeedLine(name,model){if(provisionFailed(model)){const who=model?.owner==="workshop"?"\u9700\u8981\u4F60\u5904\u7406":model?.owner==="waiting"?"\u6B63\u5728\u7B49\u522B\u5904\u505A\u4E00\u4EF6\u4E8B\uFF0C\u505A\u5B8C\u540E\u70B9\u91CD\u8BD5":"\u5E73\u53F0\u4FA7\u7684\u95EE\u9898\uFF0C\u5E73\u53F0\u4FEE\u597D\u540E\u70B9\u91CD\u8BD5";return{title:`${name} \u7684 Agent \u6CA1\u5EFA\u6210`,detail:`\u5DE5\u574A \xB7 ${model?.what??who}`,act:"\u67E5\u770B"}}return{title:`${name} \u8FD8\u6CA1\u914D\u6A21\u578B`,detail:"\u5DE5\u574A \xB7 \u4F60\u662F\u7BA1\u7406\u5458\uFF0C\u914D\u597D\u4E4B\u524D\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE",act:"\u53BB\u914D\u7F6E"}}function splitInbox(items){return{needs:items.filter(i=>i.kind!=="unsent"&&i.kind!=="publish"&&isAlerting(i)),publish:items.filter(i=>i.kind==="publish"),other:items.filter(i=>i.kind!=="unsent"&&i.kind!=="publish"&&!isAlerting(i)),unsent:items.filter(i=>i.kind==="unsent")}}var src_default=definePlugin({surfaces:{home:reactMount((ctx,{owner})=>jsx2(Home,{ctx,owner}))}});function Home({ctx,owner,now=()=>new Date}){const route=useRoute(ctx);const scope=route.workshop;const filter=scope===void 0?void 0:{workshop:scope};const{data,error,reload}=useAppData(ctx,async d=>{const[inbox,projects,workshops]=await Promise.all([d.inbox(filter),d.projects(filter),d.workshops(filter)]);return{inbox,projects,workshops}},[scope]);const{data:unscoped}=useAppData(ctx,d=>scope===void 0?Promise.resolve(null):d.projects(),[scope]);const allProjects=scope===void 0?data?.projects:unscoped??void 0;const me=ctx.app.member;const rowId=useId2();const[modelNotice,setModelNotice]=useState(null);const[confirmingProject,setConfirmingProject]=useState(null);const projectPage=owner.page("project");const workshopOf=new Map(data?.projects.map(p=>[p.project.id,p.workshop.id]));const openProject=(projectId,thread)=>{const ws=workshopOf.get(projectId);if(!projectPage)return;ctx.app.navigate({page:projectPage,params:{project:projectId,...ws?{workshop:ws}:{},...thread?{thread}:{}}})};const open=i=>{const models2=ctx.app.data.write?.projectAgentModels;if(i.kind==="model_consent"&&models2?.confirmProvisionUse){setConfirmingProject(i.projectId);setModelNotice(null);models2.confirmProvisionUse(i.projectId).then(()=>{setModelNotice("\u5DF2\u786E\u8BA4\uFF0C\u8BF7\u9879\u76EE\u6210\u5458\u91CD\u65B0\u53D1\u9001\u56DE\u5408\u3002");reload()}).catch(e=>setModelNotice(failedBecause(e,"\u786E\u8BA4\u6CA1\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5"))).finally(()=>setConfirmingProject(null));return}if(i.kind==="model_rebound"||i.kind==="model_consent"){if(i.kind==="model_rebound")models2?.markReboundRead?.(i.projectId).catch(()=>{});ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/settings",params:{project:i.projectId,tab:"models",...workshopOf.get(i.projectId)?{workshop:workshopOf.get(i.projectId)}:{}}});return}if(i.kind==="mention"&&i.commentId){ctx.app.data.write?.markRead(i.commentId).catch(()=>{})}openProject(i.projectId,i.threadId)};const{needs,publish,other,unsent}=splitInbox(data?.inbox.needsYou??[]);const wsNeeds=(data?.inbox.workshops??[]).filter(isAlerting2);const wsNameOf=new Map((data?.workshops??[]).map(w=>[w.id,w.name]));const copyBlocked=(data?.inbox.workshopCopyBlocked??[]).map(item=>({item,name:wsNameOf.get(item.workshopId)}));const copyBlockedNeeds=copyBlocked.filter(c=>isAlerting2(c.item));const copyBlockedQuiet=copyBlocked.filter(c=>!isAlerting2(c.item));const models=modelNeeds(data?.workshops??[]);const progress=data?.inbox.inProgress??[];const needNames=distinctNames(needs.map(inboxActionName));const publishNames=distinctNames(publish.map(inboxActionName));const otherNames=distinctNames(other.map(inboxActionName));const unsentNames=distinctNames(unsent.map(inboxActionName));const wsNeedNames=distinctNames(wsNeeds.map(workshopInboxActionName));const copyBlockedNames=distinctNames(copyBlocked.map(c=>copyBlockedActionName(c.item,c.name)));const copyBlockedIndexOf=new Map(copyBlocked.map((c,i)=>[c.item.workshopId,i]));const aboutPage=owner.page("about");const needCount=needs.length+wsNeeds.length+copyBlockedNeeds.length+models.length;const progressNames=distinctNames(progress.map(progressActionName));const running=progress.filter(p=>p.status==="running").length;const t=now();const scopeCard=scope?data?.workshops.find(w=>w.id===scope):void 0;const inboxRow=(i,n,prefix,names,glyph)=>{const line=inboxLine(i);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":names[n],"aria-describedby":`${rowId}-${prefix}${n}`,onClick:()=>open(i),disabled:confirmingProject===i.projectId,children:[jsx2(Glyph,{kind:glyph??line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-${prefix}${n}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(i.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},[prefix,i.kind,i.projectId,i.commentId,i.threadId,i.runId,i.stage,i.role].join(":"))};if(scope!==void 0&&data&&!scopeCard){return jsxs2("main",{className:"band-home",children:[jsxs2("div",{className:"band-home-hello",children:["\u6CA1\u6709\u300C",scope,"\u300D\u8FD9\u4E2A\u5DE5\u574A",jsx2("small",{children:"\u53EF\u80FD\u662F\u5730\u5740\u6253\u9519\u4E86\uFF0C\u6216\u8005\u5DE5\u574A\u5DF2\u7ECF\u4E0B\u7EBF\u3002"})]}),jsx2("div",{children:jsx2("button",{type:"button",className:"btn",onClick:()=>{const home=ctx.app.route().page;if(home)ctx.app.navigate({page:home})},children:"\u56DE\u5230\u5F85\u6211\u5904\u7406"})})]})}return jsxs2("main",{className:"band-home",children:[modelNotice&&jsx2("output",{children:modelNotice}),jsxs2("div",{className:"band-home-hello",children:[greet(t.getHours()),"\uFF0C",me.displayName,jsx2("small",{children:!data?scopeCard?`${scopeCard.name}\u5DE5\u574A`:"\xA0":needCount?`${scopeCard?`${scopeCard.name}\u5DE5\u574A\u91CC\uFF0C`:""}${needCount} \u4EF6\u4E8B\u5728\u7B49\u4F60${running?`\uFF0C${running} \u4E2A\u56DE\u5408\u6B63\u5728\u8FDB\u884C`:""}\u3002`:running?`${scopeCard?`${scopeCard.name}\u5DE5\u574A\u91CC\uFF0C`:""}${running} \u4E2A\u56DE\u5408\u6B63\u5728\u8FDB\u884C\u3002`:scopeCard?`${scopeCard.name}\u5DE5\u574A`:" "})]}),jsx2(Composer,{ctx,workshops:data?.workshops,projects:data?.projects,allProjects,scope,projectPage:owner.page("project")}),error&&jsxs2(ErrorNote,{retry:reload,children:["\u5F85\u6211\u5904\u7406\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}),jsx2("h2",{className:"band-home-h",children:"\u9700\u8981\u4F60"}),!data&&!error?jsxs2("div",{className:"band-home-skeleton","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx2("i",{}),jsx2("i",{})]}):needCount?jsxs2("div",{className:"inbox",children:[models.map(w=>{const line=modelNeedLine(w.name,w.model);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-describedby":`${rowId}-m-${w.id}`,onClick:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-workshops/model",params:{workshop:w.id}}),children:[jsx2(Glyph,{kind:"needs"}),jsxs2("span",{className:"ib-m",id:`${rowId}-m-${w.id}`,children:[jsx2("span",{className:"ib-t",children:line.title}),jsx2("span",{className:"ib-d",children:line.detail})]}),jsx2("span",{className:"band-home-act",children:line.act})]},`model:${w.id}`)}),wsNeeds.map((i,n)=>{const line=workshopInboxLine(i);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":wsNeedNames[n],"aria-describedby":`${rowId}-w${n}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:i.workshopId}})},children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-w${n}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(i.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},[i.kind,i.workshopId,i.recordId??i.plugin,i.version].join(":"))}),copyBlockedNeeds.map(({item,name},n)=>{const line=copyBlockedLine(item,name);const idx=copyBlockedIndexOf.get(item.workshopId)??0;return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":copyBlockedNames[idx],"aria-describedby":`${rowId}-c${idx}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:item.workshopId}})},children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-c${idx}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(item.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},`copy_blocked:${item.workshopId}`)}),needs.map((i,n)=>inboxRow(i,n,"",needNames))]}):data?jsxs2("div",{className:"rest band-home-rest",children:[jsx2("i",{}),"\u6CA1\u6709\u7B49\u4F60\u7684\u4E8B\u3002"]}):null,publish.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u53EF\u4EE5\u53D1\u5E03"}),jsx2("div",{className:"inbox quiet",children:publish.map((i,n)=>inboxRow(i,n,"pub",publishNames))})]}),other.length>0||copyBlockedQuiet.length>0?jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u5176\u4ED6\u5F85\u5904\u7406"}),jsxs2("div",{className:"inbox quiet",children:[other.map((i,n)=>inboxRow(i,n,"o",otherNames,"queued")),copyBlockedQuiet.map(({item,name})=>{const idx=copyBlockedIndexOf.get(item.workshopId)??0;const line=copyBlockedLine(item,name);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":copyBlockedNames[idx],"aria-describedby":`${rowId}-cq${idx}`,onClick:()=>{if(aboutPage)ctx.app.navigate({page:aboutPage,params:{workshop:item.workshopId}})},children:[jsx2(Glyph,{kind:"queued"}),jsxs2("span",{className:"ib-m",id:`${rowId}-cq${idx}`,children:[jsx2("span",{className:"ib-t",children:line.text}),jsxs2("span",{className:"ib-d",children:[line.sub,jsxs2("span",{className:"band-home-when",children:[" \xB7 ",shortWhen(item.at,t)]})]})]}),jsx2("span",{className:"band-home-act",children:line.verb})]},`copy_blocked_q:${item.workshopId}`)})]})]}):null,unsent.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u8FD8\u6CA1\u4EA4\u51FA\u53BB"}),jsx2("div",{className:"inbox quiet",children:unsent.map((i,n)=>inboxRow(i,n,"u",unsentNames))})]}),progress.length>0&&jsxs2(Fragment,{children:[jsx2("h2",{className:"band-home-h",children:"\u6B63\u5728\u8FDB\u884C"}),jsx2("div",{className:"inbox quiet",children:progress.map((p,n)=>{const line=progressLine(p);return jsxs2("button",{type:"button",className:"ib band-home-ib","aria-label":progressNames[n],"aria-describedby":`${rowId}-p${n}`,onClick:()=>openProject(p.projectId),children:[jsx2(Glyph,{kind:line.glyph}),jsxs2("span",{className:"ib-m",id:`${rowId}-p${n}`,children:[jsx2("span",{className:"ib-t",children:p.projectName}),jsx2("span",{className:"ib-d",children:line.sub})]}),jsx2("span",{className:"band-home-act quiet",children:"\u53BB\u770B"})]},`${p.projectId}:${p.runId}:${p.stage}:${p.status}`)})})]})]})}function Composer(props){const write=props.ctx.app.data.write;return write?jsx2(RepositoryComposer,{...props,write}):null}function RepositoryComposer({ctx,workshops,projects,allProjects,scope,projectPage,write}){const[draft,setDraft]=useState(emptyDraft);const[picked,setPicked]=useState(null);const[busy,setBusy]=useState(false);const[repoUrls,setRepoUrls]=useState({});const[flaggedFor,setFlaggedFor]=useState(null);const[repoError,setRepoError]=useState(null);const[noKey,setNoKey]=useState(false);const repoInputs=useRef({});useEffect(()=>{if(repoError)repoInputs.current[repoError.repo]?.focus()},[repoError]);const composerRef=useRef(null);const focusAfterFill=useRef(false);useEffect(()=>{if(!focusAfterFill.current)return;focusAfterFill.current=false;const box=composerRef.current?.querySelector("textarea");box?.focus();box?.setSelectionRange(draft.text.length,draft.text.length)},[draft.text]);const choices=composerChoices(workshops??[]);const recent=leadingWorkshops(recentWorkshops(projects??[],ctx.app.member.id));const rec=scope===void 0?recommend(draft.text,choices):null;const pick=composerPick(draft.text,choices,scope,picked);const name=nameFrom(draft.text);const pickedCard=choices.find(w=>w.id===pick);const intro=showsSamples({workshop:pickedCard?.id,projects:allProjects,draftEmpty:draft.text.trim()===""&&draft.items.length===0});const{data:detail,error:detailError,reload:reloadDetail}=useAppData(ctx,data=>pickedCard?data.workshop(pickedCard.id):Promise.resolve(null),[pickedCard?.id]);const requiredRepos=(detail?.repos??[]).filter(repo=>repo.needsUrl);const modelPolicy=detail?.userModelKey;useEffect(()=>{setNoKey(false)},[pickedCard?.id,modelPolicy]);const modelApi=write.modelCredentials;const modelActive=!!modelApi&&(modelPolicy==="allow"||modelPolicy==="require");const modelRead=useAppData(ctx,async()=>({workshop:pickedCard?.id,policy:modelPolicy,list:modelActive&&modelApi?await modelApi.list():null}),[pickedCard?.id,modelPolicy,modelApi]);const modelList=modelRead.data?.workshop===pickedCard?.id&&modelRead.data?.policy===modelPolicy?modelRead.data?.list:void 0;const defaultModel=modelActive?modelList?.credentials.find(c=>c.isDefault):void 0;const provision=modelList?.credentials.length===0?modelList.provision:void 0;const consentQuota=modelActive&&modelPolicy==="require"&&provision&&(provision.status==="none"||provision.status==="pending")?provision.quotaUsd:void 0;const modelLoading=modelActive&&modelList===void 0&&!modelRead.error;const modelMissing=modelActive&&modelList!==void 0&&modelList!==null&&modelPolicy==="require"&&!defaultModel&&consentQuota===void 0;const modelHint=modelList?modelHintText(modelPolicy,defaultModel??null):null;const spendLine=defaultModel?composerSpendLine(defaultModel):null;const spendDetail=modelHint?.text;const urls=repoUrls[pickedCard?.id??""]??{};const missingRepo=requiredRepos.some(repo=>!urls[repo.name]?.trim());const asForm=requiredRepos.length>0;const scopeName=scope===void 0?void 0:choices.find(w=>w.id===scope)?.name;const carries=pickedCard!==void 0&&takesFirstMessage(pickedCard);const first=carries?firstMessageOf(draft.text):void 0;const files=draft.items.filter(i=>i.kind==="file");const carriesItems=draft.items.every(i=>i.kind==="file");const strandedFiles=!carries&&files.length>0;const ready=!busy&&(name!==""||asForm)&&pickedCard!==void 0&&first!==null&&detail?.id===pickedCard.id&&!detailError&&!modelLoading&&!(modelActive&&modelRead.error)&&!modelMissing&&!strandedFiles&&carriesItems;const attach=useMemo(()=>ctx.app.attachments.available?{limits:ATTACHMENT_LIMITS,upload:(file,o)=>ctx.app.attachments.upload(file,{signal:o.signal,onProgress:o.onProgress}).then(a=>({attachmentId:a.id,size:a.size,name:a.name,mime:a.mime,...a.existing?{existing:true}:{}}))}:void 0,[ctx]);const externalImport=useMemo(()=>personalImportSources(ctx,ctx.app.attachments),[ctx]);const emptyCopy=emptyComposerCopy({nameOnly:pickedCard!==void 0&&!carries,scopeName});const doneAttachments=d=>[...new Set(d.items.flatMap(i=>i.kind==="file"&&i.state==="done"&&i.attachmentId?[i.attachmentId]:[]))];const submit=async sent=>{if(!ready||!pickedCard||name==="")return false;if(missingRepo){setFlaggedFor(pickedCard.id);const empty=requiredRepos.find(repo=>!urls[repo.name]?.trim());if(empty)repoInputs.current[empty.name]?.focus();return false}setBusy(true);setRepoError(null);setNoKey(false);const attachments=doneAttachments(sent);let id;try{({id}=await write.createProject({workshop:pickedCard.id,name,...defaultModel?{modelCredentialId:defaultModel.id}:{},...consentQuota!==void 0?{modelProvisionConsent:true}:{},...first?{firstMessage:{...first,...attachments.length>0?{attachments}:{}}}:{},...requiredRepos.length?{repos:Object.fromEntries(requiredRepos.map(repo=>[repo.name,urls[repo.name]?.trim()??""]))}:{}}))}catch(e){setBusy(false);if(isModelRequired(e)){setNoKey(true);return false}const repo=errorRepo(e);if(repo!==void 0&&requiredRepos.some(r=>r.name===repo)){setRepoError({workshop:pickedCard.id,repo,value:urls[repo]?.trim()??"",message:errorText(e),requestAccessUrl:errorRequestAccessUrl(e)});return false}setBusy(false);throw new Error(`\u6CA1\u5EFA\u6210\uFF1A${errorText(e)}`)}setBusy(false);if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:pickedCard.id,project:id}})};const goConfigure=()=>{if(!pickedCard)return;const attachments=doneAttachments(draft);saveDraft(pickedCard.id,{name,need:draft.text,repoUrls:repoUrls[pickedCard.id]??{},formValues:{},formAcked:[],...attachments.length>0?{attachments}:{}});ctx.app.navigate({page:MODELS_FOR_PAGE,params:{workshop:pickedCard.id}})};const notes=jsxs2("div",{className:"band-home-notes",children:[noKey?jsx2(NoKeyNotice,{id:"band-home-no-key",onGo:goConfigure}):modelLoading?jsx2("p",{className:"band-plugin-react-model-hint",children:"\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u914D\u7F6E\u2026"}):modelActive&&modelRead.error?jsx2(ErrorNote,{retry:modelRead.reload,children:"\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF0C\u8BF7\u91CD\u8BD5\u3002"}):consentQuota!==void 0?jsxs2("p",{className:"band-plugin-react-model-hint",children:[provisionConsentText(consentQuota)," ",jsx2("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u6539\u7528\u81EA\u5DF1\u7684 key"})]}):modelHint&&jsxs2("p",{className:"band-plugin-react-model-hint band-home-spend-note",...modelHint.action?{"data-action":""}:{},children:[modelHint.text," ",modelHint.action&&jsx2("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u53BB\u4E2A\u4EBA\u8BBE\u7F6E"})]}),spendLine&&!noKey&&!modelLoading&&consentQuota===void 0&&jsx2("p",{className:"band-home-spend",children:jsx2("span",{title:spendDetail??void 0,children:spendLine})}),jsx2("div",{className:"band-home-hint","aria-live":"polite",children:detailError?null:busy?"\u6B63\u5728\u65B0\u5EFA\u9879\u76EE\u2026":pickedCard&&!detail?"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u8981\u6C42\u2026":missingRepo?missingFieldCopy({nameOnly:pickedCard!==void 0&&!carries,missingName:name==="",missingRepo:true}):asForm&&!name?missingFieldCopy({nameOnly:pickedCard!==void 0&&!carries,missingName:true,missingRepo:false}):first===null?jsx2("span",{className:"band-home-hint-err",children:"\u9700\u6C42\u592A\u957F\u4E86\uFF0C\u5220\u77ED\u4E00\u4E9B\u518D\u5EFA"}):strandedFiles&&pickedCard?jsxs2("span",{className:"band-home-hint-err",children:[pickedCard.name,"\u5DE5\u574A\u7684\u6D41\u7A0B\u91CC\u6CA1\u6709 Agent\uFF0C\u9644\u4EF6\u5E26\u4E0D\u8FDB\u9879\u76EE\uFF0C\u5148\u79FB\u9664\u9644\u4EF6\u518D\u5EFA"]}):modelMissing?null:name&&pickedCard?.id===FREEFORM?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u4E0D\u8D70\u6D41\u7A0B\uFF0C\u8FD9\u6BB5\u8BDD\u76F4\u63A5\u4EA4\u7ED9 Rondo\uFF0C\u4F1A\u5F00\u59CB\u4E00\u4E2A\u56DE\u5408"]}):name&&pickedCard&&!carries?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u7528 ",pickedCard.name," \u5DE5\u574A\uFF08\u6D41\u7A0B\u91CC\u6CA1\u6709 Agent\uFF0C\u8FD9\u6BB5\u8BDD\u4E0D\u5E26\u8FDB\u9879\u76EE\uFF09"]}):name&&pickedCard?jsxs2(Fragment,{children:["\u56DE\u8F66\u65B0\u5EFA\u300C",name,"\u300D\uFF0C\u7528 ",pickedCard.name," \u5DE5\u574A\uFF0C\u4F1A\u5F00\u59CB\u4E00\u4E2A\u56DE\u5408"]}):name?"\u9009\u4E00\u4E2A\u5DE5\u574A\u5F00\u59CB":jsx2(Fragment,{children:emptyCopy.hint})})]});return jsxs2(Fragment,{children:[jsxs2("div",{className:"band-home-composer",ref:composerRef,"data-band-guide":"request","data-band-guide-keep":"","data-band-guide-workshop":pickedCard?.id??"",children:[jsx2(PromptInput,{externalImport:carries?externalImport:void 0,draft,onDraft:setDraft,onSubmit:submit,variant:"prompt",label:"\u65B0\u7684\u9700\u6C42",foldPaste:false,placeholder:emptyCopy.placeholder,busy:!ready,required:asForm,onMissing:()=>setFlaggedFor(pickedCard?.id??null),submitLabel:"\u65B0\u5EFA\u9879\u76EE",hint:" ",...attach&&(carries||files.length>0)?{attach}:{},footerStart:jsx2(WorkshopPicker,{choices,recent,pick,rec:picked===null?rec:null,scope,disabled:busy,onPick:id=>setPicked(picked===id?null:id)}),fields:jsxs2(Fragment,{children:[requiredRepos.length>0&&requiredRepos.map(repo=>{const noteId=`band-home-repo-${repo.name}-note`;const rejected=repoError?.workshop===pickedCard?.id&&repoError?.repo===repo.name&&repoError?.value===(urls[repo.name]?.trim()??"")?repoError?.message:void 0;return jsxs2("div",{className:"band-home-repo",children:[jsxs2("label",{className:"band-home-repo-field",children:[jsxs2("span",{children:["\u4ED3\u5E93\u5730\u5740 ",jsx2("em",{className:"band-home-repo-req",children:"\u5FC5\u586B"})," ",jsx2("em",{className:"band-home-repo-opt",children:repoFieldHint(repo)})]}),jsx2("input",{ref:el=>{repoInputs.current[repo.name]=el},className:"band-home-repo-input",type:"text",value:urls[repo.name]??"",required:true,maxLength:500,disabled:busy,placeholder:REPO_URL_EXAMPLE,"aria-invalid":flaggedFor===pickedCard?.id&&!urls[repo.name]?.trim()||rejected?true:void 0,"aria-describedby":rejected?`${targetRepoErrorId(noteId)} ${noteId}`:noteId,onChange:e=>{const id=pickedCard?.id;const value=e.target.value;if(id)setRepoUrls(current=>({...current,[id]:{...current[id],[repo.name]:value}}))}})]}),jsx2(TargetRepoNote,{id:noteId,error:rejected,requestAccessUrl:rejected?repoError?.requestAccessUrl:void 0})]},repo.name)}),notes]})}),detailError&&jsxs2(ErrorNote,{retry:reloadDetail,children:["\u5DE5\u574A\u8981\u6C42\u6CA1\u8BFB\u51FA\u6765\uFF1A",detailError]})]}),intro&&jsx2(FreeformIntro,{workshop:pickedCard?.id,onPick:text=>{focusAfterFill.current=true;if(scope===void 0&&pickedCard)setPicked(pickedCard.id);setDraft({...draft,text})}})]})}var NARROW="(max-width: 860px)";function useNarrow(){return useSyncExternalStore(fn=>{const m=window.matchMedia?.(NARROW);m?.addEventListener("change",fn);return()=>m?.removeEventListener("change",fn)},()=>window.matchMedia?.(NARROW).matches??false)}function WorkshopPicker({choices,recent,pick,rec,scope,disabled,onPick}){const narrow=useNarrow();const[open,setOpen]=useState(false);const[fit,setFit]=useState({n:ROW_MAX});const seg=useRef(null);const trigger=useRef(null);useLayoutEffect(()=>{const el=seg.current;if(el&&fit.n>0&&el.scrollWidth>el.clientWidth)setFit({n:fit.n-1})});useEffect(()=>{const bar=seg.current?.closest(".composer-bar");if(!bar||typeof ResizeObserver==="undefined")return;let width=bar.clientWidth;const ro=new ResizeObserver(()=>{if(bar.clientWidth===width)return;width=bar.clientWidth;setFit({n:ROW_MAX})});ro.observe(bar);return()=>ro.disconnect()},[]);const close=back=>{setOpen(false);if(back)trigger.current?.focus()};if(scope!==void 0){const w=choices.find(c=>c.id===scope);return jsx2("div",{className:"seg band-home-picker",role:"group","aria-label":"\u7528\u54EA\u4E2A\u5DE5\u574A",children:w&&jsxs2("button",{type:"button","aria-pressed":true,children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),w.name]})})}const picked=choices.find(w=>w.id===pick);const{row,rest}=pickerRow(choices,recent,fit.n);const inRest=picked!==void 0&&rest.includes(picked);const tag=w=>jsxs2(Fragment,{children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),w.name,rec===w.id&&jsx2("span",{className:"band-home-rec",children:"\u63A8\u8350"})]});const opener={ref:trigger,type:"button","aria-haspopup":"listbox","aria-expanded":open,disabled,onMouseDown:e=>{if(open)e.preventDefault()},onClick:()=>open?close(true):setOpen(true)};return jsxs2("div",{className:"band-home-picker-wrap",children:[jsx2("div",{className:"seg band-home-picker",role:"group","aria-label":"\u7528\u54EA\u4E2A\u5DE5\u574A",ref:seg,children:narrow?jsxs2("button",{...opener,"data-band-guide":"workshop-pick",children:[picked?tag(picked):"\u9009\u5DE5\u574A",jsx2("span",{className:"band-home-caret","aria-hidden":"true"})]}):jsxs2(Fragment,{children:[row.map(w=>jsx2("button",{type:"button","aria-pressed":pick===w.id,disabled,onClick:()=>onPick(w.id),"data-band-guide":"workshop-pick","data-band-guide-workshop":w.id,children:tag(w)},w.id)),rest.length>0&&jsxs2("button",{...opener,"aria-pressed":inRest,children:[inRest&&picked?tag(picked):"\u66F4\u591A\u5DE5\u574A",jsx2("span",{className:"band-home-caret","aria-hidden":"true"})]})]})}),open&&jsx2(WorkshopMenu,{anchor:trigger,items:narrow?choices:rest,pick,onPick:id=>{onPick(id);close(true)},onClose:close})]})}function WorkshopMenu({anchor,items,pick,onPick,onClose}){const box=useRef(null);const[left,setLeft]=useState();useLayoutEffect(()=>{const el=box.current;const wrap=el?.offsetParent;const button=anchor.current;if(!el||!button||!(wrap instanceof HTMLElement))return;const at2=popoverLeft(button.getBoundingClientRect(),el.offsetWidth,document.documentElement.clientWidth);setLeft(at2-wrap.getBoundingClientRect().left)},[anchor]);const[query,setQuery]=useState("");const{settled,imeProps}=useSettledText(query);const[active,setActive]=useState(0);const listId=useId2();const shown=searchWorkshops(items,settled);const at=Math.min(active,Math.max(shown.length-1,0));const activeId=shown[at]?`${listId}-${shown[at].id}`:void 0;useEffect(()=>{const el=activeId?document.getElementById(activeId):null;if(el)scrollIntoPanel(el)},[activeId]);return jsxs2("div",{className:"band-home-menu field-host",ref:box,style:left===void 0?void 0:{left},children:[jsx2("input",{className:"field bare",type:"text",autoFocus:true,role:"combobox","aria-label":"\u641C\u7D22\u5DE5\u574A","aria-expanded":true,"aria-controls":listId,"aria-activedescendant":activeId,placeholder:"\u641C\u7D22\u5DE5\u574A",value:query,onChange:e=>{setQuery(e.target.value);setActive(0)},...imeProps,onBlur:()=>onClose(false),onKeyDown:withImeGuard(e=>{if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();const n=shown.length;if(n)setActive((at+(e.key==="ArrowDown"?1:n-1))%n)}else if(e.key==="Enter"){e.preventDefault();const w=shown[at];if(w)onPick(w.id)}else if(e.key==="Escape"){e.preventDefault();onClose(true)}})}),jsxs2("div",{className:"mention band-home-menu-list",id:listId,role:"listbox","aria-label":"\u5DE5\u574A",onMouseDown:e=>e.preventDefault(),children:[shown.length===0&&jsxs2("div",{className:"band-home-menu-empty",children:["\u6CA1\u6709\u53EB\u300C",settled.trim(),"\u300D\u7684\u5DE5\u574A"]}),shown.map((w,i)=>jsxs2("button",{type:"button",id:`${listId}-${w.id}`,role:"option",tabIndex:-1,"aria-selected":i===at,onMouseEnter:()=>setActive(i),onClick:()=>onPick(w.id),children:[jsx2(WorkshopIcon,{icon:w.icon,size:14}),jsx2("span",{children:w.name}),jsx2("span",{className:"d",children:w.id===pick?"\u5F53\u524D":""})]},w.id))]})]})}export{Home,src_default as default};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanyun-ai-infra/band-home",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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": "^2.
|
|
10
|
+
"@kanyun-ai-infra/band-plugin-sdk": "^2.1.0",
|
|
11
11
|
"react": "^19.0.0",
|
|
12
12
|
"react-dom": "^19.0.0",
|
|
13
13
|
"@kanyun-ai-infra/band-shell": "*"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunks/chunk-JFPQMFKF.js";import{Avatar,ErrorNote as ErrorNote2,PaneHeader,SettingsNoAccess,SettingsReadError,SettingsSaveState,instrumentOf,isForbidden,memberOrder,reactMount,roleLabel,useCtxData,useMembers,useRoute}from"@kanyun-ai-infra/band-plugin-react";import{projectPath}from"@kanyun-ai-infra/band-plugin-sdk";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect as useEffect2,useState as useState2}from"react";import{ErrorNote}from"@kanyun-ai-infra/band-plugin-react";import{useEffect,useId,useState}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{SettingsDanger,SettingsDangerRow,SettingsDialog,SettingsEmpty,SettingsFacts,SettingsHead,SettingsLoading,SettingsRow,SettingsRows,SettingsSection}from"@kanyun-ai-infra/band-plugin-react";import{Fragment,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/members.css */\n.band-members {\n list-style: none;\n margin: 0;\n padding: 0 16px 12px;\n display: grid;\n gap: 8px;\n font-size: var(--fs-ui);\n}\n.band-members-item {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.band-members-name {\n flex: 0 0.2 auto;\n min-width: 2em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-members-role {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-members-cost {\n color: var(--muted);\n font-size: var(--fs-dense);\n white-space: nowrap;\n}\n.band-members-form {\n flex: 1 1 100%;\n display: grid;\n gap: 12px;\n font-size: var(--fs-row);\n}\n.band-members-form:where(fieldset) {\n margin: 0;\n padding: 0;\n border: 0;\n min-width: 0;\n}\n.band-members-form:where(.band-members-row > *) {\n padding-left: 36px;\n}\n.band-members-form p {\n margin: 0;\n}\n.band-members-field {\n position: relative;\n display: grid;\n gap: 4px;\n max-width: 360px;\n}\n.band-members-tags {\n margin: 0;\n padding: 0;\n border: 0;\n display: flex;\n flex-wrap: wrap;\n gap: 4px 16px;\n}\n.band-members-tags legend {\n padding: 0;\n margin-bottom: 4px;\n}\n.band-members-hint {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-members-cands {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 1;\n margin: 4px 0 0;\n padding: 4px;\n list-style: none;\n background: var(--panel);\n border-radius: var(--r);\n box-shadow: var(--shadow-pop);\n max-height: 240px;\n overflow: auto;\n overscroll-behavior: contain;\n}\n.band-members-cands button {\n display: flex;\n width: 100%;\n gap: 8px;\n align-items: baseline;\n padding: 6px 8px;\n border: 0;\n border-radius: var(--r);\n background: none;\n font: inherit;\n color: var(--ink);\n text-align: left;\n cursor: pointer;\n}\n.band-members-cands button:hover,\n.band-members-cands button:focus-visible {\n background: var(--fill);\n}\n.band-members-cands b {\n font-weight: 500;\n}\n.band-members-cands span {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-members-actions {\n display: flex;\n gap: 8px;\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-members"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-members");document.head.prepend(el)}el.textContent=css}var MANAGEMENT_LABEL={owner:"\u521B\u5EFA\u4EBA",maintainer:"\u7BA1\u7406\u5458",member:"\u6210\u5458"};var RANK={member:1,maintainer:2};function grantable(self,current){const all=["member","maintainer"];if(!self)return all;const now=current===void 0?0:current==="owner"?3:RANK[current];return all.filter(r=>RANK[r]<=now)}var failed=e=>e instanceof Error?e.message:String(e);function TagChoices({options,value,onChange,disabled}){return jsxs("fieldset",{className:"band-members-tags",children:[jsxs("legend",{children:["\u89D2\u8272 ",jsx("span",{className:"band-members-hint",children:"\u5FC5\u586B\uFF0C\u81F3\u5C11\u4E00\u4E2A"})]}),options.map(o=>jsxs("label",{className:"choice sm",children:[jsx("input",{type:"checkbox",className:"checkbox",checked:value.includes(o.name),disabled,onChange:e=>onChange(e.target.checked?[...value,o.name]:value.filter(r=>r!==o.name))}),o.label??o.name]},o.name))]})}function RoleSelect({value,options,onChange,disabled,fill}){const id=useId();return jsxs("div",{className:"band-members-field",children:[jsx("label",{htmlFor:id,children:"\u7BA1\u7406\u89D2\u8272"}),jsx("select",{id,className:fill?"field fill":"field",value,disabled:disabled||options.length<2,onChange:e=>onChange(e.target.value==="maintainer"?"maintainer":"member"),children:options.map(r=>jsx("option",{value:r,children:MANAGEMENT_LABEL[r]},r))})]})}function InviteForm({api,settings,onDone,onCancel}){const[q,setQ]=useState("");const[picked,setPicked]=useState(null);const[found,setFound]=useState({q:"",users:[]});const[tags,setTags]=useState([]);const[role,setRole]=useState("member");const[busy,setBusy]=useState(false);const[error,setError]=useState(null);const inputId=useId();const listId=useId();const taken=new Set(settings.people.map(p=>p.userId));const ldap=q.trim();useEffect(()=>{if(picked||ldap===""){setFound({q:"",users:[]});return}let live=true;const t=setTimeout(()=>{api.searchUsers(ldap).then(users=>live&&setFound({q:ldap,users}),()=>live&&setFound({q:"",users:[]}))},200);return()=>{live=false;clearTimeout(t)}},[api,ldap,picked]);const userId=picked?.id??ldap;const settled=found.q===ldap;const exact=settled?found.users.find(u=>u.id===ldap):void 0;const candidates=settled?found.users.filter(u=>!taken.has(u.id)):[];async function submit(){if(userId==="")return setError("\u8FD8\u6CA1\u9009\u4EBA\uFF1A\u8F93\u5165 ldap \u6216\u59D3\u540D\u67E5\u627E");if(/\s/.test(userId))return setError("ldap \u91CC\u4E0D\u80FD\u6709\u7A7A\u683C");if(taken.has(userId))return setError(`${userId} \u5DF2\u7ECF\u662F\u6210\u5458\uFF0C\u5728\u5217\u8868\u91CC\u6539\u89D2\u8272`);if(tags.length===0)return setError("\u8FD8\u5DEE\u89D2\u8272\u6CA1\u9009\uFF1A\u81F3\u5C11\u9009\u4E00\u4E2A");setBusy(true);setError(null);try{let known=picked??void 0;if(!known){try{known=(await api.searchUsers(userId)).find(u=>u.id===userId)}catch(e){return setError(`\u67E5\u7528\u6237\u76EE\u5F55\u5931\u8D25\uFF0C\u8FD8\u6CA1\u9080\u8BF7\uFF1A${failed(e)}`)}}const next=await api.set({userId,roles:tags,role,...known?{}:{displayName:userId}});onDone(next)}catch(e){setError(`\u9080\u8BF7\u5931\u8D25\uFF1A${failed(e)}`)}finally{setBusy(false)}}return jsxs("form",{className:"band-members-form field-host","aria-label":"\u9080\u8BF7\u6210\u5458",onSubmit:e=>{e.preventDefault();void submit()},children:[jsxs("div",{className:"band-members-field",children:[jsxs("label",{htmlFor:inputId,children:["\u9080\u8BF7\u8C01 ",jsx("span",{className:"band-members-hint",children:"\u5FC5\u586B"})]}),jsx("input",{id:inputId,className:"field fill",value:picked?`${picked.displayName}\uFF08${picked.id}\uFF09`:q,placeholder:"\u8F93\u5165 ldap \u6216\u59D3\u540D\u67E5\u627E",autoComplete:"off","aria-controls":listId,disabled:busy,onChange:e=>{setPicked(null);setQ(e.target.value)}}),candidates.length>0&&jsx("ul",{className:"band-members-cands",id:listId,"aria-label":"\u5019\u9009\u7684\u4EBA",children:candidates.map(u=>jsx("li",{children:jsxs("button",{type:"button",onClick:()=>{setPicked(u);setQ(u.id)},children:[jsx("b",{children:u.displayName}),jsx("span",{children:u.id})]})},u.id))}),!picked&&ldap!==""&&settled&&!exact&&!taken.has(ldap)&&jsxs("p",{className:"band-members-hint",children:["\u76EE\u5F55\u91CC\u6CA1\u6709 ",ldap,"\uFF08\u8FD8\u6CA1\u767B\u5F55\u8FC7 Band\uFF09\uFF1A\u7167\u6837\u53EF\u4EE5\u6309\u8FD9\u4E2A ldap \u9080\u8BF7\uFF0C\u4E2D\u6587\u540D\u4E4B\u540E\u81EA\u52A8\u8865\u4E0A\u3002"]})]}),jsx(TagChoices,{options:settings.roles,value:tags,onChange:setTags,disabled:busy}),jsx(RoleSelect,{value:role,options:grantable(false,void 0),onChange:setRole,disabled:busy,fill:true}),jsx(ErrorNote,{children:error}),jsxs("div",{className:"band-members-actions",children:[jsx("button",{type:"submit",className:"btn primary sm",disabled:busy,children:busy?"\u6B63\u5728\u9080\u8BF7\u2026":"\u9080\u8BF7"}),jsx("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function EditPerson({api,settings,person,self,onDone,onCancel}){const known=new Set(settings.roles.map(r=>r.name));const stale=person.roles.filter(r=>!known.has(r));const[tags,setTags]=useState(person.roles.filter(r=>known.has(r)));const[role,setRole]=useState(person.role==="maintainer"?"maintainer":"member");const[busy,setBusy]=useState(false);const[error,setError]=useState(null);const owner=person.role==="owner";async function save(){if(tags.length===0)return setError("\u8FD8\u5DEE\u89D2\u8272\u6CA1\u9009\uFF1A\u81F3\u5C11\u9009\u4E00\u4E2A");setBusy(true);setError(null);try{onDone(await api.set({userId:person.userId,roles:tags,...owner?{}:{role}}))}catch(e){setError(failed(e))}finally{setBusy(false)}}return jsxs("form",{className:"band-members-form","aria-label":`\u6539 ${person.displayName} \u7684\u89D2\u8272`,onSubmit:e=>{e.preventDefault();void save()},children:[jsx(TagChoices,{options:settings.roles,value:tags,onChange:setTags,disabled:busy}),stale.length>0&&jsxs("p",{className:"band-members-hint",children:["\u5DE5\u574A\u91CC\u5DF2\u7ECF\u6CA1\u6709 ",stale.join("\u3001"),"\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u53BB\u6389\u3002"]}),owner?jsx("p",{className:"band-members-hint",children:"\u521B\u5EFA\u4EBA\u7684\u7BA1\u7406\u89D2\u8272\u4E0D\u5728\u8FD9\u91CC\u6539\u3002"}):jsx(RoleSelect,{value:role,options:grantable(self,person.role),onChange:setRole,disabled:busy}),jsx(ErrorNote,{children:error}),jsxs("div",{className:"band-members-actions",children:[jsx("button",{type:"submit",className:"btn primary sm",disabled:busy,children:busy?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"}),jsx("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}var PAGE="@kanyun-ai-infra/band-settings/settings";var SECTION="members";var NEW_ITEM="new";var DESC="\u4EBA\u548C Agent \u90FD\u5728\u8FD9\u91CC\u3002\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3001\u6539\u89D2\u8272\u3002";var DESC_READONLY="\u4EBA\u548C Agent \u90FD\u5728\u8FD9\u91CC\u3002";var src_default=definePlugin({surfaces:{members:reactMount(ctx=>jsx2(Members,{ctx})),"settings-tab":reactMount(ctx=>jsx2(MembersTab,{ctx}))}});function Members({ctx}){const members=useMembers(ctx);const order=memberOrder(members);const peers=members.filter(m=>m.actor.kind==="agent").map(m=>m.actor.id);return jsxs2("section",{"aria-label":"\u6210\u5458",children:[jsx2(PaneHeader,{title:jsxs2(Fragment,{children:["\u6210\u5458 ",members.length]})}),jsx2("ul",{className:"band-members",children:members.map(m=>jsxs2("li",{className:"band-members-item",children:[jsx2(Avatar,{id:m.actor.id,name:m.displayName,agent:m.actor.kind==="agent",...m.actor.kind==="agent"?{instrument:instrumentOf(m.actor.id,peers)}:{},order,decorative:true}),jsx2("span",{className:"band-members-name",title:m.displayName,children:m.displayName}),jsx2("span",{className:"band-members-role",children:roleLabel(members,m.actor.id)})]},m.actor.id))})]})}function params(ctx,item){return{project:ctx.project.id,...ctx.project.workshop?{workshop:ctx.project.workshop}:{},tab:SECTION,...item?{item}:{}}}function href(ctx,item){return projectPath(ctx.project,"settings",...item?[SECTION,item]:[SECTION])}var FRESH_KEY="band-members:fresh:";function markFresh(projectId,userId){try{globalThis.sessionStorage?.setItem(FRESH_KEY+projectId,userId)}catch{}}function useFresh(projectId){const[id]=useState2(()=>{try{return globalThis.sessionStorage?.getItem(FRESH_KEY+projectId)??null}catch{return null}});useEffect2(()=>{if(id===null)return;try{globalThis.sessionStorage?.removeItem(FRESH_KEY+projectId)}catch{}},[id,projectId]);return id}function MembersTab({ctx}){const api=ctx.memberSettings;const route=useRoute(ctx);const item=route.params.item;const loaded=useCtxData(ctx,async()=>{let members2;try{members2=await ctx.members.list()}catch(e){if(isForbidden(e))return{kind:"forbidden"};throw e}let settings2=null;let settingsError=null;if(api){try{settings2=await api.get()}catch(e){if(!isForbidden(e))settingsError=e instanceof Error?e.message:String(e)}}return{kind:"ok",members:members2,settings:settings2,settingsError}},[api],["member.*","run.started"]);const[fresh,setFresh]=useState2(null);const data=loaded.data;const read=data?.kind==="ok"?data:null;const members=read?.members??[];const baseSettings=read?.settings??null;const settings=fresh&&fresh.base===baseSettings?fresh.next:baseSettings;const order=memberOrder(members);const people=members.filter(m=>m.actor.kind!=="agent");const agents=members.filter(m=>m.actor.kind==="agent");const peers=agents.map(m=>m.actor.id);const manage=api&&settings?.canManage?{api,settings}:null;const settingsFailed=read?.settingsError!=null;const settingsDenied=settings!=null&&!settings.canManage;const person=id=>settings?.people.find(p=>p.userId===id);const done=next=>setFresh({base:baseSettings,next});const freshId=useFresh(ctx.project.id);const goList=()=>ctx.app.navigate({page:PAGE,params:params(ctx)});if(data===void 0){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),loaded.error?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u6CA1\u8BFB\u51FA\u6765\uFF1A",loaded.error]}):jsx2(SettingsLoading,{text:"\u6B63\u5728\u8BFB\u53D6\u6210\u5458\u2026"})]})}if(data.kind==="forbidden"){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),jsx2(SettingsNoAccess,{title:"\u6CA1\u6709\u6743\u9650\u770B\u8FD9\u4E2A\u9879\u76EE\u7684\u6210\u5458",children:"\u53EA\u6709\u9879\u76EE\u6210\u5458\u80FD\u770B\u3002\u8981\u770B\u7684\u8BDD\uFF0C\u8BF7\u8054\u7CFB\u9879\u76EE\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u6765\u3002"})]})}if(item===NEW_ITEM){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6DFB\u52A0\u6210\u5458",desc:DESC}),manage?jsx2(InviteForm,{api:manage.api,settings:manage.settings,onDone:next=>{const before=new Set(manage.settings.people.map(p=>p.userId));const added=next.people.find(p=>!before.has(p.userId));done(next);if(added)markFresh(ctx.project.id,added.userId);goList()},onCancel:goList}):settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3002"})]})}if(item){const view=members.find(m=>m.actor.kind!=="agent"&&m.actor.id===item);const p=person(item);if(!view){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458"}),jsx2("p",{className:"band-sf-muted",children:"\u8FD9\u4E2A\u9879\u76EE\u91CC\u6CA1\u6709\u8FD9\u4E2A\u4EBA\uFF1B\u53EF\u80FD\u5DF2\u7ECF\u88AB\u79FB\u51FA\u3002"})]})}return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:view.displayName,desc:"\u7BA1\u7406\u5458\u80FD\u6539\u8FD9\u4E2A\u4EBA\u7684\u89D2\u8272\uFF1B\u521B\u5EFA\u4EBA\u7684\u7BA1\u7406\u89D2\u8272\u4E0D\u5728\u8FD9\u91CC\u6539\u3002"}),settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):settingsDenied?jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u6539\u3002"}):null,jsx2(SettingsFacts,{items:[{key:"\u540D\u5B57",value:view.displayName},{key:"\u7BA1\u7406\u89D2\u8272",value:p?MANAGEMENT_LABEL[p.role]:"\u6210\u5458"},{key:"\u4E1A\u52A1\u6807\u7B7E",value:settings&&p?tagText(settings,p):roleLabel(members,view.actor.id)||"\u6210\u5458"}]}),manage&&p?jsx2(SettingsSection,{title:"\u89D2\u8272",children:jsx2(EditPerson,{api:manage.api,settings:manage.settings,person:p,self:view.actor.id===ctx.member.id,onDone:done,onCancel:goList})}):null,manage&&p&&p.role!=="owner"?jsx2(SettingsDanger,{children:jsx2(SettingsDangerRow,{title:"\u79FB\u51FA\u9879\u76EE",note:`${view.displayName} \u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF1B\u8FD9\u4E2A\u4EBA\u9009\u5230\u9879\u76EE\u4E0A\u7684\u914D\u7F6E\u81EA\u52A8\u6E05\u7A7A\uFF0C\u8BB0\u5BA1\u8BA1\u3002`,action:jsx2(RemoveButton,{ctx,api:manage.api,person:p,onDone:goList})})}):null]})}const addHref=href(ctx,NEW_ITEM);const addAction=manage||settingsFailed?jsx2("a",{className:"btn primary",href:addHref,onClick:e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;e.preventDefault();ctx.app.navigate({page:PAGE,params:params(ctx,NEW_ITEM)})},children:"\u6DFB\u52A0\u6210\u5458"}):void 0;if(members.length===0){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):null,jsx2(SettingsEmpty,{action:addAction,children:"\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u6709\u6210\u5458\u3002"})]})}return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:settingsDenied?DESC_READONLY:DESC,action:addAction}),settingsDenied?jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3001\u6539\u89D2\u8272\u3002"}):null,jsx2(ErrorNote2,{retry:loaded.reload,children:loaded.error?`\u6210\u5458\u6CA1\u8BFB\u51FA\u6765\uFF1A${loaded.error}`:read?.settingsError?`\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A${read.settingsError}`:null}),jsxs2(SettingsRows,{label:`\u6210\u5458 ${members.length}`,children:[people.map(m=>{const p=person(m.actor.id);return jsx2(SettingsRow,{title:m.displayName,meta:settings&&p?[`${MANAGEMENT_LABEL[p.role]} \xB7 ${tagText(settings,p)}`]:[roleLabel(members,m.actor.id)||"\u6210\u5458"],href:href(ctx,m.actor.id),isNew:m.actor.id===freshId,...settings||settingsFailed?{onOpen:()=>ctx.app.navigate({page:PAGE,params:params(ctx,m.actor.id)})}:{}},`human:${m.actor.id}`)}),agents.map(m=>jsx2(SettingsRow,{title:m.displayName,meta:[m.actor.id===ctx.project.agent?"\u9ED8\u8BA4 Agent":"Agent"]},`agent:${m.actor.id}`))]}),settingsDenied?null:jsx2(UsageNote,{ctx,members})]})}function RemoveButton({ctx,api,person,onDone}){const[open,setOpen]=useState2(false);const[busy,setBusy]=useState2(false);const[error,setError]=useState2("");const self=person.userId===ctx.member.id;const remove=async()=>{if(busy)return;setBusy(true);setError("");try{await api.remove(person.userId);onDone()}catch(e){setError(`\u6CA1\u79FB\u6210\uFF1A${e instanceof Error?e.message:String(e)}`)}finally{setBusy(false)}};return jsxs2(Fragment,{children:[jsx2("button",{type:"button",className:"btn danger",onClick:()=>setOpen(true),children:"\u79FB\u51FA\u9879\u76EE"}),open?jsxs2(SettingsDialog,{title:`\u628A${person.displayName}\u79FB\u51FA\u9879\u76EE\uFF1F`,onClose:()=>setOpen(false),actions:jsxs2(Fragment,{children:[jsx2("button",{type:"button",className:"btn",onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),jsx2("button",{type:"button",className:"btn primary",disabled:busy,onClick:()=>void remove(),children:busy?"\u6B63\u5728\u79FB\u9664\u2026":"\u79FB\u51FA\u9879\u76EE"})]}),children:[jsxs2("ul",{children:[jsx2("li",{children:self?"\u4F60\u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF0C\u8981\u522B\u7684\u7BA1\u7406\u5458\u518D\u52A0\u56DE\u6765":`${person.displayName} \u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE`}),jsx2("li",{children:"\u8FD9\u4E2A\u4EBA\u9009\u5230\u9879\u76EE\u4E0A\u7684\u914D\u7F6E\u81EA\u52A8\u6E05\u7A7A\uFF0C\u8BB0\u5BA1\u8BA1"}),jsx2("li",{children:"\u5DF2\u6709\u7684\u8BC4\u8BBA\u4FDD\u7559\u7F72\u540D"})]}),error?jsx2(SettingsSaveState,{failed:error}):null]}):null]})}function tagText(settings,p){const label=r=>settings.roles.find(o=>o.name===r)?.label??r;return p.roles.map(label).join("\u3001")||"\u6210\u5458"}function UsageNote({ctx,members}){const usage=useCtxData(ctx,()=>ctx.members.usage(),[],["turn.delivered","turn.failed"]);const data=usage.data;if(!data)return null;const name=actor=>members.find(m=>m.actor.kind==="human"&&m.actor.id===actor)?.displayName??"\u5DF2\u79BB\u5F00\u7684\u6210\u5458";const money=costUsd=>costUsd===void 0?"\u2014":costUsd<.01?"\u4E0D\u5230 $0.01":`$${costUsd.toFixed(2)}`;const line=(key,label,sub,u)=>jsx2(SettingsRow,{title:label,meta:[sub],actions:jsxs2("span",{className:"band-members-cost",children:[u.turns," \u4E2A\u56DE\u5408 \xB7 ",money(u.costUsd)]})},key);return jsx2(SettingsSection,{title:"\u7528\u91CF",desc:"\u53EA\u505A\u8BB0\u5F55\uFF0C\u4E0D\u8BBE\u4E0A\u9650\u3002\u4E2D\u9014\u505C\u4E0B\u7684\u4E0D\u8BA1\u8D39\u7528\uFF0C\u53EA\u8BA1\u6B21\u6570\u3002",children:jsxs2(SettingsRows,{label:"\u7528\u91CF",children:[data.people.map(p=>line(p.actor,name(p.actor),"\u53D1\u8D77\u7684\u4FEE\u6539",p.usage)),line("auto","\u7CFB\u7EDF\u81EA\u52A8\u505A\u7684","\u7B2C\u4E00\u7248\u4EA7\u51FA\uFF0C\u6216\u4E0A\u4E00\u9636\u6BB5\u6709\u65B0\u5185\u5BB9\u65F6\u91CD\u505A",data.auto),line("totals","\u5408\u8BA1","\u5168\u90E8\u56DE\u5408",data.totals)]})})}export{MembersTab,src_default as default};
|
|
1
|
+
import"../../chunks/chunk-JFPQMFKF.js";import{Avatar,ErrorNote as ErrorNote2,PaneHeader,SettingsNoAccess,SettingsReadError,SettingsSaveState,directoryFor,instrumentOf,isForbidden,memberOrder,reactMount,roleLabel,useCtxData,useMembers,useRoute}from"@kanyun-ai-infra/band-plugin-react";import{projectPath}from"@kanyun-ai-infra/band-plugin-sdk";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect,useMemo,useState as useState2}from"react";import{ErrorNote,PersonSearch}from"@kanyun-ai-infra/band-plugin-react";import{useId,useState}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{SettingsDanger,SettingsDangerRow,SettingsDialog,SettingsEmpty,SettingsFacts,SettingsHead,SettingsLoading,SettingsRow,SettingsRows,SettingsSection}from"@kanyun-ai-infra/band-plugin-react";import{Fragment,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css="/* src/members.css */\n.band-members {\n list-style: none;\n margin: 0;\n padding: 0 16px 12px;\n display: grid;\n gap: 8px;\n font-size: var(--fs-ui);\n}\n.band-members-item {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.band-members-name {\n flex: 0 0.2 auto;\n min-width: 2em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-members-role {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-members-cost {\n color: var(--muted);\n font-size: var(--fs-dense);\n white-space: nowrap;\n}\n.band-members-form {\n flex: 1 1 100%;\n display: grid;\n gap: 12px;\n font-size: var(--fs-row);\n}\n.band-members-form:where(fieldset) {\n margin: 0;\n padding: 0;\n border: 0;\n min-width: 0;\n}\n.band-members-form:where(.band-members-row > *) {\n padding-left: 36px;\n}\n.band-members-form p {\n margin: 0;\n}\n.band-members-field {\n position: relative;\n display: grid;\n gap: 4px;\n max-width: 360px;\n}\n.band-members-tags {\n margin: 0;\n padding: 0;\n border: 0;\n display: flex;\n flex-wrap: wrap;\n gap: 4px 16px;\n}\n.band-members-tags legend {\n padding: 0;\n margin-bottom: 4px;\n}\n.band-members-label {\n font-size: var(--fs-row);\n color: var(--ink);\n}\n.band-members-hint {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-members-actions {\n display: flex;\n gap: 8px;\n}\n";let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-members"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-members");document.head.prepend(el)}el.textContent=css}var MANAGEMENT_LABEL={owner:"\u521B\u5EFA\u4EBA",maintainer:"\u7BA1\u7406\u5458",member:"\u6210\u5458"};var RANK={member:1,maintainer:2};function grantable(self,current){const all=["member","maintainer"];if(!self)return all;const now=current===void 0?0:current==="owner"?3:RANK[current];return all.filter(r=>RANK[r]<=now)}var failed=e=>e instanceof Error?e.message:String(e);function TagChoices({options,value,onChange,disabled}){return jsxs("fieldset",{className:"band-members-tags",children:[jsxs("legend",{children:["\u89D2\u8272 ",jsx("span",{className:"band-members-hint",children:"\u5FC5\u586B\uFF0C\u81F3\u5C11\u4E00\u4E2A"})]}),options.map(o=>jsxs("label",{className:"choice sm",children:[jsx("input",{type:"checkbox",className:"checkbox",checked:value.includes(o.name),disabled,onChange:e=>onChange(e.target.checked?[...value,o.name]:value.filter(r=>r!==o.name))}),o.label??o.name]},o.name))]})}function RoleSelect({value,options,onChange,disabled,fill}){const id=useId();return jsxs("div",{className:"band-members-field",children:[jsx("label",{htmlFor:id,children:"\u7BA1\u7406\u89D2\u8272"}),jsx("select",{id,className:fill?"field fill":"field",value,disabled:disabled||options.length<2,onChange:e=>onChange(e.target.value==="maintainer"?"maintainer":"member"),children:options.map(r=>jsx("option",{value:r,children:MANAGEMENT_LABEL[r]},r))})]})}function InviteForm({api,directory,settings,onDone,onCancel}){const[picked,setPicked]=useState(null);const[tags,setTags]=useState([]);const[role,setRole]=useState("member");const[busy,setBusy]=useState(false);const[error,setError]=useState(null);const disabled=settings.people.map(p=>({id:p.userId,reason:"\u5DF2\u7ECF\u662F\u6210\u5458\uFF0C\u5728\u5217\u8868\u91CC\u6539\u89D2\u8272"}));async function submit(){if(!picked)return setError("\u8FD8\u6CA1\u9009\u4EBA\uFF1A\u641C\u59D3\u540D\u3001ldap \u6216\u90E8\u95E8");if(settings.people.some(p=>p.userId===picked.id))return setError(`${picked.id} \u5DF2\u7ECF\u662F\u6210\u5458\uFF0C\u5728\u5217\u8868\u91CC\u6539\u89D2\u8272`);if(tags.length===0)return setError("\u8FD8\u5DEE\u89D2\u8272\u6CA1\u9009\uFF1A\u81F3\u5C11\u9009\u4E00\u4E2A");setBusy(true);setError(null);try{const next=await api.set({userId:picked.id,roles:tags,role,...picked.inBand===false?{displayName:picked.name}:{}});onDone(next)}catch(e){setError(`\u9080\u8BF7\u5931\u8D25\uFF1A${failed(e)}`)}finally{setBusy(false)}}return jsxs("form",{className:"band-members-form","aria-label":"\u9080\u8BF7\u6210\u5458",onSubmit:e=>{e.preventDefault();void submit()},children:[jsxs("div",{className:"band-members-field",children:[jsxs("span",{className:"band-members-label",children:["\u9080\u8BF7\u8C01 ",jsx("span",{className:"band-members-hint",children:"\u5FC5\u586B"})]}),jsx(PersonSearch,{label:"\u9080\u8BF7\u8C01",directory,picked:picked?[picked]:[],onPick:p=>{setPicked(p[0]??null);setError(null)},onUnpick:()=>setPicked(null),disabled,allowUnknown:true,busy})]}),jsx(TagChoices,{options:settings.roles,value:tags,onChange:setTags,disabled:busy}),jsx(RoleSelect,{value:role,options:grantable(false,void 0),onChange:setRole,disabled:busy,fill:true}),jsx(ErrorNote,{children:error}),jsxs("div",{className:"band-members-actions",children:[jsx("button",{type:"submit",className:"btn primary sm",disabled:busy||!picked,children:busy?"\u6B63\u5728\u9080\u8BF7\u2026":"\u9080\u8BF7"}),jsx("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function EditPerson({api,settings,person,self,onDone,onCancel}){const known=new Set(settings.roles.map(r=>r.name));const stale=person.roles.filter(r=>!known.has(r));const[tags,setTags]=useState(person.roles.filter(r=>known.has(r)));const[role,setRole]=useState(person.role==="maintainer"?"maintainer":"member");const[busy,setBusy]=useState(false);const[error,setError]=useState(null);const owner=person.role==="owner";async function save(){if(tags.length===0)return setError("\u8FD8\u5DEE\u89D2\u8272\u6CA1\u9009\uFF1A\u81F3\u5C11\u9009\u4E00\u4E2A");setBusy(true);setError(null);try{onDone(await api.set({userId:person.userId,roles:tags,...owner?{}:{role}}))}catch(e){setError(failed(e))}finally{setBusy(false)}}return jsxs("form",{className:"band-members-form","aria-label":`\u6539 ${person.displayName} \u7684\u89D2\u8272`,onSubmit:e=>{e.preventDefault();void save()},children:[jsx(TagChoices,{options:settings.roles,value:tags,onChange:setTags,disabled:busy}),stale.length>0&&jsxs("p",{className:"band-members-hint",children:["\u5DE5\u574A\u91CC\u5DF2\u7ECF\u6CA1\u6709 ",stale.join("\u3001"),"\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u53BB\u6389\u3002"]}),owner?jsx("p",{className:"band-members-hint",children:"\u521B\u5EFA\u4EBA\u7684\u7BA1\u7406\u89D2\u8272\u4E0D\u5728\u8FD9\u91CC\u6539\u3002"}):jsx(RoleSelect,{value:role,options:grantable(self,person.role),onChange:setRole,disabled:busy}),jsx(ErrorNote,{children:error}),jsxs("div",{className:"band-members-actions",children:[jsx("button",{type:"submit",className:"btn primary sm",disabled:busy,children:busy?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"}),jsx("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}var PAGE="@kanyun-ai-infra/band-settings/settings";var SECTION="members";var NEW_ITEM="new";var DESC="\u4EBA\u548C Agent \u90FD\u5728\u8FD9\u91CC\u3002\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3001\u6539\u89D2\u8272\u3002";var DESC_READONLY="\u4EBA\u548C Agent \u90FD\u5728\u8FD9\u91CC\u3002";var src_default=definePlugin({surfaces:{members:reactMount(ctx=>jsx2(Members,{ctx})),"settings-tab":reactMount(ctx=>jsx2(MembersTab,{ctx}))}});function Members({ctx}){const members=useMembers(ctx);const order=memberOrder(members);const peers=members.filter(m=>m.actor.kind==="agent").map(m=>m.actor.id);return jsxs2("section",{"aria-label":"\u6210\u5458",children:[jsx2(PaneHeader,{title:jsxs2(Fragment,{children:["\u6210\u5458 ",members.length]})}),jsx2("ul",{className:"band-members",children:members.map(m=>jsxs2("li",{className:"band-members-item",children:[jsx2(Avatar,{id:m.actor.id,name:m.displayName,agent:m.actor.kind==="agent",...m.actor.kind==="agent"?{instrument:instrumentOf(m.actor.id,peers)}:{},order,decorative:true}),jsx2("span",{className:"band-members-name",title:m.displayName,children:m.displayName}),jsx2("span",{className:"band-members-role",children:roleLabel(members,m.actor.id)})]},m.actor.id))})]})}function params(ctx,item){return{project:ctx.project.id,...ctx.project.workshop?{workshop:ctx.project.workshop}:{},tab:SECTION,...item?{item}:{}}}function href(ctx,item){return projectPath(ctx.project,"settings",...item?[SECTION,item]:[SECTION])}var FRESH_KEY="band-members:fresh:";function markFresh(projectId,userId){try{globalThis.sessionStorage?.setItem(FRESH_KEY+projectId,userId)}catch{}}function useFresh(projectId){const[id]=useState2(()=>{try{return globalThis.sessionStorage?.getItem(FRESH_KEY+projectId)??null}catch{return null}});useEffect(()=>{if(id===null)return;try{globalThis.sessionStorage?.removeItem(FRESH_KEY+projectId)}catch{}},[id,projectId]);return id}function MembersTab({ctx}){const api=ctx.memberSettings;const route=useRoute(ctx);const item=route.params.item;const loaded=useCtxData(ctx,async()=>{let members2;try{members2=await ctx.members.list()}catch(e){if(isForbidden(e))return{kind:"forbidden"};throw e}let settings2=null;let settingsError=null;if(api){try{settings2=await api.get()}catch(e){if(!isForbidden(e))settingsError=e instanceof Error?e.message:String(e)}}return{kind:"ok",members:members2,settings:settings2,settingsError}},[api],["member.*","run.started"]);const[fresh,setFresh]=useState2(null);const data=loaded.data;const read=data?.kind==="ok"?data:null;const members=read?.members??[];const baseSettings=read?.settings??null;const settings=fresh&&fresh.base===baseSettings?fresh.next:baseSettings;const order=memberOrder(members);const people=members.filter(m=>m.actor.kind!=="agent");const agents=members.filter(m=>m.actor.kind==="agent");const peers=agents.map(m=>m.actor.id);const manage=api&&settings?.canManage?{api,settings}:null;const directory=useMemo(()=>directoryFor(ctx.people,q=>api?api.searchUsers(q):Promise.resolve([])),[ctx.people,api]);const settingsFailed=read?.settingsError!=null;const settingsDenied=settings!=null&&!settings.canManage;const person=id=>settings?.people.find(p=>p.userId===id);const done=next=>setFresh({base:baseSettings,next});const freshId=useFresh(ctx.project.id);const goList=()=>ctx.app.navigate({page:PAGE,params:params(ctx)});if(data===void 0){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),loaded.error?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u6CA1\u8BFB\u51FA\u6765\uFF1A",loaded.error]}):jsx2(SettingsLoading,{text:"\u6B63\u5728\u8BFB\u53D6\u6210\u5458\u2026"})]})}if(data.kind==="forbidden"){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),jsx2(SettingsNoAccess,{title:"\u6CA1\u6709\u6743\u9650\u770B\u8FD9\u4E2A\u9879\u76EE\u7684\u6210\u5458",children:"\u53EA\u6709\u9879\u76EE\u6210\u5458\u80FD\u770B\u3002\u8981\u770B\u7684\u8BDD\uFF0C\u8BF7\u8054\u7CFB\u9879\u76EE\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u6765\u3002"})]})}if(item===NEW_ITEM){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6DFB\u52A0\u6210\u5458",desc:DESC}),manage?jsx2(InviteForm,{api:manage.api,directory,settings:manage.settings,onDone:next=>{const before=new Set(manage.settings.people.map(p=>p.userId));const added=next.people.find(p=>!before.has(p.userId));done(next);if(added)markFresh(ctx.project.id,added.userId);goList()},onCancel:goList}):settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3002"})]})}if(item){const view=members.find(m=>m.actor.kind!=="agent"&&m.actor.id===item);const p=person(item);if(!view){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458"}),jsx2("p",{className:"band-sf-muted",children:"\u8FD9\u4E2A\u9879\u76EE\u91CC\u6CA1\u6709\u8FD9\u4E2A\u4EBA\uFF1B\u53EF\u80FD\u5DF2\u7ECF\u88AB\u79FB\u51FA\u3002"})]})}return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:view.displayName,desc:"\u7BA1\u7406\u5458\u80FD\u6539\u8FD9\u4E2A\u4EBA\u7684\u89D2\u8272\uFF1B\u521B\u5EFA\u4EBA\u7684\u7BA1\u7406\u89D2\u8272\u4E0D\u5728\u8FD9\u91CC\u6539\u3002"}),settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):settingsDenied?jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u6539\u3002"}):null,jsx2(SettingsFacts,{items:[{key:"\u540D\u5B57",value:view.displayName},{key:"\u7BA1\u7406\u89D2\u8272",value:p?MANAGEMENT_LABEL[p.role]:"\u6210\u5458"},{key:"\u4E1A\u52A1\u6807\u7B7E",value:settings&&p?tagText(settings,p):roleLabel(members,view.actor.id)||"\u6210\u5458"}]}),manage&&p?jsx2(SettingsSection,{title:"\u89D2\u8272",children:jsx2(EditPerson,{api:manage.api,settings:manage.settings,person:p,self:view.actor.id===ctx.member.id,onDone:done,onCancel:goList})}):null,manage&&p&&p.role!=="owner"?jsx2(SettingsDanger,{children:jsx2(SettingsDangerRow,{title:"\u79FB\u51FA\u9879\u76EE",note:`${view.displayName} \u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF1B\u8FD9\u4E2A\u4EBA\u9009\u5230\u9879\u76EE\u4E0A\u7684\u914D\u7F6E\u81EA\u52A8\u6E05\u7A7A\uFF0C\u8BB0\u5BA1\u8BA1\u3002`,action:jsx2(RemoveButton,{ctx,api:manage.api,person:p,onDone:goList})})}):null]})}const addHref=href(ctx,NEW_ITEM);const addAction=manage||settingsFailed?jsx2("a",{className:"btn primary",href:addHref,onClick:e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;e.preventDefault();ctx.app.navigate({page:PAGE,params:params(ctx,NEW_ITEM)})},children:"\u6DFB\u52A0\u6210\u5458"}):void 0;if(members.length===0){return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:DESC}),settingsFailed?jsxs2(SettingsReadError,{retry:loaded.reload,children:["\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",read?.settingsError]}):null,jsx2(SettingsEmpty,{action:addAction,children:"\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u6709\u6210\u5458\u3002"})]})}return jsxs2(Fragment,{children:[jsx2(SettingsHead,{title:"\u6210\u5458",desc:settingsDenied?DESC_READONLY:DESC,action:addAction}),settingsDenied?jsx2("p",{className:"band-sf-muted",children:"\u53EA\u6709\u9879\u76EE\u7BA1\u7406\u5458\u80FD\u52A0\u4EBA\u3001\u6539\u89D2\u8272\u3002"}):null,jsx2(ErrorNote2,{retry:loaded.reload,children:loaded.error?`\u6210\u5458\u6CA1\u8BFB\u51FA\u6765\uFF1A${loaded.error}`:read?.settingsError?`\u6210\u5458\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A${read.settingsError}`:null}),jsxs2(SettingsRows,{label:`\u6210\u5458 ${members.length}`,children:[people.map(m=>{const p=person(m.actor.id);return jsx2(SettingsRow,{title:m.displayName,meta:settings&&p?[`${MANAGEMENT_LABEL[p.role]} \xB7 ${tagText(settings,p)}`]:[roleLabel(members,m.actor.id)||"\u6210\u5458"],href:href(ctx,m.actor.id),isNew:m.actor.id===freshId,...settings||settingsFailed?{onOpen:()=>ctx.app.navigate({page:PAGE,params:params(ctx,m.actor.id)})}:{}},`human:${m.actor.id}`)}),agents.map(m=>jsx2(SettingsRow,{title:m.displayName,meta:[m.actor.id===ctx.project.agent?"\u9ED8\u8BA4 Agent":"Agent"]},`agent:${m.actor.id}`))]}),settingsDenied?null:jsx2(UsageNote,{ctx,members})]})}function RemoveButton({ctx,api,person,onDone}){const[open,setOpen]=useState2(false);const[busy,setBusy]=useState2(false);const[error,setError]=useState2("");const self=person.userId===ctx.member.id;const remove=async()=>{if(busy)return;setBusy(true);setError("");try{await api.remove(person.userId);onDone()}catch(e){setError(`\u6CA1\u79FB\u6210\uFF1A${e instanceof Error?e.message:String(e)}`)}finally{setBusy(false)}};return jsxs2(Fragment,{children:[jsx2("button",{type:"button",className:"btn danger",onClick:()=>setOpen(true),children:"\u79FB\u51FA\u9879\u76EE"}),open?jsxs2(SettingsDialog,{title:`\u628A${person.displayName}\u79FB\u51FA\u9879\u76EE\uFF1F`,onClose:()=>setOpen(false),actions:jsxs2(Fragment,{children:[jsx2("button",{type:"button",className:"btn",onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),jsx2("button",{type:"button",className:"btn primary",disabled:busy,onClick:()=>void remove(),children:busy?"\u6B63\u5728\u79FB\u9664\u2026":"\u79FB\u51FA\u9879\u76EE"})]}),children:[jsxs2("ul",{children:[jsx2("li",{children:self?"\u4F60\u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF0C\u8981\u522B\u7684\u7BA1\u7406\u5458\u518D\u52A0\u56DE\u6765":`${person.displayName} \u4E0D\u518D\u80FD\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE`}),jsx2("li",{children:"\u8FD9\u4E2A\u4EBA\u9009\u5230\u9879\u76EE\u4E0A\u7684\u914D\u7F6E\u81EA\u52A8\u6E05\u7A7A\uFF0C\u8BB0\u5BA1\u8BA1"}),jsx2("li",{children:"\u5DF2\u6709\u7684\u8BC4\u8BBA\u4FDD\u7559\u7F72\u540D"})]}),error?jsx2(SettingsSaveState,{failed:error}):null]}):null]})}function tagText(settings,p){const label=r=>settings.roles.find(o=>o.name===r)?.label??r;return p.roles.map(label).join("\u3001")||"\u6210\u5458"}function UsageNote({ctx,members}){const usage=useCtxData(ctx,()=>ctx.members.usage(),[],["turn.delivered","turn.failed"]);const data=usage.data;if(!data)return null;const name=actor=>members.find(m=>m.actor.kind==="human"&&m.actor.id===actor)?.displayName??"\u5DF2\u79BB\u5F00\u7684\u6210\u5458";const money=costUsd=>costUsd===void 0?"\u2014":costUsd<.01?"\u4E0D\u5230 $0.01":`$${costUsd.toFixed(2)}`;const line=(key,label,sub,u)=>jsx2(SettingsRow,{title:label,meta:[sub],actions:jsxs2("span",{className:"band-members-cost",children:[u.turns," \u4E2A\u56DE\u5408 \xB7 ",money(u.costUsd)]})},key);return jsx2(SettingsSection,{title:"\u7528\u91CF",desc:"\u53EA\u505A\u8BB0\u5F55\uFF0C\u4E0D\u8BBE\u4E0A\u9650\u3002\u4E2D\u9014\u505C\u4E0B\u7684\u4E0D\u8BA1\u8D39\u7528\uFF0C\u53EA\u8BA1\u6B21\u6570\u3002",children:jsxs2(SettingsRows,{label:"\u7528\u91CF",children:[data.people.map(p=>line(p.actor,name(p.actor),"\u53D1\u8D77\u7684\u4FEE\u6539",p.usage)),line("auto","\u7CFB\u7EDF\u81EA\u52A8\u505A\u7684","\u7B2C\u4E00\u7248\u4EA7\u51FA\uFF0C\u6216\u4E0A\u4E00\u9636\u6BB5\u6709\u65B0\u5185\u5BB9\u65F6\u91CD\u505A",data.auto),line("totals","\u5408\u8BA1","\u5168\u90E8\u56DE\u5408",data.totals)]})})}export{MembersTab,src_default as default};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanyun-ai-infra/band-members",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "成员与角色列表,区分人和 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": "^2.
|
|
10
|
+
"@kanyun-ai-infra/band-plugin-sdk": "^2.1.0",
|
|
11
11
|
"react": "^19.0.0",
|
|
12
12
|
"react-dom": "^19.0.0",
|
|
13
13
|
"@kanyun-ai-infra/band-project": "*",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ARTIFACT_DIALOG,ArtifactPage,AwaitingFile,DEFAULT_LAYOUT,FirstVersion,HeaderVersion,LOCKED_REFS2,PROJECT,PROJECT_HEAD,ProjectPage,ReviewPage,SLOTS,StageReplay,activePair,approvalPlaced,artifactCaps,candidateGroup,candidateGroupLabel,candidateLabel,isLatestVersion,pickedOf,place,readStageForm,resolvePanel2,shortName,src_default,stageDoer,stageOutputs}from"../../chunks/chunk-
|
|
1
|
+
import{ARTIFACT_DIALOG,ArtifactPage,AwaitingFile,DEFAULT_LAYOUT,FirstVersion,HeaderVersion,LOCKED_REFS2,PROJECT,PROJECT_HEAD,ProjectPage,ReviewPage,SLOTS,StageReplay,activePair,approvalPlaced,artifactCaps,candidateGroup,candidateGroupLabel,candidateLabel,isLatestVersion,pickedOf,place,readStageForm,resolvePanel2,shortName,src_default,stageDoer,stageOutputs}from"../../chunks/chunk-7XYETT7C.js";import"../../chunks/chunk-N6N56MWF.js";import{DOCK_SERVICE,mountDockButtons}from"../../chunks/chunk-TWQQ2CCT.js";import"../../chunks/chunk-JFPQMFKF.js";export{ARTIFACT_DIALOG,ArtifactPage,AwaitingFile,DEFAULT_LAYOUT,DOCK_SERVICE,FirstVersion,HeaderVersion,LOCKED_REFS2 as LOCKED_REFS,PROJECT,PROJECT_HEAD,ProjectPage,ReviewPage,SLOTS,StageReplay,activePair,approvalPlaced,artifactCaps,candidateGroup,candidateGroupLabel,candidateLabel,src_default as default,isLatestVersion,mountDockButtons,pickedOf,place,readStageForm,resolvePanel2 as resolvePanel,shortName,stageDoer,stageOutputs};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanyun-ai-infra/band-project",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
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": "^2.
|
|
10
|
+
"@kanyun-ai-infra/band-plugin-sdk": "^2.1.0",
|
|
11
11
|
"react": "^19.0.0",
|
|
12
12
|
"react-dom": "^19.0.0",
|
|
13
13
|
"@kanyun-ai-infra/band-shell": "*"
|