@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.
Files changed (54) hide show
  1. package/bundled/official/activity/package.json +1 -1
  2. package/bundled/official/approval/package.json +1 -1
  3. package/bundled/official/artifacts/package.json +1 -1
  4. package/bundled/official/chat/dist/index.js +1 -1
  5. package/bundled/official/chat/package.json +2 -2
  6. package/bundled/official/chunks/chunk-7XYETT7C.js +1 -0
  7. package/bundled/official/comment/package.json +1 -1
  8. package/bundled/official/header/package.json +1 -1
  9. package/bundled/official/home/dist/index.js +1 -1
  10. package/bundled/official/home/package.json +2 -2
  11. package/bundled/official/layouts/package.json +1 -1
  12. package/bundled/official/library/package.json +1 -1
  13. package/bundled/official/members/dist/index.js +1 -1
  14. package/bundled/official/members/package.json +2 -2
  15. package/bundled/official/memory/package.json +1 -1
  16. package/bundled/official/native/package.json +1 -1
  17. package/bundled/official/params-form/package.json +1 -1
  18. package/bundled/official/plugins/package.json +1 -1
  19. package/bundled/official/project/dist/index.js +1 -1
  20. package/bundled/official/project/package.json +2 -2
  21. package/bundled/official/queue/package.json +1 -1
  22. package/bundled/official/settings/dist/index.js +1 -1
  23. package/bundled/official/settings/package.json +2 -2
  24. package/bundled/official/shell/dist/index.js +1 -1
  25. package/bundled/official/shell/package.json +2 -2
  26. package/bundled/official/stages/package.json +1 -1
  27. package/bundled/official/threads/dist/index.js +1 -1
  28. package/bundled/official/threads/package.json +2 -2
  29. package/bundled/official/turn-bar/package.json +1 -1
  30. package/bundled/official/turn-trace/package.json +1 -1
  31. package/bundled/official/version-switch/dist/index.js +1 -1
  32. package/bundled/official/version-switch/package.json +1 -1
  33. package/bundled/official/viewer-entity/package.json +1 -1
  34. package/bundled/official/viewer-external/package.json +1 -1
  35. package/bundled/official/viewer-image/package.json +1 -1
  36. package/bundled/official/viewer-media/package.json +1 -1
  37. package/bundled/official/viewer-storyboard/package.json +1 -1
  38. package/bundled/official/viewer-text/package.json +1 -1
  39. package/bundled/official/viewer-tool/package.json +1 -1
  40. package/bundled/official/viewer-web/package.json +1 -1
  41. package/bundled/official/viewer-web-app/package.json +1 -1
  42. package/bundled/official/workshops/dist/index.js +2 -2
  43. package/bundled/official/workshops/package.json +2 -2
  44. package/bundled/tokens/components.css +1 -1
  45. package/dev-host/app.tsx +23 -7
  46. package/dev-host/host.css +7 -0
  47. package/dist/bin.js +1 -1
  48. package/dist/{chunk-Q2XJXNVH.js → chunk-FGPWXAOA.js} +151 -19
  49. package/dist/{dev-server-Q7NTJ3QD.js → dev-server-IBR3PKDE.js} +14 -1
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +1 -1
  52. package/package.json +5 -4
  53. package/src/inspector-default.ts +9 -0
  54. package/bundled/official/chunks/chunk-DIL5YSVK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{ParamFields,SUBMIT_SHORTCUT,commandEnter,missingRequiredFields,needsConfirm,schemaInitialValues,submittedValues}from"../../chunks/chunk-VL7UVRSN.js";import"../../chunks/chunk-JFPQMFKF.js";import{DEPLOY_RELEASE_NOTE,agentDisplayName,artifactTypeDisplayName as artifactTypeDisplayName2,isRondoAgent,roleDisplayName,stageDisplayName as stageDisplayName2}from"@kanyun-ai-infra/band-contracts";import{FIRST_MESSAGE_MAX,projectNameFromNeed}from"@kanyun-ai-infra/band-contracts/api";import{Avatar as Avatar4,ErrorNote as ErrorNote13,MODELS_FOR_PAGE,NoKeyNotice,REPO_URL_EXAMPLE,TargetRepoNote,WorkshopEmblem,WorkshopIcon,errorRepo,errorRequestAccessUrl,errorText as errorText9,gateWho,inline as inline2,instrumentOf,isModelRequired,isProvisionFailure,localDay as localDay2,reactMount,repoFieldHint,saveDraft,takeDraft,targetRepoErrorId,useAppData as useAppData5,withImeGuard as withImeGuard3}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{Fragment as Fragment17,useEffect as useEffect13,useId as useId8,useLayoutEffect,useMemo,useRef as useRef8,useState as useState15}from"react";import{ErrorNote,failedBecause,isForbidden}from"@kanyun-ai-infra/band-plugin-react";import{useCallback,useEffect,useState}from"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{SettingsDanger,SettingsDangerRow,SettingsDialog,SettingsSaveState,failedBecause as failedBecause2}from"@kanyun-ai-infra/band-plugin-react";import{useState as useState2}from"react";import{Fragment as Fragment2,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";import{Fragment as Fragment3,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";import{withImeGuard}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect2,useRef}from"react";import{useId}from"react";import{jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";import{ErrorNote as ErrorNote2,failedBecause as failedBecause3,isForbidden as isForbidden2,localDay}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback2,useEffect as useEffect3,useState as useState3}from"react";import{Fragment as Fragment4,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";import{Avatar,ErrorNote as ErrorNote3,PersonSearch,errorText}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect4,useState as useState4}from"react";import{jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";import{CUSTOM_MODEL_PRESET_ID}from"@kanyun-ai-infra/band-contracts/api";import{PROJECT_MODEL_HEADING,credentialOptionLabel,projectModelNote,provisionConsentText}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect5,useId as useId2,useState as useState5}from"react";import{Fragment as Fragment5,jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";import{Avatar as Avatar2,ErrorNote as ErrorNote4,errorText as errorText2,shortTime,useAppData}from"@kanyun-ai-infra/band-plugin-react";import{Fragment as Fragment6,useEffect as useEffect6,useId as useId3,useRef as useRef2,useState as useState6}from"react";import{Fragment as Fragment7,jsx as jsx8,jsxs as jsxs8}from"react/jsx-runtime";import{ErrorNote as ErrorNote6,SettingsActions,SettingsField,SettingsForm,SettingsPicks,SettingsSaveState as SettingsSaveState3,errorText as errorText3,useAppData as useAppData2}from"@kanyun-ai-infra/band-plugin-react";import{OFFICIAL_SCOPE}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect as useEffect8,useRef as useRef3,useState as useState8}from"react";import{WORKSHOP_PLUGIN_NAMES_MAX}from"@kanyun-ai-infra/band-contracts/api";import{ErrorNote as ErrorNote5,SettingsDialog as SettingsDialog2,SettingsSaveState as SettingsSaveState2,failedBecause as failedBecause4,isForbidden as isForbidden3}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback3,useEffect as useEffect7,useState as useState7}from"react";import{Fragment as Fragment8,jsx as jsx9,jsxs as jsxs9}from"react/jsx-runtime";import{Fragment as Fragment9,jsx as jsx10,jsxs as jsxs10}from"react/jsx-runtime";import{peopleDirectory}from"@kanyun-ai-infra/band-plugin-react";import{ErrorNote as ErrorNote7,errorText as errorText4,useAppData as useAppData3}from"@kanyun-ai-infra/band-plugin-react";import{useId as useId4,useRef as useRef4,useState as useState9}from"react";import{Fragment as Fragment10,jsx as jsx11,jsxs as jsxs11}from"react/jsx-runtime";import{ErrorNote as ErrorNote8,errorText as errorText5,isForbidden as isForbidden4}from"@kanyun-ai-infra/band-plugin-react";import{useState as useState10}from"react";import{Fragment as Fragment11,jsx as jsx12,jsxs as jsxs12}from"react/jsx-runtime";import{ErrorNote as ErrorNote9,PersonPicker,errorText as errorText6}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect9,useId as useId5,useRef as useRef5,useState as useState11}from"react";import{Fragment as Fragment12,jsx as jsx13,jsxs as jsxs13}from"react/jsx-runtime";import{artifactTypeDisplayName,stageDisplayName}from"@kanyun-ai-infra/band-contracts";import{LIVE_PREVIEW_POLL_MS}from"@kanyun-ai-infra/band-contracts/api";import{Avatar as Avatar3,ErrorNote as ErrorNote11,PromptInput as PromptInput2,emptyDraft as emptyDraft2,errorText as errorText8,failedBecause as failedBecause5,inline,isForbidden as isForbidden5,scrollIntoPanel,useAppData as useAppData4,useMessageList}from"@kanyun-ai-infra/band-plugin-react";import{withImeGuard as withImeGuard2}from"@kanyun-ai-infra/band-plugin-sdk";import{Fragment as Fragment14,useCallback as useCallback4,useEffect as useEffect11,useId as useId7,useRef as useRef6,useState as useState13}from"react";import{Fragment as Fragment13,jsx as jsx14,jsxs as jsxs14}from"react/jsx-runtime";import{ErrorNote as ErrorNote10,PromptInput,emptyDraft,errorText as errorText7}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect10,useId as useId6,useState as useState12}from"react";import{jsx as jsx15,jsxs as jsxs15}from"react/jsx-runtime";import{Fragment as Fragment15,jsx as jsx16,jsxs as jsxs16}from"react/jsx-runtime";import{ErrorNote as ErrorNote12,UPGRADE_TEXT,failedBecause as failedBecause6,isForbidden as isForbidden6}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback5,useEffect as useEffect12,useRef as useRef7,useState as useState14}from"react";import{Fragment as Fragment16,jsx as jsx17,jsxs as jsxs17}from"react/jsx-runtime";import{Fragment as Fragment18,jsx as jsx18,jsxs as jsxs18}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css='/* src/workshop-edit.css */\n.band-workshop-edit {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 24px 32px 16px;\n overflow: hidden;\n color: var(--ink);\n}\n.band-workshop-edit h1 {\n font-size: var(--fs-title);\n margin: 8px 0;\n}\n.band-workshop-edit h2 {\n font-size: var(--fs-body);\n margin: 0 0 12px;\n}\n.band-workshop-edit h3,\n.band-workshop-edit h4 {\n font-size: var(--fs-dense);\n margin: 0 0 10px;\n}\n.band-workshop-edit p {\n margin: 8px 0;\n line-height: 1.65;\n}\n.band-workshop-edit-head {\n display: flex;\n justify-content: space-between;\n gap: 20px;\n flex: 0 0 auto;\n}\n.band-workshop-edit-lock {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n color: var(--muted);\n font-size: var(--fs-caption);\n}\n.band-workshop-edit-actions {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 55%;\n font-size: var(--fs-caption);\n}\n.band-workshop-edit-actions > .band-workshops-hint {\n flex-basis: 100%;\n text-align: right;\n}\n.band-workshop-edit-entry {\n display: grid;\n gap: 6px;\n}\n.band-workshop-edit-body {\n flex: 1;\n min-height: 0;\n display: grid;\n grid-template-columns: min(400px, 42%) minmax(0, 1fr);\n gap: 28px;\n}\n.band-workshop-edit-chat,\n.band-workshop-edit-side,\n.band-workshop-edit-diff,\n.band-workshop-edit-trial {\n display: flex;\n flex-direction: column;\n min-height: 0;\n min-width: 0;\n}\n.band-workshop-edit-side {\n border-left: 1px solid var(--rule);\n padding-left: 24px;\n gap: 12px;\n}\n.band-workshop-edit-diff,\n.band-workshop-edit-trial {\n flex: 1;\n}\n.band-workshop-edit-diff[hidden],\n.band-workshop-edit-trial[hidden] {\n display: none;\n}\n.band-workshop-edit-side-tabs {\n align-self: flex-start;\n flex: 0 0 auto;\n}\n.band-workshop-edit-messages,\n.band-workshop-edit-diff-scroll {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 4px 8px 16px 0;\n}\n.band-workshop-edit-empty {\n margin: 48px auto;\n max-width: 440px;\n}\n.band-workshop-edit-empty p {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshop-edit-empty .btn {\n white-space: normal;\n text-align: left;\n}\n.band-workshop-edit-user {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 16px;\n margin: 16px 0 16px 40px;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-who {\n display: flex;\n align-items: center;\n gap: 7px;\n font-size: var(--fs-caption);\n margin: 10px 0;\n}\n.band-workshop-edit-receipt {\n background: var(--panel);\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n padding: 16px;\n margin-bottom: 20px;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-progress {\n margin: 0;\n padding: 0 0 0 20px;\n color: var(--muted);\n}\n.band-workshop-edit-progress li {\n padding: 4px 0;\n}\n.band-workshop-edit-progress [aria-current=step] {\n color: var(--accent-text);\n}\n.band-workshop-edit-issues {\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n color: var(--bad);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n padding-left: 16px;\n}\n.band-workshop-edit-changes {\n padding: 0;\n margin: 0 0 16px;\n list-style: none;\n}\n.band-workshop-edit-changes button {\n font: inherit;\n font-size: var(--fs-dense);\n text-align: left;\n padding: 8px 0;\n color: var(--ink);\n background: none;\n border: 0;\n cursor: pointer;\n}\n.band-workshop-edit-changes button:hover {\n text-decoration: underline;\n}\n.band-workshop-edit-changes .band-workshop-edit-file-row {\n font-size: var(--fs-dense);\n padding: 4px 0;\n}\n.band-workshop-edit-changes code {\n font-family: var(--mono);\n font-size: var(--fs-caption);\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-file-row details {\n margin: 2px 0;\n}\n.band-workshop-edit-file-row summary {\n cursor: pointer;\n padding: 2px 0;\n}\n.band-workshop-edit-file-row details[open] summary {\n color: var(--muted);\n}\n.band-workshop-edit-file-note {\n margin: 4px 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit-file-diff {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 8px;\n margin: 6px 0 10px;\n}\n@media (min-width: 1200px) {\n .band-workshop-edit-file-diff {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n}\n.band-workshop-edit-file-diff h5 {\n margin: 0 0 4px;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit-file-diff pre {\n margin: 0;\n padding: 10px;\n max-height: 320px;\n overflow: auto;\n overscroll-behavior: contain;\n background: var(--fill);\n border-radius: var(--r-lg);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-views,\n.band-workshop-edit-others {\n margin-top: 24px;\n}\n.band-workshop-edit-view-plugin h4 {\n margin: 8px 0 2px;\n color: var(--muted);\n}\n.band-workshop-edit-view-plugin .band-workshop-edit-changes {\n margin-bottom: 4px;\n}\n.band-workshop-edit-preview {\n margin-top: 8px;\n}\n.band-workshop-edit-preview-open {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n}\n.band-workshop-edit-preview-label {\n font-size: var(--fs-dense);\n white-space: nowrap;\n}\n.band-workshop-edit-preview-open .field {\n flex: 1;\n min-width: 140px;\n width: auto;\n}\n.band-workshop-edit-comparison {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 20px;\n margin-top: 16px;\n}\n.band-workshop-edit-comparison > section {\n min-width: 0;\n}\n.band-workshop-edit-comparison .band-workshops-layer {\n flex-direction: column;\n}\n.band-workshop-edit-comparison .band-workshops-node {\n min-width: 0;\n background: var(--panel);\n}\n.band-workshop-edit-comparison .band-workshops-node.agent b {\n color: var(--ink);\n}\n.band-workshop-edit-comparison .band-workshops-node.is-changed {\n border: 2px solid var(--ink);\n}\n.band-workshop-edit-comparison .band-workshops-node.is-removed {\n border-style: dashed;\n}\n.band-workshop-edit-comparison .band-workshops-node.is-removed b {\n text-decoration: line-through;\n}\n.band-workshop-edit-comparison .band-workshops-node.is-highlighted {\n outline: 2px solid var(--accent);\n outline-offset: 3px;\n}\n.band-workshop-edit-mark {\n font-size: var(--fs-caption);\n font-weight: 600;\n}\n.band-workshop-edit-roles {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 14px 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit .band-workshop-edit-pane-switch,\n.band-workshop-edit .band-workshop-edit-compare-switch {\n display: none;\n}\n@media (max-width: 860px) {\n .band-workshop-edit {\n padding: 12px;\n gap: 10px;\n }\n .band-workshop-edit-head {\n flex-direction: column;\n gap: 8px;\n }\n .band-workshop-edit h1 {\n font-size: var(--fs-title);\n }\n .band-workshop-edit-actions {\n max-width: 100%;\n justify-content: flex-start;\n }\n .band-workshop-edit-actions > span {\n flex-basis: 100%;\n }\n .band-workshop-edit-actions > .band-workshops-hint {\n text-align: left;\n }\n .band-workshop-edit .band-workshop-edit-pane-switch,\n .band-workshop-edit .band-workshop-edit-compare-switch {\n display: flex;\n flex-shrink: 0;\n }\n .band-workshop-edit-body {\n display: flex;\n }\n .band-workshop-edit-body > section,\n .band-workshop-edit-body > .band-workshop-edit-side {\n flex: 1;\n }\n .band-workshop-edit-body[data-pane=chat] > .band-workshop-edit-side,\n .band-workshop-edit-body:not([data-pane=chat]) > .band-workshop-edit-chat {\n display: none;\n }\n .band-workshop-edit .band-workshop-edit-side-tabs {\n display: none;\n }\n .band-workshop-edit-side {\n border: 0;\n padding-left: 0;\n }\n .band-workshop-edit-comparison {\n display: block;\n }\n .band-workshop-edit-comparison[data-show=before] > [data-side=after],\n .band-workshop-edit-comparison[data-show=after] > [data-side=before] {\n display: none;\n }\n .band-workshop-edit-empty {\n margin: 20px 0;\n }\n}\n.band-workshop-edit-comparison .band-workshops-layer > li > .band-workshops-node {\n flex: 1;\n}\n.band-workshop-edit .band-workshop-edit-compare-switch[hidden] {\n display: none;\n}\n.band-workshop-edit-comparison[data-empty=true] {\n grid-template-columns: minmax(0, 1fr);\n}\n.band-workshop-edit-comparison[data-empty=true] > [data-side=before] {\n display: none;\n}\n.band-workshop-edit-comparison[data-empty=true] > [data-side=after] {\n display: block;\n}\n.band-workshop-edit > [role=alert] {\n max-height: 120px;\n overflow: auto;\n overscroll-behavior: contain;\n flex-shrink: 0;\n}\n.band-workshop-edit-agent {\n display: grid;\n gap: 12px;\n padding-bottom: 24px;\n}\n.band-workshop-edit-agent .band-workshop-edit-changes {\n margin: 0;\n}\n.band-workshop-edit-agent .band-workshop-edit-changes li {\n padding: 6px 0;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-file {\n min-width: 0;\n}\n.band-workshop-edit-file h4 {\n display: flex;\n align-items: baseline;\n gap: 8px;\n margin: 0 0 6px;\n}\n.band-workshop-edit-lines {\n margin: 0;\n padding: 8px 0;\n overflow-x: auto;\n background: var(--sunk);\n border-radius: var(--r);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n line-height: 1.6;\n}\n.band-workshop-edit-line,\n.band-workshop-edit-fold {\n display: block;\n padding: 0 10px;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-sign {\n display: inline-block;\n width: 1.5em;\n font-weight: 600;\n}\n.band-workshop-edit-line[data-kind=add] {\n background: var(--fill-2);\n}\n.band-workshop-edit-line[data-kind=del] {\n color: var(--muted);\n text-decoration: line-through;\n}\n.band-workshop-edit-fold {\n color: var(--muted);\n}\n.band-workshop-trial {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n.band-workshop-trial-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-between;\n gap: 8px 16px;\n flex: 0 0 auto;\n}\n.band-workshop-trial-status {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 0;\n font-size: var(--fs-dense);\n color: var(--muted);\n min-width: 0;\n}\n.band-workshop-trial-pick {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--fs-caption);\n color: var(--muted);\n min-width: 0;\n}\n.band-workshop-trial-frame {\n flex: 1 0 auto;\n min-height: 460px;\n position: relative;\n display: flex;\n flex-direction: column;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n overflow: hidden;\n background: var(--sunk);\n}\n.band-workshop-trial-screen {\n position: absolute;\n inset: 0;\n overflow: hidden;\n}\n.band-workshop-trial-screen iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: 0;\n background: var(--panel);\n}\n.band-workshop-trial .band-workshop-trial-narrow {\n display: none;\n}\n.band-workshop-trial-frame > .band-workshop-trial-wide {\n position: absolute;\n right: 8px;\n bottom: 8px;\n background: var(--panel);\n box-shadow: var(--shadow-card);\n}\n.band-workshop-trial-rest {\n flex: 1;\n align-content: center;\n padding: 32px 16px;\n}\n.band-workshop-trial-rest b {\n color: var(--ink);\n font-weight: 500;\n}\n.band-workshop-trial-rest span {\n max-width: 44ch;\n}\n.band-workshop-trial-try {\n flex: 0 0 auto;\n display: grid;\n gap: 10px;\n}\n.band-workshop-edit .band-workshop-trial-caption {\n margin: 0;\n font-size: var(--fs-caption);\n font-weight: 400;\n color: var(--muted);\n}\n.band-workshop-trial-run {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 14px;\n display: grid;\n gap: 6px;\n justify-items: start;\n font-size: var(--fs-dense);\n}\n.band-workshop-trial-run header {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n}\n.band-workshop-trial-run p {\n margin: 0;\n}\n.band-workshop-trial-meta {\n color: var(--muted);\n font-size: var(--fs-caption);\n}\n@media (max-width: 860px) {\n .band-workshop-trial-frame {\n min-height: 0;\n flex: 0 0 auto;\n border: 0;\n background: none;\n }\n .band-workshop-trial-frame iframe {\n display: none;\n }\n .band-workshop-trial .band-workshop-trial-frame > .band-workshop-trial-wide {\n display: none;\n }\n .band-workshop-trial .band-workshop-trial-narrow {\n display: inline-flex;\n align-self: flex-start;\n }\n}\n.band-workshop-edit .band-workshop-edit-rail {\n display: none;\n}\n@media (min-width: 861px) {\n .band-workshop-edit-body[data-fold=chat] {\n grid-template-columns: auto minmax(0, 1fr);\n }\n .band-workshop-edit-body[data-fold=chat] > .band-workshop-edit-chat {\n display: none;\n }\n .band-workshop-edit .band-workshop-edit-body[data-fold=chat] > .band-workshop-edit-rail {\n display: inline-grid;\n align-self: start;\n }\n}\n.band-workshop-trial-head {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshop-trial-create {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px;\n width: 100%;\n max-width: 420px;\n}\n.band-workshop-trial-create > .field {\n flex: 1 1 200px;\n min-width: 0;\n}\n\n/* src/workshops.css */\n.band-workshops-screen {\n container: band-workshops / inline-size;\n box-sizing: border-box;\n width: 100%;\n max-width: 1080px;\n margin: 0 auto;\n padding: 36px 32px 64px;\n display: grid;\n gap: 26px;\n align-content: start;\n}\n.band-workshops-screen h1 {\n margin: 0;\n font-family: var(--font-display);\n font-weight: 600;\n font-size: var(--fs-h1);\n line-height: 1.3;\n}\n.band-workshops-head {\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 16px;\n flex-wrap: wrap;\n}\n.band-workshops-head .sub,\n.band-workshops-lede {\n margin: 6px 0 0;\n max-width: 64ch;\n}\n.band-workshops-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));\n gap: 10px;\n}\n.band-workshops-card {\n padding: 16px 16px 14px;\n display: grid;\n gap: 10px;\n align-content: start;\n text-align: left;\n background: var(--fill);\n border: 0;\n border-radius: 14px;\n width: 100%;\n color: inherit;\n font: inherit;\n cursor: pointer;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-workshops-card:hover {\n background: var(--fill-2);\n}\n.band-workshops-card.is-skeleton {\n min-height: 150px;\n cursor: default;\n animation: band-workshops-breathe 1.6s var(--ease) infinite alternate;\n}\n@keyframes band-workshops-breathe {\n to {\n opacity: 0.5;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .band-workshops-card.is-skeleton {\n animation: none;\n }\n}\n.band-workshops-card-h {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.band-workshops-card-t {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshops-name {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-size: var(--fs-title);\n font-weight: 650;\n}\nh1.band-workshops-name {\n font-size: var(--fs-h1);\n gap: 10px;\n}\n.band-workshops-desc {\n font-size: var(--fs-dense);\n line-height: 1.55;\n color: var(--muted);\n}\n.band-workshops-meta {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 12px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-flowline {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 4px;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-st {\n padding: 0 7px;\n border-radius: 5px;\n background: var(--fill-2);\n color: var(--ink);\n line-height: 1.7;\n}\n.band-workshops-st.agent {\n background: var(--accent-soft);\n color: var(--accent-text);\n}\n.band-workshops-st.external {\n background: none;\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n color: var(--muted);\n}\n.band-workshops-rest {\n padding: 24px 0;\n justify-items: start;\n}\n.band-workshops-crumb {\n font-size: var(--fs-dense);\n color: var(--muted);\n display: flex;\n gap: 6px;\n align-items: center;\n}\n.band-workshops-crumb button {\n background: none;\n border: 0;\n padding: 0;\n font: inherit;\n color: var(--muted);\n cursor: pointer;\n}\n.band-workshops-crumb button:hover {\n color: var(--ink);\n}\n.band-workshops-detail {\n display: grid;\n grid-template-columns: minmax(0, 1fr) 300px;\n gap: 28px;\n align-items: start;\n}\n.band-workshops-stack {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 18px;\n}\n.band-workshops-aside {\n background: var(--fill);\n border-radius: 14px;\n padding: 16px;\n display: grid;\n gap: 14px;\n}\n.band-workshops-aside .btn {\n justify-content: center;\n}\n.band-workshops-facts {\n margin: 0;\n display: grid;\n grid-template-columns: 44px minmax(0, 1fr);\n gap: 6px 10px;\n font-size: var(--fs-ui);\n}\n.band-workshops-facts dt {\n color: var(--muted);\n}\n.band-workshops-facts dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n.band-workshops-facts code,\n.band-workshops-table code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-nowrap {\n white-space: nowrap;\n}\n.band-workshops-note {\n margin: 8px 0 0;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-note.band-plugin-react-model-hint {\n margin: 8px 0 0;\n}\n.band-workshops-table {\n overflow-x: auto;\n}\n.band-workshops-table table {\n border-collapse: collapse;\n width: 100%;\n font-size: var(--fs-ui);\n}\n.band-workshops-table th,\n.band-workshops-table td {\n text-align: left;\n padding: 8px 12px 8px 0;\n border-bottom: var(--hairline) solid var(--rule);\n vertical-align: top;\n}\n.band-workshops-table th {\n color: var(--muted);\n font-weight: 500;\n font-size: var(--fs-meta);\n}\n.band-workshops-table tr:last-child td {\n border-bottom: 0;\n}\n.band-workshops-flowbig {\n position: relative;\n padding: 4px 0;\n}\n.band-workshops-edges {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n pointer-events: none;\n}\n.band-workshops-edges path {\n fill: none;\n stroke: var(--muted);\n stroke-width: 1;\n}\n.band-workshops-edges marker path {\n fill: var(--muted);\n stroke: none;\n}\n.band-workshops-layers {\n position: relative;\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n row-gap: 32px;\n}\n.band-workshops-layer {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-wrap: wrap;\n align-items: stretch;\n gap: 32px 24px;\n}\n.band-workshops-layer > li {\n display: flex;\n}\n.band-workshops-node {\n min-width: 150px;\n padding: 10px 12px;\n border-radius: 10px;\n background: var(--fill-2);\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n display: grid;\n gap: 2px;\n align-content: start;\n}\n.band-workshops-node.agent {\n background: var(--accent-soft);\n}\n.band-workshops-node.agent b {\n color: var(--accent-text);\n}\n.band-workshops-node.external {\n background: var(--sunk);\n}\n.band-workshops-node-g {\n font-size: var(--fs-dense);\n color: var(--ink);\n margin-top: 2px;\n}\n.band-workshops-node-loop {\n max-width: 320px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-node-missing {\n max-width: 320px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-flow-line {\n margin: 0 0 8px;\n font-size: var(--fs-dense);\n color: var(--ink);\n}\n.band-workshops-flowbig + .band-workshops-flow-line {\n margin: 8px 0 0;\n}\n.band-workshops-node-a {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-node.agent .band-workshops-node-a {\n color: var(--accent-text);\n}\n.band-workshops-whead {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n.band-workshops-whead :where(.band-workshops-lede) {\n margin-top: 6px;\n}\n.band-workshops-tabs {\n display: flex;\n gap: 18px;\n border-bottom: var(--hairline) solid var(--rule);\n overflow-x: auto;\n scrollbar-width: none;\n}\n.band-workshops-tabs > button {\n flex: none;\n border: 0;\n background: none;\n padding: 6px 0 9px;\n font: inherit;\n font-size: var(--fs-body);\n color: var(--muted);\n cursor: pointer;\n border-radius: 0;\n}\n.band-workshops-tabs > button:hover {\n color: var(--ink);\n}\n.band-workshops-tabs > button[aria-selected=true] {\n color: var(--ink);\n font-weight: 500;\n box-shadow: inset 0 -2px 0 var(--ink);\n}\n.band-workshops-tabs > button:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n}\n.band-workshops-panel {\n display: grid;\n gap: 12px;\n}\n.band-workshops-callout {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 14px;\n font-size: var(--fs-ui);\n line-height: 1.6;\n color: var(--muted);\n}\n.band-workshops-callout b {\n color: var(--ink);\n font-weight: 600;\n}\n.band-workshops-callout blockquote {\n margin: 8px 0;\n padding: 0 0 0 12px;\n border-left: 2px solid var(--rule);\n color: var(--ink);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n.band-workshops-callout[data-first-message] {\n margin: 8px 0;\n}\n.band-workshops-callout[data-first-message] p {\n margin: 0;\n}\n.band-workshops-agents {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: 8px;\n}\n.band-workshops-agent {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n}\n.band-workshops-agent-t {\n display: grid;\n gap: 1px;\n min-width: 0;\n}\n.band-workshops-agent-t b {\n font-weight: 500;\n}\n.band-workshops-agent-k {\n font-size: var(--fs-dense);\n color: var(--muted);\n font-weight: 400;\n}\n.band-workshops-agent-d {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-mine {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 4px 10px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-mine button {\n background: none;\n border: 0;\n padding: 0;\n font: inherit;\n color: var(--accent-text);\n cursor: pointer;\n}\n.band-workshops-mine button:hover {\n text-decoration: underline;\n}\n.band-workshops-empty {\n display: grid;\n gap: 8px;\n justify-items: start;\n padding: 28px 0;\n}\n.band-workshops-empty :where(.sub) {\n margin: 0;\n max-width: 52ch;\n}\n.band-workshops-sk {\n display: block;\n border-radius: var(--r-lg);\n background: var(--fill);\n animation: band-workshops-breathe 1.6s var(--ease) infinite alternate;\n}\n.band-workshops-sk:where(.is-tile) {\n width: 64px;\n height: 64px;\n border-radius: var(--r-xl);\n}\n.band-workshops-sk:where(.is-line) {\n width: 240px;\n height: 28px;\n}\n.band-workshops-sk:where(.is-block) {\n height: 180px;\n}\n.band-workshops-sk:where(.is-aside) {\n height: 220px;\n}\n@media (prefers-reduced-motion: reduce) {\n .band-workshops-sk {\n animation: none;\n }\n}\n.band-workshops-missing {\n display: grid;\n gap: 12px;\n justify-items: start;\n}\n.band-workshops-form {\n display: grid;\n gap: 18px;\n max-width: 560px;\n}\n.band-workshops-field {\n display: grid;\n gap: 6px;\n}\n.band-workshops-field > span {\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-field input,\n.band-workshops-field textarea,\n.band-workshops-field select {\n width: 100%;\n background-color: var(--panel);\n border: 0;\n box-shadow: inset 0 0 0 1px var(--control-edge);\n border-radius: var(--r);\n padding: 8px 10px;\n font: inherit;\n font-size: var(--fs-body);\n color: var(--ink);\n transition: box-shadow var(--sixteenth) var(--ease);\n}\n.band-workshops-field input::placeholder,\n.band-workshops-field textarea::placeholder {\n color: var(--muted);\n}\n.band-workshops-field input {\n text-overflow: ellipsis;\n}\n.band-workshops-field input:focus,\n.band-workshops-field textarea:focus,\n.band-workshops-field select:focus {\n outline: none;\n box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);\n}\n.band-workshops-field input:disabled,\n.band-workshops-field textarea:disabled,\n.band-workshops-field select:disabled {\n opacity: 0.42;\n cursor: not-allowed;\n}\n.band-workshops-field textarea {\n resize: vertical;\n line-height: 1.6;\n min-height: 6.4em;\n}\n.band-workshops-field input[aria-invalid=true],\n.band-workshops-field textarea[aria-invalid=true] {\n box-shadow: inset 0 0 0 1px var(--bad);\n}\n.band-workshops-repo {\n display: grid;\n gap: 6px;\n}\n.band-workshops-req,\n.band-workshops-opt {\n margin-left: 6px;\n font-style: normal;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-err {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--bad);\n}\n.band-workshops-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-yanked p {\n margin: 0 0 4px;\n}\n.band-workshops-yanked ul {\n margin: 0;\n padding-left: 18px;\n}\n.band-workshops-hint code,\n.band-workshops-callout code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-yaml {\n margin-top: 10px;\n display: grid;\n gap: 6px;\n}\n.band-workshops-yaml-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.band-workshops-yaml-code {\n margin: 0;\n max-height: 264px;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 10px 12px;\n border-radius: var(--r);\n background: var(--panel);\n font-family: var(--mono);\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--ink);\n white-space: pre;\n}\n.band-workshops-yaml-said {\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-callout {\n background: var(--fill);\n border-radius: var(--r);\n padding: 10px 12px;\n font-size: var(--fs-ui);\n color: var(--muted);\n display: grid;\n gap: 6px;\n}\n.band-workshops-callout p {\n margin: 0;\n}\n.band-workshops-status {\n display: block;\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-headacts {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n.band-workshops-link {\n border: 0;\n background: none;\n padding: 0;\n font: inherit;\n color: var(--accent-text);\n cursor: pointer;\n}\n.band-workshops-link:hover {\n text-decoration: underline;\n}\n.band-workshops-link:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n border-radius: 3px;\n}\n.band-workshops-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n@media (max-width: 860px) {\n .band-workshops-whead {\n align-items: flex-start;\n }\n .band-workshops-screen {\n padding: 22px 16px 48px;\n gap: 22px;\n }\n .band-workshops-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n@container band-workshops (max-width: 900px) {\n .band-workshops-detail {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-publish {\n display: grid;\n gap: 8px;\n}\n.band-workshops-publish-dialog {\n width: min(440px, calc(100vw - 32px));\n max-width: none;\n margin: auto;\n padding: 0;\n border: 0;\n border-radius: var(--r-xl);\n background: var(--panel);\n color: var(--ink);\n box-shadow: var(--shadow-pop);\n}\n.band-workshops-publish-dialog::backdrop {\n background: var(--scrim);\n}\n.band-workshops-publish-body {\n display: grid;\n gap: 14px;\n padding: 20px;\n font-size: var(--fs-ui);\n}\n.band-workshops-publish-title {\n margin: 0;\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-publish-body > p {\n margin: 0;\n}\n.band-workshops-publish-body .band-workshops-field textarea {\n min-height: 3.6em;\n}\n.band-workshops-params {\n display: grid;\n gap: 10px;\n padding: 14px 12px;\n border-radius: 10px;\n background: var(--sunk);\n}\n.band-workshops-params-title {\n font-size: var(--fs-caption);\n letter-spacing: 0.08em;\n color: var(--muted);\n text-transform: uppercase;\n}\n.band-workshops-params-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-sub {\n margin: 14px 0 6px;\n font-size: var(--fs-dense);\n font-weight: 500;\n color: var(--muted);\n}\n.band-workshops-sub:first-child {\n margin-top: 0;\n}\n.band-workshops-plugin {\n display: inline-grid;\n gap: 2px;\n text-align: left;\n}\n.band-workshops-plugin b {\n font-weight: 500;\n}\n.band-workshops-plugin code {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n.band-workshops-detach {\n display: grid;\n gap: 6px;\n margin-top: 14px;\n}\n.band-workshops-detach .band-workshops-note {\n margin: 0;\n}\n.band-workshops-detach-list {\n display: grid;\n gap: 6px;\n margin: 4px 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-detach-list li {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n column-gap: 10px;\n row-gap: 2px;\n min-width: 0;\n}\n.band-workshops-detach-list code {\n font-size: var(--fs-meta);\n overflow-wrap: anywhere;\n}\n.band-workshops-detach-meta {\n font-size: var(--fs-dense);\n color: var(--muted);\n overflow-wrap: anywhere;\n}\n.band-workshops-detach-acts {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.band-workshops-detach-done {\n display: grid;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n color: var(--ink);\n font-size: var(--fs-ui);\n overflow-wrap: anywhere;\n}\n.band-workshops-copy-plugins {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n border: 0;\n min-width: 0;\n}\n.band-workshops-copy-plugins legend {\n padding: 0;\n margin-bottom: 6px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-copy-plugins .band-workshops-note {\n margin: 0;\n}\n.band-workshops-copy-list {\n display: grid;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-copy-list li {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-between;\n gap: 6px 16px;\n min-width: 0;\n}\n.band-workshops-copy-list code {\n font-size: var(--fs-meta);\n overflow-wrap: anywhere;\n}\n.band-workshops-copy-list li > .band-workshops-plugin {\n flex: 1 1 240px;\n min-width: 0;\n}\n.band-workshops-copy-why {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-copy-choices {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 14px;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-people {\n display: grid;\n gap: 12px;\n}\n.band-workshops-people-bar {\n display: grid;\n justify-items: start;\n}\n.band-workshops-people-card {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n background: var(--panel);\n border-radius: var(--r-lg);\n box-shadow: var(--shadow-card);\n}\n.band-workshops-people-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 12px;\n padding: 10px 14px;\n border-top: var(--hairline) solid var(--rule);\n}\n.band-workshops-people-row:where(:first-child) {\n border-top: 0;\n}\n.band-workshops-people-line {\n display: flex;\n align-items: center;\n gap: 12px;\n flex: 1 1 100%;\n min-width: 0;\n}\n.band-workshops-people-who {\n display: grid;\n gap: 1px;\n min-width: 0;\n font-size: var(--fs-row);\n}\n.band-workshops-people-who b {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-workshops-people-who span {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-people-ops {\n margin-left: auto;\n display: flex;\n gap: 4px;\n text-align: right;\n}\n.band-workshops-people-form {\n flex: 1 1 100%;\n display: grid;\n gap: 12px;\n margin: 0;\n padding: 14px;\n border: 0;\n min-width: 0;\n background: var(--panel);\n border-radius: var(--r-lg);\n box-shadow: var(--shadow-card);\n font-size: var(--fs-row);\n}\n.band-workshops-people-form:where(.band-workshops-people-row > *) {\n padding: 0 0 0 36px;\n background: none;\n box-shadow: none;\n}\n.band-workshops-people-form p {\n margin: 0;\n}\n.band-workshops-people-field {\n position: relative;\n display: grid;\n gap: 4px;\n max-width: 420px;\n}\n.band-workshops-people-label,\n.band-workshops-viewers-label {\n font-size: var(--fs-row);\n color: var(--ink);\n}\n.band-workshops-people-hint {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-workshops-people-actions {\n display: flex;\n gap: 8px;\n}\n.band-workshops-visibility {\n padding: 16px;\n color: var(--ink);\n display: grid;\n gap: 12px;\n align-content: start;\n max-width: 640px;\n}\n.band-workshops-visibility h2 {\n margin: 0;\n font-size: var(--fs-title);\n}\n.band-workshops-visibility p {\n margin: 0;\n color: var(--muted);\n}\n.band-workshops-visibility .btn {\n justify-self: start;\n}\n.band-workshops-levels {\n display: grid;\n gap: 8px;\n}\n.band-workshops-level {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n cursor: pointer;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-workshops-level:where(:hover, :has(:checked)) {\n background: var(--fill);\n}\n.band-workshops-level:where(:has(:disabled)) {\n cursor: default;\n}\n.band-workshops-level:where(:has(:disabled):not(:has(:checked)):hover) {\n background: none;\n}\n.band-workshops-level .radio {\n margin-top: 2px;\n}\n.band-workshops-level > span {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshops-level b {\n font-weight: 600;\n}\n.band-workshops-level span span {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-workshops-viewers {\n display: grid;\n gap: 8px;\n position: relative;\n}\n.band-workshops-steps {\n display: flex;\n gap: 14px;\n margin: 0 0 6px;\n padding: 0;\n list-style: none;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-steps li::before {\n content: attr(data-n) " ";\n font-family: var(--mono);\n}\n.band-workshops-steps li[aria-current=step] {\n color: var(--ink);\n font-weight: 600;\n}\n.band-workshops-steps li.is-done {\n color: var(--ok);\n}\n.band-workshops-sources {\n display: grid;\n gap: 8px;\n}\n.band-workshops-source {\n display: grid;\n grid-template-columns: 16px minmax(0, 1fr);\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n cursor: pointer;\n --control: var(--accent);\n --control-ink: var(--accent-ink);\n}\n.band-workshops-source .radio {\n margin-top: 3px;\n}\n.band-workshops-source.is-on {\n box-shadow: inset 0 0 0 1px var(--accent);\n background: var(--accent-soft);\n}\n.band-workshops-source b {\n font-weight: 600;\n font-size: var(--fs-row);\n color: var(--ink);\n}\n.band-workshops-source small {\n display: block;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-subfields {\n display: grid;\n gap: 14px;\n padding-left: 26px;\n}\n.band-workshops-req {\n color: var(--muted);\n font-size: var(--fs-meta);\n font-weight: 400;\n margin-left: 6px;\n}\n.band-workshops-readonly {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-readonly code {\n color: var(--ink);\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-result {\n display: grid;\n gap: 6px;\n}\n.band-workshops-result-line {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-wrap: wrap;\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-result p {\n margin: 0;\n}\n.band-workshops-why {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-why.is-bad {\n color: var(--bad);\n}\n.band-workshops-why code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-actions.is-start {\n justify-content: flex-start;\n}\n.band-workshops-retry {\n display: grid;\n gap: 8px;\n justify-items: start;\n}\n.band-workshops-model-facts {\n max-width: 520px;\n}\n.band-workshops-callout-more {\n margin-top: 6px;\n}\n.band-workshops-needs {\n display: grid;\n grid-template-columns: 16px minmax(0, 1fr) auto;\n gap: 10px;\n align-items: start;\n background: var(--warn-soft);\n color: var(--ink);\n border-radius: var(--r-lg);\n padding: 10px 12px;\n font-size: var(--fs-ui);\n}\n.band-workshops-needs .glyph {\n margin-top: 2px;\n}\n.band-workshops-needs b {\n color: var(--warn);\n font-weight: 600;\n}\n.band-workshops-needs p {\n margin: 0;\n}\n.band-workshops-needs .btn {\n align-self: center;\n}\n.band-workshops-agent-x {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-wrap: wrap;\n justify-content: flex-end;\n margin-left: auto;\n}\n.band-workshops-agent.is-off .av,\n.band-workshops-agent.is-off .band-workshops-agent-t b {\n opacity: 0.42;\n}\n@media (max-width: 560px) {\n .band-workshops-needs {\n grid-template-columns: 16px minmax(0, 1fr);\n }\n .band-workshops-needs .btn {\n grid-column: 2;\n justify-self: start;\n }\n .band-workshops-subfields {\n padding-left: 0;\n }\n}\n.band-workshops-overrides {\n display: grid;\n gap: 8px;\n padding: 12px 14px;\n border-radius: var(--r-lg);\n background: var(--sunk);\n}\n.band-workshops-overrides-h {\n margin: 0;\n font-size: var(--fs-ui);\n font-weight: 600;\n color: var(--ink);\n}\n.band-workshops-overrides-list {\n display: grid;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-overrides-list > li {\n display: grid;\n gap: 2px;\n padding-left: 10px;\n border-left: 2px solid var(--rule);\n min-width: 0;\n}\n.band-workshops-overrides-list > li.is-action {\n border-left-color: var(--bad);\n}\n.band-workshops-overrides-t {\n font-size: var(--fs-row);\n color: var(--ink);\n overflow-wrap: anywhere;\n}\n.band-workshops-overrides-scope,\n.band-workshops-overrides-d {\n font-size: var(--fs-ui);\n color: var(--muted);\n overflow-wrap: anywhere;\n}\n.band-workshops-intro {\n display: grid;\n gap: 10px;\n max-width: 560px;\n}\n.band-workshops-intro-lede {\n margin: 0;\n font-size: var(--fs-body);\n line-height: 1.6;\n color: var(--ink);\n}\n.band-workshops-intro-h {\n margin: 4px 0 0;\n font-size: var(--fs-meta);\n font-weight: 400;\n color: var(--muted);\n letter-spacing: 0.04em;\n}\n.band-workshops-samples {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 10px;\n}\nbutton.band-workshops-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-workshops-sample:hover {\n border-color: var(--rule-strong);\n}\nbutton.band-workshops-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-workshops-sample b {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-workshops-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-workshops-samples {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-ref-hint {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n color: var(--ink);\n font-size: var(--fs-ui);\n overflow-wrap: anywhere;\n}\n.band-workshops-ref-hint p,\n.band-workshops-ref-hint ul {\n margin: 0;\n}\n.band-workshops-ref-hint ul {\n padding-left: 18px;\n}\n.band-workshops-ref-hint-title {\n font-weight: 600;\n}\n.band-workshops-upgrade {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-upgrade p,\n.band-workshops-upgrade ul {\n margin: 0;\n}\n.band-workshops-upgrade ul {\n padding-left: 18px;\n}\n.band-workshops-upgrade-dialog {\n width: min(440px, calc(100vw - 32px));\n max-width: none;\n margin: auto;\n padding: 0;\n border: 0;\n border-radius: var(--r-xl);\n background: var(--panel);\n color: var(--ink);\n box-shadow: var(--shadow-pop);\n}\n.band-workshops-upgrade-dialog::backdrop {\n background: var(--scrim);\n}\n.band-workshops-upgrade-body {\n display: grid;\n gap: 12px;\n padding: 20px;\n font-size: var(--fs-ui);\n}\n.band-workshops-upgrade-title {\n margin: 0;\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-upgrade-body > p {\n margin: 0;\n}\n.band-workshops-details {\n font-size: var(--fs-ui);\n}\n.band-workshops-details summary {\n color: var(--muted);\n cursor: pointer;\n}\n.band-workshops-details .band-workshops-facts {\n margin-top: 6px;\n}\n.band-workshops-secrets {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: 12px;\n max-width: 620px;\n}\n.band-workshops-secret {\n display: grid;\n gap: 10px;\n}\n.band-workshops-secret-line {\n display: flex;\n gap: 10px;\n align-items: center;\n flex-wrap: wrap;\n}\n.band-workshops-secret-name {\n font-family: var(--mono);\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-secret-line .btn {\n margin-left: auto;\n}\n.band-workshops-secret-form {\n display: grid;\n gap: 10px;\n padding-left: 2px;\n}\n.band-workshops-agent-upgrade-line {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 6px 0 0;\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-agent-upgrade {\n display: grid;\n gap: 8px;\n margin-top: 16px;\n padding: 12px;\n border-radius: var(--r-lg);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-agent-upgrade h3,\n.band-workshops-agent-upgrade h4,\n.band-workshops-agent-upgrade p,\n.band-workshops-agent-upgrade ul {\n margin: 0;\n}\n.band-workshops-agent-upgrade h3 {\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-agent-upgrade h4 {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-workshops-agent-upgrade ul {\n display: grid;\n gap: 8px;\n padding-left: 18px;\n}\n.band-workshops-agent-upgrade-log {\n margin: 4px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font: inherit;\n}\n.band-workshops-model-pick {\n display: grid;\n gap: 6px;\n}\n.band-workshops-follow {\n margin-top: 18px;\n}\n.band-workshops-follow-list {\n display: grid;\n margin: 8px 0 0;\n padding: 0;\n list-style: none;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n}\n.band-workshops-follow-row {\n display: grid;\n grid-template-columns: 7em minmax(0, 1fr) minmax(0, 1.4fr);\n gap: 4px 12px;\n align-items: baseline;\n padding: 8px 12px;\n font-size: var(--fs-ui);\n border-left: 3px solid transparent;\n}\n.band-workshops-follow-row + .band-workshops-follow-row {\n border-top: 1px solid var(--rule);\n}\n.band-workshops-follow-row[data-status=failed] {\n border-left-color: var(--bad);\n}\n.band-workshops-follow-when {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n.band-workshops-follow-trigger {\n overflow-wrap: anywhere;\n}\n.band-workshops-follow-outcome {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 8px;\n align-items: baseline;\n overflow-wrap: anywhere;\n}\n.band-workshops-follow-status[data-status=unchanged] {\n color: var(--muted);\n}\n.band-workshops-follow-outcome code {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n@media (max-width: 640px) {\n .band-workshops-follow-row {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-trials {\n display: grid;\n gap: 12px;\n list-style: none;\n padding: 0;\n}\n.band-workshops-trials > li {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.band-workshops-new {\n max-width: 720px;\n}\n.band-workshops-new-head {\n display: grid;\n gap: 8px;\n}\n.band-workshops-new-head h1,\n.band-workshops-new-head .sub {\n margin: 0;\n}\n.band-workshops-new-head .sub {\n color: var(--muted);\n}\n.band-workshops-new-help {\n display: grid;\n gap: 8px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-new-help p {\n margin: 0;\n}\n.band-workshops-new-help summary {\n cursor: pointer;\n color: var(--accent-text);\n}\n.band-workshops-new-help details[open] > summary {\n margin-bottom: 8px;\n}\n';let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-workshops"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-workshops");document.head.prepend(el)}el.textContent=css}var AGENT_UPGRADE_TEXT={line:{available:n=>`${n} \u4E2A Agent \u7684\u63D2\u4EF6\u6709\u65B0\u7248\u672C`,behind:"\u6709 Agent \u7684\u534F\u4F5C\u534F\u8BAE\u7248\u672C\u8F83\u65E7\uFF0C\u4E4B\u540E\u4F1A\u505C\u6B62\u652F\u6301",unsupported:"\u6709 Agent \u7684\u534F\u4F5C\u534F\u8BAE\u7248\u672C\u5DF2\u4E0D\u518D\u652F\u6301\uFF0C\u5B83\u7684\u56DE\u5408\u6B63\u5728\u88AB\u62D2\u7EDD",show:"\u67E5\u770B"},block:{title:"Agent \u63D2\u4EF6\u7248\u672C",unread:"\u8FD9\u4E2A Agent \u7684\u63D2\u4EF6\u7248\u672C\u6CA1\u8BFB\u51FA\u6765\uFF0C\u7A0D\u540E\u518D\u770B\u3002",unpublished:"Agent \u4ED3\u5E93\u91CC\u6709\u8FD8\u6CA1\u8FDB\u5DE5\u574A\u7684\u4FEE\u6539\uFF1A\u91CD\u65B0\u53D1\u5E03\u5DE5\u574A\u540E\uFF0C\u65B0\u5EFA\u7684\u9879\u76EE\u624D\u4F1A\u7528\u4E0A\uFF1B\u5DF2\u6709\u9879\u76EE\u518D\u7528\u300C\u66F4\u65B0\u672C\u5DE5\u574A\u5168\u90E8\u9879\u76EE\u300D\u3002",changelog:"\u66F4\u65B0\u5185\u5BB9",editHint:(file,dependency,version)=>`\u5728 Agent \u4ED3\u5E93\u91CC\u628A ${file} \u7684\u4F9D\u8D56 ${dependency} \u6539\u6210 ${version}\uFF0C\u63D0\u4EA4\u3002`,pipeline:"\u63D0\u4EA4\u540E\u4F1A\u81EA\u52A8\u53D1\u5230\u6D4B\u8BD5\u73AF\u5883\uFF1B\u6B63\u5F0F\u73AF\u5883\u8981\u5728 AgentHub \u91CC\u624B\u52A8\u664B\u7EA7\u3002",republish:"\u664B\u7EA7\u53EA\u662F AgentHub \u91CC\u7684\u53D1\u5E03\u8BB0\u5F55\u3002\u8981\u8BA9\u9879\u76EE\u7528\u4E0A\uFF0C\u8FD8\u8981\u91CD\u65B0\u53D1\u5E03\u5DE5\u574A\uFF0C\u518D\u66F4\u65B0\u9879\u76EE\u3002"},plugin:{available:(name,current,target)=>`${name} \u6709\u65B0\u7248\u672C ${target}\uFF08\u73B0\u5728 ${current}\uFF09`,behind:(name,current,end)=>`${name} ${current} \u7248\u672C\u8F83\u65E7${end?`\uFF0C${end} \u8D77\u4E0D\u518D\u652F\u6301`:"\uFF0C\u4E4B\u540E\u4F1A\u505C\u6B62\u652F\u6301"}`,unsupported:(name,current)=>`${name} ${current} \u5DF2\u4E0D\u518D\u652F\u6301\uFF0C\u56DE\u5408\u6B63\u5728\u88AB\u62D2\u7EDD`}};var shortPluginName=name=>name.split("/").pop()??name;var isShown=p=>p.level==="available"&&p.target!==null||p.level==="behind"||p.level==="unsupported";var shownPlugins=a=>a.plugins.filter(isShown);var needsAttention=a=>a.state==="unread"||a.unpublished||shownPlugins(a).length>0;function headline(advice){const plugins=advice.agents.flatMap(shownPlugins);if(plugins.some(p=>p.level==="unsupported"))return AGENT_UPGRADE_TEXT.line.unsupported;if(plugins.some(p=>p.level==="behind"))return AGENT_UPGRADE_TEXT.line.behind;const n=advice.agents.filter(a=>shownPlugins(a).length>0).length;return n>0?AGENT_UPGRADE_TEXT.line.available(n):null}function useAgentUpgrade(ctx,workshop,enabled){const api=ctx.app.data.write?.agentUpgrade;const[advice,setAdvice]=useState(null);const[error,setError]=useState(null);const load=useCallback(()=>{if(!api||!enabled)return;api.advice(workshop).then(a=>{setAdvice(a);setError(null)},e=>{setAdvice(null);setError(isForbidden(e)?null:failedBecause(e,"\u70B9\u91CD\u8BD5"))})},[api,enabled,workshop]);useEffect(()=>{load()},[load]);return{advice,error,reload:load}}function AgentUpgradeLine({advice,onShow}){const text=advice?headline(advice):null;if(!text)return null;return jsxs("p",{className:"band-workshops-agent-upgrade-line","data-agent-upgrade-line":true,children:[jsx("span",{children:text}),jsx("button",{type:"button",className:"btn sm",onClick:onShow,children:AGENT_UPGRADE_TEXT.line.show})]})}function PluginRow({p,slug,pinned}){const T=AGENT_UPGRADE_TEXT;const name=shortPluginName(p.name);const text=p.level==="available"?T.plugin.available(name,p.current,p.target):p.level==="behind"?T.plugin.behind(name,p.current,p.endOfSupport):T.plugin.unsupported(name,p.current);return jsxs("li",{"data-agent-upgrade-plugin":`${slug}/${p.name}`,"data-level":p.level,children:[jsx("b",{children:text}),p.edit?jsxs(Fragment,{children:[jsx("p",{children:T.block.editHint(p.edit.file,p.edit.dependency,p.edit.version)}),jsx("p",{children:T.block.pipeline}),pinned&&jsx("p",{children:T.block.republish})]}):jsx("p",{children:"\u6682\u65F6\u8FD8\u6CA1\u6709\u9A8C\u8BC1\u8FC7\u7684\u65B0\u7248\u672C\u53EF\u4EE5\u5347\u7EA7\u5230\u3002"}),p.changelog.length>0&&jsxs("details",{className:"band-workshops-details",children:[jsx("summary",{children:T.block.changelog}),p.changelog.map(c=>jsxs("section",{children:[jsx("h4",{children:c.version}),jsx("pre",{className:"band-workshops-agent-upgrade-log",children:c.body})]},c.version))]})]})}function AgentUpgradeBlock({advice,error,reload,labelOf}){if(error)return jsxs(ErrorNote,{retry:reload,children:["Agent \u63D2\u4EF6\u7248\u672C\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});const agents=advice?.agents.filter(needsAttention)??[];if(agents.length===0)return null;return jsxs("section",{className:"band-workshops-agent-upgrade","aria-label":AGENT_UPGRADE_TEXT.block.title,"data-agent-upgrade-block":true,children:[jsx("h3",{children:AGENT_UPGRADE_TEXT.block.title}),agents.map(a=>jsxs("div",{"data-agent-upgrade-agent":a.slug,children:[jsx("h4",{children:labelOf(a.slug)}),a.state==="unread"&&jsx("p",{children:AGENT_UPGRADE_TEXT.block.unread}),a.unpublished&&jsx("p",{children:AGENT_UPGRADE_TEXT.block.unpublished}),jsx("ul",{children:shownPlugins(a).map(p=>jsx(PluginRow,{p,slug:a.slug,pinned:a.source==="snapshot"},p.name))})]},a.slug))]})}var RESTORE_HINT="\u5728\u5DE5\u574A\u76EE\u5F55\u53F3\u4E0A\u89D2\u7684\u300C\u5DF2\u5F52\u6863\u300D\u91CC\u627E\u5230\u5B83\uFF0C\u6216\u76F4\u63A5\u6253\u5F00\u5B83\u7684\u5730\u5740\uFF0C\u70B9\u300C\u590D\u539F\u5DE5\u574A\u300D\u3002";function ArchivedNotice({api,workshop,onChanged}){const[busy,setBusy]=useState2(false);const[error,setError]=useState2("");const restore=async()=>{if(!api||busy)return;setBusy(true);setError("");try{await api.set(workshop,false);onChanged()}catch(e){setError(`\u6CA1\u590D\u539F\u6210\uFF1A${failedBecause2(e,"\u518D\u70B9\u4E00\u6B21\u300C\u590D\u539F\u5DE5\u574A\u300D")}`)}finally{setBusy(false)}};return jsxs2("output",{className:"band-workshops-status",children:["\u5DE5\u574A\u5DF2\u5F52\u6863\uFF1A\u4E0D\u5728\u5DE5\u574A\u76EE\u5F55\u91CC\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF0C\u5DF2\u6709\u9879\u76EE\u7167\u5E38\u4F7F\u7528\u3002",api&&jsxs2(Fragment2,{children:[" ",jsx2("button",{type:"button",className:"btn sm",disabled:busy,onClick:()=>void restore(),children:busy?"\u6B63\u5728\u590D\u539F\u2026":"\u590D\u539F\u5DE5\u574A"})]}),error&&jsx2(SettingsSaveState,{failed:error})]})}function WorkshopArchiveTab({api,workshop,name,archived,onChanged}){const[dialog,setDialog]=useState2(false);const[busy,setBusy]=useState2(false);const[error,setError]=useState2("");const restore=async()=>{if(busy)return;setBusy(true);setError("");try{await api.set(workshop,false);onChanged()}catch(e){setError(`\u6CA1\u590D\u539F\u6210\uFF1A${failedBecause2(e,"\u518D\u70B9\u4E00\u6B21\u300C\u590D\u539F\u5DE5\u574A\u300D")}`)}finally{setBusy(false)}};return jsxs2(Fragment2,{children:[jsx2(SettingsDanger,{children:archived?jsx2(SettingsDangerRow,{title:"\u5DE5\u574A\u5DF2\u5F52\u6863",note:"\u590D\u539F\u540E\u56DE\u5230\u5DE5\u574A\u76EE\u5F55\uFF0C\u53EF\u4EE5\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002",action:jsx2("button",{type:"button",className:"btn",disabled:busy,onClick:()=>void restore(),children:busy?"\u6B63\u5728\u590D\u539F\u2026":"\u590D\u539F\u5DE5\u574A"})}):jsx2(SettingsDangerRow,{title:"\u5F52\u6863\u5DE5\u574A",note:"\u4ECE\u5DE5\u574A\u76EE\u5F55\u91CC\u6536\u8D77\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF1B\u5DF2\u6709\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u968F\u65F6\u53EF\u4EE5\u590D\u539F\u3002",action:jsx2("button",{type:"button",className:"btn danger",onClick:()=>setDialog(true),children:"\u5F52\u6863\u5DE5\u574A"})})}),error&&jsx2(SettingsSaveState,{failed:error}),dialog&&jsx2(ArchiveDialog,{api,workshop,name,onClose:()=>setDialog(false),onDone:()=>{setDialog(false);onChanged()}})]})}function ArchiveDialog({api,workshop,name,onClose,onDone}){const[busy,setBusy]=useState2(false);const[error,setError]=useState2("");const go=async()=>{if(busy)return;setBusy(true);setError("");try{await api.set(workshop,true);onDone()}catch(e){setError(`\u6CA1\u5F52\u6863\u6210\uFF1A${failedBecause2(e,"\u518D\u70B9\u4E00\u6B21\u300C\u5F52\u6863\u5DE5\u574A\u300D")}`);setBusy(false)}};return jsxs2(SettingsDialog,{title:`\u5F52\u6863\u5DE5\u574A\u300C${name}\u300D\uFF1F`,onClose:()=>!busy&&onClose(),actions:jsxs2(Fragment2,{children:[jsx2("button",{type:"button",className:"btn ghost",disabled:busy,onClick:onClose,children:"\u53D6\u6D88"}),jsx2("button",{type:"button",className:"btn danger",disabled:busy,onClick:()=>void go(),children:busy?"\u6B63\u5728\u5F52\u6863\u2026":"\u5F52\u6863\u5DE5\u574A"})]}),children:[jsxs2("ul",{children:[jsx2("li",{children:"\u5DE5\u574A\u4ECE\u5DE5\u574A\u76EE\u5F55\u91CC\u6D88\u5931\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF0C\u4E5F\u4E0D\u80FD\u590D\u5236\u5B83\u3002"}),jsx2("li",{children:"\u7528\u5B83\u5EFA\u7684\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u7167\u5E38\u4F7F\u7528\u3002"}),jsx2("li",{children:"\u5DE5\u574A\u7684\u4ED3\u5E93\u4E0E\u5B9A\u4E49\u90FD\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u5220\u9664\u4EFB\u4F55\u5185\u5BB9\u3002"}),jsxs2("li",{children:["\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3001\u7BA1\u7406\u5458\u548C Band \u7BA1\u7406\u5458\u968F\u65F6\u53EF\u4EE5\u590D\u539F\uFF1A",RESTORE_HINT]})]}),error&&jsx2(SettingsSaveState,{failed:error})]})}var SELF="@kanyun-ai-infra/band-workshops";function Crumb({ctx,w,here}){return jsxs3("nav",{className:"band-workshops-crumb","aria-label":"\u4F4D\u7F6E",children:[jsx3("button",{type:"button",onClick:()=>ctx.app.navigate({page:`${SELF}/workshops`}),children:"\u5DE5\u574A"}),w&&jsxs3(Fragment3,{children:[jsx3("span",{"aria-hidden":"true",children:"\u203A"}),here?jsx3("button",{type:"button",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}}),children:w.name}):jsx3("span",{"aria-current":"page",children:w.name})]}),here&&jsxs3(Fragment3,{children:[jsx3("span",{"aria-hidden":"true",children:"\u203A"}),jsx3("span",{"aria-current":"page",children:here})]})]})}function useModalDialog({open,onRequestClose,blocked,initialFocus="button"}){const dialog=useRef(null);const trigger=useRef(null);const close=useRef(onRequestClose);close.current=onRequestClose;const busy=useRef(blocked);busy.current=blocked;useEffect2(()=>{const d=dialog.current;if(!d)return;if(open&&!d.open){if(typeof d.showModal==="function")d.showModal();else d.setAttribute("open","");d.querySelector(initialFocus)?.focus()}else if(!open&&d.open){if(typeof d.close==="function")d.close();else d.removeAttribute("open");trigger.current?.focus()}},[open,initialFocus]);useEffect2(()=>{if(!open)return;const d=dialog.current;const onKey=withImeGuard(e=>{if(e.key!=="Escape"||e.defaultPrevented)return;const layers=document.querySelectorAll("[data-band-layer]");if(layers[layers.length-1]!==d)return;e.preventDefault();if(!busy.current)close.current()});let downOnBackdrop=false;const onDown=e=>{downOnBackdrop=e.target===d};const onClick=e=>{if(downOnBackdrop&&e.target===d&&!busy.current)close.current();downOnBackdrop=false};window.addEventListener("keydown",onKey);d?.addEventListener("mousedown",onDown);d?.addEventListener("click",onClick);return()=>{window.removeEventListener("keydown",onKey);d?.removeEventListener("mousedown",onDown);d?.removeEventListener("click",onClick)}},[open]);return{dialog,trigger}}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"}];function showsFreeformIntro(o){return o.workshop===FREEFORM_ID&&o.projects!==void 0&&o.projects.length===0&&o.draftEmpty}function needLede(workshop){return workshop===FREEFORM_ID?"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48\u3002":"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48\u3002\u5EFA\u597D\u5C31\u4EA4\u7ED9 Rondo\uFF0C\u5B83\u63A5\u7740\u505A\u7B2C\u4E00\u7248\u3002"}function FreeformIntro({onPick}){const titleId=useId();return jsxs4("section",{className:"band-workshops-intro","aria-labelledby":titleId,children:[jsx4("p",{className:"band-workshops-intro-lede",children:FREEFORM_INTRO}),jsx4("h2",{id:titleId,className:"band-workshops-intro-h",children:"\u53EF\u4EE5\u4ECE\u8FD9\u4E9B\u5F00\u59CB"}),jsx4("div",{className:"band-workshops-samples",children:FREEFORM_SAMPLES.map(s=>jsxs4("button",{type:"button",className:"band-workshops-sample",onClick:()=>onPick(s.text),children:[jsx4("b",{children:s.title}),jsx4("span",{children:s.text})]},s.title))})]})}var FOLLOW_RUNS_TEXT={title:"\u8DDF\u968F\u8BB0\u5F55",lead:"\u5171\u4EAB\u63D2\u4EF6\u53D1\u65B0\u7248\u672C\u3001\u64A4\u56DE\u6216\u53D6\u6D88\u64A4\u56DE\u540E\uFF0CBand \u4F1A\u66FF\u5F15\u7528\u5B83\u7684\u5DE5\u574A\u91CD\u65B0\u53D1\u5E03\u4E00\u6B21\uFF1B\u8FD9\u91CC\u662F\u6BCF\u6B21\u7684\u7ED3\u679C\u3002",empty:"\u8FD8\u6CA1\u6709\u8DDF\u968F\u8BB0\u5F55\uFF1A\u5F15\u7528\u7684\u5171\u4EAB\u63D2\u4EF6\u8FD8\u6CA1\u53D1\u8FC7\u65B0\u7248\u672C\uFF0C\u6216\u6CA1\u88AB\u64A4\u56DE\u8FC7\u3002",head:["\u65F6\u95F4","\u89E6\u53D1","\u7ED3\u679C"],kind:{registered:"\u53D1\u5E03\u4E86\u65B0\u7248\u672C",yanked:"\u88AB\u64A4\u56DE",unyanked:"\u53D6\u6D88\u64A4\u56DE"},outcome:{changed:seq=>`\u5DF2\u91CD\u65B0\u53D1\u5E03\u4E3A v${seq}`,unchanged:"\u65E0\u9700\u91CD\u65B0\u53D1\u5E03\uFF1A\u8FD9\u4E2A\u5DE5\u574A\u7684\u5185\u5BB9\u6CA1\u6709\u53D8\u5316",failed:"\u6CA1\u6709\u8DDF\u4E0A"},unknownReason:"\u539F\u56E0\u6CA1\u6709\u8BB0\u5F55",more:"\u53EA\u663E\u793A\u6700\u8FD1 50 \u6761\u3002",load:reason=>`\u8DDF\u968F\u8BB0\u5F55\u6CA1\u8BFB\u51FA\u6765\uFF1A${reason}`};var FOLLOW_RUNS_PAGE=50;function triggerText(r){return`${r.pluginName} ${r.triggerVersion} ${FOLLOW_RUNS_TEXT.kind[r.kind]}`}function outcomeText(r){const T=FOLLOW_RUNS_TEXT.outcome;if(r.status==="changed")return r.releaseSeq===null?"\u5DF2\u91CD\u65B0\u53D1\u5E03":T.changed(r.releaseSeq);if(r.status==="unchanged")return T.unchanged;return`${T.failed}\uFF1A${r.reasonText??FOLLOW_RUNS_TEXT.unknownReason}`}function useFollowRuns(ctx,workshop){const api=ctx.app.data.write?.followRuns;const[state,setState]=useState3(api?{kind:"loading"}:{kind:"hidden"});const load=useCallback2(()=>{if(!api)return;api.list(workshop).then(r=>setState({kind:"ok",runs:r.runs}),e=>setState(isForbidden2(e)?{kind:"hidden"}:{kind:"error",reason:failedBecause3(e,"\u70B9\u91CD\u8BD5")}))},[api,workshop]);useEffect3(()=>{setState(api?{kind:"loading"}:{kind:"hidden"});load()},[api,load]);return{state,reload:load}}function Row({r}){return jsxs5("li",{className:"band-workshops-follow-row","data-follow-run":`${r.pluginName}@${r.triggerVersion}:${r.kind}`,"data-status":r.status,children:[jsx5("code",{className:"band-workshops-follow-when",children:localDay(r.createdAt)}),jsx5("span",{className:"band-workshops-follow-trigger",children:triggerText(r)}),jsxs5("span",{className:"band-workshops-follow-outcome",children:[jsx5("span",{className:"band-workshops-follow-status","data-status":r.status,children:outcomeText(r)}),r.status==="failed"&&r.reasonCode&&jsx5("code",{children:r.reasonCode})]})]})}function FollowRuns({ctx,workshop}){const{state,reload}=useFollowRuns(ctx,workshop);if(state.kind==="hidden")return null;const T=FOLLOW_RUNS_TEXT;return jsxs5("section",{className:"band-workshops-follow","aria-label":T.title,"data-follow-runs":true,children:[jsx5("h3",{className:"band-workshops-sub",children:T.title}),jsx5("p",{className:"band-workshops-note",children:T.lead}),state.kind==="loading"&&jsx5("span",{className:"band-workshops-sk is-block","aria-busy":"true"}),state.kind==="error"&&jsx5(ErrorNote2,{retry:reload,children:T.load(state.reason)}),state.kind==="ok"&&(state.runs.length===0?jsx5("p",{className:"band-workshops-note","data-follow-empty":true,children:T.empty}):jsxs5(Fragment4,{children:[jsx5("ul",{className:"band-workshops-follow-list",children:state.runs.map(r=>jsx5(Row,{r},`${r.pluginName}@${r.triggerVersion}:${r.kind}:${r.createdAt}`))}),state.runs.length>=FOLLOW_RUNS_PAGE&&jsx5("p",{className:"band-workshops-note",children:T.more})]}))]})}var ROLE_LABEL={owner:"\u521B\u5EFA\u4EBA",maintainer:"\u7BA1\u7406\u5458"};var lastOne=v=>v.people.length<=1;function AddMaintainer({api,directory,workshop,view,onDone,onCancel}){const[picked,setPicked]=useState4(null);const[busy,setBusy]=useState4(false);const[error,setError]=useState4(null);const disabled=view.people.map(p=>({id:p.userId,reason:"\u5DF2\u7ECF\u80FD\u7BA1\u8FD9\u4E2A\u5DE5\u574A"}));async function submit(){if(!picked)return setError("\u8FD8\u6CA1\u9009\u4EBA\uFF1A\u641C\u59D3\u540D\u3001ldap \u6216\u90E8\u95E8");setBusy(true);setError(null);try{onDone(await api.add(workshop,picked.id))}catch(e){setError(`\u6CA1\u52A0\u4E0A\uFF1A${errorText(e)}`)}finally{setBusy(false)}}return jsxs6("form",{className:"band-workshops-people-form","aria-label":"\u6DFB\u52A0\u7BA1\u7406\u5458",onSubmit:e=>{e.preventDefault();void submit()},children:[jsxs6("div",{className:"band-workshops-people-field",children:[jsxs6("span",{className:"band-workshops-people-label",children:["\u8BBE\u8C01\u4E3A\u7BA1\u7406\u5458 ",jsx6("span",{className:"band-workshops-people-hint",children:"\u5FC5\u586B"})]}),jsx6(PersonSearch,{label:"\u8BBE\u8C01\u4E3A\u7BA1\u7406\u5458",directory,picked:picked?[picked]:[],onPick:p=>{setPicked(p[0]??null);setError(null)},onUnpick:()=>setPicked(null),disabled,allowUnknown:true,busy})]}),jsx6("p",{className:"band-workshops-people-hint",children:"\u7BA1\u7406\u5458\u80FD\u53D1\u5E03\u65B0\u7248\u3001\u6539\u5DE5\u574A\u8BBE\u7F6E\u3001\u7BA1\u5DE5\u574A\u7684\u7BA1\u7406\u5458\uFF1B\u4E0D\u662F\u5DE5\u574A\u6210\u5458\u7684\u4EBA\u4F1A\u540C\u65F6\u6210\u4E3A\u6210\u5458\u3002"}),jsx6(ErrorNote3,{children:error}),jsxs6("div",{className:"band-workshops-people-actions",children:[jsx6("button",{type:"submit",className:"btn primary sm",disabled:busy||!picked,children:busy?"\u6B63\u5728\u6DFB\u52A0\u2026":"\u8BBE\u4E3A\u7BA1\u7406\u5458"}),jsx6("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function ConfirmRemoveMaintainer({api,workshop,person,self,onDone,onCancel}){const[busy,setBusy]=useState4(false);const[error,setError]=useState4(null);async function remove(){setBusy(true);setError(null);try{onDone(await api.remove(workshop,person.userId))}catch(e){setError(errorText(e))}finally{setBusy(false)}}return jsxs6("fieldset",{className:"band-workshops-people-form","aria-label":`\u79FB\u9664 ${person.displayName}`,children:[jsx6("p",{children:self?"\u628A\u81EA\u5DF1\u4ECE\u7BA1\u7406\u5458\u91CC\u79FB\u9664\uFF1F\u4F60\u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3001\u80FD\u7528\u5B83\u5EFA\u9879\u76EE\uFF0C\u4F46\u4E0D\u80FD\u518D\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u8981\u522B\u7684\u7BA1\u7406\u5458\u518D\u52A0\u56DE\u6765\u3002":`\u628A ${person.displayName} \u4ECE\u7BA1\u7406\u5458\u91CC\u79FB\u9664\uFF1F${person.displayName} \u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3001\u80FD\u7528\u5B83\u5EFA\u9879\u76EE\u3002`}),jsx6(ErrorNote3,{children:error}),jsxs6("div",{className:"band-workshops-people-actions",children:[jsx6("button",{type:"button",className:"btn danger sm",disabled:busy,onClick:()=>void remove(),children:busy?"\u6B63\u5728\u79FB\u9664\u2026":"\u79FB\u9664"}),jsx6("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function ConfirmTransferOwner({transfer,workshop,person,owner,self,onDone,onCancel}){const[busy,setBusy]=useState4(false);const[error,setError]=useState4(null);async function go(){setBusy(true);setError(null);try{onDone(await transfer(workshop,person.userId))}catch(e){setError(`\u6CA1\u8F6C\u4EA4\u6210\uFF1A${errorText(e)}`)}finally{setBusy(false)}}const who=person.displayName;const text=self?`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${who}\uFF1F\u8F6C\u4EA4\u540E\u4F60\u53D8\u6210\u7BA1\u7406\u5458\uFF0C\u518D\u8F6C\u4EA4\u521B\u5EFA\u4EBA\u53EA\u6709 ${who} \u80FD\u505A\u3002`:owner?`\u628A\u521B\u5EFA\u4EBA\u4ECE ${owner.displayName} \u8F6C\u4EA4\u7ED9 ${who}\uFF1F${owner.displayName} \u53D8\u6210\u7BA1\u7406\u5458\u3002`:`\u8BA9 ${who} \u6210\u4E3A\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\uFF1F\u4E4B\u540E\u518D\u8F6C\u4EA4\u521B\u5EFA\u4EBA\u7531 ${who} \u505A\u3002`;return jsxs6("fieldset",{className:"band-workshops-people-form","aria-label":`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${who}`,children:[jsx6("p",{children:text}),jsx6(ErrorNote3,{children:error}),jsxs6("div",{className:"band-workshops-people-actions",children:[jsx6("button",{type:"button",className:"btn primary sm",disabled:busy,onClick:()=>void go(),children:busy?"\u6B63\u5728\u8F6C\u4EA4\u2026":"\u8F6C\u4EA4"}),jsx6("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function Maintainers({api,directory,workshop,me}){const[view,setView]=useState4(null);const[error,setError]=useState4(null);const[open,setOpen]=useState4(null);const[tick,setTick]=useState4(0);useEffect4(()=>{let live=true;setError(null);api.get(workshop).then(v=>live&&setView(v),e=>live&&setError(errorText(e)));return()=>{live=false}},[api,workshop,tick]);const done=next=>{setView(next);setOpen(null)};if(view===null){return error?jsxs6(ErrorNote3,{retry:()=>setTick(t=>t+1),children:["\u7BA1\u7406\u5458\u540D\u5355\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}):jsx6("p",{className:"band-workshops-note","aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u7BA1\u7406\u5458\u2026"})}const order=view.people.map(p=>p.userId);const owner=view.people.find(p=>p.role==="owner")??null;const transfer=view.canTransfer?api.transfer:void 0;return jsxs6("div",{className:"band-workshops-people",children:[view.canManage&&jsx6("div",{className:"band-workshops-people-bar",children:open?.kind==="add"?jsx6(AddMaintainer,{api,directory,workshop,view,onDone:done,onCancel:()=>setOpen(null)}):jsx6("button",{type:"button",className:"btn primary sm",onClick:()=>setOpen({kind:"add"}),children:"\u6DFB\u52A0\u7BA1\u7406\u5458"})}),view.canManage&&owner===null&&view.people.length>0&&jsxs6("p",{className:"band-workshops-note",children:["\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u521B\u5EFA\u4EBA\uFF08\u539F\u521B\u5EFA\u4EBA\u5DF2\u79BB\u5F00\uFF09\u3002",transfer?"\u8BF7\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\u3002":"Band \u7BA1\u7406\u5458\u80FD\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\u3002"]}),view.people.length===0?jsx6("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u5DE5\u574A\u7BA1\u7406\u5458\uFF0C\u7531 Band \u7BA1\u7406\u5458\u7BA1\u3002"}):jsx6("ul",{className:"band-workshops-people-card","aria-label":`\u7BA1\u7406\u5458 ${view.people.length}`,children:view.people.map(p=>{const removing=open?.kind==="remove"&&open.id===p.userId;const transferring=open?.kind==="transfer"&&open.id===p.userId;const removable=view.canManage&&p.role==="maintainer"&&!lastOne(view);return jsxs6("li",{className:"band-workshops-people-row",children:[jsxs6("div",{className:"band-workshops-people-line",children:[jsx6(Avatar,{id:p.userId,name:p.displayName,order,size:"md",decorative:true}),jsxs6("span",{className:"band-workshops-people-who",children:[jsx6("b",{title:p.displayName,children:p.displayName}),jsxs6("span",{children:[ROLE_LABEL[p.role]," \xB7 ",p.userId]})]}),(removable&&!removing||transfer&&p.role==="maintainer"&&!transferring)&&jsxs6("span",{className:"band-workshops-people-ops",children:[transfer&&p.role==="maintainer"&&!transferring&&jsx6("button",{type:"button",className:"btn ghost sm","aria-label":`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${p.displayName}`,onClick:()=>setOpen({kind:"transfer",id:p.userId}),children:"\u8F6C\u4EA4\u521B\u5EFA\u4EBA"}),removable&&!removing&&jsx6("button",{type:"button",className:"btn ghost sm","aria-label":`\u79FB\u9664 ${p.displayName}`,onClick:()=>setOpen({kind:"remove",id:p.userId}),children:"\u79FB\u9664"})]}),view.canManage&&p.role==="maintainer"&&lastOne(view)&&jsx6("span",{className:"band-workshops-people-hint band-workshops-people-ops",children:"\u6700\u540E\u4E00\u4E2A\u7BA1\u7406\u5458\uFF0C\u4E0D\u80FD\u79FB\u9664"})]}),transferring&&transfer&&jsx6(ConfirmTransferOwner,{transfer,workshop,person:p,owner,self:owner?.userId===me,onDone:done,onCancel:()=>setOpen(null)}),removing&&jsx6(ConfirmRemoveMaintainer,{api,workshop,person:p,self:p.userId===me,onDone:done,onCancel:()=>setOpen(null)})]},p.userId)})}),jsx6("p",{className:"band-workshops-note",children:"\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u53D1\u5E03\u65B0\u7248\u3001\u6539\u5DE5\u574A\u8BBE\u7F6E\u3001\u7BA1\u5DE5\u574A\u7684\u7BA1\u7406\u5458\u3002\u521B\u5EFA\u4EBA\u4E0D\u80FD\u79FB\u9664\uFF0C\u8981\u5148\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\uFF1B\u5DE5\u574A\u81F3\u5C11\u8981\u7559\u4E00\u4E2A\u7BA1\u7406\u5458\u3002 \u79FB\u9664\u7684\u7BA1\u7406\u5458\u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3002"})]})}function useProjectModel(ctx,policy){const api=ctx.app.data.write?.modelCredentials;const active=!!api&&policy!==void 0&&policy!=="off";const[state,setState]=useState5(active?{kind:"loading"}:{kind:"hidden"});const[forPolicy,setForPolicy]=useState5(void 0);const[selected,select]=useState5(null);useEffect5(()=>{if(!active){setState({kind:"hidden"});setForPolicy(policy);return}if(!api)return;let live=true;setState(s=>s.kind==="hidden"||s.kind==="loading"?{kind:"loading"}:s);api.list().then(r=>{if(!live)return;setForPolicy(policy);if(r===null)return setState({kind:"hidden"});if(r.credentials.length===0)return setState({kind:"none",required:policy==="require",...r.provision?{provision:r.provision}:{}});setState({kind:"pick",credentials:r.credentials,presets:r.presets,required:policy==="require"});const has=id=>r.credentials.some(c=>c.id===id);select(cur=>{if(cur!==null&&has(cur))return cur;return(r.credentials.find(c=>c.isDefault)??r.credentials[0])?.id??null})},()=>{if(!live)return;setForPolicy(policy);setState({kind:"hidden"})});return()=>{live=false}},[api,policy,active]);const settled=forPolicy===policy?state:active?{kind:"loading"}:state;return{state:settled,selected,select}}function projectModelBlocked(state){return state.kind==="loading"||state.kind==="none"&&state.required&&provisionConsentOf(state)===null}function provisionConsentOf(state){if(state.kind!=="none"||!state.required||!state.provision)return null;const s=state.provision.status;return s==="none"||s==="pending"?{quotaUsd:state.provision.quotaUsd}:null}function projectModelMissing(state){if(state.kind==="loading")return"\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u914D\u7F6E\u2026";return projectModelBlocked(state)?"\u8FD8\u5DEE\u6A21\u578B\u914D\u7F6E\uFF1A\u4F60\u540D\u4E0B\u6CA1\u6709\u53EF\u9009\u7684":null}function selectedCredential(state,selected){return state.kind==="pick"?state.credentials.find(c=>c.id===selected)??null:null}function modelCredentialIdOf(state,selected){return selectedCredential(state,selected)?.id}function ProjectModelField({state,selected,select,onConfigure,disabled=false}){const id=useId2();if(state.kind==="hidden"||state.kind==="loading")return null;const consent=provisionConsentOf(state);if(consent){return jsx7("div",{className:"band-workshops-model-pick",children:jsxs7("p",{className:"band-workshops-note",children:[provisionConsentText(consent.quotaUsd)," ",jsx7("button",{type:"button",className:"btn sm",onClick:onConfigure,disabled,children:"\u6539\u7528\u81EA\u5DF1\u7684 key"})]})})}const required=state.required;const picked=selectedCredential(state,selected);const note=projectModelNote(required?"require":"allow",picked);const labelOf=preset=>preset===CUSTOM_MODEL_PRESET_ID?"\u81EA\u5B9A\u4E49":state.kind==="pick"?state.presets.find(p=>p.id===preset)?.label??preset:preset;return jsxs7("div",{className:"band-workshops-model-pick",children:[jsxs7("label",{className:"band-workshops-field",htmlFor:id,children:[jsxs7("span",{children:[PROJECT_MODEL_HEADING,required?jsx7("em",{className:"band-workshops-req",children:"\u5FC5\u586B"}):null]}),state.kind==="pick"?jsxs7("select",{id,value:selected??"",disabled,onChange:e=>select(e.target.value===""?null:e.target.value),children:[selected===null?jsx7("option",{value:"",children:"\u8BF7\u9009\u4E00\u4EFD"}):null,state.credentials.map(c=>jsxs7("option",{value:c.id,children:[credentialOptionLabel(c,labelOf(c.preset)),c.isDefault?"\uFF08\u9ED8\u8BA4\uFF09":""]},c.id))]}):jsx7("select",{id,value:"",disabled:true,children:jsx7("option",{value:"",children:required?"\u8FD8\u6CA1\u6709\u53EF\u9009\u7684":"\u5DE5\u574A\u7684\u56E2\u961F key"})})]}),jsxs7("p",{className:"band-workshops-note",children:[note.text,note.action&&jsxs7(Fragment5,{children:[" ",jsx7("button",{type:"button",className:"btn sm",onClick:onConfigure,children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"})]})]})]})}var MODEL_POLL_MS=3e3;function Steps({current,done=false}){return jsxs8("ol",{className:"band-workshops-steps","aria-label":"\u65B0\u5EFA\u5DE5\u574A\u7684\u6B65\u9AA4",children:[jsx8("li",{"data-n":"1",className:current===2?"is-done":void 0,"aria-current":current===1?"step":void 0,children:"\u57FA\u672C\u4FE1\u606F"}),jsx8("li",{"data-n":"2",className:done?"is-done":void 0,"aria-current":current===2&&!done?"step":void 0,children:"\u914D\u7F6E\u6A21\u578B"})]})}function useModelDeployment(ctx){const api=ctx.app.data.write?.workshopModel;const{data,error,reload}=useAppData(ctx,()=>api?api.deployment():Promise.resolve(null),[api]);return{deployment:data,error:data===void 0?error:null,reload}}var NOT_PROVISIONED={state:"not_provisioned",hubProject:"ready",agent:"ready"};function modelOf(w){return w.model??NOT_PROVISIONED}function newProjectBlocked(w){const m=modelOf(w);if(m.state==="not_provisioned")return void 0;if(w.version!==void 0&&repoBuilding({version:w.version,status:w.status}))return"\u5DE5\u574A\u51C6\u5907\u597D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";const detail=w.canAdmin?m.what:m.brief??m.what;if(modelMissing(m,w.userModelKey))return w.canAdmin?"\u914D\u597D\u6A21\u578B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002":"\u5DE5\u574A\u7BA1\u7406\u5458\u914D\u597D\u6A21\u578B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";if(m.agent==="failed"){if(m.owner==="waiting")return`Agent \u8FD8\u6CA1\u51C6\u5907\u597D\uFF0C\u6B63\u5728\u7B49\uFF1A${detail??"\u5B83\u81EA\u5DF1\u597D"}\u3002`;if(m.owner==="platform")return`Agent \u6CA1\u51C6\u5907\u597D\uFF0C\u9700\u8981\u5E73\u53F0\u7BA1\u7406\u5458\u5904\u7406\uFF1A${detail??"\u539F\u56E0\u672A\u77E5"}\u3002`;const fix=detail?`\uFF1A${detail}`:"";return w.canAdmin?`Agent \u6CA1\u51C6\u5907\u597D${fix}\uFF0C\u70B9\u300C\u91CD\u8BD5\u300D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002`:`Agent \u6CA1\u51C6\u5907\u597D${fix}\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u91CD\u8BD5\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002`}if(m.agent!=="ready")return"Agent \u51C6\u5907\u597D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";return void 0}function agentLabel(agent){return agent==="failed"?"\u6CA1\u51C6\u5907\u597D":agent==="awaiting_promotion"?"\u7B49\u4E0A\u7EBF":agent==="ready"?"\u5DF2\u5C31\u7EEA":"\u51C6\u5907\u4E2D"}function waitedText(ms){const min=Math.floor(Math.max(0,ms)/6e4);if(min<1)return"\u4E0D\u5230 1 \u5206\u949F";if(min<60)return`${min} \u5206\u949F`;const h=Math.floor(min/60);const rest=min%60;return rest===0?`${h} \u5C0F\u65F6`:`${h} \u5C0F\u65F6 ${rest} \u5206\u949F`}function provisionProgress(m,now=Date.now()){if(m.state==="not_provisioned"||m.hasRequest===false)return void 0;if(m.agent==="ready"||m.agent==="failed"||m.hubProject==="failed")return void 0;const t=m.since===void 0?Number.NaN:Date.parse(m.since);const waited=Number.isNaN(t)?"":`\u5DF2\u7ECF\u7B49\u4E86 ${waitedText(now-t)}\u3002`;if(m.agent==="awaiting_promotion")return{step:3,text:`\u7B2C 3 \u6B65\uFF0C\u5171 3 \u6B65\uFF1AAgent \u5DF2\u7ECF\u505A\u597D\uFF0C\u7B49 Band \u7BA1\u7406\u5458\u4E0A\u7EBF\uFF1B\u4E0A\u7EBF\u540E\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u8981\u5728\u5DE5\u574A\u9875\u70B9\u300C\u91CD\u8BD5\u300D\uFF0C\u624D\u4F1A\u7EE7\u7EED\u3002${waited}`};if(m.hubProject==="pending")return{step:1,text:`\u7B2C 1 \u6B65\uFF0C\u5171 3 \u6B65\uFF1A\u6B63\u5728\u4E3A\u8FD9\u4E2A\u5DE5\u574A\u5EFA AgentHub \u9879\u76EE\u3002${waited}`};return{step:2,text:`\u7B2C 2 \u6B65\uFF0C\u5171 3 \u6B65\uFF1A\u6B63\u5728\u51C6\u5907 Agent\uFF1A\u5199\u5165\u5B9A\u4E49\u5E76\u53D1\u5E03\u3002${waited}`}}function AgentFailedNote({error,owner,what,brief,retry}){const detail=(retry?what:brief??what)??error??"\u539F\u56E0\u672A\u77E5";if(owner==="waiting")return jsxs8("div",{className:"band-workshops-retry",children:[jsxs8("output",{className:"band-workshops-status",children:[jsx8("span",{className:"chip s-running",children:"\u6B63\u5728\u7B49"}),"\u3000",detail,"\u3002"]}),retry&&jsx8(RetryProvision,{api:retry.api,workshop:retry.workshop,onDone:retry.onDone})]});const platform=owner==="platform";return jsxs8("div",{className:"band-workshops-retry",children:[jsx8(ErrorNote4,{children:platform?`\u9700\u8981\u5E73\u53F0\u7BA1\u7406\u5458\u5904\u7406\uFF1A${detail}\u3002`:`\u5DE5\u574A\u7684 Agent \u6CA1\u51C6\u5907\u597D\uFF1A${detail}\u3002`}),retry&&jsx8(RetryProvision,{api:retry.api,workshop:retry.workshop,onDone:retry.onDone,afterFix:platform})]})}function modelMissing(m,userModelKey){if(m===void 0||m.state==="not_provisioned")return false;return userModelKey!=="require"&&m.state!=="configured"}var SAVE_IN_PROGRESS="SAVE_IN_PROGRESS";function writeFailedText(reason){if(reason==="FORBIDDEN"||reason==="INSUFFICIENT_SCOPE")return"\u7F3A\u5C11 model-services:write \u6743\u9650";if(reason==="MODEL_SERVICE_NOT_UNIQUE")return"\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u91CC\u6709\u4E0D\u6B62\u4E00\u4E2A\u6A21\u578B\u670D\u52A1";if(reason===SAVE_IN_PROGRESS)return"\u53E6\u4E00\u4F4D\u7BA1\u7406\u5458\u6B63\u5728\u4FDD\u5B58";return reason??"\u539F\u56E0\u672A\u77E5"}function goAbout(ctx,id){ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}})}function RetryProvision({api,workshop,onDone,afterFix=false,label="\u91CD\u8BD5"}){const[busy,setBusy]=useState6(false);const[note,setNote]=useState6(null);const run=async()=>{setBusy(true);setNote(null);try{await api.retryProvision(workshop);onDone()}catch(e){const status=typeof e==="object"&&e!==null&&"details"in e?e.details?.status:void 0;setNote(status==="pending"||status==="running"?"\u6B63\u5728\u51C6\u5907\uFF0C\u4E0D\u7528\u518D\u70B9\u3002":status==="done"?"\u5DF2\u7ECF\u51C6\u5907\u597D\u4E86\u3002":`\u6CA1\u91CD\u8BD5\u6210\uFF1A${errorText2(e)}`)}finally{setBusy(false)}};return jsxs8(Fragment7,{children:[jsx8("button",{type:"button",className:"btn sm",disabled:busy,onClick:()=>void run(),children:busy?"\u6B63\u5728\u91CD\u8BD5\u2026":label}),afterFix&&jsx8("span",{className:"band-workshops-hint",children:"\u5E73\u53F0\u4FEE\u597D\u540E\u70B9"}),note&&jsx8("output",{className:"band-workshops-hint","aria-live":"polite",children:note})]})}function ModelSetup({ctx,id}){const{data:w,error,reload}=useAppData(ctx,d=>d.workshop(id),[id]);const api=ctx.app.data.write?.workshopModel;const{deployment,error:deploymentError,reload:reloadDeployment}=useModelDeployment(ctx);const waiting=!!w&&(w.status==="provisioning"||modelOf(w).state!=="not_provisioned"&&modelOf(w).hasRequest!==false&&(modelOf(w).hubProject==="pending"||modelOf(w).agent==="preparing"));useEffect6(()=>{if(!waiting)return;const t=setInterval(reload,MODEL_POLL_MS);return()=>clearInterval(t)},[waiting,reload]);if(error&&w===void 0)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx}),jsxs8(ErrorNote4,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(deploymentError&&deployment===void 0)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx}),jsxs8(ErrorNote4,{retry:reloadDeployment,children:["\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",deploymentError]})]});const policyPending=!!w&&w.status==="provisioning"&&w.userModelKey===void 0;if(policyPending&&error)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs8(ErrorNote4,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(w===void 0||deployment===void 0||policyPending)return jsx8("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsx8("span",{className:"band-workshops-sk is-block"})});if(w===null)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx}),jsxs8("p",{className:"band-workshops-note",children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id,"\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"]})]});if(!api||deployment===null||modelOf(w).state==="not_provisioned"&&w.status!=="provisioning"||w.userModelKey==="require")return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx8("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsx8("p",{className:"band-workshops-note",children:w.userModelKey==="require"?"\u8FD9\u4E2A\u5DE5\u574A\u7528\u6210\u5458\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u6CA1\u6709\u56E2\u961F\u6A21\u578B\u8FD9\u4E00\u6B65\uFF1B\u6BCF\u4E2A\u4EBA\u5728\u4E2A\u4EBA\u8BBE\u7F6E\u91CC\u914D\u597D\u81EA\u5DF1\u7684\u6A21\u578B key\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u8FD9\u4E00\u6B65\uFF1A\u6A21\u578B\u5728\u5B83\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u91CC\u7BA1\u3002"}),w.userModelKey==="require"&&w.canAdmin&&api&&takeoverNeeded(w)&&jsx8(HubProjectLine,{w,api,onRetried:reload})]});if(!w.canAdmin)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx8("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsx8("div",{className:"band-workshops-callout",children:jsx8("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u914D\u6A21\u578B\u3002\u8981\u914D\u6216\u8981\u6362 key\uFF0C\u8BF7\u627E\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u3002"})}),jsx8("div",{className:"band-workshops-actions is-start",children:jsx8("button",{type:"button",className:"btn",onClick:()=>goAbout(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A"})})]});return jsx8(ModelPage,{ctx,w,api,deployment,reloadWorkshop:reload})}function ModelPage({ctx,w,api,deployment,reloadWorkshop}){const hubReady=modelOf(w).hubProject==="ready";const canSave=hubReady||modelOf(w).hasRequest===false;const[view,setView]=useState6(null);const[viewError,setViewError]=useState6(null);const[revision,setRevision]=useState6(0);useEffect6(()=>{if(!hubReady)return;let live=true;setViewError(null);api.get(w.id).then(v=>live&&setView(v),e=>live&&setViewError(errorText2(e)));return()=>{live=false}},[api,w.id,hubReady,revision,modelOf(w).state,modelOf(w).agent]);const status=view?.status??w.model;const[reconfigure,setReconfigure]=useState6(false);const[saved,setSaved]=useState6(null);const[savedAgent,setSavedAgent]=useState6();const setup=status===void 0||status.state==="unconfigured";const afterSave=from=>agent=>{if(from==="setup"&&w.firstMessage&&deployment?.workshopEdit===true&&ctx.app.data.write?.workshopEdit){ctx.app.navigate({page:`${SELF}/edit`,params:{workshop:w.id}});return}setSaved(from);setSavedAgent(agent);setReconfigure(false);setRevision(n=>n+1)};if(viewError!==null&&!view)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs8(ErrorNote4,{retry:()=>setRevision(n=>n+1),children:["\u6A21\u578B\u7684\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A",viewError]})]});if(saved)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:saved==="setup"?"\u914D\u7F6E\u6A21\u578B":"\u6A21\u578B"}),jsxs8("div",{children:[saved==="setup"&&jsx8(Steps,{current:2,done:true}),jsx8("h1",{className:"band-workshops-name",children:saved==="setup"?"\u914D\u7F6E\u6A21\u578B":"\u6A21\u578B"})]}),jsx8(SavedResult,{ctx,w,agent:savedAgent??modelOf(w).agent})]});if(setup)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u914D\u7F6E\u6A21\u578B"}),jsxs8("div",{children:[jsx8(Steps,{current:2}),jsx8("h1",{className:"band-workshops-name",children:"\u914D\u7F6E\u6A21\u578B"}),jsxs8("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684\u56DE\u5408\u7528\u8FD9\u91CC\u586B\u7684 key\uFF0C\u82B1\u8D39\u8BB0\u5728\u8FD9\u628A key \u4E0A\u3002\u914D\u597D\u4E4B\u524D\uFF0C\u8FD9\u4E2A\u5DE5\u574A\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]})]}),jsx8(HubProjectLine,{w,api,onRetried:reloadWorkshop}),jsx8(ModelForm,{ctx,w,api,deployment,canSave,mode:"setup",onSaved:afterSave("setup")})]});if(reconfigure)return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx8("h1",{className:"band-workshops-name",children:"\u91CD\u65B0\u914D\u7F6E\u6A21\u578B"}),jsx8(ModelForm,{ctx,w,api,deployment,canSave,mode:"reconfigure",onSaved:afterSave("reconfigure"),onCancel:()=>setReconfigure(false)})]});return jsxs8("main",{className:"band-workshops-screen",children:[jsx8(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs8("div",{children:[jsx8("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsxs8("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684\u56DE\u5408\u7528\u8FD9\u91CC\u914D\u7684\u6A21\u578B\uFF0C\u82B1\u8D39\u8BB0\u5728\u8FD9\u91CC\u586B\u7684 key \u4E0A\u3002"]})]}),jsxs8(Fragment7,{children:[jsx8(ModelFacts,{status,deployment}),status?.state==="configured"&&status.agent==="failed"&&jsx8(AgentFailedNote,{error:status.error,owner:status.owner,what:status.what,brief:status.brief,retry:{api,workshop:w.id,onDone:reloadWorkshop}}),status?.state==="missing"?jsx8("p",{className:"band-workshops-why is-bad",children:"AgentHub \u91CC\u627E\u4E0D\u5230\u8FD9\u4E2A\u5DE5\u574A\u5728\u7528\u7684\u6A21\u578B\u670D\u52A1\uFF08\u53EF\u80FD\u88AB\u5F52\u6863\u4E86\uFF09\u3002\u91CD\u65B0\u914D\u7F6E\u4E00\u6B21\uFF0C\u5DE5\u574A\u624D\u80FD\u7EE7\u7EED\u5F00\u5DE5\u3002"}):status?.state==="ambiguous"?jsx8("p",{className:"band-workshops-why is-bad",children:"AgentHub \u91CC\u8FD9\u4E2A\u5DE5\u574A\u6709\u4E0D\u6B62\u4E00\u4E2A\u540C\u540D\u7684\u6A21\u578B\u670D\u52A1\uFF0CBand \u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4E2A\u3002\u627E Band \u7BA1\u7406\u5458\u5728 AgentHub \u91CC\u5F52\u6863\u591A\u4F59\u7684\uFF0C\u518D\u70B9\u300C\u91CD\u8BD5\u300D\u3002"}):jsx8("div",{className:"band-workshops-callout",children:jsx8("p",{children:"key \u5728\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u91CC\uFF0CBand \u770B\u4E0D\u5230\u4E5F\u4E0D\u4FDD\u5B58\u3002\u8981\u6362 key\uFF0C\u70B9\u300C\u91CD\u65B0\u914D\u7F6E\u300D\u518D\u586B\u4E00\u6B21\u3002"})}),jsxs8("div",{className:"band-workshops-actions is-start",children:[jsx8("button",{type:"button",className:"btn primary",onClick:()=>setReconfigure(true),children:"\u91CD\u65B0\u914D\u7F6E"}),status?.state==="ambiguous"&&jsx8(RetryProvision,{api,workshop:w.id,onDone:reloadWorkshop})]})]})]})}function HubProjectLine({w,api,onRetried}){const hub=modelOf(w).hubProject??"pending";if(hub==="ready")return null;if(hub==="failed")return jsxs8("div",{className:"band-workshops-retry",children:[jsxs8(ErrorNote4,{children:["\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u6CA1\u5EFA\u6210\uFF1A",modelOf(w).error??"\u539F\u56E0\u672A\u77E5"]}),jsx8(RetryProvision,{api,workshop:w.id,onDone:onRetried})]});if(takeoverNeeded(w))return jsxs8("div",{className:"band-workshops-retry",children:[jsx8("p",{className:"band-workshops-note",children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF1A\u5B83\u662F\u5728\u4EE3\u5EFA\u529F\u80FD\u6253\u5F00\u4E4B\u524D\u5EFA\u7684\u3002\u70B9\u4E0B\u9762\u7684\u6309\u94AE\u8BA9 Band \u7ED9\u5B83\u5EFA AgentHub \u9879\u76EE\uFF0C\u5EFA\u597D\u4E4B\u540E\u624D\u80FD\u586B\u6A21\u578B key\u3002"}),jsx8(RetryProvision,{api,workshop:w.id,onDone:onRetried,label:"\u8BA9 Band \u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A"})]});return jsxs8("output",{className:"band-workshops-status",children:[jsx8("span",{className:"chip s-running",children:"\u6B63\u5728\u5EFA\u5DE5\u574A\u7684 AgentHub \u9879\u76EE"}),"\u3000","\u597D\u4E86\u5C31\u80FD\u4FDD\u5B58\uFF0C\u4E00\u822C\u4E0D\u5230\u4E00\u5206\u949F\uFF0C\u8FD9\u91CC\u4F1A\u81EA\u52A8\u5237\u65B0\u3002\u53EF\u4EE5\u5148\u586B\u3002"]})}function ModelFacts({status,deployment}){const configured=status?.state==="configured";return jsxs8("dl",{className:"band-workshops-facts band-workshops-model-facts",children:[jsx8("dt",{children:"\u72B6\u6001"}),jsx8("dd",{children:configured?jsx8("span",{className:"chip s-done",children:"\u5DF2\u914D\u7F6E"}):jsx8("span",{className:"chip s-failed",children:"\u8981\u91CD\u65B0\u914D\u7F6E"})}),configured&&jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u6765\u6E90"}),jsx8("dd",{children:"ModelGate"}),jsx8("dt",{children:"\u6A21\u578B"}),jsx8("dd",{children:status?.model??deployment.model}),status?.configuredBy&&jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u914D\u7F6E\u4EBA"}),jsxs8("dd",{children:[jsx8(Avatar2,{id:status.configuredBy.userId,name:status.configuredBy.displayName,size:"xs",decorative:true})," ",status.configuredBy.displayName,status.verifiedAt&&` \xB7 ${shortTime(status.verifiedAt)}`]})]}),status?.verifiedAt&&jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u4E0A\u6B21\u6821\u9A8C"}),jsxs8("dd",{children:[shortTime(status.verifiedAt)," \u901A\u8FC7"]})]}),status&&status.agent!=="ready"&&jsxs8(Fragment7,{children:[jsx8("dt",{children:"Agent"}),jsx8("dd",{children:agentLabel(status.agent)})]})]})]})}function SavedResult({ctx,w,agent}){return jsxs8("div",{className:"band-workshops-form",children:[jsxs8("div",{className:"band-workshops-result","aria-live":"polite",children:[jsxs8("div",{className:"band-workshops-result-line",children:[jsx8("span",{className:"chip s-done",children:"\u5DF2\u914D\u7F6E"}),"\u6821\u9A8C\u901A\u8FC7\uFF0C\u5DF2\u4EA4\u7ED9 AgentHub\u3002"]}),jsx8("p",{className:"band-workshops-hint",children:agent==="ready"?"Agent \u5DF2\u5C31\u7EEA\uFF0C\u53EF\u4EE5\u65B0\u5EFA\u9879\u76EE\u4E86\u3002":agent==="awaiting_promotion"?"Band \u63A5\u7740\u51C6\u5907\u5DE5\u574A\u7684 Agent\uFF1B\u51C6\u5907\u597D\u4E4B\u524D\u4ECD\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u7B49 Band \u7BA1\u7406\u5458\u628A\u5B83\u4E0A\u7EBF\u3002":"\u63A5\u4E0B\u6765 Band \u4F1A\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent\uFF0C\u901A\u5E38\u8981 15\u201325 \u5206\u949F\u3002\u51C6\u5907\u597D\u4E4B\u524D\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u597D\u4E86\u5DE5\u574A\u9875\u4F1A\u81EA\u52A8\u5237\u65B0\u3002"})]}),jsx8("div",{className:"band-workshops-actions is-start",children:jsx8("button",{type:"button",className:"btn primary",onClick:()=>goAbout(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A\u9875"})})]})}var RESULT_TITLE={unauthorized:"key \u65E0\u6548",forbidden:"key \u65E0\u6548",model_unavailable:"\u6A21\u578B\u4E0D\u53EF\u7528",unreachable:"\u8FDE\u4E0D\u4E0A ModelGate",write_failed:"\u6CA1\u4EA4\u7ED9 AgentHub"};function resultText(outcome,reason,model){switch(outcome){case"unauthorized":return"ModelGate \u4E0D\u8BA4\u8FD9\u628A key\uFF08401\uFF09\u3002\u6838\u5BF9\u662F\u4E0D\u662F\u6574\u628A\u590D\u5236\u3001\u6709\u6CA1\u6709\u8FC7\u671F\u6216\u88AB\u505C\u7528\uFF0C\u6539\u597D\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";case"forbidden":return"\u8FD9\u628A key \u6CA1\u6709\u8C03\u7528\u6743\u9650\uFF08403\uFF09\u3002\u6838\u5BF9\u662F\u4E0D\u662F\u6574\u628A\u590D\u5236\u3001\u6709\u6CA1\u6709\u8FC7\u671F\u6216\u88AB\u505C\u7528\uFF0C\u6539\u597D\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";case"model_unavailable":return jsxs8(Fragment7,{children:["ModelGate \u8BA4\u8FD9\u628A key\uFF0C\u4F46\u8FD9\u628A key \u6CA1\u5F00\u901A Band \u7528\u7684\u6A21\u578B\uFF08",jsx8("code",{children:model}),"\uFF09\u3002\u5728 ModelGate \u7ED9\u8FD9\u628A key \u5F00\u901A\u540E\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002"]});case"unreachable":return"10 \u79D2\u5185\u6CA1\u8FDE\u4E0A ModelGate\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u7A0D\u540E\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\uFF1B\u4E00\u76F4\u8FDE\u4E0D\u4E0A\u5C31\u627E Band \u7BA1\u7406\u5458\u3002";case"write_failed":if(reason===SAVE_IN_PROGRESS)return"\u53E6\u4E00\u4F4D\u7BA1\u7406\u5458\u6B63\u5728\u4FDD\u5B58\u8FD9\u4E2A\u5DE5\u574A\u7684\u6A21\u578B\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u7A0D\u7B49\u7247\u523B\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";return`\u6821\u9A8C\u901A\u8FC7\u4E86\uFF0C\u4F46\u5199\u8FDB AgentHub \u5931\u8D25\uFF1A${writeFailedText(reason)}\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u627E Band \u7BA1\u7406\u5458\u3002`}}function ModelForm({ctx,w,api,deployment,canSave,mode,onSaved,onCancel}){const[key,setKey]=useState6("");const[phase,setPhase]=useState6({kind:"idle"});const input=useRef2(null);const keyId=useId3();const hintId=useId3();const checking=phase.kind==="checking";const keyBad=phase.kind==="missing"||phase.kind==="failed"&&(phase.outcome==="unauthorized"||phase.outcome==="forbidden");const notSaved=mode==="setup"?"\u8FD9\u6B21\u6CA1\u6709\u4FDD\u5B58\uFF0C\u5DE5\u574A\u4ECD\u662F\u300C\u5F85\u914D\u7F6E\u6A21\u578B\u300D\u3002":"\u539F\u6765\u7684\u914D\u7F6E\u6CA1\u53D8\u3002";const submit=async()=>{if(checking||!canSave)return;const value=key.trim();if(value===""){setPhase({kind:"missing"});input.current?.focus();return}setPhase({kind:"checking"});try{const r=await api.configure(w.id,{source:"modelgate",key:value});if(r.outcome==="ok"){setKey("");setPhase({kind:"idle"});onSaved(r.model.status.agent);return}setPhase({kind:"failed",outcome:r.outcome,...r.reason!==void 0?{reason:r.reason}:{}})}catch(e){setPhase({kind:"error",message:errorText2(e)})}};return jsxs8("form",{className:"band-workshops-form",onSubmit:e=>{e.preventDefault();void submit()},children:[jsx8("div",{className:"band-workshops-sources",role:"radiogroup","aria-label":"\u6A21\u578B\u4ECE\u54EA\u6765",children:jsxs8("label",{className:"band-workshops-source is-on",children:[jsx8("input",{type:"radio",className:"radio",name:"band-workshops-model-source",checked:true,readOnly:true}),jsxs8("span",{children:[jsx8("b",{children:"ModelGate"}),jsx8("small",{children:"\u586B\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684 ModelGate key\uFF0C\u7AEF\u70B9\u548C\u6A21\u578B\u7531 Band \u5B9A\u3002"})]})]})}),jsxs8("div",{className:"band-workshops-subfields",children:[jsxs8("label",{className:"band-workshops-field",htmlFor:keyId,children:[jsxs8("span",{children:["ModelGate key",jsx8("span",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx8("input",{id:keyId,ref:input,className:"field mono",type:"password",autoComplete:"off",spellCheck:false,placeholder:mode==="setup"?"\u7C98\u8D34\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684 ModelGate key":"\u7C98\u8D34\u65B0\u7684\u6216\u539F\u6765\u7684 key",value:key,disabled:checking,onChange:e=>{setKey(e.target.value);if(phase.kind==="missing")setPhase({kind:"idle"})},"aria-invalid":keyBad?true:void 0,"aria-describedby":hintId}),jsx8("small",{id:hintId,className:phase.kind==="missing"?"band-workshops-err":"band-workshops-hint",children:phase.kind==="missing"?"\u8FD8\u5DEE ModelGate key \u6CA1\u586B":mode==="setup"?"\u8FD9\u4E2A\u5DE5\u574A\u6240\u6709\u9879\u76EE\u7684\u82B1\u8D39\u90FD\u8BB0\u5728\u8FD9\u628A key \u4E0A\u3002":"\u65B0 key \u4ECE\u4E0B\u4E00\u56DE\u5408\u8D77\u751F\u6548\uFF1B\u6B63\u5728\u8DD1\u7684\u56DE\u5408\u7528\u539F\u6765\u7684\u8DD1\u5B8C\u3002"})]}),jsxs8("p",{className:"band-workshops-readonly",children:["\u6A21\u578B\uFF1A",jsx8("code",{children:deployment.model}),"\u3000\u7AEF\u70B9\uFF1A",jsx8("code",{children:deployment.endpoint})]})]}),mode==="setup"&&jsx8("div",{className:"band-workshops-callout",children:jsxs8("p",{children:[jsx8("b",{children:"key \u53EA\u4EA4\u7ED9 AgentHub\u3002"}),"Band \u6821\u9A8C\u4E00\u6B21\u540E\u628A\u5B83\u5199\u8FDB\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\uFF0C\u81EA\u5DF1\u4E0D\u4FDD\u5B58\u3002\u914D\u597D\u4EE5\u540E\u8FD9\u91CC\u770B\u4E0D\u5230 key\uFF0C\u8981\u6362\u5C31\u91CD\u65B0\u586B\u4E00\u628A\u3002"]})}),phase.kind==="checking"&&jsx8("div",{className:"band-workshops-result","aria-live":"polite",children:jsxs8("div",{className:"band-workshops-result-line",children:[jsx8("span",{className:"chip s-running",children:"\u6B63\u5728\u6821\u9A8C"}),"\u7528\u8FD9\u628A key \u5411 ModelGate \u53D1\u4E00\u6B21\u6700\u5C0F\u8BF7\u6C42\uFF0C\u51E0\u79D2\u949F\u3002"]})}),phase.kind==="failed"&&jsxs8("div",{className:"band-workshops-result",role:"alert",children:[jsx8("div",{className:"band-workshops-result-line",children:jsx8("span",{className:"chip s-failed",children:RESULT_TITLE[phase.outcome]})}),jsx8("p",{className:"band-workshops-why is-bad",children:resultText(phase.outcome,phase.reason,deployment.model)}),phase.outcome!=="unreachable"&&phase.outcome!=="write_failed"&&jsx8("p",{className:"band-workshops-hint",children:notSaved}),(phase.outcome==="unreachable"||phase.outcome==="write_failed")&&mode==="reconfigure"&&jsx8("p",{className:"band-workshops-hint",children:notSaved})]}),phase.kind==="error"&&jsxs8("div",{className:"band-workshops-result",role:"alert",children:[jsxs8("p",{className:"band-workshops-why is-bad",children:["\u6CA1\u4FDD\u5B58\uFF1A",phase.message]}),jsx8("p",{className:"band-workshops-hint",children:notSaved})]}),jsxs8("div",{className:"band-workshops-actions",children:[jsx8("button",{type:"button",className:"btn ghost",disabled:checking,onClick:()=>onCancel?onCancel():goAbout(ctx,w.id),children:mode==="setup"?"\u4EE5\u540E\u518D\u914D":"\u53D6\u6D88"}),jsx8("button",{type:"submit",className:"btn primary",disabled:checking||!canSave,title:canSave?void 0:"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58",children:checking?"\u6B63\u5728\u6821\u9A8C\u2026":"\u6821\u9A8C\u5E76\u4FDD\u5B58"})]})]})}function WhoCanConfigure({ctx,workshop}){const api=ctx.app.data.write?.workshopMaintainers;const{data}=useAppData(ctx,()=>api?api.get(workshop):Promise.resolve(null),[api,workshop]);if(!data||data.people.length===0)return jsx8(Fragment7,{children:"\u80FD\u914D\u7684\u4EBA\uFF1A\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u3002"});return jsxs8(Fragment7,{children:["\u80FD\u914D\u7684\u4EBA\uFF1A",data.people.map((p,i)=>jsxs8(Fragment6,{children:[i>0&&"\u3001",jsx8(Avatar2,{id:p.userId,name:p.displayName,size:"xs",decorative:true})," ",p.displayName,"\uFF08",p.role==="owner"?"\u521B\u5EFA\u4EBA":"\u7BA1\u7406\u5458","\uFF09"]},p.userId)),"\u3002"]})}function openModelPage(ctx,workshop){ctx.app.navigate({page:`${SELF}/model`,params:{workshop}})}function takeoverNeeded(w){return modelOf(w).hasRequest===false&&w.version>0&&!repoBuilding(w)}function repoBuilding(w){return w.status==="provisioning"||w.version===0&&w.status!=="failed"}function ModelNotice({ctx,w,onChanged,building}){const m=modelOf(w);const api=ctx.app.data.write?.workshopModel;const buildingRepo=building??repoBuilding(w);if(m.hasRequest===false&&buildingRepo)return jsx8("div",{className:"band-workshops-callout",children:jsxs8("p",{children:[jsx8("span",{className:"chip s-running",children:"\u6B63\u5728\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A"}),"\u3000","\u4ED3\u5E93\u548C\u5B9A\u4E49\u5EFA\u597D\u540E\uFF0CBand \u4F1A\u81EA\u52A8\u63A5\u624B\u5B83\u7684 Agent\uFF0C\u4E0D\u7528\u4F60\u64CD\u4F5C\u3002"]})});if(m.hasRequest===false&&w.version===0&&!buildingRepo)return null;if(m.hasRequest===false)return w.canAdmin&&api?jsxs8("output",{className:"band-workshops-needs",children:[jsx8("span",{className:"glyph needs","aria-hidden":"true"}),jsxs8("p",{children:[jsx8("b",{children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\u3002"}),"\u5B83\u662F\u5728\u4EE3\u5EFA\u529F\u80FD\u6253\u5F00\u4E4B\u524D\u5EFA\u7684\uFF0C\u8FD8\u6CA1\u6709 AgentHub \u9879\u76EE\uFF1B\u70B9\u4E0B\u9762\u8BA9\u5B83\u63A5\u624B\uFF0C\u4E4B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]}),jsx8(RetryProvision,{api,workshop:w.id,onDone:onChanged,label:"\u8BA9 Band \u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A"})]}):jsx8("div",{className:"band-workshops-callout",children:jsxs8("p",{children:[jsx8("b",{children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u6682\u65F6\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"}),jsx8(WhoCanConfigure,{ctx,workshop:w.id})]})});if(modelMissing(m,w.userModelKey))return w.canAdmin?jsxs8("output",{className:"band-workshops-needs",children:[jsx8("span",{className:"glyph needs","aria-hidden":"true"}),jsxs8("p",{children:[jsx8("b",{children:"\u8FD8\u6CA1\u914D\u6A21\u578B\u3002"}),"\u914D\u597D\u4E4B\u524D\u8FD9\u4E2A\u5DE5\u574A\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u4E5F\u4E0D\u4F1A\u5F00\u59CB\u56DE\u5408\u3002\u56DE\u5408\u7684\u82B1\u8D39\u8BB0\u5728\u8FD9\u4E2A\u5DE5\u574A\u7684 key \u4E0A\u3002"]}),jsx8("button",{type:"button",className:"btn primary sm",onClick:()=>openModelPage(ctx,w.id),children:"\u914D\u7F6E\u6A21\u578B"})]}):jsx8("div",{className:"band-workshops-callout",children:jsxs8("p",{children:[jsx8("b",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0C\u6682\u65F6\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"}),jsx8(WhoCanConfigure,{ctx,workshop:w.id})]})});if(m.agent==="preparing")return jsxs8("div",{className:"band-workshops-callout",children:[jsx8("p",{children:jsx8("span",{className:"chip s-running",children:"\u6B63\u5728\u51C6\u5907\u5DE5\u574A\u7684 Agent"})}),jsxs8("p",{className:"band-workshops-callout-more",children:[w.userModelKey==="require"?null:jsx8("b",{children:"\u6A21\u578B\u5DF2\u914D\u7F6E\u3002"}),"Band \u6B63\u5728\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent\uFF0C\u901A\u5E38\u8981 15\u201325 \u5206\u949F\u3002\u597D\u4E86\u5C31\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u8FD9\u91CC\u4F1A\u81EA\u52A8\u5237\u65B0\u3002"]})]});if(m.agent==="awaiting_promotion")return jsxs8("div",{className:"band-workshops-callout",children:[jsx8("p",{children:jsx8("span",{className:"chip",children:"\u7B49\u4E0A\u7EBF"})}),jsxs8("p",{className:"band-workshops-callout-more",children:[jsx8("b",{children:w.userModelKey==="require"?"Agent \u7B49\u4E0A\u7EBF\u3002":"\u6A21\u578B\u5DF2\u914D\u7F6E\uFF0CAgent \u7B49\u4E0A\u7EBF\u3002"}),"Band \u7BA1\u7406\u5458\u628A\u5B83\u4E0A\u7EBF\u540E\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u70B9\u300C\u91CD\u8BD5\u300D\uFF0C\u5C31\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]}),w.canAdmin&&api&&jsx8(RetryProvision,{api,workshop:w.id,onDone:onChanged})]});if(m.agent==="failed")return jsx8(AgentFailedNote,{error:m.error,owner:m.owner,what:m.what,brief:m.brief,retry:w.canAdmin&&api?{api,workshop:w.id,onDone:onChanged}:void 0});return null}function ModelFactsRows({w}){const m=modelOf(w);if(m.state==="not_provisioned")return null;if(repoBuilding(w))return jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u6A21\u578B"}),jsx8("dd",{children:"\u6B63\u5728\u51C6\u5907"})]});if(modelMissing(m,w.userModelKey))return jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u6A21\u578B"}),jsx8("dd",{children:w.canAdmin?jsx8("span",{className:"chip s-stale",children:"\u5F85\u914D\u7F6E"}):"\u5F85\u914D\u7F6E"})]});return jsxs8(Fragment7,{children:[jsx8("dt",{children:"\u6A21\u578B"}),jsx8("dd",{children:w.userModelKey==="require"?"\u6210\u5458\u81EA\u5DF1\u7684\u6A21\u578B":jsx8("span",{className:"chip s-done",children:"\u5DF2\u914D\u7F6E"})}),m.agent!=="ready"&&jsxs8(Fragment7,{children:[jsx8("dt",{children:"Agent"}),jsx8("dd",{children:takeoverNeeded(w)?"\u5F85\u914D\u7F6E\u6A21\u578B":agentLabel(m.agent)})]})]})}var absent=e=>isForbidden3(e)||e?.code==="NOT_FOUND";var TEXT={detach:{title:n=>`\u62C6\u51FA ${n} \u4E2A\u63D2\u4EF6\uFF1F`,button:"\u62C6\u51FA",busy:"\u6B63\u5728\u62C6\u51FA\u2026",failed:"\u6CA1\u62C6\u51FA",done:"\u62C6\u51FA"},refollow:{title:n=>`\u91CD\u65B0\u8DDF\u968F ${n} \u4E2A\u63D2\u4EF6\uFF1F`,button:"\u91CD\u65B0\u8DDF\u968F",busy:"\u6B63\u5728\u91CD\u65B0\u8DDF\u968F\u2026",failed:"\u6CA1\u91CD\u65B0\u8DDF\u968F",done:"\u91CD\u65B0\u8DDF\u968F"}};var repoDir=spec=>`band/${spec.replace(/^\.\//,"").replace(/\/+$/,"")}/`;function DetachPlugins({ctx,workshop}){const api=ctx.app.data.write?.workshopPlugins;const[data,setData]=useState7(null);const[loadError,setLoadError]=useState7(null);const[picked,setPicked]=useState7({detach:[],refollow:[]});const[dialog,setDialog]=useState7(null);const[pending,setPending]=useState7({});const[done,setDone]=useState7(null);const load=useCallback3(()=>{if(!api)return;api.list(workshop).then(r=>{setData(r);setLoadError(null)},e=>{setData(null);setLoadError(absent(e)?null:failedBecause4(e,"\u70B9\u91CD\u8BD5"))})},[api,workshop]);useEffect7(()=>{load()},[load]);if(!api)return null;if(loadError)return jsxs9(ErrorNote5,{retry:load,children:["\u62C6\u51FA\u4E0E\u91CD\u65B0\u8DDF\u968F\u6CA1\u8BFB\u51FA\u6765\uFF1A",loadError]});if(!data||data.references.length===0&&data.detached.length===0)return null;const toggle=(mode,name,on)=>setPicked(p=>({...p,[mode]:on?[...p[mode],name]:p[mode].filter(n=>n!==name)}));const row=(mode,name,meta)=>{const state=pending[name];return jsxs9("li",{children:[jsxs9("label",{className:"choice",children:[jsx9("input",{type:"checkbox",className:"checkbox",checked:picked[mode].includes(name),disabled:state!==void 0,onChange:e=>toggle(mode,name,e.target.checked)}),jsx9("code",{children:name})]}),jsx9("span",{className:"band-workshops-detach-meta",children:state?`\u5DF2\u63D0\u4EA4${TEXT[state].done}\uFF0C\u53D1\u5E03\u65B0\u7248\u540E\u751F\u6548`:meta})]},name)};const actions=mode=>{const n=picked[mode].length;const over=n>WORKSHOP_PLUGIN_NAMES_MAX;return jsxs9("div",{className:"band-workshops-detach-acts",children:[over&&jsxs9("span",{className:"band-workshops-hint",children:["\u4E00\u6B21\u6700\u591A ",WORKSHOP_PLUGIN_NAMES_MAX," \u4E2A\uFF0C\u8BF7\u5C11\u9009\u51E0\u4E2A"]}),jsxs9("button",{type:"button",className:"btn sm",disabled:n===0||over,"aria-haspopup":"dialog",onClick:()=>{setDone(null);setDialog(mode)},children:[TEXT[mode].button,n>0?`\u6240\u9009 ${n} \u4E2A`:""]})]})};return jsxs9("section",{className:"band-workshops-detach","aria-label":"\u5171\u4EAB\u63D2\u4EF6\u7684\u8DDF\u968F",children:[data.references.length>0&&jsxs9(Fragment8,{children:[jsx9("h3",{className:"band-workshops-sub",children:"\u5F15\u7528\u7684\u5171\u4EAB\u63D2\u4EF6"}),jsx9("p",{className:"band-workshops-note",children:"\u8FD9\u4E9B\u63D2\u4EF6\u5F15\u7528\u5171\u4EAB\u51FA\u6765\u7684\u7248\u672C\uFF0C\u53D1\u5E03\u65B0\u7248\u65F6\u8DDF\u7740\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\uFF08\u5305\u540D\u91CC @ \u540E\u9762\u90A3\u4E2A\uFF09\u8D70\u3002\u60F3\u81EA\u5DF1\u6539\u4EE3\u7801\uFF0C\u9009\u4E0A\u70B9\u300C\u62C6\u51FA\u300D\uFF1A\u6E90\u7801\u62F7\u8FDB\u672C\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E4B\u540E\u4E0D\u518D\u8DDF\u968F\u3002"}),jsx9("ul",{className:"band-workshops-detach-list",children:data.references.map(r=>row("detach",r.name,`\u5F15\u7528 ${r.spec}\uFF0C\u73B0\u5728\u7528 ${r.version}`))}),actions("detach")]}),data.detached.length>0&&jsxs9(Fragment8,{children:[jsx9("h3",{className:"band-workshops-sub",children:"\u62C6\u51FA\u7684\u5171\u4EAB\u63D2\u4EF6"}),jsx9("p",{className:"band-workshops-note",children:"\u8FD9\u4E9B\u63D2\u4EF6\u662F\u4ECE\u5171\u4EAB\u7248\u672C\u62C6\u51FA\u6765\u7684\u6E90\u7801\u3002\u60F3\u56DE\u5230\u8DDF\u7740\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u8D70\uFF0C\u9009\u4E0A\u70B9\u300C\u91CD\u65B0\u8DDF\u968F\u300D\uFF1A\u5220\u6389\u672C\u5DE5\u574A\u91CC\u8FD9\u4EFD\u6E90\u7801\uFF0C\u6539\u56DE\u5F15\u7528\u3002"}),jsx9("ul",{className:"band-workshops-detach-list",children:data.detached.map(d=>row("refollow",d.name,`\u672C\u5DE5\u574A\u7684\u6E90\u7801 ${d.spec}\uFF08${d.version}\uFF09\uFF0C\u6240\u5C5E\u5DE5\u574A\u73B0\u5728\u5171\u4EAB\u7684\u662F ${d.upstreamVersion}`))}),actions("refollow")]}),done&&jsxs9("output",{className:"band-workshops-detach-done","aria-live":"polite",children:[jsx9("span",{children:`\u5DF2\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF1A${TEXT[done.mode].done} ${done.names.join("\u3001")}\u3002\u8FD8\u6CA1\u751F\u6548\uFF0C\u70B9\u5DE5\u574A\u9875\u7684\u300C\u53D1\u5E03\u65B0\u7248\u300D\u53D1\u5E03\u540E\uFF0C\u65B0\u9879\u76EE\u624D\u7528\u4E0A\u3002`}),done.notes.map(n=>jsx9("span",{children:n},n))]}),dialog&&jsx9(ConfirmDialog,{api,workshop,mode:dialog,names:picked[dialog],data,onClose:()=>setDialog(null),onDone:(names,notes)=>{const mode=dialog;setDialog(null);setPicked(p=>({...p,[mode]:[]}));setPending(p=>({...p,...Object.fromEntries(names.map(n=>[n,mode]))}));setDone({mode,names,notes})}})]})}function ConfirmDialog({api,workshop,mode,names,data,onClose,onDone}){const[chosen,setChosen]=useState7(names);const[busy,setBusy]=useState7(false);const[error,setError]=useState7("");const t=TEXT[mode];const go=async()=>{if(busy||chosen.length===0)return;setBusy(true);setError("");try{if(mode==="detach"){const r=await api.detach(workshop,chosen);onDone(r.detached.map(d=>d.name),r.notes??[])}else{const r=await api.refollow(workshop,chosen);onDone(r.refollowed.map(d=>d.name),[])}}catch(e){setError(`${t.failed}\uFF1A${failedBecause4(e,`\u518D\u70B9\u4E00\u6B21\u300C${t.button}\u300D`)}${chosen.length>1?"\u3002\u53EF\u4EE5\u53BB\u6389\u5176\u4E2D\u4E00\u4E2A\u518D\u8BD5\u3002":""}`);setBusy(false)}};const label=name=>{if(mode==="detach"){const r=data.references.find(x=>x.name===name);return r?`${r.version}\uFF0C\u62C6\u51FA\u540E\u5728 band/views/ \u4E0B`:""}const d=data.detached.find(x=>x.name===name);return d?`\u5220\u6389 ${repoDir(d.spec)}\uFF0C\u6539\u56DE ${name}@^${d.upstreamVersion}`:""};return jsxs9(SettingsDialog2,{title:t.title(chosen.length),onClose:()=>!busy&&onClose(),actions:jsxs9(Fragment8,{children:[jsx9("button",{type:"button",className:"btn ghost",disabled:busy,onClick:onClose,children:"\u53D6\u6D88"}),jsx9("button",{type:"button",className:"btn primary",disabled:busy||chosen.length===0,onClick:()=>void go(),children:busy?t.busy:t.button})]}),children:[jsx9("ul",{className:"band-workshops-detach-list",children:names.map(n=>jsxs9("li",{children:[jsxs9("label",{className:"choice",children:[jsx9("input",{type:"checkbox",className:"checkbox",checked:chosen.includes(n),disabled:busy,onChange:e=>setChosen(c=>e.target.checked?[...c,n]:c.filter(x=>x!==n))}),jsx9("code",{children:n})]}),jsx9("span",{className:"band-workshops-detach-meta",children:label(n)})]},n))}),mode==="detach"?jsxs9("ul",{children:[jsx9("li",{children:"\u4E0D\u518D\u8DDF\u968F\uFF1A\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u4EE5\u540E\u53D1\u65B0\u7248\u672C\uFF0C\u8FD9\u4E9B\u63D2\u4EF6\u4E0D\u4F1A\u8DDF\u7740\u66F4\u65B0\u3002"}),jsx9("li",{children:"\u5305\u540D\u4E0D\u53D8\uFF0C\u5DF2\u6709\u9879\u76EE\u91CC\u7684\u6570\u636E\u548C\u610F\u89C1\u4F4D\u7F6E\u7167\u5E38\u63A5\u5F97\u4E0A\u3002"}),jsx9("li",{children:"\u6E90\u7801\u662F\u767B\u8BB0\u8FD9\u4E00\u7248\u65F6\u5B58\u4E0B\u7684\u90A3\u4EFD\uFF0C\u62F7\u8FDB\u672C\u5DE5\u574A\u4ED3\u5E93\uFF0C\u53D8\u6210\u8FD9\u4E2A\u5DE5\u574A\u79C1\u6709\u7684\u6E90\u7801\uFF0C\u4E4B\u540E\u53EF\u4EE5\u81EA\u5DF1\u6539\u3002"}),jsx9("li",{children:"\u53EA\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E0D\u53D1\u5E03\uFF1A\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u4E4B\u540E\u624D\u751F\u6548\u3002"}),jsx9("li",{children:"\u60F3\u56DE\u5230\u5F15\u7528\uFF1A\u4E4B\u540E\u5728\u8FD9\u91CC\u70B9\u300C\u91CD\u65B0\u8DDF\u968F\u300D\uFF0C\u8981\u4F60\u80FD\u7528\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u3001\u90A3\u4E2A\u5DE5\u574A\u5F53\u524D\u7248\u672C\u91CC\u8FD8\u5171\u4EAB\u7740\u8FD9\u4E2A\u63D2\u4EF6\u3002"})]}):jsxs9("ul",{children:[jsx9("li",{children:"\u5220\u6389\u672C\u5DE5\u574A\u4ED3\u5E93\u91CC\u8FD9\u4EFD\u6E90\u7801\uFF0C\u4F60\u5728\u91CC\u9762\u6539\u8FC7\u7684\u4EE3\u7801\u4E5F\u4E00\u8D77\u5220\u6389\uFF1B\u51E0\u4E2A\u63D2\u4EF6\u5171\u7528\u7684\u6587\u4EF6\u7559\u7740\u3002"}),jsx9("li",{children:"\u6539\u56DE\u5F15\u7528\uFF1A\u4EE5\u540E\u53D1\u5E03\u65B0\u7248\u65F6\uFF0C\u53D6\u5B83\u6240\u5C5E\u5DE5\u574A\u533A\u95F4\u91CC\u6700\u65B0\u7684\u517C\u5BB9\u7248\u672C\u3002"}),jsx9("li",{children:"\u5305\u540D\u4E0D\u53D8\uFF0C\u5DF2\u6709\u9879\u76EE\u91CC\u7684\u6570\u636E\u548C\u610F\u89C1\u4F4D\u7F6E\u7167\u5E38\u63A5\u5F97\u4E0A\u3002"}),jsx9("li",{children:"\u53EA\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E0D\u53D1\u5E03\uFF1A\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u4E4B\u540E\u624D\u751F\u6548\u3002"})]}),error&&jsx9(SettingsSaveState2,{failed:error})]})}var COPY_CHOICES=[{value:"ref",label:"\u5F15\u7528\uFF08\u9ED8\u8BA4\uFF09"},{value:"freeze",label:"\u51BB\u7ED3"},{value:"copy",label:"\u62F7\u6E90\u7801"}];function copyPluginsBody(plugins,choices){const out={};for(const p of plugins){const c=choices[p.name];if(!p.fixed&&c&&c!=="ref")out[p.name]=c}return Object.keys(out).length>0?out:void 0}function useCopyPlugins(ctx,source,reloadKey){const read=ctx.app.data.write?.copyPlugins;const[plugins,setPlugins]=useState7(null);const[loading,setLoading]=useState7(false);const[error,setError]=useState7(null);const[tick,setTick]=useState7(0);useEffect7(()=>{setPlugins(null)},[source]);useEffect7(()=>{if(!read||source===""){setPlugins([]);setLoading(false);setError(null);return}let live=true;setLoading(true);setError(null);read(source).then(r=>{if(!live)return;setPlugins(r.plugins);setLoading(false)},e=>{if(!live)return;setLoading(false);if(absent(e))setPlugins([]);else setError(failedBecause4(e,"\u70B9\u91CD\u8BD5"))});return()=>{live=false}},[read,source,reloadKey,tick]);return{plugins,loading,error,retry:()=>setTick(n=>n+1)}}function CopyPluginChoices({plugins,error,retry,choices,onChange,disabled}){if(error)return jsxs9(ErrorNote5,{retry,children:["\u5171\u4EAB\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});if(!plugins||plugins.length===0)return null;return jsxs9("fieldset",{className:"band-workshops-copy-plugins",disabled,children:[jsx9("legend",{children:"\u539F\u5DE5\u574A\u5171\u4EAB\u7684\u63D2\u4EF6"}),jsx9("p",{className:"band-workshops-note",children:"\u5F15\u7528\uFF1A\u65B0\u5DE5\u574A\u6BCF\u6B21\u53D1\u5E03\u65F6\u53D6\u539F\u5DE5\u574A\u533A\u95F4\u91CC\u6700\u65B0\u7684\u517C\u5BB9\u7248\u672C\u3002\u51BB\u7ED3\uFF1A\u4E00\u76F4\u7528\u73B0\u5728\u8FD9\u4E00\u7248\u3002\u62F7\u6E90\u7801\uFF1A\u628A\u8FD9\u4E00\u7248\u6E90\u7801\u62F7\u8FDB\u65B0\u5DE5\u574A\uFF0C\u53D8\u6210\u65B0\u5DE5\u574A\u79C1\u6709\u3001\u53EF\u4EE5\u6539\uFF0C\u4E0D\u518D\u8DDF\u7740\u539F\u5DE5\u574A\u3002\u5EFA\u597D\u4E4B\u540E\u5728\u5DE5\u574A\u9875\u7684\u300C\u63D2\u4EF6\u300D\u5206\u9875\u8FD8\u80FD\u62C6\u51FA\u6216\u91CD\u65B0\u8DDF\u968F\u3002"}),jsx9("ul",{className:"band-workshops-copy-list",children:plugins.map(p=>jsxs9("li",{children:[jsxs9("span",{className:"band-workshops-plugin",children:[jsxs9("code",{children:[p.name,"@",p.version]}),p.fixed&&jsx9("span",{className:"band-workshops-copy-why",children:p.fixed.reason})]}),p.fixed?.action==="drop"?jsx9("span",{className:"band-workshops-copy-choices",children:"\u4E0D\u590D\u5236"}):jsx9("span",{className:"band-workshops-copy-choices",role:"radiogroup","aria-label":p.name,children:COPY_CHOICES.map(c=>{const checked=p.fixed?p.fixed.action===c.value:(choices[p.name]??"ref")===c.value;return jsxs9("label",{className:"choice sm",children:[jsx9("input",{type:"radio",className:"radio",name:`band-workshops-copy-${p.name}`,value:c.value,checked,disabled:p.fixed!==void 0,onChange:()=>onChange(p.name,c.value)}),c.label]},c.value)})})]},p.name))})]})}function copyBlocked(w){if(w.archivedAt!==void 0)return"\u5DE5\u574A\u5DF2\u5F52\u6863\uFF0C\u590D\u539F\u540E\u624D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";if(w.status==="provisioning")return"\u5DE5\u574A\u8FD8\u5728\u5EFA\uFF0C\u5EFA\u597D\u624D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";if(w.status==="failed")return"\u5DE5\u574A\u6CA1\u5EFA\u6210\uFF0C\u4E0D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";return void 0}var WORKSHOP_ID=/^[a-z][a-z0-9-]{1,39}$/;function workshopIdProblems(id){if(WORKSHOP_ID.test(id))return id===OFFICIAL_SCOPE?["reserved"]:[];const problems=[];if(/[A-Z]/.test(id))problems.push("uppercase");if(/[^A-Za-z0-9-]/.test(id))problems.push("chars");if(/^[0-9-]/.test(id))problems.push("start");if(id.length<2)problems.push("short");if(id.length>40)problems.push("long");return problems}var ID_PROBLEM_TEXT={reserved:`\u300C${OFFICIAL_SCOPE}\u300D\u662F Band \u5B98\u65B9\u63D2\u4EF6\u7528\u7684\u540D\u5B57\uFF0C\u5DF2\u7ECF\u88AB\u5360\u4E86\uFF0C\u6362\u4E00\u4E2A`,uppercase:"\u4E0D\u80FD\u6709\u5927\u5199\u5B57\u6BCD\uFF0C\u90FD\u6539\u6210\u5C0F\u5199",chars:"\u53EA\u80FD\u7528\u82F1\u6587\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF08-\uFF09\uFF0C\u4E0D\u80FD\u6709\u7A7A\u683C\u3001\u4E0B\u5212\u7EBF\u6216\u4E2D\u6587",start:"\u8981\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u4E0D\u80FD\u662F\u6570\u5B57\u6216\u8FDE\u5B57\u7B26",short:"\u81F3\u5C11\u8981 2 \u4E2A\u5B57\u7B26",long:"\u6700\u591A 40 \u4E2A\u5B57\u7B26"};var WORKSHOP_YAML_EXAMPLE=`artifactTypes:
1
+ import{ParamFields,SUBMIT_SHORTCUT,commandEnter,missingRequiredFields,needsConfirm,schemaInitialValues,submittedValues}from"../../chunks/chunk-VL7UVRSN.js";import"../../chunks/chunk-JFPQMFKF.js";import{DEPLOY_RELEASE_NOTE as DEPLOY_RELEASE_NOTE2,agentDisplayName,isRondoAgent,roleDisplayName as roleDisplayName2,stageDisplayName as stageDisplayName2}from"@kanyun-ai-infra/band-contracts";import{FIRST_MESSAGE_MAX,projectNameFromNeed}from"@kanyun-ai-infra/band-contracts/api";import{Avatar as Avatar5,ErrorNote as ErrorNote14,MODELS_FOR_PAGE,NoKeyNotice,REPO_URL_EXAMPLE,TargetRepoNote,WorkshopEmblem as WorkshopEmblem2,WorkshopIcon,errorRepo,errorRequestAccessUrl,errorText as errorText9,gateWho,inline as inline2,instrumentOf as instrumentOf2,isModelRequired,isProvisionFailure,reactMount,repoFieldHint,saveDraft,takeDraft,targetRepoErrorId,useAppData as useAppData6,withImeGuard as withImeGuard4}from"@kanyun-ai-infra/band-plugin-react";import{definePlugin}from"@kanyun-ai-infra/band-plugin-sdk";import{Fragment as Fragment18,useEffect as useEffect14,useId as useId8,useLayoutEffect,useMemo,useRef as useRef7,useState as useState16}from"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{withImeGuard}from"@kanyun-ai-infra/band-plugin-react";import{useEffect,useRef}from"react";import{useId}from"react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";import{CUSTOM_MODEL_PRESET_ID}from"@kanyun-ai-infra/band-contracts/api";import{PROJECT_MODEL_HEADING,credentialOptionLabel,projectModelNote,provisionConsentText}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect2,useId as useId2,useState}from"react";import{Fragment as Fragment2,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";import{Avatar,ErrorNote,errorText,shortTime,useAppData}from"@kanyun-ai-infra/band-plugin-react";import{Fragment as Fragment3,useEffect as useEffect3,useId as useId3,useRef as useRef2,useState as useState2}from"react";import{Fragment as Fragment4,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";import{ErrorNote as ErrorNote3,SettingsActions,SettingsField,SettingsForm,SettingsPicks,SettingsSaveState as SettingsSaveState2,errorText as errorText2,useAppData as useAppData2}from"@kanyun-ai-infra/band-plugin-react";import{OFFICIAL_SCOPE}from"@kanyun-ai-infra/band-plugin-sdk";import{useEffect as useEffect5,useRef as useRef3,useState as useState4}from"react";import{WORKSHOP_PLUGIN_NAMES_MAX}from"@kanyun-ai-infra/band-contracts/api";import{ErrorNote as ErrorNote2,SettingsDialog,SettingsSaveState,failedBecause,isForbidden}from"@kanyun-ai-infra/band-plugin-react";import{useCallback,useEffect as useEffect4,useState as useState3}from"react";import{Fragment as Fragment5,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";import{Fragment as Fragment6,jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";import{ErrorNote as ErrorNote4,errorText as errorText3,useAppData as useAppData3}from"@kanyun-ai-infra/band-plugin-react";import{useId as useId4,useRef as useRef4,useState as useState5}from"react";import{Fragment as Fragment7,jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";import{ErrorNote as ErrorNote5,PersonPicker,errorText as errorText4,usePersonList}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect6,useId as useId5,useState as useState6}from"react";import{Fragment as Fragment8,jsx as jsx8,jsxs as jsxs8}from"react/jsx-runtime";import{artifactTypeDisplayName,stageDisplayName}from"@kanyun-ai-infra/band-contracts";import{LIVE_PREVIEW_POLL_MS}from"@kanyun-ai-infra/band-contracts/api";import{Avatar as Avatar2,ErrorNote as ErrorNote7,PromptInput as PromptInput2,emptyDraft as emptyDraft2,errorText as errorText6,failedBecause as failedBecause2,inline,isForbidden as isForbidden2,scrollIntoPanel,useAppData as useAppData4,useMessageList}from"@kanyun-ai-infra/band-plugin-react";import{withImeGuard as withImeGuard2}from"@kanyun-ai-infra/band-plugin-sdk";import{Fragment as Fragment10,useCallback as useCallback2,useEffect as useEffect8,useId as useId7,useRef as useRef5,useState as useState8}from"react";import{Fragment as Fragment9,jsx as jsx9,jsxs as jsxs9}from"react/jsx-runtime";import{ErrorNote as ErrorNote6,PromptInput,emptyDraft,errorText as errorText5}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect7,useId as useId6,useState as useState7}from"react";import{jsx as jsx10,jsxs as jsxs10}from"react/jsx-runtime";import{Fragment as Fragment11,jsx as jsx11,jsxs as jsxs11}from"react/jsx-runtime";import{DEPLOY_RELEASE_NOTE,artifactTypeDisplayName as artifactTypeDisplayName2,roleDisplayName}from"@kanyun-ai-infra/band-contracts";import{Avatar as Avatar4,ErrorNote as ErrorNote13,Glyph,SettingsFacts,SettingsRow,SettingsRows,SettingsSection,UPGRADE_TEXT as UPGRADE_TEXT2,WorkshopEmblem,directoryFor,instrumentOf,localDay as localDay2,useAppData as useAppData5,withImeGuard as withImeGuard3}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback6,useEffect as useEffect13,useState as useState15}from"react";import{ErrorNote as ErrorNote8,failedBecause as failedBecause3,isForbidden as isForbidden3}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback3,useEffect as useEffect9,useState as useState9}from"react";import{Fragment as Fragment12,jsx as jsx12,jsxs as jsxs12}from"react/jsx-runtime";import{SettingsDanger,SettingsDangerRow,SettingsDialog as SettingsDialog2,SettingsSaveState as SettingsSaveState3,failedBecause as failedBecause4}from"@kanyun-ai-infra/band-plugin-react";import{useState as useState10}from"react";import{Fragment as Fragment13,jsx as jsx13,jsxs as jsxs13}from"react/jsx-runtime";import{ErrorNote as ErrorNote9,failedBecause as failedBecause5,isForbidden as isForbidden4,localDay}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback4,useEffect as useEffect10,useState as useState11}from"react";import{Fragment as Fragment14,jsx as jsx14,jsxs as jsxs14}from"react/jsx-runtime";import{Avatar as Avatar3,ErrorNote as ErrorNote10,PersonSearch,errorText as errorText7}from"@kanyun-ai-infra/band-plugin-react";import{useEffect as useEffect11,useState as useState12}from"react";import{jsx as jsx15,jsxs as jsxs15}from"react/jsx-runtime";import{ErrorNote as ErrorNote11,errorText as errorText8,isForbidden as isForbidden5}from"@kanyun-ai-infra/band-plugin-react";import{useState as useState13}from"react";import{Fragment as Fragment15,jsx as jsx16,jsxs as jsxs16}from"react/jsx-runtime";import{ErrorNote as ErrorNote12,UPGRADE_TEXT,failedBecause as failedBecause6,isForbidden as isForbidden6}from"@kanyun-ai-infra/band-plugin-react";import{useCallback as useCallback5,useEffect as useEffect12,useRef as useRef6,useState as useState14}from"react";import{Fragment as Fragment16,jsx as jsx17,jsxs as jsxs17}from"react/jsx-runtime";import{Fragment as Fragment17,jsx as jsx18,jsxs as jsxs18}from"react/jsx-runtime";import{Fragment as Fragment19,jsx as jsx19,jsxs as jsxs19}from"react/jsx-runtime";if(typeof document!=="undefined"&&document.head){const css='/* src/workshop-edit.css */\n.band-workshop-edit {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 24px 32px 16px;\n overflow: hidden;\n color: var(--ink);\n}\n.band-workshop-edit h1 {\n font-size: var(--fs-title);\n margin: 8px 0;\n}\n.band-workshop-edit h2 {\n font-size: var(--fs-body);\n margin: 0 0 12px;\n}\n.band-workshop-edit h3,\n.band-workshop-edit h4 {\n font-size: var(--fs-dense);\n margin: 0 0 10px;\n}\n.band-workshop-edit p {\n margin: 8px 0;\n line-height: 1.65;\n}\n.band-workshop-edit-head {\n display: flex;\n justify-content: space-between;\n gap: 20px;\n flex: 0 0 auto;\n}\n.band-workshop-edit-lock {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n color: var(--muted);\n font-size: var(--fs-caption);\n}\n.band-workshop-edit-actions {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 55%;\n font-size: var(--fs-caption);\n}\n.band-workshop-edit-actions > .band-workshops-hint {\n flex-basis: 100%;\n text-align: right;\n}\n.band-workshop-edit-entry {\n display: grid;\n gap: 6px;\n}\n.band-workshop-edit-body {\n flex: 1;\n min-height: 0;\n display: grid;\n grid-template-columns: min(400px, 42%) minmax(0, 1fr);\n gap: 28px;\n}\n.band-workshop-edit-chat,\n.band-workshop-edit-side,\n.band-workshop-edit-diff,\n.band-workshop-edit-trial {\n display: flex;\n flex-direction: column;\n min-height: 0;\n min-width: 0;\n}\n.band-workshop-edit-side {\n border-left: 1px solid var(--rule);\n padding-left: 24px;\n gap: 12px;\n}\n.band-workshop-edit-diff,\n.band-workshop-edit-trial {\n flex: 1;\n}\n.band-workshop-edit-diff[hidden],\n.band-workshop-edit-trial[hidden] {\n display: none;\n}\n.band-workshop-edit-side-tabs {\n align-self: flex-start;\n flex: 0 0 auto;\n}\n.band-workshop-edit-messages,\n.band-workshop-edit-diff-scroll {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 4px 8px 16px 0;\n}\n.band-workshop-edit-empty {\n margin: 48px auto;\n max-width: 440px;\n}\n.band-workshop-edit-empty p {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshop-edit-empty .btn {\n white-space: normal;\n text-align: left;\n}\n.band-workshop-edit-user {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 16px;\n margin: 16px 0 16px 40px;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-who {\n display: flex;\n align-items: center;\n gap: 7px;\n font-size: var(--fs-caption);\n margin: 10px 0;\n}\n.band-workshop-edit-receipt {\n background: var(--panel);\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n padding: 16px;\n margin-bottom: 20px;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-progress {\n margin: 0;\n padding: 0 0 0 20px;\n color: var(--muted);\n}\n.band-workshop-edit-progress li {\n padding: 4px 0;\n}\n.band-workshop-edit-progress [aria-current=step] {\n color: var(--accent-text);\n}\n.band-workshop-edit-issues {\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n color: var(--bad);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n padding-left: 16px;\n}\n.band-workshop-edit-changes {\n padding: 0;\n margin: 0 0 16px;\n list-style: none;\n}\n.band-workshop-edit-changes button {\n font: inherit;\n font-size: var(--fs-dense);\n text-align: left;\n padding: 8px 0;\n color: var(--ink);\n background: none;\n border: 0;\n cursor: pointer;\n}\n.band-workshop-edit-changes button:hover {\n text-decoration: underline;\n}\n.band-workshop-edit-changes .band-workshop-edit-file-row {\n font-size: var(--fs-dense);\n padding: 4px 0;\n}\n.band-workshop-edit-changes code {\n font-family: var(--mono);\n font-size: var(--fs-caption);\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-file-row details {\n margin: 2px 0;\n}\n.band-workshop-edit-file-row summary {\n cursor: pointer;\n padding: 2px 0;\n}\n.band-workshop-edit-file-row details[open] summary {\n color: var(--muted);\n}\n.band-workshop-edit-file-note {\n margin: 4px 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit-file-diff {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 8px;\n margin: 6px 0 10px;\n}\n@media (min-width: 1200px) {\n .band-workshop-edit-file-diff {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n }\n}\n.band-workshop-edit-file-diff h5 {\n margin: 0 0 4px;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit-file-diff pre {\n margin: 0;\n padding: 10px;\n max-height: 320px;\n overflow: auto;\n overscroll-behavior: contain;\n background: var(--fill);\n border-radius: var(--r-lg);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n line-height: 1.5;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-views,\n.band-workshop-edit-others {\n margin-top: 24px;\n}\n.band-workshop-edit-view-plugin h4 {\n margin: 8px 0 2px;\n color: var(--muted);\n}\n.band-workshop-edit-view-plugin .band-workshop-edit-changes {\n margin-bottom: 4px;\n}\n.band-workshop-edit-preview {\n margin-top: 8px;\n}\n.band-workshop-edit-preview-open {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n}\n.band-workshop-edit-preview-label {\n font-size: var(--fs-dense);\n white-space: nowrap;\n}\n.band-workshop-edit-preview-open .field {\n flex: 1;\n min-width: 140px;\n width: auto;\n}\n.band-workshop-edit-comparison {\n display: grid;\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: 20px;\n margin-top: 16px;\n}\n.band-workshop-edit-comparison > section {\n min-width: 0;\n}\n.band-workshop-edit-comparison .band-workshops-layer {\n flex-direction: column;\n}\n.band-workshop-edit-comparison .band-workshops-node {\n min-width: 0;\n background: var(--panel);\n}\n.band-workshop-edit-comparison .band-workshops-node.agent b {\n color: var(--ink);\n}\n.band-workshop-edit-comparison .band-workshops-node.is-changed {\n border: 2px solid var(--ink);\n}\n.band-workshop-edit-comparison .band-workshops-node.is-removed {\n border-style: dashed;\n}\n.band-workshop-edit-comparison .band-workshops-node.is-removed b {\n text-decoration: line-through;\n}\n.band-workshop-edit-comparison .band-workshops-node.is-highlighted {\n outline: 2px solid var(--accent);\n outline-offset: 3px;\n}\n.band-workshop-edit-mark {\n font-size: var(--fs-caption);\n font-weight: 600;\n}\n.band-workshop-edit-roles {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 14px 0;\n font-size: var(--fs-caption);\n color: var(--muted);\n}\n.band-workshop-edit .band-workshop-edit-pane-switch,\n.band-workshop-edit .band-workshop-edit-compare-switch {\n display: none;\n}\n@media (max-width: 860px) {\n .band-workshop-edit {\n padding: 12px;\n gap: 10px;\n }\n .band-workshop-edit-head {\n flex-direction: column;\n gap: 8px;\n }\n .band-workshop-edit h1 {\n font-size: var(--fs-title);\n }\n .band-workshop-edit-actions {\n max-width: 100%;\n justify-content: flex-start;\n }\n .band-workshop-edit-actions > span {\n flex-basis: 100%;\n }\n .band-workshop-edit-actions > .band-workshops-hint {\n text-align: left;\n }\n .band-workshop-edit .band-workshop-edit-pane-switch,\n .band-workshop-edit .band-workshop-edit-compare-switch {\n display: flex;\n flex-shrink: 0;\n }\n .band-workshop-edit-body {\n display: flex;\n }\n .band-workshop-edit-body > section,\n .band-workshop-edit-body > .band-workshop-edit-side {\n flex: 1;\n }\n .band-workshop-edit-body[data-pane=chat] > .band-workshop-edit-side,\n .band-workshop-edit-body:not([data-pane=chat]) > .band-workshop-edit-chat {\n display: none;\n }\n .band-workshop-edit .band-workshop-edit-side-tabs {\n display: none;\n }\n .band-workshop-edit-side {\n border: 0;\n padding-left: 0;\n }\n .band-workshop-edit-comparison {\n display: block;\n }\n .band-workshop-edit-comparison[data-show=before] > [data-side=after],\n .band-workshop-edit-comparison[data-show=after] > [data-side=before] {\n display: none;\n }\n .band-workshop-edit-empty {\n margin: 20px 0;\n }\n}\n.band-workshop-edit-comparison .band-workshops-layer > li > .band-workshops-node {\n flex: 1;\n}\n.band-workshop-edit .band-workshop-edit-compare-switch[hidden] {\n display: none;\n}\n.band-workshop-edit-comparison[data-empty=true] {\n grid-template-columns: minmax(0, 1fr);\n}\n.band-workshop-edit-comparison[data-empty=true] > [data-side=before] {\n display: none;\n}\n.band-workshop-edit-comparison[data-empty=true] > [data-side=after] {\n display: block;\n}\n.band-workshop-edit > [role=alert] {\n max-height: 120px;\n overflow: auto;\n overscroll-behavior: contain;\n flex-shrink: 0;\n}\n.band-workshop-edit-agent {\n display: grid;\n gap: 12px;\n padding-bottom: 24px;\n}\n.band-workshop-edit-agent .band-workshop-edit-changes {\n margin: 0;\n}\n.band-workshop-edit-agent .band-workshop-edit-changes li {\n padding: 6px 0;\n font-size: var(--fs-dense);\n}\n.band-workshop-edit-file {\n min-width: 0;\n}\n.band-workshop-edit-file h4 {\n display: flex;\n align-items: baseline;\n gap: 8px;\n margin: 0 0 6px;\n}\n.band-workshop-edit-lines {\n margin: 0;\n padding: 8px 0;\n overflow-x: auto;\n background: var(--sunk);\n border-radius: var(--r);\n font-family: var(--mono);\n font-size: var(--fs-caption);\n line-height: 1.6;\n}\n.band-workshop-edit-line,\n.band-workshop-edit-fold {\n display: block;\n padding: 0 10px;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n.band-workshop-edit-sign {\n display: inline-block;\n width: 1.5em;\n font-weight: 600;\n}\n.band-workshop-edit-line[data-kind=add] {\n background: var(--fill-2);\n}\n.band-workshop-edit-line[data-kind=del] {\n color: var(--muted);\n text-decoration: line-through;\n}\n.band-workshop-edit-fold {\n color: var(--muted);\n}\n.band-workshop-trial {\n flex: 1;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n.band-workshop-trial-bar {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-between;\n gap: 8px 16px;\n flex: 0 0 auto;\n}\n.band-workshop-trial-status {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 0;\n font-size: var(--fs-dense);\n color: var(--muted);\n min-width: 0;\n}\n.band-workshop-trial-pick {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: var(--fs-caption);\n color: var(--muted);\n min-width: 0;\n}\n.band-workshop-trial-frame {\n flex: 1 0 auto;\n min-height: 460px;\n position: relative;\n display: flex;\n flex-direction: column;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n overflow: hidden;\n background: var(--sunk);\n}\n.band-workshop-trial-screen {\n position: absolute;\n inset: 0;\n overflow: hidden;\n}\n.band-workshop-trial-screen iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: 0;\n background: var(--panel);\n}\n.band-workshop-trial .band-workshop-trial-narrow {\n display: none;\n}\n.band-workshop-trial-frame > .band-workshop-trial-wide {\n position: absolute;\n right: 8px;\n bottom: 8px;\n background: var(--panel);\n box-shadow: var(--shadow-card);\n}\n.band-workshop-trial-rest {\n flex: 1;\n align-content: center;\n padding: 32px 16px;\n}\n.band-workshop-trial-rest b {\n color: var(--ink);\n font-weight: 500;\n}\n.band-workshop-trial-rest span {\n max-width: 44ch;\n}\n.band-workshop-trial-try {\n flex: 0 0 auto;\n display: grid;\n gap: 10px;\n}\n.band-workshop-edit .band-workshop-trial-caption {\n margin: 0;\n font-size: var(--fs-caption);\n font-weight: 400;\n color: var(--muted);\n}\n.band-workshop-trial-run {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 14px;\n display: grid;\n gap: 6px;\n justify-items: start;\n font-size: var(--fs-dense);\n}\n.band-workshop-trial-run header {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n}\n.band-workshop-trial-run p {\n margin: 0;\n}\n.band-workshop-trial-meta {\n color: var(--muted);\n font-size: var(--fs-caption);\n}\n@media (max-width: 860px) {\n .band-workshop-trial-frame {\n min-height: 0;\n flex: 0 0 auto;\n border: 0;\n background: none;\n }\n .band-workshop-trial-frame iframe {\n display: none;\n }\n .band-workshop-trial .band-workshop-trial-frame > .band-workshop-trial-wide {\n display: none;\n }\n .band-workshop-trial .band-workshop-trial-narrow {\n display: inline-flex;\n align-self: flex-start;\n }\n}\n.band-workshop-edit .band-workshop-edit-rail {\n display: none;\n}\n@media (min-width: 861px) {\n .band-workshop-edit-body[data-fold=chat] {\n grid-template-columns: auto minmax(0, 1fr);\n }\n .band-workshop-edit-body[data-fold=chat] > .band-workshop-edit-chat {\n display: none;\n }\n .band-workshop-edit .band-workshop-edit-body[data-fold=chat] > .band-workshop-edit-rail {\n display: inline-grid;\n align-self: start;\n }\n}\n.band-workshop-trial-head {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshop-trial-create {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px;\n width: 100%;\n max-width: 420px;\n}\n.band-workshop-trial-create > .field {\n flex: 1 1 200px;\n min-width: 0;\n}\n\n/* src/workshops.css */\n.band-workshops-screen {\n container: band-workshops / inline-size;\n box-sizing: border-box;\n width: 100%;\n max-width: 1080px;\n margin: 0 auto;\n padding: 36px 32px 64px;\n display: grid;\n gap: 26px;\n align-content: start;\n}\n.band-workshops-screen h1 {\n margin: 0;\n font-family: var(--font-display);\n font-weight: 600;\n font-size: var(--fs-h1);\n line-height: 1.3;\n}\n.band-workshops-head {\n display: flex;\n align-items: flex-end;\n justify-content: space-between;\n gap: 16px;\n flex-wrap: wrap;\n}\n.band-workshops-head .sub,\n.band-workshops-lede {\n margin: 6px 0 0;\n max-width: 64ch;\n}\n.band-workshops-grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));\n gap: 10px;\n}\n.band-workshops-card {\n padding: 16px 16px 14px;\n display: grid;\n gap: 10px;\n align-content: start;\n text-align: left;\n background: var(--fill);\n border: 0;\n border-radius: 14px;\n width: 100%;\n color: inherit;\n font: inherit;\n cursor: pointer;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-workshops-card:hover {\n background: var(--fill-2);\n}\n.band-workshops-card.is-skeleton {\n min-height: 150px;\n cursor: default;\n animation: band-workshops-breathe 1.6s var(--ease) infinite alternate;\n}\n@keyframes band-workshops-breathe {\n to {\n opacity: 0.5;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .band-workshops-card.is-skeleton {\n animation: none;\n }\n}\n.band-workshops-card-h {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n.band-workshops-card-t {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshops-name {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n font-size: var(--fs-title);\n font-weight: 650;\n}\nh1.band-workshops-name {\n font-size: var(--fs-h1);\n gap: 10px;\n}\n.band-workshops-desc {\n font-size: var(--fs-dense);\n line-height: 1.55;\n color: var(--muted);\n}\n.band-workshops-meta {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 12px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-flowline {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 4px;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-st {\n padding: 0 7px;\n border-radius: 5px;\n background: var(--fill-2);\n color: var(--ink);\n line-height: 1.7;\n}\n.band-workshops-st.agent {\n background: var(--accent-soft);\n color: var(--accent-text);\n}\n.band-workshops-st.external {\n background: none;\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n color: var(--muted);\n}\n.band-workshops-crumb {\n font-size: var(--fs-dense);\n color: var(--muted);\n display: flex;\n gap: 6px;\n align-items: center;\n}\n.band-workshops-crumb button {\n background: none;\n border: 0;\n padding: 0;\n font: inherit;\n color: var(--muted);\n cursor: pointer;\n}\n.band-workshops-crumb button:hover {\n color: var(--ink);\n}\n.band-workshops-detail {\n display: grid;\n grid-template-columns: minmax(0, 1fr) 300px;\n gap: 28px;\n align-items: start;\n}\n.band-workshops-stack {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n gap: 18px;\n}\n.band-workshops-facts {\n margin: 0;\n display: grid;\n grid-template-columns: 44px minmax(0, 1fr);\n gap: 6px 10px;\n font-size: var(--fs-ui);\n}\n.band-workshops-facts dt {\n color: var(--muted);\n}\n.band-workshops-facts dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n.band-workshops-facts code,\n.band-workshops-table code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-nowrap {\n white-space: nowrap;\n}\n.band-workshops-note {\n margin: 8px 0 0;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-note.band-plugin-react-model-hint {\n margin: 8px 0 0;\n}\n.band-workshops-table {\n overflow-x: auto;\n}\n.band-workshops-table table {\n border-collapse: collapse;\n width: 100%;\n font-size: var(--fs-ui);\n}\n.band-workshops-table th,\n.band-workshops-table td {\n text-align: left;\n padding: 8px 12px 8px 0;\n border-bottom: var(--hairline) solid var(--rule);\n vertical-align: top;\n}\n.band-workshops-table th {\n color: var(--muted);\n font-weight: 500;\n font-size: var(--fs-meta);\n}\n.band-workshops-table tr:last-child td {\n border-bottom: 0;\n}\n.band-workshops-flowbig {\n position: relative;\n padding: 4px 0;\n}\n.band-workshops-edges {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n pointer-events: none;\n}\n.band-workshops-edges path {\n fill: none;\n stroke: var(--muted);\n stroke-width: 1;\n}\n.band-workshops-edges marker path {\n fill: var(--muted);\n stroke: none;\n}\n.band-workshops-layers {\n position: relative;\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n row-gap: 32px;\n}\n.band-workshops-layer {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-wrap: wrap;\n align-items: stretch;\n gap: 32px 24px;\n}\n.band-workshops-layer > li {\n display: flex;\n}\n.band-workshops-node {\n min-width: 150px;\n padding: 10px 12px;\n border-radius: 10px;\n background: var(--fill-2);\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n display: grid;\n gap: 2px;\n align-content: start;\n}\n.band-workshops-node.agent {\n background: var(--accent-soft);\n}\n.band-workshops-node.agent b {\n color: var(--accent-text);\n}\n.band-workshops-node.external {\n background: var(--sunk);\n}\n.band-workshops-node-g {\n font-size: var(--fs-dense);\n color: var(--ink);\n margin-top: 2px;\n}\n.band-workshops-node-loop {\n max-width: 320px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-node-missing {\n max-width: 320px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-flow-line {\n margin: 0 0 8px;\n font-size: var(--fs-dense);\n color: var(--ink);\n}\n.band-workshops-flowbig + .band-workshops-flow-line {\n margin: 8px 0 0;\n}\n.band-workshops-node-a {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-top: 2px;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-node.agent .band-workshops-node-a {\n color: var(--accent-text);\n}\n.band-workshops-whead {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n.band-workshops-whead :where(.band-workshops-lede) {\n margin-top: 6px;\n}\n.band-workshops-panel {\n display: grid;\n gap: 12px;\n}\n.band-workshops-callout {\n background: var(--fill);\n border-radius: var(--r-lg);\n padding: 12px 14px;\n font-size: var(--fs-ui);\n line-height: 1.6;\n color: var(--muted);\n}\n.band-workshops-callout b {\n color: var(--ink);\n font-weight: 600;\n}\n.band-workshops-callout blockquote {\n margin: 8px 0;\n padding: 0 0 0 12px;\n border-left: 2px solid var(--rule);\n color: var(--ink);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n.band-workshops-callout[data-first-message] {\n margin: 8px 0;\n}\n.band-workshops-callout[data-first-message] p {\n margin: 0;\n}\n.band-workshops-agents {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: 8px;\n}\n.band-workshops-agent {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n}\n.band-workshops-agent-t {\n display: grid;\n gap: 1px;\n min-width: 0;\n}\n.band-workshops-agent-t b {\n font-weight: 500;\n}\n.band-workshops-agent-k {\n font-size: var(--fs-dense);\n color: var(--muted);\n font-weight: 400;\n}\n.band-workshops-agent-d {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-empty {\n display: grid;\n gap: 8px;\n justify-items: start;\n padding: 28px 0;\n}\n.band-workshops-empty :where(.sub) {\n margin: 0;\n max-width: 52ch;\n}\n.band-workshops-sk {\n display: block;\n border-radius: var(--r-lg);\n background: var(--fill);\n animation: band-workshops-breathe 1.6s var(--ease) infinite alternate;\n}\n.band-workshops-sk:where(.is-tile) {\n width: 64px;\n height: 64px;\n border-radius: var(--r-xl);\n}\n.band-workshops-sk:where(.is-line) {\n width: 240px;\n height: 28px;\n}\n.band-workshops-sk:where(.is-block) {\n height: 180px;\n}\n.band-workshops-sk:where(.is-aside) {\n height: 220px;\n}\n@media (prefers-reduced-motion: reduce) {\n .band-workshops-sk {\n animation: none;\n }\n}\n.band-workshops-missing {\n display: grid;\n gap: 12px;\n justify-items: start;\n}\n.band-workshops-form {\n display: grid;\n gap: 18px;\n max-width: 560px;\n}\n.band-workshops-field {\n display: grid;\n gap: 6px;\n}\n.band-workshops-field > span {\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-field input,\n.band-workshops-field textarea,\n.band-workshops-field select {\n width: 100%;\n background-color: var(--panel);\n border: 0;\n box-shadow: inset 0 0 0 1px var(--control-edge);\n border-radius: var(--r);\n padding: 8px 10px;\n font: inherit;\n font-size: var(--fs-body);\n color: var(--ink);\n transition: box-shadow var(--sixteenth) var(--ease);\n}\n.band-workshops-field input::placeholder,\n.band-workshops-field textarea::placeholder {\n color: var(--muted);\n}\n.band-workshops-field input {\n text-overflow: ellipsis;\n}\n.band-workshops-field input:focus,\n.band-workshops-field textarea:focus,\n.band-workshops-field select:focus {\n outline: none;\n box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft);\n}\n.band-workshops-field input:disabled,\n.band-workshops-field textarea:disabled,\n.band-workshops-field select:disabled {\n opacity: 0.42;\n cursor: not-allowed;\n}\n.band-workshops-field textarea {\n resize: vertical;\n line-height: 1.6;\n min-height: 6.4em;\n}\n.band-workshops-field input[aria-invalid=true],\n.band-workshops-field textarea[aria-invalid=true] {\n box-shadow: inset 0 0 0 1px var(--bad);\n}\n.band-workshops-repo {\n display: grid;\n gap: 6px;\n}\n.band-workshops-req,\n.band-workshops-opt {\n margin-left: 6px;\n font-style: normal;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-err {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--bad);\n}\n.band-workshops-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-yanked p {\n margin: 0 0 4px;\n}\n.band-workshops-yanked ul {\n margin: 0;\n padding-left: 18px;\n}\n.band-workshops-hint code,\n.band-workshops-callout code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-yaml {\n margin-top: 10px;\n display: grid;\n gap: 6px;\n}\n.band-workshops-yaml-head {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n}\n.band-workshops-yaml-code {\n margin: 0;\n max-height: 264px;\n overflow: auto;\n overscroll-behavior: contain;\n padding: 10px 12px;\n border-radius: var(--r);\n background: var(--panel);\n font-family: var(--mono);\n font-size: var(--fs-meta);\n line-height: 1.5;\n color: var(--ink);\n white-space: pre;\n}\n.band-workshops-yaml-said {\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-callout {\n background: var(--fill);\n border-radius: var(--r);\n padding: 10px 12px;\n font-size: var(--fs-ui);\n color: var(--muted);\n display: grid;\n gap: 6px;\n}\n.band-workshops-callout p {\n margin: 0;\n}\n.band-workshops-status {\n display: block;\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-headacts {\n display: flex;\n align-items: center;\n gap: 10px;\n flex-wrap: wrap;\n}\n.band-workshops-link {\n border: 0;\n background: none;\n padding: 0;\n font: inherit;\n color: var(--accent-text);\n cursor: pointer;\n}\n.band-workshops-link:hover {\n text-decoration: underline;\n}\n.band-workshops-link:focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n border-radius: 3px;\n}\n.band-workshops-actions {\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n}\n@media (max-width: 860px) {\n .band-workshops-whead {\n align-items: flex-start;\n }\n .band-workshops-screen {\n padding: 22px 16px 48px;\n gap: 22px;\n }\n .band-workshops-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n@container band-workshops (max-width: 900px) {\n .band-workshops-detail {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-publish {\n display: grid;\n gap: 8px;\n}\n.band-workshops-publish-dialog {\n width: min(440px, calc(100vw - 32px));\n max-width: none;\n margin: auto;\n padding: 0;\n border: 0;\n border-radius: var(--r-xl);\n background: var(--panel);\n color: var(--ink);\n box-shadow: var(--shadow-pop);\n}\n.band-workshops-publish-dialog::backdrop {\n background: var(--scrim);\n}\n.band-workshops-publish-body {\n display: grid;\n gap: 14px;\n padding: 20px;\n font-size: var(--fs-ui);\n}\n.band-workshops-publish-title {\n margin: 0;\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-publish-body > p {\n margin: 0;\n}\n.band-workshops-publish-body .band-workshops-field textarea {\n min-height: 3.6em;\n}\n.band-workshops-params {\n display: grid;\n gap: 10px;\n padding: 14px 12px;\n border-radius: 10px;\n background: var(--sunk);\n}\n.band-workshops-params-title {\n font-size: var(--fs-caption);\n letter-spacing: 0.08em;\n color: var(--muted);\n text-transform: uppercase;\n}\n.band-workshops-params-hint {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-sub {\n margin: 14px 0 6px;\n font-size: var(--fs-dense);\n font-weight: 500;\n color: var(--muted);\n}\n.band-workshops-sub:first-child {\n margin-top: 0;\n}\n.band-workshops-plugin {\n display: inline-grid;\n gap: 2px;\n text-align: left;\n}\n.band-workshops-plugin b {\n font-weight: 500;\n}\n.band-workshops-plugin code {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n.band-workshops-detach {\n display: grid;\n gap: 6px;\n margin-top: 14px;\n}\n.band-workshops-detach .band-workshops-note {\n margin: 0;\n}\n.band-workshops-detach-list {\n display: grid;\n gap: 6px;\n margin: 4px 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-detach-list li {\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n column-gap: 10px;\n row-gap: 2px;\n min-width: 0;\n}\n.band-workshops-detach-list li > .choice {\n flex: 0 1 22em;\n min-width: 0;\n}\n.band-workshops-detach-meta {\n flex: 1 1 14em;\n}\n.band-workshops-detach-list code {\n font-size: var(--fs-meta);\n overflow-wrap: anywhere;\n}\n.band-workshops-detach-meta {\n font-size: var(--fs-dense);\n color: var(--muted);\n overflow-wrap: anywhere;\n}\n.band-workshops-detach-acts {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.band-workshops-detach-done {\n display: grid;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n color: var(--ink);\n font-size: var(--fs-ui);\n overflow-wrap: anywhere;\n}\n.band-workshops-copy-plugins {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n border: 0;\n min-width: 0;\n}\n.band-workshops-copy-plugins legend {\n padding: 0;\n margin-bottom: 6px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-copy-plugins .band-workshops-note {\n margin: 0;\n}\n.band-workshops-copy-list {\n display: grid;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-copy-list li {\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-between;\n gap: 6px 16px;\n min-width: 0;\n}\n.band-workshops-copy-list code {\n font-size: var(--fs-meta);\n overflow-wrap: anywhere;\n}\n.band-workshops-copy-list li > .band-workshops-plugin {\n flex: 1 1 240px;\n min-width: 0;\n}\n.band-workshops-copy-why {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-copy-choices {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 14px;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-people {\n display: grid;\n gap: 12px;\n}\n.band-workshops-people-bar {\n display: grid;\n justify-items: start;\n}\n.band-workshops-people-card {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n background: var(--panel);\n border-radius: var(--r-lg);\n box-shadow: var(--shadow-card);\n}\n.band-workshops-people-row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 12px;\n padding: 10px 14px;\n border-top: var(--hairline) solid var(--rule);\n}\n.band-workshops-people-row:where(:first-child) {\n border-top: 0;\n}\n.band-workshops-people-line {\n display: flex;\n align-items: center;\n gap: 12px;\n flex: 1 1 100%;\n min-width: 0;\n}\n.band-workshops-people-who {\n display: grid;\n gap: 1px;\n min-width: 0;\n font-size: var(--fs-row);\n}\n.band-workshops-people-who b {\n font-weight: 500;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.band-workshops-people-who span {\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-people-ops {\n margin-left: auto;\n display: flex;\n gap: 4px;\n text-align: right;\n}\n.band-workshops-people-form {\n flex: 1 1 100%;\n display: grid;\n gap: 12px;\n margin: 0;\n padding: 14px;\n border: 0;\n min-width: 0;\n background: var(--panel);\n border-radius: var(--r-lg);\n box-shadow: var(--shadow-card);\n font-size: var(--fs-row);\n}\n.band-workshops-people-form:where(.band-workshops-people-row > *) {\n padding: 0 0 0 36px;\n background: none;\n box-shadow: none;\n}\n.band-workshops-people-form p {\n margin: 0;\n}\n.band-workshops-people-field {\n position: relative;\n display: grid;\n gap: 4px;\n max-width: 420px;\n}\n.band-workshops-people-label,\n.band-workshops-viewers-label {\n font-size: var(--fs-row);\n color: var(--ink);\n}\n.band-workshops-people-hint {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-workshops-people-actions {\n display: flex;\n gap: 8px;\n}\n.band-workshops-visibility {\n padding: 16px;\n color: var(--ink);\n display: grid;\n gap: 12px;\n align-content: start;\n max-width: 640px;\n}\n.band-workshops-visibility h2 {\n margin: 0;\n font-size: var(--fs-title);\n}\n.band-workshops-visibility p {\n margin: 0;\n color: var(--muted);\n}\n.band-workshops-visibility .btn {\n justify-self: start;\n}\n.band-workshops-levels {\n display: grid;\n gap: 8px;\n}\n.band-workshops-level {\n display: flex;\n align-items: flex-start;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n cursor: pointer;\n transition: background var(--sixteenth) var(--ease);\n}\n.band-workshops-level:where(:hover, :has(:checked)) {\n background: var(--fill);\n}\n.band-workshops-level:where(:has(:disabled)) {\n cursor: default;\n}\n.band-workshops-level:where(:has(:disabled):not(:has(:checked)):hover) {\n background: none;\n}\n.band-workshops-level .radio {\n margin-top: 2px;\n}\n.band-workshops-level > span {\n display: grid;\n gap: 2px;\n min-width: 0;\n}\n.band-workshops-level b {\n font-weight: 600;\n}\n.band-workshops-level span span {\n color: var(--muted);\n font-size: var(--fs-dense);\n}\n.band-workshops-viewers {\n display: grid;\n gap: 8px;\n position: relative;\n}\n.band-workshops-steps {\n display: flex;\n gap: 14px;\n margin: 0 0 6px;\n padding: 0;\n list-style: none;\n font-size: var(--fs-meta);\n color: var(--muted);\n}\n.band-workshops-steps li::before {\n content: attr(data-n) " ";\n font-family: var(--mono);\n}\n.band-workshops-steps li[aria-current=step] {\n color: var(--ink);\n font-weight: 600;\n}\n.band-workshops-steps li.is-done {\n color: var(--ok);\n}\n.band-workshops-sources {\n display: grid;\n gap: 8px;\n}\n.band-workshops-source {\n display: grid;\n grid-template-columns: 16px minmax(0, 1fr);\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n box-shadow: inset 0 0 0 1px var(--rule-strong);\n cursor: pointer;\n --control: var(--accent);\n --control-ink: var(--accent-ink);\n}\n.band-workshops-source .radio {\n margin-top: 3px;\n}\n.band-workshops-source.is-on {\n box-shadow: inset 0 0 0 1px var(--accent);\n background: var(--accent-soft);\n}\n.band-workshops-source b {\n font-weight: 600;\n font-size: var(--fs-row);\n color: var(--ink);\n}\n.band-workshops-source small {\n display: block;\n font-size: var(--fs-dense);\n color: var(--muted);\n}\n.band-workshops-subfields {\n display: grid;\n gap: 14px;\n padding-left: 26px;\n}\n.band-workshops-req {\n color: var(--muted);\n font-size: var(--fs-meta);\n font-weight: 400;\n margin-left: 6px;\n}\n.band-workshops-readonly {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-readonly code {\n color: var(--ink);\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-result {\n display: grid;\n gap: 6px;\n}\n.band-workshops-result-line {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-wrap: wrap;\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-result p {\n margin: 0;\n}\n.band-workshops-why {\n margin: 0;\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-why.is-bad {\n color: var(--bad);\n}\n.band-workshops-why code {\n font-family: var(--mono);\n font-size: 0.92em;\n}\n.band-workshops-actions.is-start {\n justify-content: flex-start;\n}\n.band-workshops-retry {\n display: grid;\n gap: 8px;\n justify-items: start;\n}\n.band-workshops-model-facts {\n max-width: 520px;\n}\n.band-workshops-callout-more {\n margin-top: 6px;\n}\n.band-workshops-needs {\n display: grid;\n grid-template-columns: 16px minmax(0, 1fr) auto;\n gap: 10px;\n align-items: start;\n background: var(--warn-soft);\n color: var(--ink);\n border-radius: var(--r-lg);\n padding: 10px 12px;\n font-size: var(--fs-ui);\n}\n.band-workshops-needs .glyph {\n margin-top: 2px;\n}\n.band-workshops-needs b {\n color: var(--warn);\n font-weight: 600;\n}\n.band-workshops-needs p {\n margin: 0;\n}\n.band-workshops-needs .btn {\n align-self: center;\n}\n.band-workshops-agent-x {\n display: flex;\n gap: 8px;\n align-items: center;\n flex-wrap: wrap;\n justify-content: flex-end;\n margin-left: auto;\n}\n.band-workshops-agent.is-off .av,\n.band-workshops-agent.is-off .band-workshops-agent-t b {\n opacity: 0.42;\n}\n@media (max-width: 560px) {\n .band-workshops-needs {\n grid-template-columns: 16px minmax(0, 1fr);\n }\n .band-workshops-needs .btn {\n grid-column: 2;\n justify-self: start;\n }\n .band-workshops-subfields {\n padding-left: 0;\n }\n}\n.band-workshops-overrides {\n display: grid;\n gap: 8px;\n padding: 12px 14px;\n border-radius: var(--r-lg);\n background: var(--sunk);\n}\n.band-workshops-overrides-h {\n margin: 0;\n font-size: var(--fs-ui);\n font-weight: 600;\n color: var(--ink);\n}\n.band-workshops-overrides-list {\n display: grid;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.band-workshops-overrides-list > li {\n display: grid;\n gap: 2px;\n padding-left: 10px;\n border-left: 2px solid var(--rule);\n min-width: 0;\n}\n.band-workshops-overrides-list > li.is-action {\n border-left-color: var(--bad);\n}\n.band-workshops-overrides-t {\n font-size: var(--fs-row);\n color: var(--ink);\n overflow-wrap: anywhere;\n}\n.band-workshops-overrides-scope,\n.band-workshops-overrides-d {\n font-size: var(--fs-ui);\n color: var(--muted);\n overflow-wrap: anywhere;\n}\n.band-workshops-intro {\n display: grid;\n gap: 10px;\n max-width: 560px;\n}\n.band-workshops-intro-lede {\n margin: 0;\n font-size: var(--fs-body);\n line-height: 1.6;\n color: var(--ink);\n}\n.band-workshops-intro-h {\n margin: 4px 0 0;\n font-size: var(--fs-meta);\n font-weight: 400;\n color: var(--muted);\n letter-spacing: 0.04em;\n}\n.band-workshops-samples {\n display: grid;\n grid-template-columns: repeat(3, minmax(0, 1fr));\n gap: 10px;\n}\nbutton.band-workshops-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-workshops-sample:hover {\n border-color: var(--rule-strong);\n}\nbutton.band-workshops-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-workshops-sample b {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-workshops-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-workshops-samples {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-ref-hint {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n color: var(--ink);\n font-size: var(--fs-ui);\n overflow-wrap: anywhere;\n}\n.band-workshops-ref-hint p,\n.band-workshops-ref-hint ul {\n margin: 0;\n}\n.band-workshops-ref-hint ul {\n padding-left: 18px;\n}\n.band-workshops-ref-hint-title {\n font-weight: 600;\n}\n.band-workshops-upgrade {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-upgrade p,\n.band-workshops-upgrade ul {\n margin: 0;\n}\n.band-workshops-upgrade ul {\n padding-left: 18px;\n}\n.band-workshops-upgrade-dialog {\n width: min(440px, calc(100vw - 32px));\n max-width: none;\n margin: auto;\n padding: 0;\n border: 0;\n border-radius: var(--r-xl);\n background: var(--panel);\n color: var(--ink);\n box-shadow: var(--shadow-pop);\n}\n.band-workshops-upgrade-dialog::backdrop {\n background: var(--scrim);\n}\n.band-workshops-upgrade-body {\n display: grid;\n gap: 12px;\n padding: 20px;\n font-size: var(--fs-ui);\n}\n.band-workshops-upgrade-title {\n margin: 0;\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-upgrade-body > p {\n margin: 0;\n}\n.band-workshops-details {\n font-size: var(--fs-ui);\n}\n.band-workshops-details summary {\n color: var(--muted);\n cursor: pointer;\n}\n.band-workshops-details .band-workshops-facts {\n margin-top: 6px;\n}\n.band-workshops-secrets {\n list-style: none;\n margin: 0;\n padding: 0;\n display: grid;\n gap: 12px;\n max-width: 620px;\n}\n.band-workshops-secret {\n display: grid;\n gap: 10px;\n}\n.band-workshops-secret-line {\n display: flex;\n gap: 10px;\n align-items: center;\n flex-wrap: wrap;\n}\n.band-workshops-secret-name {\n font-family: var(--mono);\n font-size: var(--fs-ui);\n color: var(--ink);\n}\n.band-workshops-secret-line .btn {\n margin-left: auto;\n}\n.band-workshops-secret-form {\n display: grid;\n gap: 10px;\n padding-left: 2px;\n}\n.band-workshops-agent-upgrade-line {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n margin: 6px 0 0;\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-agent-upgrade {\n display: grid;\n gap: 8px;\n margin-top: 16px;\n padding: 12px;\n border-radius: var(--r-lg);\n background: var(--warn-soft);\n color: var(--ink);\n font-size: var(--fs-ui);\n}\n.band-workshops-agent-upgrade h3,\n.band-workshops-agent-upgrade h4,\n.band-workshops-agent-upgrade p,\n.band-workshops-agent-upgrade ul {\n margin: 0;\n}\n.band-workshops-agent-upgrade h3 {\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.band-workshops-agent-upgrade h4 {\n font-size: var(--fs-ui);\n font-weight: 600;\n}\n.band-workshops-agent-upgrade ul {\n display: grid;\n gap: 8px;\n padding-left: 18px;\n}\n.band-workshops-agent-upgrade-log {\n margin: 4px 0 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font: inherit;\n}\n.band-workshops-model-pick {\n display: grid;\n gap: 6px;\n}\n.band-workshops-follow {\n margin-top: 18px;\n}\n.band-workshops-follow-list {\n display: grid;\n margin: 8px 0 0;\n padding: 0;\n list-style: none;\n border: 1px solid var(--rule);\n border-radius: var(--r-lg);\n}\n.band-workshops-follow-row {\n display: grid;\n grid-template-columns: 7em minmax(0, 1fr) minmax(0, 1.4fr);\n gap: 4px 12px;\n align-items: baseline;\n padding: 8px 12px;\n font-size: var(--fs-ui);\n border-left: 3px solid transparent;\n}\n.band-workshops-follow-row + .band-workshops-follow-row {\n border-top: 1px solid var(--rule);\n}\n.band-workshops-follow-row[data-status=failed] {\n border-left-color: var(--bad);\n}\n.band-workshops-follow-when {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n.band-workshops-follow-trigger {\n overflow-wrap: anywhere;\n}\n.band-workshops-follow-outcome {\n display: flex;\n flex-wrap: wrap;\n gap: 4px 8px;\n align-items: baseline;\n overflow-wrap: anywhere;\n}\n.band-workshops-follow-status[data-status=unchanged] {\n color: var(--muted);\n}\n.band-workshops-follow-outcome code {\n color: var(--muted);\n font-size: var(--fs-meta);\n}\n@media (max-width: 640px) {\n .band-workshops-follow-row {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n.band-workshops-trials {\n display: grid;\n gap: 12px;\n list-style: none;\n padding: 0;\n}\n.band-workshops-trials > li {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 8px;\n}\n.band-workshops-new {\n max-width: 720px;\n}\n.band-workshops-new-head {\n display: grid;\n gap: 8px;\n}\n.band-workshops-new-head h1,\n.band-workshops-new-head .sub {\n margin: 0;\n}\n.band-workshops-new-head .sub {\n color: var(--muted);\n}\n.band-workshops-new-help {\n display: grid;\n gap: 8px;\n font-size: var(--fs-ui);\n color: var(--muted);\n}\n.band-workshops-new-help p {\n margin: 0;\n}\n.band-workshops-new-help summary {\n cursor: pointer;\n color: var(--accent-text);\n}\n.band-workshops-new-help details[open] > summary {\n margin-bottom: 8px;\n}\n.wp {\n gap: 18px;\n}\n.wp-head {\n display: grid;\n grid-template-columns: 56px minmax(0, 1fr) auto;\n gap: 16px;\n align-items: center;\n}\n.wp-title {\n min-width: 0;\n}\n.wp-title h1 {\n margin: 0;\n}\n.wp-title .sub {\n margin: 4px 0 0;\n color: var(--muted);\n font-size: var(--fs-body);\n max-width: 62ch;\n}\n.wp-acts {\n display: flex;\n gap: 8px;\n align-items: flex-start;\n justify-content: flex-end;\n flex-wrap: wrap;\n max-width: 560px;\n}\n.wp-acts .btn .glyph {\n margin-left: 6px;\n}\n.wp-acts .band-workshop-edit-entry {\n max-width: 240px;\n}\n.wp-acts-why {\n flex-basis: 100%;\n text-align: right;\n}\n.wp-meta {\n margin: 0;\n display: flex;\n flex-wrap: wrap;\n gap: 6px 22px;\n font-size: var(--fs-ui);\n}\n.wp-meta > div {\n display: flex;\n gap: 6px;\n min-width: 0;\n}\n.wp-meta dt {\n color: var(--muted);\n}\n.wp-meta dd {\n margin: 0;\n}\n.wp-mine {\n display: inline-flex;\n gap: 10px;\n flex-wrap: wrap;\n}\n.wp-pending {\n display: grid;\n gap: 8px;\n}\n.wp-pending > * {\n margin: 0;\n}\n.wp-line {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--r-lg);\n background: var(--fill);\n font-size: var(--fs-ui);\n}\n.wp-line > span:not(.chip) {\n flex: 1;\n min-width: 0;\n}\n.wp-main {\n display: grid;\n gap: 18px;\n min-width: 0;\n}\n.wp-panel {\n display: grid;\n gap: 32px;\n min-width: 0;\n}\n.wp-flow {\n display: grid;\n grid-template-columns: minmax(0, max-content) minmax(280px, 1fr);\n gap: 40px;\n align-items: start;\n}\n.wp-flow-main {\n display: grid;\n gap: 18px;\n min-width: 0;\n}\n.wp a.band-workshops-link {\n text-decoration: none;\n}\n.wp a.band-workshops-link:hover {\n text-decoration: underline;\n}\n.wp-flow-side {\n max-width: 460px;\n display: grid;\n gap: 28px;\n min-width: 0;\n}\n.wp-sec {\n display: grid;\n gap: 12px;\n min-width: 0;\n}\n.wp-sec h2 {\n margin: 0;\n font-size: var(--fs-title);\n font-weight: 600;\n}\n.wp-sec-h {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 16px;\n flex-wrap: wrap;\n}\n.wp-sec-h p {\n margin: 4px 0 0;\n}\n@container band-workshops (max-width: 860px) {\n .wp-flow {\n grid-template-columns: minmax(0, 1fr);\n }\n}\n@media (max-width: 860px) {\n .wp-head {\n grid-template-columns: 48px minmax(0, 1fr);\n }\n .wp-acts {\n grid-column: 1 / -1;\n justify-content: flex-start;\n max-width: none;\n }\n .wp-acts-why {\n text-align: left;\n }\n}\n@media (max-width: 599px) {\n .wp.band-workshops-screen {\n padding: 16px 16px 48px;\n }\n .wp-acts > .btn,\n .wp-acts .band-workshop-edit-entry {\n flex: 1 1 40%;\n max-width: none;\n }\n .wp-acts > .btn.primary,\n .wp-acts .band-workshop-edit-entry:has(.btn.primary) {\n flex-basis: 100%;\n order: -1;\n }\n}\n.wp-tabs {\n max-width: 100%;\n overflow-x: auto;\n}\n.wp-new-project {\n white-space: nowrap;\n}\n.wp-meta-act dd {\n margin: 0;\n}\n';let el=document.head.querySelector('style[data-band-style="@kanyun-ai-infra/band-workshops"]');if(!el){el=document.createElement("style");el.setAttribute("data-band-style","@kanyun-ai-infra/band-workshops");document.head.prepend(el)}el.textContent=css}var SELF="@kanyun-ai-infra/band-workshops";function Crumb({ctx,w,here}){return jsxs("nav",{className:"band-workshops-crumb","aria-label":"\u4F4D\u7F6E",children:[jsx("button",{type:"button",onClick:()=>ctx.app.navigate({page:`${SELF}/workshops`}),children:"\u5DE5\u574A"}),w&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":"true",children:"\u203A"}),here?jsx("button",{type:"button",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}}),children:w.name}):jsx("span",{"aria-current":"page",children:w.name})]}),here&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":"true",children:"\u203A"}),jsx("span",{"aria-current":"page",children:here})]})]})}function useModalDialog({open,onRequestClose,blocked,initialFocus="button"}){const dialog=useRef(null);const trigger=useRef(null);const close=useRef(onRequestClose);close.current=onRequestClose;const busy=useRef(blocked);busy.current=blocked;useEffect(()=>{const d=dialog.current;if(!d)return;if(open&&!d.open){if(typeof d.showModal==="function")d.showModal();else d.setAttribute("open","");d.querySelector(initialFocus)?.focus()}else if(!open&&d.open){if(typeof d.close==="function")d.close();else d.removeAttribute("open");trigger.current?.focus()}},[open,initialFocus]);useEffect(()=>{if(!open)return;const d=dialog.current;const onKey=withImeGuard(e=>{if(e.key!=="Escape"||e.defaultPrevented)return;const layers=document.querySelectorAll("[data-band-layer]");if(layers[layers.length-1]!==d)return;e.preventDefault();if(!busy.current)close.current()});let downOnBackdrop=false;const onDown=e=>{downOnBackdrop=e.target===d};const onClick=e=>{if(downOnBackdrop&&e.target===d&&!busy.current)close.current();downOnBackdrop=false};window.addEventListener("keydown",onKey);d?.addEventListener("mousedown",onDown);d?.addEventListener("click",onClick);return()=>{window.removeEventListener("keydown",onKey);d?.removeEventListener("mousedown",onDown);d?.removeEventListener("click",onClick)}},[open]);return{dialog,trigger}}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"}];function showsFreeformIntro(o){return o.workshop===FREEFORM_ID&&o.projects!==void 0&&o.projects.length===0&&o.draftEmpty}function needLede(workshop){return workshop===FREEFORM_ID?"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48\u3002":"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48\u3002\u5EFA\u597D\u5C31\u4EA4\u7ED9 Rondo\uFF0C\u5B83\u63A5\u7740\u505A\u7B2C\u4E00\u7248\u3002"}function FreeformIntro({onPick}){const titleId=useId();return jsxs2("section",{className:"band-workshops-intro","aria-labelledby":titleId,children:[jsx2("p",{className:"band-workshops-intro-lede",children:FREEFORM_INTRO}),jsx2("h2",{id:titleId,className:"band-workshops-intro-h",children:"\u53EF\u4EE5\u4ECE\u8FD9\u4E9B\u5F00\u59CB"}),jsx2("div",{className:"band-workshops-samples",children:FREEFORM_SAMPLES.map(s=>jsxs2("button",{type:"button",className:"band-workshops-sample",onClick:()=>onPick(s.text),children:[jsx2("b",{children:s.title}),jsx2("span",{children:s.text})]},s.title))})]})}function useProjectModel(ctx,policy){const api=ctx.app.data.write?.modelCredentials;const active=!!api&&policy!==void 0&&policy!=="off";const[state,setState]=useState(active?{kind:"loading"}:{kind:"hidden"});const[forPolicy,setForPolicy]=useState(void 0);const[selected,select]=useState(null);useEffect2(()=>{if(!active){setState({kind:"hidden"});setForPolicy(policy);return}if(!api)return;let live=true;setState(s=>s.kind==="hidden"||s.kind==="loading"?{kind:"loading"}:s);api.list().then(r=>{if(!live)return;setForPolicy(policy);if(r===null)return setState({kind:"hidden"});if(r.credentials.length===0)return setState({kind:"none",required:policy==="require",...r.provision?{provision:r.provision}:{}});setState({kind:"pick",credentials:r.credentials,presets:r.presets,required:policy==="require"});const has=id=>r.credentials.some(c=>c.id===id);select(cur=>{if(cur!==null&&has(cur))return cur;return(r.credentials.find(c=>c.isDefault)??r.credentials[0])?.id??null})},()=>{if(!live)return;setForPolicy(policy);setState({kind:"hidden"})});return()=>{live=false}},[api,policy,active]);const settled=forPolicy===policy?state:active?{kind:"loading"}:state;return{state:settled,selected,select}}function projectModelBlocked(state){return state.kind==="loading"||state.kind==="none"&&state.required&&provisionConsentOf(state)===null}function provisionConsentOf(state){if(state.kind!=="none"||!state.required||!state.provision)return null;const s=state.provision.status;return s==="none"||s==="pending"?{quotaUsd:state.provision.quotaUsd}:null}function projectModelMissing(state){if(state.kind==="loading")return"\u6B63\u5728\u8BFB\u53D6\u6A21\u578B\u914D\u7F6E\u2026";return projectModelBlocked(state)?"\u8FD8\u5DEE\u6A21\u578B\u914D\u7F6E\uFF1A\u4F60\u540D\u4E0B\u6CA1\u6709\u53EF\u9009\u7684":null}function selectedCredential(state,selected){return state.kind==="pick"?state.credentials.find(c=>c.id===selected)??null:null}function modelCredentialIdOf(state,selected){return selectedCredential(state,selected)?.id}function ProjectModelField({state,selected,select,onConfigure,disabled=false}){const id=useId2();if(state.kind==="hidden"||state.kind==="loading")return null;const consent=provisionConsentOf(state);if(consent){return jsx3("div",{className:"band-workshops-model-pick",children:jsxs3("p",{className:"band-workshops-note",children:[provisionConsentText(consent.quotaUsd)," ",jsx3("button",{type:"button",className:"btn sm",onClick:onConfigure,disabled,children:"\u6539\u7528\u81EA\u5DF1\u7684 key"})]})})}const required=state.required;const picked=selectedCredential(state,selected);const note=projectModelNote(required?"require":"allow",picked);const labelOf=preset=>preset===CUSTOM_MODEL_PRESET_ID?"\u81EA\u5B9A\u4E49":state.kind==="pick"?state.presets.find(p=>p.id===preset)?.label??preset:preset;return jsxs3("div",{className:"band-workshops-model-pick",children:[jsxs3("label",{className:"band-workshops-field",htmlFor:id,children:[jsxs3("span",{children:[PROJECT_MODEL_HEADING,required?jsx3("em",{className:"band-workshops-req",children:"\u5FC5\u586B"}):null]}),state.kind==="pick"?jsxs3("select",{id,value:selected??"",disabled,onChange:e=>select(e.target.value===""?null:e.target.value),children:[selected===null?jsx3("option",{value:"",children:"\u8BF7\u9009\u4E00\u4EFD"}):null,state.credentials.map(c=>jsxs3("option",{value:c.id,children:[credentialOptionLabel(c,labelOf(c.preset)),c.isDefault?"\uFF08\u9ED8\u8BA4\uFF09":""]},c.id))]}):jsx3("select",{id,value:"",disabled:true,children:jsx3("option",{value:"",children:required?"\u8FD8\u6CA1\u6709\u53EF\u9009\u7684":"\u5DE5\u574A\u7684\u56E2\u961F key"})})]}),jsxs3("p",{className:"band-workshops-note",children:[note.text,note.action&&jsxs3(Fragment2,{children:[" ",jsx3("button",{type:"button",className:"btn sm",onClick:onConfigure,children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"})]})]})]})}var MODEL_POLL_MS=3e3;function Steps({current,done=false}){return jsxs4("ol",{className:"band-workshops-steps","aria-label":"\u65B0\u5EFA\u5DE5\u574A\u7684\u6B65\u9AA4",children:[jsx4("li",{"data-n":"1",className:current===2?"is-done":void 0,"aria-current":current===1?"step":void 0,children:"\u57FA\u672C\u4FE1\u606F"}),jsx4("li",{"data-n":"2",className:done?"is-done":void 0,"aria-current":current===2&&!done?"step":void 0,children:"\u914D\u7F6E\u6A21\u578B"})]})}function useModelDeployment(ctx){const api=ctx.app.data.write?.workshopModel;const{data,error,reload}=useAppData(ctx,()=>api?api.deployment():Promise.resolve(null),[api]);return{deployment:data,error:data===void 0?error:null,reload}}var NOT_PROVISIONED={state:"not_provisioned",hubProject:"ready",agent:"ready"};function modelOf(w){return w.model??NOT_PROVISIONED}function newProjectBlocked(w){const m=modelOf(w);if(m.state==="not_provisioned")return void 0;if(w.version!==void 0&&repoBuilding({version:w.version,status:w.status}))return"\u5DE5\u574A\u51C6\u5907\u597D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";const detail=w.canAdmin?m.what:m.brief??m.what;if(modelMissing(m,w.userModelKey))return w.canAdmin?"\u914D\u597D\u6A21\u578B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002":"\u5DE5\u574A\u7BA1\u7406\u5458\u914D\u597D\u6A21\u578B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";if(m.agent==="failed"){if(m.owner==="waiting")return`Agent \u8FD8\u6CA1\u51C6\u5907\u597D\uFF0C\u6B63\u5728\u7B49\uFF1A${detail??"\u5B83\u81EA\u5DF1\u597D"}\u3002`;if(m.owner==="platform")return`Agent \u6CA1\u51C6\u5907\u597D\uFF0C\u9700\u8981\u5E73\u53F0\u7BA1\u7406\u5458\u5904\u7406\uFF1A${detail??"\u539F\u56E0\u672A\u77E5"}\u3002`;const fix=detail?`\uFF1A${detail}`:"";return w.canAdmin?`Agent \u6CA1\u51C6\u5907\u597D${fix}\uFF0C\u70B9\u300C\u91CD\u8BD5\u300D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002`:`Agent \u6CA1\u51C6\u5907\u597D${fix}\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u91CD\u8BD5\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002`}if(m.agent!=="ready")return"Agent \u51C6\u5907\u597D\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002";return void 0}function agentLabel(agent,retrying=false){if(agent==="preparing"&&retrying)return"\u6B63\u5728\u91CD\u8BD5";return agent==="failed"?"\u6CA1\u51C6\u5907\u597D":agent==="awaiting_promotion"?"\u7B49\u4E0A\u7EBF":agent==="ready"?"\u5DF2\u5C31\u7EEA":"\u51C6\u5907\u4E2D"}function waitedText(ms){const min=Math.floor(Math.max(0,ms)/6e4);if(min<1)return"\u4E0D\u5230 1 \u5206\u949F";if(min<60)return`${min} \u5206\u949F`;const h=Math.floor(min/60);const rest=min%60;return rest===0?`${h} \u5C0F\u65F6`:`${h} \u5C0F\u65F6 ${rest} \u5206\u949F`}function provisionProgress(m,now=Date.now()){if(m.state==="not_provisioned"||m.hasRequest===false)return void 0;if(m.agent==="ready"||m.agent==="failed"||m.hubProject==="failed")return void 0;const t=m.since===void 0?Number.NaN:Date.parse(m.since);const waitedFor=Number.isNaN(t)?"":waitedText(now-t);const waited=waitedFor===""?"":`\u5DF2\u7ECF\u7B49\u4E86${/^\d/.test(waitedFor)?" ":""}${waitedFor}\u3002`;if(m.agent==="awaiting_promotion")return{step:3,text:`\u7B2C 3 \u6B65\uFF0C\u5171 3 \u6B65\uFF1AAgent \u5DF2\u7ECF\u505A\u597D\uFF0C\u7B49 Band \u7BA1\u7406\u5458\u4E0A\u7EBF\uFF1B\u4E0A\u7EBF\u540E\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u8981\u5728\u5DE5\u574A\u9875\u70B9\u300C\u91CD\u8BD5\u300D\uFF0C\u624D\u4F1A\u7EE7\u7EED\u3002${waited}`};if(m.hubProject==="pending")return{step:1,text:`\u7B2C 1 \u6B65\uFF0C\u5171 3 \u6B65\uFF1A\u6B63\u5728\u4E3A\u8FD9\u4E2A\u5DE5\u574A\u5EFA AgentHub \u9879\u76EE\u3002${waited}`};return{step:2,text:`\u7B2C 2 \u6B65\uFF0C\u5171 3 \u6B65\uFF1A\u6B63\u5728\u51C6\u5907 Agent\uFF1A\u5199\u5165\u5B9A\u4E49\u5E76\u53D1\u5E03\u3002${waited}`}}function AgentFailedNote({error,owner,what,brief,retry,primary=false}){const detail=(retry?what:brief??what)??error??"\u539F\u56E0\u672A\u77E5";if(owner==="waiting")return jsxs4("div",{className:"band-workshops-retry",children:[jsxs4("output",{className:"band-workshops-status",children:[jsx4("span",{className:"chip s-running",children:"\u6B63\u5728\u7B49"}),"\u3000",detail,"\u3002"]}),retry&&jsx4(RetryProvision,{api:retry.api,workshop:retry.workshop,onDone:retry.onDone})]});const platform=owner==="platform";return jsxs4("div",{className:"band-workshops-retry",children:[jsx4(ErrorNote,{children:platform?`\u9700\u8981\u5E73\u53F0\u7BA1\u7406\u5458\u5904\u7406\uFF1A${detail}\u3002`:`\u5DE5\u574A\u7684 Agent \u6CA1\u51C6\u5907\u597D\uFF1A${detail}\u3002`}),retry&&jsx4(RetryProvision,{api:retry.api,workshop:retry.workshop,onDone:retry.onDone,afterFix:platform,primary:primary&&!platform})]})}function modelMissing(m,userModelKey){if(m===void 0||m.state==="not_provisioned")return false;return userModelKey!=="require"&&m.state!=="configured"}var SAVE_IN_PROGRESS="SAVE_IN_PROGRESS";function writeFailedText(reason){if(reason==="FORBIDDEN"||reason==="INSUFFICIENT_SCOPE")return"\u7F3A\u5C11 model-services:write \u6743\u9650";if(reason==="MODEL_SERVICE_NOT_UNIQUE")return"\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u91CC\u6709\u4E0D\u6B62\u4E00\u4E2A\u6A21\u578B\u670D\u52A1";if(reason===SAVE_IN_PROGRESS)return"\u53E6\u4E00\u4F4D\u7BA1\u7406\u5458\u6B63\u5728\u4FDD\u5B58";return reason??"\u539F\u56E0\u672A\u77E5"}function goAbout(ctx,id){ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}})}function RetryProvision({api,workshop,onDone,afterFix=false,label="\u91CD\u8BD5",primary=false}){const[busy,setBusy]=useState2(false);const[note,setNote]=useState2(null);const run=async()=>{setBusy(true);setNote(null);try{await api.retryProvision(workshop);onDone()}catch(e){const status=typeof e==="object"&&e!==null&&"details"in e?e.details?.status:void 0;setNote(status==="pending"||status==="running"?"\u6B63\u5728\u51C6\u5907\uFF0C\u4E0D\u7528\u518D\u70B9\u3002":status==="done"?"\u5DF2\u7ECF\u51C6\u5907\u597D\u4E86\u3002":`\u6CA1\u91CD\u8BD5\u6210\uFF1A${errorText(e)}`)}finally{setBusy(false)}};return jsxs4(Fragment4,{children:[jsx4("button",{type:"button",className:primary?"btn primary sm":"btn sm",disabled:busy,onClick:()=>void run(),children:busy?"\u6B63\u5728\u91CD\u8BD5\u2026":label}),afterFix&&jsx4("span",{className:"band-workshops-hint",children:"\u5E73\u53F0\u4FEE\u597D\u540E\u70B9"}),note&&jsx4("output",{className:"band-workshops-hint","aria-live":"polite",children:note})]})}function ModelSetup({ctx,id}){const{data:w,error,reload}=useAppData(ctx,d=>d.workshop(id),[id]);const api=ctx.app.data.write?.workshopModel;const{deployment,error:deploymentError,reload:reloadDeployment}=useModelDeployment(ctx);const waiting=!!w&&(w.status==="provisioning"||modelOf(w).state!=="not_provisioned"&&modelOf(w).hasRequest!==false&&(modelOf(w).hubProject==="pending"||modelOf(w).agent==="preparing"));useEffect3(()=>{if(!waiting)return;const t=setInterval(reload,MODEL_POLL_MS);return()=>clearInterval(t)},[waiting,reload]);if(error&&w===void 0)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx}),jsxs4(ErrorNote,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(deploymentError&&deployment===void 0)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx}),jsxs4(ErrorNote,{retry:reloadDeployment,children:["\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",deploymentError]})]});const policyPending=!!w&&w.status==="provisioning"&&w.userModelKey===void 0;if(policyPending&&error)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs4(ErrorNote,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(w===void 0||deployment===void 0||policyPending)return jsx4("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsx4("span",{className:"band-workshops-sk is-block"})});if(w===null)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx}),jsxs4("p",{className:"band-workshops-note",children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id,"\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"]})]});if(!api||deployment===null||modelOf(w).state==="not_provisioned"&&w.status!=="provisioning"||w.userModelKey==="require")return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx4("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsx4("p",{className:"band-workshops-note",children:w.userModelKey==="require"?"\u8FD9\u4E2A\u5DE5\u574A\u7528\u6210\u5458\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u6CA1\u6709\u56E2\u961F\u6A21\u578B\u8FD9\u4E00\u6B65\uFF1B\u6BCF\u4E2A\u4EBA\u5728\u4E2A\u4EBA\u8BBE\u7F6E\u91CC\u914D\u597D\u81EA\u5DF1\u7684\u6A21\u578B key\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u8FD9\u4E00\u6B65\uFF1A\u6A21\u578B\u5728\u5B83\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u91CC\u7BA1\u3002"}),w.userModelKey==="require"&&w.canAdmin&&api&&takeoverNeeded(w)&&jsx4(HubProjectLine,{w,api,onRetried:reload})]});if(!w.canAdmin)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx4("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsx4("div",{className:"band-workshops-callout",children:jsx4("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u914D\u6A21\u578B\u3002\u8981\u914D\u6216\u8981\u6362 key\uFF0C\u8BF7\u627E\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u3002"})}),jsx4("div",{className:"band-workshops-actions is-start",children:jsx4("button",{type:"button",className:"btn",onClick:()=>goAbout(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A"})})]});return jsx4(ModelPage,{ctx,w,api,deployment,reloadWorkshop:reload})}function ModelPage({ctx,w,api,deployment,reloadWorkshop}){const hubReady=modelOf(w).hubProject==="ready";const canSave=hubReady||modelOf(w).hasRequest===false;const[view,setView]=useState2(null);const[viewError,setViewError]=useState2(null);const[revision,setRevision]=useState2(0);useEffect3(()=>{if(!hubReady)return;let live=true;setViewError(null);api.get(w.id).then(v=>live&&setView(v),e=>live&&setViewError(errorText(e)));return()=>{live=false}},[api,w.id,hubReady,revision,modelOf(w).state,modelOf(w).agent]);const status=view?.status??w.model;const[reconfigure,setReconfigure]=useState2(false);const[saved,setSaved]=useState2(null);const[savedAgent,setSavedAgent]=useState2();const setup=status===void 0||status.state==="unconfigured";const afterSave=from=>agent=>{if(from==="setup"&&w.firstMessage&&deployment?.workshopEdit===true&&ctx.app.data.write?.workshopEdit){ctx.app.navigate({page:`${SELF}/edit`,params:{workshop:w.id}});return}setSaved(from);setSavedAgent(agent);setReconfigure(false);setRevision(n=>n+1)};if(viewError!==null&&!view)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs4(ErrorNote,{retry:()=>setRevision(n=>n+1),children:["\u6A21\u578B\u7684\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A",viewError]})]});if(saved)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:saved==="setup"?"\u914D\u7F6E\u6A21\u578B":"\u6A21\u578B"}),jsxs4("div",{children:[saved==="setup"&&jsx4(Steps,{current:2,done:true}),jsx4("h1",{className:"band-workshops-name",children:saved==="setup"?"\u914D\u7F6E\u6A21\u578B":"\u6A21\u578B"})]}),jsx4(SavedResult,{ctx,w,agent:savedAgent??modelOf(w).agent})]});if(setup)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u914D\u7F6E\u6A21\u578B"}),jsxs4("div",{children:[jsx4(Steps,{current:2}),jsx4("h1",{className:"band-workshops-name",children:"\u914D\u7F6E\u6A21\u578B"}),jsxs4("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684\u56DE\u5408\u7528\u8FD9\u91CC\u586B\u7684 key\uFF0C\u82B1\u8D39\u8BB0\u5728\u8FD9\u628A key \u4E0A\u3002\u914D\u597D\u4E4B\u524D\uFF0C\u8FD9\u4E2A\u5DE5\u574A\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]})]}),jsx4(HubProjectLine,{w,api,onRetried:reloadWorkshop}),jsx4(ModelForm,{ctx,w,api,deployment,canSave,mode:"setup",onSaved:afterSave("setup")})]});if(reconfigure)return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsx4("h1",{className:"band-workshops-name",children:"\u91CD\u65B0\u914D\u7F6E\u6A21\u578B"}),jsx4(ModelForm,{ctx,w,api,deployment,canSave,mode:"reconfigure",onSaved:afterSave("reconfigure"),onCancel:()=>setReconfigure(false)})]});return jsxs4("main",{className:"band-workshops-screen",children:[jsx4(Crumb,{ctx,w,here:"\u6A21\u578B"}),jsxs4("div",{children:[jsx4("h1",{className:"band-workshops-name",children:"\u6A21\u578B"}),jsxs4("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684\u56DE\u5408\u7528\u8FD9\u91CC\u914D\u7684\u6A21\u578B\uFF0C\u82B1\u8D39\u8BB0\u5728\u8FD9\u91CC\u586B\u7684 key \u4E0A\u3002"]})]}),jsxs4(Fragment4,{children:[jsx4(ModelFacts,{status,deployment}),status?.state==="configured"&&status.agent==="failed"&&jsx4(AgentFailedNote,{error:status.error,owner:status.owner,what:status.what,brief:status.brief,retry:{api,workshop:w.id,onDone:reloadWorkshop}}),status?.state==="missing"?jsx4("p",{className:"band-workshops-why is-bad",children:"AgentHub \u91CC\u627E\u4E0D\u5230\u8FD9\u4E2A\u5DE5\u574A\u5728\u7528\u7684\u6A21\u578B\u670D\u52A1\uFF08\u53EF\u80FD\u88AB\u5F52\u6863\u4E86\uFF09\u3002\u91CD\u65B0\u914D\u7F6E\u4E00\u6B21\uFF0C\u5DE5\u574A\u624D\u80FD\u7EE7\u7EED\u5F00\u5DE5\u3002"}):status?.state==="ambiguous"?jsx4("p",{className:"band-workshops-why is-bad",children:"AgentHub \u91CC\u8FD9\u4E2A\u5DE5\u574A\u6709\u4E0D\u6B62\u4E00\u4E2A\u540C\u540D\u7684\u6A21\u578B\u670D\u52A1\uFF0CBand \u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4E2A\u3002\u627E Band \u7BA1\u7406\u5458\u5728 AgentHub \u91CC\u5F52\u6863\u591A\u4F59\u7684\uFF0C\u518D\u70B9\u300C\u91CD\u8BD5\u300D\u3002"}):jsx4("div",{className:"band-workshops-callout",children:jsx4("p",{children:"key \u5728\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u91CC\uFF0CBand \u770B\u4E0D\u5230\u4E5F\u4E0D\u4FDD\u5B58\u3002\u8981\u6362 key\uFF0C\u70B9\u300C\u91CD\u65B0\u914D\u7F6E\u300D\u518D\u586B\u4E00\u6B21\u3002"})}),jsxs4("div",{className:"band-workshops-actions is-start",children:[jsx4("button",{type:"button",className:"btn primary",onClick:()=>setReconfigure(true),children:"\u91CD\u65B0\u914D\u7F6E"}),status?.state==="ambiguous"&&jsx4(RetryProvision,{api,workshop:w.id,onDone:reloadWorkshop})]})]})]})}function HubProjectLine({w,api,onRetried}){const hub=modelOf(w).hubProject??"pending";if(hub==="ready")return null;if(hub==="failed")return jsxs4("div",{className:"band-workshops-retry",children:[jsxs4(ErrorNote,{children:["\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u6CA1\u5EFA\u6210\uFF1A",modelOf(w).error??"\u539F\u56E0\u672A\u77E5"]}),jsx4(RetryProvision,{api,workshop:w.id,onDone:onRetried})]});if(takeoverNeeded(w))return jsxs4("div",{className:"band-workshops-retry",children:[jsx4("p",{className:"band-workshops-note",children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF1A\u5B83\u662F\u5728\u4EE3\u5EFA\u529F\u80FD\u6253\u5F00\u4E4B\u524D\u5EFA\u7684\u3002\u70B9\u4E0B\u9762\u7684\u6309\u94AE\u8BA9 Band \u7ED9\u5B83\u5EFA AgentHub \u9879\u76EE\uFF0C\u5EFA\u597D\u4E4B\u540E\u624D\u80FD\u586B\u6A21\u578B key\u3002"}),jsx4(RetryProvision,{api,workshop:w.id,onDone:onRetried,label:"\u8BA9 Band \u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A"})]});return jsxs4("output",{className:"band-workshops-status",children:[jsx4("span",{className:"chip s-running",children:"\u6B63\u5728\u5EFA\u5DE5\u574A\u7684 AgentHub \u9879\u76EE"}),"\u3000","\u597D\u4E86\u5C31\u80FD\u4FDD\u5B58\uFF0C\u4E00\u822C\u4E0D\u5230\u4E00\u5206\u949F\uFF0C\u8FD9\u91CC\u4F1A\u81EA\u52A8\u5237\u65B0\u3002\u53EF\u4EE5\u5148\u586B\u3002"]})}function ModelFacts({status,deployment}){const configured=status?.state==="configured";return jsxs4("dl",{className:"band-workshops-facts band-workshops-model-facts",children:[jsx4("dt",{children:"\u72B6\u6001"}),jsx4("dd",{children:configured?jsx4("span",{className:"chip s-done",children:"\u5DF2\u914D\u7F6E"}):jsx4("span",{className:"chip s-failed",children:"\u8981\u91CD\u65B0\u914D\u7F6E"})}),configured&&jsxs4(Fragment4,{children:[jsx4("dt",{children:"\u6765\u6E90"}),jsx4("dd",{children:"ModelGate"}),jsx4("dt",{children:"\u6A21\u578B"}),jsx4("dd",{children:status?.model??deployment.model}),status?.configuredBy&&jsxs4(Fragment4,{children:[jsx4("dt",{children:"\u914D\u7F6E\u4EBA"}),jsxs4("dd",{children:[jsx4(Avatar,{id:status.configuredBy.userId,name:status.configuredBy.displayName,size:"xs",decorative:true})," ",status.configuredBy.displayName,status.verifiedAt&&` \xB7 ${shortTime(status.verifiedAt)}`]})]}),status?.verifiedAt&&jsxs4(Fragment4,{children:[jsx4("dt",{children:"\u4E0A\u6B21\u6821\u9A8C"}),jsxs4("dd",{children:[shortTime(status.verifiedAt)," \u901A\u8FC7"]})]}),status&&status.agent!=="ready"&&jsxs4(Fragment4,{children:[jsx4("dt",{children:"Agent"}),jsx4("dd",{children:agentLabel(status.agent,status.retrying)})]})]})]})}function SavedResult({ctx,w,agent}){return jsxs4("div",{className:"band-workshops-form",children:[jsxs4("div",{className:"band-workshops-result","aria-live":"polite",children:[jsxs4("div",{className:"band-workshops-result-line",children:[jsx4("span",{className:"chip s-done",children:"\u5DF2\u914D\u7F6E"}),"\u6821\u9A8C\u901A\u8FC7\uFF0C\u5DF2\u4EA4\u7ED9 AgentHub\u3002"]}),jsx4("p",{className:"band-workshops-hint",children:agent==="ready"?"Agent \u5DF2\u5C31\u7EEA\uFF0C\u53EF\u4EE5\u65B0\u5EFA\u9879\u76EE\u4E86\u3002":agent==="awaiting_promotion"?"Band \u63A5\u7740\u51C6\u5907\u5DE5\u574A\u7684 Agent\uFF1B\u51C6\u5907\u597D\u4E4B\u524D\u4ECD\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u7B49 Band \u7BA1\u7406\u5458\u628A\u5B83\u4E0A\u7EBF\u3002":"\u63A5\u4E0B\u6765 Band \u4F1A\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent\uFF0C\u901A\u5E38\u8981 15\u201325 \u5206\u949F\u3002\u51C6\u5907\u597D\u4E4B\u524D\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u597D\u4E86\u5DE5\u574A\u9875\u4F1A\u81EA\u52A8\u5237\u65B0\u3002"})]}),jsx4("div",{className:"band-workshops-actions is-start",children:jsx4("button",{type:"button",className:"btn primary",onClick:()=>goAbout(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A\u9875"})})]})}var RESULT_TITLE={unauthorized:"key \u65E0\u6548",forbidden:"key \u65E0\u6548",model_unavailable:"\u6A21\u578B\u4E0D\u53EF\u7528",unreachable:"\u8FDE\u4E0D\u4E0A ModelGate",write_failed:"\u6CA1\u4EA4\u7ED9 AgentHub"};function resultText(outcome,reason,model){switch(outcome){case"unauthorized":return"ModelGate \u4E0D\u8BA4\u8FD9\u628A key\uFF08401\uFF09\u3002\u6838\u5BF9\u662F\u4E0D\u662F\u6574\u628A\u590D\u5236\u3001\u6709\u6CA1\u6709\u8FC7\u671F\u6216\u88AB\u505C\u7528\uFF0C\u6539\u597D\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";case"forbidden":return"\u8FD9\u628A key \u6CA1\u6709\u8C03\u7528\u6743\u9650\uFF08403\uFF09\u3002\u6838\u5BF9\u662F\u4E0D\u662F\u6574\u628A\u590D\u5236\u3001\u6709\u6CA1\u6709\u8FC7\u671F\u6216\u88AB\u505C\u7528\uFF0C\u6539\u597D\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";case"model_unavailable":return jsxs4(Fragment4,{children:["ModelGate \u8BA4\u8FD9\u628A key\uFF0C\u4F46\u8FD9\u628A key \u6CA1\u5F00\u901A Band \u7528\u7684\u6A21\u578B\uFF08",jsx4("code",{children:model}),"\uFF09\u3002\u5728 ModelGate \u7ED9\u8FD9\u628A key \u5F00\u901A\u540E\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002"]});case"unreachable":return"10 \u79D2\u5185\u6CA1\u8FDE\u4E0A ModelGate\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u7A0D\u540E\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\uFF1B\u4E00\u76F4\u8FDE\u4E0D\u4E0A\u5C31\u627E Band \u7BA1\u7406\u5458\u3002";case"write_failed":if(reason===SAVE_IN_PROGRESS)return"\u53E6\u4E00\u4F4D\u7BA1\u7406\u5458\u6B63\u5728\u4FDD\u5B58\u8FD9\u4E2A\u5DE5\u574A\u7684\u6A21\u578B\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u7A0D\u7B49\u7247\u523B\u518D\u70B9\u300C\u6821\u9A8C\u5E76\u4FDD\u5B58\u300D\u3002";return`\u6821\u9A8C\u901A\u8FC7\u4E86\uFF0C\u4F46\u5199\u8FDB AgentHub \u5931\u8D25\uFF1A${writeFailedText(reason)}\u3002\u8FD9\u4E0D\u662F key \u7684\u95EE\u9898\uFF0C\u627E Band \u7BA1\u7406\u5458\u3002`}}function ModelForm({ctx,w,api,deployment,canSave,mode,onSaved,onCancel}){const[key,setKey]=useState2("");const[phase,setPhase]=useState2({kind:"idle"});const input=useRef2(null);const keyId=useId3();const hintId=useId3();const checking=phase.kind==="checking";const keyBad=phase.kind==="missing"||phase.kind==="failed"&&(phase.outcome==="unauthorized"||phase.outcome==="forbidden");const notSaved=mode==="setup"?"\u8FD9\u6B21\u6CA1\u6709\u4FDD\u5B58\uFF0C\u5DE5\u574A\u4ECD\u662F\u300C\u5F85\u914D\u7F6E\u6A21\u578B\u300D\u3002":"\u539F\u6765\u7684\u914D\u7F6E\u6CA1\u53D8\u3002";const submit=async()=>{if(checking||!canSave)return;const value=key.trim();if(value===""){setPhase({kind:"missing"});input.current?.focus();return}setPhase({kind:"checking"});try{const r=await api.configure(w.id,{source:"modelgate",key:value});if(r.outcome==="ok"){setKey("");setPhase({kind:"idle"});onSaved(r.model.status.agent);return}setPhase({kind:"failed",outcome:r.outcome,...r.reason!==void 0?{reason:r.reason}:{}})}catch(e){setPhase({kind:"error",message:errorText(e)})}};return jsxs4("form",{className:"band-workshops-form",onSubmit:e=>{e.preventDefault();void submit()},children:[jsx4("div",{className:"band-workshops-sources",role:"radiogroup","aria-label":"\u6A21\u578B\u4ECE\u54EA\u6765",children:jsxs4("label",{className:"band-workshops-source is-on",children:[jsx4("input",{type:"radio",className:"radio",name:"band-workshops-model-source",checked:true,readOnly:true}),jsxs4("span",{children:[jsx4("b",{children:"ModelGate"}),jsx4("small",{children:"\u586B\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684 ModelGate key\uFF0C\u7AEF\u70B9\u548C\u6A21\u578B\u7531 Band \u5B9A\u3002"})]})]})}),jsxs4("div",{className:"band-workshops-subfields",children:[jsxs4("label",{className:"band-workshops-field",htmlFor:keyId,children:[jsxs4("span",{children:["ModelGate key",jsx4("span",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx4("input",{id:keyId,ref:input,className:"field mono",type:"password",autoComplete:"off",spellCheck:false,placeholder:mode==="setup"?"\u7C98\u8D34\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684 ModelGate key":"\u7C98\u8D34\u65B0\u7684\u6216\u539F\u6765\u7684 key",value:key,disabled:checking,onChange:e=>{setKey(e.target.value);if(phase.kind==="missing")setPhase({kind:"idle"})},"aria-invalid":keyBad?true:void 0,"aria-describedby":hintId}),jsx4("small",{id:hintId,className:phase.kind==="missing"?"band-workshops-err":"band-workshops-hint",children:phase.kind==="missing"?"\u8FD8\u5DEE ModelGate key \u6CA1\u586B":mode==="setup"?"\u8FD9\u4E2A\u5DE5\u574A\u6240\u6709\u9879\u76EE\u7684\u82B1\u8D39\u90FD\u8BB0\u5728\u8FD9\u628A key \u4E0A\u3002":"\u65B0 key \u4ECE\u4E0B\u4E00\u56DE\u5408\u8D77\u751F\u6548\uFF1B\u6B63\u5728\u8DD1\u7684\u56DE\u5408\u7528\u539F\u6765\u7684\u8DD1\u5B8C\u3002"})]}),jsxs4("p",{className:"band-workshops-readonly",children:["\u6A21\u578B\uFF1A",jsx4("code",{children:deployment.model}),"\u3000\u7AEF\u70B9\uFF1A",jsx4("code",{children:deployment.endpoint})]})]}),mode==="setup"&&jsx4("div",{className:"band-workshops-callout",children:jsxs4("p",{children:[jsx4("b",{children:"key \u53EA\u4EA4\u7ED9 AgentHub\u3002"}),"Band \u6821\u9A8C\u4E00\u6B21\u540E\u628A\u5B83\u5199\u8FDB\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\uFF0C\u81EA\u5DF1\u4E0D\u4FDD\u5B58\u3002\u914D\u597D\u4EE5\u540E\u8FD9\u91CC\u770B\u4E0D\u5230 key\uFF0C\u8981\u6362\u5C31\u91CD\u65B0\u586B\u4E00\u628A\u3002"]})}),phase.kind==="checking"&&jsx4("div",{className:"band-workshops-result","aria-live":"polite",children:jsxs4("div",{className:"band-workshops-result-line",children:[jsx4("span",{className:"chip s-running",children:"\u6B63\u5728\u6821\u9A8C"}),"\u7528\u8FD9\u628A key \u5411 ModelGate \u53D1\u4E00\u6B21\u6700\u5C0F\u8BF7\u6C42\uFF0C\u51E0\u79D2\u949F\u3002"]})}),phase.kind==="failed"&&jsxs4("div",{className:"band-workshops-result",role:"alert",children:[jsx4("div",{className:"band-workshops-result-line",children:jsx4("span",{className:"chip s-failed",children:RESULT_TITLE[phase.outcome]})}),jsx4("p",{className:"band-workshops-why is-bad",children:resultText(phase.outcome,phase.reason,deployment.model)}),phase.outcome!=="unreachable"&&phase.outcome!=="write_failed"&&jsx4("p",{className:"band-workshops-hint",children:notSaved}),(phase.outcome==="unreachable"||phase.outcome==="write_failed")&&mode==="reconfigure"&&jsx4("p",{className:"band-workshops-hint",children:notSaved})]}),phase.kind==="error"&&jsxs4("div",{className:"band-workshops-result",role:"alert",children:[jsxs4("p",{className:"band-workshops-why is-bad",children:["\u6CA1\u4FDD\u5B58\uFF1A",phase.message]}),jsx4("p",{className:"band-workshops-hint",children:notSaved})]}),jsxs4("div",{className:"band-workshops-actions",children:[jsx4("button",{type:"button",className:"btn ghost",disabled:checking,onClick:()=>onCancel?onCancel():goAbout(ctx,w.id),children:mode==="setup"?"\u4EE5\u540E\u518D\u914D":"\u53D6\u6D88"}),jsx4("button",{type:"submit",className:"btn primary",disabled:checking||!canSave,title:canSave?void 0:"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58",children:checking?"\u6B63\u5728\u6821\u9A8C\u2026":"\u6821\u9A8C\u5E76\u4FDD\u5B58"})]})]})}function WhoCanConfigure({ctx,workshop}){const api=ctx.app.data.write?.workshopMaintainers;const{data}=useAppData(ctx,()=>api?api.get(workshop):Promise.resolve(null),[api,workshop]);if(!data||data.people.length===0)return jsx4(Fragment4,{children:"\u80FD\u914D\u7684\u4EBA\uFF1A\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u3002"});return jsxs4(Fragment4,{children:["\u80FD\u914D\u7684\u4EBA\uFF1A",data.people.map((p,i)=>jsxs4(Fragment3,{children:[i>0&&"\u3001",jsx4(Avatar,{id:p.userId,name:p.displayName,size:"xs",decorative:true})," ",p.displayName,"\uFF08",p.role==="owner"?"\u521B\u5EFA\u4EBA":"\u7BA1\u7406\u5458","\uFF09"]},p.userId)),"\u3002"]})}function openModelPage(ctx,workshop){ctx.app.navigate({page:`${SELF}/model`,params:{workshop}})}function takeoverNeeded(w){return modelOf(w).hasRequest===false&&w.version>0&&!repoBuilding(w)}function repoBuilding(w){return w.status==="provisioning"||w.version===0&&w.status!=="failed"}function ModelNotice({ctx,w,onChanged,building,primary=true}){const m=modelOf(w);const api=ctx.app.data.write?.workshopModel;const buildingRepo=building??repoBuilding(w);if(m.hasRequest===false&&buildingRepo)return jsx4("div",{className:"band-workshops-callout",children:jsxs4("p",{children:[jsx4("span",{className:"chip s-running",children:"\u6B63\u5728\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A"}),"\u3000","\u4ED3\u5E93\u548C\u5B9A\u4E49\u5EFA\u597D\u540E\uFF0CBand \u4F1A\u81EA\u52A8\u63A5\u624B\u5B83\u7684 Agent\uFF0C\u4E0D\u7528\u4F60\u64CD\u4F5C\u3002"]})});if(m.hasRequest===false&&w.version===0&&!buildingRepo)return null;if(m.hasRequest===false)return w.canAdmin&&api?jsxs4("output",{className:"band-workshops-needs",children:[jsx4("span",{className:"glyph needs","aria-hidden":"true"}),jsxs4("p",{children:[jsx4("b",{children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\u3002"}),"\u5B83\u662F\u5728\u4EE3\u5EFA\u529F\u80FD\u6253\u5F00\u4E4B\u524D\u5EFA\u7684\uFF0C\u8FD8\u6CA1\u6709 AgentHub \u9879\u76EE\uFF1B\u70B9\u4E0B\u9762\u8BA9\u5B83\u63A5\u624B\uFF0C\u4E4B\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]}),jsx4(RetryProvision,{api,workshop:w.id,onDone:onChanged,label:"\u8BA9 Band \u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A",primary})]}):jsx4("div",{className:"band-workshops-callout",children:jsxs4("p",{children:[jsx4("b",{children:"Band \u8FD8\u6CA1\u63A5\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u6682\u65F6\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"}),jsx4(WhoCanConfigure,{ctx,workshop:w.id})]})});if(modelMissing(m,w.userModelKey))return w.canAdmin?jsxs4("output",{className:"band-workshops-needs",children:[jsx4("span",{className:"glyph needs","aria-hidden":"true"}),jsxs4("p",{children:[jsx4("b",{children:"\u8FD8\u6CA1\u914D\u6A21\u578B\u3002"}),"\u914D\u597D\u4E4B\u524D\u8FD9\u4E2A\u5DE5\u574A\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u4E5F\u4E0D\u4F1A\u5F00\u59CB\u56DE\u5408\u3002\u56DE\u5408\u7684\u82B1\u8D39\u8BB0\u5728\u8FD9\u4E2A\u5DE5\u574A\u7684 key \u4E0A\u3002"]}),jsx4("button",{type:"button",className:primary?"btn primary sm":"btn sm",onClick:()=>openModelPage(ctx,w.id),children:"\u914D\u7F6E\u6A21\u578B"})]}):jsx4("div",{className:"band-workshops-callout",children:jsxs4("p",{children:[jsx4("b",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0C\u6682\u65F6\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"}),jsx4(WhoCanConfigure,{ctx,workshop:w.id})]})});if(m.agent==="preparing")return jsxs4("div",{className:"band-workshops-callout",children:[jsx4("p",{children:jsx4("span",{className:"chip s-running",children:m.retrying?"\u6B63\u5728\u91CD\u8BD5":"\u6B63\u5728\u51C6\u5907\u5DE5\u574A\u7684 Agent"})}),jsxs4("p",{className:"band-workshops-callout-more",children:[w.userModelKey==="require"?null:jsx4("b",{children:"\u6A21\u578B\u5DF2\u914D\u7F6E\u3002"}),"Band \u6B63\u5728\u51C6\u5907\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent\uFF0C\u901A\u5E38\u8981 15\u201325 \u5206\u949F\u3002\u597D\u4E86\u5C31\u80FD\u65B0\u5EFA\u9879\u76EE\uFF0C\u8FD9\u91CC\u4F1A\u81EA\u52A8\u5237\u65B0\u3002"]})]});if(m.agent==="awaiting_promotion")return jsxs4("div",{className:"band-workshops-callout",children:[jsx4("p",{children:jsx4("span",{className:"chip",children:"\u7B49\u4E0A\u7EBF"})}),jsxs4("p",{className:"band-workshops-callout-more",children:[jsx4("b",{children:w.userModelKey==="require"?"Agent \u7B49\u4E0A\u7EBF\u3002":"\u6A21\u578B\u5DF2\u914D\u7F6E\uFF0CAgent \u7B49\u4E0A\u7EBF\u3002"}),"Band \u7BA1\u7406\u5458\u628A\u5B83\u4E0A\u7EBF\u540E\uFF0C\u5DE5\u574A\u7BA1\u7406\u5458\u70B9\u300C\u91CD\u8BD5\u300D\uFF0C\u5C31\u80FD\u65B0\u5EFA\u9879\u76EE\u3002"]}),w.canAdmin&&api&&jsx4(RetryProvision,{api,workshop:w.id,onDone:onChanged})]});if(m.agent==="failed")return jsx4(AgentFailedNote,{error:m.error,owner:m.owner,what:m.what,brief:m.brief,retry:w.canAdmin&&api?{api,workshop:w.id,onDone:onChanged}:void 0,primary});return null}function modelNeedsYou(w,hasModelApi){if(!w.canAdmin||!hasModelApi)return false;const m=modelOf(w);if(m.hasRequest===false)return!repoBuilding(w)&&w.version!==0;if(modelMissing(m,w.userModelKey))return true;return m.agent==="failed"&&m.owner!=="platform"&&m.owner!=="waiting"}var absent=e=>isForbidden(e)||e?.code==="NOT_FOUND";var TEXT={detach:{title:n=>`\u62C6\u51FA ${n} \u4E2A\u63D2\u4EF6\uFF1F`,button:"\u62C6\u51FA",busy:"\u6B63\u5728\u62C6\u51FA\u2026",failed:"\u6CA1\u62C6\u51FA",done:"\u62C6\u51FA"},refollow:{title:n=>`\u91CD\u65B0\u8DDF\u968F ${n} \u4E2A\u63D2\u4EF6\uFF1F`,button:"\u91CD\u65B0\u8DDF\u968F",busy:"\u6B63\u5728\u91CD\u65B0\u8DDF\u968F\u2026",failed:"\u6CA1\u91CD\u65B0\u8DDF\u968F",done:"\u91CD\u65B0\u8DDF\u968F"}};var detachedDir=name=>`band/views/${name.split("/").pop()??name}/`;var repoDir=spec=>`band/${spec.replace(/^\.\//,"").replace(/\/+$/,"")}/`;function DetachPlugins({ctx,workshop}){const api=ctx.app.data.write?.workshopPlugins;const[data,setData]=useState3(null);const[loadError,setLoadError]=useState3(null);const[picked,setPicked]=useState3({detach:[],refollow:[]});const[dialog,setDialog]=useState3(null);const[pending,setPending]=useState3({});const[done,setDone]=useState3(null);const load=useCallback(()=>{if(!api)return;api.list(workshop).then(r=>{setData(r);setLoadError(null)},e=>{setData(null);setLoadError(absent(e)?null:failedBecause(e,"\u70B9\u91CD\u8BD5"))})},[api,workshop]);useEffect4(()=>{load()},[load]);if(!api)return null;if(loadError)return jsxs5(ErrorNote2,{retry:load,children:["\u62C6\u51FA\u4E0E\u91CD\u65B0\u8DDF\u968F\u6CA1\u8BFB\u51FA\u6765\uFF1A",loadError]});if(!data||data.references.length===0&&data.detached.length===0)return null;const toggle=(mode,name,on)=>setPicked(p=>({...p,[mode]:on?[...p[mode],name]:p[mode].filter(n=>n!==name)}));const row=(mode,name,meta)=>{const state=pending[name];return jsxs5("li",{children:[jsxs5("label",{className:"choice",children:[jsx5("input",{type:"checkbox",className:"checkbox",checked:picked[mode].includes(name),disabled:state!==void 0,onChange:e=>toggle(mode,name,e.target.checked)}),jsx5("code",{children:name})]}),jsx5("span",{className:"band-workshops-detach-meta",children:state?`\u5DF2\u63D0\u4EA4${TEXT[state].done}\uFF0C\u53D1\u5E03\u65B0\u7248\u540E\u751F\u6548`:meta})]},name)};const actions=mode=>{const n=picked[mode].length;const over=n>WORKSHOP_PLUGIN_NAMES_MAX;return jsxs5("div",{className:"band-workshops-detach-acts",children:[over&&jsxs5("span",{className:"band-workshops-hint",children:["\u4E00\u6B21\u6700\u591A ",WORKSHOP_PLUGIN_NAMES_MAX," \u4E2A\uFF0C\u8BF7\u5C11\u9009\u51E0\u4E2A"]}),jsxs5("button",{type:"button",className:"btn sm",disabled:n===0||over,"aria-haspopup":"dialog",onClick:()=>{setDone(null);setDialog(mode)},children:[TEXT[mode].button,n>0?`\u6240\u9009 ${n} \u4E2A`:""]})]})};const doneNote=mode=>done?.mode===mode?jsxs5("output",{className:"band-workshops-detach-done","aria-live":"polite",children:[jsx5("span",{children:`\u5DF2\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF1A${TEXT[done.mode].done} ${done.names.join("\u3001")}\u3002\u8FD8\u6CA1\u751F\u6548\uFF0C\u70B9\u300C\u7248\u672C\u300D\u5206\u9875\u7684\u300C\u53D1\u5E03\u65B0\u7248\u300D\u53D1\u5E03\u540E\uFF0C\u65B0\u9879\u76EE\u624D\u7528\u4E0A\u3002`}),done.notes.map(n=>jsx5("span",{children:n},n))]}):null;return jsxs5("section",{className:"band-workshops-detach","aria-label":"\u5171\u4EAB\u63D2\u4EF6\u7684\u8DDF\u968F",children:[data.references.length>0&&jsxs5(Fragment5,{children:[jsx5("h3",{className:"band-workshops-sub",children:"\u5F15\u7528\u7684\u5171\u4EAB\u63D2\u4EF6"}),jsx5("p",{className:"band-workshops-note",children:"\u8FD9\u4E9B\u63D2\u4EF6\u5F15\u7528\u5171\u4EAB\u51FA\u6765\u7684\u7248\u672C\uFF0C\u53D1\u5E03\u65B0\u7248\u65F6\u8DDF\u7740\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\uFF08\u5305\u540D\u91CC @ \u540E\u9762\u90A3\u4E2A\uFF09\u8D70\u3002\u60F3\u81EA\u5DF1\u6539\u4EE3\u7801\uFF0C\u9009\u4E0A\u70B9\u300C\u62C6\u51FA\u300D\uFF1A\u6E90\u7801\u62F7\u8FDB\u672C\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E4B\u540E\u4E0D\u518D\u8DDF\u968F\u3002"}),jsx5("ul",{className:"band-workshops-detach-list",children:data.references.map(r=>row("detach",r.name,`\u5F15\u7528 ${r.spec}\uFF0C\u73B0\u5728\u7528 ${r.version}`))}),actions("detach"),doneNote("detach")]}),data.detached.length>0&&jsxs5(Fragment5,{children:[jsx5("h3",{className:"band-workshops-sub",children:"\u62C6\u51FA\u7684\u5171\u4EAB\u63D2\u4EF6"}),jsx5("p",{className:"band-workshops-note",children:"\u8FD9\u4E9B\u63D2\u4EF6\u662F\u4ECE\u5171\u4EAB\u7248\u672C\u62C6\u51FA\u6765\u7684\u6E90\u7801\u3002\u60F3\u56DE\u5230\u8DDF\u7740\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u8D70\uFF0C\u9009\u4E0A\u70B9\u300C\u91CD\u65B0\u8DDF\u968F\u300D\uFF1A\u5220\u6389\u672C\u5DE5\u574A\u91CC\u8FD9\u4EFD\u6E90\u7801\uFF0C\u6539\u56DE\u5F15\u7528\u3002"}),jsx5("ul",{className:"band-workshops-detach-list",children:data.detached.map(d=>row("refollow",d.name,`\u672C\u5DE5\u574A\u7684\u6E90\u7801 ${d.spec}\uFF08${d.version}\uFF09\uFF0C\u6240\u5C5E\u5DE5\u574A\u73B0\u5728\u5171\u4EAB\u7684\u662F ${d.upstreamVersion}`))}),actions("refollow"),doneNote("refollow")]}),dialog&&jsx5(ConfirmDialog,{api,workshop,mode:dialog,names:picked[dialog],data,onClose:()=>setDialog(null),onDone:(names,notes)=>{const mode=dialog;setDialog(null);setPicked(p=>({...p,[mode]:[]}));setPending(p=>({...p,...Object.fromEntries(names.map(n=>[n,mode]))}));setDone({mode,names,notes})}})]})}function ConfirmDialog({api,workshop,mode,names,data,onClose,onDone}){const[chosen,setChosen]=useState3(names);const[busy,setBusy]=useState3(false);const[error,setError]=useState3("");const t=TEXT[mode];const go=async()=>{if(busy||chosen.length===0)return;setBusy(true);setError("");try{if(mode==="detach"){const r=await api.detach(workshop,chosen);onDone(r.detached.map(d=>d.name),r.notes??[])}else{const r=await api.refollow(workshop,chosen);onDone(r.refollowed.map(d=>d.name),[])}}catch(e){setError(`${t.failed}\uFF1A${failedBecause(e,`\u518D\u70B9\u4E00\u6B21\u300C${t.button}\u300D`)}${chosen.length>1?"\u3002\u53EF\u4EE5\u53BB\u6389\u5176\u4E2D\u4E00\u4E2A\u518D\u8BD5\u3002":""}`);setBusy(false)}};const label=name=>{if(mode==="detach"){const r=data.references.find(x=>x.name===name);return r?`${r.version}\uFF0C\u62C6\u51FA\u540E\u5728 ${detachedDir(name)}`:""}const d=data.detached.find(x=>x.name===name);return d?`\u5220\u6389 ${repoDir(d.spec)}\uFF0C\u6539\u56DE ${name}@^${d.upstreamVersion}`:""};return jsxs5(SettingsDialog,{title:t.title(chosen.length),onClose:()=>!busy&&onClose(),actions:jsxs5(Fragment5,{children:[jsx5("button",{type:"button",className:"btn ghost",disabled:busy,onClick:onClose,children:"\u53D6\u6D88"}),jsx5("button",{type:"button",className:"btn primary",disabled:busy||chosen.length===0,onClick:()=>void go(),children:busy?t.busy:t.button})]}),children:[jsx5("ul",{className:"band-workshops-detach-list",children:names.map(n=>jsxs5("li",{children:[jsxs5("label",{className:"choice",children:[jsx5("input",{type:"checkbox",className:"checkbox",checked:chosen.includes(n),disabled:busy,onChange:e=>setChosen(c=>e.target.checked?[...c,n]:c.filter(x=>x!==n))}),jsx5("code",{children:n})]}),jsx5("span",{className:"band-workshops-detach-meta",children:label(n)})]},n))}),mode==="detach"?jsxs5("ul",{children:[jsx5("li",{children:"\u4E0D\u518D\u8DDF\u968F\uFF1A\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u4EE5\u540E\u53D1\u65B0\u7248\u672C\uFF0C\u8FD9\u4E9B\u63D2\u4EF6\u4E0D\u4F1A\u8DDF\u7740\u66F4\u65B0\u3002"}),jsx5("li",{children:"\u5305\u540D\u4E0D\u53D8\uFF0C\u5DF2\u6709\u9879\u76EE\u91CC\u7684\u6570\u636E\u548C\u610F\u89C1\u4F4D\u7F6E\u7167\u5E38\u63A5\u5F97\u4E0A\u3002"}),jsx5("li",{children:"\u6E90\u7801\u662F\u767B\u8BB0\u8FD9\u4E00\u7248\u65F6\u5B58\u4E0B\u7684\u90A3\u4EFD\uFF0C\u62F7\u8FDB\u672C\u5DE5\u574A\u4ED3\u5E93\uFF0C\u53D8\u6210\u8FD9\u4E2A\u5DE5\u574A\u79C1\u6709\u7684\u6E90\u7801\uFF0C\u4E4B\u540E\u53EF\u4EE5\u81EA\u5DF1\u6539\u3002"}),jsx5("li",{children:"\u53EA\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E0D\u53D1\u5E03\uFF1A\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u4E4B\u540E\u624D\u751F\u6548\u3002"}),jsx5("li",{children:"\u60F3\u56DE\u5230\u5F15\u7528\uFF1A\u4E4B\u540E\u5728\u8FD9\u91CC\u70B9\u300C\u91CD\u65B0\u8DDF\u968F\u300D\uFF0C\u8981\u4F60\u80FD\u7528\u5B83\u6240\u5C5E\u7684\u5DE5\u574A\u3001\u90A3\u4E2A\u5DE5\u574A\u5F53\u524D\u7248\u672C\u91CC\u8FD8\u5171\u4EAB\u7740\u8FD9\u4E2A\u63D2\u4EF6\u3002"})]}):jsxs5("ul",{children:[jsx5("li",{children:"\u5220\u6389\u672C\u5DE5\u574A\u4ED3\u5E93\u91CC\u8FD9\u4EFD\u6E90\u7801\uFF0C\u4F60\u5728\u91CC\u9762\u6539\u8FC7\u7684\u4EE3\u7801\u4E5F\u4E00\u8D77\u5220\u6389\uFF1B\u51E0\u4E2A\u63D2\u4EF6\u5171\u7528\u7684\u6587\u4EF6\u7559\u7740\u3002"}),jsx5("li",{children:"\u6539\u56DE\u5F15\u7528\uFF1A\u4EE5\u540E\u53D1\u5E03\u65B0\u7248\u65F6\uFF0C\u53D6\u5B83\u6240\u5C5E\u5DE5\u574A\u533A\u95F4\u91CC\u6700\u65B0\u7684\u517C\u5BB9\u7248\u672C\u3002"}),jsx5("li",{children:"\u5305\u540D\u4E0D\u53D8\uFF0C\u5DF2\u6709\u9879\u76EE\u91CC\u7684\u6570\u636E\u548C\u610F\u89C1\u4F4D\u7F6E\u7167\u5E38\u63A5\u5F97\u4E0A\u3002"}),jsx5("li",{children:"\u53EA\u63D0\u4EA4\u5230\u5DE5\u574A\u4ED3\u5E93\uFF0C\u4E0D\u53D1\u5E03\uFF1A\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u4E4B\u540E\u624D\u751F\u6548\u3002"})]}),error&&jsx5(SettingsSaveState,{failed:error})]})}var COPY_CHOICES=[{value:"ref",label:"\u5F15\u7528\uFF08\u9ED8\u8BA4\uFF09"},{value:"freeze",label:"\u51BB\u7ED3"},{value:"copy",label:"\u62F7\u6E90\u7801"}];function copyPluginsBody(plugins,choices){const out={};for(const p of plugins){const c=choices[p.name];if(!p.fixed&&c&&c!=="ref")out[p.name]=c}return Object.keys(out).length>0?out:void 0}function useCopyPlugins(ctx,source,reloadKey){const read=ctx.app.data.write?.copyPlugins;const[plugins,setPlugins]=useState3(null);const[loading,setLoading]=useState3(false);const[error,setError]=useState3(null);const[tick,setTick]=useState3(0);useEffect4(()=>{setPlugins(null)},[source]);useEffect4(()=>{if(!read||source===""){setPlugins([]);setLoading(false);setError(null);return}let live=true;setLoading(true);setError(null);read(source).then(r=>{if(!live)return;setPlugins(r.plugins);setLoading(false)},e=>{if(!live)return;setLoading(false);if(absent(e))setPlugins([]);else setError(failedBecause(e,"\u70B9\u91CD\u8BD5"))});return()=>{live=false}},[read,source,reloadKey,tick]);return{plugins,loading,error,retry:()=>setTick(n=>n+1)}}function CopyPluginChoices({plugins,error,retry,choices,onChange,disabled}){if(error)return jsxs5(ErrorNote2,{retry,children:["\u5171\u4EAB\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});if(!plugins||plugins.length===0)return null;return jsxs5("fieldset",{className:"band-workshops-copy-plugins",disabled,children:[jsx5("legend",{children:"\u539F\u5DE5\u574A\u5171\u4EAB\u7684\u63D2\u4EF6"}),jsx5("p",{className:"band-workshops-note",children:"\u5F15\u7528\uFF1A\u65B0\u5DE5\u574A\u6BCF\u6B21\u53D1\u5E03\u65F6\u53D6\u539F\u5DE5\u574A\u533A\u95F4\u91CC\u6700\u65B0\u7684\u517C\u5BB9\u7248\u672C\u3002\u51BB\u7ED3\uFF1A\u4E00\u76F4\u7528\u73B0\u5728\u8FD9\u4E00\u7248\u3002\u62F7\u6E90\u7801\uFF1A\u628A\u8FD9\u4E00\u7248\u6E90\u7801\u62F7\u8FDB\u65B0\u5DE5\u574A\uFF0C\u53D8\u6210\u65B0\u5DE5\u574A\u79C1\u6709\u3001\u53EF\u4EE5\u6539\uFF0C\u4E0D\u518D\u8DDF\u7740\u539F\u5DE5\u574A\u3002\u5EFA\u597D\u4E4B\u540E\u5728\u5DE5\u574A\u9875\u7684\u300C\u63D2\u4EF6\u300D\u5206\u9875\u8FD8\u80FD\u62C6\u51FA\u6216\u91CD\u65B0\u8DDF\u968F\u3002"}),jsx5("ul",{className:"band-workshops-copy-list",children:plugins.map(p=>jsxs5("li",{children:[jsxs5("span",{className:"band-workshops-plugin",children:[jsxs5("code",{children:[p.name,"@",p.version]}),p.fixed&&jsx5("span",{className:"band-workshops-copy-why",children:p.fixed.reason})]}),p.fixed?.action==="drop"?jsx5("span",{className:"band-workshops-copy-choices",children:"\u4E0D\u590D\u5236"}):jsx5("span",{className:"band-workshops-copy-choices",role:"radiogroup","aria-label":p.name,children:COPY_CHOICES.map(c=>{const checked=p.fixed?p.fixed.action===c.value:(choices[p.name]??"ref")===c.value;return jsxs5("label",{className:"choice sm",children:[jsx5("input",{type:"radio",className:"radio",name:`band-workshops-copy-${p.name}`,value:c.value,checked,disabled:p.fixed!==void 0,onChange:()=>onChange(p.name,c.value)}),c.label]},c.value)})})]},p.name))})]})}function copyBlocked(w){if(w.archivedAt!==void 0)return"\u5DE5\u574A\u5DF2\u5F52\u6863\uFF0C\u590D\u539F\u540E\u624D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";if(w.status==="provisioning")return"\u5DE5\u574A\u8FD8\u5728\u5EFA\uFF0C\u5EFA\u597D\u624D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";if(w.status==="failed")return"\u5DE5\u574A\u6CA1\u5EFA\u6210\uFF0C\u4E0D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA";return void 0}var WORKSHOP_ID=/^[a-z][a-z0-9-]{1,39}$/;function workshopIdProblems(id){if(WORKSHOP_ID.test(id))return id===OFFICIAL_SCOPE?["reserved"]:[];const problems=[];if(/[A-Z]/.test(id))problems.push("uppercase");if(/[^A-Za-z0-9-]/.test(id))problems.push("chars");if(/^[0-9-]/.test(id))problems.push("start");if(id.length<2)problems.push("short");if(id.length>40)problems.push("long");return problems}var ID_PROBLEM_TEXT={reserved:`\u300C${OFFICIAL_SCOPE}\u300D\u662F Band \u5B98\u65B9\u63D2\u4EF6\u7528\u7684\u540D\u5B57\uFF0C\u5DF2\u7ECF\u88AB\u5360\u4E86\uFF0C\u6362\u4E00\u4E2A`,uppercase:"\u4E0D\u80FD\u6709\u5927\u5199\u5B57\u6BCD\uFF0C\u90FD\u6539\u6210\u5C0F\u5199",chars:"\u53EA\u80FD\u7528\u82F1\u6587\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF08-\uFF09\uFF0C\u4E0D\u80FD\u6709\u7A7A\u683C\u3001\u4E0B\u5212\u7EBF\u6216\u4E2D\u6587",start:"\u8981\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u4E0D\u80FD\u662F\u6570\u5B57\u6216\u8FDE\u5B57\u7B26",short:"\u81F3\u5C11\u8981 2 \u4E2A\u5B57\u7B26",long:"\u6700\u591A 40 \u4E2A\u5B57\u7B26"};var WORKSHOP_YAML_EXAMPLE=`artifactTypes:
2
2
  draft: { label: \u521D\u7A3F }
3
3
  final: { label: \u5B9A\u7A3F }
4
4
 
@@ -21,4 +21,4 @@ workflows:
21
21
  needs: ['draft:draft']
22
22
  produces: final
23
23
  gate: { approveBy: [reviewer] }
24
- `;function WorkshopYamlExample({note}){const[said,setSaid]=useState8(null);const live=useRef3(true);useEffect8(()=>{live.current=true;return()=>{live.current=false}},[]);const copy=async()=>{try{await navigator.clipboard.writeText(WORKSHOP_YAML_EXAMPLE);if(live.current)setSaid("\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB\u5DE5\u574A\u4ED3\u5E93\u7684 band/workshop.yaml")}catch{if(live.current)setSaid("\u590D\u5236\u4E0D\u4E86\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u8FD9\u6BB5")}};return jsxs10("div",{className:"band-workshops-yaml",children:[jsxs10("div",{className:"band-workshops-yaml-head",children:[jsx10("span",{children:note}),jsx10("button",{type:"button",className:"btn sm",onClick:()=>void copy(),children:"\u590D\u5236"})]}),jsx10("pre",{className:"band-workshops-yaml-code",children:jsx10("code",{children:WORKSHOP_YAML_EXAMPLE})}),said&&jsx10("output",{className:"band-workshops-yaml-said","aria-live":"polite",children:said})]})}var FLOW_MAX=8e3;function NewWorkshop({ctx,from}){const{data:list}=useAppData2(ctx,d=>d.workshops(),[]);const[copySource,setCopySource]=useState8(from);const[pick,setPick]=useState8(null);const[name,setName]=useState8("");const[id,setId]=useState8("");const[flow,setFlow]=useState8("");const[busy,setBusy]=useState8(false);const[failed,setFailed]=useState8(null);const[pluginChoices,setPluginChoices]=useState8({});const[pluginsReload,setPluginsReload]=useState8(0);const create=ctx.app.data.write?.createWorkshop;const model=useModelDeployment(ctx);const flowOn=model.deployment?.workshopEdit===true&&!!ctx.app.data.write?.workshopEdit;const start=pick??(from||!flowOn?"copy":"describe");const source=start==="copy"?copySource:"";const picked=source!=="";const{data:src,error:srcError}=useAppData2(ctx,d=>source?d.workshop(source):Promise.resolve(null),[source]);const copyPlugins=useCopyPlugins(ctx,source,pluginsReload);const needsModelStep=!(picked&&src?.userModelKey==="require");const twoStep=!!model.deployment&&needsModelStep;const flowText=flow.trim();const flowTooLong=flowText.length>FLOW_MAX;const trimmed=name.trim();const idProblems=id===""?[]:workshopIdProblems(id);const idBad=idProblems.length>0;const blocked=picked&&src?copyBlocked(src):void 0;const sourceOk=!picked||!!src&&srcError===null&&blocked===void 0;const custom=picked&&src?customAgents(src):[];const missingFields=[...start==="describe"&&flowText===""?["\u4F60\u7684\u6D41\u7A0B"]:[],...start==="copy"&&!picked?["\u9009\u5DE5\u574A"]:[],...trimmed===""?["\u5DE5\u574A\u540D"]:[],...id===""?["\u77ED\u540D"]:[]];const pluginsBlocked=!picked||!sourceOk?null:copyPlugins.error!==null?"\u5171\u4EAB\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF0C\u70B9\u300C\u91CD\u8BD5\u300D\u518D\u8BFB":copyPlugins.loading||copyPlugins.plugins===null?"\u6B63\u5728\u8BFB\u53D6\u63D2\u4EF6\u5217\u8868\u2026":null;const canSubmit=!!create&&missingFields.length===0&&!idBad&&!busy&&sourceOk&&pluginsBlocked===null&&!(start==="describe"&&flowTooLong)&&model.deployment!==void 0;const sourceBlocked=!picked||sourceOk?null:blocked??(srcError!==null?"\u6765\u6E90\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF0C\u7A0D\u540E\u518D\u8BD5":src===null?`\u627E\u4E0D\u5230\u5DE5\u574A ${source}\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u7528\u5B83`:"\u6B63\u5728\u8BFB\u53D6\u6E90\u5DE5\u574A\u2026");const submitBlocked=busy||canSubmit?null:(sourceBlocked??pluginsBlocked)!==null?sourceBlocked??pluginsBlocked:missingFields.length>0?`\u8FD8\u5DEE${missingFields.join("\u3001")}\u6CA1\u586B`:null;const submit=async()=>{if(!create||!canSubmit)return;setBusy(true);setFailed(null);let created;const plugins=picked?copyPluginsBody(copyPlugins.plugins??[],pluginChoices):void 0;try{({id:created}=await create({id,name:trimmed,...picked?{copyFrom:source}:{},...start==="describe"?{firstMessage:flowText}:{},...plugins?{plugins}:{}}))}catch(e){setFailed(errorText3(e));setBusy(false);if(picked)setPluginsReload(n=>n+1);return}ctx.app.navigate({page:twoStep?`${SELF}/model`:`${SELF}/about`,params:{workshop:created}})};const back=()=>from?ctx.app.navigate({page:`${SELF}/about`,params:{workshop:from}}):ctx.app.navigate({page:`${SELF}/workshops`});const title=from&&src?`\u57FA\u4E8E\u300C${src.name}\u300D\u65B0\u5EFA\u5DE5\u574A`:"\u65B0\u5EFA\u5DE5\u574A";const sourceName=picked&&src?src.name:"";const startOptions=[...flowOn?[{value:"describe",label:"\u63CF\u8FF0\u6D41\u7A0B\uFF0C\u8BA9 Rondo \u8D77\u8349",line:"\u5199\u4E00\u53E5\u8BDD\uFF0C\u5EFA\u597D\u540E Rondo \u7167\u7740\u6539\u51FA\u7B2C\u4E00\u7248\u6D41\u7A0B\uFF0C\u4F60\u786E\u8BA4\u4E86\u518D\u53D1\u5E03"}]:[],{value:"copy",label:"\u57FA\u4E8E\u5DF2\u6709\u5DE5\u574A\u65B0\u5EFA",line:"\u9009\u4E00\u4E2A\u73B0\u6210\u7684\u5DE5\u574A\u5F53\u5E95\u7A3F\uFF0C\u6539\u6210\u81EA\u5DF1\u56E2\u961F\u7684"},{value:"blank",label:"\u7A7A\u767D\u5DE5\u574A",line:"\u53EA\u6709\u4E00\u4E2A\u9636\u6BB5\uFF0C\u8981\u81EA\u5DF1\u5199\u6D41\u7A0B\u3002\u9002\u5408\u5DF2\u7ECF\u4F1A\u5199 workshop.yaml \u7684\u4EBA"}];const sourceError=!picked?void 0:srcError?`\u6E90\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A${srcError}`:src===null?`\u627E\u4E0D\u5230\u5DE5\u574A ${source}\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u7528\u5B83\u3002`:blocked?`\u4E0D\u80FD\u57FA\u4E8E ${sourceName} \u65B0\u5EFA\uFF1A${blocked}\u3002`:void 0;const sourceHint=!picked?"\u9009\u4E00\u4E2A\u4F60\u80FD\u7528\u7684\u5DE5\u574A\uFF1B\u9009\u597D\u540E\u8FD9\u91CC\u5199\u6E05\u4F1A\u5E26\u8FC7\u6765\u4EC0\u4E48\u3002":src===void 0?"\u6B63\u5728\u8BFB\u53D6\u6E90\u5DE5\u574A\u2026":src&&!sourceError?`\u628A ${src.name} \u5F53\u524D\u53D1\u5E03\u7684\u7B2C ${src.version} \u7248\u5B9A\u4E49\u590D\u5236\u8FC7\u6765\u505A\u5E95\u7A3F\u3002\u4E4B\u540E\u4E24\u8FB9\u5404\u6539\u5404\u7684\uFF0C${src.name} \u518D\u53D1\u7248\u4E0D\u4F1A\u540C\u6B65\u8FC7\u6765${(copyPlugins.plugins??[]).length>0?"\uFF08\u4E0B\u9762\u9009\u300C\u5F15\u7528\u300D\u7684\u5171\u4EAB\u63D2\u4EF6\u9664\u5916\uFF09":""}\u3002\u5BC6\u94A5\u7684\u503C\u4E0D\u590D\u5236\uFF0C\u65B0\u5DE5\u574A\u58F0\u660E\u4E86\u5BC6\u94A5\u65F6\uFF0C\u8BF7\u5230\u65B0\u5DE5\u574A\u7684\u300C\u5DE5\u574A\u8BBE\u7F6E \xB7 \u5BC6\u94A5\u300D\u91CD\u65B0\u586B\u5199\u3002${custom.length>0?`\u5B83\u6709\u5B9A\u5236 agent ${custom.map(a=>a.name).join("\u3001")}\uFF1A\u6E90\u7801\u4E00\u8D77\u590D\u5236\uFF0C\u4F46\u4E0D\u5171\u7528 ${src.name} \u7684 AgentHub \u9879\u76EE\uFF0C\u7ED9\u65B0\u5DE5\u574A\u5EFA\u597D\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u3001\u914D\u597D\u5BC6\u94A5\u548C MCP \u51ED\u636E\u4E4B\u524D\uFF0C\u7528\u5B83\u4EEC\u7684\u9636\u6BB5\u5F00\u4E0D\u4E86\u5DE5\u3002`:""}`:void 0;return jsxs10("main",{className:"band-workshops-screen band-workshops-new",children:[jsx10(Crumb,{ctx,w:from?src:null,here:from?"\u57FA\u4E8E\u5B83\u65B0\u5EFA":"\u65B0\u5EFA\u5DE5\u574A"}),jsxs10("div",{className:"band-workshops-new-head",children:[twoStep&&jsx10(Steps,{current:1}),jsx10("h1",{className:"band-workshops-name",children:title}),jsx10("p",{className:"sub band-workshops-lede",children:picked&&sourceName?`\u4EE5 ${sourceName} \u73B0\u5728\u53D1\u5E03\u7684\u7248\u672C\u4E3A\u5E95\u7A3F\uFF0C\u5EFA\u597D\u540E\u4F60\u662F\u65B0\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3002${twoStep?"\u4E0B\u4E00\u6B65\u7ED9\u5B83\u914D\u4E0A\u6A21\u578B\u3002":""}`:`\u5EFA\u597D\u540E\u4F60\u662F\u5B83\u7684\u521B\u5EFA\u4EBA\u3002${twoStep?"\u4E0B\u4E00\u6B65\u7ED9\u8FD9\u4E2A\u5DE5\u574A\u914D\u4E0A\u6A21\u578B\uFF0C\u5B83\u624D\u80FD\u5F00\u5DE5\u3002":""}`})]}),create?jsxs10(SettingsForm,{label:title,onSubmit:()=>void submit(),children:[jsx10(SettingsPicks,{label:"\u4ECE\u54EA\u5F00\u59CB",value:start,options:startOptions,disabled:busy,onChange:v=>{setPick(v);setFailed(null)}}),start==="describe"&&jsx10(SettingsField,{label:"\u4F60\u7684\u6D41\u7A0B",required:true,hint:"Rondo \u7167\u8FD9\u53E5\u8BDD\u6539\u51FA\u7B2C\u4E00\u7248\u6D41\u7A0B\uFF0C\u5728\u300C\u6539\u5DE5\u574A\u300D\u9875\u7ED9\u4F60\u770B\u6539\u4E86\u4EC0\u4E48\uFF0C\u6EE1\u610F\u518D\u4FDD\u5B58\u53D1\u5E03\u3002",error:flowTooLong?`\u592A\u957F\u4E86\uFF0C\u6700\u591A ${FLOW_MAX} \u5B57\uFF08\u73B0\u5728 ${flowText.length}\uFF09\u3002`:void 0,count:`${flowText.length} / ${FLOW_MAX}`,over:flowTooLong,children:f=>jsx10("textarea",{...f,className:"field",rows:3,value:flow,disabled:busy,placeholder:"\u6BD4\u5982\uFF1A\u5148\u5199\u6559\u5B66\u8BBE\u8BA1\uFF0C\u518D\u505A\u8BFE\u4EF6\uFF0C\u6700\u540E\u7531\u6559\u7814\u7EC4\u957F\u5BA1\u6821",onChange:e=>setFlow(e.target.value)})}),start==="blank"&&jsxs10("div",{className:"band-workshops-new-help",children:[jsxs10("p",{children:["\u7A7A\u767D\u5DE5\u574A\u53EA\u6709\u4E00\u4E2A\u9636\u6BB5\uFF1ARondo \u7167\u4F60\u7684\u9700\u6C42\u505A\u4E00\u7248\uFF0C\u518D\u4EA4\u7ED9\u4F60\u6279\u51C6\u3002\u5EFA\u597D\u540E\u5728\u5DE5\u574A\u9875\u70B9\u300C\u8BA9 Rondo \u6539\u8FD9\u4E2A\u5DE5\u574A\u300D\u52A0\u9636\u6BB5\u3001\u89D2\u8272\u3001\u8C01\u6279\u51C6\uFF1B\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539\u5DE5\u574A\u4ED3\u5E93\u91CC\u7684"," ",jsx10("code",{children:"band/workshop.yaml"}),"\uFF0C\u518D\u56DE\u5DE5\u574A\u9875\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u3002"]}),jsxs10("details",{children:[jsx10("summary",{children:"\u770B\u4E00\u4EFD\u4E24\u9636\u6BB5\u7684 workshop.yaml \u4F8B\u5B50"}),jsxs10("p",{children:["\u5B57\u6BB5\u8BF4\u660E\u89C1"," ",jsx10("a",{href:"/docs/reference/workshop-yaml",target:"_blank",rel:"noreferrer",children:"\u6587\u6863\uFF1Aworkshop.yaml \u7684\u5B57\u6BB5"}),"\u3002"]}),jsx10(WorkshopYamlExample,{note:"\u4E24\u9636\u6BB5\u7684\u4F8B\u5B50\uFF1A\u5148\u751F\u6210\u521D\u7A3F\uFF0C\u6279\u51C6\u540E\u518D\u505A\u5B9A\u7A3F"})]})]}),start==="copy"&&jsxs10(Fragment9,{children:[jsx10(SettingsField,{label:"\u57FA\u4E8E\u54EA\u4E2A\u5DE5\u574A",required:true,hint:sourceHint,error:sourceError,children:f=>jsxs10("select",{...f,className:"field",value:copySource,disabled:busy,onChange:e=>{setCopySource(e.target.value);setPluginChoices({})},children:[jsx10("option",{value:"",disabled:true,children:"\u9009\u4E00\u4E2A\u5DE5\u574A"}),copySource&&!(list??[]).some(w=>w.id===copySource)&&jsx10("option",{value:copySource,children:src?.name??copySource}),(list??[]).map(w=>jsx10("option",{value:w.id,children:w.name},w.id))]})}),picked&&sourceOk&&jsx10(CopyPluginChoices,{plugins:copyPlugins.plugins,error:copyPlugins.error,retry:copyPlugins.retry,choices:pluginChoices,onChange:(n,choice)=>setPluginChoices(c=>({...c,[n]:choice})),disabled:busy})]}),jsx10(SettingsField,{label:"\u5DE5\u574A\u540D",required:true,children:f=>jsx10("input",{...f,className:"field",type:"text",value:name,maxLength:60,disabled:busy,placeholder:sourceName?`\u6BD4\u5982\uFF1A\u6211\u4EEC\u7EC4\u7684 ${sourceName}`:"\u6BD4\u5982\uFF1A\u4E09\u5E74\u7EA7\u6559\u5177",onChange:e=>setName(e.target.value)})}),jsx10(SettingsField,{label:"\u77ED\u540D",required:true,error:idBad?`${idProblems.map(p=>ID_PROBLEM_TEXT[p]).join("\uFF1B")}\u3002`:void 0,hint:"\u8FDB\u5730\u5740\u548C\u4ED3\u5E93\u540D\uFF1A\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF0C2\u201340 \u4F4D\u3002",children:f=>jsxs10("div",{className:"field-group field-host","data-invalid":idBad?"true":void 0,children:[jsx10("span",{className:"field-affix",children:"/w/"}),jsx10("input",{...f,className:"field bare",type:"text",value:id,maxLength:40,disabled:busy,spellCheck:false,autoCapitalize:"off",placeholder:"\u6BD4\u5982\uFF1Agrade3-tools",onChange:e=>setId(e.target.value.trim())})]})}),model.error&&jsxs10(ErrorNote6,{retry:model.reload,children:["\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",model.error]}),jsxs10(SettingsActions,{end:true,children:[jsx10("button",{type:"button",className:"btn ghost",onClick:back,disabled:busy,children:"\u53D6\u6D88"}),failed&&jsx10(SettingsSaveState3,{failed:`\u6CA1\u5EFA\u6210\uFF1A${failed}`}),jsx10(SettingsSaveState3,{...submitBlocked?{missing:submitBlocked}:{}}),jsx10("button",{type:"submit",className:"btn primary",disabled:!canSubmit,children:busy?"\u6B63\u5728\u65B0\u5EFA\u2026":twoStep?"\u65B0\u5EFA\uFF0C\u4E0B\u4E00\u6B65\u914D\u7F6E\u6A21\u578B":"\u65B0\u5EFA\u5DE5\u574A"})]})]}):jsx10("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u574A\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u7ED9\u8FD9\u4E2A\u6743\u9650\u3002"})]})}function directoryFor(people,searchUsers){if(people)return peopleDirectory(people);return{async search(q){const users=await searchUsers(q);return{orgs:[],people:users.map(u=>({id:u.id,name:u.displayName,inBand:true}))}}}}function openSecretsPage(ctx,workshop){ctx.app.navigate({page:`${SELF}/secrets`,params:{workshop}})}function goAbout2(ctx,id){ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}})}function SecretsSetup({ctx,id}){const{data:w,error,reload}=useAppData3(ctx,d=>d.workshop(id),[id]);const api=ctx.app.data.write?.workshopSecrets;if(error&&w===void 0)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx}),jsxs11(ErrorNote7,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(w===void 0)return jsx11("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsx11("span",{className:"band-workshops-sk is-block"})});if(w===null)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx}),jsxs11("p",{className:"band-workshops-note",children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id,"\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"]})]});const m=modelOf(w);if(!api||m.state==="not_provisioned")return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx11("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsx11("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u8FD9\u4E00\u6B65\uFF1A\u5B83\u4E0D\u8D70 Band \u7684 Agent \u4EE3\u5EFA\uFF0C\u5BC6\u94A5\u5728\u5B83\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u91CC\u7BA1\u3002"})]});if(!w.canAdmin)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx11("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsx11("div",{className:"band-workshops-callout",children:jsx11("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u586B\u5BC6\u94A5\u3002\u8981\u586B\u6216\u8981\u6362\uFF0C\u8BF7\u627E\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u3002"})}),jsx11("div",{className:"band-workshops-actions is-start",children:jsx11("button",{type:"button",className:"btn",onClick:()=>goAbout2(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A"})})]});return jsx11(SecretsPage,{ctx,w,api})}function SecretsPage({ctx,w,api}){const{data,error,reload}=useAppData3(ctx,()=>api.get(w.id),[api,w.id]);if(error!==null&&data===void 0)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsxs11(ErrorNote7,{retry:reload,children:["\u5BC6\u94A5\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(data===void 0)return jsxs11("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx11(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx11("span",{className:"band-workshops-sk is-block"})]});const m=modelOf(w);const blocked=m.hubProject!=="ready";return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsxs11("div",{children:[jsx11("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsxs11("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684 Agent \u8981\u7528\u7684\u5BC6\u94A5\u3002\u8FD9\u91CC\u586B\u7684\u503C Band \u4E0D\u4FDD\u5B58\uFF0C\u76F4\u63A5\u5199\u8FDB\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\uFF1B\u9875\u9762\u4E0A\u53EA\u770B\u5F97\u5230\u300C\u5DF2\u8BBE\u7F6E\u300D\u3002"]}),data.secrets.length>0&&jsx11("p",{className:"sub band-workshops-lede",children:"\u590D\u5236\u5DE5\u574A\u6216\u91CD\u65B0\u521B\u5EFA AgentHub \u9879\u76EE\u540E\uFF0C\u5BC6\u94A5\u9700\u8981\u91CD\u65B0\u586B\u5199\uFF0CBand \u6CA1\u6709\u53EF\u6062\u590D\u7684\u5907\u4EFD\u3002"})]}),data.secrets.length===0?jsxs11(Fragment10,{children:[jsx11("div",{className:"band-workshops-callout",children:jsx11("p",{children:"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u6CA1\u58F0\u660E\u8981\u7528\u5BC6\u94A5\uFF0C\u8FD9\u91CC\u6CA1\u6709\u8981\u586B\u7684\u3002"})}),jsxs11("p",{className:"band-workshops-note",children:["\u8981\u586B\u5BC6\u94A5\uFF0C\u5148\u5728\u5DE5\u574A\u4ED3\u5E93\u7684 ",jsx11("code",{children:"band/agent/agent.yaml"})," \u91CC\u5199 ",jsx11("code",{children:"secrets"}),"\uFF0C\u53D1\u5E03\u4E00\u7248\u4E4B\u540E\u8FD9\u91CC\u5C31\u4F1A\u51FA\u73B0\u3002"]})]}):jsxs11(Fragment10,{children:[m.hasRequest===false&&jsxs11("output",{className:"band-workshops-status",children:[jsx11("span",{className:"chip",children:"\u5F85\u914D\u7F6E\u6A21\u578B"}),"\u3000","\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0C\u4E5F\u6CA1\u6709\u4E1C\u897F\u5728\u6392\u961F\u3002\u5148\u914D\u597D\u6A21\u578B\uFF0CBand \u4F1A\u7ED9\u5B83\u5EFA AgentHub \u9879\u76EE\uFF0C\u4E4B\u540E\u5BC6\u94A5\u624D\u6709\u5730\u65B9\u5199\u3002",jsx11("button",{type:"button",className:"btn sm",onClick:()=>openModelPage(ctx,w.id),children:"\u914D\u7F6E\u6A21\u578B"})]}),m.hubProject==="pending"&&m.hasRequest!==false&&jsxs11("output",{className:"band-workshops-status",children:[jsx11("span",{className:"chip s-running",children:"\u6B63\u5728\u5EFA\u5DE5\u574A\u7684 AgentHub \u9879\u76EE"}),"\u3000","\u5EFA\u597D\u4E4B\u540E\u624D\u80FD\u4FDD\u5B58\uFF0C\u4E00\u822C\u4E0D\u5230\u4E00\u5206\u949F\uFF1B\u597D\u4E86\u8FD9\u4E00\u9875\u4F1A\u8DDF\u7740\u53D8\u3002"]}),m.hubProject==="failed"&&jsxs11("output",{className:"band-workshops-status",children:[jsx11("span",{className:"chip s-failed",children:"AgentHub \u9879\u76EE\u6CA1\u5EFA\u8D77\u6765"}),"\u3000",m.what??m.error??"\u539F\u56E0\u4E0D\u6E05\u695A","\u3002\u5EFA\u597D\u4E4B\u524D\u5B58\u4E0D\u4E86\u5BC6\u94A5\uFF0C\u5148\u56DE\u5DE5\u574A\u9875\u91CD\u8BD5\u4EE3\u5EFA\u3002"]}),jsx11("ul",{className:"band-workshops-secrets",children:data.secrets.map(s=>jsx11(SecretRow,{api,workshop:w.id,name:s.name,set:s.set,pending:s.pending===true,blocked,onSaved:reload},s.name))}),jsx11("div",{className:"band-workshops-callout",children:jsxs11("p",{children:[jsx11("b",{children:"\u503C\u53EA\u4EA4\u7ED9 AgentHub\u3002"}),"Band \u4E0D\u4FDD\u5B58\u5B83\uFF0C\u9875\u9762\u4E0A\u4E5F\u770B\u4E0D\u5230\u5DF2\u586B\u7684\u503C\u3002\u8981\u6362\u5C31\u91CD\u65B0\u586B\u4E00\u6B21\uFF0CAgentHub \u91CC\u90A3\u6761\u4F1A\u88AB\u539F\u5730\u6362\u503C\uFF1B\u8981\u505C\u7528\uFF0C\u53BB AgentHub \u95E8\u6237\u628A\u90A3\u6761\u5F52\u6863\u3002"]})})]})]})}function SecretRow({api,workshop,name,set,pending,blocked,onSaved}){const[open,setOpen]=useState9(false);const[value,setValue]=useState9("");const[phase,setPhase]=useState9({kind:"idle"});const input=useRef4(null);const id=useId4();const hintId=useId4();const saving=phase.kind==="saving";const save=async()=>{if(saving||blocked)return;if(value.trim()===""){setPhase({kind:"missing"});input.current?.focus();return}setPhase({kind:"saving"});try{await api.set(workshop,name,value);setValue("");setOpen(false);setPhase({kind:"idle"});onSaved()}catch(e){setValue("");setPhase({kind:"failed",message:errorText4(e)})}};return jsxs11("li",{className:"band-workshops-secret",children:[jsxs11("div",{className:"band-workshops-secret-line",children:[jsx11("code",{className:"band-workshops-secret-name",children:name}),set?jsx11("span",{className:"chip s-done",children:"\u5DF2\u8BBE\u7F6E"}):pending?jsx11("span",{className:"chip s-queued",children:"\u5DF2\u5199\u5165\uFF0C\u7B49 AgentHub \u751F\u6548"}):jsx11("span",{className:"chip s-stale",children:"\u672A\u8BBE\u7F6E"}),!open&&jsx11("button",{type:"button",className:set?"btn sm":"btn primary sm",disabled:blocked,title:blocked?"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58":void 0,onClick:()=>{setOpen(true);setPhase({kind:"idle"})},children:set?"\u66F4\u6362":"\u586B\u5199"})]}),open&&jsxs11("form",{className:"band-workshops-secret-form",onSubmit:e=>{e.preventDefault();void save()},children:[jsxs11("label",{className:"band-workshops-field",htmlFor:id,children:[jsxs11("span",{children:[name,jsx11("span",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx11("input",{id,ref:input,className:"field mono",type:"password",autoComplete:"off",spellCheck:false,placeholder:set?"\u7C98\u8D34\u65B0\u7684\u503C":"\u7C98\u8D34\u8FD9\u4E2A\u5BC6\u94A5\u7684\u503C",value,disabled:saving,onChange:e=>{setValue(e.target.value);if(phase.kind==="missing")setPhase({kind:"idle"})},"aria-invalid":phase.kind==="missing"?true:void 0,"aria-describedby":hintId}),jsx11("small",{id:hintId,className:phase.kind==="missing"?"band-workshops-err":"band-workshops-hint",children:phase.kind==="missing"?`\u8FD8\u5DEE ${name} \u7684\u503C\u6CA1\u586B`:set?"\u65B0\u503C\u5728\u65B0\u5EFA\u4F1A\u8BDD\u540E\u751F\u6548\uFF0C\u5DF2\u7ECF\u5728\u8DD1\u7684\u4F1A\u8BDD\u4ECD\u7528\u65E7\u503C\u3002":"\u8FD9\u4E2A\u503C Band \u4E0D\u4FDD\u5B58\uFF0C\u53EA\u5F80 AgentHub \u5199\u4E00\u6B21\u3002"})]}),phase.kind==="failed"&&jsxs11("p",{className:"band-workshops-why is-bad",role:"alert",children:["\u6CA1\u4FDD\u5B58\uFF1A",phase.message]}),jsxs11("div",{className:"band-workshops-actions",children:[jsx11("button",{type:"button",className:"btn ghost",disabled:saving,onClick:()=>{setOpen(false);setValue("");setPhase({kind:"idle"})},children:"\u53D6\u6D88"}),jsx11("button",{type:"submit",className:"btn primary",disabled:saving||blocked,title:blocked?"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58":void 0,children:saving?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"})]})]})]})}function TrialProjects({ctx,data,reload,onCreate,openProject}){const api=ctx.app.data.write?.trialProjects;const[target,setTarget]=useState10(null);const[open,setOpen]=useState10(false);const[busy,setBusy]=useState10(false);const[failed,setFailed]=useState10(null);const[forbidden,setForbidden]=useState10(false);const[ended,setEnded]=useState10(null);const modal=useModalDialog({open,blocked:busy,onRequestClose:()=>setOpen(false)});if(!api||!data.canManage||forbidden)return jsx12("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u7BA1\u7406\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\u3002"});const end=async()=>{if(!target||busy)return;setBusy(true);setFailed(null);try{await api.end(target.id);setEnded(target.name);setOpen(false);reload()}catch(e){if(isForbidden4(e)){setForbidden(true);setOpen(false);reload()}else setFailed(errorText5(e))}finally{setBusy(false)}};return jsxs12(Fragment11,{children:[jsx12("h2",{children:"\u8BD5\u7528\u9879\u76EE"}),jsx12("p",{className:"band-workshops-note",children:"\u7528 test \u69FD\u9A8C\u8BC1\u5DE5\u574A\u7684\u4E0B\u4E00\u7248\uFF0C\u8BD5\u7528\u9879\u76EE\u4F1A\u8DDF\u968F\u8FD9\u4E2A\u69FD\u66F4\u65B0\u3002\u666E\u901A\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u5DF2\u6709\u6B63\u5F0F\u9879\u76EE\u4E0D\u80FD\u6539\u6210\u8BD5\u7528\u3002"}),data.createBlocked?jsxs12("p",{className:"band-workshops-note",children:["\u6682\u65F6\u4E0D\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF1A",data.createBlocked]}):jsx12("button",{type:"button",className:"btn",onClick:onCreate,children:"\u7528 test \u69FD\u5F00\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE"}),jsx12("h3",{children:"\u4F60\u53EF\u8BBF\u95EE\u7684\u8BD5\u7528\u9879\u76EE"}),jsx12("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u53EA\u5217\u4F60\u5DF2\u6709\u8BFB\u53D6\u6743\u9650\u7684\u9879\u76EE\u3002\u5176\u4ED6\u4EBA\u521B\u5EFA\u7684\u79C1\u6709\u9879\u76EE\uFF0C\u8BF7\u5148\u8BA9\u9879\u76EE\u6210\u5458\u628A\u4F60\u52A0\u5165\u3002"}),ended&&jsxs12("output",{children:["\u5DF2\u7ED3\u675F\u300C",ended,"\u300D\u7684\u8BD5\u7528\uFF0C\u8FD9\u4E2A\u9879\u76EE\u5DF2\u53D8\u4E3A\u6B63\u5F0F\u9879\u76EE\u3002"]}),data.projects.length===0?jsxs12("p",{className:"band-workshops-note",children:["\u4F60\u53EF\u8BBF\u95EE\u7684\u9879\u76EE\u4E2D\u8FD8\u6CA1\u6709\u8BD5\u7528\u9879\u76EE\u3002",data.createBlocked?"\u5148\u6309\u4E0A\u9762\u7684\u63D0\u793A\u8BA9\u5DE5\u574A\u51C6\u5907\u597D\u3002":"\u70B9\u300C\u7528 test \u69FD\u5F00\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE\u300D\u5F00\u59CB\u9A8C\u8BC1\u3002"]}):jsx12("ul",{className:"band-workshops-trials",children:data.projects.map(p=>jsxs12("li",{children:[jsx12("button",{type:"button",className:"band-workshops-link",onClick:()=>openProject(p.id),children:p.name}),jsx12("span",{className:"chip plain",children:"\u8BD5\u7528\u9879\u76EE \xB7 test \u69FD"}),jsx12("button",{type:"button",className:"btn sm",ref:target?.id===p.id?modal.trigger:void 0,onClick:()=>{setFailed(null);setTarget(p);setOpen(true)},children:"\u7ED3\u675F\u8BD5\u7528"})]},p.id))}),jsx12("dialog",{ref:modal.dialog,"aria-labelledby":"band-trial-end-title",className:"band-workshops-publish-dialog","data-band-layer":open?"dialog":void 0,onCancel:e=>{e.preventDefault();if(!busy)setOpen(false)},children:jsxs12("div",{className:"band-workshops-publish-body",children:[jsxs12("h2",{id:"band-trial-end-title",className:"band-workshops-publish-title",children:["\u7ED3\u675F\u300C",target?.name,"\u300D\u7684\u8BD5\u7528\uFF1F"]}),jsx12("p",{children:"\u8FD9\u4E2A\u9879\u76EE\u4F1A\u53D8\u4E3A\u6B63\u5F0F\u9879\u76EE\uFF0C\u4E0D\u80FD\u518D\u6539\u56DE\u8BD5\u7528\u3002\u540E\u7EED\u56DE\u5408\u6309\u6B63\u5F0F\u9879\u76EE\u7684\u89C4\u5219\u4F7F\u7528 Agent \u7248\u672C\uFF1B\u5DF2\u7ECF\u6D3E\u51FA\u7684\u56DE\u5408\u4F1A\u7EE7\u7EED\u8DD1\u5B8C\uFF0C\u5DF2\u6709\u5185\u5BB9\u4FDD\u7559\u3002"}),jsx12("p",{children:"\u8FD9\u4E0D\u4F1A\u628A\u5DE5\u574A\u7684 test \u69FD\u4E0A\u7EBF\u5230 production \u69FD\u3002"}),failed&&jsxs12(ErrorNote8,{children:["\u6CA1\u7ED3\u675F\u8BD5\u7528\uFF1A",failed,"\u3002\u53EF\u4EE5\u518D\u70B9\u300C\u786E\u5B9A\u7ED3\u675F\u8BD5\u7528\u300D\u3002"]}),jsxs12("div",{className:"band-workshops-actions",children:[jsx12("button",{type:"button",className:"btn ghost",disabled:busy,onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),jsx12("button",{type:"button",className:"btn primary",disabled:busy,onClick:()=>void end(),children:busy?"\u6B63\u5728\u7ED3\u675F\u8BD5\u7528\u2026":"\u786E\u5B9A\u7ED3\u675F\u8BD5\u7528"})]})]})})]})}var WORKSHOP_LEVELS=[{value:"members",label:"\u53EA\u6709\u5DE5\u574A\u7684\u4EBA",hint:"\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3001\u7BA1\u7406\u5458\u548C\u6210\u5458\u80FD\u770B\u5230\u5B83\u3001\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002"},{value:"users",label:"\u5DE5\u574A\u7684\u4EBA\u548C\u6307\u5B9A\u7684\u4EBA",hint:"\u4E0B\u9762\u540D\u5355\u91CC\u7684\u4EBA\u4E5F\u80FD\u770B\u5230\u8FD9\u4E2A\u5DE5\u574A\u3001\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002"},{value:"everyone",label:"\u516C\u53F8\u5185\u6240\u6709\u4EBA",hint:"\u51FA\u73B0\u5728\u6240\u6709\u4EBA\u7684\u5DE5\u574A\u5217\u8868\u91CC\uFF0C\u8C01\u90FD\u80FD\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3001\u590D\u5236\u5B83\u3002"}];var MISSING="missing";function fromCache(people,cache){return people.map(p=>{const cached=cache.get(p.id);const chain=p.chain??(cached&&cached!==MISSING?cached:void 0);return chain?{...p,chain}:{...p}})}var VIEWERS_MAX=200;function WorkshopVisibilityTab({api,directory,workshop}){const[loaded,setLoaded]=useState11(null);const[canManage,setCanManage]=useState11(false);const[level,setLevel]=useState11("members");const[viewers,setViewersRaw]=useState11([]);const[error,setError]=useState11(null);const[saved,setSaved]=useState11(false);const[busy,setBusy]=useState11(false);const[reload,setReload]=useState11(0);const groupId=useId5();const cache=useRef5(new Map);const noOrg=useRef5(false);const[filled,setFilled]=useState11(false);const filling=useRef5(0);const putViewers=next=>setViewersRaw(cur=>fromCache(typeof next==="function"?next(cur):next,cache.current));function remember(people){for(const p of people)if(p.chain)cache.current.set(p.id,p.chain)}async function fillChains(people){const seq=++filling.current;remember(people);const need=people.filter(p=>!cache.current.has(p.id)).map(p=>p.id);if(need.length>0&&directory.resolve){try{const r=await directory.resolve(need,{signal:new AbortController().signal});if(r.fallback!==void 0)noOrg.current=true;remember(r.people);for(const id of need)if(!cache.current.has(id))cache.current.set(id,MISSING)}catch{}}if(seq!==filling.current)return;putViewers(cur=>cur);setFilled(true)}useEffect9(()=>{let active=true;setError(null);void api.get(workshop).then(v=>{if(!active)return;const people=v.viewers??[];setLoaded({visibility:v.visibility,viewers:people});setLevel(v.visibility);putViewers(people);void fillChains(people);setCanManage(v.canManage)}).catch(e=>{if(active)setError(`\u53EF\u89C1\u8303\u56F4\u6CA1\u8BFB\u51FA\u6765\uFF1A${errorText6(e)}`)});return()=>{active=false}},[api,workshop,reload]);const changed=loaded!==null&&(level!==loaded.visibility||level==="users"&&viewers.map(p=>p.id).join("\n")!==loaded.viewers.map(p=>p.id).join("\n"));async function save(){if(busy)return;if(level==="users"&&viewers.length===0)return setError("\u8FD8\u5DEE\u540D\u5355\uFF1A\u9009\u300C\u5DE5\u574A\u7684\u4EBA\u548C\u6307\u5B9A\u7684\u4EBA\u300D\u65F6\u81F3\u5C11\u52A0\u4E00\u4E2A\u4EBA");setBusy(true);setError(null);setSaved(false);try{const v=await api.set(workshop,level==="users"?{visibility:level,viewers:viewers.map(p=>p.id)}:{visibility:level});remember(viewers);const people=fromCache(v.viewers??[],cache.current);setLoaded({visibility:v.visibility,viewers:people});setLevel(v.visibility);putViewers(people);void fillChains(people);setCanManage(v.canManage);setSaved(true)}catch(e){setError(`\u6CA1\u6709\u4FDD\u5B58\uFF1A${errorText6(e)}`)}finally{setBusy(false)}}return jsxs13("section",{className:"band-workshops-visibility","aria-label":"\u8C01\u80FD\u770B",children:[jsx13("h2",{id:groupId,children:"\u8C01\u80FD\u770B\u8FD9\u4E2A\u5DE5\u574A"}),loaded===null?jsx13(ErrorNote9,{retry:()=>setReload(n=>n+1),children:error}):error&&jsx13("div",{role:"alert",children:jsx13(ErrorNote9,{children:error})}),loaded===null?!error&&jsx13("p",{children:"\u6B63\u5728\u8BFB\u53D6\u53EF\u89C1\u8303\u56F4\u2026"}):jsxs13(Fragment12,{children:[jsx13("div",{className:"band-workshops-levels",role:"radiogroup","aria-labelledby":groupId,children:WORKSHOP_LEVELS.map(l=>jsxs13("label",{className:"band-workshops-level",children:[jsx13("input",{type:"radio",className:"radio",name:`${groupId}-level`,value:l.value,checked:level===l.value,disabled:!canManage||busy,onChange:()=>{setLevel(l.value);setSaved(false);setError(null)}}),jsxs13("span",{children:[jsx13("b",{children:l.label}),jsx13("span",{children:l.hint})]})]},l.value))}),level==="users"&&(canManage?jsx13(ViewerList,{people:viewers,busy,directory,noChain:filled&&!noOrg.current?viewers.filter(p=>!p.chain).length:0,onLearn:people=>{remember(people);putViewers(cur=>cur)},onChange:next=>{remember(next);putViewers(next);setSaved(false);setError(null)}}):jsx13("p",{children:"\u540D\u5355\u53EA\u6709\u5DE5\u574A\u7BA1\u7406\u5458\u770B\u5F97\u5230\u3002"})),jsx13("p",{children:"\u5DE5\u574A\u7684\u8303\u56F4\u4E0D\u7BA1\u9879\u76EE\uFF1A\u6BCF\u4E2A\u9879\u76EE\u5404\u81EA\u8BBE\u7F6E\u8C01\u80FD\u770B\uFF0C\u7F3A\u7701\u53EA\u6709\u9879\u76EE\u6210\u5458\u3002"}),jsx13("p",{children:"\u6539\u4E86\u7ACB\u5373\u751F\u6548\uFF1A\u4E0D\u5728\u8303\u56F4\u91CC\u7684\u4EBA\u4E0B\u4E00\u6B21\u6253\u5F00\u6216\u5237\u65B0\u5C31\u770B\u4E0D\u5230\u8FD9\u4E2A\u5DE5\u574A\u4E86\u3002"}),canManage?jsx13("button",{type:"button",className:"btn primary",disabled:busy||!changed,onClick:()=>void save(),children:busy?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"}):jsx13("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u53EF\u4EE5\u4FEE\u6539\u3002"}),saved&&jsx13("output",{children:"\u5DF2\u4FDD\u5B58"})]})]})}function ViewerList({people,busy,directory,noChain,onLearn,onChange}){return jsxs13("div",{className:"band-workshops-viewers",children:[jsxs13("span",{className:"band-workshops-viewers-label",children:["\u6307\u5B9A\u7684\u4EBA ",jsxs13("span",{className:"band-workshops-hint",children:["\u5FC5\u586B\uFF0C\u6700\u591A ",VIEWERS_MAX," \u4EBA"]})]}),noChain>0&&jsxs13("p",{className:"band-workshops-hint",children:["\u540D\u5355\u91CC\u6709 ",noChain," ","\u4EBA\u7684\u90E8\u95E8\u6CA1\u67E5\u5230\uFF1A\u52FE\u6574\u4E2A\u90E8\u95E8\u3001\u53D6\u6D88\u6574\u4E2A\u90E8\u95E8\u90FD\u4E0D\u7B97\u4ED6\u4EEC\uFF0C\u8981\u79FB\u51FA\u8BF7\u5728\u540D\u5355\u91CC\u9010\u4E2A\u70B9\u300C\u79FB\u51FA\u300D\u3002"]}),jsx13(PersonPicker,{label:"\u6307\u5B9A\u7684\u4EBA",directory,value:people.map(p=>({id:p.id,name:p.displayName,...p.chain?{chain:p.chain}:{}})),onChange:next=>onChange(next.map(p=>({id:p.id,displayName:p.name,...p.chain?{chain:p.chain}:{}}))),max:VIEWERS_MAX,allowUnknown:true,busy,onLearn,emptyText:"\u8FD8\u6CA1\u6709\u4EBA\uFF0C\u4ECE\u4E0B\u9762\u641C\u4EBA\u6216\u6309\u90E8\u95E8\u52A0"})]})}var splitLines=s=>s===null||s===""?[]:s.replace(/\n$/,"").split("\n");var DIFF_MAX_LINES=800;function lineDiff(before,after){const a=splitLines(before);const b=splitLines(after);if(a.length>DIFF_MAX_LINES||b.length>DIFF_MAX_LINES)return[...a.map(text=>({kind:"del",text})),...b.map(text=>({kind:"add",text}))];const n=a.length;const m=b.length;const lcs=Array.from({length:n+1},()=>new Uint16Array(m+1));for(let i2=n-1;i2>=0;i2--){const row=lcs[i2];const below=lcs[i2+1];for(let j2=m-1;j2>=0;j2--)row[j2]=a[i2]===b[j2]?(below[j2+1]??0)+1:Math.max(below[j2]??0,row[j2+1]??0)}const out=[];let i=0;let j=0;while(i<n&&j<m){if(a[i]===b[j]){out.push({kind:"same",text:a[i]});i++;j++}else if((lcs[i+1]?.[j]??0)>=(lcs[i]?.[j+1]??0))out.push({kind:"del",text:a[i++]});else out.push({kind:"add",text:b[j++]})}while(i<n)out.push({kind:"del",text:a[i++]});while(j<m)out.push({kind:"add",text:b[j++]});return out}function foldDiff(lines,context=2){const keep=lines.map(()=>false);lines.forEach((l,i2)=>{if(l.kind==="same")return;for(let k=Math.max(0,i2-context);k<=Math.min(lines.length-1,i2+context);k++)keep[k]=true});const out=[];let i=0;while(i<lines.length){if(keep[i]){const run=[];while(i<lines.length&&keep[i])run.push(lines[i++]);out.push({kind:"lines",lines:run})}else{let count=0;while(i<lines.length&&!keep[i]){count++;i++}out.push({kind:"fold",count})}}return out}var changeWord={added:"\u65B0\u589E",modified:"\u6539\u4E86",deleted:"\u5220\u6389"};function agentFileTitle(f){const rest=f.path.replace(/^band\/agent\//,"");switch(f.kind){case"instructions":return"Agent \u603B\u8BF4\u660E";case"stage":return`\u9636\u6BB5\u8BF4\u660E\uFF1A${rest.replace(/^stages\//,"").replace(/\.md$/,"")}`;case"skill":return`\u6280\u80FD\uFF1A${rest.replace(/^skills\//,"")}`;case"declaration":return"Agent \u7684\u5BC6\u94A5\u58F0\u660E";default:return rest}}var omittedText={binary:"\u8FD9\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u6CA1\u6CD5\u9010\u884C\u5BF9\u6BD4\u3002",too_large:"\u6587\u4EF6\u592A\u5927\uFF0C\u6CA1\u6CD5\u9010\u884C\u5BF9\u6BD4\u3002",too_many:"\u6539\u7684\u6587\u4EF6\u592A\u591A\uFF0C\u8FD9\u91CC\u53EA\u5217\u51FA\u6587\u4EF6\u540D\u3002"};function agentChangeCount(state){return(state?.changes.agentPlugins.length??0)+(state?.changes.agentFiles?.length??0)}function pluginChangeText(c){const who=c.agent==="rondo"?"":`\u300C${c.agent}\u300D`;if(c.before===null)return`${who}\u52A0\u4E86\u63D2\u4EF6 ${c.plugin}\uFF08\u7248\u672C ${c.after}\uFF09`;if(c.after===null)return`${who}\u53BB\u6389\u4E86\u63D2\u4EF6 ${c.plugin}`;return`${who}\u63D2\u4EF6 ${c.plugin} \u7684\u7248\u672C\u4ECE ${c.before} \u6539\u6210 ${c.after}`}function FileDiff({file}){const blocks=file.omitted?[]:foldDiff(lineDiff(file.before,file.after));return jsxs14("article",{className:"band-workshop-edit-file",children:[jsxs14("h4",{children:[jsx14("span",{className:"band-workshop-edit-mark",children:changeWord[file.change]}),agentFileTitle(file)]}),file.omitted?jsx14("p",{className:"band-workshops-note",children:omittedText[file.omitted]}):blocks.length===0?jsx14("p",{className:"band-workshops-note",children:"\u5185\u5BB9\u662F\u7A7A\u7684\u3002"}):jsx14("pre",{className:"band-workshop-edit-lines","aria-label":`${agentFileTitle(file)}\u7684\u6587\u5B57\u6539\u52A8`,children:blocks.map((b,bi)=>b.kind==="fold"?jsxs14("span",{className:"band-workshop-edit-fold",children:["\u2026 ",b.count," \u884C\u6CA1\u53D8"]},`f${bi}`):b.lines.map((l,li)=>jsxs14("span",{className:"band-workshop-edit-line","data-kind":l.kind,children:[jsx14("span",{className:"band-workshop-edit-sign","aria-hidden":"true",children:l.kind==="add"?"\uFF0B":l.kind==="del"?"\uFF0D":"\u3000"}),jsx14("span",{className:"sr-only",children:l.kind==="add"?"\u52A0\u7684\uFF1A":l.kind==="del"?"\u5220\u7684\uFF1A":""}),l.text||" "]},`${bi}/${li}`)))})]})}function AgentChanges({state}){const plugins=state.changes.agentPlugins;const files=state.changes.agentFiles??[];const n=plugins.length+files.length;return jsx14("div",{className:"band-workshop-edit-agent","aria-label":"Agent \u7684\u6539\u52A8",children:n===0?jsx14("p",{className:"band-workshops-note",children:state.agentEditable?"\u8FD8\u6CA1\u6709 Agent \u4FEE\u6539\u3002\u8DDF Rondo \u8BF4 Agent \u8981\u600E\u4E48\u505A\u4E8B\uFF0C\u4F8B\u5982\uFF1A\u5BA1\u6821\u9636\u6BB5\u5148\u5BF9\u7167\u8BFE\u6807\u518D\u7ED9\u610F\u89C1\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u4E0D\u6539 Agent\u3002"}):jsxs14(Fragment13,{children:[jsxs14("h3",{children:[n," \u5904 Agent \u4FEE\u6539"]}),plugins.length>0&&jsxs14(Fragment13,{children:[jsx14("ul",{className:"band-workshop-edit-changes",children:plugins.map(c=>jsx14("li",{children:pluginChangeText(c)},`${c.agent}/${c.plugin}`))}),jsx14("p",{className:"band-workshops-note",children:"\u4FDD\u5B58\u540E\u4F1A\u91CD\u65B0\u51C6\u5907 Agent\uFF0C\u7EA6\u51E0\u5206\u949F\uFF1B\u8FD9\u671F\u95F4\u65B0\u5EFA\u9879\u76EE\u8981\u7B49\u5B83\u51C6\u5907\u597D\uFF0C\u5DF2\u6709\u9879\u76EE\u7684\u4E0B\u4E00\u56DE\u5408\u4E5F\u4F1A\u7528\u65B0\u63D2\u4EF6\u3002Band \u5199\u8FDB Agent \u4ED3\u5E93\u7684\u90A3\u51E0\u4E2A\u6587\u4EF6\uFF08\u63D2\u4EF6\u6E05\u5355\u3001\u8BF4\u660E\u3001\u5B9A\u4E49\uFF09\u91CC\u7684\u624B\u6539\u4F1A\u88AB\u76D6\u6389\u3002"})]}),files.map(f=>jsx14(FileDiff,{file:f},f.path))]})})}function readableFailure(e){const reason=errorText7(e).trim();return e?.code==="CONFLICT"&&!reason?"\u73B0\u5728\u4E0D\u80FD\u8BD5\uFF0C\u5237\u65B0\u540E\u518D\u770B\u770B":reason}var TICKET_RETRY_MS=[2e3,5e3,15e3];var TICKET_RECOVER_MS=3e4;var TICKET_FAIL_ROUNDS=2;var TICKET_SOON_MS=3e4;var MAX_RENEW_MS=10*6e4;var MAX_TIMEOUT_MS=2147483647;function roundOf(state,commit){const done=(state.session?.turns??[]).filter(t=>t.status==="committed"&&t.commit);const i=done.findIndex(t=>t.commit===commit);return i<0?"\u6700\u65B0\u4E00\u4EFD\u4FEE\u6539":`\u7B2C ${i+1} \u8F6E`}function Status({chip,tone,text}){return jsxs15("p",{className:"band-workshop-trial-status",children:[jsx15("span",{className:tone?`chip ${tone}`:"chip",children:chip}),jsx15("span",{children:text})]})}var TRIAL_DESKTOP_W=1e3;function ScaledFrame({src,title}){const[box,setBox]=useState12(null);const[size,setSize]=useState12({w:0,h:0});useEffect10(()=>{if(!box||typeof ResizeObserver==="undefined")return;const watch=new ResizeObserver(([entry])=>setSize({w:Math.round(entry?.contentRect.width??0),h:Math.round(entry?.contentRect.height??0)}));watch.observe(box);return()=>watch.disconnect()},[box]);const scale=size.w>0&&size.w<TRIAL_DESKTOP_W?size.w/TRIAL_DESKTOP_W:1;return jsx15("div",{className:"band-workshop-trial-screen",ref:setBox,children:jsx15("iframe",{src,title,...scale<1?{style:{width:TRIAL_DESKTOP_W,height:size.h/scale,transform:`scale(${scale})`,transformOrigin:"0 0"},"data-scaled":scale.toFixed(2)}:{}})})}function Loading({text}){return jsxs15("output",{className:"band-workshop-trial-rest tuning",children:[jsxs15("svg",{viewBox:"0 0 80 55","aria-hidden":"true",children:[jsx15("line",{x1:"0",y1:"12",x2:"80",y2:"12"}),jsx15("line",{x1:"0",y1:"22",x2:"80",y2:"22"}),jsx15("line",{x1:"0",y1:"32",x2:"80",y2:"32"}),jsx15("line",{x1:"0",y1:"42",x2:"80",y2:"42"}),jsx15("line",{x1:"0",y1:"52",x2:"80",y2:"52"}),jsx15("circle",{cx:"20",cy:"37",r:"4.6",fill:"var(--ink)"}),jsx15("circle",{cx:"40",cy:"27",r:"4.6",fill:"var(--accent)"}),jsx15("circle",{cx:"60",cy:"17",r:"4.6",fill:"var(--ink)"})]}),jsx15("span",{children:text})]})}function Rest({title,children}){return jsxs15("div",{className:"band-workshop-trial-rest rest",children:[jsx15("i",{}),jsx15("b",{children:title}),children]})}function TrialTab({ctx,id,state,own,holder,trials,trialsError,reloadTrials,projectPage,agentPreparing,workshopName,ended,onRestart,onRefresh}){const api=ctx.app.data.write?.workshopEdit;const session=state.session?.id;const[picked,setPicked]=useState12("");const[draft,setDraft]=useState12(emptyDraft);const[failed,setFailed]=useState12(null);const livePreview=own?state.livePreview:void 0;const[ticket,setTicket]=useState12(null);const wantTicket=!!session&&livePreview?.status==="live"&&!!api?.previewTicket;useEffect10(()=>{if(!wantTicket||!session||!api?.previewTicket){setTicket(null);return}const fetchTicket=api.previewTicket;let alive=true;let timer;let expiry;let attempt=0;let rounds=0;const get=()=>{fetchTicket(id,session).then(t=>{if(!alive)return;attempt=0;rounds=0;setTicket(prev=>prev&&prev.session===session&&"entry"in prev?{...prev,open:t.url}:{session,entry:t.url,open:t.url});const left=Date.parse(t.expiresAt)-Date.now();if(expiry)clearTimeout(expiry);if(Number.isFinite(left)&&left>TICKET_SOON_MS)expiry=setTimeout(()=>setTicket({session,failed:true}),Math.min(left,MAX_TIMEOUT_MS));timer=setTimeout(get,Number.isFinite(left)&&left>TICKET_SOON_MS?Math.min(Math.max(15e3,left/2),MAX_RENEW_MS):6e4)},()=>{if(!alive)return;const wait=TICKET_RETRY_MS[attempt++];if(wait!==void 0){timer=setTimeout(get,wait);return}rounds+=1;setTicket(prev=>prev&&"entry"in prev&&rounds<TICKET_FAIL_ROUNDS?prev:{session,failed:true});attempt=0;timer=setTimeout(get,TICKET_RECOVER_MS)})};get();return()=>{alive=false;if(timer)clearTimeout(timer);if(expiry)clearTimeout(expiry)}},[api,id,session,wantTicket]);const mine=ticket?.session===session?ticket:null;const ticketUrl=mine&&"entry"in mine?mine.entry:null;const ticketOpenUrl=mine&&"entry"in mine?mine.open:null;const ticketFailed=mine!==null&&"failed"in mine;const liveBroken=livePreview?.status==="live"&&(!api?.previewTicket||ticketFailed);const pickId=useId6();const[name,setName]=useState12(`${workshopName} \xB7 \u8BD5\u7528`);const[creating,setCreating]=useState12(false);const[createFailed,setCreateFailed]=useState12(null);const create=async()=>{const write=ctx.app.data.write?.trialProjects;if(!write||creating||!name.trim())return;setCreating(true);setCreateFailed(null);try{const{id:created}=await write.create({workshop:id,name:name.trim()});setPicked(created);reloadTrials()}catch(e){setCreateFailed(errorText7(e))}finally{setCreating(false)}};if(ended)return jsxs15(Rest,{title:"\u7F16\u8F91\u5DF2\u7ED3\u675F",children:[jsx15("span",{children:"30 \u5206\u949F\u6CA1\u6709\u52A8\u9759\uFF0C\u6216\u8005\u6709\u4EBA\u70B9\u4E86\u7ED3\u675F\uFF0C\u8FD9\u6B21\u7F16\u8F91\u5DF2\u7ECF\u7ED3\u675F\uFF0C\u9884\u89C8\u4E5F\u5173\u4E86\u3002\u5DF2\u7ECF\u901A\u8FC7\u68C0\u67E5\u7684\u4FEE\u6539\u90FD\u8FD8\u5728\uFF0C\u91CD\u65B0\u5F00\u59CB\u5C31\u80FD\u63A5\u7740\u6539\u3001\u63A5\u7740\u8BD5\u3002"}),jsx15("button",{type:"button",className:"btn primary",onClick:onRestart,children:"\u91CD\u65B0\u5F00\u59CB"})]});if(agentPreparing)return jsx15(Rest,{title:"Agent \u51C6\u5907\u597D\u4E4B\u540E\u5C31\u80FD\u8BD5",children:jsx15("span",{children:"\u5DE5\u574A\u7684 Agent \u8FD8\u5728\u51C6\u5907\uFF0C\u901A\u5E38\u51E0\u5206\u949F\u3002\u597D\u4E86\u4EE5\u540E\u8FD9\u91CC\u81EA\u52A8\u51FA\u73B0\u8BD5\u7528\u9879\u76EE\u548C\u9884\u89C8\uFF0C\u4E0D\u7528\u5237\u65B0\u3002"})});if(trialsError)return jsxs15(ErrorNote10,{retry:reloadTrials,children:["\u8BD5\u7528\u9879\u76EE\u6CA1\u8BFB\u51FA\u6765\uFF1A",trialsError]});if(trials===void 0)return jsx15(Loading,{text:"\u6B63\u5728\u8BFB\u53D6\u8BD5\u7528\u9879\u76EE"});if(own&&trials&&!trials.canManage)return jsx15(Rest,{title:"\u53EA\u6709\u5DE5\u574A\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u80FD\u8BD5\u7528",children:jsx15("span",{children:"\u4F60\u80FD\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u4F46\u8BD5\u7528\u9879\u76EE\u5F52\u5DE5\u574A\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u7BA1\u3002\u4FDD\u5B58\u5E76\u53D1\u5E03\u4E4B\u540E\uFF0C\u53EF\u4EE5\u5728\u65B0\u9879\u76EE\u91CC\u7528\u4E0A\u8FD9\u4E9B\u4FEE\u6539\u3002"})});const projects=trials?.projects??[];if(!projects.length)return own?jsxs15(Rest,{title:"\u8FD8\u6CA1\u6709\u8BD5\u7528\u9879\u76EE",children:[jsx15("span",{children:"\u4FDD\u5B58\u4E4B\u524D\uFF0C\u5728\u8BD5\u7528\u9879\u76EE\u91CC\u770B\u6539\u540E\u7684\u6D41\u7A0B\u548C\u89C6\u56FE\uFF0C\u5E76\u7528\u5B83\u8DD1\u4E00\u56DE\u5408\u3002\u6B63\u5F0F\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\u3002"}),trials?.createBlocked?jsxs15("span",{children:["\u6682\u65F6\u4E0D\u80FD\u5EFA\uFF1A",trials.createBlocked]}):jsxs15("form",{className:"band-workshop-trial-create",onSubmit:e=>{e.preventDefault();void create()},children:[jsx15("label",{htmlFor:`${pickId}-name`,className:"sr-only",children:"\u8BD5\u7528\u9879\u76EE\u540D"}),jsx15("input",{id:`${pickId}-name`,className:"field",value:name,maxLength:80,onChange:e=>setName(e.target.value)}),jsx15("button",{type:"submit",className:"btn primary",disabled:creating||!name.trim(),children:creating?"\u6B63\u5728\u5EFA\u2026":"\u5EFA\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE"})]}),createFailed&&jsxs15(ErrorNote10,{children:["\u6CA1\u5EFA\u6210\uFF1A",createFailed]})]}):jsx15(Rest,{title:"\u8FD8\u6CA1\u6709\u80FD\u770B\u7684\u8BD5\u7528\u9879\u76EE",children:jsxs15("span",{children:[holder??"\u5BF9\u65B9"," \u5EFA\u4E86\u8BD5\u7528\u9879\u76EE\u5E76\u628A\u4F60\u52A0\u8FDB\u53BB\u4E4B\u540E\uFF0C\u8FD9\u91CC\u80FD\u770B\u5230\u6700\u65B0\u4E00\u8F6E\u7684\u9884\u89C8\u3002"]})});const project=projects.find(p=>p.id===picked)??projects[0];if(!project)return null;const preview=state.preview;const shown=state.readyPreview??(preview?.status==="ready"&&preview.hash?{commit:preview.commit,hash:preview.hash}:null);const frame=ticketUrl?{kind:"live",url:ticketUrl,open:ticketOpenUrl??ticketUrl}:shown?{kind:"snapshot",...shown}:{kind:"none"};const shownRound=shown?roundOf(state,shown.commit):"";const latest=preview?.status==="ready"&&preview.commit===state.head;const showingLatest=latest&&shown?.commit===preview?.commit;let status;if(!own)status=jsx15(Status,{chip:"\u53EA\u8BFB",text:`${holder??"\u522B\u4EBA"} \u6B63\u5728\u6539\uFF0C\u4F60\u53EA\u80FD\u770B${shown?`${shownRound}\u4E4B\u540E\u7684\u9884\u89C8`:"\u6700\u65B0\u4E00\u8F6E\u7684\u9884\u89C8"}`});else if(frame.kind==="live")status=jsx15(Status,{chip:"\u5B9E\u65F6\u9884\u89C8",tone:"s-done",text:"\u6539\u52A8\u9A6C\u4E0A\u663E\u793A\u5728\u8FD9\u91CC\uFF1B\u7528\u7684\u662F\u793A\u4F8B\u6570\u636E"});else if(preview?.status==="failed")status=jsx15(Status,{chip:"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7",tone:"s-failed",text:shown?`\u663E\u793A\u7684\u662F${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`:"\u4FEE\u597D\u4E4B\u540E\u8FD9\u91CC\u663E\u793A\u9884\u89C8"});else if(livePreview?.status==="snapshot"||liveBroken)status=jsx15(Status,{chip:"\u4E0A\u4E00\u8F6E\u7684\u9884\u89C8",text:`\u5B9E\u65F6\u9884\u89C8\u6682\u65F6\u4E0D\u53EF\u7528\uFF1A${livePreview?.status==="snapshot"?livePreview.reason:!api?.previewTicket?"\u8FD9\u4E2A\u9875\u9762\u8FD8\u4E0D\u652F\u6301\u5B9E\u65F6\u9884\u89C8\uFF0C\u5148\u663E\u793A\u5FEB\u7167":"\u5165\u573A\u5730\u5740\u6CA1\u53D6\u5230\u6216\u5DF2\u8FC7\u671F\uFF0C\u5148\u663E\u793A\u5FEB\u7167"}`});else if(preview?.status==="building")status=jsx15(Status,{chip:"\u6B63\u5728\u51C6\u5907\u65B0\u4E00\u8F6E\u7684\u9884\u89C8",tone:"s-running",text:shown?`\u5148\u663E\u793A${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`:"\u901A\u5E38\u4E00\u5206\u949F\u5DE6\u53F3"});else if(livePreview?.status==="preparing"||livePreview?.status==="live")status=jsx15(Status,{chip:livePreview.status==="preparing"?"\u6B63\u5728\u51C6\u5907\u5B9E\u65F6\u9884\u89C8":"\u6B63\u5728\u6253\u5F00\u5B9E\u65F6\u9884\u89C8",tone:"s-running",text:livePreview.status==="live"?"\u9A6C\u4E0A\u597D":shown?`\u7EA6\u51E0\u5206\u949F\uFF0C\u5148\u663E\u793A${shownRound}\u4E4B\u540E\u7684\u9884\u89C8`:"\u7EA6\u51E0\u5206\u949F"});else if(showingLatest)status=jsx15(Status,{chip:"\u6700\u65B0",tone:"s-done",text:`\u73B0\u5728\u770B\u7684\u662F${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`});else status=jsx15(Status,{chip:"\u7B49\u5F85\u9884\u89C8",text:"\u4E0B\u4E00\u8F6E\u6539\u5B8C\u3001\u901A\u8FC7\u68C0\u67E5\u540E\uFF0C\u8FD9\u91CC\u663E\u793A\u6539\u540E\u7684\u6837\u5B50"});const src=frame.kind==="live"?frame.url:frame.kind==="snapshot"?`/w/${encodeURIComponent(id)}/${encodeURIComponent(project.id)}?preview=${encodeURIComponent(frame.hash)}`:null;const open=()=>{if(frame.kind==="live"){window.open(frame.open,"_blank","noopener");return}if(src)window.location.assign(src)};const run=own?state.trial??null:null;const running2=run?.status==="running";const tryWhy=!api?.trial?"\u8FD9\u4E2A\u9875\u9762\u8FD8\u4E0D\u80FD\u8BD5\u8DD1":!latest?preview?.status==="failed"?"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7\uFF0C\u4FEE\u597D\u4E4B\u540E\u624D\u80FD\u8BD5":preview?.status==="building"?"\u65B0\u4E00\u8F6E\u7684\u9884\u89C8\u51C6\u5907\u597D\u4E4B\u540E\u624D\u80FD\u8BD5":"\u4E0B\u4E00\u8F6E\u6539\u5B8C\u3001\u901A\u8FC7\u68C0\u67E5\u540E\u624D\u80FD\u8BD5":running2?"\u8FD9\u4E00\u6B21\u8DD1\u5B8C\u4E4B\u540E\u624D\u80FD\u518D\u8BD5":void 0;const pluginNote=state.pluginTrial!==true&&state.changes.agentPlugins.length?"\u63D2\u4EF6\u7684\u6539\u52A8\u4FDD\u5B58\u540E\u624D\u4F1A\u7528\u4E0A\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\u3002":null;return jsxs15("div",{className:"band-workshop-trial",children:[jsxs15("div",{className:"band-workshop-trial-bar",children:[jsxs15("div",{className:"band-workshop-trial-head",children:[status,jsx15("p",{className:"band-workshop-trial-meta",children:"\u8FD9\u662F\u8BD5\u7528\u9879\u76EE\uFF0C\u5728\u8FD9\u91CC\u5199\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u8BD5\u7528\u9879\u76EE\u91CC"})]}),jsxs15("div",{className:"band-workshop-trial-pick",children:[jsx15("label",{htmlFor:pickId,children:"\u8BD5\u7528\u9879\u76EE"}),jsx15("select",{id:pickId,className:"select",value:project.id,onChange:e=>setPicked(e.target.value),children:projects.map(p=>jsx15("option",{value:p.id,children:p.name},p.id))})]})]}),src?jsxs15("div",{className:"band-workshop-trial-frame",children:[jsx15(ScaledFrame,{src,title:`${project.name} \u7684\u9884\u89C8`},src),jsx15("button",{type:"button",className:"btn ghost sm band-workshop-trial-wide",onClick:open,children:"\u5728\u6574\u9875\u6253\u5F00"}),jsx15("button",{type:"button",className:"btn sm band-workshop-trial-narrow",onClick:open,children:"\u6253\u5F00\u9884\u89C8"})]}):preview?.status==="building"?jsx15(Loading,{text:"\u6B63\u5728\u51C6\u5907\u9884\u89C8"}):jsx15(Rest,{title:"\u8FD8\u6CA1\u6709\u9884\u89C8",children:jsx15("span",{children:"\u8DDF Rondo \u8BF4\u4E00\u53E5\uFF0C\u6539\u5B8C\u901A\u8FC7\u68C0\u67E5\u540E\uFF0C\u8FD9\u91CC\u663E\u793A\u6539\u540E\u7684\u6837\u5B50\u3002"})}),own&&jsxs15("section",{className:"band-workshop-trial-try","aria-labelledby":`${pickId}-try`,children:[jsx15("h3",{id:`${pickId}-try`,className:"band-workshop-trial-caption",children:"\u7528\u6539\u540E\u7684\u5B9A\u4E49\u8BD5\u4E00\u6B21"}),run&&jsx15(TrialRunCard,{run,round:roundOf(state,run.commit),pluginTrial:state.pluginTrial===true,ctx,id,projectPage}),failed&&jsxs15(ErrorNote10,{children:["\u6CA1\u8BD5\u6210\uFF1A",failed]}),jsx15(PromptInput,{draft,onDraft:setDraft,variant:"prompt",label:"\u5199\u4E00\u53E5\u9879\u76EE\u9700\u6C42",placeholder:"\u5199\u4E00\u53E5\u9879\u76EE\u9700\u6C42\uFF0C\u4F8B\u5982\uFF1A\u7ED9\u4E09\u5E74\u7EA7\u505A\u4E00\u8282\u5206\u6570\u5BFC\u5165\u8BFE",submitText:"\u8BD5\u4E00\u6B21",submitLabel:"\u8BD5\u4E00\u6B21",busy:!!tryWhy,notice:tryWhy??pluginNote??void 0,hint:`\u5728\u300C${project.name}\u300D\u91CC\u65B0\u8D77\u4E00\u4E2A\u6D41\u7A0B\uFF0C\u6B63\u5F0F\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD`,onSubmit:async d=>{const hash=preview?.hash;if(!api?.trial||!session||!hash||tryWhy)return false;setFailed(null);try{await api.trial(id,session,{projectId:project.id,previewHash:hash,message:d.text.trim()});await onRefresh();return true}catch(e){setFailed(readableFailure(e));return false}}})]})]})}function TrialRunCard({ctx,id,run,round,projectPage,pluginTrial}){const pluginsPending=run.pluginsPending===true;const chip=run.status==="failed"?{text:"\u56DE\u5408\u5931\u8D25",tone:"s-failed"}:pluginsPending?{text:"\u6CA1\u5E26\u4E0A\u63D2\u4EF6\u6539\u52A8",tone:""}:run.status==="running"?{text:"\u56DE\u5408\u8FDB\u884C\u4E2D",tone:"s-running"}:{text:"\u5DF2\u8DD1\u5B8C",tone:"s-done"};return jsxs15("article",{className:"band-workshop-trial-run",children:[jsxs15("header",{children:[jsxs15("b",{children:["\u8BD5\u4E00\u6B21 \xB7 ",round,"\u4E4B\u540E\u7684\u5B9A\u4E49"]}),jsx15("span",{className:chip.tone?`chip ${chip.tone}`:"chip",children:chip.text})]}),pluginsPending&&jsx15("p",{children:pluginTrial?"\u63D2\u4EF6\u7684\u6539\u52A8\u8FD8\u5728\u51C6\u5907\uFF08\u7EA6\u51E0\u5206\u949F\uFF09\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\uFF1B\u6D41\u7A0B\u3001\u8BF4\u660E\u3001skill \u548C\u89C6\u56FE\u90FD\u662F\u6539\u540E\u7684\u3002\u51C6\u5907\u597D\u4E4B\u540E\u518D\u8BD5\u4E00\u6B21\u5C31\u4F1A\u5E26\u4E0A\u3002":"\u63D2\u4EF6\u7684\u6539\u52A8\u4FDD\u5B58\u540E\u624D\u4F1A\u7528\u4E0A\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\uFF1B\u6D41\u7A0B\u3001\u8BF4\u660E\u3001skill \u548C\u89C6\u56FE\u90FD\u662F\u6539\u540E\u7684\u3002"}),jsxs15("p",{className:"band-workshop-trial-meta",children:["\u5728\u300C",run.projectName,"\u300D\u91CC\u65B0\u8D77\u4E86\u4E00\u4E2A\u6D41\u7A0B",run.status==="running"?"\uFF0C\u56DE\u5408\u8FDB\u884C\u4E2D":""]}),projectPage&&jsx15("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:projectPage,params:{workshop:id,project:run.projectId}}),children:"\u6253\u5F00\u8FD9\u4E2A\u6D41\u7A0B"})]})}var TRIAL_UNFOLDED_MIN=400+28+24+TRIAL_DESKTOP_W;var readable=text=>text.replace(/默认分支|分支|Revision|槽位/g,"\u5B9A\u4E49").replace(/提交/g,"\u8BB0\u5F55");var running=t=>["queued","running","validating"].includes(t.status);var codeOf=e=>e?.code;var missing=e=>["NOT_FOUND","FORBIDDEN"].includes(codeOf(e)??"");var EDIT_STATE_POLL_MS=2e3;function editStatePollMs(state){return state?.livePreview?.status==="preparing"?LIVE_PREVIEW_POLL_MS.starting:EDIT_STATE_POLL_MS}function editBlocked(state){switch(state.blocked?.code){case"builtin":return"\u8FD9\u4E2A\u5DE5\u574A\u662F\u5E73\u53F0\u81EA\u5E26\u7684\uFF0C\u5148\u590D\u5236\u4E00\u4EFD\u518D\u6539\u3002";case"model_key":return"\u8FD9\u4E2A\u5DE5\u574A\u8981\u7528\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u4F60\u8FD8\u6CA1\u914D\u3002";case"not_ready":return"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\u3002";case"provision":return`\u5DE5\u574A\u7684 Agent \u6CA1\u51C6\u5907\u597D\uFF1A${readable(state.blocked.message)}`;case"not_band_repo":return"\u8FD9\u4E2A\u5DE5\u574A\u6682\u65F6\u4E0D\u80FD\u5728\u754C\u9762\u4E0A\u6539\uFF0C\u8BF7\u590D\u5236\u4E00\u4EFD\u518D\u6539\u3002";case"ref_mismatch":return"\u5DE5\u574A\u7684\u6765\u6E90\u8BBE\u7F6E\u9700\u8981\u7BA1\u7406\u5458\u8C03\u6574\uFF0C\u6682\u65F6\u4E0D\u80FD\u5728\u8FD9\u91CC\u6539\u3002";case"unsupported_files":return"\u5DE5\u574A\u91CC\u6709\u4E0D\u652F\u6301\u7684\u6587\u4EF6\uFF0C\u8BF7\u5728\u5DE5\u574A\u4ED3\u5E93\u4E2D\u5904\u7406\u540E\u518D\u6539\u3002";case"disabled":return"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002";case"forbidden":return"\u4F60\u6CA1\u6709\u6539\u8FD9\u4E2A\u5DE5\u574A\u7684\u6743\u9650\u3002";case"first_message_pending":return"\u521B\u5EFA\u4EBA\u65B0\u5EFA\u65F6\u5199\u7684\u6D41\u7A0B\u63CF\u8FF0\u8FD8\u6CA1\u53D1\u51FA\uFF0C\u7B49\u521B\u5EFA\u4EBA\u5148\u5F00\u59CB\u3002";case"locked":return`${state.session?.holder.name??"\u5176\u4ED6\u4EBA"} \u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A`;default:return void 0}}function UnsupportedFiles({state}){const files=state.changes.unsupportedFiles;if(!files?.length)return null;return jsx16("ul",{className:"band-workshop-edit-issues","aria-label":"\u4E0D\u652F\u6301\u7684\u6587\u4EF6",children:files.map(file=>jsxs16("li",{children:[jsx16("code",{children:file.path}),"\uFF1A",file.message]},file.path))})}function WorkshopEditEntry({ctx,w}){const api=ctx.app.data.write?.workshopEdit;const[state,setState]=useState13(null);const[error,setError]=useState13(null);const load=useCallback4(()=>{if(!api||!w.canAdmin)return;let alive=true;api.get(w.id).then(s=>{if(alive){setState(s);setError(null)}},e=>{if(alive){setState(null);setError(missing(e)?null:`\u6539\u5DE5\u574A\u7684\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause5(e,"\u70B9\u91CD\u8BD5"))}`)}});return()=>{alive=false}},[api,w]);useEffect11(()=>load(),[load]);if(!api||!w.canAdmin||state?.blocked?.code==="disabled"||state?.blocked?.code==="forbidden")return null;if(!state)return error?jsx16(ErrorNote11,{retry:load,children:error}):null;const locked=state.blocked?.code==="locked";const why=editBlocked(state);return jsxs16("div",{className:"band-workshop-edit-entry",children:[jsx16("button",{type:"button",className:"btn",disabled:!!why&&!locked,title:why,onClick:()=>{ctx.app.navigate({page:`${SELF}/edit`,params:{workshop:w.id}})},children:locked?`\u770B ${state.session?.holder.name??"\u5BF9\u65B9"} \u6B63\u5728\u6539\u7684\u5185\u5BB9`:"\u8BA9 Rondo \u6539\u8FD9\u4E2A\u5DE5\u574A"}),why&&jsx16("small",{className:"band-workshops-hint",children:why}),jsx16(UnsupportedFiles,{state}),state.blocked?.code==="model_key"&&jsx16("button",{className:"btn ghost sm",type:"button",onClick:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/models"}),children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"}),!state.agentEditable&&!why&&jsx16("small",{className:"band-workshops-hint",children:"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u53EA\u80FD\u6539\u6D41\u7A0B\u548C\u89C6\u56FE\uFF1BAgent \u7684\u8BF4\u660E\u3001\u6280\u80FD\u548C\u63D2\u4EF6\u7167\u65E7\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u6539\u3002"})]})}var CHANGE_LABEL={added:"\u65B0\u589E",modified:"\u6539\u4E86",deleted:"\u5220\u6389"};function viewFileGroups(files){const groups=new Map;for(const file of files){const parts=file.path.split("/");const plugin=parts.length>3?parts[2]??"":"";const list=groups.get(plugin);if(list)list.push(file);else groups.set(plugin,[file])}return[...groups.entries()].sort(([a],[b])=>a.localeCompare(b)).map(([plugin,list])=>({plugin:plugin||"\u5171\u4EAB\u6587\u4EF6",files:list}))}function flowChangeRows(diff,roles=[],artifactTypes=[]){if(!diff)return[];const roleName=(name,side)=>diff.roles.find(r=>r.role===name)?.label[side]??roles.find(r=>r.name===name)?.label??name;const value=(v,side)=>v===null?"\u65E0":Array.isArray(v)?v.map(x=>side?roleName(x,side):x).join("\u3001")||"\u65E0":v;const fieldNames={label:"\u540D\u5B57",kind:"\u7531\u8C01\u6765\u505A",agent:"Agent",needs:"\u524D\u9762\u7684\u6B65\u9AA4",produces:"\u4EA7\u7269",approveBy:"\u6279\u51C6\u4EBA",confirmBy:"\u786E\u8BA4\u4EBA"};const types=[...artifactTypes].sort((a,b)=>a.name.localeCompare(b.name));const needsValue=(v,side,workflow)=>{if(v===null)return"\u65E0";return(Array.isArray(v)?v:[v]).map(need=>{const partial=need.endsWith("#partial");const[stage="",type]=need.replace(/#partial$/,"").split(":");const stages=diff.workflows[workflow]?.[side]??[];const index=stages.findIndex(s=>s.id===stage);const name=stageDisplayName(stage,stages[index]?.label,index);const typeIndex=types.findIndex(t=>t.name===type);return`${name}${type?` \xB7 ${artifactTypeDisplayName(type,types[typeIndex]?.label,typeIndex)}`:""}${partial?"\uFF08\u90E8\u5206\uFF09":""}`}).join("\u3001")||"\u65E0"};return[...diff.stages.flatMap(s=>{const key=`${s.workflow}/${s.stage}`;if(s.change!=="changed")return[{key,workflow:s.workflow,stage:s.stage,text:`${s.change==="added"?"\u65B0\u589E":"\u5220\u6389"}\u9636\u6BB5\u300C${s.label}\u300D`}];const who=s.fields.filter(f=>f.field==="approveBy"||f.field==="confirmBy");const other=s.fields.filter(f=>f.field!=="approveBy"&&f.field!=="confirmBy");return[...other.length?[{key,workflow:s.workflow,stage:s.stage,text:`\u6539\u4E86\u9636\u6BB5\u300C${s.label}\u300D\uFF1A${other.map(f=>`${fieldNames[f.field]}\u4ECE\u300C${f.field==="needs"?needsValue(f.before,"before",s.workflow):value(f.before)}\u300D\u6539\u6210\u300C${f.field==="needs"?needsValue(f.after,"after",s.workflow):value(f.after)}\u300D`).join("\uFF1B")}`}]:[],...who.map(f=>({key:`${key}/${f.field}`,workflow:s.workflow,stage:s.stage,text:`\u300C${s.label}\u300D\u7684${fieldNames[f.field]}\u4ECE\u300C${value(f.before,"before")}\u300D\u6539\u6210\u300C${value(f.after,"after")}\u300D`}))]}),...diff.roles.map(r=>({key:`role/${r.role}`,text:`${r.change==="added"?"\u65B0\u589E":r.change==="removed"?"\u5220\u6389":"\u6539\u4E86"}\u89D2\u8272\u300C${r.label.after??r.label.before??r.role}\u300D`}))]}function matchesReleasedFiles(state){return!!state.head&&!!state.released?.commit&&state.changes.files.length===0&&!state.changes.unsupportedFiles?.length&&state.changes.flow?.planChanged===false&&(!state.saveBlocked||state.saveBlocked.code==="no_changes")}function FlowComparison({state,w,rows,paramsFiles,listedBelow}){const agentCount=agentChangeCount(state);const[side,setSide]=useState13("after");const[highlight,setHighlight]=useState13(null);const root=useRef6(null);const flow=state.changes.flow;const count=rows.length+paramsFiles.length;const roles=[...w.roles];for(const r of flow?.roles??[]){if(!roles.some(x=>x.name===r.role))roles.push({name:r.role,label:r.label.after??r.label.before??r.role,permissions:[]})}const snapshot=s=>({...s,kind:s.kind==="agent"||s.kind==="human"||s.kind==="external"?s.kind:"human",needs:s.needs.map(need=>need.replace(/#partial$/,"")),produces:[]});return jsxs16("div",{ref:root,children:[count?jsxs16(Fragment15,{children:[jsxs16("h3",{children:["\u6D41\u7A0B ",count," \u5904"]}),jsxs16("ul",{className:"band-workshop-edit-changes",children:[rows.map(r=>jsx16("li",{children:jsx16("button",{type:"button",onClick:()=>{if(!r.stage)return;const target=`${r.workflow}/${r.stage}`;setHighlight(target);const isRemoved=flow?.stages.some(s=>s.workflow===r.workflow&&s.stage===r.stage&&s.change==="removed");setSide(isRemoved?"before":"after");requestAnimationFrame(()=>{const el=Array.from(root.current?.querySelectorAll("[data-edit-stage]")??[]).find(e=>e.dataset.editStage===target&&e.closest("[data-side]")?.dataset.side===(isRemoved?"before":"after"));if(el){scrollIntoPanel(el);el.focus({preventScroll:true})}})},children:r.text})},r.key)),paramsFiles.map(f=>jsxs16("li",{className:"band-workshop-edit-file-row",children:[CHANGE_LABEL[f.change],"\u9636\u6BB5\u53C2\u6570 ",jsx16("code",{children:f.path})]},f.path))]}),jsx16("p",{className:"band-workshops-note",children:"\u65B0\u9879\u76EE\u7528\u65B0\u7248\uFF1B\u5DF2\u6709\u9879\u76EE\u7684\u66F4\u65B0\u60C5\u51B5\u4F1A\u5728\u53D1\u5E03\u540E\u9010\u9879\u5217\u51FA\u3002"})]}):jsx16("p",{className:"band-workshops-note",children:matchesReleasedFiles(state)?"\u4E0E\u4E0A\u6B21\u53D1\u5E03\u7684\u5185\u5BB9\u76F8\u540C\uFF0C\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\u3002":flow?state.ahead>0?listedBelow?"\u8FD9\u6B21\u6CA1\u6709\u6D41\u7A0B\u4FEE\u6539\uFF0CAgent \u7684\u4FEE\u6539\u5728\u4E0B\u9762\u3002":"\u5F53\u524D\u4FEE\u6539\u4E0D\u6D89\u53CA\u6D41\u7A0B\u3002\u8BF7\u5148\u5230\u5DE5\u574A\u4ED3\u5E93\u67E5\u770B\u5B8C\u6574\u6539\u52A8\uFF0C\u518D\u4FDD\u5B58\u5E76\u53D1\u5E03\u3002":"\u8FD8\u6CA1\u6709\u6D41\u7A0B\u4FEE\u6539\u3002\u8DDF Rondo \u8BF4\u8981\u6539\u4EC0\u4E48\uFF0C\u6539\u52A8\u4F1A\u5217\u5728\u8FD9\u91CC\u3002":"\u6D41\u7A0B\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u5148\u5904\u7406\u68C0\u67E5\u63D0\u793A\u3002"}),jsx16("div",{className:"band-workshop-edit-compare-switch seg","aria-label":"\u5BF9\u6BD4\u7248\u672C",hidden:!rows.length,children:["before","after"].map(s=>jsx16("button",{type:"button","aria-pressed":side===s,onClick:()=>setSide(s),children:s==="before"?"\u6539\u524D":"\u6539\u540E"},s))}),Object.entries(flow?.workflows??{}).map(([workflow,snapshots])=>jsx16("div",{className:"band-workshop-edit-comparison","data-show":side,"data-empty":rows.length===0?"true":void 0,children:["before","after"].map(s=>jsxs16("section",{"data-side":s,"aria-label":s==="before"?"\u6539\u524D\u7684\u6D41\u7A0B":"\u6539\u540E\u7684\u6D41\u7A0B",children:[jsx16("h4",{children:s==="before"?state.released?`\u6539\u524D\uFF1A\u5DF2\u53D1\u5E03\u7684 v${state.released.seq}`:"\u6539\u524D\uFF1A\u8FD8\u6CA1\u53D1\u5E03\u8FC7":rows.length===0&&state.released?`\u73B0\u5728\u7684\u6D41\u7A0B\uFF08v${state.released.seq}\uFF09`:"\u6539\u540E\uFF1A\u8FD8\u6CA1\u4FDD\u5B58"}),jsx16(FlowBig,{stages:snapshots[s].map(snapshot),peers:["rondo"],roles,story:{loops:{}},executorKnown:false,approvalText:Object.fromEntries(snapshots[s].map(stage=>[stage.id,stage.approveBy.length?`\u6279\u51C6\uFF1A${stage.approveBy.map(role=>flow?.roles.find(r=>r.role===role)?.label[s]??roles.find(r=>r.name===role)?.label??role).join("\u3001")}`:"\u4E0D\u8BBE\u95E8\u7981"])),decorations:Object.fromEntries((flow?.stages??[]).filter(c=>c.workflow===workflow).map(c=>[c.stage,{tag:c.change==="added"&&s==="after"?"\u65B0\u589E":c.change==="removed"&&s==="before"?"\u5220\u6389":c.change==="changed"&&s==="after"?"\u6539\u4E86":void 0,removed:c.change==="removed"&&s==="before",highlight:highlight===`${workflow}/${c.stage}`,key:`${workflow}/${c.stage}`}]))}),jsxs16("div",{className:"band-workshop-edit-roles",children:[jsx16("b",{children:"\u89D2\u8272"}),roles.filter(r=>{const c=flow?.roles.find(c2=>c2.role===r.name);return!(s==="before"&&c?.change==="added")&&!(s==="after"&&c?.change==="removed")}).map(r=>jsx16("span",{children:flow?.roles.find(c=>c.role===r.name)?.label[s]??r.label??r.name},r.name))]})]},s))},workflow))]})}function PreviewOpen({ctx,id,hash,projectPage}){const labelId=useId7();const trials=useAppData4(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const mine=useAppData4(ctx,d=>typeof d.projects==="function"?d.projects({workshop:id}):Promise.resolve([]),[id]);const[picked,setPicked]=useState13("");if(!projectPage)return null;if(trials.data===void 0&&mine.data===void 0)return null;const seen=new Set;const entries=[];for(const source of[...(trials.data?.projects??[]).map(p=>({id:p.id,name:p.name,trial:true})),...(mine.data??[]).filter(p=>!p.project.archivedAt).map(p=>({id:p.project.id,name:p.project.name,trial:false}))]){if(seen.has(source.id))continue;seen.add(source.id);entries.push(source)}const current=entries.some(o=>o.id===picked)?picked:entries[0]?.id??"";return jsx16("div",{className:"band-workshop-edit-preview",children:mine.error?jsxs16(ErrorNote11,{retry:mine.reload,children:["\u9879\u76EE\u6CA1\u8BFB\u51FA\u6765\uFF1A",readable(mine.error)]}):!entries.length?jsx16("p",{className:"band-workshops-note",children:"\u8FD8\u6CA1\u6709\u80FD\u6253\u5F00\u9884\u89C8\u7684\u9879\u76EE\uFF1A\u5148\u5230\u5DE5\u574A\u8BBE\u7F6E\u7684\u300C\u8BD5\u7528\u9879\u76EE\u300D\u5F00\u4E00\u4E2A\uFF0C\u6216\u5EFA\u4E00\u4E2A\u9879\u76EE\uFF0C\u518D\u56DE\u6765\u5728\u9884\u89C8\u91CC\u770B\u3002"}):jsxs16(Fragment15,{children:[jsxs16("div",{className:"band-workshop-edit-preview-open field-host",children:[jsx16("label",{htmlFor:labelId,className:"band-workshop-edit-preview-label",children:"\u5728\u9884\u89C8\u91CC\u770B"}),jsxs16("select",{id:labelId,className:"field bare",value:current,onChange:e=>setPicked(e.target.value),children:[entries.some(o=>o.trial)&&jsx16("optgroup",{label:"\u8BD5\u7528\u9879\u76EE",children:entries.filter(o=>o.trial).map(o=>jsx16("option",{value:o.id,children:o.name},o.id))}),entries.some(o=>!o.trial)&&jsx16("optgroup",{label:"\u6211\u7684\u9879\u76EE",children:entries.filter(o=>!o.trial).map(o=>jsx16("option",{value:o.id,children:o.name},o.id))})]}),jsx16("button",{type:"button",className:"btn sm",disabled:!current,onClick:()=>{if(!current)return;ctx.app.navigate({page:projectPage,params:{workshop:id,project:current}});window.location.assign(`${window.location.pathname}?preview=${hash}`)},children:"\u6253\u5F00"})]}),jsx16("p",{className:"band-workshops-note",children:"\u6309\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF1B\u9884\u89C8\u91CC\u7684\u5199\u5165\u4ECD\u4F1A\u843D\u5230\u771F\u5B9E\u9879\u76EE\uFF0C\u770B\u5B8C\u70B9\u9875\u9762\u91CC\u7684\u300C\u9000\u51FA\u9884\u89C8\u300D\u56DE\u6765\u3002"})]})})}function ViewFileRow({ctx,id,file,head}){const api=ctx.app.data.write?.workshopEdit;const[open,setOpen]=useState13(false);const[loaded,setLoaded]=useState13(null);const[error,setError]=useState13(null);const read=()=>{if(!api||!head||loaded&&loaded.head===head)return;api.file(id,file.path).then(content=>{setError(null);setLoaded({head,content})},e=>setError(`\u5185\u5BB9\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause5(e,"\u91CD\u8BD5"))}`))};useEffect11(()=>{if(open)read()},[open,head]);const stale=loaded?.head!==head;return jsx16("li",{className:"band-workshop-edit-file-row",children:jsxs16("details",{open,children:[jsxs16("summary",{onClick:e=>{e.preventDefault();setOpen(!open)},children:[CHANGE_LABEL[file.change]," ",jsx16("code",{children:file.path})]}),error?jsxs16("p",{className:"band-workshop-edit-file-note",children:[error,jsx16("button",{type:"button",className:"btn ghost sm",onClick:()=>{setError(null);setLoaded(null);read()},children:"\u91CD\u8BD5"})]}):loaded&&!stale?loaded.content.unavailable?jsx16("p",{className:"band-workshop-edit-file-note",children:loaded.content.unavailable}):jsxs16("div",{className:"band-workshop-edit-file-diff",children:[loaded.content.before!==null&&jsxs16("section",{"aria-label":"\u6539\u524D\u7684\u5185\u5BB9",children:[jsx16("h5",{children:"\u6539\u524D\uFF08\u5DF2\u53D1\u5E03\uFF09"}),jsx16("pre",{children:loaded.content.before})]}),loaded.content.after!==null&&jsxs16("section",{"aria-label":"\u6539\u540E\u7684\u5185\u5BB9",children:[jsx16("h5",{children:"\u6539\u540E\uFF08\u8FD8\u6CA1\u4FDD\u5B58\uFF09"}),jsx16("pre",{children:loaded.content.after})]})]}):jsx16("p",{className:"band-workshop-edit-file-note",children:open?"\u8BFB\u53D6\u4E2D\u2026":"\u70B9\u5F00\u770B\u6539\u524D\u6539\u540E\u7684\u5185\u5BB9"})]})})}function ViewChanges({ctx,id,state,files,declaration,projectPage}){const groups=viewFileGroups(files);const preview=state.preview;const previewHash=state.ahead>0&&preview?.status==="ready"&&preview.hash?preview.hash:void 0;if(!files.length&&!declaration&&!previewHash)return null;const count=files.length+(declaration?1:0);return jsxs16("section",{className:"band-workshop-edit-views","aria-label":"\u89C6\u56FE\u6539\u52A8",children:[jsx16("h3",{children:count?`\u89C6\u56FE ${count} \u5904`:"\u89C6\u56FE"}),!!count&&jsx16("p",{className:"band-workshops-note",children:"\u89C6\u56FE\u662F\u8981\u8FD0\u884C\u7684\u4EE3\u7801\uFF1A\u70B9\u300C\u5728\u9884\u89C8\u91CC\u770B\u300D\u6216\u4FDD\u5B58\u5E76\u53D1\u5E03\u540E\uFF0C\u5B83\u5C31\u4F1A\u4EE5\u4F60\u7684\u8EAB\u4EFD\u5728 Band \u91CC\u8FD0\u884C\u3002\u70B9\u5F00\u6BCF\u4E2A\u6587\u4EF6\u6838\u5BF9\u5185\u5BB9\u3002"}),declaration&&jsxs16("div",{className:"band-workshop-edit-view-plugin",children:[jsx16("h4",{children:"\u89C6\u56FE\u58F0\u660E\uFF08workshop.yaml\uFF09"}),jsx16("ul",{className:"band-workshop-edit-changes",children:jsx16(ViewFileRow,{ctx,id,file:declaration,head:state.head})})]}),groups.map(g=>jsxs16("div",{className:"band-workshop-edit-view-plugin",children:[jsx16("h4",{children:g.plugin}),jsx16("ul",{className:"band-workshop-edit-changes",children:g.files.map(f=>jsx16(ViewFileRow,{ctx,id,file:f,head:state.head},f.path))})]},g.plugin)),state.ahead>0&&preview?.status==="building"&&jsx16("p",{className:"band-workshops-note",children:"\u6B63\u5728\u68C0\u67E5\u6700\u65B0\u7684\u4FEE\u6539\uFF0C\u597D\u4E86\u4EE5\u540E\u53EF\u4EE5\u5728\u8FD9\u91CC\u6253\u5F00\u9884\u89C8\u3002"}),previewHash&&jsx16(PreviewOpen,{ctx,id,hash:previewHash,projectPage})]})}function OtherChanges({files}){if(!files.length)return null;return jsxs16("section",{className:"band-workshop-edit-others","aria-label":"\u5176\u4ED6\u6539\u52A8",children:[jsxs16("h3",{children:["\u5176\u4ED6 ",files.length," \u5904"]}),jsx16("ul",{className:"band-workshop-edit-changes",children:files.map(f=>jsxs16("li",{className:"band-workshop-edit-file-row",children:[CHANGE_LABEL[f.change]," ",jsx16("code",{children:f.path})]},f.path))}),jsx16("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u53EA\u5217\u6539\u4E86\u54EA\u4E9B\u6587\u4EF6\uFF1B\u5B8C\u6574\u6539\u52A8\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u3002"})]})}function TurnReceipt({turn,onSee}){const title=turn.status==="committed"?"\u5DF2\u6539\u597D\uFF0C\u901A\u8FC7\u68C0\u67E5":turn.status==="question"?"Rondo \u9700\u8981\u4F60\u56DE\u7B54":turn.status==="rejected"?turn.round>=3?"Rondo \u6539\u4E86 3 \u6B21\u8FD8\u6CA1\u8FC7\u68C0\u67E5":"\u8FD9\u4E00\u8F6E\u6CA1\u8FC7\u68C0\u67E5\uFF0CRondo \u4F1A\u63A5\u7740\u6539":turn.status==="failed"||turn.status==="aborted"?"\u8FD9\u4E00\u8F6E\u6CA1\u8DD1\u5B8C":turn.status==="queued"?"\u6B63\u5728\u6392\u961F":"\u6B63\u5728\u6539";return jsxs16("article",{className:"band-workshop-edit-receipt","aria-label":title,children:[jsx16("h3",{children:title}),turn.status==="queued"&&jsx16("p",{children:"\u7B49\u5F85 Rondo \u5F00\u59CB\u8FD9\u4E00\u8F6E\u3002"}),turn.status==="running"||turn.status==="validating"?jsx16("ol",{className:"band-workshop-edit-progress","aria-label":"\u56DE\u5408\u8FDB\u5EA6",children:["\u6539\u5DE5\u574A","\u68C0\u67E5\u6539\u52A8","\u66F4\u65B0\u53F3\u8FB9\u7684\u5BF9\u6BD4"].map((s,i)=>jsx16("li",{"aria-current":(turn.status==="validating"?i===1:i===0)?"step":void 0,children:s},s))}):null,turn.summary&&jsx16("p",{children:inline(readable(turn.summary))}),turn.question&&jsx16("p",{children:inline(readable(turn.question))}),(turn.status==="failed"||turn.status==="aborted")&&jsxs16("p",{children:[turn.failure?readable(turn.failure):"\u8FD9\u4E00\u8F6E\u505C\u4E86\u3002"," \u5BF9\u8BDD\u8FD8\u5728\uFF0C\u518D\u8BF4\u4E00\u6B21\u5C31\u884C\u3002"]}),turn.status==="rejected"&&jsx16("p",{children:"\u8FD9\u4E00\u8F6E\u7684\u4FEE\u6539\u6CA1\u8BB0\u4E0B\uFF0C\u53F3\u8FB9\u8FD8\u662F\u4E0A\u4E00\u6B21\u8FC7\u4E86\u68C0\u67E5\u7684\u6837\u5B50\u3002\u63A5\u7740\u8BF4\u8981\u600E\u4E48\u6539\u3002"}),turn.issues.length>0&&jsx16("ul",{className:"band-workshop-edit-issues",children:turn.issues.map((issue,i)=>jsxs16("li",{children:[issue.at??"\u68C0\u67E5\u6539\u52A8","\uFF1A",readable(issue.message)]},`${issue.step}/${i}`))}),turn.status==="committed"&&jsx16("button",{type:"button",className:"btn ghost sm",onClick:onSee,children:"\u770B\u6539\u52A8"})]})}function FirstMessageNote({ctx,w,state,onRefresh}){const code=state?.blocked?.code;if(!w.firstMessage)return null;if(state?.session?.turns.length)return null;const m=modelOf(w);const refresh=onRefresh&&jsx16("button",{type:"button",className:"btn sm",onClick:onRefresh,children:"\u5237\u65B0\u8FD9\u4E00\u9875"});const unknown=jsxs16("p",{children:["\u6CA1\u80FD\u81EA\u52A8\u5F00\u59CB\uFF0C\u8BDD\u8FD8\u7559\u7740\u3002 ",refresh]});const reading=jsx16("p",{"aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u72B6\u6001\u2026"});const guidance=()=>{if(state===null)return reading;switch(code){case"not_ready":return jsx16("p",{children:"\u5DE5\u574A\u8FD8\u5728\u5EFA\uFF0C\u5EFA\u597D\u540E\u4F1A\u81EA\u52A8\u7EE7\u7EED\u3002"});case"model_key":return jsx16("p",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8981\u7528\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u914D\u597D\u4E4B\u540E\u56DE\u5230\u8FD9\u4E00\u9875\u5C31\u4F1A\u5F00\u59CB\u3002"});case"unsupported_files":return jsx16("p",{children:"\u5DE5\u574A\u4ED3\u5E93\u91CC\u6709\u4E0D\u652F\u6301\u7684\u6587\u4EF6\uFF0C\u5728\u4ED3\u5E93\u91CC\u5904\u7406\u6389\u4E4B\u540E\u624D\u80FD\u5F00\u59CB\uFF1B\u8BDD\u5148\u7559\u7740\u3002"});case"ref_mismatch":return jsx16("p",{children:"\u5DE5\u574A\u7684\u6765\u6E90\u8BBE\u7F6E\u9700\u8981\u7BA1\u7406\u5458\u8C03\u6574\u4E4B\u540E\u624D\u80FD\u5F00\u59CB\uFF1B\u8BDD\u5148\u7559\u7740\u3002"});case"locked":return jsx16("p",{children:"\u6709\u4EBA\u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u7B49\u5BF9\u65B9\u7ED3\u675F\uFF1B\u8BDD\u5148\u7559\u7740\uFF0C\u8F6E\u5230\u4F60\u65F6\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002"});case"provision":return modelMissing(m,w.userModelKey)?jsxs16("p",{children:["\u8FD8\u5DEE\u914D\u7F6E\u6A21\u578B\uFF0C\u914D\u597D\u540E Agent \u624D\u80FD\u51C6\u5907\u3002 ",go("model","\u53BB\u914D\u7F6E\u6A21\u578B")]}):m.agent==="failed"?jsxs16("p",{children:["Agent \u6CA1\u51C6\u5907\u597D\uFF0C\u8FD9\u53E5\u8BDD\u5148\u7559\u7740\uFF1B\u5728\u5DE5\u574A\u9875\u91CD\u8BD5\uFF0C\u6210\u529F\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002"," ",go("about","\u53BB\u5DE5\u574A\u9875\u91CD\u8BD5")]}):progress?.step===3?jsxs16("p",{"data-provision-step":3,children:[progress.text," ",go("about","\u53BB\u5DE5\u574A\u9875")]}):m.agent!=="ready"?jsxs16("p",{"data-provision-step":progress?.step,children:[progress?`${progress.text} `:"Agent \u6B63\u5728\u51C6\u5907\uFF0C","\u597D\u4E86\u4E4B\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\uFF0C\u4E0D\u7528\u518D\u70B9\u3002"]}):unknown;default:return unknown}};const progress=provisionProgress(m);const go=(page,label)=>jsx16("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:`${SELF}/${page}`,params:{workshop:w.id}}),children:label});return jsxs16("section",{className:"band-workshops-callout","aria-label":"\u8FD8\u6CA1\u53D1\u51FA\u7684\u6D41\u7A0B\u63CF\u8FF0","data-first-message":true,children:[jsx16("p",{children:"\u4F60\u65B0\u5EFA\u65F6\u5199\u7684\u6D41\u7A0B\u63CF\u8FF0\u8FD8\u7559\u7740\uFF0C\u51C6\u5907\u597D\u4E4B\u540E\u4F1A\u81EA\u52A8\u4EA4\u7ED9 Rondo\uFF1A"}),jsx16("blockquote",{children:w.firstMessage}),guidance()]})}function WorkshopEdit({ctx,id,projectPage}){const api=ctx.app.data.write?.workshopEdit;const workshop=useAppData4(ctx,d=>d.workshop(id),[id]);const w=workshop.data;const canRead=w?.canAdmin===true;const latest=useRef6(null);const[state,setState]=useState13(null);const[error,setError]=useState13(null);const[readDenied,setReadDenied]=useState13(null);const[fresh,setFresh]=useState13(false);const[busy,setBusy]=useState13(false);const[draft,setDraft]=useState13(emptyDraft2);const[pane,setPane]=useState13("chat");const[side,setSide]=useState13("diff");const[chatOpen,setChatOpen]=useState13(false);const[bodyEl,setBodyEl]=useState13(null);const[bodyW,setBodyW]=useState13(0);useEffect11(()=>{if(!bodyEl||typeof ResizeObserver==="undefined")return;const watch=new ResizeObserver(([entry])=>setBodyW(Math.round(entry?.contentRect.width??0)));watch.observe(bodyEl);return()=>watch.disconnect()},[bodyEl]);const trials=useAppData4(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const[confirm,setConfirm]=useState13(null);const[revertingHead,setRevertingHead]=useState13(null);const[reverted,setReverted]=useState13(false);const[endingSession,setEndingSession]=useState13(null);const inFlight=useRef6(false);const autoStarted=useRef6(false);const generation=useRef6(0);const manualRead=useRef6(null);const alive=useRef6(true);const stopPolling=useRef6(false);const messages=useMessageList();const modal=useModalDialog({open:confirm!==null,onRequestClose:()=>setConfirm(null),blocked:busy});const refresh=useCallback4(async(explicit=false)=>{if(!api||!canRead||inFlight.current||!explicit&&manualRead.current!==null)return;const seq=++generation.current;if(explicit)manualRead.current=seq;try{const s=await api.get(id);if(alive.current&&seq===generation.current){setState(s);latest.current=s;setError(null);setReadDenied(null);setFresh(true);return s.head??void 0}}catch(e){if(alive.current&&seq===generation.current){setFresh(false);if(isForbidden5(e)||codeOf(e)==="NOT_FOUND"){setState(null);setReadDenied(isForbidden5(e)?"forbidden":"disabled");stopPolling.current=true}else setError(`\u5DE5\u574A\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause5(e,"\u70B9\u91CD\u8BD5"))}`)}}finally{if(manualRead.current===seq)manualRead.current=null}},[api,id,canRead]);useEffect11(()=>{if(!api||!canRead)return;alive.current=true;stopPolling.current=false;let timer=null;let armed=false;let pollGeneration=0;let stopped=false;const clear=()=>{if(timer!==null)clearTimeout(timer);timer=null;armed=false};const schedule=()=>{if(stopped||!alive.current||stopPolling.current||armed)return;if(document.visibilityState!=="visible")return;armed=true;timer=setTimeout(()=>{timer=null;armed=false;void poll()},editStatePollMs(latest.current))};const poll=async()=>{if(stopped||!alive.current||stopPolling.current)return;if(document.visibilityState!=="visible")return;const current=++pollGeneration;try{await refresh()}finally{if(current===pollGeneration)schedule()}};const onVisibility=()=>{if(document.visibilityState!=="visible"){clear();return}clear();void poll()};document.addEventListener("visibilitychange",onVisibility);void poll();return()=>{stopped=true;alive.current=false;++generation.current;manualRead.current=null;clear();document.removeEventListener("visibilitychange",onVisibility)}},[api,refresh,canRead]);const act=async run=>{if(!api||inFlight.current)return false;inFlight.current=true;++generation.current;setBusy(true);try{const s=await run(api);if(alive.current){++generation.current;setState(s);setFresh(true);setError(null);setConfirm(null)}return true}catch(e){if(alive.current){setError(codeOf(e)==="CONFLICT"?confirm==="revert"?`${readable(errorText8(e))} \u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u8BD5\u3002`:"\u4F60\u6253\u5F00\u4E4B\u540E\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\uFF0C\u6216\u4FEE\u6539\u5DF2\u7531\u522B\u4EBA\u63A5\u624B\u3002\u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u8BD5\u3002":readable(errorText8(e)));setFresh(false)}return false}finally{inFlight.current=false;if(alive.current)setBusy(false)}};const firstTried=useRef6(false);useEffect11(()=>{if(!api||!w?.firstMessage||!state||!fresh||firstTried.current)return;if(state.blocked||!w.canAdmin||state.session&&state.session.status!=="ended")return;firstTried.current=true;autoStarted.current=true;void act(a=>a.start(id)).then(()=>workshop.reload())});useEffect11(()=>{if(!api||!w||!state||!fresh||autoStarted.current)return;autoStarted.current=true;if(w.canAdmin&&!state.blocked&&(!state.session||state.session.status==="ended"))void act(a=>a.start(id))});const mine=state?.session?.status==="active"&&state.session.holder.id===ctx.app.member.id;const memberId=ctx.app.member.id;useEffect11(()=>{if(!api||!mine||pane!=="trial")return;const beat=()=>{if(document.visibilityState!=="visible"||inFlight.current)return;api.get(id).then(read=>{if(!alive.current||inFlight.current)return;const held=read.session?.status==="active"&&read.session.holder.id===memberId;if(!held){setState(read);return}return api.start(id).then(s=>alive.current&&setState(s))}).catch(()=>{})};const timer=setInterval(beat,5*6e4);document.addEventListener("visibilitychange",beat);return()=>{clearInterval(timer);document.removeEventListener("visibilitychange",beat)}},[api,id,pane,mine,memberId]);const hadOwn=useRef6(false);if(mine)hadOwn.current=true;if(w===null)return jsxs16("main",{className:"band-workshops-screen",children:[jsx16(Crumb,{ctx,here:"\u6539\u5DE5\u574A"}),jsx16("p",{children:"\u5DE5\u574A\u4E0D\u5B58\u5728\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u67E5\u770B\u6743\u9650\u3002"})]});if(readDenied||w&&!w.canAdmin)return jsxs16("main",{className:"band-workshops-screen",children:[jsx16(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsx16("p",{children:readDenied==="disabled"?"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002":"\u6CA1\u6709\u6743\u9650\u770B\u5DE5\u574A\u6539\u52A8\u3002\u53EA\u6709\u5DE5\u574A\u521B\u5EFA\u4EBA\u3001\u5DE5\u574A\u7BA1\u7406\u5458\u548C Band \u7BA1\u7406\u5458\u80FD\u770B\uFF0C\u8BF7\u627E\u5DE5\u574A\u7BA1\u7406\u5458\u3002"}),jsx16("button",{type:"button",className:"btn",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}}),children:"\u56DE\u5230\u5DE5\u574A"})]});if(!w)return jsxs16("main",{className:"band-workshops-screen",children:[jsx16(Crumb,{ctx,here:"\u6539\u5DE5\u574A"}),workshop.error?jsx16(ErrorNote11,{retry:workshop.reload,children:workshop.error}):jsx16("p",{children:"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u2026"})]});if(!api)return jsxs16("main",{className:"band-workshops-screen",children:[jsx16(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsx16("p",{children:"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002"})]});const session=state?.session;const own=!!session&&session.status==="active"&&session.holder.id===ctx.app.member.id&&w.canAdmin&&state?.blocked?.code!=="forbidden";const active=session?.turns.some(running)??false;const rows=flowChangeRows(state?.changes.flow??null,w.roles,w.artifactTypes);const agentCount=agentChangeCount(state);const fileChanges=state?.changes.files??[];const viewFiles=fileChanges.filter(f=>f.face==="views");const declaration=fileChanges.find(f=>f.path==="band/workshop.yaml"&&f.viewsSection);const paramsFiles=fileChanges.filter(f=>f.face==="flow"&&f.path.startsWith("band/params/"));const otherFiles=fileChanges.filter(f=>f.face==="other"||f.path==="band/workshop.yaml"&&!f.viewsSection&&rows.length===0&&agentCount===0);const totalCount=rows.length+paramsFiles.length+viewFiles.length+(declaration?1:0)+otherFiles.length+agentCount;const hasViewCode=viewFiles.length>0||!!declaration;const why=state?editBlocked(state):"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u2026";const readOnly=!fresh||!own||!!state?.blocked;const disabled=readOnly||busy;const saveWhy=busy?"\u6B63\u5728\u5904\u7406\uFF0C\u8BF7\u7A0D\u7B49":disabled?why??(!own?"\u5F00\u59CB\u4FEE\u6539\u540E\u624D\u80FD\u4FDD\u5B58":"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001"):active?"\u8FD9\u4E00\u8F6E\u6539\u5B8C\u624D\u80FD\u4FDD\u5B58":state&&matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":state?.saveBlocked?readable(state.saveBlocked.message):state?.head?void 0:"\u5DE5\u574A\u8FD8\u6CA1\u51C6\u5907\u597D";const revertWhy=busy?"\u6B63\u5728\u5904\u7406\uFF0C\u8BF7\u7A0D\u7B49":!api.revert?"\u9000\u56DE\u529F\u80FD\u8FD8\u6CA1\u5F00\u653E":!fresh||!state?.head?"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001":session?.status==="active"&&!own?"\u8BF7\u7B49\u5BF9\u65B9\u7ED3\u675F\u4FEE\u6539\u540E\u518D\u9000\u56DE":active?"\u8BF7\u5148\u505C\u6B62\u8FD9\u4E00\u8F6E\uFF0C\u7B49\u56DE\u5408\u7ED3\u675F\u540E\u518D\u9000\u56DE":state?.blocked&&!["model_key","provision","unsupported_files"].includes(state.blocked.code)?why:!state?.released?.commit?"\u6CA1\u6709\u53EF\u9000\u56DE\u7684\u53D1\u5E03\u7248\u672C":state.ahead===0||matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":void 0;const confirmTitle=confirm==="end"?"\u7ED3\u675F\u8FD9\u6B21\u4FEE\u6539":confirm==="revert"?"\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03":"\u63A5\u624B\u4FEE\u6539";const see=()=>{setPane("diff");setSide("diff")};const showTrial=()=>{setPane("trial");setSide("trial");setChatOpen(false)};return jsxs16("main",{className:"band-workshop-edit",children:[jsxs16("header",{className:"band-workshop-edit-head",children:[jsxs16("div",{children:[jsx16(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsxs16("h1",{children:["\u6539\u5DE5\u574A\uFF1A",w.name]}),jsx16("div",{className:"band-workshop-edit-lock",children:own?jsxs16(Fragment15,{children:[jsx16("span",{children:"\u4F60\u6B63\u5728\u6539 \xB7 \u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B"}),jsx16("button",{type:"button",className:"btn ghost sm",disabled:busy||!fresh,onClick:event=>{modal.trigger.current=event.currentTarget;setEndingSession(session?.id??null);setConfirm("end")},children:"\u7ED3\u675F"})]}):session?.status==="active"?jsxs16(Fragment15,{children:[jsxs16("span",{children:[session.holder.name," \u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B\u3002"]}),w.canAdmin&&state?.blocked?.code==="locked"&&jsx16("button",{type:"button",className:"btn sm",disabled:busy||!fresh,onClick:event=>{modal.trigger.current=event.currentTarget;setConfirm("takeover")},children:"\u63A5\u624B"})]}):jsxs16(Fragment15,{children:[jsx16("span",{children:why??"\u5F00\u59CB\u4FEE\u6539\u540E\uFF0C\u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B"}),state&&!state.blocked&&jsx16("button",{type:"button",className:"btn sm",disabled:busy||!fresh,onClick:()=>void act(a=>a.start(id)),children:"\u5F00\u59CB\u4FEE\u6539"})]})})]}),jsxs16("div",{className:"band-workshop-edit-actions",children:[jsx16("span",{children:!state?"\u6B63\u5728\u8BFB\u53D6\u4FEE\u6539\u2026":state.head===null?"\u6539\u52A8\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528":state.ahead===0||matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":totalCount?`\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF1A${totalCount} \u5904`:state.changes.flow?"\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF08\u5BF9\u6BD4 0 \u5904\uFF09":"\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528"}),state?.released&&jsx16("button",{type:"button",className:"btn",disabled:!!revertWhy,title:revertWhy,onClick:event=>{modal.trigger.current=event.currentTarget;setRevertingHead(state.head);setReverted(false);setConfirm("revert")},children:"\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03"}),jsx16(PublishRelease,{ctx,w,onDone:()=>{void refresh();workshop.reload()},label:"\u4FDD\u5B58\u5E76\u53D1\u5E03",primary:true,disabledReason:saveWhy,commit:state?.head??void 0,onConflict:()=>{setFresh(false)},onRefresh:async()=>{const head=await refresh(true);workshop.reload();return head},publishingChanged:setBusy}),saveWhy&&state?.saveBlocked?.code!=="no_changes"&&jsx16("small",{className:"band-workshops-hint",children:saveWhy}),hasViewCode&&state?.ahead!==0&&jsx16("small",{className:"band-workshops-hint",children:"\u542B\u89C6\u56FE\u4EE3\u7801\uFF1A\u4FDD\u5B58\u5E76\u53D1\u5E03\u540E\uFF0C\u4F1A\u5728\u6210\u5458\u6253\u5F00\u9879\u76EE\u65F6\u8FD0\u884C\u3002"})]})]}),reverted&&jsx16("output",{children:"\u5DF2\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03\u3002\u4FEE\u6539\u5386\u53F2\u5DF2\u4FDD\u7559\uFF0C\u6CA1\u6709\u53D1\u5E03\u65B0\u7248\u3002"}),error&&jsx16(ErrorNote11,{retry:()=>void refresh(),children:error}),jsx16(FirstMessageNote,{ctx,w,state,onRefresh:()=>{void refresh();workshop.reload()}}),state?.changes.unsupportedFiles?.length?jsxs16("div",{role:"alert",children:[jsx16("p",{children:editBlocked(state)}),jsx16(UnsupportedFiles,{state})]}):null,state&&!state.agentEditable&&jsx16("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u53EA\u80FD\u6539\u6D41\u7A0B\u548C\u89C6\u56FE\uFF1BAgent \u7684\u8BF4\u660E\u3001\u6280\u80FD\u548C\u63D2\u4EF6\u7167\u65E7\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u6539\u3002"}),state?.preview?.status==="failed"&&jsxs16("div",{role:"alert",children:[jsx16(ErrorNote11,{children:"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7\u3002\u4FEE\u597D\u4E4B\u524D\u4E0D\u80FD\u4FDD\u5B58\uFF1B\u63A5\u7740\u8DDF Rondo \u8BF4\u8981\u600E\u4E48\u6539\u3002"}),jsx16("ul",{children:state.preview.issues.map((s,i)=>jsx16("li",{children:readable(s)},`${i}/${s}`))})]}),jsxs16("div",{className:"band-workshop-edit-pane-switch seg","aria-label":"\u6539\u5DE5\u574A\u5185\u5BB9",children:[jsx16("button",{type:"button","aria-pressed":pane==="chat",onClick:()=>setPane("chat"),children:"\u5BF9\u8BDD"}),jsxs16("button",{type:"button","aria-pressed":pane==="diff",onClick:see,children:["\u6539\u52A8",totalCount?` \xB7 ${totalCount}`:""]}),jsx16("button",{type:"button","aria-pressed":pane==="trial",onClick:showTrial,children:"\u8BD5\u7528"})]}),jsxs16("div",{className:"band-workshop-edit-body","data-pane":pane,"data-fold":side==="trial"&&!chatOpen&&bodyW>0&&bodyW<TRIAL_UNFOLDED_MIN?"chat":void 0,ref:setBodyEl,children:[jsx16("button",{type:"button",className:"band-workshop-edit-rail iconbtn","aria-label":"\u5C55\u5F00\u5BF9\u8BDD",title:"\u5C55\u5F00\u5BF9\u8BDD",onClick:()=>setChatOpen(true),children:"\u25E7"}),jsxs16("section",{className:"band-workshop-edit-chat","aria-label":"\u5BF9\u8BDD",children:[jsxs16("div",{className:"band-workshop-edit-messages","data-band-messages":true,...messages,children:[!session?.turns.length&&jsxs16("div",{className:"band-workshop-edit-empty",children:[jsx16("h2",{children:"\u8DDF Rondo \u8BF4\u8981\u600E\u4E48\u6539\u8FD9\u4E2A\u5DE5\u574A"}),jsx16("p",{children:"\u8BF4\u8981\u6539\u4EC0\u4E48\uFF1A\u6D41\u7A0B\uFF08\u52A0\u54EA\u4E00\u6B65\u3001\u8C01\u6765\u6279\u3001\u53BB\u6389\u4EC0\u4E48\uFF09\u6216\u754C\u9762\uFF08\u7ED9\u67D0\u4E2A\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0 \u9762\u677F\uFF09\u3002Rondo \u6539\u5B8C\u5148\u8FC7\u68C0\u67E5\uFF0C\u53F3\u8FB9\u4F1A\u5217\u51FA\u6539\u4E86\u4EC0\u4E48\uFF1B\u70B9\u300C\u4FDD\u5B58\u5E76\u53D1\u5E03\u300D\u4E4B\u524D\uFF0C\u9879\u76EE\u90FD\u4E0D\u53D7\u5F71\u54CD\u3002"}),jsx16("button",{type:"button",className:"btn ghost",disabled:disabled||active,onClick:()=>setDraft({...emptyDraft2(),text:"\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u7531\u6559\u7814\u7EC4\u957F\u6279"}),children:"\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u7531\u6559\u7814\u7EC4\u957F\u6279"}),jsx16("button",{type:"button",className:"btn ghost",disabled:disabled||active,onClick:()=>setDraft({...emptyDraft2(),text:"\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0\u9762\u677F\uFF0C\u80FD\u770B\u5230\u4EA7\u51FA\u7684\u6E05\u5355"}),children:"\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0\u9762\u677F"})]}),session?.turns.map(t=>jsxs16(Fragment14,{children:[t.message&&jsx16("div",{className:"band-workshop-edit-user",children:inline(t.message)}),jsxs16("div",{className:"band-workshop-edit-message","data-band-message":true,tabIndex:-1,children:[jsxs16("div",{className:"band-workshop-edit-who",children:[jsx16(Avatar3,{id:"rondo",name:"Rondo",agent:true,size:"sm",decorative:true}),"Rondo"]}),jsx16(TurnReceipt,{turn:t,onSee:see}),(t.status==="failed"||t.status==="aborted")&&jsx16("button",{type:"button",className:"btn ghost sm",disabled:disabled||active,onClick:()=>{const message=session.turns.slice(0,session.turns.indexOf(t)+1).reverse().find(turn=>turn.message)?.message;if(message)void act(a=>a.send(id,session.id,{message}))},children:"\u518D\u53D1\u4E00\u6B21\u8FD9\u53E5\u8BDD"})]})]},t.id))]}),active&&own&&jsx16("button",{type:"button",className:"btn ghost sm",disabled:busy||!fresh,onClick:()=>session&&void act(a=>a.stop(id,session.id)),children:"\u505C\u6B62\u8FD9\u4E00\u8F6E"}),jsx16(PromptInput2,{draft,onDraft:setDraft,variant:"prompt",label:"\u544A\u8BC9 Rondo \u8981\u600E\u4E48\u6539",placeholder:"\u8BF4\u8981\u600E\u4E48\u6539\uFF0C\u4F8B\u5982\uFF1A\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u6216\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u9762\u677F",busy:busy||active,disabledReason:readOnly?why??(!own?"\u5F00\u59CB\u4FEE\u6539\u540E\uFF0C\u5C31\u80FD\u8DDF Rondo \u8BF4\u8981\u6539\u4EC0\u4E48\u3002":"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001\u3002"):void 0,onSubmit:async d=>{if(disabled||active||!session)return false;if(d.text.trim().length>8e3)throw new Error("\u8FD9\u53E5\u8BDD\u592A\u957F\u4E86\uFF0C\u8BF7\u7F29\u77ED\u5230 8000 \u5B57\u4EE5\u5185\u3002");return await act(a=>a.send(id,session.id,{message:d.text.trim()}))}}),jsxs16("small",{className:"band-workshops-hint",children:["\u6A21\u578B\uFF1A",w.userModelKey==="require"?"\u4F60\u7684\u9ED8\u8BA4\u6A21\u578B\u914D\u7F6E":"\u5DE5\u574A\u7684\u56E2\u961F\u6A21\u578B"]})]}),jsxs16("div",{className:"band-workshop-edit-side","data-side":pane==="chat"?side:pane,children:[jsx16("div",{className:"band-workshop-edit-side-tabs tabs plain",role:"tablist","aria-label":"\u6539\u52A8\u4E0E\u8BD5\u7528",children:[["diff",`\u6539\u52A8${totalCount?` \xB7 ${totalCount}`:""}`],["trial","\u8BD5\u7528"]].map(([key,label])=>jsx16("button",{type:"button",role:"tab",id:`band-workshop-edit-tab-${key}`,"aria-controls":`band-workshop-edit-panel-${key}`,"aria-selected":side===key,tabIndex:side===key?0:-1,onClick:()=>key==="diff"?see():showTrial(),onKeyDown:withImeGuard2(e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();const next=e.key==="Home"?"diff":e.key==="End"?"trial":side==="diff"?"trial":"diff";if(next==="diff")see();else showTrial();document.getElementById(`band-workshop-edit-tab-${next}`)?.focus()}),children:label},key))}),jsx16("section",{className:"band-workshop-edit-diff",id:"band-workshop-edit-panel-diff",role:"tabpanel","aria-labelledby":"band-workshop-edit-tab-diff","aria-label":"\u6539\u52A8",hidden:side!=="diff",children:jsx16("div",{className:"band-workshop-edit-diff-scroll",children:state?jsxs16(Fragment15,{children:[jsx16(FlowComparison,{state,w,rows,paramsFiles,listedBelow:viewFiles.length+(declaration?1:0)+otherFiles.length+agentCount}),jsx16(ViewChanges,{ctx,id,state,files:viewFiles,declaration,projectPage}),(state.agentEditable||agentCount>0)&&jsxs16("section",{className:"band-workshop-edit-agent","aria-label":"Agent \u6539\u52A8",children:[jsx16("h3",{children:"Agent \u6539\u52A8"}),jsx16(AgentChanges,{state})]}),jsx16(OtherChanges,{files:otherFiles})]}):jsx16("p",{children:"\u6B63\u5728\u8BFB\u53D6\u5BF9\u6BD4\u2026"})})}),jsx16("section",{className:"band-workshop-edit-trial",id:"band-workshop-edit-panel-trial",role:"tabpanel","aria-labelledby":"band-workshop-edit-tab-trial","aria-label":"\u8BD5\u7528",hidden:side!=="trial",children:state?jsx16(TrialTab,{ctx,id,state,own,holder:session?.status==="active"?session.holder.name:void 0,trials:trials.data,trialsError:trials.error??null,reloadTrials:trials.reload,workshopName:w.name,ended:hadOwn.current&&session?.status!=="active",onRestart:()=>void act(a=>a.start(id)),onRefresh:()=>refresh(true),projectPage,agentPreparing:["preparing","awaiting_promotion"].includes(modelOf(w).agent)}):jsx16("p",{children:"\u6B63\u5728\u8BFB\u53D6\u2026"})})]})]}),jsx16("dialog",{ref:modal.dialog,className:"band-workshops-publish-dialog","data-band-layer":confirm?"dialog":void 0,"aria-label":confirmTitle,onCancel:e=>{e.preventDefault();if(!busy)setConfirm(null)},onClose:()=>setConfirm(null),children:jsxs16("div",{className:"band-workshops-publish-body",children:[jsx16("h2",{children:confirmTitle}),jsx16("p",{children:confirm==="revert"?`\u628A\u5DE5\u574A\u91CC\u8FD8\u6CA1\u53D1\u5E03\u7684\u6D41\u7A0B\u3001\u89C6\u56FE\u548C Agent \u6587\u4EF6\u6062\u590D\u6210\u4E0A\u6B21\u53D1\u5E03\uFF08v${state?.released?.seq}\uFF09\u7684\u6837\u5B50\u3002\u8FD9\u4E9B\u4FEE\u6539\u4F1A\u4ECE\u5F53\u524D\u5B9A\u4E49\u4E2D\u79FB\u9664\uFF0C\u4FEE\u6539\u5386\u53F2\u4ECD\u4F1A\u4FDD\u7559\u3002\u9000\u56DE\u4E0D\u4F1A\u53D1\u5E03\u65B0\u7248\uFF0C\u4E5F\u4E0D\u4F1A\u6539\u53D8\u5DF2\u6709\u9879\u76EE\u3002`:confirm==="end"?"\u7ED3\u675F\u540E\uFF0C\u5DF2\u7ECF\u901A\u8FC7\u68C0\u67E5\u7684\u4FEE\u6539\u4ECD\u4F1A\u4FDD\u7559\uFF1B\u4E0B\u6B21\u4F60\u6216\u522B\u4EBA\u8FDB\u6765\u90FD\u80FD\u63A5\u7740\u6539\u3001\u4FDD\u5B58\u3002":`${session?.holder.name??"\u5BF9\u65B9"} \u7684\u4FEE\u6539\u4F1A\u505C\u4E0B\uFF0C\u4E4B\u540E\u7531\u4F60\u63A5\u7740\u6539\u3002\u8FD9\u6B21\u63A5\u624B\u4F1A\u8BB0\u8FDB\u64CD\u4F5C\u8BB0\u5F55\u3002`}),confirm==="end"&&(!own||session?.id!==endingSession)&&jsx16("p",{children:"\u8FD9\u6B21\u4FEE\u6539\u5DF2\u7ED3\u675F\u6216\u5DF2\u53D8\u5316\uFF0C\u8BF7\u70B9\u300C\u53D6\u6D88\u300D\u540E\u518D\u770B\u5F53\u524D\u72B6\u6001\u3002"}),confirm==="revert"&&(revertWhy||state?.head!==revertingHead)&&jsx16("p",{role:"alert",children:state?.head!==revertingHead?"\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\uFF0C\u8BF7\u70B9\u300C\u53D6\u6D88\u300D\uFF0C\u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u9000\u56DE\u3002":revertWhy}),confirm==="revert"&&error&&jsx16("p",{role:"alert",children:error}),jsxs16("div",{className:"band-workshops-actions",children:[jsx16("button",{type:"button",className:"btn ghost",disabled:busy,onClick:()=>setConfirm(null),children:"\u53D6\u6D88"}),jsx16("button",{type:"button",className:"btn primary",disabled:busy||confirm==="end"&&(!own||!session||session.id!==endingSession)||confirm==="revert"&&(!!revertWhy||!revertingHead||state?.head!==revertingHead),onClick:()=>{if(confirm==="end"){if(!own||!session||session.id!==endingSession)return;void act(a=>a.end(id,session.id))}else if(confirm==="takeover")void act(a=>a.start(id,{takeOver:true}));else if(confirm==="revert"&&!revertWhy&&revertingHead&&state?.head===revertingHead){const expectedHead=revertingHead;void act(a=>{if(!a.revert)throw new Error("\u9000\u56DE\u529F\u80FD\u8FD8\u6CA1\u5F00\u653E");return a.revert(id,{expectedHead})}).then(ok=>{if(ok&&alive.current)setReverted(true)})}},children:busy?"\u6B63\u5728\u5904\u7406\u2026":confirm==="end"?"\u7ED3\u675F":confirm==="revert"?"\u786E\u8BA4\u9000\u56DE":"\u63A5\u624B"})]})]})})]})}function upgradeCounts(status){const incompatible=status.projects.filter(p=>!p.archived&&p.pins.some(pin=>pin.incompatibleRoles.length>0)).length;return{outdated:status.outdatedProjects,incompatible}}function upgradeGroups(status){const archived=status.projects.filter(p=>p.archived);const changing=p=>!p.archived&&(p.outdated||p.pins.some(pin=>pin.incompatibleRoles.length>0));return{willUpdate:status.projects.filter(changing),archived,latest:status.projects.filter(p=>!p.archived&&!changing(p))}}function WorkshopUpgrade({ctx,workshop}){const api=ctx.app.data.write?.workshopUpgrade;const[status,setStatus]=useState14(null);const[loadError,setLoadError]=useState14(null);const[confirming,setConfirming]=useState14(false);const[busy,setBusy]=useState14(false);const[result,setResult]=useState14(null);const[runError,setRunError]=useState14(null);const inFlight=useRef7(false);const load=useCallback5(()=>{if(!api)return;api.status(workshop).then(s=>{setStatus(s);setLoadError(null)},e=>{setStatus(null);setLoadError(isForbidden6(e)?null:failedBecause6(e,"\u70B9\u91CD\u8BD5"))})},[api,workshop]);useEffect12(()=>{load();return ctx.app.data.subscribe(load)},[ctx,load]);const behind=status?.outdatedProjects??0;useEffect12(()=>{if(behind===0)setConfirming(false)},[behind]);const{dialog,trigger}=useModalDialog({open:confirming,onRequestClose:()=>setConfirming(false),blocked:busy});if(!api)return null;if(loadError)return jsxs17(ErrorNote12,{retry:load,children:["\u5347\u7EA7\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A",loadError]});if(!status)return null;const{outdated,incompatible}=upgradeCounts(status);const currentBehind=status.current.outdatedRoles.length>0||(status.current.outdatedOfficialPlugins??[]).length>0;const hints=status.referenceHints??[];const hint=hints.length>0?jsx17(ReferenceHints,{hints}):null;if(outdated===0&&incompatible===0&&!currentBehind&&!result)return hint;const run=()=>{if(inFlight.current)return;inFlight.current=true;setBusy(true);setRunError(null);api.run(workshop).then(r=>{inFlight.current=false;setBusy(false);setConfirming(false);setResult(r);load()},e=>{inFlight.current=false;setBusy(false);setRunError(failedBecause6(e,"\u518D\u70B9\u4E00\u6B21\u300C\u66F4\u65B0\u300D"))})};const{willUpdate,archived,latest}=upgradeGroups(status);return jsxs17("section",{className:"band-workshops-upgrade","aria-label":"\u66F4\u65B0\u534F\u4F5C\u529F\u80FD",children:[jsxs17("div",{"aria-live":"polite",children:[outdated>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.outdatedProjects(outdated)}),incompatible>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.incompatibleProjects(incompatible)}),currentBehind&&jsx17("p",{children:UPGRADE_TEXT.workshop.currentOutdated})]}),outdated>0&&jsxs17(Fragment16,{children:[jsx17("button",{ref:trigger,type:"button",className:"btn","aria-haspopup":"dialog",onClick:()=>{setRunError(null);setConfirming(true)},children:UPGRADE_TEXT.workshop.button}),jsx17("dialog",{ref:dialog,className:"band-workshops-upgrade-dialog","data-band-layer":confirming?"dialog":void 0,"aria-label":UPGRADE_TEXT.workshop.confirm.title,onCancel:e=>{if(busy)e.preventDefault()},onClose:()=>setConfirming(false),children:jsxs17("div",{className:"band-workshops-upgrade-body",children:[jsx17("h2",{className:"band-workshops-upgrade-title",children:UPGRADE_TEXT.workshop.confirm.title}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.willUpdate(willUpdate)}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.unchanged}),archived.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.archived(archived.length)}),latest.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.alreadyLatest(latest.length)}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.checks}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.noUndo}),runError&&jsx17("div",{role:"alert",children:jsx17(ErrorNote12,{children:runError})}),jsxs17("div",{className:"band-workshops-actions",children:[jsx17("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:()=>setConfirming(false),children:"\u53D6\u6D88"}),jsx17("button",{type:"button",className:"btn primary sm","aria-disabled":busy,onClick:run,children:busy?UPGRADE_TEXT.workshop.confirm.busy:UPGRADE_TEXT.workshop.confirm.submit})]})]})})]}),result&&jsx17(UpgradeResult,{result}),hint]})}function ReferenceHints({hints}){const text=UPGRADE_TEXT.workshop.referenceHint;const specs=hints.map(h=>`${h.name}@^${h.version}`);return jsxs17("section",{className:"band-workshops-ref-hint","aria-label":text.title(hints.length),children:[jsx17("p",{className:"band-workshops-ref-hint-title",children:text.title(hints.length)}),jsx17("ul",{children:hints.map(h=>jsx17("li",{children:text.row(h.name,h.version)},h.name))}),jsx17("p",{children:text.how(specs)})]})}function UpgradeResult({result}){const of=kind=>result.projects.filter(p=>p.result===kind);const failed=of("failed").map(p=>({name:p.name,problems:p.failures.flatMap(f=>f.problems)}));const upgraded=of("upgraded");const kept=result.projects.flatMap(p=>p.unchanged).filter(u=>u.reason==="structure_changed"||u.reason==="plan_differs").length;return jsxs17("div",{className:"band-workshops-upgrade-result","data-upgrade-result":true,"aria-live":"polite",children:[result.counts.upgraded>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.upgraded(result.counts.upgraded,upgraded)}),result.counts.current>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.current(result.counts.current)}),result.counts.skipped>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.archived(result.counts.skipped)}),kept>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.keptInstances(kept)}),failed.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.failed(failed)})]})}var src_default=definePlugin({surfaces:{workshops:reactMount(ctx=>jsx18(Catalog,{ctx})),about:reactMount((ctx,{owner})=>jsx18(About,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")})),new:reactMount((ctx,{owner})=>jsx18(NewProject,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")},owner.params.workshop)),resume:reactMount((ctx,{owner})=>jsx18(NewProject,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project"),resume:true},owner.params.workshop)),create:reactMount(ctx=>jsx18(NewWorkshop,{ctx,from:""})),copy:reactMount((ctx,{owner})=>jsx18(NewWorkshop,{ctx,from:owner.params.workshop??""})),model:reactMount((ctx,{owner})=>jsx18(ModelSetup,{ctx,id:owner.params.workshop??""},owner.params.workshop)),edit:reactMount((ctx,{owner})=>jsx18(WorkshopEdit,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")},owner.params.workshop)),secrets:reactMount((ctx,{owner})=>jsx18(SecretsSetup,{ctx,id:owner.params.workshop??""},owner.params.workshop))}});var SCOPE_TEXT={public:"\u516C\u5F00",team:"\u56E2\u961F"};function visibilityText(w){const v=w.visibility??(w.scope==="public"?"everyone":"members");return WORKSHOP_LEVELS.find(l=>l.value===v)?.label??v}var PERM_TEXT={comment:"\u8BC4\u8BBA","submit-change":"\u63D0\u4EA4\u4FEE\u6539",confirm:"\u786E\u8BA4\u4FEE\u6539",approve:"\u6279\u51C6",publish:"\u53D1\u5E03",admin:"\u7BA1\u7406\u9879\u76EE"};var STORAGE_TEXT={git:"\u76EE\u6807\u4ED3\u5E93",store:"Band",external:"\u5916\u90E8\u5E73\u53F0"};function stageNames(stages){return stages.map((s,i)=>stageDisplayName2(s.id,s.label,i))}function cardStatus(w){if(w.version===0)return{text:"\u8FD8\u6CA1\u5C31\u7EEA",failed:false};if(modelOf(w).state==="not_provisioned")return void 0;if(modelOf(w).hasRequest===false)return{text:"\u5F85\u914D\u7F6E\u6A21\u578B",failed:false};const agent=modelOf(w).agent;if(!agent||agent==="ready")return void 0;return{text:agentLabel(agent),failed:agent==="failed"}}function FlowLine({stages}){const names=stageNames(stages);return jsx18("div",{className:"band-workshops-flowline","aria-label":"\u6D41\u7A0B",children:stages.map((s,i)=>jsxs18(Fragment17,{children:[i>0&&jsx18("span",{"aria-hidden":"true",children:"\u2192"}),jsx18("span",{className:`band-workshops-st ${s.kind}`,children:names[i]})]},s.id))})}function Catalog({ctx}){const[scope,setScope]=useState15("all");const canArchive=ctx.app.data.write?.workshopArchive!==void 0;const[archived,setArchived]=useState15(false);const{data,error,reload}=useAppData5(ctx,d=>d.workshops(archived?{archived:true}:void 0),[archived]);const list=(data??[]).filter(w=>archived||scope==="all"||w.scope===scope);return jsxs18("main",{className:"band-workshops-screen",children:[jsxs18("div",{className:"band-workshops-head",children:[jsxs18("div",{children:[jsx18("h1",{children:"\u5DE5\u574A"}),jsx18("p",{className:"sub",children:"\u4E00\u4E2A\u5DE5\u574A\u5B9A\u4E49\u4E00\u7C7B\u5DE5\u4F5C\uFF1A\u7528\u54EA\u4E9B Agent\u3001\u4EA4\u4ED8\u54EA\u4E9B\u4EA7\u7269\u3001\u6309\u4EC0\u4E48\u6D41\u7A0B\u8D70\u3001\u7528\u4EC0\u4E48\u89C6\u56FE\u770B\u3002\u9009\u4E00\u4E2A\u5F00\u59CB\u65B0\u9879\u76EE\uFF0C\u6216\u8005\u590D\u5236\u4E00\u4EFD\u6539\u6210\u4F60\u4EEC\u56E2\u961F\u7684\u3002"})]}),jsxs18("div",{className:"band-workshops-headacts",children:[ctx.app.data.write?.createWorkshop&&jsx18("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:`${SELF}/create`}),children:"\u65B0\u5EFA\u5DE5\u574A"}),canArchive&&jsx18("button",{type:"button",className:"btn ghost sm","aria-pressed":archived,onClick:()=>setArchived(a=>!a),children:archived?"\u8FD4\u56DE\u76EE\u5F55":"\u5DF2\u5F52\u6863"}),!archived&&jsx18(Fragment18,{children:jsx18("div",{className:"seg",role:"group","aria-label":"\u8303\u56F4",children:[["all","\u5168\u90E8"],["public","\u516C\u5F00"],["team","\u6211\u7684\u56E2\u961F"]].map(([k,v])=>jsx18("button",{type:"button","aria-pressed":scope===k,onClick:()=>setScope(k),children:v},k))})})]})]}),error&&jsxs18(ErrorNote13,{retry:reload,children:["\u5DE5\u574A\u76EE\u5F55\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}),!data&&!error&&jsxs18("div",{className:"band-workshops-grid","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx18("div",{className:"band-workshops-card is-skeleton"}),jsx18("div",{className:"band-workshops-card is-skeleton"}),jsx18("div",{className:"band-workshops-card is-skeleton"})]}),data&&list.length===0&&jsxs18("div",{className:"band-workshops-empty",children:[jsx18("b",{children:archived?"\u6CA1\u6709\u5DF2\u5F52\u6863\u7684\u5DE5\u574A":scope==="all"?"\u8FD8\u6CA1\u6709\u5DE5\u574A":scope==="team"?"\u4F60\u7684\u56E2\u961F\u8FD8\u6CA1\u6709\u5DE5\u574A":"\u8FD8\u6CA1\u6709\u516C\u5F00\u7684\u5DE5\u574A"}),jsx18("p",{className:"sub",children:archived?"\u5F52\u6863\u7684\u5DE5\u574A\u4E0D\u5728\u76EE\u5F55\u91CC\uFF0C\u5728\u8FD9\u91CC\u627E\u56DE\uFF1B\u518D\u70B9\u4E00\u6B21\u300C\u5DF2\u5F52\u6863\u300D\u56DE\u5230\u76EE\u5F55\u3002":"\u5DE5\u574A\u5B9A\u4E49\u4E00\u7C7B\u5DE5\u4F5C\uFF1A\u8C01\u6765\u505A\u3001\u5206\u51E0\u4E2A\u9636\u6BB5\u3001\u54EA\u91CC\u8981\u8C01\u6279\u51C6\u3002\u5B9A\u4E49\u5199\u8FDB\u5DE5\u574A\u4ED3\u5E93\u7684 band/workshop.yaml\uFF0C\u53D1\u5E03\u540E\u5C31\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"}),scope!=="all"&&!archived&&jsx18("button",{type:"button",className:"btn sm",onClick:()=>setScope("all"),children:"\u770B\u5168\u90E8\u5DE5\u574A"})]}),list.length>0&&jsx18("div",{className:"band-workshops-grid",children:list.map(w=>jsxs18("button",{type:"button",className:"band-workshops-card",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}}),children:[jsxs18("span",{className:"band-workshops-card-h",children:[jsx18(WorkshopEmblem,{icon:w.icon,size:48}),jsxs18("span",{className:"band-workshops-card-t",children:[jsx18("span",{className:"band-workshops-name",children:w.name}),jsx18("span",{className:"band-workshops-meta",children:[w.maintainer&&`${w.maintainer} \u7EF4\u62A4`,`${w.projectCount} \u4E2A\u9879\u76EE`,SCOPE_TEXT[w.scope]].filter(Boolean).join(" \xB7 ")})]})]}),jsx18("span",{className:"band-workshops-desc",children:w.description}),w.archivedAt!==void 0&&jsx18("span",{className:"chip",children:"\u5DF2\u5F52\u6863"}),modelMissing(w.model,w.userModelKey)?jsx18("span",{className:w.canAdmin?"chip s-stale":"chip",children:"\u5F85\u914D\u7F6E\u6A21\u578B"}):cardStatus(w)&&jsx18("span",{className:cardStatus(w)?.failed?"chip s-failed":"chip",children:cardStatus(w)?.text}),jsx18(FlowLine,{stages:w.stages})]},w.id))})]})}function Missing({ctx,id}){return jsxs18("main",{className:"band-workshops-screen",children:[jsx18(Crumb,{ctx}),jsxs18("div",{className:"band-workshops-missing",children:[jsxs18("h1",{children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id]}),jsx18("p",{className:"sub",children:"\u53EF\u80FD\u8F93\u9519\u4E86\u5730\u5740\u3001\u5DE5\u574A\u5DF2\u7ECF\u5F52\u6863\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"}),jsx18("button",{type:"button",className:"btn",onClick:()=>ctx.app.navigate({page:`${SELF}/workshops`}),children:"\u56DE\u5DE5\u574A\u76EE\u5F55"})]})]})}function useWorkshop(ctx,id){return useAppData5(ctx,d=>d.workshop(id),[id])}function agentLine(a,model,noModel){if(noModel)return"\u672A\u914D\u7F6E\u6A21\u578B \xB7 \u4E0D\u63A5\u5BF9\u8BDD";const role=a.name==="rondo"?"\u6CA1\u6307\u5B9A Agent \u7684\u9636\u6BB5\u90FD\u4EA4\u7ED9\u5B83":a.stages.length?`\u8D1F\u8D23${a.stages.map(x=>`\u300C${x}\u300D`).join("")}`:"\u5728\u5BF9\u8BDD\u91CC @ \u5B83";return model?.model?`\u6A21\u578B ModelGate \xB7 ${model.model} \xB7 ${role}`:role}function agentsOf(stages){const out=new Map([["rondo",{stages:[]}]]);const names=stageNames(stages);for(const[i,s]of stages.entries()){if(s.kind!=="agent")continue;const key=(s.agent??"rondo").toLowerCase()==="rondo"?"rondo":s.agent;const prev=out.get(key)??{stages:[]};const label=prev.label??s.agentLabel;out.set(key,{...label?{label}:{},stages:[...prev.stages,names[i]??s.id]})}return[...out].map(([name,a])=>({name,...a}))}var agentLabel2=(name,label)=>agentDisplayName(name,label);var customAgents=w=>agentsOf(w.workflows[0]?.stages??[]).filter(a=>!isRondoAgent(a.name));var EXPIRY_WARN_DAYS=7;function daysLeft(iso,now){const day=t=>{const d=new Date(t);return new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime()};return Math.round((day(Date.parse(iso))-day(now))/864e5)}function useExpiringConnections(ctx,id,admin){const api=ctx.app.data.write?.teamConnections;const[count,setCount]=useState15(0);useEffect13(()=>{let live=true;setCount(0);if(!api||!admin)return;api.list({scope:"workshop",workshopId:id}).then(rows=>{if(!live)return;const now=Date.now();setCount(rows.filter(r=>r.status==="expired"||r.status==="active"&&r.expiresAt!==null&&daysLeft(r.expiresAt,now)<=EXPIRY_WARN_DAYS).length)},()=>void 0);return()=>{live=false}},[api,id,admin]);return count}function overrideLine(n){const plugin=n.version?`${n.name}@${n.version}`:n.name;const blocked=n.replacementVersion===void 0;const title=blocked?`${plugin} \u5DF2\u88AB\u5E73\u53F0\u5C01\u7981`:`${plugin} \u5DF2\u88AB\u5E73\u53F0\u6362\u6210 ${n.replacementVersion}`;const scope=n.current?"\u5F53\u524D\u7248\u672C\u5728\u7528":"\u53EA\u5728\u65E7\u7248\u672C\u6216\u9884\u89C8\u91CC";if(blocked&&n.current&&n.official===false)return{title,scope,action:"\u6362\u4E00\u4E2A\u7248\u672C\u518D\u53D1\u5E03\uFF1A\u73B0\u5728\u53D1\u5E03\u4F1A\u5931\u8D25\uFF0C\u7528\u5F53\u524D\u7248\u672C\u7684\u9879\u76EE\u91CC\u8FD9\u4E2A\u63D2\u4EF6\u5DF2\u7ECF\u505C\u7528\u3002",needsAction:true};if(blocked&&n.current)return{title,scope,action:"\u8FD9\u662F\u5E73\u53F0\u81EA\u5E26\u7684\u63D2\u4EF6\uFF0C\u5DE5\u574A\u8FD9\u8FB9\u6539\u4E0D\u4E86\uFF0C\u7B49\u5E73\u53F0\u66F4\u65B0\uFF1B\u5728\u90A3\u4E4B\u524D\u53D1\u5E03\u4F1A\u5931\u8D25\u3002",needsAction:false};if(blocked)return{title,scope,action:"\u4E0D\u7528\u5904\u7406\uFF1B\u8FD8\u5728\u7528\u65E7\u7248\u672C\u7684\u9879\u76EE\u91CC\u8FD9\u4E2A\u63D2\u4EF6\u5DF2\u7ECF\u505C\u7528\u3002",needsAction:false};return{title,scope,action:n.current?"\u4E0D\u7528\u5904\u7406\uFF0C\u9879\u76EE\u5DF2\u5728\u7528\u66FF\u6362\u7248\u672C\uFF0C\u4E0B\u6B21\u53D1\u5E03\u4E5F\u4F1A\u81EA\u52A8\u4F7F\u7528\u5B83\u3002":"\u4E0D\u7528\u5904\u7406\uFF1B\u8FD8\u5728\u7528\u65E7\u7248\u672C\u7684\u9879\u76EE\u5DF2\u5728\u7528\u66FF\u6362\u7248\u672C\u3002",needsAction:false}}function OverrideNotices({items}){return jsxs18("section",{className:"band-workshops-overrides","aria-labelledby":"band-workshops-overrides-h",children:[jsx18("h2",{className:"band-workshops-overrides-h",id:"band-workshops-overrides-h",children:"\u5E73\u53F0\u64A4\u6362"}),jsx18("ul",{className:"band-workshops-overrides-list",children:items.map(n=>{const line=overrideLine(n);return jsxs18("li",{className:line.needsAction?"is-action":void 0,children:[jsxs18("span",{className:"band-workshops-overrides-t",children:[line.title,jsxs18("span",{className:"band-workshops-overrides-scope",children:[" \xB7 ",line.scope]})]}),jsxs18("span",{className:"band-workshops-overrides-d",children:["\u539F\u56E0\uFF1A",n.reason]}),jsx18("span",{className:"band-workshops-overrides-d",children:line.action})]},`${n.name}@${n.version??""}:${n.at}`)})})]})}var deployCount=w=>w.releases.filter(r=>r.note===DEPLOY_RELEASE_NOTE).length;function About({ctx,id,projectPage}){const{data:w,error,reload}=useWorkshop(ctx,id);const{data:mine}=useAppData5(ctx,d=>d.projects({workshop:id}),[id]);const expiring=useExpiringConnections(ctx,id,w?.canAdmin===true);const[tab,setTab]=useState15("flow");const[showDeploy,setShowDeploy]=useState15(false);const trials=useAppData5(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const[creatingTrial,setCreatingTrial]=useState15(false);const agentUp=useAgentUpgrade(ctx,id,w?.canAdmin===true&&w.status!=="provisioning"&&w.status!=="failed");if(error&&w===void 0){return jsxs18("main",{className:"band-workshops-screen",children:[jsx18(Crumb,{ctx}),jsxs18(ErrorNote13,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]})}if(w===void 0){return jsx18("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsxs18("div",{className:"band-workshops-detail",children:[jsxs18("div",{className:"band-workshops-stack",children:[jsxs18("div",{className:"band-workshops-whead",children:[jsx18("span",{className:"band-workshops-sk is-tile"}),jsx18("span",{className:"band-workshops-sk is-line"})]}),jsx18("span",{className:"band-workshops-sk is-block"})]}),jsx18("span",{className:"band-workshops-sk is-aside"})]})})}if(w===null)return jsx18(Missing,{ctx,id});if(creatingTrial)return jsx18(NewProject,{ctx,id,projectPage,trial:{onCancel:()=>setCreatingTrial(false)}});const stages=w.workflows[0]?.stages??[];const agents=agentsOf(stages);const peers=agents.map(a=>a.name);const maintainers=ctx.app.data.write?.workshopMaintainers;const visibilityApi=ctx.app.data.write?.workshopVisibility;const archiveApi=w.canAdmin&&w.origin!==void 0?ctx.app.data.write?.workshopArchive:void 0;const archived=w.archivedAt!==void 0;const modelBlock=archived?"\u5DE5\u574A\u5DF2\u5F52\u6863\uFF0C\u590D\u539F\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE":newProjectBlocked(w);const copyBlock=copyBlocked(w);const noModel=modelMissing(w.model,w.userModelKey);const tabs=[["flow","\u6D41\u7A0B"],["art","\u4EA7\u7269\u7C7B\u578B"],["agents","Agent"],["roles","\u89D2\u8272"],["plugins","\u63D2\u4EF6"],...maintainers?[["people","\u7BA1\u7406\u5458"]]:[],["log","\u7248\u672C\u8BB0\u5F55"],...trials.data?.canManage&&!trials.error?[["trials","\u8BD5\u7528\u9879\u76EE"]]:[],...visibilityApi?[["visibility","\u8C01\u80FD\u770B"]]:[],...archiveApi?[["danger","\u5371\u9669\u64CD\u4F5C"]]:[]];const samples=mine??[];return jsxs18("main",{className:"band-workshops-screen",children:[jsx18(Crumb,{ctx,w}),jsxs18("div",{className:"band-workshops-detail",children:[jsxs18("div",{className:"band-workshops-stack",children:[jsxs18("div",{className:"band-workshops-whead",children:[jsx18(WorkshopEmblem,{icon:w.icon,size:64}),jsxs18("div",{children:[jsx18("h1",{className:"band-workshops-name",children:w.name}),jsx18("p",{className:"sub band-workshops-lede",children:w.description}),jsx18(AgentUpgradeLine,{advice:agentUp.advice,onShow:()=>setTab("agents")})]})]}),w.status==="provisioning"&&jsxs18("output",{className:"band-workshops-status",children:[w.origin==="copied"?"\u6B63\u5728\u5EFA\u5DE5\u574A\u4ED3\u5E93\u5E76\u590D\u5236\u5B9A\u4E49":"\u6B63\u5728\u5EFA\u5DE5\u574A\u4ED3\u5E93","\uFF0C\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\uFF0C\u597D\u4E86\u4F1A\u81EA\u52A8\u51FA\u73B0\u3002"]}),w.archivedAt!==void 0&&jsx18(ArchivedNotice,{api:archiveApi,workshop:w.id,onChanged:reload}),w.status==="failed"&&jsxs18(ErrorNote13,{children:["\u5DE5\u574A\u6CA1\u5EFA\u6210\uFF1A",w.error??"\u539F\u56E0\u672A\u77E5"]}),jsx18(ModelNotice,{ctx,w,onChanged:reload}),w.overrides&&jsx18(OverrideNotices,{items:w.overrides}),jsx18("div",{className:"band-workshops-tabs",role:"tablist","aria-label":"\u5DE5\u574A\u5185\u5BB9",children:tabs.map(([k,v])=>jsx18("button",{type:"button",role:"tab",id:`band-workshops-tab-${k}`,"aria-selected":tab===k,"aria-controls":"band-workshops-panel",tabIndex:tab===k?0:-1,onClick:()=>setTab(k),onKeyDown:withImeGuard3(e=>{const i=tabs.findIndex(([t])=>t===k);const next=e.key==="ArrowRight"?tabs[(i+1)%tabs.length]:e.key==="ArrowLeft"?tabs[(i-1+tabs.length)%tabs.length]:void 0;if(next){e.preventDefault();setTab(next[0]);document.getElementById(`band-workshops-tab-${next[0]}`)?.focus()}}),children:v},k))}),jsxs18("div",{id:"band-workshops-panel",role:"tabpanel","aria-labelledby":`band-workshops-tab-${tab}`,className:"band-workshops-panel",children:[tab==="flow"&&jsxs18(Fragment18,{children:[unavailableStageNote(stages)&&jsx18("p",{className:"band-workshops-note",children:unavailableStageNote(stages)}),jsx18(FlowBig,{stages,peers,roles:w.roles,story:flowStory(w),building:repoBuilding(w)})]}),tab==="art"&&jsxs18(Fragment18,{children:[jsx18(Table,{head:["\u4EA7\u7269\u7C7B\u578B","\u5B58\u5728\u54EA"],rows:w.artifactTypes.map((a,i)=>[artifactTypeDisplayName2(a.name,a.label,i),jsx18("span",{className:"chip plain",children:STORAGE_TEXT[a.storage]??a.storage},"s")]),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u58F0\u660E\u4EA7\u7269\u7C7B\u578B\u3002"}),jsxs18("div",{className:"band-workshops-callout",children:[jsx18("b",{children:"\u4EE5\u4EA7\u7269\u4E3A\u4E2D\u5FC3\u3002"}),"\u5DE5\u574A\u4ED3\u5E93\u53EA\u653E\u5B9A\u4E49\uFF1B\u4EA7\u7269\u9ED8\u8BA4\u5B58\u5728 Band\uFF0C\u6BCF\u4E2A\u7248\u672C\u6309\u5185\u5BB9\u54C8\u5E0C\u8BB0\u4E0B\u6765\u3002\u53EA\u6709\u4EE3\u7801\u7C7B\u4EA7\u7269\u5199\u8FDB\u5DE5\u574A\u58F0\u660E\u7684\u76EE\u6807\u4ED3\u5E93\uFF0CBand \u7528\u81EA\u5DF1\u7684 GitLab \u8D26\u53F7\u5EFA\u5206\u652F\u3001\u5F00 MR\uFF0C\u4ECE\u4E0D\u66FF\u4EBA\u5408\u5E76\u3002"]})]}),tab==="agents"&&jsxs18(Fragment18,{children:[noModel&&!w.canAdmin&&jsx18("div",{className:"band-workshops-callout",children:jsxs18("p",{children:[jsx18("b",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0CAgent \u6682\u65F6\u4E0D\u63A5\u5BF9\u8BDD\u3002"}),jsx18(WhoCanConfigure,{ctx,workshop:w.id})]})}),jsx18("ul",{className:"band-workshops-agents",children:agents.map(a=>jsxs18("li",{className:noModel?"band-workshops-agent is-off":"band-workshops-agent",children:[jsx18(Avatar4,{id:a.name,name:agentLabel2(a.name,a.label),agent:true,instrument:instrumentOf(a.name,peers),size:"md",decorative:true}),jsxs18("span",{className:"band-workshops-agent-t",children:[jsxs18("b",{children:[agentLabel2(a.name,a.label),jsxs18("span",{className:"band-workshops-agent-k",children:[" ","\xB7 ",a.name==="rondo"?"\u5DE5\u574A\u7684\u7B2C\u4E00\u4E2A Agent":"\u81EA\u5B9A\u4E49 Agent"]})]}),jsx18("span",{className:"band-workshops-agent-d",children:agentLine(a,noModel||w.userModelKey==="require"?void 0:w.model,noModel)})]}),noModel&&w.canAdmin&&jsx18("span",{className:"band-workshops-agent-x",children:jsx18("button",{type:"button",className:"btn sm",onClick:()=>openModelPage(ctx,w.id),children:"\u53BB\u914D\u7F6E"})})]},a.name))}),jsx18(AgentUpgradeBlock,{advice:agentUp.advice,error:agentUp.error,reload:agentUp.reload,labelOf:slug=>agentLabel2(slug,agents.find(a=>a.name===slug)?.label)}),modelOf(w).state!=="not_provisioned"&&jsx18("p",{className:"band-workshops-note",children:w.userModelKey==="require"?"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u7528\u5EFA\u9879\u76EE\u7684\u4EBA\u81EA\u5DF1\u7684\u6A21\u578B\uFF1B\u5728\u4E2A\u4EBA\u8BBE\u7F6E\u91CC\u914D\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u90FD\u7528\u5DE5\u574A\u7684\u6A21\u578B\uFF1B\u6539\u6A21\u578B\u53BB\u300C\u5DE5\u574A\u8BBE\u7F6E \xB7 \u6A21\u578B\u300D\u3002"}),jsx18("p",{className:"band-workshops-note",children:"\u5DE5\u574A\u81EA\u5DF1\u7684 Agent \u5404\u6709\u4E00\u4E2A\u9ED8\u8BA4\u5934\u50CF\uFF0C\u5BF9\u8BDD\u91CC\u9760\u5934\u50CF\u5206\u6E05\u662F\u8C01\uFF1BRondo \u7684\u5934\u50CF\u53D6\u81EA Band \u6807\u5FD7\u3002"})]}),tab==="roles"&&jsx18(Table,{head:["\u89D2\u8272","\u80FD\u505A\u4EC0\u4E48"],rows:w.roles.map((r,i)=>[roleDisplayName(r.name,r.label,i),r.permissions.map(p=>PERM_TEXT[p]??p).join("\u3001")||"\u53EA\u80FD\u770B"]),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u58F0\u660E\u89D2\u8272\u3002"}),tab==="plugins"&&jsxs18(Fragment18,{children:[jsx18(WorkshopPlugins,{ctx,id:w.id}),w.canAdmin&&w.origin!==void 0&&w.copiedFrom&&jsx18(DetachPlugins,{ctx,workshop:w.id},w.version),w.canAdmin&&w.origin!==void 0&&jsx18(FollowRuns,{ctx,workshop:w.id})]}),tab==="people"&&maintainers&&jsx18(Maintainers,{api:maintainers,directory:directoryFor(ctx.people,q=>maintainers.searchUsers(q)),workshop:w.id,me:ctx.app.member.id}),tab==="trials"&&trials.error&&jsxs18(ErrorNote13,{retry:trials.reload,children:["\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",trials.error]}),tab==="trials"&&!trials.error&&trials.data&&jsx18(TrialProjects,{ctx,data:trials.data,reload:trials.reload,onCreate:()=>setCreatingTrial(true),openProject:project=>{if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:w.id,project}})}}),tab==="danger"&&archiveApi&&jsx18(WorkshopArchiveTab,{api:archiveApi,workshop:w.id,name:w.name,archived:w.archivedAt!==void 0,onChanged:reload}),tab==="visibility"&&visibilityApi&&jsx18(WorkshopVisibilityTab,{api:visibilityApi,directory:directoryFor(ctx.people,q=>visibilityApi.searchUsers(q)),workshop:w.id}),tab==="log"&&jsxs18(Fragment18,{children:[deployCount(w)>0&&jsxs18("label",{className:"choice",children:[jsx18("input",{type:"checkbox",className:"checkbox",checked:showDeploy,onChange:e=>setShowDeploy(e.target.checked)}),"\u663E\u793A\u90E8\u7F72\u5E26\u6765\u7684\u7248\u672C\uFF08",deployCount(w)," \u4E2A\uFF09"]}),jsx18(Table,{head:["\u7248\u672C","\u65E5\u671F","\u6539\u52A8"],rows:w.releases.filter(r=>showDeploy||r.note!==DEPLOY_RELEASE_NOTE).map(r=>[jsxs18("code",{children:["v",r.version]},"v"),jsx18("code",{children:localDay2(r.publishedAt)},"d"),r.note||"\u6CA1\u6709\u5199\u8BF4\u660E"]),empty:"\u8FD8\u6CA1\u6709\u53D1\u5E03\u8BB0\u5F55\u3002"}),jsx18("p",{className:"band-workshops-note",children:"\u8FDB\u884C\u4E2D\u7684\u9879\u76EE\u9489\u4F4F\u521B\u5EFA\u65F6\u7684\u5DE5\u574A\u7248\u672C\uFF0C\u65B0\u7248\u672C\u53EA\u5F71\u54CD\u65B0\u9879\u76EE\u3002"})]})]})]}),jsxs18("aside",{className:"band-workshops-aside","aria-label":"\u5DE5\u574A\u4FE1\u606F",children:[jsx18("button",{type:"button",className:"btn primary",disabled:!ctx.app.data.write||modelBlock!==void 0,title:ctx.app.data.write?modelBlock:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE","aria-describedby":modelBlock?"band-workshops-new-blocked":void 0,onClick:()=>ctx.app.navigate({page:`${SELF}/new`,params:{workshop:w.id}}),children:"\u7528\u8FD9\u4E2A\u5DE5\u574A\u65B0\u5EFA\u9879\u76EE"}),modelBlock&&jsx18("small",{id:"band-workshops-new-blocked",className:"band-workshops-hint",children:modelBlock}),ctx.app.data.write?.createWorkshop&&jsxs18(Fragment18,{children:[jsx18("button",{type:"button",className:"btn",disabled:copyBlock!==void 0,title:copyBlock,"aria-describedby":copyBlock?"band-workshops-copy-blocked":void 0,onClick:()=>ctx.app.navigate({page:`${SELF}/copy`,params:{workshop:w.id}}),children:"\u57FA\u4E8E\u5B83\u65B0\u5EFA\u5DE5\u574A"}),copyBlock&&jsx18("small",{id:"band-workshops-copy-blocked",className:"band-workshops-hint",children:copyBlock})]}),jsx18(WorkshopEditEntry,{ctx,w}),canPublish(w)&&jsx18(PublishRelease,{ctx,w,onDone:reload}),w.canAdmin&&w.status!=="provisioning"&&w.status!=="failed"&&jsx18(WorkshopUpgrade,{ctx,workshop:w.id}),w.canAdmin&&modelOf(w).state!=="not_provisioned"&&(w.userModelKey!=="require"||takeoverNeeded(w))&&ctx.app.data.write?.workshopModel&&jsx18("button",{type:"button",className:"btn",onClick:()=>openModelPage(ctx,id),children:"\u5DE5\u574A\u8BBE\u7F6E \xB7 \u6A21\u578B"}),w.canAdmin&&modelOf(w).state!=="not_provisioned"&&ctx.app.data.write?.workshopSecrets&&jsx18("button",{type:"button",className:"btn",onClick:()=>openSecretsPage(ctx,id),children:"\u5DE5\u574A\u8BBE\u7F6E \xB7 \u5BC6\u94A5"}),w.canAdmin&&ctx.app.data.write?.teamConnections&&jsxs18("button",{type:"button",className:"btn",onClick:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/team-connections",params:{workshop:id}}),children:["\u5DE5\u574A\u8BBE\u7F6E \xB7 \u56E2\u961F\u8FDE\u63A5",expiring>0&&` \xB7 ${expiring} \u4E2A\u5FEB\u8FC7\u671F\u6216\u5DF2\u8FC7\u671F`]}),trials.data?.canManage&&!trials.error&&jsx18("button",{type:"button",className:"btn",onClick:()=>setTab("trials"),children:"\u5DE5\u574A\u8BBE\u7F6E \xB7 \u8BD5\u7528\u9879\u76EE"}),trials.error&&tab!=="trials"&&jsxs18(ErrorNote13,{retry:trials.reload,children:["\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",trials.error]}),jsxs18("dl",{className:"band-workshops-facts",children:[jsx18(ModelFactsRows,{w}),jsx18("dt",{children:"\u7EF4\u62A4"}),jsx18("dd",{children:w.maintainer||"\u6CA1\u6709\u586B\u5199"}),jsx18("dt",{children:"\u53EF\u89C1"}),jsx18("dd",{children:visibilityText(w)}),jsx18("dt",{children:"\u5728\u7528"}),jsxs18("dd",{children:[w.projectCount," \u4E2A\u9879\u76EE"]}),w.docs&&jsxs18(Fragment18,{children:[jsx18("dt",{children:"\u8BF4\u660E"}),jsx18("dd",{children:jsx18("a",{href:w.docs,target:"_blank",rel:"noreferrer",children:"\u600E\u4E48\u7528\u8FD9\u4E2A\u5DE5\u574A"})})]}),w.copiedFrom&&jsx18(CopiedFrom,{ctx,raw:w.copiedFrom})]}),w.canAdmin&&jsxs18("details",{className:"band-workshops-details",children:[jsx18("summary",{children:"\u8BE6\u60C5"}),jsxs18("dl",{className:"band-workshops-facts",children:[jsx18("dt",{children:"\u5B9A\u4E49"}),jsxs18("dd",{children:[jsx18("code",{children:"band/workshop.yaml"})," @ ",jsx18("code",{children:w.ref})]}),jsx18("dt",{children:"\u5730\u5740"}),jsx18("dd",{children:jsxs18("code",{children:["/w/",w.id]})})]})]}),samples.length>0&&projectPage&&jsxs18("div",{className:"band-workshops-mine",children:[jsx18("span",{children:"\u4F60\u5728\u8FD9\u91CC\u7684\u9879\u76EE"}),samples.map(p=>jsx18("button",{type:"button",onClick:()=>ctx.app.navigate({page:projectPage,params:{workshop:w.id,project:p.project.id}}),children:p.project.name},p.project.id))]})]})]})]})}var PLUGIN_PAGE="@kanyun-ai-infra/band-plugins/plugin";function workshopPlugins(list,id){const own=list.filter(p=>p.source!=="official"&&p.workshop?.id===id);return{own,used:list.filter(p=>!own.includes(p))}}function pluginSourceText(p,id){if(p.source==="official")return"\u5B98\u65B9";if(p.workshop?.id===id)return p.source==="shared"?"\u672C\u5DE5\u574A \xB7 \u5DF2\u5171\u4EAB":"\u672C\u5DE5\u574A \xB7 \u6CA1\u5171\u4EAB";return`\u5171\u4EAB \xB7 ${p.workshop?.name??"\u522B\u7684\u5DE5\u574A"}`}function pluginParams(name){const m=/^@([^/]+)\/(.+)$/.exec(name);return m?.[1]&&m[2]?{scope:m[1],name:m[2]}:{scope:"_",name}}function WorkshopPlugins({ctx,id}){const{data,error,reload}=useAppData5(ctx,d=>d.plugins({workshop:id}),[id]);if(error&&!data)return jsxs18(ErrorNote13,{retry:reload,children:["\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});if(!data)return jsx18("span",{className:"band-workshops-sk is-block","aria-busy":"true"});const{own,used}=workshopPlugins(data,id);const row=p=>[p.source==="workshop"?jsxs18("span",{className:"band-workshops-plugin",children:[jsx18("b",{children:p.title}),jsx18("code",{children:p.name})]},"n"):jsxs18("button",{type:"button",className:"band-workshops-plugin band-workshops-link",onClick:()=>ctx.app.navigate({page:PLUGIN_PAGE,params:pluginParams(p.name)}),children:[jsx18("b",{children:p.title}),jsx18("code",{children:p.name})]},"n"),pluginSourceText(p,id),p.source==="official"?jsx18("span",{className:"band-workshops-nowrap",children:"\u5DF2\u9489\u4F4F"},"v"):jsx18("code",{children:p.version},"v")];return jsxs18(Fragment18,{children:[jsx18("h3",{className:"band-workshops-sub",children:"\u672C\u5DE5\u574A\u7684\u63D2\u4EF6"}),jsx18(Table,{head:["\u63D2\u4EF6","\u6765\u6E90","\u7248\u672C"],rows:own.map(row),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u81EA\u5DF1\u7684\u63D2\u4EF6\uFF1A\u7528\u7684\u90FD\u662F\u5B98\u65B9\u7684\u6216\u522B\u7684\u5DE5\u574A\u5171\u4EAB\u7684\u3002"}),jsx18("h3",{className:"band-workshops-sub",children:"\u7528\u5230\u7684\u63D2\u4EF6"}),jsx18(Table,{head:["\u63D2\u4EF6","\u6765\u6E90","\u7248\u672C"],rows:used.map(row),empty:"\u5F53\u524D\u53D1\u5E03\u7684\u7248\u672C\u6CA1\u5728 views \u91CC\u7528\u5230\u5B98\u65B9\u6216\u5171\u4EAB\u7684\u63D2\u4EF6\u3002"}),jsx18("p",{className:"band-workshops-note",children:"\u53EA\u7B97\u5F53\u524D\u53D1\u5E03\u7684\u7248\u672C\uFF1A\u5B98\u65B9\u63D2\u4EF6\u6309 views \u91CC\u5199\u51FA\u6765\u7684\u5E03\u5C40\u3001\u9762\u677F\u3001\u67E5\u770B\u5668\u7B97\uFF1B\u9501\u5B9A\u63D2\u4EF6\u4E0E\u5916\u58F3\u6309\u90E8\u7F72\u65B9\u6848\u88C5\uFF0C\u4E0D\u5217\u5728\u8FD9\u91CC\u3002"})]})}function canPublish(w){return w.canAdmin&&w.origin!==void 0&&(w.status??"ready")==="ready"&&w.repoUrl!==void 0}function publishFailure(e){const err=e;const latest=err?.details?.latestVersion;if(err?.code==="CONFLICT"&&typeof latest==="number")return`\u6709\u4EBA\u521A\u521A\u53D1\u5E03\u4E86 v${latest}\uFF0C\u5237\u65B0\u770B\u770B`;return`\u6CA1\u53D1\u5E03\u6210\u529F\uFF1A${errorText9(e)}`}function PublishRelease({ctx,w,onDone,label="\u53D1\u5E03\u65B0\u7248",primary=false,commit,disabledReason,onConflict,onRefresh,publishingChanged}){const release=ctx.app.data.write?.releaseWorkshop;const upgrade=ctx.app.data.write?.workshopUpgrade;const[open,setOpen]=useState15(false);const[expectedCommit,setExpectedCommit]=useState15();const[conflict,setConflict]=useState15(false);const[refreshing,setRefreshing]=useState15(false);const[note,setNote]=useState15("");const[busy,setBusy]=useState15(false);const[outcome,setOutcome]=useState15(null);const[followProjects,setFollowProjects]=useState15(true);const[projectResult,setProjectResult]=useState15(null);const[projectError,setProjectError]=useState15(null);const publishing=useRef8(busy);publishing.current=busy;const inFlight=useRef8(false);const{dialog,trigger}=useModalDialog({open,onRequestClose:()=>setOpen(false),blocked:busy,initialFocus:"textarea"});if(!release)return null;const next=w.version+1;const previous=w.releases.find(r=>r.version===w.version);const submit=async()=>{if(inFlight.current||conflict||refreshing||disabledReason)return;inFlight.current=true;setBusy(true);publishingChanged?.(true);setOutcome(null);setProjectResult(null);setProjectError(null);const text=note.trim();try{const r=await release({workshop:w.id,...text?{note:text}:{},...expectedCommit?{commit:expectedCommit}:{}});setOutcome({said:r.changed?`\u5DF2\u53D1\u5E03 v${r.version}`:"\u5B9A\u4E49\u6CA1\u6709\u53D8\u5316\uFF0C\u6CA1\u6709\u53D1\u65B0\u7248",...r.yanked?{yanked:r.yanked}:{}});if(r.changed){setNote("");if(followProjects&&upgrade){try{setProjectResult(await upgrade.run(w.id))}catch(e){setProjectError(errorText9(e))}}onDone()}setOpen(false)}catch(e){const failure=e;const changedHead=commit!==void 0&&failure?.code==="CONFLICT"&&(typeof failure.details?.actualCommit==="string"||typeof failure.details?.latestVersion==="number");setOutcome({failed:changedHead?"\u4F60\u6253\u5F00\u4E4B\u540E\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\u3002\u5148\u770B\u4E00\u773C\u66F4\u65B0\u540E\u7684\u5BF9\u6BD4\u518D\u4FDD\u5B58\u3002":publishFailure(e)});if(changedHead){setConflict(true);onConflict?.()}}finally{inFlight.current=false;setBusy(false);publishingChanged?.(false)}};return jsxs18("div",{className:"band-workshops-publish",children:[jsx18("button",{ref:trigger,type:"button",className:primary?"btn primary":"btn","aria-haspopup":"dialog",disabled:busy||!!disabledReason,title:disabledReason,onClick:()=>{setExpectedCommit(commit);setConflict(false);setOutcome(null);setProjectResult(null);setProjectError(null);setFollowProjects(true);setOpen(true)},children:busy?"\u53D1\u5E03\u4E2D\u2026":label}),jsx18("dialog",{ref:dialog,className:"band-workshops-publish-dialog","data-band-layer":open?"dialog":void 0,"aria-label":"\u53D1\u5E03\u65B0\u7248",onCancel:e=>{if(publishing.current)e.preventDefault()},onClose:()=>setOpen(false),children:jsxs18("div",{className:"band-workshops-publish-body",children:[jsx18("h2",{className:"band-workshops-publish-title",children:"\u53D1\u5E03\u65B0\u7248"}),jsxs18("p",{children:["\u628A\u73B0\u5728\u7684\u5B9A\u4E49\u53D1\u5E03\u6210 v",next,"\uFF1B\u65B0\u5EFA\u7684\u9879\u76EE\u7528\u65B0\u7248"]}),jsx18("p",{children:previous?.note?`\u4E0A\u4E00\u7248 v${w.version} \u7684\u8BF4\u660E\uFF1A${previous.note}`:`\u4E0A\u4E00\u7248 v${w.version} \u6CA1\u6709\u5199\u8BF4\u660E\u3002`}),jsx18("p",{children:"\u53D1\u5E03\u540E\u4E0D\u80FD\u64A4\u56DE\uFF1B\u8981\u6539\u5C31\u63A5\u7740\u6539\uFF0C\u518D\u53D1\u4E00\u7248\u3002"}),jsxs18("label",{className:"band-workshops-field",children:[jsxs18("span",{children:["\u8BF4\u660E ",jsx18("em",{className:"band-workshops-opt",children:"\u53EF\u4E0D\u586B\uFF0C\u5199\u8FDB\u7248\u672C\u8BB0\u5F55"})]}),jsx18("textarea",{rows:2,value:note,maxLength:500,readOnly:busy,placeholder:`\u6BD4\u5982\uFF1A\u76F8\u5BF9 v${w.version} \u52A0\u4E86\u914D\u97F3\u9636\u6BB5`,onChange:e=>setNote(e.target.value)})]}),upgrade&&jsxs18("label",{className:"choice",children:[jsx18("input",{type:"checkbox",className:"checkbox",checked:followProjects,disabled:busy,onChange:e=>setFollowProjects(e.target.checked)}),"\u540C\u65F6\u5347\u7EA7\u672C\u5DE5\u574A\u5168\u90E8\u9879\u76EE"]}),busy&&outcome&&"said"in outcome&&jsxs18("p",{"aria-live":"polite",children:[outcome.said,"\uFF0C\u6B63\u5728\u66F4\u65B0\u9879\u76EE\u2026"]}),outcome&&"failed"in outcome&&jsx18("div",{role:"alert",children:jsx18(ErrorNote13,{children:outcome.failed})}),jsxs18("div",{className:"band-workshops-actions",children:[jsx18("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),conflict&&onRefresh&&jsx18("button",{type:"button",className:"btn sm",disabled:busy||refreshing,onClick:async()=>{setRefreshing(true);try{const head=await onRefresh();if(head){setExpectedCommit(head);setConflict(false);setOutcome(null)}}finally{setRefreshing(false)}},children:refreshing?"\u6B63\u5728\u5237\u65B0\u2026":"\u5237\u65B0\u5BF9\u6BD4"}),jsx18("button",{type:"button",className:"btn primary sm","aria-disabled":busy||conflict||refreshing||!!disabledReason,onClick:()=>void submit(),children:busy?"\u53D1\u5E03\u4E2D\u2026":`\u53D1\u5E03 v${next}`})]})]})}),outcome&&"said"in outcome&&jsx18("output",{className:"band-workshops-hint","aria-live":"polite",children:outcome.said}),projectResult&&jsx18("section",{"aria-label":"\u9879\u76EE\u66F4\u65B0\u7ED3\u679C",children:projectResult.total===0?jsx18("p",{children:"\u6CA1\u6709\u9700\u8981\u66F4\u65B0\u7684\u9879\u76EE\u3002"}):jsx18(UpgradeResult,{result:projectResult})}),projectError&&jsx18("div",{role:"alert",children:jsxs18(ErrorNote13,{children:["\u65B0\u7248\u5DF2\u53D1\u5E03\uFF0C\u9879\u76EE\u66F4\u65B0\u6CA1\u5B8C\u6210\uFF1A",projectError]})}),outcome&&"said"in outcome&&outcome.yanked&&jsxs18("div",{className:"band-workshops-hint band-workshops-yanked","aria-live":"polite",children:[jsx18("p",{children:"\u8FD9\u6B21\u53D1\u5E03\u5F15\u7528\u4E86\u5DF2\u64A4\u56DE\u7684\u63D2\u4EF6\u7248\u672C\uFF0C\u7167\u5E38\u53D1\u51FA\u53BB\u4E86\uFF0C\u5EFA\u8BAE\u6362\u6210\u6CA1\u64A4\u56DE\u7684\u7248\u672C\uFF1A"}),jsx18("ul",{children:outcome.yanked.map(y=>jsxs18("li",{children:[jsxs18("code",{children:[y.name,"@",y.version]}),"\uFF1A",y.reason]},`${y.name}@${y.version}`))})]})]})}function flowLayout(stages){const ids=new Set(stages.map(s=>s.id));const ups=new Map(stages.map(s=>[s.id,[...new Set(s.needs.map(n=>n.split(":")[0]??n))].filter(u=>ids.has(u)&&u!==s.id)]));const depth=new Map;const level=(id,seen)=>{const known=depth.get(id);if(known!==void 0)return known;if(seen.has(id))return 0;seen.add(id);const d=Math.max(-1,...(ups.get(id)??[]).map(u=>level(u,seen)))+1;depth.set(id,d);return d};const layers=[];for(const s of stages){const d=level(s.id,new Set);const layer=layers[d];if(layer)layer.push(s.id);else layers[d]=[s.id]}const edges=stages.flatMap(s=>(ups.get(s.id)??[]).map(u=>[u,s.id]));return{layers,edges}}function edgePath(from,to,others){const x1=from.left+(from.right-from.left)/2;const y1=from.bottom;const x2=to.left+(to.right-to.left)/2;const y2=to.top;const lo=Math.min(x1,x2);const hi=Math.max(x1,x2);const between=others.filter(o=>o.top>=y1-1&&o.bottom<=y2+1&&o.right>lo&&o.left<hi+1);if(between.length>0){const band=others.filter(o=>o.bottom>y1&&o.top<y2);const side=Math.max(from.right,to.right,...band.map(o=>o.right))+12;return`M${x1} ${y1} V${y1+10} H${side} V${y2-10} H${x2} V${y2}`}const bend=Math.max((y2-y1)/2,8);return`M${x1} ${y1} C${x1} ${y1+bend} ${x2} ${y2-bend} ${x2} ${y2}`}function useEdgePaths(box,edges){const[paths,setPaths]=useState15({});useLayoutEffect(()=>{const el=box.current;if(!el||edges.length===0)return;const fit=()=>{const origin=el.getBoundingClientRect();const rects=new Map(Array.from(el.querySelectorAll("[data-stage]"),n=>{const r=n.getBoundingClientRect();return[n.dataset.stage??"",{left:r.left-origin.left,top:r.top-origin.top,right:r.right-origin.left,bottom:r.bottom-origin.top}]}));const next={};for(const[from,to]of edges){const a=rects.get(from);const b=rects.get(to);if(!a||!b)continue;const others=[...rects].flatMap(([id,r])=>id===from||id===to?[]:[r]);next[`${from}\u2192${to}`]=edgePath(a,b,others)}setPaths(prev=>JSON.stringify(prev)===JSON.stringify(next)?prev:next)};fit();if(typeof ResizeObserver==="undefined")return;const observer=new ResizeObserver(fit);observer.observe(el);for(const n of Array.from(el.querySelectorAll("[data-stage]")))observer.observe(n);return()=>observer.disconnect()},[box,edges]);return paths}function FlowBig({stages,peers,roles,story,building=false,decorations={},approvalText,executorKnown=true}){const role=r=>{const i=roles.findIndex(x=>x.name===r);return roleDisplayName(r,roles[i]?.label,i)};const box=useRef8(null);const layout=useMemo(()=>flowLayout(stages),[stages]);const paths=useEdgePaths(box,layout.edges);const arrow=useId8();const byId=new Map(stages.map(s=>[s.id,s]));const ordered=stageNames(stages);const names=new Map(stages.map((s,i)=>[s.id,ordered[i]??s.id]));if(stages.length===0)return jsx18("p",{className:"band-workshops-note",children:building?"\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\uFF0C\u6D41\u7A0B\u5EFA\u597D\u4F1A\u81EA\u52A8\u51FA\u73B0\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u6D41\u7A0B\u3002"});const node=s=>{const agent=s.kind==="agent"?s.agent??"rondo":void 0;const doer=agent?executorKnown?`${agentLabel2(agent,s.agentLabel)} \u6765\u505A`:"Agent \u6765\u505A":s.kind==="human"?"\u4EBA\u6765\u505A":s.kind==="external"?s.viaMissing?`${names.get(s.id)??s.id} \xB7 \u6682\u4E0D\u53EF\u7528`:s.viaDisplayName:void 0;return jsxs18("div",{className:`band-workshops-node ${s.kind}${decorations[s.id]?.tag?" is-changed":""}${decorations[s.id]?.removed?" is-removed":""}${decorations[s.id]?.highlight?" is-highlighted":""}`,"data-stage":s.id,"data-edit-stage":decorations[s.id]?.key,tabIndex:decorations[s.id]?-1:void 0,children:[decorations[s.id]?.tag&&jsx18("span",{className:"band-workshop-edit-mark",children:decorations[s.id]?.tag}),jsx18("b",{children:names.get(s.id)??s.id}),doer&&jsxs18("span",{className:"band-workshops-node-a",children:[agent&&executorKnown&&jsx18(Avatar4,{id:agent,name:agentLabel2(agent,s.agentLabel),agent:true,instrument:instrumentOf(agent,peers),size:"xs",decorative:true}),doer]}),jsx18("span",{className:"band-workshops-node-g",children:approvalText?.[s.id]!==void 0?approvalText[s.id]:s.gate?`\u6279\u51C6\uFF1A${gateWho(s.gate.approveBy.map(role),s.gate.mode).trimStart()}`:"\u4E0D\u8BBE\u95E8\u7981"}),s.viaMissing&&jsx18("span",{className:"band-workshops-node-missing",children:"\u8FD9\u4E00\u6B65\u6682\u65F6\u7528\u4E0D\u4E86\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458"}),story.loops[s.id]&&jsx18("span",{className:"band-workshops-node-loop",children:story.loops[s.id]})]})};return jsxs18(Fragment18,{children:[story.start&&jsx18("p",{className:"band-workshops-flow-line",children:story.start}),jsxs18("div",{ref:box,className:"band-workshops-flowbig",children:[jsxs18("svg",{className:"band-workshops-edges","aria-hidden":"true",children:[jsx18("defs",{children:jsx18("marker",{id:arrow,viewBox:"0 0 6 6",refX:"6",refY:"3",markerWidth:"6",markerHeight:"6",orient:"auto",children:jsx18("path",{d:"M0 0 L6 3 L0 6 z"})})}),layout.edges.map(([from,to])=>jsx18("path",{"data-edge":`${from}\u2192${to}`,d:paths[`${from}\u2192${to}`]??"",markerEnd:`url(#${arrow})`},`${from}\u2192${to}`))]}),jsx18("ol",{className:"band-workshops-layers","aria-label":"\u6D41\u7A0B",children:layout.layers.map(ids=>jsx18("li",{children:jsx18("ul",{className:"band-workshops-layer",children:ids.flatMap(id=>{const s=byId.get(id);return s?[jsx18("li",{children:node(s)},id)]:[]})})},ids.join(",")))})]}),story.end&&jsx18("p",{className:"band-workshops-flow-line",children:story.end})]})}function Table({head,rows,empty}){if(rows.length===0)return jsx18("p",{className:"band-workshops-note",children:empty});return jsx18("div",{className:"band-workshops-table",children:jsxs18("table",{children:[jsx18("thead",{children:jsx18("tr",{children:head.map(h=>jsx18("th",{scope:"col",children:h},h))})}),jsx18("tbody",{children:rows.map((r,i)=>jsx18("tr",{children:r.map((c,j)=>jsx18("td",{children:c},j))},i))})]})})}function sentence(text){return text.replace(/\s+([,、;()])/g,"$1").replace(/([,、;()])\s+/g,"$1").trim()}function flowStory(w){const stages=w.workflows[0]?.stages??[];const role=r=>{const i=w.roles.findIndex(x=>x.name===r);return roleDisplayName(r,w.roles[i]?.label,i)};const first=stages.find(s=>s.kind==="agent");const agent=first?agentLabel2(first.agent??"rondo",first.agentLabel):void 0;const loops={};for(const s of stages){if(!s.gate)continue;const who=inline2(s.gate.approveBy.map(role).join("\u3001"));loops[s.id]=sentence(s.kind==="agent"?`${who}\u53EF\u4EE5\u63D0\u4FEE\u6539\u610F\u89C1\uFF0C${inline2(agentLabel2(s.agent??"rondo",s.agentLabel))}\u51FA\u65B0\u7248\u672C\uFF0C\u518D\u6279\u51C6\uFF1B\u4E0D\u6EE1\u610F\u53EF\u9000\u56DE\u91CD\u505A`:s.kind==="human"?s.produces.length>0?`\u4EBA\u5DE5\u63D0\u4EA4\u5185\u5BB9\u540E\uFF0C${who}\u5BA1\u9605\u5E76\u6279\u51C6`:`${who}\u5BA1\u9605\u4E0A\u6E38\u5185\u5BB9\uFF0C\u5BA1\u9605\u5B8C\u6210\u540E\u6279\u51C6`:`${who}\u53EF\u4EE5\u63D0\u4FEE\u6539\u610F\u89C1\uFF0C\u6539\u51FA\u65B0\u7248\u672C\uFF0C\u518D\u6279\u51C6\uFF1B\u4E0D\u6EE1\u610F\u53EF\u9000\u56DE\u91CD\u505A`)}const repo=r=>r.label?`\u5B58\u653E${inline2(r.label)}\u7684\u4ED3\u5E93`:`\u4ED3\u5E93${inline2(r.name)}`;const repos=w.repos??[];const ends=repos.flatMap(r=>(r.release??"mr")==="mr"?[`\u6279\u51C6\u540E\u5F00 MR \u5230${repo(r)}\uFF08Band \u4E0D\u5408\u5E76\uFF09`]:r.release==="direct"?[`${repo(r)}\u6BCF\u56DE\u5408\u76F4\u63A5\u6539\u9ED8\u8BA4\u5206\u652F\uFF0C\u6CA1\u6709 MR`]:[]);const end=ends.length>0?ends.join("\uFF1B"):repos.length>0?void 0:stages.some(s=>s.gate)?"\u6279\u51C6\u5373\u5B9A\u7A3F":agent&&`${inline2(agent)}\u4EA4\u51FA\u6765\u5C31\u662F\u5B9A\u7A3F\uFF0C\u63A5\u7740\u804A\u7740\u6539`;const entry=stages[0];const start=takesNeed(w)?agent&&`\u5EFA\u9879\u76EE\u65F6\u5199\u9700\u6C42\uFF0C${inline2(agent)}\u505A\u7B2C\u4E00\u7248`:entry?.kind==="human"&&entry.produces.length>0?`\u5148${entry.params?"\u586B\u5199":"\u63D0\u4EA4"}\u300C${stageNames(stages)[0]}\u300D\uFF0C\u518D\u6309\u6D41\u7A0B\u7EE7\u7EED`:entry?.kind==="agent"&&agent?`\u5EFA\u9879\u76EE\u540E\uFF0C${inline2(agent)}\u505A\u7B2C\u4E00\u7248`:void 0;return{...start?{start:sentence(start)}:{},loops,...end?{end:sentence(end)}:{}}}function takesNeed(w){return w.requiresInput??w.workflows[0]?.stages.some(s=>s.kind==="agent")??false}function newProjectInput(name,need,withNeed){const body=need.trim();if(withNeed){if(body==="")return{missing:"\u9700\u6C42"};if(body.length>FIRST_MESSAGE_MAX)return{missing:"\u9700\u6C42\u592A\u957F"}}const named=name.trim()||(withNeed?projectNameFromNeed(body):"");if(named==="")return{missing:"\u9879\u76EE\u540D"};return withNeed?{name:named,firstMessage:{body}}:{name:named}}function unavailableStageNote(stages){const names=stageNames(stages).map((name,i)=>stages[i]?.viaMissing?`\u300C${name}\u300D`:null).filter(n=>n!==null);if(names.length===0)return null;return`${names.join("")}\u6682\u65F6\u7528\u4E0D\u4E86\uFF0C\u8D70\u5230\u8FD9\u4E00\u6B65\u4F1A\u505C\u4F4F\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\uFF1B\u524D\u9762\u7684\u6B65\u9AA4\u4E0D\u53D7\u5F71\u54CD\u3002`}function NewProject({ctx,id,projectPage,resume=false,trial}){const{data:w,error,reload}=useWorkshop(ctx,id);const trialInfo=useAppData5(ctx,d=>trial?d.write?.trialProjects?.workshop(id)??Promise.resolve(null):Promise.resolve(null),[id,trial!==void 0]);const draftKey=trial?`trial:${id}`:id;const draftRef=useRef8({taken:false});if(!draftRef.current.taken){const draft=takeDraft(draftKey);draftRef.current=draft?{taken:true,draft}:{taken:true}}const restored=draftRef.current.draft;const restoredAttachments=restored?.attachments??[];const[name,setName]=useState15(restored?.name??"");const[need,setNeed]=useState15(restored?.need??"");const[repoUrls,setRepoUrls]=useState15(restored?.repoUrls??{});const[formValues,setFormValues]=useState15(restored?.formValues??{});const[autoPending,setAutoPending]=useState15(resume&&restored!==void 0);const restoredForm=useRef8(restored?.formValues);const[noKey,setNoKey]=useState15(false);const[provisionFailed,setProvisionFailed]=useState15(false);const submitRef=useRef8(void 0);const[formAcked,setFormAcked]=useState15(()=>new Set(restored?.formAcked??[]));const[formFlagged,setFormFlagged]=useState15(false);const[seededForm,setSeededForm]=useState15(null);const[busy,setBusy]=useState15(false);const[failed,setFailed]=useState15(null);const[flagged,setFlagged]=useState15(false);const needRef=useRef8(null);const nameRef=useRef8(null);const repoInputs=useRef8({});const[repoError,setRepoError]=useState15(null);useEffect13(()=>{if(repoError)repoInputs.current[repoError.repo]?.focus()},[repoError]);const ready=w!==void 0&&w!==null;useEffect13(()=>{if(ready)(needRef.current??nameRef.current)?.focus()},[ready]);const model=useProjectModel(ctx,w?.userModelKey);useEffect13(()=>{if(!autoPending||!ready||model.state.kind==="loading")return;setAutoPending(false);void submitRef.current?.()},[autoPending,ready,model.state.kind]);const{data:projects}=useAppData5(ctx,d=>w?.id==="freeform"?d.projects():Promise.resolve(null),[w?.id]);const focusAfterFill=useRef8(false);useEffect13(()=>{if(!focusAfterFill.current)return;focusAfterFill.current=false;needRef.current?.focus();needRef.current?.setSelectionRange(need.length,need.length)},[need]);const write=ctx.app.data.write;if(error&&w===void 0){return jsx18("main",{className:"band-workshops-screen",children:jsxs18(ErrorNote13,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})})}if(w===void 0){return jsx18("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6"})}if(w===null)return jsx18(Missing,{ctx,id});if(trial&&(trialInfo.data===void 0||trialInfo.error))return jsxs18("main",{className:"band-workshops-screen",children:[trialInfo.error?jsxs18(ErrorNote13,{retry:trialInfo.reload,children:["\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",trialInfo.error]}):jsx18("p",{"aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u2026"}),jsx18("button",{type:"button",className:"btn",onClick:trial.onCancel,children:"\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E"})]});if(trial&&!trialInfo.data?.canManage)return jsxs18("main",{className:"band-workshops-screen",children:[jsx18("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\u3002"}),jsx18("button",{type:"button",className:"btn",onClick:trial.onCancel,children:"\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E"})]});const withNeed=takesNeed(w);const formStage=w.formTarget?w.workflows[0]?.stages.find(s=>s.id===w.formTarget?.stage):void 0;const formSchema=formStage?.params;if(formSchema!==void 0){const key=JSON.stringify(formSchema);if(key!==seededForm){setSeededForm(key);const saved=restoredForm.current;setFormValues(saved&&Object.keys(saved).length>0?saved:schemaInitialValues(formSchema));restoredForm.current=void 0;setFormFlagged(false)}}const input=newProjectInput(name,need,withNeed);const requiredRepos=(w.repos??[]).filter(r=>r.needsUrl);const emptyRepo=requiredRepos.find(r=>!repoUrls[r.name]?.trim());const formMissing=formSchema?missingRequiredFields(formSchema,formValues):[];const formUnacked=formSchema?Object.entries(formSchema.properties).filter(([k,f])=>needsConfirm(f,formValues[k])&&!formAcked.has(k)):[];const modelMissingNote=projectModelMissing(model.state);const inputMissingNote=flagged&&"missing"in input&&input.missing!=="\u9700\u6C42\u592A\u957F"?input.missing==="\u9700\u6C42"?"\u8FD8\u5DEE\u300C\u8981\u505A\u4EC0\u4E48\u300D\u6CA1\u586B":"\u8FD8\u5DEE\u9879\u76EE\u540D\u6CA1\u586B":null;const createDisabled=busy||modelMissingNote!==null||trial!==void 0&&trialInfo.data?.createBlocked!==void 0;const submit=async()=>{if(!write||busy)return;if(trial&&(!write.trialProjects||trialInfo.data?.createBlocked))return;if("missing"in input||emptyRepo){setFlagged(true);if("missing"in input)(input.missing==="\u9879\u76EE\u540D"?nameRef:needRef).current?.focus();else if(emptyRepo)repoInputs.current[emptyRepo.name]?.focus();return}if(formMissing.length>0||formUnacked.length>0){setFormFlagged(true);return}if(modelMissingNote!==null){setFailed(modelMissingNote);return}setBusy(true);setFailed(null);setNoKey(false);setProvisionFailed(false);setRepoError(null);let project;try{const chosen=modelCredentialIdOf(model.state,model.selected);const trialApi=write.trialProjects;if(trial&&!trialApi)throw new Error("\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E");const create=trial&&trialApi?input2=>trialApi.create(input2):input2=>write.createProject(input2);({id:project}=await create({workshop:w.id,...input,...restoredAttachments.length>0&&input.firstMessage?{firstMessage:{...input.firstMessage,attachments:restoredAttachments}}:{},...formSchema?{form:submittedValues(formValues)}:{},...chosen!==void 0?{modelCredentialId:chosen}:{},...chosen===void 0&&provisionConsentOf(model.state)!==null?{modelProvisionConsent:true}:{},...requiredRepos.length?{repos:Object.fromEntries(requiredRepos.map(r=>[r.name,repoUrls[r.name]?.trim()??""]))}:{}}))}catch(e){const repo=errorRepo(e);if(isModelRequired(e))setNoKey(true);else if(isProvisionFailure(e)){setFailed(errorText9(e));setProvisionFailed(true)}else if(repo!==void 0&&requiredRepos.some(r=>r.name===repo))setRepoError({repo,value:repoUrls[repo]?.trim()??"",message:errorText9(e),requestAccessUrl:errorRequestAccessUrl(e)});else setFailed(errorText9(e));setBusy(false);return}if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:w.id,project}});else ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}})};submitRef.current=submit;const goConfigure=()=>{saveDraft(draftKey,{name,need,repoUrls,formValues,formAcked:[...formAcked]});ctx.app.navigate({page:MODELS_FOR_PAGE,params:trial?{}:{workshop:w.id}})};const firstStage=w.workflows[0]?.stages[0];const unavailableNote=unavailableStageNote(w.workflows[0]?.stages??[]);const cancel=()=>trial?trial.onCancel():ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}});const tooLong="missing"in input&&input.missing==="\u9700\u6C42\u592A\u957F";const errId="band-workshops-new-err";const described=failed||noKey?{"aria-describedby":errId}:{};const placeholderName=withNeed&&!("missing"in input)&&name.trim()===""?`\u7559\u7A7A\u5C31\u7528\uFF1A${input.name}`:`\u7ED9\u8FD9\u4E2A${w.name}\u9879\u76EE\u8D77\u4E2A\u540D\u5B57`;return jsxs18("main",{className:"band-workshops-screen",children:[trial?jsx18("button",{type:"button",className:"btn ghost",disabled:busy,onClick:cancel,children:"\u2039 \u5DE5\u574A\u8BBE\u7F6E \xB7 \u8BD5\u7528\u9879\u76EE"}):jsx18(Crumb,{ctx,w,here:"\u65B0\u5EFA\u9879\u76EE"}),jsxs18("div",{children:[jsxs18("h1",{className:"band-workshops-name",children:[jsx18(WorkshopIcon,{icon:w.icon,size:28}),trial?`\u65B0\u5EFA${w.name}\u8BD5\u7528\u9879\u76EE`:`\u65B0\u5EFA${w.name}\u9879\u76EE`]}),jsx18("p",{className:"sub band-workshops-lede",children:withNeed?needLede(w.id):formSchema?"\u586B\u597D\u4E0B\u9762\u7684\u8868\u5355\u3001\u8D77\u4E2A\u540D\u5B57\uFF0C\u5EFA\u597D\u5C31\u5F00\u5DE5\u3002":trial?`\u5148\u8D77\u4E2A\u540D\u5B57\u3002\u5EFA\u597D\u540E${firstStage?`\u4ECE\u300C${stageNames(w.workflows[0]?.stages??[])[0]}\u300D\u5F00\u59CB`:"\u8FDB\u5165\u9879\u76EE"}\u3002`:`\u5148\u8D77\u4E2A\u540D\u5B57\u3002\u5EFA\u597D\u540E\u8FDB\u9879\u76EE${firstStage?`\u4ECE\u300C${firstStage.id}\u300D\u5F00\u59CB`:"\u5F00\u59CB"}\u3002`}),!trial&&w.docs&&jsxs18("p",{className:"band-workshops-note",children:["\u7B2C\u4E00\u6B21\u7528\uFF0C\u5148\u770B"," ",jsx18("a",{href:w.docs,target:"_blank",rel:"noreferrer",children:"\u8FD9\u4E2A\u5DE5\u574A\u600E\u4E48\u7528"}),"\u3002"]})]}),trial&&jsx18("p",{className:"band-workshops-note",children:"\u8BD5\u7528\u9879\u76EE\u4F7F\u7528 test \u69FD\uFF0C\u540E\u7EED\u56DE\u5408\u4F1A\u8DDF\u968F\u8FD9\u4E2A\u69FD\u66F4\u65B0\uFF0C\u7528\u4E8E\u9A8C\u8BC1\u5F85\u4E0A\u7EBF\u7684 Agent\u3002\u7ED3\u675F\u8BD5\u7528\u540E\u4E0D\u80FD\u6539\u56DE\u8BD5\u7528\u3002\u914D\u7F6E\u6A21\u578B\u540E\u8BF7\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E\u7EE7\u7EED\u3002"}),trialInfo.data?.createBlocked&&jsxs18("p",{className:"band-workshops-note",children:["\u6682\u65F6\u4E0D\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF1A",trialInfo.data.createBlocked]}),unavailableNote&&jsx18("p",{className:"band-workshops-note",children:unavailableNote}),write&&withNeed&&showsFreeformIntro({workshop:w.id,projects:projects??void 0,draftEmpty:need.trim()===""})&&jsx18(FreeformIntro,{onPick:text=>{focusAfterFill.current=true;setNeed(text)}}),write?jsxs18("form",{className:"band-workshops-form",noValidate:true,onSubmit:e=>{e.preventDefault();void submit()},onKeyDown:withImeGuard3(e=>commandEnter(e,()=>{if(!createDisabled)void submit()})),children:[withNeed&&jsxs18("label",{className:"band-workshops-field",children:[jsxs18("span",{children:["\u8981\u505A\u4EC0\u4E48 ",jsx18("em",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx18("textarea",{ref:needRef,rows:4,value:need,required:true,disabled:busy,placeholder:w.needExample?`\u6BD4\u5982\u300C${w.needExample}\u300D`:"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48",onChange:e=>setNeed(e.target.value),"aria-invalid":failed||tooLong||flagged&&need.trim()===""?true:void 0,...described})]}),jsxs18("label",{className:"band-workshops-field",children:[jsxs18("span",{children:["\u9879\u76EE\u540D",withNeed?jsx18("em",{className:"band-workshops-opt",children:"\u53EF\u4E0D\u586B\uFF0C\u9ED8\u8BA4\u53D6\u9700\u6C42\u7684\u7B2C\u4E00\u53E5\uFF08\u6700\u591A 30 \u5B57\uFF09"}):null]}),jsx18("input",{ref:nameRef,type:"text",value:name,maxLength:200,required:!withNeed,disabled:busy,placeholder:placeholderName,onChange:e=>setName(e.target.value),"aria-invalid":failed||flagged&&"missing"in input&&input.missing==="\u9879\u76EE\u540D"?true:void 0,...described})]}),formSchema&&jsxs18("div",{className:"band-workshops-params",children:[jsx18("span",{className:"band-workshops-params-title",children:formStage?stageNames(w.workflows[0]?.stages??[])[w.workflows[0]?.stages.indexOf(formStage)??-1]??formStage.id:""}),jsx18(ParamFields,{schema:formSchema,values:formValues,acked:formAcked,disabled:busy,invalidKeys:formFlagged?new Set(formMissing):void 0,onChange:(k,v)=>{setFormValues(cur=>({...cur,[k]:v}));setFormAcked(cur=>{if(!cur.has(k))return cur;const next=new Set(cur);next.delete(k);return next});setFormFlagged(false)},onAck:(k,checked)=>setFormAcked(cur=>{const next=new Set(cur);if(checked)next.add(k);else next.delete(k);return next})}),formMissing.length>0&&jsxs18("span",{className:"band-workshops-params-hint",children:["\u8FD8\u5DEE",formMissing.map(k=>formSchema.properties[k]?.title??k).join("\u3001"),"\u6CA1\u586B"]}),formUnacked.length>0&&jsxs18("span",{className:"band-workshops-params-hint",children:[formUnacked.map(([k])=>formSchema.properties[k]?.title??k).join("\u3001"),"\u9009\u4E86\u8981\u786E\u8BA4\u7684\u503C\uFF0C\u5148\u52FE\u300C\u6211\u5DF2\u77E5\u6653\u300D"]})]}),requiredRepos.map(repo=>{const noteId=`band-workshops-repo-${repo.name}-note`;const rejected=repoError?.repo===repo.name&&repoError.value===(repoUrls[repo.name]?.trim()??"")?repoError.message:void 0;return jsxs18("div",{className:"band-workshops-repo",children:[jsxs18("label",{className:"band-workshops-field",children:[jsxs18("span",{children:["\u4ED3\u5E93\u5730\u5740 ",jsx18("em",{className:"band-workshops-req",children:"\u5FC5\u586B"})," ",jsx18("em",{className:"band-workshops-opt",children:repoFieldHint(repo)})]}),jsx18("input",{ref:el=>{repoInputs.current[repo.name]=el},className:"field",type:"text",value:repoUrls[repo.name]??"",required:true,maxLength:500,disabled:busy,placeholder:REPO_URL_EXAMPLE,"aria-invalid":flagged&&!repoUrls[repo.name]?.trim()||rejected?true:void 0,"aria-describedby":rejected?`${targetRepoErrorId(noteId)} ${noteId}`:noteId,onChange:e=>setRepoUrls(current=>({...current,[repo.name]:e.target.value}))})]}),jsx18(TargetRepoNote,{id:noteId,error:rejected,requestAccessUrl:rejected?repoError?.requestAccessUrl:void 0})]},repo.name)}),noKey?jsx18(NoKeyNotice,{id:errId,onGo:goConfigure}):failed?jsxs18("p",{id:errId,className:"band-workshops-err",role:"alert",children:["\u6CA1\u5EFA\u6210\uFF1A",failed,provisionFailed?jsxs18(Fragment18,{children:[" ",jsx18("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"})]}):null]}):tooLong?jsx18("p",{className:"band-workshops-err",children:"\u9700\u6C42\u592A\u957F\u4E86\uFF0C\u5220\u77ED\u4E00\u4E9B\u518D\u5EFA"}):null,jsx18(ProjectModelField,{state:model.state,selected:model.selected,select:model.select,onConfigure:goConfigure,disabled:busy}),jsxs18("div",{className:"band-workshops-actions",children:[jsx18("button",{type:"button",className:"btn ghost",onClick:cancel,disabled:busy,children:"\u53D6\u6D88"}),!modelMissingNote&&inputMissingNote&&jsx18("output",{id:"band-workshops-project-hint",className:"band-workshops-hint",children:inputMissingNote}),jsx18("button",{type:"submit",className:"btn primary","aria-describedby":!modelMissingNote&&inputMissingNote?"band-workshops-project-hint":void 0,disabled:createDisabled,...modelMissingNote?{title:modelMissingNote}:{},children:busy?"\u6B63\u5728\u65B0\u5EFA\u2026":trial?"\u65B0\u5EFA\u8BD5\u7528\u9879\u76EE":withNeed?"\u65B0\u5EFA\u5E76\u4EA4\u7ED9 Rondo":"\u65B0\u5EFA\u5E76\u6253\u5F00"}),modelMissingNote?jsx18("span",{className:"band-workshops-params-hint",children:modelMissingNote}):createDisabled||inputMissingNote?null:jsxs18("span",{className:"band-workshops-params-hint",children:[SUBMIT_SHORTCUT," \u65B0\u5EFA"]})]})]}):jsx18("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u7ED9\u5199\u6743\u9650\u3002"})]})}function CopiedFrom({ctx,raw}){const at=raw.lastIndexOf("@");const source=at>0?raw.slice(0,at):raw;const{data:list}=useAppData5(ctx,d=>d.workshops(),[]);const name=list?.find(w=>w.id===source)?.name??source;return jsxs18(Fragment18,{children:[jsx18("dt",{children:"\u57FA\u4E8E"}),jsx18("dd",{children:jsx18("button",{type:"button",className:"band-workshops-link",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:source}}),children:name})})]})}export{About,Catalog,FlowBig,NewProject,NewWorkshop,PublishRelease,WORKSHOP_YAML_EXAMPLE,agentLabel2 as agentLabel,agentLine,agentsOf,canPublish,cardStatus,copyBlocked,customAgents,src_default as default,edgePath,flowLayout,flowStory,isRondoAgent,newProjectInput,overrideLine,pluginSourceText,publishFailure,stageNames,takesNeed,unavailableStageNote,workshopIdProblems,workshopPlugins};
24
+ `;function WorkshopYamlExample({note}){const[said,setSaid]=useState4(null);const live=useRef3(true);useEffect5(()=>{live.current=true;return()=>{live.current=false}},[]);const copy=async()=>{try{await navigator.clipboard.writeText(WORKSHOP_YAML_EXAMPLE);if(live.current)setSaid("\u5DF2\u590D\u5236\uFF0C\u7C98\u8FDB\u5DE5\u574A\u4ED3\u5E93\u7684 band/workshop.yaml")}catch{if(live.current)setSaid("\u590D\u5236\u4E0D\u4E86\uFF0C\u8BF7\u624B\u52A8\u9009\u4E2D\u8FD9\u6BB5")}};return jsxs6("div",{className:"band-workshops-yaml",children:[jsxs6("div",{className:"band-workshops-yaml-head",children:[jsx6("span",{children:note}),jsx6("button",{type:"button",className:"btn sm",onClick:()=>void copy(),children:"\u590D\u5236"})]}),jsx6("pre",{className:"band-workshops-yaml-code",children:jsx6("code",{children:WORKSHOP_YAML_EXAMPLE})}),said&&jsx6("output",{className:"band-workshops-yaml-said","aria-live":"polite",children:said})]})}var FLOW_MAX=8e3;function NewWorkshop({ctx,from}){const{data:list}=useAppData2(ctx,d=>d.workshops(),[]);const[copySource,setCopySource]=useState4(from);const[pick,setPick]=useState4(null);const[name,setName]=useState4("");const[id,setId]=useState4("");const[flow,setFlow]=useState4("");const[busy,setBusy]=useState4(false);const[failed,setFailed]=useState4(null);const[pluginChoices,setPluginChoices]=useState4({});const[pluginsReload,setPluginsReload]=useState4(0);const create=ctx.app.data.write?.createWorkshop;const model=useModelDeployment(ctx);const flowOn=model.deployment?.workshopEdit===true&&!!ctx.app.data.write?.workshopEdit;const start=pick??(from||!flowOn?"copy":"describe");const source=start==="copy"?copySource:"";const picked=source!=="";const{data:src,error:srcError}=useAppData2(ctx,d=>source?d.workshop(source):Promise.resolve(null),[source]);const copyPlugins=useCopyPlugins(ctx,source,pluginsReload);const needsModelStep=!(picked&&src?.userModelKey==="require");const twoStep=!!model.deployment&&needsModelStep;const flowText=flow.trim();const flowTooLong=flowText.length>FLOW_MAX;const trimmed=name.trim();const idProblems=id===""?[]:workshopIdProblems(id);const idBad=idProblems.length>0;const blocked=picked&&src?copyBlocked(src):void 0;const sourceOk=!picked||!!src&&srcError===null&&blocked===void 0;const custom=picked&&src?customAgents(src):[];const missingFields=[...start==="describe"&&flowText===""?["\u4F60\u7684\u6D41\u7A0B"]:[],...start==="copy"&&!picked?["\u9009\u5DE5\u574A"]:[],...trimmed===""?["\u5DE5\u574A\u540D"]:[],...id===""?["\u77ED\u540D"]:[]];const pluginsBlocked=!picked||!sourceOk?null:copyPlugins.error!==null?"\u5171\u4EAB\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF0C\u70B9\u300C\u91CD\u8BD5\u300D\u518D\u8BFB":copyPlugins.loading||copyPlugins.plugins===null?"\u6B63\u5728\u8BFB\u53D6\u63D2\u4EF6\u5217\u8868\u2026":null;const canSubmit=!!create&&missingFields.length===0&&!idBad&&!busy&&sourceOk&&pluginsBlocked===null&&!(start==="describe"&&flowTooLong)&&model.deployment!==void 0;const sourceBlocked=!picked||sourceOk?null:blocked??(srcError!==null?"\u6765\u6E90\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF0C\u7A0D\u540E\u518D\u8BD5":src===null?`\u627E\u4E0D\u5230\u5DE5\u574A ${source}\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u7528\u5B83`:"\u6B63\u5728\u8BFB\u53D6\u6E90\u5DE5\u574A\u2026");const submitBlocked=busy||canSubmit?null:(sourceBlocked??pluginsBlocked)!==null?sourceBlocked??pluginsBlocked:missingFields.length>0?`\u8FD8\u5DEE${missingFields.join("\u3001")}\u6CA1\u586B`:null;const submit=async()=>{if(!create||!canSubmit)return;setBusy(true);setFailed(null);let created;const plugins=picked?copyPluginsBody(copyPlugins.plugins??[],pluginChoices):void 0;try{({id:created}=await create({id,name:trimmed,...picked?{copyFrom:source}:{},...start==="describe"?{firstMessage:flowText}:{},...plugins?{plugins}:{}}))}catch(e){setFailed(errorText2(e));setBusy(false);if(picked)setPluginsReload(n=>n+1);return}ctx.app.navigate({page:twoStep?`${SELF}/model`:`${SELF}/about`,params:{workshop:created}})};const back=()=>from?ctx.app.navigate({page:`${SELF}/about`,params:{workshop:from}}):ctx.app.navigate({page:`${SELF}/workshops`});const title=from&&src?`\u57FA\u4E8E\u300C${src.name}\u300D\u65B0\u5EFA\u5DE5\u574A`:"\u65B0\u5EFA\u5DE5\u574A";const sourceName=picked&&src?src.name:"";const startOptions=[...flowOn?[{value:"describe",label:"\u63CF\u8FF0\u6D41\u7A0B\uFF0C\u8BA9 Rondo \u8D77\u8349",line:"\u5199\u4E00\u53E5\u8BDD\uFF0C\u5EFA\u597D\u540E Rondo \u7167\u7740\u6539\u51FA\u7B2C\u4E00\u7248\u6D41\u7A0B\uFF0C\u4F60\u786E\u8BA4\u4E86\u518D\u53D1\u5E03"}]:[],{value:"copy",label:"\u57FA\u4E8E\u5DF2\u6709\u5DE5\u574A\u65B0\u5EFA",line:"\u9009\u4E00\u4E2A\u73B0\u6210\u7684\u5DE5\u574A\u5F53\u5E95\u7A3F\uFF0C\u6539\u6210\u81EA\u5DF1\u56E2\u961F\u7684"},{value:"blank",label:"\u7A7A\u767D\u5DE5\u574A",line:"\u53EA\u6709\u4E00\u4E2A\u9636\u6BB5\uFF0C\u8981\u81EA\u5DF1\u5199\u6D41\u7A0B\u3002\u9002\u5408\u5DF2\u7ECF\u4F1A\u5199 workshop.yaml \u7684\u4EBA"}];const sourceError=!picked?void 0:srcError?`\u6E90\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A${srcError}`:src===null?`\u627E\u4E0D\u5230\u5DE5\u574A ${source}\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u7528\u5B83\u3002`:blocked?`\u4E0D\u80FD\u57FA\u4E8E ${sourceName} \u65B0\u5EFA\uFF1A${blocked}\u3002`:void 0;const sourceHint=!picked?"\u9009\u4E00\u4E2A\u4F60\u80FD\u7528\u7684\u5DE5\u574A\uFF1B\u9009\u597D\u540E\u8FD9\u91CC\u5199\u6E05\u4F1A\u5E26\u8FC7\u6765\u4EC0\u4E48\u3002":src===void 0?"\u6B63\u5728\u8BFB\u53D6\u6E90\u5DE5\u574A\u2026":src&&!sourceError?`\u628A ${src.name} \u5F53\u524D\u53D1\u5E03\u7684\u7B2C ${src.version} \u7248\u5B9A\u4E49\u590D\u5236\u8FC7\u6765\u505A\u5E95\u7A3F\u3002\u4E4B\u540E\u4E24\u8FB9\u5404\u6539\u5404\u7684\uFF0C${src.name} \u518D\u53D1\u7248\u4E0D\u4F1A\u540C\u6B65\u8FC7\u6765${(copyPlugins.plugins??[]).length>0?"\uFF08\u4E0B\u9762\u9009\u300C\u5F15\u7528\u300D\u7684\u5171\u4EAB\u63D2\u4EF6\u9664\u5916\uFF09":""}\u3002\u5BC6\u94A5\u7684\u503C\u4E0D\u590D\u5236\uFF0C\u65B0\u5DE5\u574A\u58F0\u660E\u4E86\u5BC6\u94A5\u65F6\uFF0C\u8BF7\u5230\u65B0\u5DE5\u574A\u7684\u300C\u5DE5\u574A\u8BBE\u7F6E \xB7 \u5BC6\u94A5\u300D\u91CD\u65B0\u586B\u5199\u3002${src.userModelKey==="require"?"\u5B83\u7528\u6210\u5458\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u65B0\u5DE5\u574A\u6CA1\u6709\u914D\u7F6E\u6A21\u578B\u8FD9\u4E00\u6B65\uFF0C\u5EFA\u597D\u76F4\u63A5\u8FDB\u5DE5\u574A\u9875\u3002":""}${custom.length>0?`\u5B83\u6709\u5B9A\u5236 agent ${custom.map(a=>a.name).join("\u3001")}\uFF1A\u6E90\u7801\u4E00\u8D77\u590D\u5236\uFF0C\u4F46\u4E0D\u5171\u7528 ${src.name} \u7684 AgentHub \u9879\u76EE\uFF0C\u7ED9\u65B0\u5DE5\u574A\u5EFA\u597D\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u3001\u914D\u597D\u5BC6\u94A5\u548C MCP \u51ED\u636E\u4E4B\u524D\uFF0C\u7528\u5B83\u4EEC\u7684\u9636\u6BB5\u5F00\u4E0D\u4E86\u5DE5\u3002`:""}`:void 0;return jsxs6("main",{className:"band-workshops-screen band-workshops-new",children:[jsx6(Crumb,{ctx,w:from?src:null,here:from?"\u57FA\u4E8E\u5B83\u65B0\u5EFA":"\u65B0\u5EFA\u5DE5\u574A"}),jsxs6("div",{className:"band-workshops-new-head",children:[twoStep&&jsx6(Steps,{current:1}),jsx6("h1",{className:"band-workshops-name",children:title}),jsx6("p",{className:"sub band-workshops-lede",children:picked&&sourceName?`\u4EE5 ${sourceName} \u73B0\u5728\u53D1\u5E03\u7684\u7248\u672C\u4E3A\u5E95\u7A3F\uFF0C\u5EFA\u597D\u540E\u4F60\u662F\u65B0\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3002${twoStep?"\u4E0B\u4E00\u6B65\u7ED9\u5B83\u914D\u4E0A\u6A21\u578B\u3002":""}`:`\u5EFA\u597D\u540E\u4F60\u662F\u5B83\u7684\u521B\u5EFA\u4EBA\u3002${twoStep?"\u4E0B\u4E00\u6B65\u7ED9\u8FD9\u4E2A\u5DE5\u574A\u914D\u4E0A\u6A21\u578B\uFF0C\u5B83\u624D\u80FD\u5F00\u5DE5\u3002":""}`})]}),create&&model.deployment===void 0&&model.error===null?jsx6("span",{className:"band-workshops-sk is-block","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6"}):create?jsxs6(SettingsForm,{label:title,onSubmit:()=>void submit(),children:[jsx6(SettingsPicks,{label:"\u4ECE\u54EA\u5F00\u59CB",value:start,options:startOptions,disabled:busy,onChange:v=>{setPick(v);setFailed(null)}}),start==="describe"&&jsx6(SettingsField,{label:"\u4F60\u7684\u6D41\u7A0B",required:true,hint:"Rondo \u7167\u8FD9\u53E5\u8BDD\u6539\u51FA\u7B2C\u4E00\u7248\u6D41\u7A0B\uFF0C\u5728\u300C\u6539\u5DE5\u574A\u300D\u9875\u7ED9\u4F60\u770B\u6539\u4E86\u4EC0\u4E48\uFF0C\u6EE1\u610F\u518D\u4FDD\u5B58\u53D1\u5E03\u3002",error:flowTooLong?`\u592A\u957F\u4E86\uFF0C\u6700\u591A ${FLOW_MAX} \u5B57\uFF08\u73B0\u5728 ${flowText.length}\uFF09\u3002`:void 0,count:`${flowText.length} / ${FLOW_MAX}`,over:flowTooLong,children:f=>jsx6("textarea",{...f,className:"field",rows:3,value:flow,disabled:busy,placeholder:"\u6BD4\u5982\uFF1A\u5148\u5199\u6559\u5B66\u8BBE\u8BA1\uFF0C\u518D\u505A\u8BFE\u4EF6\uFF0C\u6700\u540E\u7531\u6559\u7814\u7EC4\u957F\u5BA1\u6821",onChange:e=>setFlow(e.target.value)})}),start==="blank"&&jsxs6("div",{className:"band-workshops-new-help",children:[jsxs6("p",{children:["\u7A7A\u767D\u5DE5\u574A\u53EA\u6709\u4E00\u4E2A\u9636\u6BB5\uFF1ARondo \u7167\u4F60\u7684\u9700\u6C42\u505A\u4E00\u7248\uFF0C\u518D\u4EA4\u7ED9\u4F60\u6279\u51C6\u3002\u5EFA\u597D\u540E\u5728\u5DE5\u574A\u9875\u70B9\u300C\u8BA9 Rondo \u6539\u8FD9\u4E2A\u5DE5\u574A\u300D\u52A0\u9636\u6BB5\u3001\u89D2\u8272\u3001\u8C01\u6279\u51C6\uFF1B\u4E5F\u53EF\u4EE5\u76F4\u63A5\u6539\u5DE5\u574A\u4ED3\u5E93\u91CC\u7684"," ",jsx6("code",{children:"band/workshop.yaml"}),"\uFF0C\u518D\u56DE\u5DE5\u574A\u9875\u70B9\u300C\u53D1\u5E03\u65B0\u7248\u300D\u3002"]}),jsxs6("details",{children:[jsx6("summary",{children:"\u770B\u4E00\u4EFD\u4E24\u9636\u6BB5\u7684 workshop.yaml \u4F8B\u5B50"}),jsxs6("p",{children:["\u5B57\u6BB5\u8BF4\u660E\u89C1"," ",jsx6("a",{href:"/docs/reference/workshop-yaml",target:"_blank",rel:"noreferrer",children:"\u6587\u6863\uFF1Aworkshop.yaml \u7684\u5B57\u6BB5"}),"\u3002"]}),jsx6(WorkshopYamlExample,{note:"\u4E24\u9636\u6BB5\u7684\u4F8B\u5B50\uFF1A\u5148\u751F\u6210\u521D\u7A3F\uFF0C\u6279\u51C6\u540E\u518D\u505A\u5B9A\u7A3F"})]})]}),start==="copy"&&jsxs6(Fragment6,{children:[jsx6(SettingsField,{label:"\u57FA\u4E8E\u54EA\u4E2A\u5DE5\u574A",required:true,hint:sourceHint,error:sourceError,children:f=>jsxs6("select",{...f,className:"field",value:copySource,disabled:busy,onChange:e=>{setCopySource(e.target.value);setPluginChoices({})},children:[jsx6("option",{value:"",disabled:true,children:"\u9009\u4E00\u4E2A\u5DE5\u574A"}),copySource&&!(list??[]).some(w=>w.id===copySource)&&jsx6("option",{value:copySource,children:src?.name??copySource}),(list??[]).map(w=>jsx6("option",{value:w.id,children:w.name},w.id))]})}),picked&&sourceOk&&jsx6(CopyPluginChoices,{plugins:copyPlugins.plugins,error:copyPlugins.error,retry:copyPlugins.retry,choices:pluginChoices,onChange:(n,choice)=>setPluginChoices(c=>({...c,[n]:choice})),disabled:busy})]}),jsx6(SettingsField,{label:"\u5DE5\u574A\u540D",required:true,children:f=>jsx6("input",{...f,className:"field",type:"text",value:name,maxLength:60,disabled:busy,placeholder:sourceName?`\u6BD4\u5982\uFF1A\u6211\u4EEC\u7EC4\u7684 ${sourceName}`:"\u6BD4\u5982\uFF1A\u4E09\u5E74\u7EA7\u6559\u5177",onChange:e=>setName(e.target.value)})}),jsx6(SettingsField,{label:"\u77ED\u540D",required:true,error:idBad?`${idProblems.map(p=>ID_PROBLEM_TEXT[p]).join("\uFF1B")}\u3002`:void 0,hint:"\u8FDB\u5730\u5740\u548C\u4ED3\u5E93\u540D\uFF1A\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\uFF0C2\u201340 \u4F4D\u3002",children:f=>jsxs6("div",{className:"field-group field-host","data-invalid":idBad?"true":void 0,children:[jsx6("span",{className:"field-affix",children:"/w/"}),jsx6("input",{...f,className:"field bare",type:"text",value:id,maxLength:40,disabled:busy,spellCheck:false,autoCapitalize:"off",placeholder:"\u6BD4\u5982\uFF1Agrade3-tools",onChange:e=>setId(e.target.value.trim())})]})}),model.error&&jsxs6(ErrorNote3,{retry:model.reload,children:["\u6A21\u578B\u914D\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",model.error]}),jsxs6(SettingsActions,{end:true,children:[jsx6("button",{type:"button",className:"btn ghost",onClick:back,disabled:busy,children:"\u53D6\u6D88"}),failed&&jsx6(SettingsSaveState2,{failed:`\u6CA1\u5EFA\u6210\uFF1A${failed}`}),jsx6(SettingsSaveState2,{...submitBlocked?{missing:submitBlocked}:{}}),jsx6("button",{type:"submit",className:"btn primary",disabled:!canSubmit,children:busy?"\u6B63\u5728\u65B0\u5EFA\u2026":twoStep?"\u65B0\u5EFA\uFF0C\u4E0B\u4E00\u6B65\u914D\u7F6E\u6A21\u578B":"\u65B0\u5EFA\u5DE5\u574A"})]})]}):jsx6("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u574A\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u7ED9\u8FD9\u4E2A\u6743\u9650\u3002"})]})}function openSecretsPage(ctx,workshop){ctx.app.navigate({page:`${SELF}/secrets`,params:{workshop}})}function goAbout2(ctx,id){ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}})}function SecretsSetup({ctx,id}){const{data:w,error,reload}=useAppData3(ctx,d=>d.workshop(id),[id]);const api=ctx.app.data.write?.workshopSecrets;if(error&&w===void 0)return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx}),jsxs7(ErrorNote4,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(w===void 0)return jsx7("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsx7("span",{className:"band-workshops-sk is-block"})});if(w===null)return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx}),jsxs7("p",{className:"band-workshops-note",children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id,"\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"]})]});const m=modelOf(w);if(!api||m.state==="not_provisioned")return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx7("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsx7("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u8FD9\u4E00\u6B65\uFF1A\u5B83\u4E0D\u8D70 Band \u7684 Agent \u4EE3\u5EFA\uFF0C\u5BC6\u94A5\u5728\u5B83\u81EA\u5DF1\u7684 AgentHub \u9879\u76EE\u91CC\u7BA1\u3002"})]});if(!w.canAdmin)return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx7("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsx7("div",{className:"band-workshops-callout",children:jsx7("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u586B\u5BC6\u94A5\u3002\u8981\u586B\u6216\u8981\u6362\uFF0C\u8BF7\u627E\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u3002"})}),jsx7("div",{className:"band-workshops-actions is-start",children:jsx7("button",{type:"button",className:"btn",onClick:()=>goAbout2(ctx,w.id),children:"\u56DE\u5230\u5DE5\u574A"})})]});return jsx7(SecretsPage,{ctx,w,api})}function SecretsPage({ctx,w,api}){const{data,error,reload}=useAppData3(ctx,()=>api.get(w.id),[api,w.id]);if(error!==null&&data===void 0)return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsxs7(ErrorNote4,{retry:reload,children:["\u5BC6\u94A5\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]});if(data===void 0)return jsxs7("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx7(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsx7("span",{className:"band-workshops-sk is-block"})]});const m=modelOf(w);const blocked=m.hubProject!=="ready";return jsxs7("main",{className:"band-workshops-screen",children:[jsx7(Crumb,{ctx,w,here:"\u5BC6\u94A5"}),jsxs7("div",{children:[jsx7("h1",{className:"band-workshops-name",children:"\u5BC6\u94A5"}),jsxs7("p",{className:"sub band-workshops-lede",children:[w.name,"\u7684 Agent \u8981\u7528\u7684\u5BC6\u94A5\u3002\u8FD9\u91CC\u586B\u7684\u503C Band \u4E0D\u4FDD\u5B58\uFF0C\u76F4\u63A5\u5199\u8FDB\u8FD9\u4E2A\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\uFF1B\u9875\u9762\u4E0A\u53EA\u770B\u5F97\u5230\u300C\u5DF2\u8BBE\u7F6E\u300D\u3002"]}),data.secrets.length>0&&jsx7("p",{className:"sub band-workshops-lede",children:"\u590D\u5236\u5DE5\u574A\u6216\u91CD\u65B0\u521B\u5EFA AgentHub \u9879\u76EE\u540E\uFF0C\u5BC6\u94A5\u9700\u8981\u91CD\u65B0\u586B\u5199\uFF0CBand \u6CA1\u6709\u53EF\u6062\u590D\u7684\u5907\u4EFD\u3002"})]}),data.secrets.length===0?jsxs7(Fragment7,{children:[jsx7("div",{className:"band-workshops-callout",children:jsx7("p",{children:"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u6CA1\u58F0\u660E\u8981\u7528\u5BC6\u94A5\uFF0C\u8FD9\u91CC\u6CA1\u6709\u8981\u586B\u7684\u3002"})}),jsxs7("p",{className:"band-workshops-note",children:["\u8981\u586B\u5BC6\u94A5\uFF0C\u5148\u5728\u5DE5\u574A\u4ED3\u5E93\u7684 ",jsx7("code",{children:"band/agent/agent.yaml"})," \u91CC\u5199 ",jsx7("code",{children:"secrets"}),"\uFF0C\u53D1\u5E03\u4E00\u7248\u4E4B\u540E\u8FD9\u91CC\u5C31\u4F1A\u51FA\u73B0\u3002"]})]}):jsxs7(Fragment7,{children:[m.hasRequest===false&&jsxs7("output",{className:"band-workshops-status",children:[jsx7("span",{className:"chip",children:"\u5F85\u914D\u7F6E\u6A21\u578B"}),"\u3000","\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0C\u4E5F\u6CA1\u6709\u4E1C\u897F\u5728\u6392\u961F\u3002\u5148\u914D\u597D\u6A21\u578B\uFF0CBand \u4F1A\u7ED9\u5B83\u5EFA AgentHub \u9879\u76EE\uFF0C\u4E4B\u540E\u5BC6\u94A5\u624D\u6709\u5730\u65B9\u5199\u3002",jsx7("button",{type:"button",className:"btn sm",onClick:()=>openModelPage(ctx,w.id),children:"\u914D\u7F6E\u6A21\u578B"})]}),m.hubProject==="pending"&&m.hasRequest!==false&&jsxs7("output",{className:"band-workshops-status",children:[jsx7("span",{className:"chip s-running",children:"\u6B63\u5728\u5EFA\u5DE5\u574A\u7684 AgentHub \u9879\u76EE"}),"\u3000","\u5EFA\u597D\u4E4B\u540E\u624D\u80FD\u4FDD\u5B58\uFF0C\u4E00\u822C\u4E0D\u5230\u4E00\u5206\u949F\uFF1B\u597D\u4E86\u8FD9\u4E00\u9875\u4F1A\u8DDF\u7740\u53D8\u3002"]}),m.hubProject==="failed"&&jsxs7("output",{className:"band-workshops-status",children:[jsx7("span",{className:"chip s-failed",children:"AgentHub \u9879\u76EE\u6CA1\u5EFA\u8D77\u6765"}),"\u3000",m.what??m.error??"\u539F\u56E0\u4E0D\u6E05\u695A","\u3002\u5EFA\u597D\u4E4B\u524D\u5B58\u4E0D\u4E86\u5BC6\u94A5\uFF0C\u5148\u56DE\u5DE5\u574A\u9875\u91CD\u8BD5\u4EE3\u5EFA\u3002"]}),jsx7("ul",{className:"band-workshops-secrets",children:data.secrets.map(s=>jsx7(SecretRow,{api,workshop:w.id,name:s.name,set:s.set,pending:s.pending===true,blocked,onSaved:reload},s.name))}),jsx7("div",{className:"band-workshops-callout",children:jsxs7("p",{children:[jsx7("b",{children:"\u503C\u53EA\u4EA4\u7ED9 AgentHub\u3002"}),"Band \u4E0D\u4FDD\u5B58\u5B83\uFF0C\u9875\u9762\u4E0A\u4E5F\u770B\u4E0D\u5230\u5DF2\u586B\u7684\u503C\u3002\u8981\u6362\u5C31\u91CD\u65B0\u586B\u4E00\u6B21\uFF0CAgentHub \u91CC\u90A3\u6761\u4F1A\u88AB\u539F\u5730\u6362\u503C\uFF1B\u8981\u505C\u7528\uFF0C\u53BB AgentHub \u95E8\u6237\u628A\u90A3\u6761\u5F52\u6863\u3002"]})})]})]})}function SecretRow({api,workshop,name,set,pending,blocked,onSaved}){const[open,setOpen]=useState5(false);const[value,setValue]=useState5("");const[phase,setPhase]=useState5({kind:"idle"});const input=useRef4(null);const id=useId4();const hintId=useId4();const saving=phase.kind==="saving";const save=async()=>{if(saving||blocked)return;if(value.trim()===""){setPhase({kind:"missing"});input.current?.focus();return}setPhase({kind:"saving"});try{await api.set(workshop,name,value);setValue("");setOpen(false);setPhase({kind:"idle"});onSaved()}catch(e){setValue("");setPhase({kind:"failed",message:errorText3(e)})}};return jsxs7("li",{className:"band-workshops-secret",children:[jsxs7("div",{className:"band-workshops-secret-line",children:[jsx7("code",{className:"band-workshops-secret-name",children:name}),set?jsx7("span",{className:"chip s-done",children:"\u5DF2\u8BBE\u7F6E"}):pending?jsx7("span",{className:"chip s-queued",children:"\u5DF2\u5199\u5165\uFF0C\u7B49 AgentHub \u751F\u6548"}):jsx7("span",{className:"chip s-stale",children:"\u672A\u8BBE\u7F6E"}),!open&&jsx7("button",{type:"button",className:set?"btn sm":"btn primary sm",disabled:blocked,title:blocked?"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58":void 0,onClick:()=>{setOpen(true);setPhase({kind:"idle"})},children:set?"\u66F4\u6362":"\u586B\u5199"})]}),open&&jsxs7("form",{className:"band-workshops-secret-form",onSubmit:e=>{e.preventDefault();void save()},children:[jsxs7("label",{className:"band-workshops-field",htmlFor:id,children:[jsxs7("span",{children:[name,jsx7("span",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx7("input",{id,ref:input,className:"field mono",type:"password",autoComplete:"off",spellCheck:false,placeholder:set?"\u7C98\u8D34\u65B0\u7684\u503C":"\u7C98\u8D34\u8FD9\u4E2A\u5BC6\u94A5\u7684\u503C",value,disabled:saving,onChange:e=>{setValue(e.target.value);if(phase.kind==="missing")setPhase({kind:"idle"})},"aria-invalid":phase.kind==="missing"?true:void 0,"aria-describedby":hintId}),jsx7("small",{id:hintId,className:phase.kind==="missing"?"band-workshops-err":"band-workshops-hint",children:phase.kind==="missing"?`\u8FD8\u5DEE ${name} \u7684\u503C\u6CA1\u586B`:set?"\u65B0\u503C\u5728\u65B0\u5EFA\u4F1A\u8BDD\u540E\u751F\u6548\uFF0C\u5DF2\u7ECF\u5728\u8DD1\u7684\u4F1A\u8BDD\u4ECD\u7528\u65E7\u503C\u3002":"\u8FD9\u4E2A\u503C Band \u4E0D\u4FDD\u5B58\uFF0C\u53EA\u5F80 AgentHub \u5199\u4E00\u6B21\u3002"})]}),phase.kind==="failed"&&jsxs7("p",{className:"band-workshops-why is-bad",role:"alert",children:["\u6CA1\u4FDD\u5B58\uFF1A",phase.message]}),jsxs7("div",{className:"band-workshops-actions",children:[jsx7("button",{type:"button",className:"btn ghost",disabled:saving,onClick:()=>{setOpen(false);setValue("");setPhase({kind:"idle"})},children:"\u53D6\u6D88"}),jsx7("button",{type:"submit",className:"btn primary",disabled:saving||blocked,title:blocked?"\u5DE5\u574A\u7684 AgentHub \u9879\u76EE\u5EFA\u597D\u540E\u624D\u80FD\u4FDD\u5B58":void 0,children:saving?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"})]})]})]})}var WORKSHOP_LEVELS=[{value:"members",label:"\u53EA\u6709\u5DE5\u574A\u7684\u4EBA",hint:"\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3001\u7BA1\u7406\u5458\u548C\u6210\u5458\u80FD\u770B\u5230\u5B83\u3001\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002"},{value:"users",label:"\u5DE5\u574A\u7684\u4EBA\u548C\u6307\u5B9A\u7684\u4EBA",hint:"\u4E0B\u9762\u540D\u5355\u91CC\u7684\u4EBA\u4E5F\u80FD\u770B\u5230\u8FD9\u4E2A\u5DE5\u574A\u3001\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002"},{value:"everyone",label:"\u516C\u53F8\u5185\u6240\u6709\u4EBA",hint:"\u51FA\u73B0\u5728\u6240\u6709\u4EBA\u7684\u5DE5\u574A\u5217\u8868\u91CC\uFF0C\u8C01\u90FD\u80FD\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3001\u57FA\u4E8E\u5B83\u65B0\u5EFA\u5DE5\u574A\u3002"}];var VIEWERS_MAX=200;function WorkshopVisibilityTab({api,directory,workshop}){const[loaded,setLoaded]=useState6(null);const[canManage,setCanManage]=useState6(false);const[level,setLevel]=useState6("members");const named=usePersonList(directory);const viewers=named.list;const[error,setError]=useState6(null);const[saved,setSaved]=useState6(false);const[busy,setBusy]=useState6(false);const[reload,setReload]=useState6(0);const groupId=useId5();useEffect6(()=>{let active=true;setError(null);void api.get(workshop).then(v=>{if(!active)return;const people=v.viewers??[];setLoaded({visibility:v.visibility,viewers:people});setLevel(v.visibility);named.load(people);setCanManage(v.canManage)}).catch(e=>{if(active)setError(`\u53EF\u89C1\u8303\u56F4\u6CA1\u8BFB\u51FA\u6765\uFF1A${errorText4(e)}`)});return()=>{active=false}},[api,workshop,reload]);const changed=loaded!==null&&(level!==loaded.visibility||level==="users"&&viewers.map(p=>p.id).join("\n")!==loaded.viewers.map(p=>p.id).join("\n"));async function save(){if(busy)return;if(level==="users"&&viewers.length===0)return setError("\u8FD8\u5DEE\u540D\u5355\uFF1A\u9009\u300C\u5DE5\u574A\u7684\u4EBA\u548C\u6307\u5B9A\u7684\u4EBA\u300D\u65F6\u81F3\u5C11\u52A0\u4E00\u4E2A\u4EBA");setBusy(true);setError(null);setSaved(false);try{const v=await api.set(workshop,level==="users"?{visibility:level,viewers:viewers.map(p=>p.id)}:{visibility:level});const people=v.viewers??[];setLoaded({visibility:v.visibility,viewers:people});setLevel(v.visibility);named.load(people);setCanManage(v.canManage);setSaved(true)}catch(e){setError(`\u6CA1\u6709\u4FDD\u5B58\uFF1A${errorText4(e)}`)}finally{setBusy(false)}}return jsxs8("section",{className:"band-workshops-visibility","aria-label":"\u8C01\u80FD\u770B",children:[jsx8("h2",{id:groupId,children:"\u8C01\u80FD\u770B\u8FD9\u4E2A\u5DE5\u574A"}),loaded===null?jsx8(ErrorNote5,{retry:()=>setReload(n=>n+1),children:error}):error&&jsx8("div",{role:"alert",children:jsx8(ErrorNote5,{children:error})}),loaded===null?!error&&jsx8("p",{children:"\u6B63\u5728\u8BFB\u53D6\u53EF\u89C1\u8303\u56F4\u2026"}):jsxs8(Fragment8,{children:[jsx8("div",{className:"band-workshops-levels",role:"radiogroup","aria-labelledby":groupId,children:WORKSHOP_LEVELS.map(l=>jsxs8("label",{className:"band-workshops-level",children:[jsx8("input",{type:"radio",className:"radio",name:`${groupId}-level`,value:l.value,checked:level===l.value,disabled:!canManage||busy,onChange:()=>{setLevel(l.value);setSaved(false);setError(null)}}),jsxs8("span",{children:[jsx8("b",{children:l.label}),jsx8("span",{children:l.hint})]})]},l.value))}),level==="users"&&(canManage?jsx8(ViewerList,{people:viewers,busy,directory,noChain:named.noChain,onLearn:named.onLearn,onChange:next=>{named.onChange(next);setSaved(false);setError(null)}}):jsx8("p",{children:"\u540D\u5355\u53EA\u6709\u5DE5\u574A\u7BA1\u7406\u5458\u770B\u5F97\u5230\u3002"})),jsx8("p",{children:"\u5DE5\u574A\u7684\u8303\u56F4\u4E0D\u7BA1\u9879\u76EE\uFF1A\u6BCF\u4E2A\u9879\u76EE\u5404\u81EA\u8BBE\u7F6E\u8C01\u80FD\u770B\uFF0C\u7F3A\u7701\u53EA\u6709\u9879\u76EE\u6210\u5458\u3002"}),jsx8("p",{children:"\u6539\u4E86\u7ACB\u5373\u751F\u6548\uFF1A\u4E0D\u5728\u8303\u56F4\u91CC\u7684\u4EBA\u4E0B\u4E00\u6B21\u6253\u5F00\u6216\u5237\u65B0\u5C31\u770B\u4E0D\u5230\u8FD9\u4E2A\u5DE5\u574A\u4E86\u3002"}),canManage?jsx8("button",{type:"button",className:"btn primary",disabled:busy||!changed,onClick:()=>void save(),children:busy?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58"}):jsx8("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u53EF\u4EE5\u4FEE\u6539\u3002"}),saved&&jsx8("output",{children:"\u5DF2\u4FDD\u5B58"})]})]})}function ViewerList({people,busy,directory,noChain,onLearn,onChange}){return jsxs8("div",{className:"band-workshops-viewers",children:[jsxs8("span",{className:"band-workshops-viewers-label",children:["\u6307\u5B9A\u7684\u4EBA ",jsxs8("span",{className:"band-workshops-hint",children:["\u5FC5\u586B\uFF0C\u6700\u591A ",VIEWERS_MAX," \u4EBA"]})]}),noChain>0&&jsxs8("p",{className:"band-workshops-hint",children:["\u540D\u5355\u91CC\u6709 ",noChain," ","\u4EBA\u7684\u90E8\u95E8\u6CA1\u67E5\u5230\uFF1A\u52FE\u6574\u4E2A\u90E8\u95E8\u3001\u53D6\u6D88\u6574\u4E2A\u90E8\u95E8\u90FD\u4E0D\u7B97\u4ED6\u4EEC\uFF0C\u8981\u79FB\u51FA\u8BF7\u5728\u540D\u5355\u91CC\u9010\u4E2A\u70B9\u300C\u79FB\u51FA\u300D\u3002"]}),jsx8(PersonPicker,{label:"\u6307\u5B9A\u7684\u4EBA",directory,value:people.map(p=>({id:p.id,name:p.displayName,...p.chain?{chain:p.chain}:{}})),onChange:next=>onChange(next.map(p=>({id:p.id,displayName:p.name,...p.chain?{chain:p.chain}:{}}))),max:VIEWERS_MAX,allowUnknown:true,busy,onLearn,emptyText:"\u8FD8\u6CA1\u6709\u4EBA\uFF0C\u4ECE\u4E0B\u9762\u641C\u4EBA\u6216\u6309\u90E8\u95E8\u52A0"})]})}var splitLines=s=>s===null||s===""?[]:s.replace(/\n$/,"").split("\n");var DIFF_MAX_LINES=800;function lineDiff(before,after){const a=splitLines(before);const b=splitLines(after);if(a.length>DIFF_MAX_LINES||b.length>DIFF_MAX_LINES)return[...a.map(text=>({kind:"del",text})),...b.map(text=>({kind:"add",text}))];const n=a.length;const m=b.length;const lcs=Array.from({length:n+1},()=>new Uint16Array(m+1));for(let i2=n-1;i2>=0;i2--){const row=lcs[i2];const below=lcs[i2+1];for(let j2=m-1;j2>=0;j2--)row[j2]=a[i2]===b[j2]?(below[j2+1]??0)+1:Math.max(below[j2]??0,row[j2+1]??0)}const out=[];let i=0;let j=0;while(i<n&&j<m){if(a[i]===b[j]){out.push({kind:"same",text:a[i]});i++;j++}else if((lcs[i+1]?.[j]??0)>=(lcs[i]?.[j+1]??0))out.push({kind:"del",text:a[i++]});else out.push({kind:"add",text:b[j++]})}while(i<n)out.push({kind:"del",text:a[i++]});while(j<m)out.push({kind:"add",text:b[j++]});return out}function foldDiff(lines,context=2){const keep=lines.map(()=>false);lines.forEach((l,i2)=>{if(l.kind==="same")return;for(let k=Math.max(0,i2-context);k<=Math.min(lines.length-1,i2+context);k++)keep[k]=true});const out=[];let i=0;while(i<lines.length){if(keep[i]){const run=[];while(i<lines.length&&keep[i])run.push(lines[i++]);out.push({kind:"lines",lines:run})}else{let count=0;while(i<lines.length&&!keep[i]){count++;i++}out.push({kind:"fold",count})}}return out}var changeWord={added:"\u65B0\u589E",modified:"\u6539\u4E86",deleted:"\u5220\u6389"};function agentFileTitle(f){const rest=f.path.replace(/^band\/agent\//,"");switch(f.kind){case"instructions":return"Agent \u603B\u8BF4\u660E";case"stage":return`\u9636\u6BB5\u8BF4\u660E\uFF1A${rest.replace(/^stages\//,"").replace(/\.md$/,"")}`;case"skill":return`\u6280\u80FD\uFF1A${rest.replace(/^skills\//,"")}`;case"declaration":return"Agent \u7684\u5BC6\u94A5\u58F0\u660E";default:return rest}}var omittedText={binary:"\u8FD9\u662F\u4E8C\u8FDB\u5236\u6587\u4EF6\uFF0C\u6CA1\u6CD5\u9010\u884C\u5BF9\u6BD4\u3002",too_large:"\u6587\u4EF6\u592A\u5927\uFF0C\u6CA1\u6CD5\u9010\u884C\u5BF9\u6BD4\u3002",too_many:"\u6539\u7684\u6587\u4EF6\u592A\u591A\uFF0C\u8FD9\u91CC\u53EA\u5217\u51FA\u6587\u4EF6\u540D\u3002"};function agentChangeCount(state){return(state?.changes.agentPlugins.length??0)+(state?.changes.agentFiles?.length??0)}function pluginChangeText(c){const who=c.agent==="rondo"?"":`\u300C${c.agent}\u300D`;if(c.before===null)return`${who}\u52A0\u4E86\u63D2\u4EF6 ${c.plugin}\uFF08\u7248\u672C ${c.after}\uFF09`;if(c.after===null)return`${who}\u53BB\u6389\u4E86\u63D2\u4EF6 ${c.plugin}`;return`${who}\u63D2\u4EF6 ${c.plugin} \u7684\u7248\u672C\u4ECE ${c.before} \u6539\u6210 ${c.after}`}function FileDiff({file}){const blocks=file.omitted?[]:foldDiff(lineDiff(file.before,file.after));return jsxs9("article",{className:"band-workshop-edit-file",children:[jsxs9("h4",{children:[jsx9("span",{className:"band-workshop-edit-mark",children:changeWord[file.change]}),agentFileTitle(file)]}),file.omitted?jsx9("p",{className:"band-workshops-note",children:omittedText[file.omitted]}):blocks.length===0?jsx9("p",{className:"band-workshops-note",children:"\u5185\u5BB9\u662F\u7A7A\u7684\u3002"}):jsx9("pre",{className:"band-workshop-edit-lines","aria-label":`${agentFileTitle(file)}\u7684\u6587\u5B57\u6539\u52A8`,children:blocks.map((b,bi)=>b.kind==="fold"?jsxs9("span",{className:"band-workshop-edit-fold",children:["\u2026 ",b.count," \u884C\u6CA1\u53D8"]},`f${bi}`):b.lines.map((l,li)=>jsxs9("span",{className:"band-workshop-edit-line","data-kind":l.kind,children:[jsx9("span",{className:"band-workshop-edit-sign","aria-hidden":"true",children:l.kind==="add"?"\uFF0B":l.kind==="del"?"\uFF0D":"\u3000"}),jsx9("span",{className:"sr-only",children:l.kind==="add"?"\u52A0\u7684\uFF1A":l.kind==="del"?"\u5220\u7684\uFF1A":""}),l.text||" "]},`${bi}/${li}`)))})]})}function AgentChanges({state}){const plugins=state.changes.agentPlugins;const files=state.changes.agentFiles??[];const n=plugins.length+files.length;return jsx9("div",{className:"band-workshop-edit-agent","aria-label":"Agent \u7684\u6539\u52A8",children:n===0?jsx9("p",{className:"band-workshops-note",children:state.agentEditable?"\u8FD8\u6CA1\u6709 Agent \u4FEE\u6539\u3002\u8DDF Rondo \u8BF4 Agent \u8981\u600E\u4E48\u505A\u4E8B\uFF0C\u4F8B\u5982\uFF1A\u5BA1\u6821\u9636\u6BB5\u5148\u5BF9\u7167\u8BFE\u6807\u518D\u7ED9\u610F\u89C1\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u4E0D\u6539 Agent\u3002"}):jsxs9(Fragment9,{children:[jsxs9("h3",{children:[n," \u5904 Agent \u4FEE\u6539"]}),plugins.length>0&&jsxs9(Fragment9,{children:[jsx9("ul",{className:"band-workshop-edit-changes",children:plugins.map(c=>jsx9("li",{children:pluginChangeText(c)},`${c.agent}/${c.plugin}`))}),jsx9("p",{className:"band-workshops-note",children:"\u4FDD\u5B58\u540E\u4F1A\u91CD\u65B0\u51C6\u5907 Agent\uFF0C\u7EA6\u51E0\u5206\u949F\uFF1B\u8FD9\u671F\u95F4\u65B0\u5EFA\u9879\u76EE\u8981\u7B49\u5B83\u51C6\u5907\u597D\uFF0C\u5DF2\u6709\u9879\u76EE\u7684\u4E0B\u4E00\u56DE\u5408\u4E5F\u4F1A\u7528\u65B0\u63D2\u4EF6\u3002Band \u5199\u8FDB Agent \u4ED3\u5E93\u7684\u90A3\u51E0\u4E2A\u6587\u4EF6\uFF08\u63D2\u4EF6\u6E05\u5355\u3001\u8BF4\u660E\u3001\u5B9A\u4E49\uFF09\u91CC\u7684\u624B\u6539\u4F1A\u88AB\u76D6\u6389\u3002"})]}),files.map(f=>jsx9(FileDiff,{file:f},f.path))]})})}function readableFailure(e){const reason=errorText5(e).trim();return e?.code==="CONFLICT"&&!reason?"\u73B0\u5728\u4E0D\u80FD\u8BD5\uFF0C\u5237\u65B0\u540E\u518D\u770B\u770B":reason}var TICKET_RETRY_MS=[2e3,5e3,15e3];var TICKET_RECOVER_MS=3e4;var TICKET_FAIL_ROUNDS=2;var TICKET_SOON_MS=3e4;var MAX_RENEW_MS=10*6e4;var MAX_TIMEOUT_MS=2147483647;function roundOf(state,commit){const done=(state.session?.turns??[]).filter(t=>t.status==="committed"&&t.commit);const i=done.findIndex(t=>t.commit===commit);return i<0?"\u6700\u65B0\u4E00\u4EFD\u4FEE\u6539":`\u7B2C ${i+1} \u8F6E`}function Status({chip,tone,text}){return jsxs10("p",{className:"band-workshop-trial-status",children:[jsx10("span",{className:tone?`chip ${tone}`:"chip",children:chip}),jsx10("span",{children:text})]})}var TRIAL_DESKTOP_W=1e3;function ScaledFrame({src,title}){const[box,setBox]=useState7(null);const[size,setSize]=useState7({w:0,h:0});useEffect7(()=>{if(!box||typeof ResizeObserver==="undefined")return;const watch=new ResizeObserver(([entry])=>setSize({w:Math.round(entry?.contentRect.width??0),h:Math.round(entry?.contentRect.height??0)}));watch.observe(box);return()=>watch.disconnect()},[box]);const scale=size.w>0&&size.w<TRIAL_DESKTOP_W?size.w/TRIAL_DESKTOP_W:1;return jsx10("div",{className:"band-workshop-trial-screen",ref:setBox,children:jsx10("iframe",{src,title,...scale<1?{style:{width:TRIAL_DESKTOP_W,height:size.h/scale,transform:`scale(${scale})`,transformOrigin:"0 0"},"data-scaled":scale.toFixed(2)}:{}})})}function Loading({text}){return jsxs10("output",{className:"band-workshop-trial-rest tuning",children:[jsxs10("svg",{viewBox:"0 0 80 55","aria-hidden":"true",children:[jsx10("line",{x1:"0",y1:"12",x2:"80",y2:"12"}),jsx10("line",{x1:"0",y1:"22",x2:"80",y2:"22"}),jsx10("line",{x1:"0",y1:"32",x2:"80",y2:"32"}),jsx10("line",{x1:"0",y1:"42",x2:"80",y2:"42"}),jsx10("line",{x1:"0",y1:"52",x2:"80",y2:"52"}),jsx10("circle",{cx:"20",cy:"37",r:"4.6",fill:"var(--ink)"}),jsx10("circle",{cx:"40",cy:"27",r:"4.6",fill:"var(--accent)"}),jsx10("circle",{cx:"60",cy:"17",r:"4.6",fill:"var(--ink)"})]}),jsx10("span",{children:text})]})}function Rest({title,children}){return jsxs10("div",{className:"band-workshop-trial-rest rest",children:[jsx10("i",{}),jsx10("b",{children:title}),children]})}function TrialTab({ctx,id,state,own,holder,trials,trialsError,reloadTrials,projectPage,agentPreparing,workshopName,ended,onRestart,onRefresh}){const api=ctx.app.data.write?.workshopEdit;const session=state.session?.id;const[picked,setPicked]=useState7("");const[draft,setDraft]=useState7(emptyDraft);const[failed,setFailed]=useState7(null);const livePreview=own?state.livePreview:void 0;const[ticket,setTicket]=useState7(null);const wantTicket=!!session&&livePreview?.status==="live"&&!!api?.previewTicket;useEffect7(()=>{if(!wantTicket||!session||!api?.previewTicket){setTicket(null);return}const fetchTicket=api.previewTicket;let alive=true;let timer;let expiry;let attempt=0;let rounds=0;const get=()=>{fetchTicket(id,session).then(t=>{if(!alive)return;attempt=0;rounds=0;setTicket(prev=>prev&&prev.session===session&&"entry"in prev?{...prev,open:t.url}:{session,entry:t.url,open:t.url});const left=Date.parse(t.expiresAt)-Date.now();if(expiry)clearTimeout(expiry);if(Number.isFinite(left)&&left>TICKET_SOON_MS)expiry=setTimeout(()=>setTicket({session,failed:true}),Math.min(left,MAX_TIMEOUT_MS));timer=setTimeout(get,Number.isFinite(left)&&left>TICKET_SOON_MS?Math.min(Math.max(15e3,left/2),MAX_RENEW_MS):6e4)},()=>{if(!alive)return;const wait=TICKET_RETRY_MS[attempt++];if(wait!==void 0){timer=setTimeout(get,wait);return}rounds+=1;setTicket(prev=>prev&&"entry"in prev&&rounds<TICKET_FAIL_ROUNDS?prev:{session,failed:true});attempt=0;timer=setTimeout(get,TICKET_RECOVER_MS)})};get();return()=>{alive=false;if(timer)clearTimeout(timer);if(expiry)clearTimeout(expiry)}},[api,id,session,wantTicket]);const mine=ticket?.session===session?ticket:null;const ticketUrl=mine&&"entry"in mine?mine.entry:null;const ticketOpenUrl=mine&&"entry"in mine?mine.open:null;const ticketFailed=mine!==null&&"failed"in mine;const liveBroken=livePreview?.status==="live"&&(!api?.previewTicket||ticketFailed);const pickId=useId6();const[name,setName]=useState7(`${workshopName} \xB7 \u8BD5\u7528`);const[creating,setCreating]=useState7(false);const[createFailed,setCreateFailed]=useState7(null);const create=async()=>{const write=ctx.app.data.write?.trialProjects;if(!write||creating||!name.trim())return;setCreating(true);setCreateFailed(null);try{const{id:created}=await write.create({workshop:id,name:name.trim()});setPicked(created);reloadTrials()}catch(e){setCreateFailed(errorText5(e))}finally{setCreating(false)}};if(ended)return jsxs10(Rest,{title:"\u7F16\u8F91\u5DF2\u7ED3\u675F",children:[jsx10("span",{children:"30 \u5206\u949F\u6CA1\u6709\u52A8\u9759\uFF0C\u6216\u8005\u6709\u4EBA\u70B9\u4E86\u7ED3\u675F\uFF0C\u8FD9\u6B21\u7F16\u8F91\u5DF2\u7ECF\u7ED3\u675F\uFF0C\u9884\u89C8\u4E5F\u5173\u4E86\u3002\u5DF2\u7ECF\u901A\u8FC7\u68C0\u67E5\u7684\u4FEE\u6539\u90FD\u8FD8\u5728\uFF0C\u91CD\u65B0\u5F00\u59CB\u5C31\u80FD\u63A5\u7740\u6539\u3001\u63A5\u7740\u8BD5\u3002"}),jsx10("button",{type:"button",className:"btn primary",onClick:onRestart,children:"\u91CD\u65B0\u5F00\u59CB"})]});if(agentPreparing)return jsx10(Rest,{title:"Agent \u51C6\u5907\u597D\u4E4B\u540E\u5C31\u80FD\u8BD5",children:jsx10("span",{children:"\u5DE5\u574A\u7684 Agent \u8FD8\u5728\u51C6\u5907\uFF0C\u901A\u5E38\u51E0\u5206\u949F\u3002\u597D\u4E86\u4EE5\u540E\u8FD9\u91CC\u81EA\u52A8\u51FA\u73B0\u8BD5\u7528\u9879\u76EE\u548C\u9884\u89C8\uFF0C\u4E0D\u7528\u5237\u65B0\u3002"})});if(trialsError)return jsxs10(ErrorNote6,{retry:reloadTrials,children:["\u8BD5\u7528\u9879\u76EE\u6CA1\u8BFB\u51FA\u6765\uFF1A",trialsError]});if(trials===void 0)return jsx10(Loading,{text:"\u6B63\u5728\u8BFB\u53D6\u8BD5\u7528\u9879\u76EE"});if(own&&trials&&!trials.canManage)return jsx10(Rest,{title:"\u53EA\u6709\u5DE5\u574A\u521B\u5EFA\u4EBA\u6216\u7BA1\u7406\u5458\u80FD\u8BD5\u7528",children:jsx10("span",{children:"\u4F60\u80FD\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u4F46\u8BD5\u7528\u9879\u76EE\u5F52\u5DE5\u574A\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u7BA1\u3002\u4FDD\u5B58\u5E76\u53D1\u5E03\u4E4B\u540E\uFF0C\u53EF\u4EE5\u5728\u65B0\u9879\u76EE\u91CC\u7528\u4E0A\u8FD9\u4E9B\u4FEE\u6539\u3002"})});const projects=trials?.projects??[];if(!projects.length)return own?jsxs10(Rest,{title:"\u8FD8\u6CA1\u6709\u8BD5\u7528\u9879\u76EE",children:[jsx10("span",{children:"\u4FDD\u5B58\u4E4B\u524D\uFF0C\u5728\u8BD5\u7528\u9879\u76EE\u91CC\u770B\u6539\u540E\u7684\u6D41\u7A0B\u548C\u89C6\u56FE\uFF0C\u5E76\u7528\u5B83\u8DD1\u4E00\u56DE\u5408\u3002\u6B63\u5F0F\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\u3002"}),trials?.createBlocked?jsxs10("span",{children:["\u6682\u65F6\u4E0D\u80FD\u5EFA\uFF1A",trials.createBlocked]}):jsxs10("form",{className:"band-workshop-trial-create",onSubmit:e=>{e.preventDefault();void create()},children:[jsx10("label",{htmlFor:`${pickId}-name`,className:"sr-only",children:"\u8BD5\u7528\u9879\u76EE\u540D"}),jsx10("input",{id:`${pickId}-name`,className:"field",value:name,maxLength:80,onChange:e=>setName(e.target.value)}),jsx10("button",{type:"submit",className:"btn primary",disabled:creating||!name.trim(),children:creating?"\u6B63\u5728\u5EFA\u2026":"\u5EFA\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE"})]}),createFailed&&jsxs10(ErrorNote6,{children:["\u6CA1\u5EFA\u6210\uFF1A",createFailed]})]}):jsx10(Rest,{title:"\u8FD8\u6CA1\u6709\u80FD\u770B\u7684\u8BD5\u7528\u9879\u76EE",children:jsxs10("span",{children:[holder??"\u5BF9\u65B9"," \u5EFA\u4E86\u8BD5\u7528\u9879\u76EE\u5E76\u628A\u4F60\u52A0\u8FDB\u53BB\u4E4B\u540E\uFF0C\u8FD9\u91CC\u80FD\u770B\u5230\u6700\u65B0\u4E00\u8F6E\u7684\u9884\u89C8\u3002"]})});const project=projects.find(p=>p.id===picked)??projects[0];if(!project)return null;const preview=state.preview;const shown=state.readyPreview??(preview?.status==="ready"&&preview.hash?{commit:preview.commit,hash:preview.hash}:null);const frame=ticketUrl?{kind:"live",url:ticketUrl,open:ticketOpenUrl??ticketUrl}:shown?{kind:"snapshot",...shown}:{kind:"none"};const shownRound=shown?roundOf(state,shown.commit):"";const latest=preview?.status==="ready"&&preview.commit===state.head;const showingLatest=latest&&shown?.commit===preview?.commit;let status;if(!own)status=jsx10(Status,{chip:"\u53EA\u8BFB",text:`${holder??"\u522B\u4EBA"} \u6B63\u5728\u6539\uFF0C\u4F60\u53EA\u80FD\u770B${shown?`${shownRound}\u4E4B\u540E\u7684\u9884\u89C8`:"\u6700\u65B0\u4E00\u8F6E\u7684\u9884\u89C8"}`});else if(frame.kind==="live")status=jsx10(Status,{chip:"\u5B9E\u65F6\u9884\u89C8",tone:"s-done",text:"\u6539\u52A8\u9A6C\u4E0A\u663E\u793A\u5728\u8FD9\u91CC\uFF1B\u7528\u7684\u662F\u793A\u4F8B\u6570\u636E"});else if(preview?.status==="failed")status=jsx10(Status,{chip:"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7",tone:"s-failed",text:shown?`\u663E\u793A\u7684\u662F${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`:"\u4FEE\u597D\u4E4B\u540E\u8FD9\u91CC\u663E\u793A\u9884\u89C8"});else if(livePreview?.status==="snapshot"||liveBroken)status=jsx10(Status,{chip:"\u4E0A\u4E00\u8F6E\u7684\u9884\u89C8",text:`\u5B9E\u65F6\u9884\u89C8\u6682\u65F6\u4E0D\u53EF\u7528\uFF1A${livePreview?.status==="snapshot"?livePreview.reason:!api?.previewTicket?"\u8FD9\u4E2A\u9875\u9762\u8FD8\u4E0D\u652F\u6301\u5B9E\u65F6\u9884\u89C8\uFF0C\u5148\u663E\u793A\u5FEB\u7167":"\u5165\u573A\u5730\u5740\u6CA1\u53D6\u5230\u6216\u5DF2\u8FC7\u671F\uFF0C\u5148\u663E\u793A\u5FEB\u7167"}`});else if(preview?.status==="building")status=jsx10(Status,{chip:"\u6B63\u5728\u51C6\u5907\u65B0\u4E00\u8F6E\u7684\u9884\u89C8",tone:"s-running",text:shown?`\u5148\u663E\u793A${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`:"\u901A\u5E38\u4E00\u5206\u949F\u5DE6\u53F3"});else if(livePreview?.status==="preparing"||livePreview?.status==="live")status=jsx10(Status,{chip:livePreview.status==="preparing"?"\u6B63\u5728\u51C6\u5907\u5B9E\u65F6\u9884\u89C8":"\u6B63\u5728\u6253\u5F00\u5B9E\u65F6\u9884\u89C8",tone:"s-running",text:livePreview.status==="live"?"\u9A6C\u4E0A\u597D":shown?`\u7EA6\u51E0\u5206\u949F\uFF0C\u5148\u663E\u793A${shownRound}\u4E4B\u540E\u7684\u9884\u89C8`:"\u7EA6\u51E0\u5206\u949F"});else if(showingLatest)status=jsx10(Status,{chip:"\u6700\u65B0",tone:"s-done",text:`\u73B0\u5728\u770B\u7684\u662F${shownRound}\u4E4B\u540E\u7684\u6837\u5B50`});else status=jsx10(Status,{chip:"\u7B49\u5F85\u9884\u89C8",text:"\u4E0B\u4E00\u8F6E\u6539\u5B8C\u3001\u901A\u8FC7\u68C0\u67E5\u540E\uFF0C\u8FD9\u91CC\u663E\u793A\u6539\u540E\u7684\u6837\u5B50"});const src=frame.kind==="live"?frame.url:frame.kind==="snapshot"?`/w/${encodeURIComponent(id)}/${encodeURIComponent(project.id)}?preview=${encodeURIComponent(frame.hash)}`:null;const open=()=>{if(frame.kind==="live"){window.open(frame.open,"_blank","noopener");return}if(src)window.location.assign(src)};const run=own?state.trial??null:null;const running2=run?.status==="running";const tryWhy=!api?.trial?"\u8FD9\u4E2A\u9875\u9762\u8FD8\u4E0D\u80FD\u8BD5\u8DD1":!latest?preview?.status==="failed"?"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7\uFF0C\u4FEE\u597D\u4E4B\u540E\u624D\u80FD\u8BD5":preview?.status==="building"?"\u65B0\u4E00\u8F6E\u7684\u9884\u89C8\u51C6\u5907\u597D\u4E4B\u540E\u624D\u80FD\u8BD5":"\u4E0B\u4E00\u8F6E\u6539\u5B8C\u3001\u901A\u8FC7\u68C0\u67E5\u540E\u624D\u80FD\u8BD5":running2?"\u8FD9\u4E00\u6B21\u8DD1\u5B8C\u4E4B\u540E\u624D\u80FD\u518D\u8BD5":void 0;const pluginNote=state.pluginTrial!==true&&state.changes.agentPlugins.length?"\u63D2\u4EF6\u7684\u6539\u52A8\u4FDD\u5B58\u540E\u624D\u4F1A\u7528\u4E0A\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\u3002":null;return jsxs10("div",{className:"band-workshop-trial",children:[jsxs10("div",{className:"band-workshop-trial-bar",children:[jsxs10("div",{className:"band-workshop-trial-head",children:[status,jsx10("p",{className:"band-workshop-trial-meta",children:"\u8FD9\u662F\u8BD5\u7528\u9879\u76EE\uFF0C\u5728\u8FD9\u91CC\u5199\u7684\u5185\u5BB9\u4F1A\u7559\u5728\u8BD5\u7528\u9879\u76EE\u91CC"})]}),jsxs10("div",{className:"band-workshop-trial-pick",children:[jsx10("label",{htmlFor:pickId,children:"\u8BD5\u7528\u9879\u76EE"}),jsx10("select",{id:pickId,className:"select",value:project.id,onChange:e=>setPicked(e.target.value),children:projects.map(p=>jsx10("option",{value:p.id,children:p.name},p.id))})]})]}),src?jsxs10("div",{className:"band-workshop-trial-frame",children:[jsx10(ScaledFrame,{src,title:`${project.name} \u7684\u9884\u89C8`},src),jsx10("button",{type:"button",className:"btn ghost sm band-workshop-trial-wide",onClick:open,children:"\u5728\u6574\u9875\u6253\u5F00"}),jsx10("button",{type:"button",className:"btn sm band-workshop-trial-narrow",onClick:open,children:"\u6253\u5F00\u9884\u89C8"})]}):preview?.status==="building"?jsx10(Loading,{text:"\u6B63\u5728\u51C6\u5907\u9884\u89C8"}):jsx10(Rest,{title:"\u8FD8\u6CA1\u6709\u9884\u89C8",children:jsx10("span",{children:"\u8DDF Rondo \u8BF4\u4E00\u53E5\uFF0C\u6539\u5B8C\u901A\u8FC7\u68C0\u67E5\u540E\uFF0C\u8FD9\u91CC\u663E\u793A\u6539\u540E\u7684\u6837\u5B50\u3002"})}),own&&jsxs10("section",{className:"band-workshop-trial-try","aria-labelledby":`${pickId}-try`,children:[jsx10("h3",{id:`${pickId}-try`,className:"band-workshop-trial-caption",children:"\u7528\u6539\u540E\u7684\u5B9A\u4E49\u8BD5\u4E00\u6B21"}),run&&jsx10(TrialRunCard,{run,round:roundOf(state,run.commit),pluginTrial:state.pluginTrial===true,ctx,id,projectPage}),failed&&jsxs10(ErrorNote6,{children:["\u6CA1\u8BD5\u6210\uFF1A",failed]}),jsx10(PromptInput,{draft,onDraft:setDraft,variant:"prompt",label:"\u5199\u4E00\u53E5\u9879\u76EE\u9700\u6C42",placeholder:"\u5199\u4E00\u53E5\u9879\u76EE\u9700\u6C42\uFF0C\u4F8B\u5982\uFF1A\u7ED9\u4E09\u5E74\u7EA7\u505A\u4E00\u8282\u5206\u6570\u5BFC\u5165\u8BFE",submitText:"\u8BD5\u4E00\u6B21",submitLabel:"\u8BD5\u4E00\u6B21",busy:!!tryWhy,notice:tryWhy??pluginNote??void 0,hint:`\u5728\u300C${project.name}\u300D\u91CC\u65B0\u8D77\u4E00\u4E2A\u6D41\u7A0B\uFF0C\u6B63\u5F0F\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD`,onSubmit:async d=>{const hash=preview?.hash;if(!api?.trial||!session||!hash||tryWhy)return false;setFailed(null);try{await api.trial(id,session,{projectId:project.id,previewHash:hash,message:d.text.trim()});await onRefresh();return true}catch(e){setFailed(readableFailure(e));return false}}})]})]})}function TrialRunCard({ctx,id,run,round,projectPage,pluginTrial}){const pluginsPending=run.pluginsPending===true;const chip=run.status==="failed"?{text:"\u56DE\u5408\u5931\u8D25",tone:"s-failed"}:pluginsPending?{text:"\u6CA1\u5E26\u4E0A\u63D2\u4EF6\u6539\u52A8",tone:""}:run.status==="running"?{text:"\u56DE\u5408\u8FDB\u884C\u4E2D",tone:"s-running"}:{text:"\u5DF2\u8DD1\u5B8C",tone:"s-done"};return jsxs10("article",{className:"band-workshop-trial-run",children:[jsxs10("header",{children:[jsxs10("b",{children:["\u8BD5\u4E00\u6B21 \xB7 ",round,"\u4E4B\u540E\u7684\u5B9A\u4E49"]}),jsx10("span",{className:chip.tone?`chip ${chip.tone}`:"chip",children:chip.text})]}),pluginsPending&&jsx10("p",{children:pluginTrial?"\u63D2\u4EF6\u7684\u6539\u52A8\u8FD8\u5728\u51C6\u5907\uFF08\u7EA6\u51E0\u5206\u949F\uFF09\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\uFF1B\u6D41\u7A0B\u3001\u8BF4\u660E\u3001skill \u548C\u89C6\u56FE\u90FD\u662F\u6539\u540E\u7684\u3002\u51C6\u5907\u597D\u4E4B\u540E\u518D\u8BD5\u4E00\u6B21\u5C31\u4F1A\u5E26\u4E0A\u3002":"\u63D2\u4EF6\u7684\u6539\u52A8\u4FDD\u5B58\u540E\u624D\u4F1A\u7528\u4E0A\uFF0C\u8FD9\u6B21\u7528\u7684\u662F\u73B0\u5728\u7684 Agent\uFF1B\u6D41\u7A0B\u3001\u8BF4\u660E\u3001skill \u548C\u89C6\u56FE\u90FD\u662F\u6539\u540E\u7684\u3002"}),jsxs10("p",{className:"band-workshop-trial-meta",children:["\u5728\u300C",run.projectName,"\u300D\u91CC\u65B0\u8D77\u4E86\u4E00\u4E2A\u6D41\u7A0B",run.status==="running"?"\uFF0C\u56DE\u5408\u8FDB\u884C\u4E2D":""]}),projectPage&&jsx10("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:projectPage,params:{workshop:id,project:run.projectId}}),children:"\u6253\u5F00\u8FD9\u4E2A\u6D41\u7A0B"})]})}var TRIAL_UNFOLDED_MIN=400+28+24+TRIAL_DESKTOP_W;var readable=text=>text.replace(/默认分支|分支|Revision|槽位/g,"\u5B9A\u4E49").replace(/提交/g,"\u8BB0\u5F55");var running=t=>["queued","running","validating"].includes(t.status);var codeOf=e=>e?.code;var missing=e=>["NOT_FOUND","FORBIDDEN"].includes(codeOf(e)??"");var EDIT_STATE_POLL_MS=2e3;function editStatePollMs(state){return state?.livePreview?.status==="preparing"?LIVE_PREVIEW_POLL_MS.starting:EDIT_STATE_POLL_MS}function editBlocked(state){switch(state.blocked?.code){case"builtin":return"\u8FD9\u4E2A\u5DE5\u574A\u662F\u5E73\u53F0\u81EA\u5E26\u7684\uFF0C\u5148\u57FA\u4E8E\u5B83\u65B0\u5EFA\u4E00\u4E2A\u5DE5\u574A\u518D\u6539\u3002";case"model_key":return"\u8FD9\u4E2A\u5DE5\u574A\u8981\u7528\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u4F60\u8FD8\u6CA1\u914D\u3002";case"not_ready":return"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\u3002";case"provision":return`\u5DE5\u574A\u7684 Agent \u6CA1\u51C6\u5907\u597D\uFF1A${readable(state.blocked.message)}`;case"not_band_repo":return"\u8FD9\u4E2A\u5DE5\u574A\u6682\u65F6\u4E0D\u80FD\u5728\u754C\u9762\u4E0A\u6539\uFF0C\u8BF7\u57FA\u4E8E\u5B83\u65B0\u5EFA\u4E00\u4E2A\u5DE5\u574A\u518D\u6539\u3002";case"ref_mismatch":return"\u5DE5\u574A\u7684\u6765\u6E90\u8BBE\u7F6E\u9700\u8981\u7BA1\u7406\u5458\u8C03\u6574\uFF0C\u6682\u65F6\u4E0D\u80FD\u5728\u8FD9\u91CC\u6539\u3002";case"unsupported_files":return"\u5DE5\u574A\u91CC\u6709\u4E0D\u652F\u6301\u7684\u6587\u4EF6\uFF0C\u8BF7\u5728\u5DE5\u574A\u4ED3\u5E93\u4E2D\u5904\u7406\u540E\u518D\u6539\u3002";case"disabled":return"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002";case"forbidden":return"\u4F60\u6CA1\u6709\u6539\u8FD9\u4E2A\u5DE5\u574A\u7684\u6743\u9650\u3002";case"first_message_pending":return"\u521B\u5EFA\u4EBA\u65B0\u5EFA\u65F6\u5199\u7684\u6D41\u7A0B\u63CF\u8FF0\u8FD8\u6CA1\u53D1\u51FA\uFF0C\u7B49\u521B\u5EFA\u4EBA\u5148\u5F00\u59CB\u3002";case"locked":return`${state.session?.holder.name??"\u5176\u4ED6\u4EBA"} \u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A`;default:return void 0}}function UnsupportedFiles({state}){const files=state.changes.unsupportedFiles;if(!files?.length)return null;return jsx11("ul",{className:"band-workshop-edit-issues","aria-label":"\u4E0D\u652F\u6301\u7684\u6587\u4EF6",children:files.map(file=>jsxs11("li",{children:[jsx11("code",{children:file.path}),"\uFF1A",file.message]},file.path))})}function WorkshopEditEntry({ctx,w,primary=false,onUsable}){const api=ctx.app.data.write?.workshopEdit;const[state,setState]=useState8(null);const[error,setError]=useState8(null);const[concluded,setConcluded]=useState8(false);const load=useCallback2(()=>{if(!api||!w.canAdmin)return;let alive=true;api.get(w.id).then(s=>{if(alive){setState(s);setError(null);setConcluded(true)}},e=>{if(alive){setConcluded(true);setState(null);setError(missing(e)?null:`\u6539\u5DE5\u574A\u7684\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause2(e,"\u70B9\u91CD\u8BD5"))}`)}});return()=>{alive=false}},[api,w]);useEffect8(()=>load(),[load]);const usable=!!api&&w.canAdmin&&!!state&&state.blocked?.code!=="disabled"&&state.blocked?.code!=="forbidden"&&state.blocked?.code!=="locked"&&!editBlocked(state);const settled=!api||!w.canAdmin||concluded;useEffect8(()=>{if(settled)onUsable?.(usable)},[settled,usable,onUsable]);if(!api||!w.canAdmin||state?.blocked?.code==="disabled"||state?.blocked?.code==="forbidden")return null;if(!state)return error?jsx11(ErrorNote7,{retry:load,children:error}):null;const locked=state.blocked?.code==="locked";const why=editBlocked(state);return jsxs11("div",{className:"band-workshop-edit-entry",children:[jsx11("button",{type:"button",className:primary?"btn primary":"btn",disabled:!!why&&!locked,title:why,onClick:()=>{ctx.app.navigate({page:`${SELF}/edit`,params:{workshop:w.id}})},children:locked?`\u770B ${state.session?.holder.name??"\u5BF9\u65B9"} \u6B63\u5728\u6539\u7684\u5185\u5BB9`:"\u8BA9 Rondo \u6539\u8FD9\u4E2A\u5DE5\u574A"}),why&&jsx11("small",{className:"band-workshops-hint",children:why}),jsx11(UnsupportedFiles,{state}),state.blocked?.code==="model_key"&&jsx11("button",{className:"btn ghost sm",type:"button",onClick:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/models"}),children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"}),!state.agentEditable&&!why&&jsx11("small",{className:"band-workshops-hint",children:"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u53EA\u80FD\u6539\u6D41\u7A0B\u548C\u89C6\u56FE\uFF1BAgent \u7684\u8BF4\u660E\u3001\u6280\u80FD\u548C\u63D2\u4EF6\u7167\u65E7\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u6539\u3002"})]})}var CHANGE_LABEL={added:"\u65B0\u589E",modified:"\u6539\u4E86",deleted:"\u5220\u6389"};function viewFileGroups(files){const groups=new Map;for(const file of files){const parts=file.path.split("/");const plugin=parts.length>3?parts[2]??"":"";const list=groups.get(plugin);if(list)list.push(file);else groups.set(plugin,[file])}return[...groups.entries()].sort(([a],[b])=>a.localeCompare(b)).map(([plugin,list])=>({plugin:plugin||"\u5171\u4EAB\u6587\u4EF6",files:list}))}function flowChangeRows(diff,roles=[],artifactTypes=[]){if(!diff)return[];const roleName=(name,side)=>diff.roles.find(r=>r.role===name)?.label[side]??roles.find(r=>r.name===name)?.label??name;const value=(v,side)=>v===null?"\u65E0":Array.isArray(v)?v.map(x=>side?roleName(x,side):x).join("\u3001")||"\u65E0":v;const fieldNames={label:"\u540D\u5B57",kind:"\u7531\u8C01\u6765\u505A",agent:"Agent",needs:"\u524D\u9762\u7684\u6B65\u9AA4",produces:"\u4EA7\u7269",approveBy:"\u6279\u51C6\u4EBA",confirmBy:"\u786E\u8BA4\u4EBA"};const types=[...artifactTypes].sort((a,b)=>a.name.localeCompare(b.name));const needsValue=(v,side,workflow)=>{if(v===null)return"\u65E0";return(Array.isArray(v)?v:[v]).map(need=>{const partial=need.endsWith("#partial");const[stage="",type]=need.replace(/#partial$/,"").split(":");const stages=diff.workflows[workflow]?.[side]??[];const index=stages.findIndex(s=>s.id===stage);const name=stageDisplayName(stage,stages[index]?.label,index);const typeIndex=types.findIndex(t=>t.name===type);return`${name}${type?` \xB7 ${artifactTypeDisplayName(type,types[typeIndex]?.label,typeIndex)}`:""}${partial?"\uFF08\u90E8\u5206\uFF09":""}`}).join("\u3001")||"\u65E0"};return[...diff.stages.flatMap(s=>{const key=`${s.workflow}/${s.stage}`;if(s.change!=="changed")return[{key,workflow:s.workflow,stage:s.stage,text:`${s.change==="added"?"\u65B0\u589E":"\u5220\u6389"}\u9636\u6BB5\u300C${s.label}\u300D`}];const who=s.fields.filter(f=>f.field==="approveBy"||f.field==="confirmBy");const other=s.fields.filter(f=>f.field!=="approveBy"&&f.field!=="confirmBy");return[...other.length?[{key,workflow:s.workflow,stage:s.stage,text:`\u6539\u4E86\u9636\u6BB5\u300C${s.label}\u300D\uFF1A${other.map(f=>`${fieldNames[f.field]}\u4ECE\u300C${f.field==="needs"?needsValue(f.before,"before",s.workflow):value(f.before)}\u300D\u6539\u6210\u300C${f.field==="needs"?needsValue(f.after,"after",s.workflow):value(f.after)}\u300D`).join("\uFF1B")}`}]:[],...who.map(f=>({key:`${key}/${f.field}`,workflow:s.workflow,stage:s.stage,text:`\u300C${s.label}\u300D\u7684${fieldNames[f.field]}\u4ECE\u300C${value(f.before,"before")}\u300D\u6539\u6210\u300C${value(f.after,"after")}\u300D`}))]}),...diff.roles.map(r=>({key:`role/${r.role}`,text:`${r.change==="added"?"\u65B0\u589E":r.change==="removed"?"\u5220\u6389":"\u6539\u4E86"}\u89D2\u8272\u300C${r.label.after??r.label.before??r.role}\u300D`}))]}function matchesReleasedFiles(state){return!!state.head&&!!state.released?.commit&&state.changes.files.length===0&&!state.changes.unsupportedFiles?.length&&state.changes.flow?.planChanged===false&&(!state.saveBlocked||state.saveBlocked.code==="no_changes")}function FlowComparison({state,w,rows,paramsFiles,listedBelow}){const agentCount=agentChangeCount(state);const[side,setSide]=useState8("after");const[highlight,setHighlight]=useState8(null);const root=useRef5(null);const flow=state.changes.flow;const count=rows.length+paramsFiles.length;const roles=[...w.roles];for(const r of flow?.roles??[]){if(!roles.some(x=>x.name===r.role))roles.push({name:r.role,label:r.label.after??r.label.before??r.role,permissions:[]})}const snapshot=s=>({...s,kind:s.kind==="agent"||s.kind==="human"||s.kind==="external"?s.kind:"human",needs:s.needs.map(need=>need.replace(/#partial$/,"")),produces:[]});return jsxs11("div",{ref:root,children:[count?jsxs11(Fragment11,{children:[jsxs11("h3",{children:["\u6D41\u7A0B ",count," \u5904"]}),jsxs11("ul",{className:"band-workshop-edit-changes",children:[rows.map(r=>jsx11("li",{children:jsx11("button",{type:"button",onClick:()=>{if(!r.stage)return;const target=`${r.workflow}/${r.stage}`;setHighlight(target);const isRemoved=flow?.stages.some(s=>s.workflow===r.workflow&&s.stage===r.stage&&s.change==="removed");setSide(isRemoved?"before":"after");requestAnimationFrame(()=>{const el=Array.from(root.current?.querySelectorAll("[data-edit-stage]")??[]).find(e=>e.dataset.editStage===target&&e.closest("[data-side]")?.dataset.side===(isRemoved?"before":"after"));if(el){scrollIntoPanel(el);el.focus({preventScroll:true})}})},children:r.text})},r.key)),paramsFiles.map(f=>jsxs11("li",{className:"band-workshop-edit-file-row",children:[CHANGE_LABEL[f.change],"\u9636\u6BB5\u53C2\u6570 ",jsx11("code",{children:f.path})]},f.path))]}),jsx11("p",{className:"band-workshops-note",children:"\u65B0\u9879\u76EE\u7528\u65B0\u7248\uFF1B\u5DF2\u6709\u9879\u76EE\u7684\u66F4\u65B0\u60C5\u51B5\u4F1A\u5728\u53D1\u5E03\u540E\u9010\u9879\u5217\u51FA\u3002"})]}):jsx11("p",{className:"band-workshops-note",children:matchesReleasedFiles(state)?"\u4E0E\u4E0A\u6B21\u53D1\u5E03\u7684\u5185\u5BB9\u76F8\u540C\uFF0C\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\u3002":flow?state.ahead>0?listedBelow?"\u8FD9\u6B21\u6CA1\u6709\u6D41\u7A0B\u4FEE\u6539\uFF0CAgent \u7684\u4FEE\u6539\u5728\u4E0B\u9762\u3002":"\u5F53\u524D\u4FEE\u6539\u4E0D\u6D89\u53CA\u6D41\u7A0B\u3002\u8BF7\u5148\u5230\u5DE5\u574A\u4ED3\u5E93\u67E5\u770B\u5B8C\u6574\u6539\u52A8\uFF0C\u518D\u4FDD\u5B58\u5E76\u53D1\u5E03\u3002":"\u8FD8\u6CA1\u6709\u6D41\u7A0B\u4FEE\u6539\u3002\u8DDF Rondo \u8BF4\u8981\u6539\u4EC0\u4E48\uFF0C\u6539\u52A8\u4F1A\u5217\u5728\u8FD9\u91CC\u3002":"\u6D41\u7A0B\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u5148\u5904\u7406\u68C0\u67E5\u63D0\u793A\u3002"}),jsx11("div",{className:"band-workshop-edit-compare-switch seg","aria-label":"\u5BF9\u6BD4\u7248\u672C",hidden:!rows.length,children:["before","after"].map(s=>jsx11("button",{type:"button","aria-pressed":side===s,onClick:()=>setSide(s),children:s==="before"?"\u6539\u524D":"\u6539\u540E"},s))}),Object.entries(flow?.workflows??{}).map(([workflow,snapshots])=>jsx11("div",{className:"band-workshop-edit-comparison","data-show":side,"data-empty":rows.length===0?"true":void 0,children:["before","after"].map(s=>jsxs11("section",{"data-side":s,"aria-label":s==="before"?"\u6539\u524D\u7684\u6D41\u7A0B":"\u6539\u540E\u7684\u6D41\u7A0B",children:[jsx11("h4",{children:s==="before"?state.released?`\u6539\u524D\uFF1A\u5DF2\u53D1\u5E03\u7684 v${state.released.seq}`:"\u6539\u524D\uFF1A\u8FD8\u6CA1\u53D1\u5E03\u8FC7":rows.length===0&&state.released?`\u73B0\u5728\u7684\u6D41\u7A0B\uFF08v${state.released.seq}\uFF09`:"\u6539\u540E\uFF1A\u8FD8\u6CA1\u4FDD\u5B58"}),jsx11(FlowBig,{stages:snapshots[s].map(snapshot),peers:["rondo"],roles,story:{loops:{}},executorKnown:false,approvalText:Object.fromEntries(snapshots[s].map(stage=>[stage.id,stage.approveBy.length?`\u6279\u51C6\uFF1A${stage.approveBy.map(role=>flow?.roles.find(r=>r.role===role)?.label[s]??roles.find(r=>r.name===role)?.label??role).join("\u3001")}`:"\u4E0D\u8BBE\u95E8\u7981"])),decorations:Object.fromEntries((flow?.stages??[]).filter(c=>c.workflow===workflow).map(c=>[c.stage,{tag:c.change==="added"&&s==="after"?"\u65B0\u589E":c.change==="removed"&&s==="before"?"\u5220\u6389":c.change==="changed"&&s==="after"?"\u6539\u4E86":void 0,removed:c.change==="removed"&&s==="before",highlight:highlight===`${workflow}/${c.stage}`,key:`${workflow}/${c.stage}`}]))}),jsxs11("div",{className:"band-workshop-edit-roles",children:[jsx11("b",{children:"\u89D2\u8272"}),roles.filter(r=>{const c=flow?.roles.find(c2=>c2.role===r.name);return!(s==="before"&&c?.change==="added")&&!(s==="after"&&c?.change==="removed")}).map(r=>jsx11("span",{children:flow?.roles.find(c=>c.role===r.name)?.label[s]??r.label??r.name},r.name))]})]},s))},workflow))]})}function PreviewOpen({ctx,id,hash,projectPage}){const labelId=useId7();const trials=useAppData4(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const mine=useAppData4(ctx,d=>typeof d.projects==="function"?d.projects({workshop:id}):Promise.resolve([]),[id]);const[picked,setPicked]=useState8("");if(!projectPage)return null;if(trials.data===void 0&&mine.data===void 0)return null;const seen=new Set;const entries=[];for(const source of[...(trials.data?.projects??[]).map(p=>({id:p.id,name:p.name,trial:true})),...(mine.data??[]).filter(p=>!p.project.archivedAt).map(p=>({id:p.project.id,name:p.project.name,trial:false}))]){if(seen.has(source.id))continue;seen.add(source.id);entries.push(source)}const current=entries.some(o=>o.id===picked)?picked:entries[0]?.id??"";return jsx11("div",{className:"band-workshop-edit-preview",children:mine.error?jsxs11(ErrorNote7,{retry:mine.reload,children:["\u9879\u76EE\u6CA1\u8BFB\u51FA\u6765\uFF1A",readable(mine.error)]}):!entries.length?jsx11("p",{className:"band-workshops-note",children:"\u8FD8\u6CA1\u6709\u80FD\u6253\u5F00\u9884\u89C8\u7684\u9879\u76EE\uFF1A\u5148\u5230\u5DE5\u574A\u8BBE\u7F6E\u7684\u300C\u8BD5\u7528\u9879\u76EE\u300D\u5F00\u4E00\u4E2A\uFF0C\u6216\u5EFA\u4E00\u4E2A\u9879\u76EE\uFF0C\u518D\u56DE\u6765\u5728\u9884\u89C8\u91CC\u770B\u3002"}):jsxs11(Fragment11,{children:[jsxs11("div",{className:"band-workshop-edit-preview-open field-host",children:[jsx11("label",{htmlFor:labelId,className:"band-workshop-edit-preview-label",children:"\u5728\u9884\u89C8\u91CC\u770B"}),jsxs11("select",{id:labelId,className:"field bare",value:current,onChange:e=>setPicked(e.target.value),children:[entries.some(o=>o.trial)&&jsx11("optgroup",{label:"\u8BD5\u7528\u9879\u76EE",children:entries.filter(o=>o.trial).map(o=>jsx11("option",{value:o.id,children:o.name},o.id))}),entries.some(o=>!o.trial)&&jsx11("optgroup",{label:"\u6211\u7684\u9879\u76EE",children:entries.filter(o=>!o.trial).map(o=>jsx11("option",{value:o.id,children:o.name},o.id))})]}),jsx11("button",{type:"button",className:"btn sm",disabled:!current,onClick:()=>{if(!current)return;ctx.app.navigate({page:projectPage,params:{workshop:id,project:current}});window.location.assign(`${window.location.pathname}?preview=${hash}`)},children:"\u6253\u5F00"})]}),jsx11("p",{className:"band-workshops-note",children:"\u6309\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\u6253\u5F00\u8FD9\u4E2A\u9879\u76EE\uFF1B\u9884\u89C8\u91CC\u7684\u5199\u5165\u4ECD\u4F1A\u843D\u5230\u771F\u5B9E\u9879\u76EE\uFF0C\u770B\u5B8C\u70B9\u9875\u9762\u91CC\u7684\u300C\u9000\u51FA\u9884\u89C8\u300D\u56DE\u6765\u3002"})]})})}function ViewFileRow({ctx,id,file,head}){const api=ctx.app.data.write?.workshopEdit;const[open,setOpen]=useState8(false);const[loaded,setLoaded]=useState8(null);const[error,setError]=useState8(null);const read=()=>{if(!api||!head||loaded&&loaded.head===head)return;api.file(id,file.path).then(content=>{setError(null);setLoaded({head,content})},e=>setError(`\u5185\u5BB9\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause2(e,"\u91CD\u8BD5"))}`))};useEffect8(()=>{if(open)read()},[open,head]);const stale=loaded?.head!==head;return jsx11("li",{className:"band-workshop-edit-file-row",children:jsxs11("details",{open,children:[jsxs11("summary",{onClick:e=>{e.preventDefault();setOpen(!open)},children:[CHANGE_LABEL[file.change]," ",jsx11("code",{children:file.path})]}),error?jsxs11("p",{className:"band-workshop-edit-file-note",children:[error,jsx11("button",{type:"button",className:"btn ghost sm",onClick:()=>{setError(null);setLoaded(null);read()},children:"\u91CD\u8BD5"})]}):loaded&&!stale?loaded.content.unavailable?jsx11("p",{className:"band-workshop-edit-file-note",children:loaded.content.unavailable}):jsxs11("div",{className:"band-workshop-edit-file-diff",children:[loaded.content.before!==null&&jsxs11("section",{"aria-label":"\u6539\u524D\u7684\u5185\u5BB9",children:[jsx11("h5",{children:"\u6539\u524D\uFF08\u5DF2\u53D1\u5E03\uFF09"}),jsx11("pre",{children:loaded.content.before})]}),loaded.content.after!==null&&jsxs11("section",{"aria-label":"\u6539\u540E\u7684\u5185\u5BB9",children:[jsx11("h5",{children:"\u6539\u540E\uFF08\u8FD8\u6CA1\u4FDD\u5B58\uFF09"}),jsx11("pre",{children:loaded.content.after})]})]}):jsx11("p",{className:"band-workshop-edit-file-note",children:open?"\u8BFB\u53D6\u4E2D\u2026":"\u70B9\u5F00\u770B\u6539\u524D\u6539\u540E\u7684\u5185\u5BB9"})]})})}function ViewChanges({ctx,id,state,files,declaration,projectPage}){const groups=viewFileGroups(files);const preview=state.preview;const previewHash=state.ahead>0&&preview?.status==="ready"&&preview.hash?preview.hash:void 0;if(!files.length&&!declaration&&!previewHash)return null;const count=files.length+(declaration?1:0);return jsxs11("section",{className:"band-workshop-edit-views","aria-label":"\u89C6\u56FE\u6539\u52A8",children:[jsx11("h3",{children:count?`\u89C6\u56FE ${count} \u5904`:"\u89C6\u56FE"}),!!count&&jsx11("p",{className:"band-workshops-note",children:"\u89C6\u56FE\u662F\u8981\u8FD0\u884C\u7684\u4EE3\u7801\uFF1A\u70B9\u300C\u5728\u9884\u89C8\u91CC\u770B\u300D\u6216\u4FDD\u5B58\u5E76\u53D1\u5E03\u540E\uFF0C\u5B83\u5C31\u4F1A\u4EE5\u4F60\u7684\u8EAB\u4EFD\u5728 Band \u91CC\u8FD0\u884C\u3002\u70B9\u5F00\u6BCF\u4E2A\u6587\u4EF6\u6838\u5BF9\u5185\u5BB9\u3002"}),declaration&&jsxs11("div",{className:"band-workshop-edit-view-plugin",children:[jsx11("h4",{children:"\u89C6\u56FE\u58F0\u660E\uFF08workshop.yaml\uFF09"}),jsx11("ul",{className:"band-workshop-edit-changes",children:jsx11(ViewFileRow,{ctx,id,file:declaration,head:state.head})})]}),groups.map(g=>jsxs11("div",{className:"band-workshop-edit-view-plugin",children:[jsx11("h4",{children:g.plugin}),jsx11("ul",{className:"band-workshop-edit-changes",children:g.files.map(f=>jsx11(ViewFileRow,{ctx,id,file:f,head:state.head},f.path))})]},g.plugin)),state.ahead>0&&preview?.status==="building"&&jsx11("p",{className:"band-workshops-note",children:"\u6B63\u5728\u68C0\u67E5\u6700\u65B0\u7684\u4FEE\u6539\uFF0C\u597D\u4E86\u4EE5\u540E\u53EF\u4EE5\u5728\u8FD9\u91CC\u6253\u5F00\u9884\u89C8\u3002"}),previewHash&&jsx11(PreviewOpen,{ctx,id,hash:previewHash,projectPage})]})}function OtherChanges({files}){if(!files.length)return null;return jsxs11("section",{className:"band-workshop-edit-others","aria-label":"\u5176\u4ED6\u6539\u52A8",children:[jsxs11("h3",{children:["\u5176\u4ED6 ",files.length," \u5904"]}),jsx11("ul",{className:"band-workshop-edit-changes",children:files.map(f=>jsxs11("li",{className:"band-workshop-edit-file-row",children:[CHANGE_LABEL[f.change]," ",jsx11("code",{children:f.path})]},f.path))}),jsx11("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u53EA\u5217\u6539\u4E86\u54EA\u4E9B\u6587\u4EF6\uFF1B\u5B8C\u6574\u6539\u52A8\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u3002"})]})}function TurnReceipt({turn,onSee}){const title=turn.status==="committed"?"\u5DF2\u6539\u597D\uFF0C\u901A\u8FC7\u68C0\u67E5":turn.status==="question"?"Rondo \u9700\u8981\u4F60\u56DE\u7B54":turn.status==="rejected"?turn.round>=3?"Rondo \u6539\u4E86 3 \u6B21\u8FD8\u6CA1\u8FC7\u68C0\u67E5":"\u8FD9\u4E00\u8F6E\u6CA1\u8FC7\u68C0\u67E5\uFF0CRondo \u4F1A\u63A5\u7740\u6539":turn.status==="failed"||turn.status==="aborted"?"\u8FD9\u4E00\u8F6E\u6CA1\u8DD1\u5B8C":turn.status==="queued"?"\u6B63\u5728\u6392\u961F":"\u6B63\u5728\u6539";return jsxs11("article",{className:"band-workshop-edit-receipt","aria-label":title,children:[jsx11("h3",{children:title}),turn.status==="queued"&&jsx11("p",{children:"\u7B49\u5F85 Rondo \u5F00\u59CB\u8FD9\u4E00\u8F6E\u3002"}),turn.status==="running"||turn.status==="validating"?jsx11("ol",{className:"band-workshop-edit-progress","aria-label":"\u56DE\u5408\u8FDB\u5EA6",children:["\u6539\u5DE5\u574A","\u68C0\u67E5\u6539\u52A8","\u66F4\u65B0\u53F3\u8FB9\u7684\u5BF9\u6BD4"].map((s,i)=>jsx11("li",{"aria-current":(turn.status==="validating"?i===1:i===0)?"step":void 0,children:s},s))}):null,turn.summary&&jsx11("p",{children:inline(readable(turn.summary))}),turn.question&&jsx11("p",{children:inline(readable(turn.question))}),(turn.status==="failed"||turn.status==="aborted")&&jsxs11("p",{children:[turn.failure?readable(turn.failure):"\u8FD9\u4E00\u8F6E\u505C\u4E86\u3002"," \u5BF9\u8BDD\u8FD8\u5728\uFF0C\u518D\u8BF4\u4E00\u6B21\u5C31\u884C\u3002"]}),turn.status==="rejected"&&jsx11("p",{children:"\u8FD9\u4E00\u8F6E\u7684\u4FEE\u6539\u6CA1\u8BB0\u4E0B\uFF0C\u53F3\u8FB9\u8FD8\u662F\u4E0A\u4E00\u6B21\u8FC7\u4E86\u68C0\u67E5\u7684\u6837\u5B50\u3002\u63A5\u7740\u8BF4\u8981\u600E\u4E48\u6539\u3002"}),turn.issues.length>0&&jsx11("ul",{className:"band-workshop-edit-issues",children:turn.issues.map((issue,i)=>jsxs11("li",{children:[issue.at??"\u68C0\u67E5\u6539\u52A8","\uFF1A",readable(issue.message)]},`${issue.step}/${i}`))}),turn.status==="committed"&&jsx11("button",{type:"button",className:"btn ghost sm",onClick:onSee,children:"\u770B\u6539\u52A8"})]})}function FirstMessageNote({ctx,w,state,onRefresh}){const code=state?.blocked?.code;if(!w.firstMessage)return null;if(state?.session?.turns.length)return null;const m=modelOf(w);const refresh=onRefresh&&jsx11("button",{type:"button",className:"btn sm",onClick:onRefresh,children:"\u5237\u65B0\u8FD9\u4E00\u9875"});const unknown=jsxs11("p",{children:["\u6CA1\u80FD\u81EA\u52A8\u5F00\u59CB\uFF0C\u8BDD\u8FD8\u7559\u7740\u3002 ",refresh]});const reading=jsx11("p",{"aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u72B6\u6001\u2026"});const guidance=()=>{if(state===null)return reading;switch(code){case"not_ready":return jsx11("p",{children:"\u5DE5\u574A\u8FD8\u5728\u5EFA\uFF0C\u5EFA\u597D\u540E\u4F1A\u81EA\u52A8\u7EE7\u7EED\u3002"});case"model_key":return jsx11("p",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8981\u7528\u4F60\u81EA\u5DF1\u7684\u6A21\u578B\uFF0C\u914D\u597D\u4E4B\u540E\u56DE\u5230\u8FD9\u4E00\u9875\u5C31\u4F1A\u5F00\u59CB\u3002"});case"unsupported_files":return jsx11("p",{children:"\u5DE5\u574A\u4ED3\u5E93\u91CC\u6709\u4E0D\u652F\u6301\u7684\u6587\u4EF6\uFF0C\u5728\u4ED3\u5E93\u91CC\u5904\u7406\u6389\u4E4B\u540E\u624D\u80FD\u5F00\u59CB\uFF1B\u8BDD\u5148\u7559\u7740\u3002"});case"ref_mismatch":return jsx11("p",{children:"\u5DE5\u574A\u7684\u6765\u6E90\u8BBE\u7F6E\u9700\u8981\u7BA1\u7406\u5458\u8C03\u6574\u4E4B\u540E\u624D\u80FD\u5F00\u59CB\uFF1B\u8BDD\u5148\u7559\u7740\u3002"});case"locked":return jsx11("p",{children:"\u6709\u4EBA\u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u7B49\u5BF9\u65B9\u7ED3\u675F\uFF1B\u8BDD\u5148\u7559\u7740\uFF0C\u8F6E\u5230\u4F60\u65F6\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002"});case"provision":return modelMissing(m,w.userModelKey)?jsxs11("p",{children:["\u8FD8\u5DEE\u914D\u7F6E\u6A21\u578B\uFF0C\u914D\u597D\u540E Agent \u624D\u80FD\u51C6\u5907\u3002 ",go("model","\u53BB\u914D\u7F6E\u6A21\u578B")]}):m.agent==="failed"?jsxs11("p",{children:["Agent \u6CA1\u51C6\u5907\u597D\uFF0C\u8FD9\u53E5\u8BDD\u5148\u7559\u7740\uFF1B\u5728\u5DE5\u574A\u9875\u91CD\u8BD5\uFF0C\u6210\u529F\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u3002"," ",go("about","\u53BB\u5DE5\u574A\u9875\u91CD\u8BD5")]}):progress?.step===3?jsxs11("p",{"data-provision-step":3,children:[progress.text," ",go("about","\u53BB\u5DE5\u574A\u9875")]}):m.agent!=="ready"?jsxs11("p",{"data-provision-step":progress?.step,children:[progress?`${progress.text} `:"Agent \u6B63\u5728\u51C6\u5907\uFF0C","\u597D\u4E86\u4E4B\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\uFF0C\u4E0D\u7528\u518D\u70B9\u3002"]}):unknown;default:return unknown}};const progress=provisionProgress(m);const go=(page,label)=>jsx11("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:`${SELF}/${page}`,params:{workshop:w.id}}),children:label});return jsxs11("section",{className:"band-workshops-callout","aria-label":"\u8FD8\u6CA1\u53D1\u51FA\u7684\u6D41\u7A0B\u63CF\u8FF0","data-first-message":true,children:[jsx11("p",{children:"\u4F60\u65B0\u5EFA\u65F6\u5199\u7684\u6D41\u7A0B\u63CF\u8FF0\u8FD8\u7559\u7740\uFF0C\u51C6\u5907\u597D\u4E4B\u540E\u4F1A\u81EA\u52A8\u4EA4\u7ED9 Rondo\uFF1A"}),jsx11("blockquote",{children:w.firstMessage}),guidance()]})}function WorkshopEdit({ctx,id,projectPage}){const api=ctx.app.data.write?.workshopEdit;const workshop=useAppData4(ctx,d=>d.workshop(id),[id]);const w=workshop.data;const canRead=w?.canAdmin===true;const latest=useRef5(null);const[state,setState]=useState8(null);const[error,setError]=useState8(null);const[readDenied,setReadDenied]=useState8(null);const[fresh,setFresh]=useState8(false);const[busy,setBusy]=useState8(false);const[draft,setDraft]=useState8(emptyDraft2);const[pane,setPane]=useState8("chat");const[side,setSide]=useState8("diff");const[chatOpen,setChatOpen]=useState8(false);const[bodyEl,setBodyEl]=useState8(null);const[bodyW,setBodyW]=useState8(0);useEffect8(()=>{if(!bodyEl||typeof ResizeObserver==="undefined")return;const watch=new ResizeObserver(([entry])=>setBodyW(Math.round(entry?.contentRect.width??0)));watch.observe(bodyEl);return()=>watch.disconnect()},[bodyEl]);const trials=useAppData4(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const[confirm,setConfirm]=useState8(null);const[revertingHead,setRevertingHead]=useState8(null);const[reverted,setReverted]=useState8(false);const[endingSession,setEndingSession]=useState8(null);const inFlight=useRef5(false);const autoStarted=useRef5(false);const generation=useRef5(0);const manualRead=useRef5(null);const alive=useRef5(true);const stopPolling=useRef5(false);const messages=useMessageList();const modal=useModalDialog({open:confirm!==null,onRequestClose:()=>setConfirm(null),blocked:busy});const refresh=useCallback2(async(explicit=false)=>{if(!api||!canRead||inFlight.current||!explicit&&manualRead.current!==null)return;const seq=++generation.current;if(explicit)manualRead.current=seq;try{const s=await api.get(id);if(alive.current&&seq===generation.current){setState(s);latest.current=s;setError(null);setReadDenied(null);setFresh(true);return s.head??void 0}}catch(e){if(alive.current&&seq===generation.current){setFresh(false);if(isForbidden2(e)||codeOf(e)==="NOT_FOUND"){setState(null);setReadDenied(isForbidden2(e)?"forbidden":"disabled");stopPolling.current=true}else setError(`\u5DE5\u574A\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A${readable(failedBecause2(e,"\u70B9\u91CD\u8BD5"))}`)}}finally{if(manualRead.current===seq)manualRead.current=null}},[api,id,canRead]);useEffect8(()=>{if(!api||!canRead)return;alive.current=true;stopPolling.current=false;let timer=null;let armed=false;let pollGeneration=0;let stopped=false;const clear=()=>{if(timer!==null)clearTimeout(timer);timer=null;armed=false};const schedule=()=>{if(stopped||!alive.current||stopPolling.current||armed)return;if(document.visibilityState!=="visible")return;armed=true;timer=setTimeout(()=>{timer=null;armed=false;void poll()},editStatePollMs(latest.current))};const poll=async()=>{if(stopped||!alive.current||stopPolling.current)return;if(document.visibilityState!=="visible")return;const current=++pollGeneration;try{await refresh()}finally{if(current===pollGeneration)schedule()}};const onVisibility=()=>{if(document.visibilityState!=="visible"){clear();return}clear();void poll()};document.addEventListener("visibilitychange",onVisibility);void poll();return()=>{stopped=true;alive.current=false;++generation.current;manualRead.current=null;clear();document.removeEventListener("visibilitychange",onVisibility)}},[api,refresh,canRead]);const act=async run=>{if(!api||inFlight.current)return false;inFlight.current=true;++generation.current;setBusy(true);try{const s=await run(api);if(alive.current){++generation.current;setState(s);setFresh(true);setError(null);setConfirm(null)}return true}catch(e){if(alive.current){setError(codeOf(e)==="CONFLICT"?confirm==="revert"?`${readable(errorText6(e))} \u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u8BD5\u3002`:"\u4F60\u6253\u5F00\u4E4B\u540E\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\uFF0C\u6216\u4FEE\u6539\u5DF2\u7531\u522B\u4EBA\u63A5\u624B\u3002\u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u8BD5\u3002":readable(errorText6(e)));setFresh(false)}return false}finally{inFlight.current=false;if(alive.current)setBusy(false)}};const firstTried=useRef5(false);useEffect8(()=>{if(!api||!w?.firstMessage||!state||!fresh||firstTried.current)return;if(state.blocked||!w.canAdmin||state.session&&state.session.status!=="ended")return;firstTried.current=true;autoStarted.current=true;void act(a=>a.start(id)).then(()=>workshop.reload())});useEffect8(()=>{if(!api||!w||!state||!fresh||autoStarted.current)return;autoStarted.current=true;if(w.canAdmin&&!state.blocked&&(!state.session||state.session.status==="ended"))void act(a=>a.start(id))});const mine=state?.session?.status==="active"&&state.session.holder.id===ctx.app.member.id;const memberId=ctx.app.member.id;useEffect8(()=>{if(!api||!mine||pane!=="trial")return;const beat=()=>{if(document.visibilityState!=="visible"||inFlight.current)return;api.get(id).then(read=>{if(!alive.current||inFlight.current)return;const held=read.session?.status==="active"&&read.session.holder.id===memberId;if(!held){setState(read);return}return api.start(id).then(s=>alive.current&&setState(s))}).catch(()=>{})};const timer=setInterval(beat,5*6e4);document.addEventListener("visibilitychange",beat);return()=>{clearInterval(timer);document.removeEventListener("visibilitychange",beat)}},[api,id,pane,mine,memberId]);const hadOwn=useRef5(false);if(mine)hadOwn.current=true;if(w===null)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,here:"\u6539\u5DE5\u574A"}),jsx11("p",{children:"\u5DE5\u574A\u4E0D\u5B58\u5728\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u67E5\u770B\u6743\u9650\u3002"})]});if(readDenied||w&&!w.canAdmin)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsx11("p",{children:readDenied==="disabled"?"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002":"\u6CA1\u6709\u6743\u9650\u770B\u5DE5\u574A\u6539\u52A8\u3002\u53EA\u6709\u5DE5\u574A\u521B\u5EFA\u4EBA\u3001\u5DE5\u574A\u7BA1\u7406\u5458\u548C Band \u7BA1\u7406\u5458\u80FD\u770B\uFF0C\u8BF7\u627E\u5DE5\u574A\u7BA1\u7406\u5458\u3002"}),jsx11("button",{type:"button",className:"btn",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:id}}),children:"\u56DE\u5230\u5DE5\u574A"})]});if(!w)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,here:"\u6539\u5DE5\u574A"}),workshop.error?jsx11(ErrorNote7,{retry:workshop.reload,children:workshop.error}):jsx11("p",{children:"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u2026"})]});if(!api)return jsxs11("main",{className:"band-workshops-screen",children:[jsx11(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsx11("p",{children:"\u6539\u5DE5\u574A\u8FD8\u6CA1\u5F00\u653E\u3002"})]});const session=state?.session;const own=!!session&&session.status==="active"&&session.holder.id===ctx.app.member.id&&w.canAdmin&&state?.blocked?.code!=="forbidden";const active=session?.turns.some(running)??false;const rows=flowChangeRows(state?.changes.flow??null,w.roles,w.artifactTypes);const agentCount=agentChangeCount(state);const fileChanges=state?.changes.files??[];const viewFiles=fileChanges.filter(f=>f.face==="views");const declaration=fileChanges.find(f=>f.path==="band/workshop.yaml"&&f.viewsSection);const paramsFiles=fileChanges.filter(f=>f.face==="flow"&&f.path.startsWith("band/params/"));const otherFiles=fileChanges.filter(f=>f.face==="other"||f.path==="band/workshop.yaml"&&!f.viewsSection&&rows.length===0&&agentCount===0);const totalCount=rows.length+paramsFiles.length+viewFiles.length+(declaration?1:0)+otherFiles.length+agentCount;const hasViewCode=viewFiles.length>0||!!declaration;const why=state?editBlocked(state):"\u6B63\u5728\u8BFB\u53D6\u5DE5\u574A\u2026";const readOnly=!fresh||!own||!!state?.blocked;const disabled=readOnly||busy;const saveWhy=busy?"\u6B63\u5728\u5904\u7406\uFF0C\u8BF7\u7A0D\u7B49":disabled?why??(!own?"\u5F00\u59CB\u4FEE\u6539\u540E\u624D\u80FD\u4FDD\u5B58":"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001"):active?"\u8FD9\u4E00\u8F6E\u6539\u5B8C\u624D\u80FD\u4FDD\u5B58":state&&matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":state?.saveBlocked?readable(state.saveBlocked.message):state?.head?void 0:"\u5DE5\u574A\u8FD8\u6CA1\u51C6\u5907\u597D";const revertWhy=busy?"\u6B63\u5728\u5904\u7406\uFF0C\u8BF7\u7A0D\u7B49":!api.revert?"\u9000\u56DE\u529F\u80FD\u8FD8\u6CA1\u5F00\u653E":!fresh||!state?.head?"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001":session?.status==="active"&&!own?"\u8BF7\u7B49\u5BF9\u65B9\u7ED3\u675F\u4FEE\u6539\u540E\u518D\u9000\u56DE":active?"\u8BF7\u5148\u505C\u6B62\u8FD9\u4E00\u8F6E\uFF0C\u7B49\u56DE\u5408\u7ED3\u675F\u540E\u518D\u9000\u56DE":state?.blocked&&!["model_key","provision","unsupported_files"].includes(state.blocked.code)?why:!state?.released?.commit?"\u6CA1\u6709\u53EF\u9000\u56DE\u7684\u53D1\u5E03\u7248\u672C":state.ahead===0||matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":void 0;const confirmTitle=confirm==="end"?"\u7ED3\u675F\u8FD9\u6B21\u4FEE\u6539":confirm==="revert"?"\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03":"\u63A5\u624B\u4FEE\u6539";const see=()=>{setPane("diff");setSide("diff")};const showTrial=()=>{setPane("trial");setSide("trial");setChatOpen(false)};return jsxs11("main",{className:"band-workshop-edit",children:[jsxs11("header",{className:"band-workshop-edit-head",children:[jsxs11("div",{children:[jsx11(Crumb,{ctx,w,here:"\u6539\u5DE5\u574A"}),jsxs11("h1",{children:["\u6539\u5DE5\u574A\uFF1A",w.name]}),jsx11("div",{className:"band-workshop-edit-lock",children:own?jsxs11(Fragment11,{children:[jsx11("span",{children:"\u4F60\u6B63\u5728\u6539 \xB7 \u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B"}),jsx11("button",{type:"button",className:"btn ghost sm",disabled:busy||!fresh,onClick:event=>{modal.trigger.current=event.currentTarget;setEndingSession(session?.id??null);setConfirm("end")},children:"\u7ED3\u675F"})]}):session?.status==="active"?jsxs11(Fragment11,{children:[jsxs11("span",{children:[session.holder.name," \u6B63\u5728\u6539\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B\u3002"]}),w.canAdmin&&state?.blocked?.code==="locked"&&jsx11("button",{type:"button",className:"btn sm",disabled:busy||!fresh,onClick:event=>{modal.trigger.current=event.currentTarget;setConfirm("takeover")},children:"\u63A5\u624B"})]}):jsxs11(Fragment11,{children:[jsx11("span",{children:why??"\u5F00\u59CB\u4FEE\u6539\u540E\uFF0C\u5176\u4ED6\u7BA1\u7406\u5458\u53EF\u53EA\u8BFB\u67E5\u770B"}),state&&!state.blocked&&jsx11("button",{type:"button",className:"btn sm",disabled:busy||!fresh,onClick:()=>void act(a=>a.start(id)),children:"\u5F00\u59CB\u4FEE\u6539"})]})})]}),jsxs11("div",{className:"band-workshop-edit-actions",children:[jsx11("span",{children:!state?"\u6B63\u5728\u8BFB\u53D6\u4FEE\u6539\u2026":state.head===null?"\u6539\u52A8\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528":state.ahead===0||matchesReleasedFiles(state)?"\u6CA1\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539":totalCount?`\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF1A${totalCount} \u5904`:state.changes.flow?"\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF08\u5BF9\u6BD4 0 \u5904\uFF09":"\u6709\u8FD8\u6CA1\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5BF9\u6BD4\u6682\u65F6\u4E0D\u53EF\u7528"}),state?.released&&jsx11("button",{type:"button",className:"btn",disabled:!!revertWhy,title:revertWhy,onClick:event=>{modal.trigger.current=event.currentTarget;setRevertingHead(state.head);setReverted(false);setConfirm("revert")},children:"\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03"}),jsx11(PublishRelease,{ctx,w,onDone:()=>{void refresh();workshop.reload()},label:"\u4FDD\u5B58\u5E76\u53D1\u5E03",primary:true,disabledReason:saveWhy,commit:state?.head??void 0,onConflict:()=>{setFresh(false)},onRefresh:async()=>{const head=await refresh(true);workshop.reload();return head},publishingChanged:setBusy}),saveWhy&&state?.saveBlocked?.code!=="no_changes"&&jsx11("small",{className:"band-workshops-hint",children:saveWhy}),hasViewCode&&state?.ahead!==0&&jsx11("small",{className:"band-workshops-hint",children:"\u542B\u89C6\u56FE\u4EE3\u7801\uFF1A\u4FDD\u5B58\u5E76\u53D1\u5E03\u540E\uFF0C\u4F1A\u5728\u6210\u5458\u6253\u5F00\u9879\u76EE\u65F6\u8FD0\u884C\u3002"})]})]}),reverted&&jsx11("output",{children:"\u5DF2\u9000\u56DE\u5230\u4E0A\u6B21\u53D1\u5E03\u3002\u4FEE\u6539\u5386\u53F2\u5DF2\u4FDD\u7559\uFF0C\u6CA1\u6709\u53D1\u5E03\u65B0\u7248\u3002"}),error&&jsx11(ErrorNote7,{retry:()=>void refresh(),children:error}),jsx11(FirstMessageNote,{ctx,w,state,onRefresh:()=>{void refresh();workshop.reload()}}),state?.changes.unsupportedFiles?.length?jsxs11("div",{role:"alert",children:[jsx11("p",{children:editBlocked(state)}),jsx11(UnsupportedFiles,{state})]}):null,state&&!state.agentEditable&&jsx11("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u7528\u7684\u662F\u5B9A\u5236 Agent\uFF0C\u754C\u9762\u4E0A\u53EA\u80FD\u6539\u6D41\u7A0B\u548C\u89C6\u56FE\uFF1BAgent \u7684\u8BF4\u660E\u3001\u6280\u80FD\u548C\u63D2\u4EF6\u7167\u65E7\u5728\u5DE5\u574A\u4ED3\u5E93\u91CC\u6539\u3002"}),state?.preview?.status==="failed"&&jsxs11("div",{role:"alert",children:[jsx11(ErrorNote7,{children:"\u6700\u65B0\u7684\u4FEE\u6539\u6784\u5EFA\u4E0D\u8FC7\u3002\u4FEE\u597D\u4E4B\u524D\u4E0D\u80FD\u4FDD\u5B58\uFF1B\u63A5\u7740\u8DDF Rondo \u8BF4\u8981\u600E\u4E48\u6539\u3002"}),jsx11("ul",{children:state.preview.issues.map((s,i)=>jsx11("li",{children:readable(s)},`${i}/${s}`))})]}),jsxs11("div",{className:"band-workshop-edit-pane-switch seg","aria-label":"\u6539\u5DE5\u574A\u5185\u5BB9",children:[jsx11("button",{type:"button","aria-pressed":pane==="chat",onClick:()=>setPane("chat"),children:"\u5BF9\u8BDD"}),jsxs11("button",{type:"button","aria-pressed":pane==="diff",onClick:see,children:["\u6539\u52A8",totalCount?` \xB7 ${totalCount}`:""]}),jsx11("button",{type:"button","aria-pressed":pane==="trial",onClick:showTrial,children:"\u8BD5\u7528"})]}),jsxs11("div",{className:"band-workshop-edit-body","data-pane":pane,"data-fold":side==="trial"&&!chatOpen&&bodyW>0&&bodyW<TRIAL_UNFOLDED_MIN?"chat":void 0,ref:setBodyEl,children:[jsx11("button",{type:"button",className:"band-workshop-edit-rail iconbtn","aria-label":"\u5C55\u5F00\u5BF9\u8BDD",title:"\u5C55\u5F00\u5BF9\u8BDD",onClick:()=>setChatOpen(true),children:"\u25E7"}),jsxs11("section",{className:"band-workshop-edit-chat","aria-label":"\u5BF9\u8BDD",children:[jsxs11("div",{className:"band-workshop-edit-messages","data-band-messages":true,...messages,children:[!session?.turns.length&&jsxs11("div",{className:"band-workshop-edit-empty",children:[jsx11("h2",{children:"\u8DDF Rondo \u8BF4\u8981\u600E\u4E48\u6539\u8FD9\u4E2A\u5DE5\u574A"}),jsx11("p",{children:"\u8BF4\u8981\u6539\u4EC0\u4E48\uFF1A\u6D41\u7A0B\uFF08\u52A0\u54EA\u4E00\u6B65\u3001\u8C01\u6765\u6279\u3001\u53BB\u6389\u4EC0\u4E48\uFF09\u6216\u754C\u9762\uFF08\u7ED9\u67D0\u4E2A\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0\u9762\u677F\uFF09\u3002Rondo \u6539\u5B8C\u5148\u8FC7\u68C0\u67E5\uFF0C\u53F3\u8FB9\u4F1A\u5217\u51FA\u6539\u4E86\u4EC0\u4E48\uFF1B\u70B9\u300C\u4FDD\u5B58\u5E76\u53D1\u5E03\u300D\u4E4B\u524D\uFF0C\u9879\u76EE\u90FD\u4E0D\u53D7\u5F71\u54CD\u3002"}),jsx11("button",{type:"button",className:"btn ghost",disabled:disabled||active,onClick:()=>setDraft({...emptyDraft2(),text:"\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u7531\u6559\u7814\u7EC4\u957F\u6279"}),children:"\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u7531\u6559\u7814\u7EC4\u957F\u6279"}),jsx11("button",{type:"button",className:"btn ghost",disabled:disabled||active,onClick:()=>setDraft({...emptyDraft2(),text:"\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0\u9762\u677F\uFF0C\u80FD\u770B\u5230\u4EA7\u51FA\u7684\u6E05\u5355"}),children:"\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u5DE5\u4F5C\u53F0\u9762\u677F"})]}),session?.turns.map(t=>jsxs11(Fragment10,{children:[t.message&&jsx11("div",{className:"band-workshop-edit-user",children:inline(t.message)}),jsxs11("div",{className:"band-workshop-edit-message","data-band-message":true,tabIndex:-1,children:[jsxs11("div",{className:"band-workshop-edit-who",children:[jsx11(Avatar2,{id:"rondo",name:"Rondo",agent:true,size:"sm",decorative:true}),"Rondo"]}),jsx11(TurnReceipt,{turn:t,onSee:see}),(t.status==="failed"||t.status==="aborted")&&jsx11("button",{type:"button",className:"btn ghost sm",disabled:disabled||active,onClick:()=>{const message=session.turns.slice(0,session.turns.indexOf(t)+1).reverse().find(turn=>turn.message)?.message;if(message)void act(a=>a.send(id,session.id,{message}))},children:"\u518D\u53D1\u4E00\u6B21\u8FD9\u53E5\u8BDD"})]})]},t.id))]}),active&&own&&jsx11("button",{type:"button",className:"btn ghost sm",disabled:busy||!fresh,onClick:()=>session&&void act(a=>a.stop(id,session.id)),children:"\u505C\u6B62\u8FD9\u4E00\u8F6E"}),jsx11(PromptInput2,{draft,onDraft:setDraft,variant:"prompt",label:"\u544A\u8BC9 Rondo \u8981\u600E\u4E48\u6539",placeholder:"\u8BF4\u8981\u600E\u4E48\u6539\uFF0C\u4F8B\u5982\uFF1A\u5236\u4F5C\u4E4B\u540E\u52A0\u4E00\u4E2A\u5BA1\u6821\uFF0C\u6216\u7ED9\u5236\u4F5C\u9636\u6BB5\u52A0\u4E00\u4E2A\u9762\u677F",busy:busy||active,disabledReason:readOnly?why??(!own?"\u5F00\u59CB\u4FEE\u6539\u540E\uFF0C\u5C31\u80FD\u8DDF Rondo \u8BF4\u8981\u6539\u4EC0\u4E48\u3002":"\u8BF7\u5148\u5237\u65B0\u5DE5\u574A\u72B6\u6001\u3002"):void 0,onSubmit:async d=>{if(disabled||active||!session)return false;if(d.text.trim().length>8e3)throw new Error("\u8FD9\u53E5\u8BDD\u592A\u957F\u4E86\uFF0C\u8BF7\u7F29\u77ED\u5230 8000 \u5B57\u4EE5\u5185\u3002");return await act(a=>a.send(id,session.id,{message:d.text.trim()}))}}),jsxs11("small",{className:"band-workshops-hint",children:["\u6A21\u578B\uFF1A",w.userModelKey==="require"?"\u4F60\u7684\u9ED8\u8BA4\u6A21\u578B\u914D\u7F6E":"\u5DE5\u574A\u7684\u56E2\u961F\u6A21\u578B"]})]}),jsxs11("div",{className:"band-workshop-edit-side","data-side":pane==="chat"?side:pane,children:[jsx11("div",{className:"band-workshop-edit-side-tabs tabs plain",role:"tablist","aria-label":"\u6539\u52A8\u4E0E\u8BD5\u7528",children:[["diff",`\u6539\u52A8${totalCount?` \xB7 ${totalCount}`:""}`],["trial","\u8BD5\u7528"]].map(([key,label])=>jsx11("button",{type:"button",role:"tab",id:`band-workshop-edit-tab-${key}`,"aria-controls":`band-workshop-edit-panel-${key}`,"aria-selected":side===key,tabIndex:side===key?0:-1,onClick:()=>key==="diff"?see():showTrial(),onKeyDown:withImeGuard2(e=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;e.preventDefault();const next=e.key==="Home"?"diff":e.key==="End"?"trial":side==="diff"?"trial":"diff";if(next==="diff")see();else showTrial();document.getElementById(`band-workshop-edit-tab-${next}`)?.focus()}),children:label},key))}),jsx11("section",{className:"band-workshop-edit-diff",id:"band-workshop-edit-panel-diff",role:"tabpanel","aria-labelledby":"band-workshop-edit-tab-diff","aria-label":"\u6539\u52A8",hidden:side!=="diff",children:jsx11("div",{className:"band-workshop-edit-diff-scroll",children:state?jsxs11(Fragment11,{children:[jsx11(FlowComparison,{state,w,rows,paramsFiles,listedBelow:viewFiles.length+(declaration?1:0)+otherFiles.length+agentCount}),jsx11(ViewChanges,{ctx,id,state,files:viewFiles,declaration,projectPage}),(state.agentEditable||agentCount>0)&&jsxs11("section",{className:"band-workshop-edit-agent","aria-label":"Agent \u6539\u52A8",children:[jsx11("h3",{children:"Agent \u6539\u52A8"}),jsx11(AgentChanges,{state})]}),jsx11(OtherChanges,{files:otherFiles})]}):jsx11("p",{children:"\u6B63\u5728\u8BFB\u53D6\u5BF9\u6BD4\u2026"})})}),jsx11("section",{className:"band-workshop-edit-trial",id:"band-workshop-edit-panel-trial",role:"tabpanel","aria-labelledby":"band-workshop-edit-tab-trial","aria-label":"\u8BD5\u7528",hidden:side!=="trial",children:state?jsx11(TrialTab,{ctx,id,state,own,holder:session?.status==="active"?session.holder.name:void 0,trials:trials.data,trialsError:trials.error??null,reloadTrials:trials.reload,workshopName:w.name,ended:hadOwn.current&&session?.status!=="active",onRestart:()=>void act(a=>a.start(id)),onRefresh:()=>refresh(true),projectPage,agentPreparing:["preparing","awaiting_promotion"].includes(modelOf(w).agent)}):jsx11("p",{children:"\u6B63\u5728\u8BFB\u53D6\u2026"})})]})]}),jsx11("dialog",{ref:modal.dialog,className:"band-workshops-publish-dialog","data-band-layer":confirm?"dialog":void 0,"aria-label":confirmTitle,onCancel:e=>{e.preventDefault();if(!busy)setConfirm(null)},onClose:()=>setConfirm(null),children:jsxs11("div",{className:"band-workshops-publish-body",children:[jsx11("h2",{children:confirmTitle}),jsx11("p",{children:confirm==="revert"?`\u628A\u5DE5\u574A\u91CC\u8FD8\u6CA1\u53D1\u5E03\u7684\u6D41\u7A0B\u3001\u89C6\u56FE\u548C Agent \u6587\u4EF6\u6062\u590D\u6210\u4E0A\u6B21\u53D1\u5E03\uFF08v${state?.released?.seq}\uFF09\u7684\u6837\u5B50\u3002\u8FD9\u4E9B\u4FEE\u6539\u4F1A\u4ECE\u5F53\u524D\u5B9A\u4E49\u4E2D\u79FB\u9664\uFF0C\u4FEE\u6539\u5386\u53F2\u4ECD\u4F1A\u4FDD\u7559\u3002\u9000\u56DE\u4E0D\u4F1A\u53D1\u5E03\u65B0\u7248\uFF0C\u4E5F\u4E0D\u4F1A\u6539\u53D8\u5DF2\u6709\u9879\u76EE\u3002`:confirm==="end"?"\u7ED3\u675F\u540E\uFF0C\u5DF2\u7ECF\u901A\u8FC7\u68C0\u67E5\u7684\u4FEE\u6539\u4ECD\u4F1A\u4FDD\u7559\uFF1B\u4E0B\u6B21\u4F60\u6216\u522B\u4EBA\u8FDB\u6765\u90FD\u80FD\u63A5\u7740\u6539\u3001\u4FDD\u5B58\u3002":`${session?.holder.id===ctx.app.member.id?"\u4F60\u5728\u53E6\u4E00\u4E2A\u9875\u9762\u91CC\u7684\u4FEE\u6539\u4F1A\u505C\u4E0B":`${session?.holder.name??"\u5BF9\u65B9"} \u7684\u4FEE\u6539\u4F1A\u505C\u4E0B`}\uFF0C\u4E4B\u540E\u7531\u4F60\u63A5\u7740\u6539\u3002\u5DF2\u7ECF\u901A\u8FC7\u68C0\u67E5\u7684\u4FEE\u6539\u4ECD\u4F1A\u4FDD\u7559\uFF1B\u53E6\u4E00\u4E2A\u9875\u9762\u91CC\u8FD8\u6CA1\u53D1\u9001\u7684\u6587\u5B57\u4E0D\u4F1A\u5E26\u5230\u8FD9\u91CC\uFF0C\u8BF7\u5148\u590D\u5236\u3002\u8FD9\u6B21\u63A5\u624B\u4F1A\u8BB0\u8FDB\u64CD\u4F5C\u8BB0\u5F55\u3002`}),confirm==="end"&&(!own||session?.id!==endingSession)&&jsx11("p",{children:"\u8FD9\u6B21\u4FEE\u6539\u5DF2\u7ED3\u675F\u6216\u5DF2\u53D8\u5316\uFF0C\u8BF7\u70B9\u300C\u53D6\u6D88\u300D\u540E\u518D\u770B\u5F53\u524D\u72B6\u6001\u3002"}),confirm==="revert"&&(revertWhy||state?.head!==revertingHead)&&jsx11("p",{role:"alert",children:state?.head!==revertingHead?"\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\uFF0C\u8BF7\u70B9\u300C\u53D6\u6D88\u300D\uFF0C\u5237\u65B0\u5BF9\u6BD4\u540E\u518D\u9000\u56DE\u3002":revertWhy}),confirm==="revert"&&error&&jsx11("p",{role:"alert",children:error}),jsxs11("div",{className:"band-workshops-actions",children:[jsx11("button",{type:"button",className:"btn ghost",disabled:busy,onClick:()=>setConfirm(null),children:"\u53D6\u6D88"}),jsx11("button",{type:"button",className:"btn primary",disabled:busy||confirm==="end"&&(!own||!session||session.id!==endingSession)||confirm==="revert"&&(!!revertWhy||!revertingHead||state?.head!==revertingHead),onClick:()=>{if(confirm==="end"){if(!own||!session||session.id!==endingSession)return;void act(a=>a.end(id,session.id))}else if(confirm==="takeover")void act(a=>a.start(id,{takeOver:true}));else if(confirm==="revert"&&!revertWhy&&revertingHead&&state?.head===revertingHead){const expectedHead=revertingHead;void act(a=>{if(!a.revert)throw new Error("\u9000\u56DE\u529F\u80FD\u8FD8\u6CA1\u5F00\u653E");return a.revert(id,{expectedHead})}).then(ok=>{if(ok&&alive.current)setReverted(true)})}},children:busy?"\u6B63\u5728\u5904\u7406\u2026":confirm==="end"?"\u7ED3\u675F":confirm==="revert"?"\u786E\u8BA4\u9000\u56DE":"\u63A5\u624B"})]})]})})]})}var AGENT_UPGRADE_TEXT={line:{available:n=>`${n} \u4E2A Agent \u7684\u63D2\u4EF6\u6709\u65B0\u7248\u672C`,behind:"\u6709 Agent \u7684\u534F\u4F5C\u534F\u8BAE\u7248\u672C\u8F83\u65E7\uFF0C\u4E4B\u540E\u4F1A\u505C\u6B62\u652F\u6301",unsupported:"\u6709 Agent \u7684\u534F\u4F5C\u534F\u8BAE\u7248\u672C\u5DF2\u4E0D\u518D\u652F\u6301\uFF0C\u5B83\u7684\u56DE\u5408\u6B63\u5728\u88AB\u62D2\u7EDD",show:"\u67E5\u770B"},block:{title:"Agent \u63D2\u4EF6\u7248\u672C",unread:"\u8FD9\u4E2A Agent \u7684\u63D2\u4EF6\u7248\u672C\u6CA1\u8BFB\u51FA\u6765\uFF0C\u7A0D\u540E\u518D\u770B\u3002",unpublished:"Agent \u4ED3\u5E93\u91CC\u6709\u8FD8\u6CA1\u8FDB\u5DE5\u574A\u7684\u4FEE\u6539\uFF1A\u91CD\u65B0\u53D1\u5E03\u5DE5\u574A\u540E\uFF0C\u65B0\u5EFA\u7684\u9879\u76EE\u624D\u4F1A\u7528\u4E0A\uFF1B\u5DF2\u6709\u9879\u76EE\u518D\u7528\u300C\u66F4\u65B0\u672C\u5DE5\u574A\u5168\u90E8\u9879\u76EE\u300D\u3002",changelog:"\u66F4\u65B0\u5185\u5BB9",editHint:(file,dependency,version)=>`\u5728 Agent \u4ED3\u5E93\u91CC\u628A ${file} \u7684\u4F9D\u8D56 ${dependency} \u6539\u6210 ${version}\uFF0C\u63D0\u4EA4\u3002`,pipeline:"\u63D0\u4EA4\u540E\u4F1A\u81EA\u52A8\u53D1\u5230\u6D4B\u8BD5\u73AF\u5883\uFF1B\u6B63\u5F0F\u73AF\u5883\u8981\u5728 AgentHub \u91CC\u624B\u52A8\u664B\u7EA7\u3002",republish:"\u664B\u7EA7\u53EA\u662F AgentHub \u91CC\u7684\u53D1\u5E03\u8BB0\u5F55\u3002\u8981\u8BA9\u9879\u76EE\u7528\u4E0A\uFF0C\u8FD8\u8981\u91CD\u65B0\u53D1\u5E03\u5DE5\u574A\uFF0C\u518D\u66F4\u65B0\u9879\u76EE\u3002"},plugin:{available:(name,current,target)=>`${name} \u6709\u65B0\u7248\u672C ${target}\uFF08\u73B0\u5728 ${current}\uFF09`,behind:(name,current,end)=>`${name} ${current} \u7248\u672C\u8F83\u65E7${end?`\uFF0C${end} \u8D77\u4E0D\u518D\u652F\u6301`:"\uFF0C\u4E4B\u540E\u4F1A\u505C\u6B62\u652F\u6301"}`,unsupported:(name,current)=>`${name} ${current} \u5DF2\u4E0D\u518D\u652F\u6301\uFF0C\u56DE\u5408\u6B63\u5728\u88AB\u62D2\u7EDD`}};var shortPluginName=name=>name.split("/").pop()??name;var isShown=p=>p.level==="available"&&p.target!==null||p.level==="behind"||p.level==="unsupported";var shownPlugins=a=>a.plugins.filter(isShown);var needsAttention=a=>a.state==="unread"||a.unpublished||shownPlugins(a).length>0;function headline(advice){const plugins=advice.agents.flatMap(shownPlugins);if(plugins.some(p=>p.level==="unsupported"))return AGENT_UPGRADE_TEXT.line.unsupported;if(plugins.some(p=>p.level==="behind"))return AGENT_UPGRADE_TEXT.line.behind;const n=advice.agents.filter(a=>shownPlugins(a).length>0).length;return n>0?AGENT_UPGRADE_TEXT.line.available(n):null}function useAgentUpgrade(ctx,workshop,enabled){const api=ctx.app.data.write?.agentUpgrade;const[advice,setAdvice]=useState9(null);const[error,setError]=useState9(null);const load=useCallback3(()=>{if(!api||!enabled)return;api.advice(workshop).then(a=>{setAdvice(a);setError(null)},e=>{setAdvice(null);setError(isForbidden3(e)?null:failedBecause3(e,"\u70B9\u91CD\u8BD5"))})},[api,enabled,workshop]);useEffect9(()=>{load()},[load]);return{advice,error,reload:load}}function PluginRow({p,slug,pinned}){const T=AGENT_UPGRADE_TEXT;const name=shortPluginName(p.name);const text=p.level==="available"?T.plugin.available(name,p.current,p.target):p.level==="behind"?T.plugin.behind(name,p.current,p.endOfSupport):T.plugin.unsupported(name,p.current);return jsxs12("li",{"data-agent-upgrade-plugin":`${slug}/${p.name}`,"data-level":p.level,children:[jsx12("b",{children:text}),p.edit?jsxs12(Fragment12,{children:[jsx12("p",{children:T.block.editHint(p.edit.file,p.edit.dependency,p.edit.version)}),jsx12("p",{children:T.block.pipeline}),pinned&&jsx12("p",{children:T.block.republish})]}):jsx12("p",{children:"\u6682\u65F6\u8FD8\u6CA1\u6709\u9A8C\u8BC1\u8FC7\u7684\u65B0\u7248\u672C\u53EF\u4EE5\u5347\u7EA7\u5230\u3002"}),p.changelog.length>0&&jsxs12("details",{className:"band-workshops-details",children:[jsx12("summary",{children:T.block.changelog}),p.changelog.map(c=>jsxs12("section",{children:[jsx12("h4",{children:c.version}),jsx12("pre",{className:"band-workshops-agent-upgrade-log",children:c.body})]},c.version))]})]})}function AgentUpgradeBlock({advice,error,reload,labelOf}){if(error)return jsxs12(ErrorNote8,{retry:reload,children:["Agent \u63D2\u4EF6\u7248\u672C\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});const agents=advice?.agents.filter(needsAttention)??[];if(agents.length===0)return null;return jsxs12("section",{className:"band-workshops-agent-upgrade","aria-label":AGENT_UPGRADE_TEXT.block.title,"data-agent-upgrade-block":true,children:[jsx12("h3",{children:AGENT_UPGRADE_TEXT.block.title}),agents.map(a=>jsxs12("div",{"data-agent-upgrade-agent":a.slug,children:[jsx12("h4",{children:labelOf(a.slug)}),a.state==="unread"&&jsx12("p",{children:AGENT_UPGRADE_TEXT.block.unread}),a.unpublished&&jsx12("p",{children:AGENT_UPGRADE_TEXT.block.unpublished}),jsx12("ul",{children:shownPlugins(a).map(p=>jsx12(PluginRow,{p,slug:a.slug,pinned:a.source==="snapshot"},p.name))})]},a.slug))]})}var RESTORE_HINT="\u5728\u5DE5\u574A\u76EE\u5F55\u53F3\u4E0A\u89D2\u7684\u300C\u5DF2\u5F52\u6863\u300D\u91CC\u627E\u5230\u5B83\uFF0C\u6216\u76F4\u63A5\u6253\u5F00\u5B83\u7684\u5730\u5740\uFF0C\u70B9\u300C\u590D\u539F\u5DE5\u574A\u300D\u3002";function ArchivedNotice({api,workshop,onChanged}){const[busy,setBusy]=useState10(false);const[error,setError]=useState10("");const restore=async()=>{if(!api||busy)return;setBusy(true);setError("");try{await api.set(workshop,false);onChanged()}catch(e){setError(`\u6CA1\u590D\u539F\u6210\uFF1A${failedBecause4(e,"\u518D\u70B9\u4E00\u6B21\u300C\u590D\u539F\u5DE5\u574A\u300D")}`)}finally{setBusy(false)}};return jsxs13("output",{className:"band-workshops-status",children:["\u5DE5\u574A\u5DF2\u5F52\u6863\uFF1A\u4E0D\u5728\u5DE5\u574A\u76EE\u5F55\u91CC\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF0C\u5DF2\u6709\u9879\u76EE\u7167\u5E38\u4F7F\u7528\u3002",api&&jsxs13(Fragment13,{children:[" ",jsx13("button",{type:"button",className:"btn sm",disabled:busy,onClick:()=>void restore(),children:busy?"\u6B63\u5728\u590D\u539F\u2026":"\u590D\u539F\u5DE5\u574A"})]}),error&&jsx13(SettingsSaveState3,{failed:error})]})}function WorkshopArchiveTab({api,workshop,name,archived,onChanged}){const[dialog,setDialog]=useState10(false);const[busy,setBusy]=useState10(false);const[error,setError]=useState10("");const restore=async()=>{if(busy)return;setBusy(true);setError("");try{await api.set(workshop,false);onChanged()}catch(e){setError(`\u6CA1\u590D\u539F\u6210\uFF1A${failedBecause4(e,"\u518D\u70B9\u4E00\u6B21\u300C\u590D\u539F\u5DE5\u574A\u300D")}`)}finally{setBusy(false)}};return jsxs13(Fragment13,{children:[jsx13(SettingsDanger,{children:archived?jsx13(SettingsDangerRow,{title:"\u5DE5\u574A\u5DF2\u5F52\u6863",note:"\u590D\u539F\u540E\u56DE\u5230\u5DE5\u574A\u76EE\u5F55\uFF0C\u53EF\u4EE5\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\u3002",action:jsx13("button",{type:"button",className:"btn",disabled:busy,onClick:()=>void restore(),children:busy?"\u6B63\u5728\u590D\u539F\u2026":"\u590D\u539F\u5DE5\u574A"})}):jsx13(SettingsDangerRow,{title:"\u5F52\u6863\u5DE5\u574A",note:"\u4ECE\u5DE5\u574A\u76EE\u5F55\u91CC\u6536\u8D77\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF1B\u5DF2\u6709\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u968F\u65F6\u53EF\u4EE5\u590D\u539F\u3002",action:jsx13("button",{type:"button",className:"btn danger",onClick:()=>setDialog(true),children:"\u5F52\u6863\u5DE5\u574A"})})}),error&&jsx13(SettingsSaveState3,{failed:error}),dialog&&jsx13(ArchiveDialog,{api,workshop,name,onClose:()=>setDialog(false),onDone:()=>{setDialog(false);onChanged()}})]})}function ArchiveDialog({api,workshop,name,onClose,onDone}){const[busy,setBusy]=useState10(false);const[error,setError]=useState10("");const go=async()=>{if(busy)return;setBusy(true);setError("");try{await api.set(workshop,true);onDone()}catch(e){setError(`\u6CA1\u5F52\u6863\u6210\uFF1A${failedBecause4(e,"\u518D\u70B9\u4E00\u6B21\u300C\u5F52\u6863\u5DE5\u574A\u300D")}`);setBusy(false)}};return jsxs13(SettingsDialog2,{title:`\u5F52\u6863\u5DE5\u574A\u300C${name}\u300D\uFF1F`,onClose:()=>!busy&&onClose(),actions:jsxs13(Fragment13,{children:[jsx13("button",{type:"button",className:"btn ghost",disabled:busy,onClick:onClose,children:"\u53D6\u6D88"}),jsx13("button",{type:"button",className:"btn danger",disabled:busy,onClick:()=>void go(),children:busy?"\u6B63\u5728\u5F52\u6863\u2026":"\u5F52\u6863\u5DE5\u574A"})]}),children:[jsxs13("ul",{children:[jsx13("li",{children:"\u5DE5\u574A\u4ECE\u5DE5\u574A\u76EE\u5F55\u91CC\u6D88\u5931\uFF0C\u4E0D\u80FD\u518D\u7528\u5B83\u65B0\u5EFA\u9879\u76EE\uFF0C\u4E5F\u4E0D\u80FD\u57FA\u4E8E\u5B83\u65B0\u5EFA\u5DE5\u574A\u3002"}),jsx13("li",{children:"\u7528\u5B83\u5EFA\u7684\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u7167\u5E38\u4F7F\u7528\u3002"}),jsx13("li",{children:"\u5DE5\u574A\u7684\u4ED3\u5E93\u4E0E\u5B9A\u4E49\u90FD\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u5220\u9664\u4EFB\u4F55\u5185\u5BB9\u3002"}),jsxs13("li",{children:["\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u3001\u7BA1\u7406\u5458\u548C Band \u7BA1\u7406\u5458\u968F\u65F6\u53EF\u4EE5\u590D\u539F\uFF1A",RESTORE_HINT]})]}),error&&jsx13(SettingsSaveState3,{failed:error})]})}var FOLLOW_RUNS_TEXT={title:"\u8DDF\u968F\u8BB0\u5F55",lead:"\u5171\u4EAB\u63D2\u4EF6\u53D1\u65B0\u7248\u672C\u3001\u64A4\u56DE\u6216\u53D6\u6D88\u64A4\u56DE\u540E\uFF0CBand \u4F1A\u66FF\u5F15\u7528\u5B83\u7684\u5DE5\u574A\u91CD\u65B0\u53D1\u5E03\u4E00\u6B21\uFF1B\u8FD9\u91CC\u662F\u6BCF\u6B21\u7684\u7ED3\u679C\u3002",empty:"\u8FD8\u6CA1\u6709\u8DDF\u968F\u8BB0\u5F55\uFF1A\u5F15\u7528\u7684\u5171\u4EAB\u63D2\u4EF6\u8FD8\u6CA1\u53D1\u8FC7\u65B0\u7248\u672C\uFF0C\u6216\u6CA1\u88AB\u64A4\u56DE\u8FC7\u3002",head:["\u65F6\u95F4","\u89E6\u53D1","\u7ED3\u679C"],kind:{registered:"\u53D1\u5E03\u4E86\u65B0\u7248\u672C",yanked:"\u88AB\u64A4\u56DE",unyanked:"\u53D6\u6D88\u64A4\u56DE"},outcome:{changed:seq=>`\u5DF2\u91CD\u65B0\u53D1\u5E03\u4E3A v${seq}`,unchanged:"\u65E0\u9700\u91CD\u65B0\u53D1\u5E03\uFF1A\u8FD9\u4E2A\u5DE5\u574A\u7684\u5185\u5BB9\u6CA1\u6709\u53D8\u5316",failed:"\u6CA1\u6709\u8DDF\u4E0A"},unknownReason:"\u539F\u56E0\u6CA1\u6709\u8BB0\u5F55",more:"\u53EA\u663E\u793A\u6700\u8FD1 50 \u6761\u3002",load:reason=>`\u8DDF\u968F\u8BB0\u5F55\u6CA1\u8BFB\u51FA\u6765\uFF1A${reason}`};var FOLLOW_RUNS_PAGE=50;function triggerText(r){return`${r.pluginName} ${r.triggerVersion} ${FOLLOW_RUNS_TEXT.kind[r.kind]}`}function outcomeText(r){const T=FOLLOW_RUNS_TEXT.outcome;if(r.status==="changed")return r.releaseSeq===null?"\u5DF2\u91CD\u65B0\u53D1\u5E03":T.changed(r.releaseSeq);if(r.status==="unchanged")return T.unchanged;return`${T.failed}\uFF1A${r.reasonText??FOLLOW_RUNS_TEXT.unknownReason}`}function useFollowRuns(ctx,workshop){const api=ctx.app.data.write?.followRuns;const[state,setState]=useState11(api?{kind:"loading"}:{kind:"hidden"});const load=useCallback4(()=>{if(!api)return;api.list(workshop).then(r=>setState({kind:"ok",runs:r.runs}),e=>setState(isForbidden4(e)?{kind:"hidden"}:{kind:"error",reason:failedBecause5(e,"\u70B9\u91CD\u8BD5")}))},[api,workshop]);useEffect10(()=>{setState(api?{kind:"loading"}:{kind:"hidden"});load()},[api,load]);return{state,reload:load}}function Row({r}){return jsxs14("li",{className:"band-workshops-follow-row","data-follow-run":`${r.pluginName}@${r.triggerVersion}:${r.kind}`,"data-status":r.status,children:[jsx14("code",{className:"band-workshops-follow-when",children:localDay(r.createdAt)}),jsx14("span",{className:"band-workshops-follow-trigger",children:triggerText(r)}),jsxs14("span",{className:"band-workshops-follow-outcome",children:[jsx14("span",{className:"band-workshops-follow-status","data-status":r.status,children:outcomeText(r)}),r.status==="failed"&&r.reasonCode&&jsx14("code",{children:r.reasonCode})]})]})}function FollowRuns({ctx,workshop}){const{state,reload}=useFollowRuns(ctx,workshop);if(state.kind==="hidden")return null;const T=FOLLOW_RUNS_TEXT;return jsxs14("section",{className:"band-workshops-follow","aria-label":T.title,"data-follow-runs":true,children:[jsx14("h3",{className:"band-workshops-sub",children:T.title}),jsx14("p",{className:"band-workshops-note",children:T.lead}),state.kind==="loading"&&jsx14("span",{className:"band-workshops-sk is-block","aria-busy":"true"}),state.kind==="error"&&jsx14(ErrorNote9,{retry:reload,children:T.load(state.reason)}),state.kind==="ok"&&(state.runs.length===0?jsx14("p",{className:"band-workshops-note","data-follow-empty":true,children:T.empty}):jsxs14(Fragment14,{children:[jsx14("ul",{className:"band-workshops-follow-list",children:state.runs.map(r=>jsx14(Row,{r},`${r.pluginName}@${r.triggerVersion}:${r.kind}:${r.createdAt}`))}),state.runs.length>=FOLLOW_RUNS_PAGE&&jsx14("p",{className:"band-workshops-note",children:T.more})]}))]})}var ROLE_LABEL={owner:"\u521B\u5EFA\u4EBA",maintainer:"\u7BA1\u7406\u5458"};var lastOne=v=>v.people.length<=1;function AddMaintainer({api,directory,workshop,view,onDone,onCancel}){const[picked,setPicked]=useState12(null);const[busy,setBusy]=useState12(false);const[error,setError]=useState12(null);const disabled=view.people.map(p=>({id:p.userId,reason:"\u5DF2\u7ECF\u80FD\u7BA1\u8FD9\u4E2A\u5DE5\u574A"}));async function submit(){if(!picked)return setError("\u8FD8\u6CA1\u9009\u4EBA\uFF1A\u641C\u59D3\u540D\u3001ldap \u6216\u90E8\u95E8");setBusy(true);setError(null);try{onDone(await api.add(workshop,picked.id))}catch(e){setError(`\u6CA1\u52A0\u4E0A\uFF1A${errorText7(e)}`)}finally{setBusy(false)}}return jsxs15("form",{className:"band-workshops-people-form","aria-label":"\u6DFB\u52A0\u7BA1\u7406\u5458",onSubmit:e=>{e.preventDefault();void submit()},children:[jsxs15("div",{className:"band-workshops-people-field",children:[jsxs15("span",{className:"band-workshops-people-label",children:["\u8BBE\u8C01\u4E3A\u7BA1\u7406\u5458 ",jsx15("span",{className:"band-workshops-people-hint",children:"\u5FC5\u586B"})]}),jsx15(PersonSearch,{label:"\u8BBE\u8C01\u4E3A\u7BA1\u7406\u5458",directory,picked:picked?[picked]:[],onPick:p=>{setPicked(p[0]??null);setError(null)},onUnpick:()=>setPicked(null),disabled,allowUnknown:true,busy})]}),jsx15("p",{className:"band-workshops-people-hint",children:"\u7BA1\u7406\u5458\u80FD\u53D1\u5E03\u65B0\u7248\u3001\u6539\u5DE5\u574A\u8BBE\u7F6E\u3001\u7BA1\u5DE5\u574A\u7684\u7BA1\u7406\u5458\uFF1B\u4E0D\u662F\u5DE5\u574A\u6210\u5458\u7684\u4EBA\u4F1A\u540C\u65F6\u6210\u4E3A\u6210\u5458\u3002"}),jsx15(ErrorNote10,{children:error}),jsxs15("div",{className:"band-workshops-people-actions",children:[jsx15("button",{type:"submit",className:"btn primary sm",disabled:busy||!picked,children:busy?"\u6B63\u5728\u6DFB\u52A0\u2026":"\u8BBE\u4E3A\u7BA1\u7406\u5458"}),jsx15("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function ConfirmRemoveMaintainer({api,workshop,person,self,onDone,onCancel}){const[busy,setBusy]=useState12(false);const[error,setError]=useState12(null);async function remove(){setBusy(true);setError(null);try{onDone(await api.remove(workshop,person.userId))}catch(e){setError(errorText7(e))}finally{setBusy(false)}}return jsxs15("fieldset",{className:"band-workshops-people-form","aria-label":`\u79FB\u9664 ${person.displayName}`,children:[jsx15("p",{children:self?"\u628A\u81EA\u5DF1\u4ECE\u7BA1\u7406\u5458\u91CC\u79FB\u9664\uFF1F\u4F60\u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3001\u80FD\u7528\u5B83\u5EFA\u9879\u76EE\uFF0C\u4F46\u4E0D\u80FD\u518D\u7BA1\u8FD9\u4E2A\u5DE5\u574A\uFF0C\u8981\u522B\u7684\u7BA1\u7406\u5458\u518D\u52A0\u56DE\u6765\u3002":`\u628A ${person.displayName} \u4ECE\u7BA1\u7406\u5458\u91CC\u79FB\u9664\uFF1F${person.displayName} \u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3001\u80FD\u7528\u5B83\u5EFA\u9879\u76EE\u3002`}),jsx15(ErrorNote10,{children:error}),jsxs15("div",{className:"band-workshops-people-actions",children:[jsx15("button",{type:"button",className:"btn danger sm",disabled:busy,onClick:()=>void remove(),children:busy?"\u6B63\u5728\u79FB\u9664\u2026":"\u79FB\u9664"}),jsx15("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function ConfirmTransferOwner({transfer,workshop,person,owner,self,onDone,onCancel}){const[busy,setBusy]=useState12(false);const[error,setError]=useState12(null);async function go(){setBusy(true);setError(null);try{onDone(await transfer(workshop,person.userId))}catch(e){setError(`\u6CA1\u8F6C\u4EA4\u6210\uFF1A${errorText7(e)}`)}finally{setBusy(false)}}const who=person.displayName;const text=self?`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${who}\uFF1F\u8F6C\u4EA4\u540E\u4F60\u53D8\u6210\u7BA1\u7406\u5458\uFF0C\u518D\u8F6C\u4EA4\u521B\u5EFA\u4EBA\u53EA\u6709 ${who} \u80FD\u505A\u3002`:owner?`\u628A\u521B\u5EFA\u4EBA\u4ECE ${owner.displayName} \u8F6C\u4EA4\u7ED9 ${who}\uFF1F${owner.displayName} \u53D8\u6210\u7BA1\u7406\u5458\u3002`:`\u8BA9 ${who} \u6210\u4E3A\u8FD9\u4E2A\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\uFF1F\u4E4B\u540E\u518D\u8F6C\u4EA4\u521B\u5EFA\u4EBA\u7531 ${who} \u505A\u3002`;return jsxs15("fieldset",{className:"band-workshops-people-form","aria-label":`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${who}`,children:[jsx15("p",{children:text}),jsx15(ErrorNote10,{children:error}),jsxs15("div",{className:"band-workshops-people-actions",children:[jsx15("button",{type:"button",className:"btn primary sm",disabled:busy,onClick:()=>void go(),children:busy?"\u6B63\u5728\u8F6C\u4EA4\u2026":"\u8F6C\u4EA4"}),jsx15("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:onCancel,children:"\u53D6\u6D88"})]})]})}function Maintainers({api,directory,workshop,me}){const[view,setView]=useState12(null);const[error,setError]=useState12(null);const[open,setOpen]=useState12(null);const[tick,setTick]=useState12(0);useEffect11(()=>{let live=true;setError(null);api.get(workshop).then(v=>live&&setView(v),e=>live&&setError(errorText7(e)));return()=>{live=false}},[api,workshop,tick]);const done=next=>{setView(next);setOpen(null)};if(view===null){return error?jsxs15(ErrorNote10,{retry:()=>setTick(t=>t+1),children:["\u7BA1\u7406\u5458\u540D\u5355\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}):jsx15("p",{className:"band-workshops-note","aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u7BA1\u7406\u5458\u2026"})}const order=view.people.map(p=>p.userId);const owner=view.people.find(p=>p.role==="owner")??null;const transfer=view.canTransfer?api.transfer:void 0;return jsxs15("div",{className:"band-workshops-people",children:[view.canManage&&jsx15("div",{className:"band-workshops-people-bar",children:open?.kind==="add"?jsx15(AddMaintainer,{api,directory,workshop,view,onDone:done,onCancel:()=>setOpen(null)}):jsx15("button",{type:"button",className:"btn primary sm",onClick:()=>setOpen({kind:"add"}),children:"\u6DFB\u52A0\u7BA1\u7406\u5458"})}),view.canManage&&owner===null&&view.people.length>0&&jsxs15("p",{className:"band-workshops-note",children:["\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u521B\u5EFA\u4EBA\uFF08\u539F\u521B\u5EFA\u4EBA\u5DF2\u79BB\u5F00\uFF09\u3002",transfer?"\u8BF7\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\u3002":"Band \u7BA1\u7406\u5458\u80FD\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\u3002"]}),view.people.length===0?jsx15("p",{className:"band-workshops-note",children:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u5DE5\u574A\u7BA1\u7406\u5458\uFF0C\u7531 Band \u7BA1\u7406\u5458\u7BA1\u3002"}):jsx15("ul",{className:"band-workshops-people-card","aria-label":`\u7BA1\u7406\u5458 ${view.people.length}`,children:view.people.map(p=>{const removing=open?.kind==="remove"&&open.id===p.userId;const transferring=open?.kind==="transfer"&&open.id===p.userId;const removable=view.canManage&&p.role==="maintainer"&&!lastOne(view);return jsxs15("li",{className:"band-workshops-people-row",children:[jsxs15("div",{className:"band-workshops-people-line",children:[jsx15(Avatar3,{id:p.userId,name:p.displayName,order,size:"md",decorative:true}),jsxs15("span",{className:"band-workshops-people-who",children:[jsx15("b",{title:p.displayName,children:p.displayName}),jsxs15("span",{children:[ROLE_LABEL[p.role]," \xB7 ",p.userId]})]}),(removable&&!removing||transfer&&p.role==="maintainer"&&!transferring)&&jsxs15("span",{className:"band-workshops-people-ops",children:[transfer&&p.role==="maintainer"&&!transferring&&jsx15("button",{type:"button",className:"btn ghost sm","aria-label":`\u628A\u521B\u5EFA\u4EBA\u8F6C\u4EA4\u7ED9 ${p.displayName}`,onClick:()=>setOpen({kind:"transfer",id:p.userId}),children:"\u8F6C\u4EA4\u521B\u5EFA\u4EBA"}),removable&&!removing&&jsx15("button",{type:"button",className:"btn ghost sm","aria-label":`\u79FB\u9664 ${p.displayName}`,onClick:()=>setOpen({kind:"remove",id:p.userId}),children:"\u79FB\u9664"})]}),view.canManage&&p.role==="maintainer"&&lastOne(view)&&jsx15("span",{className:"band-workshops-people-hint band-workshops-people-ops",children:"\u6700\u540E\u4E00\u4E2A\u7BA1\u7406\u5458\uFF0C\u4E0D\u80FD\u79FB\u9664"})]}),transferring&&transfer&&jsx15(ConfirmTransferOwner,{transfer,workshop,person:p,owner,self:owner?.userId===me,onDone:done,onCancel:()=>setOpen(null)}),removing&&jsx15(ConfirmRemoveMaintainer,{api,workshop,person:p,self:p.userId===me,onDone:done,onCancel:()=>setOpen(null)})]},p.userId)})}),jsx15("p",{className:"band-workshops-note",children:"\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u53D1\u5E03\u65B0\u7248\u3001\u6539\u5DE5\u574A\u8BBE\u7F6E\u3001\u7BA1\u5DE5\u574A\u7684\u7BA1\u7406\u5458\u3002\u521B\u5EFA\u4EBA\u4E0D\u80FD\u79FB\u9664\uFF0C\u8981\u5148\u8F6C\u4EA4\u7ED9\u4E00\u4F4D\u7BA1\u7406\u5458\uFF1B\u5DE5\u574A\u81F3\u5C11\u8981\u7559\u4E00\u4E2A\u7BA1\u7406\u5458\u3002 \u79FB\u9664\u7684\u7BA1\u7406\u5458\u4ECD\u662F\u5DE5\u574A\u6210\u5458\u3002"})]})}function TrialProjects({ctx,data,reload,onCreate,openProject}){const api=ctx.app.data.write?.trialProjects;const[target,setTarget]=useState13(null);const[open,setOpen]=useState13(false);const[busy,setBusy]=useState13(false);const[failed,setFailed]=useState13(null);const[forbidden,setForbidden]=useState13(false);const[ended,setEnded]=useState13(null);const modal=useModalDialog({open,blocked:busy,onRequestClose:()=>setOpen(false)});if(!api||!data.canManage||forbidden)return jsx16("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u7BA1\u7406\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\u3002"});const end=async()=>{if(!target||busy)return;setBusy(true);setFailed(null);try{await api.end(target.id);setEnded(target.name);setOpen(false);reload()}catch(e){if(isForbidden5(e)){setForbidden(true);setOpen(false);reload()}else setFailed(errorText8(e))}finally{setBusy(false)}};return jsxs16(Fragment15,{children:[jsx16("h2",{children:"\u8BD5\u7528\u9879\u76EE"}),jsx16("p",{className:"band-workshops-note",children:"\u7528 test \u69FD\u9A8C\u8BC1\u5DE5\u574A\u7684\u4E0B\u4E00\u7248\uFF0C\u8BD5\u7528\u9879\u76EE\u4F1A\u8DDF\u968F\u8FD9\u4E2A\u69FD\u66F4\u65B0\u3002\u666E\u901A\u9879\u76EE\u4E0D\u53D7\u5F71\u54CD\uFF0C\u5DF2\u6709\u6B63\u5F0F\u9879\u76EE\u4E0D\u80FD\u6539\u6210\u8BD5\u7528\u3002"}),data.createBlocked?jsxs16("p",{className:"band-workshops-note",children:["\u6682\u65F6\u4E0D\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF1A",data.createBlocked]}):jsx16("button",{type:"button",className:"btn",onClick:onCreate,children:"\u7528 test \u69FD\u5F00\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE"}),jsx16("h3",{children:"\u4F60\u53EF\u8BBF\u95EE\u7684\u8BD5\u7528\u9879\u76EE"}),jsx16("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u53EA\u5217\u4F60\u5DF2\u6709\u8BFB\u53D6\u6743\u9650\u7684\u9879\u76EE\u3002\u5176\u4ED6\u4EBA\u521B\u5EFA\u7684\u79C1\u6709\u9879\u76EE\uFF0C\u8BF7\u5148\u8BA9\u9879\u76EE\u6210\u5458\u628A\u4F60\u52A0\u5165\u3002"}),ended&&jsxs16("output",{children:["\u5DF2\u7ED3\u675F\u300C",ended,"\u300D\u7684\u8BD5\u7528\uFF0C\u8FD9\u4E2A\u9879\u76EE\u5DF2\u53D8\u4E3A\u6B63\u5F0F\u9879\u76EE\u3002"]}),data.projects.length===0?jsxs16("p",{className:"band-workshops-note",children:["\u4F60\u53EF\u8BBF\u95EE\u7684\u9879\u76EE\u4E2D\u8FD8\u6CA1\u6709\u8BD5\u7528\u9879\u76EE\u3002",data.createBlocked?"\u5148\u6309\u4E0A\u9762\u7684\u63D0\u793A\u8BA9\u5DE5\u574A\u51C6\u5907\u597D\u3002":"\u70B9\u300C\u7528 test \u69FD\u5F00\u4E00\u4E2A\u8BD5\u7528\u9879\u76EE\u300D\u5F00\u59CB\u9A8C\u8BC1\u3002"]}):jsx16("ul",{className:"band-workshops-trials",children:data.projects.map(p=>jsxs16("li",{children:[jsx16("button",{type:"button",className:"band-workshops-link",onClick:()=>openProject(p.id),children:p.name}),jsx16("span",{className:"chip plain",children:"\u8BD5\u7528\u9879\u76EE \xB7 test \u69FD"}),jsx16("button",{type:"button",className:"btn sm",ref:target?.id===p.id?modal.trigger:void 0,onClick:()=>{setFailed(null);setTarget(p);setOpen(true)},children:"\u7ED3\u675F\u8BD5\u7528"})]},p.id))}),jsx16("dialog",{ref:modal.dialog,"aria-labelledby":"band-trial-end-title",className:"band-workshops-publish-dialog","data-band-layer":open?"dialog":void 0,onCancel:e=>{e.preventDefault();if(!busy)setOpen(false)},children:jsxs16("div",{className:"band-workshops-publish-body",children:[jsxs16("h2",{id:"band-trial-end-title",className:"band-workshops-publish-title",children:["\u7ED3\u675F\u300C",target?.name,"\u300D\u7684\u8BD5\u7528\uFF1F"]}),jsx16("p",{children:"\u8FD9\u4E2A\u9879\u76EE\u4F1A\u53D8\u4E3A\u6B63\u5F0F\u9879\u76EE\uFF0C\u4E0D\u80FD\u518D\u6539\u56DE\u8BD5\u7528\u3002\u540E\u7EED\u56DE\u5408\u6309\u6B63\u5F0F\u9879\u76EE\u7684\u89C4\u5219\u4F7F\u7528 Agent \u7248\u672C\uFF1B\u5DF2\u7ECF\u6D3E\u51FA\u7684\u56DE\u5408\u4F1A\u7EE7\u7EED\u8DD1\u5B8C\uFF0C\u5DF2\u6709\u5185\u5BB9\u4FDD\u7559\u3002"}),jsx16("p",{children:"\u8FD9\u4E0D\u4F1A\u628A\u5DE5\u574A\u7684 test \u69FD\u4E0A\u7EBF\u5230 production \u69FD\u3002"}),failed&&jsxs16(ErrorNote11,{children:["\u6CA1\u7ED3\u675F\u8BD5\u7528\uFF1A",failed,"\u3002\u53EF\u4EE5\u518D\u70B9\u300C\u786E\u5B9A\u7ED3\u675F\u8BD5\u7528\u300D\u3002"]}),jsxs16("div",{className:"band-workshops-actions",children:[jsx16("button",{type:"button",className:"btn ghost",disabled:busy,onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),jsx16("button",{type:"button",className:"btn primary",disabled:busy,onClick:()=>void end(),children:busy?"\u6B63\u5728\u7ED3\u675F\u8BD5\u7528\u2026":"\u786E\u5B9A\u7ED3\u675F\u8BD5\u7528"})]})]})})]})}function upgradeCounts(status){const incompatible=status.projects.filter(p=>!p.archived&&p.pins.some(pin=>pin.incompatibleRoles.length>0)).length;return{outdated:status.outdatedProjects,incompatible}}function upgradeGroups(status){const archived=status.projects.filter(p=>p.archived);const changing=p=>!p.archived&&(p.outdated||p.pins.some(pin=>pin.incompatibleRoles.length>0));return{willUpdate:status.projects.filter(changing),archived,latest:status.projects.filter(p=>!p.archived&&!changing(p))}}function useUpgradeStatus(ctx,workshop,enabled){const api=ctx.app.data.write?.workshopUpgrade;const[status,setStatus]=useState14(null);useEffect12(()=>{if(!api||!enabled)return;let live=true;const load=()=>api.status(workshop).then(s=>live&&setStatus(s),()=>live&&setStatus(null));void load();const off=ctx.app.data.subscribe(()=>void load());return()=>{live=false;off()}},[ctx,api,workshop,enabled]);return status}var currentBehindOf=status=>status.current.outdatedRoles.length>0||(status.current.outdatedOfficialPlugins??[]).length>0;function WorkshopUpgrade({ctx,workshop,showHints=true}){const api=ctx.app.data.write?.workshopUpgrade;const[status,setStatus]=useState14(null);const[loadError,setLoadError]=useState14(null);const[confirming,setConfirming]=useState14(false);const[busy,setBusy]=useState14(false);const[result,setResult]=useState14(null);const[runError,setRunError]=useState14(null);const inFlight=useRef6(false);const load=useCallback5(()=>{if(!api)return;api.status(workshop).then(s=>{setStatus(s);setLoadError(null)},e=>{setStatus(null);setLoadError(isForbidden6(e)?null:failedBecause6(e,"\u70B9\u91CD\u8BD5"))})},[api,workshop]);useEffect12(()=>{load();return ctx.app.data.subscribe(load)},[ctx,load]);const behind=status?.outdatedProjects??0;useEffect12(()=>{if(behind===0)setConfirming(false)},[behind]);const{dialog,trigger}=useModalDialog({open:confirming,onRequestClose:()=>setConfirming(false),blocked:busy});if(!api)return null;if(loadError)return jsxs17(ErrorNote12,{retry:load,children:["\u5347\u7EA7\u72B6\u6001\u6CA1\u8BFB\u51FA\u6765\uFF1A",loadError]});if(!status)return null;const{outdated,incompatible}=upgradeCounts(status);const currentBehind=status.current.outdatedRoles.length>0||(status.current.outdatedOfficialPlugins??[]).length>0;const hints=status.referenceHints??[];const hint=showHints&&hints.length>0?jsx17(ReferenceHints,{hints}):null;if(outdated===0&&incompatible===0&&!currentBehind&&!result)return hint;const run=()=>{if(inFlight.current)return;inFlight.current=true;setBusy(true);setRunError(null);api.run(workshop).then(r=>{inFlight.current=false;setBusy(false);setConfirming(false);setResult(r);load()},e=>{inFlight.current=false;setBusy(false);setRunError(failedBecause6(e,"\u518D\u70B9\u4E00\u6B21\u300C\u66F4\u65B0\u300D"))})};const{willUpdate,archived,latest}=upgradeGroups(status);return jsxs17("section",{className:"band-workshops-upgrade","aria-label":"\u66F4\u65B0\u534F\u4F5C\u529F\u80FD",children:[jsxs17("div",{"aria-live":"polite",children:[outdated>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.outdatedProjects(outdated)}),incompatible>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.incompatibleProjects(incompatible)}),currentBehind&&jsx17("p",{children:UPGRADE_TEXT.workshop.currentOutdated})]}),outdated>0&&jsxs17(Fragment16,{children:[jsx17("button",{ref:trigger,type:"button",className:"btn","aria-haspopup":"dialog",onClick:()=>{setRunError(null);setConfirming(true)},children:UPGRADE_TEXT.workshop.button}),jsx17("dialog",{ref:dialog,className:"band-workshops-upgrade-dialog","data-band-layer":confirming?"dialog":void 0,"aria-label":UPGRADE_TEXT.workshop.confirm.title,onCancel:e=>{if(busy)e.preventDefault()},onClose:()=>setConfirming(false),children:jsxs17("div",{className:"band-workshops-upgrade-body",children:[jsx17("h2",{className:"band-workshops-upgrade-title",children:UPGRADE_TEXT.workshop.confirm.title}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.willUpdate(willUpdate)}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.unchanged}),archived.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.archived(archived.length)}),latest.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.alreadyLatest(latest.length)}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.checks}),jsx17("p",{children:UPGRADE_TEXT.workshop.confirm.noUndo}),runError&&jsx17("div",{role:"alert",children:jsx17(ErrorNote12,{children:runError})}),jsxs17("div",{className:"band-workshops-actions",children:[jsx17("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:()=>setConfirming(false),children:"\u53D6\u6D88"}),jsx17("button",{type:"button",className:"btn primary sm","aria-disabled":busy,onClick:run,children:busy?UPGRADE_TEXT.workshop.confirm.busy:UPGRADE_TEXT.workshop.confirm.submit})]})]})})]}),result&&jsx17(UpgradeResult,{result}),hint]})}function ReferenceHints({hints}){const text=UPGRADE_TEXT.workshop.referenceHint;const specs=hints.map(h=>`${h.name}@^${h.version}`);return jsxs17("section",{className:"band-workshops-ref-hint","aria-label":text.title(hints.length),children:[jsx17("p",{className:"band-workshops-ref-hint-title",children:text.title(hints.length)}),jsx17("ul",{children:hints.map(h=>jsx17("li",{children:text.row(h.name,h.version)},h.name))}),jsx17("p",{children:text.how(specs)})]})}function UpgradeResult({result}){const of=kind=>result.projects.filter(p=>p.result===kind);const failed=of("failed").map(p=>({name:p.name,problems:p.failures.flatMap(f=>f.problems)}));const upgraded=of("upgraded");const kept=result.projects.flatMap(p=>p.unchanged).filter(u=>u.reason==="structure_changed"||u.reason==="plan_differs").length;return jsxs17("div",{className:"band-workshops-upgrade-result","data-upgrade-result":true,"aria-live":"polite",children:[result.counts.upgraded>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.upgraded(result.counts.upgraded,upgraded)}),result.counts.current>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.current(result.counts.current)}),result.counts.skipped>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.archived(result.counts.skipped)}),kept>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.keptInstances(kept)}),failed.length>0&&jsx17("p",{children:UPGRADE_TEXT.workshop.result.failed(failed)})]})}function AdminsFact({ctx,w}){const api=ctx.app.data.write?.workshopMaintainers;const[names,setNames]=useState15(null);useEffect13(()=>{if(!api)return;let live=true;api.get(w.id).then(r=>live&&setNames(r.people.map(p=>p.displayName)),()=>live&&setNames(null));return()=>{live=false}},[api,w.id]);const fallback=w.maintainer||"\u6CA1\u6709\u586B\u5199";if(!names||names.length===0)return jsx18(Fragment17,{children:fallback});const shown=names.slice(0,3).join("\u3001");return jsx18(Fragment17,{children:names.length>3?`${shown} \u7B49 ${names.length} \u4EBA`:shown})}var fact=(k,v)=>jsxs18("div",{children:[jsx18("dt",{children:k}),jsx18("dd",{children:v})]},k);function UpdateLine({parts,agentPart,onGo}){const all=[...parts,...agentPart?[agentPart]:[]];if(all.length===0)return null;return jsxs18("p",{className:"wp-line","data-updatable":true,children:[jsx18("span",{className:"chip s-stale",children:"\u53EF\u66F4\u65B0"}),jsx18("span",{children:all.join("\uFF1B")}),parts.length>0&&jsx18("button",{type:"button",className:"btn sm",onClick:()=>onGo("versions"),children:"\u53BB\u300C\u7248\u672C\u300D"}),agentPart&&jsx18("button",{type:"button",className:"btn sm",onClick:()=>onGo("agents"),children:"\u53BB\u300CAgent\u300D"})]})}function About({ctx,id,projectPage}){const{data:w,error,reload}=useWorkshop(ctx,id);const{data:mine}=useAppData5(ctx,d=>d.projects({workshop:id}),[id]);const expiring=useExpiringConnections(ctx,id,w?.canAdmin===true);const[tab,setTab]=useState15("flow");const[showDeploy,setShowDeploy]=useState15(false);const trials=useAppData5(ctx,d=>d.write?.trialProjects?.workshop(id)??Promise.resolve(null),[id]);const[creatingTrial,setCreatingTrial]=useState15(false);const[editUsable,setEditUsable]=useState15(null);const onEditUsable=useCallback6(u=>setEditUsable(u),[]);const built=w!==void 0&&w!==null&&w.status!=="provisioning"&&w.status!=="failed";const agentUp=useAgentUpgrade(ctx,id,w?.canAdmin===true&&built);const model=useModelDeployment(ctx);const upStatus=useUpgradeStatus(ctx,id,w?.canAdmin===true&&built);if(error&&w===void 0){return jsxs18("main",{className:"band-workshops-screen",children:[jsx18(Crumb,{ctx}),jsxs18(ErrorNote13,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})]})}if(w===void 0){return jsx18("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:jsx18("div",{className:"band-workshops-detail",children:jsxs18("div",{className:"band-workshops-stack",children:[jsxs18("div",{className:"band-workshops-whead",children:[jsx18("span",{className:"band-workshops-sk is-tile"}),jsx18("span",{className:"band-workshops-sk is-line"})]}),jsx18("span",{className:"band-workshops-sk is-block"})]})})})}if(w===null)return jsx18(Missing,{ctx,id});if(creatingTrial)return jsx18(NewProject,{ctx,id,projectPage,trial:{onCancel:()=>setCreatingTrial(false)}});const admin=w.canAdmin;const stages=w.workflows[0]?.stages??[];const agents=agentsOf(stages);const peers=agents.map(a=>a.name);const maintainers=ctx.app.data.write?.workshopMaintainers;const visibilityApi=ctx.app.data.write?.workshopVisibility;const archiveApi=admin&&w.origin!==void 0?ctx.app.data.write?.workshopArchive:void 0;const archived=w.archivedAt!==void 0;const modelBlock=archived?"\u5DE5\u574A\u5DF2\u5F52\u6863\uFF0C\u590D\u539F\u540E\u624D\u80FD\u65B0\u5EFA\u9879\u76EE":newProjectBlocked(w);const copyBlock=copyBlocked(w);const noModel=modelMissing(w.model,w.userModelKey);const canCopy=!!ctx.app.data.write?.createWorkshop;const pendingPrimary=modelNeedsYou(w,!!ctx.app.data.write?.workshopModel);const editApiOn=admin&&!!ctx.app.data.write?.workshopEdit;const deployKnown=model.deployment!==void 0||model.error!==null;const editExpected=editApiOn&&deployKnown&&(model.deployment==null||model.deployment.workshopEdit===true);const editSettled=!editApiOn||deployKnown&&(!editExpected||editUsable!==null);const editPrimary=admin&&editExpected&&!pendingPrimary&&editUsable===true;const newPrimary=!pendingPrimary&&!editPrimary&&editSettled;const settingsOn=admin;const tabs=[["flow","\u6D41\u7A0B"],["agents","Agent"],["plugins","\u63D2\u4EF6"],["versions","\u7248\u672C"],...settingsOn?[["settings","\u5DE5\u574A\u8BBE\u7F6E"]]:[]];const samples=mine??[];const goNew=()=>ctx.app.navigate({page:`${SELF}/new`,params:{workshop:w.id}});const goCopy=()=>ctx.app.navigate({page:`${SELF}/copy`,params:{workshop:w.id}});const upParts=[];if(upStatus){const{outdated,incompatible}=upgradeCounts(upStatus);if(outdated>0)upParts.push(UPGRADE_TEXT2.workshop.outdatedProjects(outdated));if(incompatible>0)upParts.push(UPGRADE_TEXT2.workshop.incompatibleProjects(incompatible));if(currentBehindOf(upStatus))upParts.push(UPGRADE_TEXT2.workshop.currentOutdated)}const agentPart=agentUp.advice?headline(agentUp.advice):null;const copiedAdmin=admin&&w.origin!==void 0;return jsxs18("main",{className:"band-workshops-screen wp",children:[jsx18(Crumb,{ctx,w}),jsxs18("header",{className:"wp-head",children:[jsx18(WorkshopEmblem,{icon:w.icon,size:56}),jsxs18("div",{className:"wp-title",children:[jsx18("h1",{className:"band-workshops-name",children:w.name}),jsx18("p",{className:"sub",children:w.description})]}),jsxs18("div",{className:"wp-acts",children:[admin?jsxs18("button",{type:"button",className:"btn",onClick:()=>setTab("settings"),children:["\u5DE5\u574A\u8BBE\u7F6E",(noModel||expiring>0)&&jsx18(Glyph,{kind:"needs"})]}):canCopy&&jsx18("button",{type:"button",className:"btn",disabled:copyBlock!==void 0,title:copyBlock,"aria-describedby":copyBlock?"band-workshops-copy-blocked":void 0,onClick:goCopy,children:"\u57FA\u4E8E\u5B83\u65B0\u5EFA\u5DE5\u574A"}),jsx18("button",{type:"button",className:newPrimary?"btn primary wp-new-project":"btn wp-new-project",disabled:!ctx.app.data.write||modelBlock!==void 0,title:ctx.app.data.write?modelBlock:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE","aria-describedby":modelBlock?"band-workshops-new-blocked":void 0,onClick:goNew,children:"\u7528\u8FD9\u4E2A\u5DE5\u574A\u65B0\u5EFA\u9879\u76EE"}),editExpected&&jsx18(WorkshopEditEntry,{ctx,w,primary:editPrimary,onUsable:onEditUsable}),modelBlock&&jsx18("small",{id:"band-workshops-new-blocked",className:"band-workshops-hint wp-acts-why",children:modelBlock}),canCopy&&copyBlock&&jsx18("small",{id:"band-workshops-copy-blocked",className:"band-workshops-hint wp-acts-why",children:copyBlock})]})]}),jsxs18("dl",{className:"wp-meta","aria-label":"\u5DE5\u574A\u4FE1\u606F",children:[modelOf(w).state!=="not_provisioned"&&fact("\u6A21\u578B",repoBuilding(w)?"\u6B63\u5728\u51C6\u5907":noModel?admin?jsx18("span",{className:"chip s-stale",children:"\u5F85\u914D\u7F6E"}):"\u5F85\u914D\u7F6E":w.userModelKey==="require"?"\u6210\u5458\u81EA\u5DF1\u7684\u6A21\u578B":"\u5DE5\u574A\u7684\u56E2\u961F key"),fact("\u7BA1\u7406\u5458",jsx18(AdminsFact,{ctx,w})),fact("\u53EF\u89C1",visibilityText(w)),fact("\u5728\u7528",`${w.projectCount} \u4E2A\u9879\u76EE`),w.copiedFrom&&jsx18("div",{children:jsx18(CopiedFrom,{ctx,raw:w.copiedFrom})}),w.docs&&fact("\u8BF4\u660E",jsx18("a",{className:"band-workshops-link",href:w.docs,target:"_blank",rel:"noreferrer",children:"\u600E\u4E48\u7528\u8FD9\u4E2A\u5DE5\u574A"})),samples.length>0&&projectPage&&fact("\u4F60\u7684\u9879\u76EE",jsx18("span",{className:"wp-mine",children:samples.map(p=>jsx18("button",{type:"button",className:"band-workshops-link",onClick:()=>ctx.app.navigate({page:projectPage,params:{workshop:w.id,project:p.project.id}}),children:p.project.name},p.project.id))})),admin&&canCopy&&jsx18("div",{className:"wp-meta-act",children:jsx18("dd",{children:jsx18("button",{type:"button",className:"band-workshops-link",disabled:copyBlock!==void 0,title:copyBlock,"aria-describedby":copyBlock?"band-workshops-copy-blocked":void 0,onClick:goCopy,children:"\u57FA\u4E8E\u5B83\u65B0\u5EFA\u5DE5\u574A"})})})]}),jsx18(PendingRows,{ctx,w,primary:pendingPrimary,archiveApi,onChanged:reload,children:admin&&built&&jsx18(UpdateLine,{parts:upParts,agentPart,onGo:t=>setTab(t)})}),jsxs18("section",{className:"wp-main","aria-label":"\u5DE5\u574A\u5185\u5BB9",children:[jsx18("div",{className:"tabs plain wp-tabs",role:"tablist","aria-label":"\u5DE5\u574A\u5185\u5BB9",children:tabs.map(([k,v])=>jsx18("button",{type:"button",role:"tab",id:`band-workshops-tab-${k}`,"aria-selected":tab===k,"aria-controls":"band-workshops-panel",tabIndex:tab===k?0:-1,onClick:()=>setTab(k),onKeyDown:withImeGuard3(e=>{const i=tabs.findIndex(([t])=>t===k);const next=e.key==="ArrowRight"?tabs[(i+1)%tabs.length]:e.key==="ArrowLeft"?tabs[(i-1+tabs.length)%tabs.length]:void 0;if(next){e.preventDefault();setTab(next[0]);document.getElementById(`band-workshops-tab-${next[0]}`)?.focus()}}),children:v},k))}),jsxs18("div",{id:"band-workshops-panel",role:"tabpanel","aria-labelledby":`band-workshops-tab-${tab}`,className:"wp-panel",children:[tab==="flow"&&jsxs18("div",{className:"wp-flow",children:[jsxs18("div",{className:"wp-flow-main",children:[unavailableStageNote(stages)&&jsx18("p",{className:"band-workshops-note",children:unavailableStageNote(stages)}),jsx18(FlowBig,{stages,peers,roles:w.roles,story:flowStory(w),building:repoBuilding(w)})]}),jsxs18("div",{className:"wp-flow-side",children:[jsxs18("section",{className:"wp-sec",children:[jsx18("h2",{children:"\u4EA7\u7269\u7C7B\u578B"}),jsx18(Table,{head:["\u4EA7\u7269\u7C7B\u578B","\u5B58\u5728\u54EA"],rows:w.artifactTypes.map((a,i)=>[artifactTypeDisplayName2(a.name,a.label,i),jsx18("span",{className:"chip plain",children:STORAGE_TEXT[a.storage]??a.storage},"s")]),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u58F0\u660E\u4EA7\u7269\u7C7B\u578B\u3002"}),jsxs18("p",{className:"band-workshops-note",children:[jsx18("b",{children:"\u4EE5\u4EA7\u7269\u4E3A\u4E2D\u5FC3\u3002"}),"\u5DE5\u574A\u4ED3\u5E93\u53EA\u653E\u5B9A\u4E49\uFF1B\u4EA7\u7269\u9ED8\u8BA4\u5B58\u5728 Band\uFF0C\u6BCF\u4E2A\u7248\u672C\u6309\u5185\u5BB9\u54C8\u5E0C\u8BB0\u4E0B\u6765\u3002 \u53EA\u6709\u4EE3\u7801\u7C7B\u4EA7\u7269\u5199\u8FDB\u5DE5\u574A\u58F0\u660E\u7684\u76EE\u6807\u4ED3\u5E93\uFF0CBand \u7528\u81EA\u5DF1\u7684 GitLab \u8D26\u53F7\u5EFA\u5206\u652F\u3001\u5F00 MR\uFF0C\u4ECE\u4E0D\u66FF\u4EBA\u5408\u5E76\u3002"]})]}),jsxs18("section",{className:"wp-sec",children:[jsx18("h2",{children:"\u89D2\u8272"}),jsx18(Table,{head:["\u89D2\u8272","\u80FD\u505A\u4EC0\u4E48"],rows:w.roles.map((r,i)=>[roleDisplayName(r.name,r.label,i),r.permissions.map(p=>PERM_TEXT[p]??p).join("\u3001")||"\u53EA\u80FD\u770B"]),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u58F0\u660E\u89D2\u8272\u3002"})]})]})]}),tab==="agents"&&jsxs18(Fragment17,{children:[noModel&&!admin&&jsx18("div",{className:"band-workshops-callout",children:jsxs18("p",{children:[jsx18("b",{children:"\u8FD9\u4E2A\u5DE5\u574A\u8FD8\u6CA1\u914D\u6A21\u578B\uFF0CAgent \u6682\u65F6\u4E0D\u63A5\u5BF9\u8BDD\u3002"}),jsx18(WhoCanConfigure,{ctx,workshop:w.id})]})}),jsx18("ul",{className:"band-workshops-agents",children:agents.map(a=>jsxs18("li",{className:noModel?"band-workshops-agent is-off":"band-workshops-agent",children:[jsx18(Avatar4,{id:a.name,name:agentLabel2(a.name,a.label),agent:true,instrument:instrumentOf(a.name,peers),size:"md",decorative:true}),jsxs18("span",{className:"band-workshops-agent-t",children:[jsxs18("b",{children:[agentLabel2(a.name,a.label),jsxs18("span",{className:"band-workshops-agent-k",children:[" ","\xB7 ",a.name==="rondo"?"\u5DE5\u574A\u7684\u7B2C\u4E00\u4E2A Agent":"\u81EA\u5B9A\u4E49 Agent"]})]}),jsx18("span",{className:"band-workshops-agent-d",children:agentLine(a,noModel||w.userModelKey==="require"?void 0:w.model,noModel)})]}),noModel&&admin&&jsx18("span",{className:"band-workshops-agent-x",children:jsx18("button",{type:"button",className:"btn sm",onClick:()=>openModelPage(ctx,w.id),children:"\u53BB\u914D\u7F6E"})})]},a.name))}),jsx18(AgentUpgradeBlock,{advice:agentUp.advice,error:agentUp.error,reload:agentUp.reload,labelOf:slug=>agentLabel2(slug,agents.find(a=>a.name===slug)?.label)}),modelOf(w).state!=="not_provisioned"&&jsx18("p",{className:"band-workshops-note",children:w.userModelKey==="require"?"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u7528\u5EFA\u9879\u76EE\u7684\u4EBA\u81EA\u5DF1\u7684\u6A21\u578B\uFF1B\u5728\u4E2A\u4EBA\u8BBE\u7F6E\u91CC\u914D\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u7684 Agent \u90FD\u7528\u5DE5\u574A\u7684\u6A21\u578B\uFF1B\u6539\u6A21\u578B\u53BB\u300C\u5DE5\u574A\u8BBE\u7F6E \xB7 \u6A21\u578B\u300D\u3002"}),jsx18("p",{className:"band-workshops-note",children:"\u5DE5\u574A\u81EA\u5DF1\u7684 Agent \u5404\u6709\u4E00\u4E2A\u9ED8\u8BA4\u5934\u50CF\uFF0C\u5BF9\u8BDD\u91CC\u9760\u5934\u50CF\u5206\u6E05\u662F\u8C01\uFF1BRondo \u7684\u5934\u50CF\u53D6\u81EA Band \u6807\u5FD7\u3002"})]}),tab==="plugins"&&jsxs18(Fragment17,{children:[jsx18(WorkshopPlugins,{ctx,id:w.id}),copiedAdmin&&w.copiedFrom&&jsxs18("section",{className:"wp-sec",children:[jsx18("h2",{children:"\u4ECE\u539F\u5DE5\u574A\u5F15\u7528\u7684\u63D2\u4EF6"}),jsx18(DetachPlugins,{ctx,workshop:w.id},w.version)]}),copiedAdmin&&jsx18(FollowRuns,{ctx,workshop:w.id})]}),tab==="versions"&&jsxs18(Fragment17,{children:[jsxs18("section",{className:"wp-sec",children:[jsxs18("div",{className:"wp-sec-h",children:[jsxs18("div",{children:[jsxs18("h2",{children:["\u73B0\u5728\u662F\u7B2C ",w.version," \u7248"]}),w.releases.length>0&&jsxs18("p",{className:"band-workshops-note",children:[latestLine(w),"\u65B0\u9879\u76EE\u7528\u8FD9\u4E00\u7248\uFF0C\u8FDB\u884C\u4E2D\u7684\u9879\u76EE\u9489\u4F4F\u521B\u5EFA\u65F6\u7684\u7248\u672C\u3002"]})]}),canPublish(w)&&jsx18(PublishRelease,{ctx,w,onDone:reload})]}),admin&&built&&jsx18(WorkshopUpgrade,{ctx,workshop:w.id,showHints:false})]}),jsxs18("section",{className:"wp-sec",children:[jsx18("h2",{children:"\u7248\u672C\u8BB0\u5F55"}),deployCount(w)>0&&jsxs18("label",{className:"choice sm",children:[jsx18("input",{type:"checkbox",className:"checkbox",checked:showDeploy,onChange:e=>setShowDeploy(e.target.checked)}),"\u663E\u793A\u90E8\u7F72\u5E26\u6765\u7684\u7248\u672C\uFF08",deployCount(w)," \u4E2A\uFF09"]}),jsx18(Table,{head:["\u7248\u672C","\u65E5\u671F","\u6539\u52A8"],rows:w.releases.filter(r=>showDeploy||r.note!==DEPLOY_RELEASE_NOTE).map(r=>[jsxs18("code",{children:["v",r.version]},"v"),jsx18("code",{children:localDay2(r.publishedAt)},"d"),r.note||"\u6CA1\u6709\u5199\u8BF4\u660E"]),empty:"\u8FD8\u6CA1\u6709\u53D1\u5E03\u8BB0\u5F55\u3002"})]})]}),tab==="settings"&&settingsOn&&jsxs18(Fragment17,{children:[(()=>{const modelRow=modelOf(w).state!=="not_provisioned"&&(w.userModelKey!=="require"||takeoverNeeded(w))&&!!ctx.app.data.write?.workshopModel;const secretsRow=modelOf(w).state!=="not_provisioned"&&!!ctx.app.data.write?.workshopSecrets;const connRow=!!ctx.app.data.write?.teamConnections;if(!modelRow&&!secretsRow&&!connRow)return null;return jsxs18(Fragment17,{children:[(modelRow||secretsRow)&&jsx18(SettingsSection,{title:"\u6A21\u578B\u4E0E\u51ED\u636E",children:jsxs18(SettingsRows,{label:"\u6A21\u578B\u4E0E\u51ED\u636E",children:[modelRow&&jsx18(SettingsRow,{title:"\u6A21\u578B",meta:[noModel?"\u8FD8\u6CA1\u914D":"\u56E2\u961F\u7528\u7684\u6A21\u578B key"],onOpen:()=>openModelPage(ctx,w.id)}),secretsRow&&jsx18(SettingsRow,{title:"\u5BC6\u94A5",meta:["Agent \u8C03\u5916\u90E8\u670D\u52A1\u8981\u7528\u7684\u5BC6\u94A5"],onOpen:()=>openSecretsPage(ctx,w.id)})]})}),connRow&&jsx18(SettingsSection,{title:"\u8FDE\u63A5",children:jsx18(SettingsRows,{label:"\u8FDE\u63A5",children:jsx18(SettingsRow,{title:"\u56E2\u961F\u8FDE\u63A5",meta:[expiring>0?`${expiring} \u4E2A\u5FEB\u8FC7\u671F\u6216\u5DF2\u8FC7\u671F`:"\u56E2\u961F\u5171\u7528\u7684\u5916\u90E8\u8D26\u53F7"],onOpen:()=>ctx.app.navigate({page:"@kanyun-ai-infra/band-settings/team-connections",params:{workshop:id}})})})})]})})(),(maintainers||visibilityApi)&&jsxs18(SettingsSection,{title:"\u534F\u4F5C",children:[maintainers&&jsx18(Maintainers,{api:maintainers,directory:directoryFor(ctx.people,q=>maintainers.searchUsers(q)),workshop:w.id,me:ctx.app.member.id}),visibilityApi&&jsx18(WorkshopVisibilityTab,{api:visibilityApi,directory:directoryFor(ctx.people,q=>visibilityApi.searchUsers(q)),workshop:w.id})]}),jsxs18(SettingsSection,{title:"\u5DE5\u574A",children:[trials.error&&jsxs18(ErrorNote13,{retry:trials.reload,children:["\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",trials.error]}),!trials.error&&trials.data?.canManage&&jsx18(TrialProjects,{ctx,data:trials.data,reload:trials.reload,onCreate:()=>setCreatingTrial(true),openProject:project=>{if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:w.id,project}})}}),jsx18(SettingsFacts,{items:[{key:"\u540D\u5B57",value:w.name},{key:"\u77ED\u540D",value:jsx18("code",{children:w.id})},{key:"\u5730\u5740",value:jsxs18("code",{children:["/w/",w.id]})},{key:"\u5B9A\u4E49",value:jsxs18(Fragment17,{children:[jsx18("code",{children:"band/workshop.yaml"})," @ ",jsx18("code",{children:w.ref})]})},...w.copiedFrom?[{key:"\u57FA\u4E8E",value:jsx18(CopiedFrom,{ctx,raw:w.copiedFrom,inline:true})}]:[],{key:"\u7EF4\u62A4\u65B9",value:w.maintainer||"\u6CA1\u6709\u586B\u5199"}]})]}),archiveApi&&jsx18(WorkshopArchiveTab,{api:archiveApi,workshop:w.id,name:w.name,archived,onChanged:reload})]})]})]})]})}function latestLine(w){const r=[...w.releases].sort((a,b)=>b.version-a.version)[0];if(!r)return"";const note=r.note===DEPLOY_RELEASE_NOTE?"\u968F\u90E8\u7F72\u66F4\u65B0":r.note||"\u6CA1\u6709\u5199\u8BF4\u660E";return`${localDay2(r.publishedAt)} \u53D1\u5E03\uFF1A${note}\u3002`}function PendingRows({ctx,w,primary,archiveApi,onChanged,children}){return jsxs18("div",{className:"wp-pending",children:[w.status==="failed"&&jsxs18(ErrorNote13,{children:["\u5DE5\u574A\u6CA1\u5EFA\u6210\uFF1A",w.error??"\u539F\u56E0\u672A\u77E5"]}),jsx18(ModelNotice,{ctx,w,onChanged,primary}),w.status==="provisioning"&&jsxs18("output",{className:"band-workshops-status",children:[w.origin==="copied"?"\u6B63\u5728\u5EFA\u5DE5\u574A\u4ED3\u5E93\u5E76\u590D\u5236\u5B9A\u4E49":"\u6B63\u5728\u5EFA\u5DE5\u574A\u4ED3\u5E93","\uFF0C\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\uFF0C\u597D\u4E86\u4F1A\u81EA\u52A8\u51FA\u73B0\u3002"]}),w.archivedAt!==void 0&&jsx18(ArchivedNotice,{api:archiveApi,workshop:w.id,onChanged}),w.overrides&&jsx18(OverrideNotices,{items:w.overrides}),children]})}var src_default=definePlugin({surfaces:{workshops:reactMount(ctx=>jsx19(Catalog,{ctx})),about:reactMount((ctx,{owner})=>jsx19(About,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")})),new:reactMount((ctx,{owner})=>jsx19(NewProject,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")},owner.params.workshop)),resume:reactMount((ctx,{owner})=>jsx19(NewProject,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project"),resume:true},owner.params.workshop)),create:reactMount(ctx=>jsx19(NewWorkshop,{ctx,from:""})),copy:reactMount((ctx,{owner})=>jsx19(NewWorkshop,{ctx,from:owner.params.workshop??""})),model:reactMount((ctx,{owner})=>jsx19(ModelSetup,{ctx,id:owner.params.workshop??""},owner.params.workshop)),edit:reactMount((ctx,{owner})=>jsx19(WorkshopEdit,{ctx,id:owner.params.workshop??"",projectPage:owner.page("project")},owner.params.workshop)),secrets:reactMount((ctx,{owner})=>jsx19(SecretsSetup,{ctx,id:owner.params.workshop??""},owner.params.workshop))}});var SCOPE_TEXT={public:"\u516C\u5F00",team:"\u56E2\u961F"};function visibilityText(w){const v=w.visibility??(w.scope==="public"?"everyone":"members");return WORKSHOP_LEVELS.find(l=>l.value===v)?.label??v}var PERM_TEXT={comment:"\u8BC4\u8BBA","submit-change":"\u63D0\u4EA4\u4FEE\u6539",confirm:"\u786E\u8BA4\u4FEE\u6539",approve:"\u6279\u51C6",publish:"\u53D1\u5E03",admin:"\u7BA1\u7406\u9879\u76EE"};var STORAGE_TEXT={git:"\u76EE\u6807\u4ED3\u5E93",store:"Band",external:"\u5916\u90E8\u5E73\u53F0"};function stageNames(stages){return stages.map((s,i)=>stageDisplayName2(s.id,s.label,i))}function cardStatus(w){if(w.version===0)return{text:"\u8FD8\u6CA1\u5C31\u7EEA",failed:false};if(modelOf(w).state==="not_provisioned")return void 0;if(modelOf(w).hasRequest===false)return{text:"\u5F85\u914D\u7F6E\u6A21\u578B",failed:false};const agent=modelOf(w).agent;if(!agent||agent==="ready")return void 0;return{text:agentLabel(agent,modelOf(w).retrying),failed:agent==="failed"}}function FlowLine({stages}){const names=stageNames(stages);return jsx19("div",{className:"band-workshops-flowline","aria-label":"\u6D41\u7A0B",children:stages.map((s,i)=>jsxs19(Fragment18,{children:[i>0&&jsx19("span",{"aria-hidden":"true",children:"\u2192"}),jsx19("span",{className:`band-workshops-st ${s.kind}`,children:names[i]})]},s.id))})}function Catalog({ctx}){const[scope,setScope]=useState16("all");const canArchive=ctx.app.data.write?.workshopArchive!==void 0;const[archived,setArchived]=useState16(false);const{data,error,reload}=useAppData6(ctx,d=>d.workshops(archived?{archived:true}:void 0),[archived]);const list=(data??[]).filter(w=>archived||scope==="all"||w.scope===scope);return jsxs19("main",{className:"band-workshops-screen",children:[jsxs19("div",{className:"band-workshops-head",children:[jsxs19("div",{children:[jsx19("h1",{children:"\u5DE5\u574A"}),jsx19("p",{className:"sub",children:"\u4E00\u4E2A\u5DE5\u574A\u5B9A\u4E49\u4E00\u7C7B\u5DE5\u4F5C\uFF1A\u7528\u54EA\u4E9B Agent\u3001\u4EA4\u4ED8\u54EA\u4E9B\u4EA7\u7269\u3001\u6309\u4EC0\u4E48\u6D41\u7A0B\u8D70\u3001\u7528\u4EC0\u4E48\u89C6\u56FE\u770B\u3002\u9009\u4E00\u4E2A\u5F00\u59CB\u65B0\u9879\u76EE\uFF0C\u6216\u8005\u57FA\u4E8E\u5B83\u65B0\u5EFA\u4E00\u4E2A\u4F60\u4EEC\u56E2\u961F\u7684\u5DE5\u574A\u3002"})]}),jsxs19("div",{className:"band-workshops-headacts",children:[ctx.app.data.write?.createWorkshop&&jsx19("button",{type:"button",className:"btn sm",onClick:()=>ctx.app.navigate({page:`${SELF}/create`}),children:"\u65B0\u5EFA\u5DE5\u574A"}),canArchive&&jsx19("button",{type:"button",className:"btn ghost sm","aria-pressed":archived,onClick:()=>setArchived(a=>!a),children:archived?"\u8FD4\u56DE\u76EE\u5F55":"\u5DF2\u5F52\u6863"}),!archived&&jsx19(Fragment19,{children:jsx19("div",{className:"seg",role:"group","aria-label":"\u8303\u56F4",children:[["all","\u5168\u90E8"],["public","\u516C\u5F00"],["team","\u6211\u7684\u56E2\u961F"]].map(([k,v])=>jsx19("button",{type:"button","aria-pressed":scope===k,onClick:()=>setScope(k),children:v},k))})})]})]}),error&&jsxs19(ErrorNote14,{retry:reload,children:["\u5DE5\u574A\u76EE\u5F55\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]}),!data&&!error&&jsxs19("div",{className:"band-workshops-grid","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6",children:[jsx19("div",{className:"band-workshops-card is-skeleton"}),jsx19("div",{className:"band-workshops-card is-skeleton"}),jsx19("div",{className:"band-workshops-card is-skeleton"})]}),data&&list.length===0&&jsxs19("div",{className:"band-workshops-empty",children:[jsx19("b",{children:archived?"\u6CA1\u6709\u5DF2\u5F52\u6863\u7684\u5DE5\u574A":scope==="all"?"\u8FD8\u6CA1\u6709\u5DE5\u574A":scope==="team"?"\u4F60\u7684\u56E2\u961F\u8FD8\u6CA1\u6709\u5DE5\u574A":"\u8FD8\u6CA1\u6709\u516C\u5F00\u7684\u5DE5\u574A"}),jsx19("p",{className:"sub",children:archived?"\u5F52\u6863\u7684\u5DE5\u574A\u4E0D\u5728\u76EE\u5F55\u91CC\uFF0C\u5728\u8FD9\u91CC\u627E\u56DE\uFF1B\u518D\u70B9\u4E00\u6B21\u300C\u5DF2\u5F52\u6863\u300D\u56DE\u5230\u76EE\u5F55\u3002":"\u5DE5\u574A\u5B9A\u4E49\u4E00\u7C7B\u5DE5\u4F5C\uFF1A\u8C01\u6765\u505A\u3001\u5206\u51E0\u4E2A\u9636\u6BB5\u3001\u54EA\u91CC\u8981\u8C01\u6279\u51C6\u3002\u5B9A\u4E49\u5199\u8FDB\u5DE5\u574A\u4ED3\u5E93\u7684 band/workshop.yaml\uFF0C\u53D1\u5E03\u540E\u5C31\u51FA\u73B0\u5728\u8FD9\u91CC\u3002"}),scope!=="all"&&!archived&&jsx19("button",{type:"button",className:"btn sm",onClick:()=>setScope("all"),children:"\u770B\u5168\u90E8\u5DE5\u574A"})]}),list.length>0&&jsx19("div",{className:"band-workshops-grid",children:list.map(w=>jsxs19("button",{type:"button",className:"band-workshops-card",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}}),children:[jsxs19("span",{className:"band-workshops-card-h",children:[jsx19(WorkshopEmblem2,{icon:w.icon,size:48}),jsxs19("span",{className:"band-workshops-card-t",children:[jsx19("span",{className:"band-workshops-name",children:w.name}),jsx19("span",{className:"band-workshops-meta",children:[w.maintainer&&`${w.maintainer} \u7EF4\u62A4`,`${w.projectCount} \u4E2A\u9879\u76EE`,SCOPE_TEXT[w.scope]].filter(Boolean).join(" \xB7 ")})]})]}),jsx19("span",{className:"band-workshops-desc",children:w.description}),w.archivedAt!==void 0&&jsx19("span",{className:"chip",children:"\u5DF2\u5F52\u6863"}),modelMissing(w.model,w.userModelKey)?jsx19("span",{className:w.canAdmin?"chip s-stale":"chip",children:"\u5F85\u914D\u7F6E\u6A21\u578B"}):cardStatus(w)&&jsx19("span",{className:cardStatus(w)?.failed?"chip s-failed":"chip",children:cardStatus(w)?.text}),jsx19(FlowLine,{stages:w.stages})]},w.id))})]})}function Missing({ctx,id}){return jsxs19("main",{className:"band-workshops-screen",children:[jsx19(Crumb,{ctx}),jsxs19("div",{className:"band-workshops-missing",children:[jsxs19("h1",{children:["\u627E\u4E0D\u5230\u5DE5\u574A ",id]}),jsx19("p",{className:"sub",children:"\u53EF\u80FD\u8F93\u9519\u4E86\u5730\u5740\u3001\u5DE5\u574A\u5DF2\u7ECF\u5F52\u6863\uFF0C\u6216\u8005\u4F60\u6CA1\u6709\u6743\u9650\u770B\u5B83\u3002"}),jsx19("button",{type:"button",className:"btn",onClick:()=>ctx.app.navigate({page:`${SELF}/workshops`}),children:"\u56DE\u5DE5\u574A\u76EE\u5F55"})]})]})}function useWorkshop(ctx,id){return useAppData6(ctx,d=>d.workshop(id),[id])}function agentLine(a,model,noModel){if(noModel)return"\u672A\u914D\u7F6E\u6A21\u578B \xB7 \u4E0D\u63A5\u5BF9\u8BDD";const role=a.name==="rondo"?"\u6CA1\u6307\u5B9A Agent \u7684\u9636\u6BB5\u90FD\u4EA4\u7ED9\u5B83":a.stages.length?`\u8D1F\u8D23${a.stages.map(x=>`\u300C${x}\u300D`).join("")}`:"\u5728\u5BF9\u8BDD\u91CC @ \u5B83";return model?.model?`\u6A21\u578B ModelGate \xB7 ${model.model} \xB7 ${role}`:role}function agentsOf(stages){const out=new Map([["rondo",{stages:[]}]]);const names=stageNames(stages);for(const[i,s]of stages.entries()){if(s.kind!=="agent")continue;const key=(s.agent??"rondo").toLowerCase()==="rondo"?"rondo":s.agent;const prev=out.get(key)??{stages:[]};const label=prev.label??s.agentLabel;out.set(key,{...label?{label}:{},stages:[...prev.stages,names[i]??s.id]})}return[...out].map(([name,a])=>({name,...a}))}var agentLabel2=(name,label)=>agentDisplayName(name,label);var customAgents=w=>agentsOf(w.workflows[0]?.stages??[]).filter(a=>!isRondoAgent(a.name));var EXPIRY_WARN_DAYS=7;function daysLeft(iso,now){const day=t=>{const d=new Date(t);return new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime()};return Math.round((day(Date.parse(iso))-day(now))/864e5)}function useExpiringConnections(ctx,id,admin){const api=ctx.app.data.write?.teamConnections;const[count,setCount]=useState16(0);useEffect14(()=>{let live=true;setCount(0);if(!api||!admin)return;api.list({scope:"workshop",workshopId:id}).then(rows=>{if(!live)return;const now=Date.now();setCount(rows.filter(r=>r.status==="expired"||r.status==="active"&&r.expiresAt!==null&&daysLeft(r.expiresAt,now)<=EXPIRY_WARN_DAYS).length)},()=>void 0);return()=>{live=false}},[api,id,admin]);return count}function overrideLine(n){const plugin=n.version?`${n.name}@${n.version}`:n.name;const blocked=n.replacementVersion===void 0;const title=blocked?`${plugin} \u5DF2\u88AB\u5E73\u53F0\u5C01\u7981`:`${plugin} \u5DF2\u88AB\u5E73\u53F0\u6362\u6210 ${n.replacementVersion}`;const scope=n.current?"\u5F53\u524D\u7248\u672C\u5728\u7528":"\u53EA\u5728\u65E7\u7248\u672C\u6216\u9884\u89C8\u91CC";if(blocked&&n.current&&n.official===false)return{title,scope,action:"\u6362\u4E00\u4E2A\u7248\u672C\u518D\u53D1\u5E03\uFF1A\u73B0\u5728\u53D1\u5E03\u4F1A\u5931\u8D25\uFF0C\u7528\u5F53\u524D\u7248\u672C\u7684\u9879\u76EE\u91CC\u8FD9\u4E2A\u63D2\u4EF6\u5DF2\u7ECF\u505C\u7528\u3002",needsAction:true};if(blocked&&n.current)return{title,scope,action:"\u8FD9\u662F\u5E73\u53F0\u81EA\u5E26\u7684\u63D2\u4EF6\uFF0C\u5DE5\u574A\u8FD9\u8FB9\u6539\u4E0D\u4E86\uFF0C\u7B49\u5E73\u53F0\u66F4\u65B0\uFF1B\u5728\u90A3\u4E4B\u524D\u53D1\u5E03\u4F1A\u5931\u8D25\u3002",needsAction:false};if(blocked)return{title,scope,action:"\u4E0D\u7528\u5904\u7406\uFF1B\u8FD8\u5728\u7528\u65E7\u7248\u672C\u7684\u9879\u76EE\u91CC\u8FD9\u4E2A\u63D2\u4EF6\u5DF2\u7ECF\u505C\u7528\u3002",needsAction:false};return{title,scope,action:n.current?"\u4E0D\u7528\u5904\u7406\uFF0C\u9879\u76EE\u5DF2\u5728\u7528\u66FF\u6362\u7248\u672C\uFF0C\u4E0B\u6B21\u53D1\u5E03\u4E5F\u4F1A\u81EA\u52A8\u4F7F\u7528\u5B83\u3002":"\u4E0D\u7528\u5904\u7406\uFF1B\u8FD8\u5728\u7528\u65E7\u7248\u672C\u7684\u9879\u76EE\u5DF2\u5728\u7528\u66FF\u6362\u7248\u672C\u3002",needsAction:false}}function OverrideNotices({items}){return jsxs19("section",{className:"band-workshops-overrides","aria-labelledby":"band-workshops-overrides-h",children:[jsx19("h2",{className:"band-workshops-overrides-h",id:"band-workshops-overrides-h",children:"\u5E73\u53F0\u64A4\u6362"}),jsx19("ul",{className:"band-workshops-overrides-list",children:items.map(n=>{const line=overrideLine(n);return jsxs19("li",{className:line.needsAction?"is-action":void 0,children:[jsxs19("span",{className:"band-workshops-overrides-t",children:[line.title,jsxs19("span",{className:"band-workshops-overrides-scope",children:[" \xB7 ",line.scope]})]}),jsxs19("span",{className:"band-workshops-overrides-d",children:["\u539F\u56E0\uFF1A",n.reason]}),jsx19("span",{className:"band-workshops-overrides-d",children:line.action})]},`${n.name}@${n.version??""}:${n.at}`)})})]})}var deployCount=w=>w.releases.filter(r=>r.note===DEPLOY_RELEASE_NOTE2).length;var PLUGIN_PAGE="@kanyun-ai-infra/band-plugins/plugin";function workshopPlugins(list,id){const own=list.filter(p=>p.source!=="official"&&p.workshop?.id===id);return{own,used:list.filter(p=>!own.includes(p))}}function pluginSourceText(p,id){if(p.source==="official")return"\u5B98\u65B9";if(p.workshop?.id===id)return p.source==="shared"?"\u672C\u5DE5\u574A \xB7 \u5DF2\u5171\u4EAB":"\u672C\u5DE5\u574A \xB7 \u6CA1\u5171\u4EAB";return`\u5171\u4EAB \xB7 ${p.workshop?.name??"\u522B\u7684\u5DE5\u574A"}`}function pluginParams(name){const m=/^@([^/]+)\/(.+)$/.exec(name);return m?.[1]&&m[2]?{scope:m[1],name:m[2]}:{scope:"_",name}}function WorkshopPlugins({ctx,id}){const{data,error,reload}=useAppData6(ctx,d=>d.plugins({workshop:id}),[id]);if(error&&!data)return jsxs19(ErrorNote14,{retry:reload,children:["\u63D2\u4EF6\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]});if(!data)return jsx19("span",{className:"band-workshops-sk is-block","aria-busy":"true"});const{own,used}=workshopPlugins(data,id);const row=p=>[p.source==="workshop"?jsxs19("span",{className:"band-workshops-plugin",children:[jsx19("b",{children:p.title}),jsx19("code",{children:p.name})]},"n"):jsxs19("button",{type:"button",className:"band-workshops-plugin band-workshops-link",onClick:()=>ctx.app.navigate({page:PLUGIN_PAGE,params:pluginParams(p.name)}),children:[jsx19("b",{children:p.title}),jsx19("code",{children:p.name})]},"n"),pluginSourceText(p,id),p.source==="official"?jsx19("span",{className:"band-workshops-nowrap",children:"\u5DF2\u9489\u4F4F"},"v"):jsx19("code",{children:p.version},"v")];return jsxs19(Fragment19,{children:[jsx19("h3",{className:"band-workshops-sub",children:"\u672C\u5DE5\u574A\u7684\u63D2\u4EF6"}),jsx19(Table,{head:["\u63D2\u4EF6","\u6765\u6E90","\u7248\u672C"],rows:own.map(row),empty:"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u81EA\u5DF1\u7684\u63D2\u4EF6\uFF1A\u7528\u7684\u90FD\u662F\u5B98\u65B9\u7684\u6216\u522B\u7684\u5DE5\u574A\u5171\u4EAB\u7684\u3002"}),jsx19("h3",{className:"band-workshops-sub",children:"\u7528\u5230\u7684\u63D2\u4EF6"}),jsx19(Table,{head:["\u63D2\u4EF6","\u6765\u6E90","\u7248\u672C"],rows:used.map(row),empty:"\u5F53\u524D\u53D1\u5E03\u7684\u7248\u672C\u6CA1\u5728 views \u91CC\u7528\u5230\u5B98\u65B9\u6216\u5171\u4EAB\u7684\u63D2\u4EF6\u3002"}),jsx19("p",{className:"band-workshops-note",children:"\u53EA\u7B97\u5F53\u524D\u53D1\u5E03\u7684\u7248\u672C\uFF1A\u5B98\u65B9\u63D2\u4EF6\u6309 views \u91CC\u5199\u51FA\u6765\u7684\u5E03\u5C40\u3001\u9762\u677F\u3001\u67E5\u770B\u5668\u7B97\uFF1B\u9501\u5B9A\u63D2\u4EF6\u4E0E\u5916\u58F3\u6309\u90E8\u7F72\u65B9\u6848\u88C5\uFF0C\u4E0D\u5217\u5728\u8FD9\u91CC\u3002"})]})}function canPublish(w){return w.canAdmin&&w.origin!==void 0&&(w.status??"ready")==="ready"&&w.repoUrl!==void 0}function publishFailure(e){const err=e;const latest=err?.details?.latestVersion;if(err?.code==="CONFLICT"&&typeof latest==="number")return`\u6709\u4EBA\u521A\u521A\u53D1\u5E03\u4E86 v${latest}\uFF0C\u5237\u65B0\u770B\u770B`;return`\u6CA1\u53D1\u5E03\u6210\u529F\uFF1A${errorText9(e)}`}function PublishRelease({ctx,w,onDone,label="\u53D1\u5E03\u65B0\u7248",primary=false,commit,disabledReason,onConflict,onRefresh,publishingChanged}){const release=ctx.app.data.write?.releaseWorkshop;const upgrade=ctx.app.data.write?.workshopUpgrade;const[open,setOpen]=useState16(false);const[expectedCommit,setExpectedCommit]=useState16();const[conflict,setConflict]=useState16(false);const[refreshing,setRefreshing]=useState16(false);const[note,setNote]=useState16("");const[busy,setBusy]=useState16(false);const[outcome,setOutcome]=useState16(null);const[followProjects,setFollowProjects]=useState16(true);const[projectResult,setProjectResult]=useState16(null);const[projectError,setProjectError]=useState16(null);const publishing=useRef7(busy);publishing.current=busy;const inFlight=useRef7(false);const{dialog,trigger}=useModalDialog({open,onRequestClose:()=>setOpen(false),blocked:busy,initialFocus:"textarea"});if(!release)return null;const next=w.version+1;const previous=w.releases.find(r=>r.version===w.version);const submit=async()=>{if(inFlight.current||conflict||refreshing||disabledReason)return;inFlight.current=true;setBusy(true);publishingChanged?.(true);setOutcome(null);setProjectResult(null);setProjectError(null);const text=note.trim();try{const r=await release({workshop:w.id,...text?{note:text}:{},...expectedCommit?{commit:expectedCommit}:{}});setOutcome({said:r.changed?`\u5DF2\u53D1\u5E03 v${r.version}`:"\u5B9A\u4E49\u6CA1\u6709\u53D8\u5316\uFF0C\u6CA1\u6709\u53D1\u65B0\u7248",...r.yanked?{yanked:r.yanked}:{}});if(r.changed){setNote("");if(followProjects&&upgrade){try{setProjectResult(await upgrade.run(w.id))}catch(e){setProjectError(errorText9(e))}}onDone()}setOpen(false)}catch(e){const failure=e;const changedHead=commit!==void 0&&failure?.code==="CONFLICT"&&(typeof failure.details?.actualCommit==="string"||typeof failure.details?.latestVersion==="number");setOutcome({failed:changedHead?"\u4F60\u6253\u5F00\u4E4B\u540E\u5DE5\u574A\u53C8\u6709\u4E86\u65B0\u4FEE\u6539\u3002\u5148\u770B\u4E00\u773C\u66F4\u65B0\u540E\u7684\u5BF9\u6BD4\u518D\u4FDD\u5B58\u3002":publishFailure(e)});if(changedHead){setConflict(true);onConflict?.()}}finally{inFlight.current=false;setBusy(false);publishingChanged?.(false)}};return jsxs19("div",{className:"band-workshops-publish",children:[jsx19("button",{ref:trigger,type:"button",className:primary?"btn primary":"btn","aria-haspopup":"dialog",disabled:busy||!!disabledReason,title:disabledReason,onClick:()=>{setExpectedCommit(commit);setConflict(false);setOutcome(null);setProjectResult(null);setProjectError(null);setFollowProjects(true);setOpen(true)},children:busy?"\u53D1\u5E03\u4E2D\u2026":label}),jsx19("dialog",{ref:dialog,className:"band-workshops-publish-dialog","data-band-layer":open?"dialog":void 0,"aria-label":"\u53D1\u5E03\u65B0\u7248",onCancel:e=>{if(publishing.current)e.preventDefault()},onClose:()=>setOpen(false),children:jsxs19("div",{className:"band-workshops-publish-body",children:[jsx19("h2",{className:"band-workshops-publish-title",children:"\u53D1\u5E03\u65B0\u7248"}),jsxs19("p",{children:["\u628A\u73B0\u5728\u7684\u5B9A\u4E49\u53D1\u5E03\u6210 v",next,"\uFF1B\u65B0\u5EFA\u7684\u9879\u76EE\u7528\u65B0\u7248"]}),jsx19("p",{children:previous?.note?`\u4E0A\u4E00\u7248 v${w.version} \u7684\u8BF4\u660E\uFF1A${previous.note}`:`\u4E0A\u4E00\u7248 v${w.version} \u6CA1\u6709\u5199\u8BF4\u660E\u3002`}),jsx19("p",{children:"\u53D1\u5E03\u540E\u4E0D\u80FD\u64A4\u56DE\uFF1B\u8981\u6539\u5C31\u63A5\u7740\u6539\uFF0C\u518D\u53D1\u4E00\u7248\u3002"}),jsxs19("label",{className:"band-workshops-field",children:[jsxs19("span",{children:["\u8BF4\u660E ",jsx19("em",{className:"band-workshops-opt",children:"\u53EF\u4E0D\u586B\uFF0C\u5199\u8FDB\u7248\u672C\u8BB0\u5F55"})]}),jsx19("textarea",{rows:2,value:note,maxLength:500,readOnly:busy,placeholder:`\u6BD4\u5982\uFF1A\u76F8\u5BF9 v${w.version} \u52A0\u4E86\u914D\u97F3\u9636\u6BB5`,onChange:e=>setNote(e.target.value)})]}),upgrade&&jsxs19("label",{className:"choice",children:[jsx19("input",{type:"checkbox",className:"checkbox",checked:followProjects,disabled:busy,onChange:e=>setFollowProjects(e.target.checked)}),"\u540C\u65F6\u5347\u7EA7\u672C\u5DE5\u574A\u5168\u90E8\u9879\u76EE"]}),busy&&outcome&&"said"in outcome&&jsxs19("p",{"aria-live":"polite",children:[outcome.said,"\uFF0C\u6B63\u5728\u66F4\u65B0\u9879\u76EE\u2026"]}),outcome&&"failed"in outcome&&jsx19("div",{role:"alert",children:jsx19(ErrorNote14,{children:outcome.failed})}),jsxs19("div",{className:"band-workshops-actions",children:[jsx19("button",{type:"button",className:"btn ghost sm",disabled:busy,onClick:()=>setOpen(false),children:"\u53D6\u6D88"}),conflict&&onRefresh&&jsx19("button",{type:"button",className:"btn sm",disabled:busy||refreshing,onClick:async()=>{setRefreshing(true);try{const head=await onRefresh();if(head){setExpectedCommit(head);setConflict(false);setOutcome(null)}}finally{setRefreshing(false)}},children:refreshing?"\u6B63\u5728\u5237\u65B0\u2026":"\u5237\u65B0\u5BF9\u6BD4"}),jsx19("button",{type:"button",className:"btn primary sm","aria-disabled":busy||conflict||refreshing||!!disabledReason,onClick:()=>void submit(),children:busy?"\u53D1\u5E03\u4E2D\u2026":`\u53D1\u5E03 v${next}`})]})]})}),outcome&&"said"in outcome&&jsx19("output",{className:"band-workshops-hint","aria-live":"polite",children:outcome.said}),projectResult&&jsx19("section",{"aria-label":"\u9879\u76EE\u66F4\u65B0\u7ED3\u679C",children:projectResult.total===0?jsx19("p",{children:"\u6CA1\u6709\u9700\u8981\u66F4\u65B0\u7684\u9879\u76EE\u3002"}):jsx19(UpgradeResult,{result:projectResult})}),projectError&&jsx19("div",{role:"alert",children:jsxs19(ErrorNote14,{children:["\u65B0\u7248\u5DF2\u53D1\u5E03\uFF0C\u9879\u76EE\u66F4\u65B0\u6CA1\u5B8C\u6210\uFF1A",projectError]})}),outcome&&"said"in outcome&&outcome.yanked&&jsxs19("div",{className:"band-workshops-hint band-workshops-yanked","aria-live":"polite",children:[jsx19("p",{children:"\u8FD9\u6B21\u53D1\u5E03\u5F15\u7528\u4E86\u5DF2\u64A4\u56DE\u7684\u63D2\u4EF6\u7248\u672C\uFF0C\u7167\u5E38\u53D1\u51FA\u53BB\u4E86\uFF0C\u5EFA\u8BAE\u6362\u6210\u6CA1\u64A4\u56DE\u7684\u7248\u672C\uFF1A"}),jsx19("ul",{children:outcome.yanked.map(y=>jsxs19("li",{children:[jsxs19("code",{children:[y.name,"@",y.version]}),"\uFF1A",y.reason]},`${y.name}@${y.version}`))})]})]})}function flowLayout(stages){const ids=new Set(stages.map(s=>s.id));const ups=new Map(stages.map(s=>[s.id,[...new Set(s.needs.map(n=>n.split(":")[0]??n))].filter(u=>ids.has(u)&&u!==s.id)]));const depth=new Map;const level=(id,seen)=>{const known=depth.get(id);if(known!==void 0)return known;if(seen.has(id))return 0;seen.add(id);const d=Math.max(-1,...(ups.get(id)??[]).map(u=>level(u,seen)))+1;depth.set(id,d);return d};const layers=[];for(const s of stages){const d=level(s.id,new Set);const layer=layers[d];if(layer)layer.push(s.id);else layers[d]=[s.id]}const edges=stages.flatMap(s=>(ups.get(s.id)??[]).map(u=>[u,s.id]));return{layers,edges}}function edgePath(from,to,others){const x1=from.left+(from.right-from.left)/2;const y1=from.bottom;const x2=to.left+(to.right-to.left)/2;const y2=to.top;const lo=Math.min(x1,x2);const hi=Math.max(x1,x2);const between=others.filter(o=>o.top>=y1-1&&o.bottom<=y2+1&&o.right>lo&&o.left<hi+1);if(between.length>0){const band=others.filter(o=>o.bottom>y1&&o.top<y2);const side=Math.max(from.right,to.right,...band.map(o=>o.right))+12;return`M${x1} ${y1} V${y1+10} H${side} V${y2-10} H${x2} V${y2}`}const bend=Math.max((y2-y1)/2,8);return`M${x1} ${y1} C${x1} ${y1+bend} ${x2} ${y2-bend} ${x2} ${y2}`}function useEdgePaths(box,edges){const[paths,setPaths]=useState16({});useLayoutEffect(()=>{const el=box.current;if(!el||edges.length===0)return;const fit=()=>{const origin=el.getBoundingClientRect();const rects=new Map(Array.from(el.querySelectorAll("[data-stage]"),n=>{const r=n.getBoundingClientRect();return[n.dataset.stage??"",{left:r.left-origin.left,top:r.top-origin.top,right:r.right-origin.left,bottom:r.bottom-origin.top}]}));const next={};for(const[from,to]of edges){const a=rects.get(from);const b=rects.get(to);if(!a||!b)continue;const others=[...rects].flatMap(([id,r])=>id===from||id===to?[]:[r]);next[`${from}\u2192${to}`]=edgePath(a,b,others)}setPaths(prev=>JSON.stringify(prev)===JSON.stringify(next)?prev:next)};fit();if(typeof ResizeObserver==="undefined")return;const observer=new ResizeObserver(fit);observer.observe(el);for(const n of Array.from(el.querySelectorAll("[data-stage]")))observer.observe(n);return()=>observer.disconnect()},[box,edges]);return paths}function FlowBig({stages,peers,roles,story,building=false,decorations={},approvalText,executorKnown=true}){const role=r=>{const i=roles.findIndex(x=>x.name===r);return roleDisplayName2(r,roles[i]?.label,i)};const box=useRef7(null);const layout=useMemo(()=>flowLayout(stages),[stages]);const paths=useEdgePaths(box,layout.edges);const arrow=useId8();const byId=new Map(stages.map(s=>[s.id,s]));const ordered=stageNames(stages);const names=new Map(stages.map((s,i)=>[s.id,ordered[i]??s.id]));if(stages.length===0)return jsx19("p",{className:"band-workshops-note",children:building?"\u5DE5\u574A\u8FD8\u5728\u51C6\u5907\u4E2D\uFF0C\u6D41\u7A0B\u5EFA\u597D\u4F1A\u81EA\u52A8\u51FA\u73B0\u3002":"\u8FD9\u4E2A\u5DE5\u574A\u6CA1\u6709\u6D41\u7A0B\u3002"});const node=s=>{const agent=s.kind==="agent"?s.agent??"rondo":void 0;const doer=agent?executorKnown?`${agentLabel2(agent,s.agentLabel)} \u6765\u505A`:"Agent \u6765\u505A":s.kind==="human"?"\u4EBA\u6765\u505A":s.kind==="external"?s.viaMissing?`${names.get(s.id)??s.id} \xB7 \u6682\u4E0D\u53EF\u7528`:s.viaDisplayName:void 0;return jsxs19("div",{className:`band-workshops-node ${s.kind}${decorations[s.id]?.tag?" is-changed":""}${decorations[s.id]?.removed?" is-removed":""}${decorations[s.id]?.highlight?" is-highlighted":""}`,"data-stage":s.id,"data-edit-stage":decorations[s.id]?.key,tabIndex:decorations[s.id]?-1:void 0,children:[decorations[s.id]?.tag&&jsx19("span",{className:"band-workshop-edit-mark",children:decorations[s.id]?.tag}),jsx19("b",{children:names.get(s.id)??s.id}),doer&&jsxs19("span",{className:"band-workshops-node-a",children:[agent&&executorKnown&&jsx19(Avatar5,{id:agent,name:agentLabel2(agent,s.agentLabel),agent:true,instrument:instrumentOf2(agent,peers),size:"xs",decorative:true}),doer]}),jsx19("span",{className:"band-workshops-node-g",children:approvalText?.[s.id]!==void 0?approvalText[s.id]:s.gate?`\u6279\u51C6\uFF1A${gateWho(s.gate.approveBy.map(role),s.gate.mode).trimStart()}`:"\u4E0D\u8BBE\u95E8\u7981"}),s.viaMissing&&jsx19("span",{className:"band-workshops-node-missing",children:"\u8FD9\u4E00\u6B65\u6682\u65F6\u7528\u4E0D\u4E86\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458"}),story.loops[s.id]&&jsx19("span",{className:"band-workshops-node-loop",children:story.loops[s.id]})]})};return jsxs19(Fragment19,{children:[story.start&&jsx19("p",{className:"band-workshops-flow-line",children:story.start}),jsxs19("div",{ref:box,className:"band-workshops-flowbig",children:[jsxs19("svg",{className:"band-workshops-edges","aria-hidden":"true",children:[jsx19("defs",{children:jsx19("marker",{id:arrow,viewBox:"0 0 6 6",refX:"6",refY:"3",markerWidth:"6",markerHeight:"6",orient:"auto",children:jsx19("path",{d:"M0 0 L6 3 L0 6 z"})})}),layout.edges.map(([from,to])=>jsx19("path",{"data-edge":`${from}\u2192${to}`,d:paths[`${from}\u2192${to}`]??"",markerEnd:`url(#${arrow})`},`${from}\u2192${to}`))]}),jsx19("ol",{className:"band-workshops-layers","aria-label":"\u6D41\u7A0B",children:layout.layers.map(ids=>jsx19("li",{children:jsx19("ul",{className:"band-workshops-layer",children:ids.flatMap(id=>{const s=byId.get(id);return s?[jsx19("li",{children:node(s)},id)]:[]})})},ids.join(",")))})]}),story.end&&jsx19("p",{className:"band-workshops-flow-line",children:story.end})]})}function Table({head,rows,empty}){if(rows.length===0)return jsx19("p",{className:"band-workshops-note",children:empty});return jsx19("div",{className:"band-workshops-table",children:jsxs19("table",{children:[jsx19("thead",{children:jsx19("tr",{children:head.map(h=>jsx19("th",{scope:"col",children:h},h))})}),jsx19("tbody",{children:rows.map((r,i)=>jsx19("tr",{children:r.map((c,j)=>jsx19("td",{children:c},j))},i))})]})})}function sentence(text){return text.replace(/\s+([,、;()])/g,"$1").replace(/([,、;()])\s+/g,"$1").trim()}function flowStory(w){const stages=w.workflows[0]?.stages??[];const role=r=>{const i=w.roles.findIndex(x=>x.name===r);return roleDisplayName2(r,w.roles[i]?.label,i)};const first=stages.find(s=>s.kind==="agent");const agent=first?agentLabel2(first.agent??"rondo",first.agentLabel):void 0;const loops={};for(const s of stages){if(!s.gate)continue;const who=inline2(s.gate.approveBy.map(role).join("\u3001"));loops[s.id]=sentence(s.kind==="agent"?`${who}\u53EF\u4EE5\u63D0\u4FEE\u6539\u610F\u89C1\uFF0C${inline2(agentLabel2(s.agent??"rondo",s.agentLabel))}\u51FA\u65B0\u7248\u672C\uFF0C\u518D\u6279\u51C6\uFF1B\u4E0D\u6EE1\u610F\u53EF\u9000\u56DE\u91CD\u505A`:s.kind==="human"?s.produces.length>0?`\u4EBA\u5DE5\u63D0\u4EA4\u5185\u5BB9\u540E\uFF0C${who}\u5BA1\u9605\u5E76\u6279\u51C6`:`${who}\u5BA1\u9605\u4E0A\u6E38\u5185\u5BB9\uFF0C\u5BA1\u9605\u5B8C\u6210\u540E\u6279\u51C6`:`${who}\u53EF\u4EE5\u63D0\u4FEE\u6539\u610F\u89C1\uFF0C\u6539\u51FA\u65B0\u7248\u672C\uFF0C\u518D\u6279\u51C6\uFF1B\u4E0D\u6EE1\u610F\u53EF\u9000\u56DE\u91CD\u505A`)}const repo=r=>r.label?`\u5B58\u653E${inline2(r.label)}\u7684\u4ED3\u5E93`:`\u4ED3\u5E93${inline2(r.name)}`;const repos=w.repos??[];const ends=repos.flatMap(r=>(r.release??"mr")==="mr"?[`\u6279\u51C6\u540E\u5F00 MR \u5230${repo(r)}\uFF08Band \u4E0D\u5408\u5E76\uFF09`]:r.release==="direct"?[`${repo(r)}\u6BCF\u56DE\u5408\u76F4\u63A5\u6539\u9ED8\u8BA4\u5206\u652F\uFF0C\u6CA1\u6709 MR`]:[]);const end=ends.length>0?ends.join("\uFF1B"):repos.length>0?void 0:stages.some(s=>s.gate)?"\u6279\u51C6\u5373\u5B9A\u7A3F":agent&&`${inline2(agent)}\u4EA4\u51FA\u6765\u5C31\u662F\u5B9A\u7A3F\uFF0C\u63A5\u7740\u804A\u7740\u6539`;const entry=stages[0];const start=takesNeed(w)?agent&&`\u5EFA\u9879\u76EE\u65F6\u5199\u9700\u6C42\uFF0C${inline2(agent)}\u505A\u7B2C\u4E00\u7248`:entry?.kind==="human"&&entry.produces.length>0?`\u5148${entry.params?"\u586B\u5199":"\u63D0\u4EA4"}\u300C${stageNames(stages)[0]}\u300D\uFF0C\u518D\u6309\u6D41\u7A0B\u7EE7\u7EED`:entry?.kind==="agent"&&agent?`\u5EFA\u9879\u76EE\u540E\uFF0C${inline2(agent)}\u505A\u7B2C\u4E00\u7248`:void 0;return{...start?{start:sentence(start)}:{},loops,...end?{end:sentence(end)}:{}}}function takesNeed(w){return w.requiresInput??w.workflows[0]?.stages.some(s=>s.kind==="agent")??false}var spaced=name=>/^[A-Za-z0-9]/.test(name)?` ${name}`:name;function freeTextFields(schema){return Object.entries(schema.properties).filter(([,f])=>f.type==="string"&&f.enum===void 0).map(([k])=>k)}function formHoldsNeed(schema){return freeTextFields(schema).some(k=>schema.required?.includes(k))}function needFromForm(schema,values){if(!formHoldsNeed(schema))return void 0;const keys=freeTextFields(schema);const texts=keys.map(k=>typeof values[k]==="string"?values[k].trim():"").filter(t=>t!=="");const first=texts[0]?.split(/\r?\n/)[0]?.trim()??"";return{body:texts.join("\n\n"),title:first===""?"":projectNameFromNeed(first)}}function newProjectInput(name,need,withNeed){const body=need.trim();if(withNeed){if(body==="")return{missing:"\u9700\u6C42"};if(body.length>FIRST_MESSAGE_MAX)return{missing:"\u9700\u6C42\u592A\u957F"}}const named=name.trim()||(withNeed?projectNameFromNeed(body):"");if(named==="")return{missing:"\u9879\u76EE\u540D"};return withNeed?{name:named,firstMessage:{body}}:{name:named}}function unavailableStageNote(stages){const names=stageNames(stages).map((name,i)=>stages[i]?.viaMissing?`\u300C${name}\u300D`:null).filter(n=>n!==null);if(names.length===0)return null;return`${names.join("")}\u6682\u65F6\u7528\u4E0D\u4E86\uFF0C\u8D70\u5230\u8FD9\u4E00\u6B65\u4F1A\u505C\u4F4F\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\uFF1B\u524D\u9762\u7684\u6B65\u9AA4\u4E0D\u53D7\u5F71\u54CD\u3002`}function NewProject({ctx,id,projectPage,resume=false,trial}){const{data:w,error,reload}=useWorkshop(ctx,id);const trialInfo=useAppData6(ctx,d=>trial?d.write?.trialProjects?.workshop(id)??Promise.resolve(null):Promise.resolve(null),[id,trial!==void 0]);const draftKey=trial?`trial:${id}`:id;const draftRef=useRef7({taken:false});if(!draftRef.current.taken){const draft=takeDraft(draftKey);draftRef.current=draft?{taken:true,draft}:{taken:true}}const restored=draftRef.current.draft;const restoredAttachments=restored?.attachments??[];const[name,setName]=useState16(restored?.name??"");const[need,setNeed]=useState16(restored?.need??"");const[repoUrls,setRepoUrls]=useState16(restored?.repoUrls??{});const[formValues,setFormValues]=useState16(restored?.formValues??{});const[autoPending,setAutoPending]=useState16(resume&&restored!==void 0);const restoredForm=useRef7(restored?.formValues);const[noKey,setNoKey]=useState16(false);const[provisionFailed,setProvisionFailed]=useState16(false);const submitRef=useRef7(void 0);const[formAcked,setFormAcked]=useState16(()=>new Set(restored?.formAcked??[]));const[formFlagged,setFormFlagged]=useState16(false);const[seededForm,setSeededForm]=useState16(null);const[busy,setBusy]=useState16(false);const[failed,setFailed]=useState16(null);const[flagged,setFlagged]=useState16(false);const needRef=useRef7(null);const nameRef=useRef7(null);const repoInputs=useRef7({});const[repoError,setRepoError]=useState16(null);useEffect14(()=>{if(repoError)repoInputs.current[repoError.repo]?.focus()},[repoError]);const ready=w!==void 0&&w!==null;useEffect14(()=>{if(ready)(needRef.current??nameRef.current)?.focus()},[ready]);const model=useProjectModel(ctx,w?.userModelKey);useEffect14(()=>{if(!autoPending||!ready||model.state.kind==="loading")return;setAutoPending(false);void submitRef.current?.()},[autoPending,ready,model.state.kind]);const{data:projects}=useAppData6(ctx,d=>w?.id==="freeform"?d.projects():Promise.resolve(null),[w?.id]);const focusAfterFill=useRef7(false);useEffect14(()=>{if(!focusAfterFill.current)return;focusAfterFill.current=false;needRef.current?.focus();needRef.current?.setSelectionRange(need.length,need.length)},[need]);const write=ctx.app.data.write;if(error&&w===void 0){return jsx19("main",{className:"band-workshops-screen",children:jsxs19(ErrorNote14,{retry:reload,children:["\u5DE5\u574A\u6CA1\u8BFB\u51FA\u6765\uFF1A",error]})})}if(w===void 0){return jsx19("main",{className:"band-workshops-screen","aria-busy":"true","aria-label":"\u6B63\u5728\u8BFB\u53D6"})}if(w===null)return jsx19(Missing,{ctx,id});if(trial&&(trialInfo.data===void 0||trialInfo.error))return jsxs19("main",{className:"band-workshops-screen",children:[trialInfo.error?jsxs19(ErrorNote14,{retry:trialInfo.reload,children:["\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u6CA1\u8BFB\u51FA\u6765\uFF1A",trialInfo.error]}):jsx19("p",{"aria-busy":"true",children:"\u6B63\u5728\u8BFB\u53D6\u8BD5\u7528\u9879\u76EE\u8BBE\u7F6E\u2026"}),jsx19("button",{type:"button",className:"btn",onClick:trial.onCancel,children:"\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E"})]});if(trial&&!trialInfo.data?.canManage)return jsxs19("main",{className:"band-workshops-screen",children:[jsx19("p",{children:"\u53EA\u6709\u5DE5\u574A\u7684\u521B\u5EFA\u4EBA\u548C\u7BA1\u7406\u5458\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u8054\u7CFB\u5DE5\u574A\u7BA1\u7406\u5458\u3002"}),jsx19("button",{type:"button",className:"btn",onClick:trial.onCancel,children:"\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E"})]});const withNeed=takesNeed(w);const formStage=w.formTarget?w.workflows[0]?.stages.find(s=>s.id===w.formTarget?.stage):void 0;const formSchema=formStage?.params;if(formSchema!==void 0){const key=JSON.stringify(formSchema);if(key!==seededForm){setSeededForm(key);const saved=restoredForm.current;setFormValues(saved&&Object.keys(saved).length>0?saved:schemaInitialValues(formSchema));restoredForm.current=void 0;setFormFlagged(false)}}const fromForm=withNeed&&formSchema?needFromForm(formSchema,formValues):void 0;const needText=need.trim();const input=newProjectInput(name.trim()||(needText!==""?"":fromForm?.title??""),fromForm?[fromForm.body,needText].filter(t=>t!=="").join("\n\n"):need,withNeed);const requiredRepos=(w.repos??[]).filter(r=>r.needsUrl);const emptyRepo=requiredRepos.find(r=>!repoUrls[r.name]?.trim());const blankRequiredText=formSchema?freeTextFields(formSchema).filter(k=>formSchema.required?.includes(k)&&typeof formValues[k]==="string"&&formValues[k].trim()===""):[];const formMissing=formSchema?[...new Set([...missingRequiredFields(formSchema,formValues),...blankRequiredText])]:[];const formUnacked=formSchema?Object.entries(formSchema.properties).filter(([k,f])=>needsConfirm(f,formValues[k])&&!formAcked.has(k)):[];const modelMissingNote=projectModelMissing(model.state);const needInForm=fromForm!==void 0&&"missing"in input&&input.missing==="\u9700\u6C42"&&needText==="";const inputMissingNote=flagged&&"missing"in input&&input.missing!=="\u9700\u6C42\u592A\u957F"&&!needInForm?input.missing==="\u9700\u6C42"?"\u8FD8\u5DEE\u300C\u8981\u505A\u4EC0\u4E48\u300D\u6CA1\u586B":"\u8FD8\u5DEE\u9879\u76EE\u540D\u6CA1\u586B":null;const createDisabled=busy||modelMissingNote!==null||trial!==void 0&&trialInfo.data?.createBlocked!==void 0;const submit=async()=>{if(!write||busy)return;if(trial&&(!write.trialProjects||trialInfo.data?.createBlocked))return;if(needInForm&&!emptyRepo){setFormFlagged(true);return}if("missing"in input||emptyRepo){setFlagged(true);if("missing"in input)(input.missing==="\u9879\u76EE\u540D"?nameRef:needRef).current?.focus();else if(emptyRepo)repoInputs.current[emptyRepo.name]?.focus();return}if(formMissing.length>0||formUnacked.length>0){setFormFlagged(true);return}if(modelMissingNote!==null){setFailed(modelMissingNote);return}setBusy(true);setFailed(null);setNoKey(false);setProvisionFailed(false);setRepoError(null);let project;try{const chosen=modelCredentialIdOf(model.state,model.selected);const trialApi=write.trialProjects;if(trial&&!trialApi)throw new Error("\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u8BD5\u7528\u9879\u76EE\uFF0C\u8BF7\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E");const create=trial&&trialApi?input2=>trialApi.create(input2):input2=>write.createProject(input2);({id:project}=await create({workshop:w.id,...input,...restoredAttachments.length>0&&input.firstMessage?{firstMessage:{...input.firstMessage,attachments:restoredAttachments}}:{},...formSchema?{form:submittedValues(formValues)}:{},...chosen!==void 0?{modelCredentialId:chosen}:{},...chosen===void 0&&provisionConsentOf(model.state)!==null?{modelProvisionConsent:true}:{},...requiredRepos.length?{repos:Object.fromEntries(requiredRepos.map(r=>[r.name,repoUrls[r.name]?.trim()??""]))}:{}}))}catch(e){const repo=errorRepo(e);if(isModelRequired(e))setNoKey(true);else if(isProvisionFailure(e)){setFailed(errorText9(e));setProvisionFailed(true)}else if(repo!==void 0&&requiredRepos.some(r=>r.name===repo))setRepoError({repo,value:repoUrls[repo]?.trim()??"",message:errorText9(e),requestAccessUrl:errorRequestAccessUrl(e)});else setFailed(errorText9(e));setBusy(false);return}if(projectPage)ctx.app.navigate({page:projectPage,params:{workshop:w.id,project}});else ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}})};submitRef.current=submit;const goConfigure=()=>{saveDraft(draftKey,{name,need,repoUrls,formValues,formAcked:[...formAcked]});ctx.app.navigate({page:MODELS_FOR_PAGE,params:trial?{}:{workshop:w.id}})};const firstStage=w.workflows[0]?.stages[0];const unavailableNote=unavailableStageNote(w.workflows[0]?.stages??[]);const cancel=()=>trial?trial.onCancel():ctx.app.navigate({page:`${SELF}/about`,params:{workshop:w.id}});const tooLong="missing"in input&&input.missing==="\u9700\u6C42\u592A\u957F";const errId="band-workshops-new-err";const described=failed||noKey?{"aria-describedby":errId}:{};const placeholderName=withNeed&&!("missing"in input)&&name.trim()===""?`\u7559\u7A7A\u5C31\u7528\uFF1A${input.name}`:`\u7ED9\u8FD9\u4E2A${w.name}\u9879\u76EE\u8D77\u4E2A\u540D\u5B57`;return jsxs19("main",{className:"band-workshops-screen",children:[trial?jsx19("button",{type:"button",className:"btn ghost",disabled:busy,onClick:cancel,children:"\u2039 \u5DE5\u574A\u8BBE\u7F6E \xB7 \u8BD5\u7528\u9879\u76EE"}):jsx19(Crumb,{ctx,w,here:"\u65B0\u5EFA\u9879\u76EE"}),jsxs19("div",{children:[jsxs19("h1",{className:"band-workshops-name",children:[jsx19(WorkshopIcon,{icon:w.icon,size:28}),trial?`\u65B0\u5EFA${spaced(w.name)}\u8BD5\u7528\u9879\u76EE`:`\u65B0\u5EFA${spaced(w.name)}\u9879\u76EE`]}),jsx19("p",{className:"sub band-workshops-lede",children:fromForm?"\u586B\u597D\u4E0B\u9762\u7684\u8868\u5355\uFF0C\u5EFA\u597D\u5C31\u4EA4\u7ED9 Rondo \u505A\u7B2C\u4E00\u7248\uFF1B\u9879\u76EE\u540D\u53EF\u4E0D\u586B\u3002":withNeed?needLede(w.id):formSchema?"\u586B\u597D\u4E0B\u9762\u7684\u8868\u5355\u3001\u8D77\u4E2A\u540D\u5B57\uFF0C\u5EFA\u597D\u5C31\u5F00\u5DE5\u3002":trial?`\u5148\u8D77\u4E2A\u540D\u5B57\u3002\u5EFA\u597D\u540E${firstStage?`\u4ECE\u300C${stageNames(w.workflows[0]?.stages??[])[0]}\u300D\u5F00\u59CB`:"\u8FDB\u5165\u9879\u76EE"}\u3002`:`\u5148\u8D77\u4E2A\u540D\u5B57\u3002\u5EFA\u597D\u540E\u8FDB\u9879\u76EE${firstStage?`\u4ECE\u300C${firstStage.id}\u300D\u5F00\u59CB`:"\u5F00\u59CB"}\u3002`}),!trial&&w.docs&&jsxs19("p",{className:"band-workshops-note",children:["\u7B2C\u4E00\u6B21\u7528\uFF0C\u5148\u770B"," ",jsx19("a",{href:w.docs,target:"_blank",rel:"noreferrer",children:"\u8FD9\u4E2A\u5DE5\u574A\u600E\u4E48\u7528"}),"\u3002"]})]}),trial&&jsx19("p",{className:"band-workshops-note",children:"\u8BD5\u7528\u9879\u76EE\u4F7F\u7528 test \u69FD\uFF0C\u540E\u7EED\u56DE\u5408\u4F1A\u8DDF\u968F\u8FD9\u4E2A\u69FD\u66F4\u65B0\uFF0C\u7528\u4E8E\u9A8C\u8BC1\u5F85\u4E0A\u7EBF\u7684 Agent\u3002\u7ED3\u675F\u8BD5\u7528\u540E\u4E0D\u80FD\u6539\u56DE\u8BD5\u7528\u3002\u914D\u7F6E\u6A21\u578B\u540E\u8BF7\u56DE\u5230\u5DE5\u574A\u8BBE\u7F6E\u7EE7\u7EED\u3002"}),trialInfo.data?.createBlocked&&jsxs19("p",{className:"band-workshops-note",children:["\u6682\u65F6\u4E0D\u80FD\u5F00\u8BD5\u7528\u9879\u76EE\uFF1A",trialInfo.data.createBlocked]}),unavailableNote&&jsx19("p",{className:"band-workshops-note",children:unavailableNote}),write&&withNeed&&showsFreeformIntro({workshop:w.id,projects:projects??void 0,draftEmpty:need.trim()===""})&&jsx19(FreeformIntro,{onPick:text=>{focusAfterFill.current=true;setNeed(text)}}),write?jsxs19("form",{className:"band-workshops-form",noValidate:true,onSubmit:e=>{e.preventDefault();void submit()},onKeyDown:withImeGuard4(e=>commandEnter(e,()=>{if(!createDisabled)void submit()})),children:[withNeed&&!fromForm&&jsxs19("label",{className:"band-workshops-field",children:[jsxs19("span",{children:["\u8981\u505A\u4EC0\u4E48 ",jsx19("em",{className:"band-workshops-req",children:"\u5FC5\u586B"})]}),jsx19("textarea",{ref:needRef,rows:4,value:need,required:true,disabled:busy,placeholder:w.needExample?`\u6BD4\u5982\u300C${w.needExample}\u300D`:"\u5199\u4E0B\u8FD9\u4E2A\u9879\u76EE\u8981\u505A\u4EC0\u4E48",onChange:e=>setNeed(e.target.value),"aria-invalid":failed||tooLong||flagged&&need.trim()===""?true:void 0,...described})]}),jsxs19("label",{className:"band-workshops-field",children:[jsxs19("span",{children:["\u9879\u76EE\u540D",withNeed?jsx19("em",{className:"band-workshops-opt",children:fromForm?"\u53EF\u4E0D\u586B\uFF0C\u9ED8\u8BA4\u53D6\u8868\u5355\u91CC\u7B2C\u4E00\u9879\u6587\u5B57\uFF08\u6700\u591A 30 \u5B57\uFF09":"\u53EF\u4E0D\u586B\uFF0C\u9ED8\u8BA4\u53D6\u9700\u6C42\u7684\u7B2C\u4E00\u53E5\uFF08\u6700\u591A 30 \u5B57\uFF09"}):null]}),jsx19("input",{ref:nameRef,type:"text",value:name,maxLength:200,required:!withNeed,disabled:busy,placeholder:placeholderName,onChange:e=>setName(e.target.value),"aria-invalid":failed||flagged&&"missing"in input&&input.missing==="\u9879\u76EE\u540D"?true:void 0,...described})]}),formSchema&&jsxs19("div",{className:"band-workshops-params",children:[jsx19("span",{className:"band-workshops-params-title",children:formStage?stageNames(w.workflows[0]?.stages??[])[w.workflows[0]?.stages.indexOf(formStage)??-1]??formStage.id:""}),jsx19(ParamFields,{schema:formSchema,values:formValues,acked:formAcked,disabled:busy,invalidKeys:formFlagged?new Set(formMissing):void 0,onChange:(k,v)=>{setFormValues(cur=>({...cur,[k]:v}));setFormAcked(cur=>{if(!cur.has(k))return cur;const next=new Set(cur);next.delete(k);return next});setFormFlagged(false)},onAck:(k,checked)=>setFormAcked(cur=>{const next=new Set(cur);if(checked)next.add(k);else next.delete(k);return next})}),formMissing.length>0&&jsxs19("span",{className:"band-workshops-params-hint",children:["\u8FD8\u5DEE",formMissing.map(k=>formSchema.properties[k]?.title??k).join("\u3001"),"\u6CA1\u586B"]}),formUnacked.length>0&&jsxs19("span",{className:"band-workshops-params-hint",children:[formUnacked.map(([k])=>formSchema.properties[k]?.title??k).join("\u3001"),"\u9009\u4E86\u8981\u786E\u8BA4\u7684\u503C\uFF0C\u5148\u52FE\u300C\u6211\u5DF2\u77E5\u6653\u300D"]})]}),requiredRepos.map(repo=>{const noteId=`band-workshops-repo-${repo.name}-note`;const rejected=repoError?.repo===repo.name&&repoError.value===(repoUrls[repo.name]?.trim()??"")?repoError.message:void 0;return jsxs19("div",{className:"band-workshops-repo",children:[jsxs19("label",{className:"band-workshops-field",children:[jsxs19("span",{children:["\u4ED3\u5E93\u5730\u5740 ",jsx19("em",{className:"band-workshops-req",children:"\u5FC5\u586B"})," ",jsx19("em",{className:"band-workshops-opt",children:repoFieldHint(repo)})]}),jsx19("input",{ref:el=>{repoInputs.current[repo.name]=el},className:"field",type:"text",value:repoUrls[repo.name]??"",required:true,maxLength:500,disabled:busy,placeholder:REPO_URL_EXAMPLE,"aria-invalid":flagged&&!repoUrls[repo.name]?.trim()||rejected?true:void 0,"aria-describedby":rejected?`${targetRepoErrorId(noteId)} ${noteId}`:noteId,onChange:e=>setRepoUrls(current=>({...current,[repo.name]:e.target.value}))})]}),jsx19(TargetRepoNote,{id:noteId,error:rejected,requestAccessUrl:rejected?repoError?.requestAccessUrl:void 0})]},repo.name)}),noKey?jsx19(NoKeyNotice,{id:errId,onGo:goConfigure}):failed?jsxs19("p",{id:errId,className:"band-workshops-err",role:"alert",children:["\u6CA1\u5EFA\u6210\uFF1A",failed,provisionFailed?jsxs19(Fragment19,{children:[" ",jsx19("button",{type:"button",className:"btn sm",onClick:goConfigure,children:"\u6211\u7684\u6A21\u578B\u4E0E\u51ED\u636E"})]}):null]}):tooLong?jsx19("p",{className:"band-workshops-err",children:"\u9700\u6C42\u592A\u957F\u4E86\uFF0C\u5220\u77ED\u4E00\u4E9B\u518D\u5EFA"}):null,jsx19(ProjectModelField,{state:model.state,selected:model.selected,select:model.select,onConfigure:goConfigure,disabled:busy}),jsxs19("div",{className:"band-workshops-actions",children:[jsx19("button",{type:"button",className:"btn ghost",onClick:cancel,disabled:busy,children:"\u53D6\u6D88"}),!modelMissingNote&&inputMissingNote&&jsx19("output",{id:"band-workshops-project-hint",className:"band-workshops-hint",children:inputMissingNote}),jsx19("button",{type:"submit",className:"btn primary","aria-describedby":!modelMissingNote&&inputMissingNote?"band-workshops-project-hint":void 0,disabled:createDisabled,...modelMissingNote?{title:modelMissingNote}:{},children:busy?"\u6B63\u5728\u65B0\u5EFA\u2026":trial?"\u65B0\u5EFA\u8BD5\u7528\u9879\u76EE":withNeed?"\u65B0\u5EFA\u5E76\u4EA4\u7ED9 Rondo":"\u65B0\u5EFA\u5E76\u6253\u5F00"}),modelMissingNote?jsx19("span",{className:"band-workshops-params-hint",children:modelMissingNote}):createDisabled||inputMissingNote?null:jsxs19("span",{className:"band-workshops-params-hint",children:[SUBMIT_SHORTCUT," \u65B0\u5EFA"]})]})]}):jsx19("p",{className:"band-workshops-note",children:"\u8FD9\u91CC\u4E0D\u80FD\u65B0\u5EFA\u9879\u76EE\uFF1A\u5BBF\u4E3B\u6CA1\u6709\u7ED9\u5199\u6743\u9650\u3002"})]})}function CopiedFrom({ctx,raw,inline:inline3=false}){const at=raw.lastIndexOf("@");const source=at>0?raw.slice(0,at):raw;const{data:list}=useAppData6(ctx,d=>d.workshops(),[]);const name=list?.find(w=>w.id===source)?.name??source;const link=jsx19("button",{type:"button",className:"band-workshops-link",onClick:()=>ctx.app.navigate({page:`${SELF}/about`,params:{workshop:source}}),children:name});if(inline3)return link;return jsxs19(Fragment19,{children:[jsx19("dt",{children:"\u57FA\u4E8E"}),jsx19("dd",{children:link})]})}export{About,Catalog,CopiedFrom,FlowBig,Missing,NewProject,NewWorkshop,OverrideNotices,PERM_TEXT,PublishRelease,STORAGE_TEXT,Table,WORKSHOP_YAML_EXAMPLE,WorkshopPlugins,agentLabel2 as agentLabel,agentLine,agentsOf,canPublish,cardStatus,copyBlocked,customAgents,src_default as default,deployCount,edgePath,flowLayout,flowStory,formHoldsNeed,freeTextFields,isRondoAgent,needFromForm,newProjectInput,overrideLine,pluginSourceText,publishFailure,spaced,stageNames,takesNeed,unavailableStageNote,useExpiringConnections,useWorkshop,visibilityText,workshopIdProblems,workshopPlugins};