@iaforged/context-code 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/bridge/bridgeMain.js +1 -1
- package/dist/src/bridge/types.js +1 -1
- package/dist/src/cli/handlers/auth.js +1 -1
- package/dist/src/cli/handlers/mcp.js +1 -1
- package/dist/src/cli/print.js +1 -1
- package/dist/src/commands/copy/copy.js +1 -1
- package/dist/src/commands/heartbeat/heartbeat.js +1 -0
- package/dist/src/commands/heartbeat/index.js +1 -0
- package/dist/src/commands/insights.js +1 -1
- package/dist/src/commands/install-github-app/ExistingWorkflowStep.js +1 -1
- package/dist/src/commands/install-github-app/InstallAppStep.js +1 -1
- package/dist/src/commands/install-github-app/OAuthFlowStep.js +1 -1
- package/dist/src/commands/install-github-app/SuccessStep.js +1 -1
- package/dist/src/commands/install-github-app/setupGitHubActions.js +1 -1
- package/dist/src/commands/login-openai/index.js +1 -1
- package/dist/src/commands/mobile/mobile.js +1 -1
- package/dist/src/commands/remote-setup/remote-setup.js +1 -1
- package/dist/src/commands/swarm-auto/swarmAuto.js +1 -1
- package/dist/src/commands/timeline/timeline.js +1 -1
- package/dist/src/commands/webapp/webapp.js +1 -1
- package/dist/src/commands.js +1 -1
- package/dist/src/components/ApproveApiKey.js +1 -1
- package/dist/src/components/ChannelDowngradeDialog.js +1 -1
- package/dist/src/components/ClaudeCodeHint/PluginHintMenu.js +1 -1
- package/dist/src/components/ConsoleOAuthFlow.js +1 -1
- package/dist/src/components/CostThresholdDialog.js +1 -1
- package/dist/src/components/CtrlOToExpand.js +1 -1
- package/dist/src/components/CustomSelect/select.js +1 -1
- package/dist/src/components/DesktopHandoff.js +1 -1
- package/dist/src/components/DesktopUpsell/DesktopUpsellStartup.js +1 -1
- package/dist/src/components/ExportDialog.js +1 -1
- package/dist/src/components/Feedback.js +1 -1
- package/dist/src/components/FeedbackSurvey/FeedbackSurvey.js +1 -1
- package/dist/src/components/FeedbackSurvey/FeedbackSurveyView.js +1 -1
- package/dist/src/components/IdeAutoConnectDialog.js +1 -1
- package/dist/src/components/IdeOnboardingDialog.js +1 -1
- package/dist/src/components/IdleReturnDialog.js +1 -1
- package/dist/src/components/InterruptedByUser.js +1 -1
- package/dist/src/components/InvalidConfigDialog.js +1 -1
- package/dist/src/components/InvalidSettingsDialog.js +1 -1
- package/dist/src/components/LanguagePicker.js +1 -1
- package/dist/src/components/LogSelector.js +1 -1
- package/dist/src/components/LogoV2/ChannelsNotice.js +1 -1
- package/dist/src/components/LogoV2/LogoV2.js +1 -1
- package/dist/src/components/LogoV2/feedConfigs.js +1 -1
- package/dist/src/components/LspRecommendation/LspRecommendationMenu.js +1 -1
- package/dist/src/components/MCPServerApprovalDialog.js +1 -1
- package/dist/src/components/MCPServerDesktopImportDialog.js +1 -1
- package/dist/src/components/ManagedSettingsSecurityDialog/ManagedSettingsSecurityDialog.js +1 -1
- package/dist/src/components/MessageSelector.js +1 -1
- package/dist/src/components/OutputStylePicker.js +1 -1
- package/dist/src/components/PromptInput/PromptInput.js +1 -1
- package/dist/src/components/RemoteCallout.js +1 -1
- package/dist/src/components/ResumeTask.js +1 -1
- package/dist/src/components/Settings/Config.js +1 -1
- package/dist/src/components/ShowInIDEPrompt.js +1 -1
- package/dist/src/components/Stats.js +1 -1
- package/dist/src/components/TagTabs.js +1 -1
- package/dist/src/components/TeleportError.js +1 -1
- package/dist/src/components/TeleportResumeWrapper.js +1 -1
- package/dist/src/components/TextInput.js +1 -1
- package/dist/src/components/agents/new-agent-creation/wizard-steps/MethodStep.js +1 -1
- package/dist/src/components/design-system/KeyboardShortcutHint.js +1 -1
- package/dist/src/components/diff/DiffDetailView.js +1 -1
- package/dist/src/components/grove/Grove.js +1 -1
- package/dist/src/components/hooks/SelectEventMode.js +1 -1
- package/dist/src/components/hooks/SelectHookMode.js +1 -1
- package/dist/src/components/hooks/SelectMatcherMode.js +1 -1
- package/dist/src/components/hooks/ViewHookMode.js +1 -1
- package/dist/src/components/mcp/MCPAgentServerMenu.js +1 -1
- package/dist/src/components/mcp/utils/reconnectHelpers.js +1 -1
- package/dist/src/components/memory/MemoryFileSelector.js +1 -1
- package/dist/src/components/messages/AssistantTextMessage.js +1 -1
- package/dist/src/components/messages/PlanApprovalMessage.js +1 -1
- package/dist/src/components/messages/ShutdownMessage.js +1 -1
- package/dist/src/components/messages/SystemAPIErrorMessage.js +1 -1
- package/dist/src/components/messages/UserPlanMessage.js +1 -1
- package/dist/src/components/permissions/AskUserQuestionPermissionRequest/PreviewQuestionView.js +1 -1
- package/dist/src/components/permissions/ComputerUseApproval/ComputerUseApproval.js +1 -1
- package/dist/src/components/permissions/FileEditPermissionRequest/FileEditPermissionRequest.js +1 -1
- package/dist/src/components/permissions/FilePermissionDialog/FilePermissionDialog.js +1 -1
- package/dist/src/components/permissions/FilePermissionDialog/permissionOptions.js +1 -1
- package/dist/src/components/permissions/FileWritePermissionRequest/FileWritePermissionRequest.js +1 -1
- package/dist/src/components/permissions/FilesystemPermissionRequest/FilesystemPermissionRequest.js +1 -1
- package/dist/src/components/permissions/PermissionRequest.js +1 -1
- package/dist/src/components/permissions/SedEditPermissionRequest/SedEditPermissionRequest.js +1 -1
- package/dist/src/components/permissions/SkillPermissionRequest/SkillPermissionRequest.js +1 -1
- package/dist/src/components/permissions/WebFetchPermissionRequest/WebFetchPermissionRequest.js +1 -1
- package/dist/src/components/permissions/rules/AddPermissionRules.js +1 -1
- package/dist/src/components/permissions/rules/AddWorkspaceDirectory.js +1 -1
- package/dist/src/components/permissions/rules/PermissionRuleList.js +1 -1
- package/dist/src/components/permissions/rules/RemoveWorkspaceDirectory.js +1 -1
- package/dist/src/components/sandbox/SandboxConfigTab.js +1 -1
- package/dist/src/components/sandbox/SandboxOverridesTab.js +1 -1
- package/dist/src/components/tasks/RemoteSessionDetailDialog.js +1 -1
- package/dist/src/constants/outputStyles.js +1 -1
- package/dist/src/entrypoints/cli.js +1 -1
- package/dist/src/hooks/notifs/useCanSwitchToExistingSubscription.js +1 -1
- package/dist/src/main.js +1 -1
- package/dist/src/projectOnboardingState.js +1 -1
- package/dist/src/screens/REPL.js +1 -1
- package/dist/src/services/api/errors.js +1 -1
- package/dist/src/services/api/filesApi.js +1 -1
- package/dist/src/services/tips/tipRegistry.js +1 -1
- package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +1 -1
- package/dist/src/tools/AgentTool/AgentTool.js +1 -1
- package/dist/src/tools/ConfigTool/supportedSettings.js +1 -1
- package/dist/src/tools/EnterWorktreeTool/EnterWorktreeTool.js +1 -1
- package/dist/src/tools/ExitWorktreeTool/ExitWorktreeTool.js +1 -1
- package/dist/src/tools/WebFetchTool/WebFetchTool.js +1 -1
- package/dist/src/utils/computerUse/cleanup.js +1 -1
- package/dist/src/utils/computerUse/wrapper.js +1 -1
- package/dist/src/utils/fileHistory.js +1 -1
- package/dist/src/utils/heartbeat.js +1 -0
- package/dist/src/utils/model/providers.js +1 -1
- package/dist/src/utils/permissions/filesystem.js +1 -1
- package/dist/src/utils/permissions/permissions.js +1 -1
- package/dist/src/utils/processUserInput/processSlashCommand.js +1 -1
- package/dist/src/utils/releaseNoteTranslations.js +1 -1
- package/dist/src/utils/shell/shellToolUtils.js +1 -1
- package/dist/src/utils/sshMcp/common.js +1 -0
- package/dist/src/utils/sshMcp/setup.js +1 -0
- package/dist/src/utils/sshMcp/sshMcpServer.js +1 -0
- package/dist/src/utils/sshMcp/sshMcpServer.test.js +1 -0
- package/dist/src/utils/teleport.js +1 -1
- package/dist/src/webapp/server.js +1 -1
- package/dist/sshMcpServer.js +1 -0
- package/dist/sshMcpServer.test.js +1 -0
- package/dist/webapp/chunk-AMCDNAIG.js +1 -0
- package/dist/webapp/{chunk-YUEYJPXQ.js → chunk-NFYBHCXF.js} +1 -1
- package/dist/webapp/{chunk-DFKSSBHI.js → chunk-OJZNEHPP.js} +1 -1
- package/dist/webapp/chunk-VAB2VXFI.js +1 -0
- package/dist/webapp/index.html +2 -2
- package/dist/webapp/main-MTQLKGXD.js +1 -0
- package/dist/webapp/ngsw.json +14 -14
- package/dist/webapp/styles-DIKEDJBH.css +1 -0
- package/package.json +2 -1
- package/dist/webapp/chunk-4SRNXNLW.js +0 -1
- package/dist/webapp/chunk-SIHYW6PA.js +0 -1
- package/dist/webapp/main-LBNRQBXX.js +0 -1
- package/dist/webapp/styles-FUPULZDX.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"figures";import{useEffect as n,useMemo as i,useState as r}from"react";import{createHistoryAuthCtx as o,fetchLatestEvents as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"figures";import{useEffect as n,useMemo as i,useState as r}from"react";import{createHistoryAuthCtx as o,fetchLatestEvents as a,fetchOlderEvents as l}from"../../assistant/sessionHistory.js";import{getSessionId as m}from"../../bootstrap/state.js";import{Select as c}from"../../components/CustomSelect/select.js";import{Spinner as u}from"../../components/Spinner.js";import{FuzzyPicker as d}from"../../components/design-system/FuzzyPicker.js";import{stringWidth as p}from"../../ink/stringWidth.js";import{setClipboard as g}from"../../ink/termio/osc.js";import{Box as f,Text as h}from"../../ink.js";import{formatRelativeTimeAgo as I,truncateToWidth as y}from"../../utils/format.js";import{logForDebugging as w}from"../../utils/debug.js";function asTimelineItem(e,t){if(!function(e){return"user"===e.type&&null==e.parent_tool_use_id&&!e.isSynthetic&&!e.isReplay}(e))return null;if(!e.uuid)return null;const s=function(e){if("string"==typeof e){const t=e.trim();return t.length>0?t:null}if(!Array.isArray(e))return null;const t=e.find(e=>"text"===e?.type&&"string"==typeof e.text),s=t?.text?.trim();return s&&s.length>0?s:null}(e.message?.content);if(!s)return null;const n=e.timestamp??(new Date).toISOString(),i=I(new Date(n));return{sessionId:t,messageId:e.uuid,preview:s.slice(0,220),fullText:s,timestamp:n,age:i+" ".repeat(Math.max(0,8-p(i))),lower:s.toLowerCase()}}function TimelinePicker({onDone:p,onJumpToMessage:I,onOpenMessageSelectorAtMessage:b}){const[j,x]=r(!0),[v,C]=r([]),[M,k]=r(""),[S,T]=r(null);n(()=>{let e=!1;return(async()=>{try{const t=m(),s=await async function(e){const t=await o(e),s=await a(t);if(!s)return[];const n=[...s.events];let i=s.firstId,r=s.hasMore,m=1;for(;r&&i&&m<30;){const e=await l(t,i);if(!e)break;n.unshift(...e.events),i=e.firstId,r=e.hasMore,m++}return r&&w(`[timeline] Stopped pagination at MAX_PAGES=30 for session ${e}`),n.map(t=>asTimelineItem(t,e)).filter(e=>null!==e).reverse()}(t);e||C(s)}catch(t){e||C([])}finally{e||x(!1)}})(),()=>{e=!0}},[]);const A=i(()=>{const e=M.trim().toLowerCase();return e?v.filter(t=>t.lower.includes(e)):v},[v,M]);if(j)return t(f,{children:[e(u,{}),e(h,{children:" Loading timeline…"})]});if(S){const n=[{label:"Copiar",value:"copy",description:"Copiar contenido del mensaje al input (sin envío automático)"},{label:"Bifurcar",value:"fork",description:"Preparar flujo /branch (el CLI actual no tiene fork por messageId)"},{label:"Revertir",value:"revert",description:"Abrir flujo /rewind existente"},{label:"Back",value:"back"}],handleAction=async e=>{if("back"!==e){if("copy"===e){const e=await g(S.fullText);return e&&process.stdout.write(e),void p("Timeline message copied to input and clipboard.",{display:"system",nextInput:S.fullText,submitNextInput:!1,jumpToMessageId:S.messageId})}"fork"!==e?(I(S.messageId),b(S.messageId),p("Opened rewind selector at selected timeline message.",{display:"skip"})):p(`Prepared /branch and kept focus on selected timeline message (${S.messageId}).`,{display:"system",nextInput:"/branch",submitNextInput:!1,jumpToMessageId:S.messageId})}else T(null)};return t(f,{flexDirection:"column",gap:1,children:[e(h,{bold:!0,children:"Timeline actions"}),e(h,{dimColor:!0,children:new Date(S.timestamp).toLocaleString()}),e(h,{children:S.preview}),t(h,{dimColor:!0,children:[s.pointer," messageId: ",S.messageId]}),e(c,{options:n,onChange:e=>{handleAction(e)},onCancel:()=>T(null)})]})}return e(d,{title:"Session timeline",placeholder:"Filter user messages…",items:A,getKey:e=>e.messageId,onQueryChange:k,onSelect:e=>{I(e.messageId),T(e)},onCancel:()=>p("Timeline cancelled"),emptyMessage:e=>0===v.length?"No user messages found in current session":e?"No matching messages":"No user messages found",selectAction:"select message",renderItem:(s,n)=>t(h,{children:[e(h,{dimColor:!0,children:s.age}),t(h,{color:n?"suggestion":void 0,children:[" ",y(s.preview,140)]})]}),renderPreview:n=>t(f,{flexDirection:"column",borderStyle:"round",borderDimColor:!0,paddingX:1,children:[e(h,{dimColor:!0,children:new Date(n.timestamp).toLocaleString()}),e(h,{children:n.preview}),t(h,{dimColor:!0,children:[s.pointer," sessionId: ",n.sessionId]}),t(h,{dimColor:!0,children:[s.pointer," messageId: ",n.messageId]})]})})}export const call=async(t,s,n)=>e(TimelinePicker,{onDone:t,onJumpToMessage:e=>{s.jumpToMessage?.(e)},onOpenMessageSelectorAtMessage:e=>{s.openMessageSelectorAtMessage?.(e)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Box as a,Text as n}from"../../ink.js";import{Select as r}from"../../components/CustomSelect/select.js";import{getGlobalConfig as o,saveGlobalConfig as l}from"../../utils/config.js";function readCfg(){return o().webappConfig??{}}function patchCfg(e){l(t=>({...t,webappConfig:{...t.webappConfig??{},...e}}))}async function start(){const{startWebappServer:e}=await import("../../webapp/server.js"),t=await e();if(t.ok){const e=await openInBrowser();return`${t.message}\n${e}`}return t.message}async function stop(){const{stopWebappServer:e}=await import("../../webapp/server.js")
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Box as a,Text as n}from"../../ink.js";import{Select as r}from"../../components/CustomSelect/select.js";import{getGlobalConfig as o,saveGlobalConfig as l}from"../../utils/config.js";function readCfg(){return o().webappConfig??{}}function patchCfg(e){l(t=>({...t,webappConfig:{...t.webappConfig??{},...e}}))}async function start(){const{startWebappServer:e}=await import("../../webapp/server.js"),t=await e();if(t.ok){const e=await openInBrowser();return`${t.message}\n${e}`}return t.message}async function stop(){const{stopWebappServer:e}=await import("../../webapp/server.js"),t=await e();return patchCfg({publicUrl:void 0}),t.message}async function statusText(){const{getWebappStatus:e}=await import("../../webapp/server.js"),{getTunnelStatus:t}=await import("../../webapp/tunnel.js"),a=e(),n=t(),r=["WebApp - estado","- Servidor: "+(a.running?"activo":"inactivo"),`- Puerto: ${a.port??readCfg().port??9876}`,`- Bind: ${a.bindHost??readCfg().bindHost??"127.0.0.1"}`,`- URL local: ${a.localUrl??`http://localhost:${readCfg().port??9876}`}`];return a.publicUrl?r.push(`- URL pública: ${a.url}`):n.running&&n.publicUrl?r.push(`- URL pública (túnel): ${n.publicUrl}/?token=<token>`):r.push("- URL pública: no configurada (usá /webapp tunnel start)"),r.push(`- Conexiones activas: ${a.connections}`,"- Build estático PWA: "+(a.staticAvailable?"disponible":"no compilado (apps/webapp aún no buildeado)"),"- Túnel cloudflared: "+(n.running?`activo (pid ${n.pid})`:"inactivo")),n.lastError&&r.push(`- Último error de túnel: ${n.lastError}`),a.sessionId&&r.push(`- Session ID: ${a.sessionId}`),r.join("\n")}async function tunnelStart(){const{getWebappStatus:e,startWebappServer:t}=await import("../../webapp/server.js"),{startTunnel:a}=await import("../../webapp/tunnel.js");let n=e();if(!n.running){const a=await t();if(!a.ok)return`No pude arrancar la WebApp antes del túnel: ${a.message}`;n=e()}const r=n.port??readCfg().port??9876,o=await a(r);if(!o.ok)return o.message;patchCfg({publicUrl:o.publicUrl});const{getWebappUrl:l}=await import("../../webapp/server.js");return[o.message,"","Compartí esta URL para acceder desde cualquier dispositivo con el token:",l(),"","Nota: la URL trycloudflare.com es efímera — al detener el túnel se invalida."].join("\n")}async function tunnelStop(){const{stopTunnel:e}=await import("../../webapp/tunnel.js"),t=await e();return patchCfg({publicUrl:void 0}),t.message}async function tunnelStatus(){const{getTunnelStatus:e}=await import("../../webapp/tunnel.js"),t=e(),a=["Túnel - estado","- Activo: "+(t.running?"sí":"no")];return t.pid&&a.push(`- PID: ${t.pid}`),t.publicUrl&&a.push(`- URL pública: ${t.publicUrl}`),t.startedAt&&a.push(`- Iniciado: ${new Date(t.startedAt).toLocaleString()}`),t.lastError&&a.push(`- Último error: ${t.lastError}`),a.join("\n")}async function showToken(e){const{ensureWebappToken:t,generateWebappToken:a}=await import("../../webapp/auth.js");return[e?"Token regenerado. El anterior queda inválido — los clientes conectados deben reconectarse con el nuevo.":"Token actual (pegalo en la PWA la primera vez que la abras):","",e?a():t(),"","Guardado en ~/.context/config.json bajo webappConfig.token."].join("\n")}async function openInBrowser(){const{getWebappUrl:e}=await import("../../webapp/server.js"),t=e();try{const{exec:e}=await import("node:child_process"),a=process.platform;let n;return n="win32"===a?`start "" "${t}"`:"darwin"===a?`open "${t}"`:`xdg-open "${t}"`,e(n,e=>{}),"Abriendo la WebApp en el navegador..."}catch{return`Abrí en tu navegador: ${t}`}}function helpText(){return["WebApp - comandos","- /webapp (menu interactivo)","- /webapp start (arranca el server HTTP+WS)","- /webapp stop (lo detiene)","- /webapp status (puerto, URL local/pública, túnel, conexiones)","- /webapp open (abre la PWA en el navegador default)","- /webapp token (muestra el token de auth)","- /webapp token reset (regenera el token y desconecta clientes)","- /webapp port <n> (cambia el puerto — default 9876)","- /webapp autostart (activa/desactiva auto-arranque al iniciar CLI)","","Acceso público (túnel):","- /webapp tunnel start (levanta un túnel Cloudflare TryCloudflare, URL HTTPS pública)","- /webapp tunnel stop (detiene el túnel)","- /webapp tunnel status (estado del túnel + URL actual)","- /webapp tunnel url <u> (registra manualmente una URL pública — propio Cloudflare/ngrok)","- /webapp tunnel clear (remueve la URL pública registrada)","","El frontend Angular vive en apps/webapp/ (build → CLI/dist/webapp/).","Por default el server escucha en 127.0.0.1 (LAN-only). Para exponer fuera","de tu red, lo recomendado es /webapp tunnel start (requiere cloudflared)."].join("\n")}export async function call(t,a,n){const r=(n??"").trim(),o=r.toLowerCase();if(!r)return t(await statusText()),e(WebAppMenu,{onDone:t});if("status"===o||"estado"===o)return t(await statusText()),null;if("start"===o||"iniciar"===o)return t(await start()),null;if("stop"===o||"detener"===o)return t(await stop()),null;if("open"===o||"abrir"===o)return t(await openInBrowser()),null;if("token"===o)return t(await showToken(!1)),null;if("token reset"===o||"token regenerar"===o)return t(await showToken(!0)),null;if("autostart"===o||"auto"===o){const e=!0===readCfg().autoStart;return patchCfg({autoStart:!e}),t(`Auto-arranque ${e?"desactivado":"activado"}. La WebApp ${e?"no se arrancará sola; usá /webapp start":"se levantará automáticamente al iniciar el CLI"}.`),null}if("help"===o||"ayuda"===o)return t(helpText()),null;const[l,...s]=r.split(/\s+/);if("port"===(l??"").toLowerCase()||"puerto"===(l??"").toLowerCase()){const e=Number(s.join(" ").trim());return!Number.isInteger(e)||e<1024||e>65535?(t("Puerto inválido. Debe ser un entero entre 1024 y 65535."),null):(patchCfg({port:e}),t(`Puerto guardado: ${e}. Reinicia el server con /webapp stop && /webapp start.`),null)}if("tunnel"===(l??"").toLowerCase()||"tunel"===(l??"").toLowerCase()||"túnel"===(l??"").toLowerCase()){const e=(s[0]??"").toLowerCase(),a=s.slice(1).join(" ").trim();return"start"===e||"iniciar"===e?(t(await tunnelStart()),null):"stop"===e||"detener"===e?(t(await tunnelStop()),null):"status"===e||"estado"===e||""===e?(t(await tunnelStatus()),null):"url"===e?a?(t(await async function(e){const t=e.trim();if(!/^https?:\/\/.+/i.test(t))return"URL inválida. Debe empezar con http:// o https://.";patchCfg({publicUrl:t});const{getWebappUrl:a}=await import("../../webapp/server.js");return[`URL pública registrada: ${t}`,`Compartí: ${a()}`,"","Para volver al modo local: /webapp tunnel clear"].join("\n")}(a)),null):(t("Uso: /webapp tunnel url <https://mi-dominio>"),null):"clear"===e||"limpiar"===e?(t(await async function(){return patchCfg({publicUrl:void 0}),"URL pública removida. La WebApp vuelve a publicarse solo en localhost."}()),null):(t("Subcomandos: start | stop | status | url <u> | clear"),null)}return t(helpText()),null}function WebAppMenu({onDone:o}){const l=readCfg(),exit=()=>o();return t(a,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan",children:[e(a,{marginBottom:1,children:e(n,{bold:!0,color:"cyan",children:"🖥 WebApp — acciones"})}),e(r,{options:[{label:"📋 Ver estado",value:"status"},{label:"🚀 Arrancar server",value:"start"},{label:"🛑 Detener server",value:"stop"},{label:"🌐 Abrir en navegador",value:"open"},{label:"🔑 Ver token",value:"token"},{label:"♻️ Regenerar token",value:"token_reset"},{label:"☁️ Túnel público (start)",value:"tunnel_start"},{label:"⏹ Detener túnel",value:"tunnel_stop"},{label:"📡 Estado del túnel",value:"tunnel_status"},{label:l.autoStart?"🔁 Desactivar auto-arranque":"🔁 Activar auto-arranque al iniciar CLI",value:"autostart"},{label:"❓ Ayuda",value:"help"},{label:"❌ Cerrar menú",value:"exit"}],onChange:async e=>{if("status"!==e)if("start"!==e)if("stop"!==e)if("open"!==e)if("token"!==e)if("token_reset"!==e)if("tunnel_start"!==e)if("tunnel_stop"!==e)if("tunnel_status"!==e){if("autostart"===e){const e=!0===readCfg().autoStart;return patchCfg({autoStart:!e}),void o(`Auto-arranque ${e?"desactivado":"activado"}.`)}"help"!==e?exit():o(helpText())}else o(await tunnelStatus());else o(await tunnelStop());else o(await tunnelStart());else o(await showToken(!0));else o(await showToken(!1));else o(await openInBrowser());else o(await stop());else o(await start());else o(await statusText())},onCancel:exit})]})}
|
package/dist/src/commands.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{feature as o}from"./recovery/bunBundleShim.js";import{createRequire as m}from"module";const n=m(import.meta.url);import i from"./commands/add-dir/index.js";import e from"./commands/autofix-pr/index.js";import s from"./commands/backfill-sessions/index.js";import r from"./commands/btw/index.js";import t from"./commands/good-claude/index.js";import a from"./commands/issue/index.js";import d from"./commands/feedback/index.js";import l from"./commands/clear/index.js";import c from"./commands/color/index.js";import p from"./commands/commit.js";import f from"./commands/copy/index.js";import u from"./commands/desktop/index.js";import j from"./commands/commit-push-pr.js";import x from"./commands/compact/index.js";import g from"./commands/config/index.js";import{context as S,contextNonInteractive as h}from"./commands/context/index.js";import k from"./commands/cost/index.js";import C from"./commands/diff/index.js";import b from"./commands/ctx_viz/index.js";import w from"./commands/doctor/index.js";import y from"./commands/memory/index.js";import E from"./commands/help/index.js";import v from"./commands/ide/index.js";import R from"./commands/init.js";import _ from"./commands/init-verifiers.js";import M from"./commands/keybindings/index.js";import O from"./commands/login/index.js";import I from"./commands/logout/index.js";import T from"./commands/install-github-app/index.js";import A from"./commands/install-slack-app/index.js";import D from"./commands/break-cache/index.js";import N from"./commands/mcp/index.js";import P from"./commands/mobile/index.js";import L from"./commands/agent/index.js";import B from"./commands/onboarding/index.js";import F from"./commands/pr_comments/index.js";import $ from"./commands/release-notes/index.js";import U from"./commands/rename/index.js";import K from"./commands/resume/index.js";import W,{ultrareview as G}from"./commands/review.js";import Y from"./commands/session/index.js";import H from"./commands/share/index.js";import z from"./commands/skills/index.js";import q from"./commands/status/index.js";import X from"./commands/teleport/index.js";import V from"./commands/telegram/index.js";import J from"./commands/whatsapp/index.js";import Q from"./commands/canal-global/index.js";import Z from"./commands/playwright/index.js";import oo from"./commands/webapp/index.js";const mo="ant"===process.env.USER_TYPE?n("./commands/agents-platform/index.js").default:null;import no from"./commands/security-review.js";import io from"./commands/bughunter/index.js";import eo from"./commands/terminalSetup/index.js";import so from"./commands/theme/index.js";import ro from"./commands/timeline/index.js";import to from"./commands/vim/index.js";const ao=o("PROACTIVE")||o("KAIROS")?n("./commands/proactive.js").default:null,lo=o("KAIROS")||o("KAIROS_BRIEF")?n("./commands/brief.js").default:null,co=o("KAIROS")?n("./commands/assistant/index.js").default:null,po=o("BRIDGE_MODE")?n("./commands/bridge/index.js").default:null,fo=o("DAEMON")&&o("BRIDGE_MODE")?n("./commands/remoteControlServer/index.js").default:null,uo=n("./commands/voice/index.js").default,jo=o("HISTORY_SNIP")?n("./commands/force-snip.js").default:null,xo=o("WORKFLOW_SCRIPTS")?n("./commands/workflows/index.js").default:null,go=o("CCR_REMOTE_SETUP")?n("./commands/remote-setup/index.js").default:null,So=o("EXPERIMENTAL_SKILL_SEARCH")?n("./services/skillSearch/localSearch.js").clearSkillIndexCache:null,ho=o("KAIROS_GITHUB_WEBHOOKS")?n("./commands/subscribe-pr.js").default:null,ko=o("ULTRAPLAN")?n("./commands/ultraplan.js").default:null,Co=o("TORCH")?n("./commands/torch.js").default:null,bo=o("UDS_INBOX")?n("./commands/peers/index.js").default:null,wo=o("FORK_SUBAGENT")?n("./commands/fork/index.js").default:null,yo=o("BUDDY")?n("./commands/buddy/index.js").default:null;import Eo from"./commands/thinkback/index.js";import vo from"./commands/thinkback-play/index.js";import Ro from"./commands/permissions/index.js";import _o from"./commands/plan/index.js";import Mo from"./commands/fast/index.js";import Oo from"./commands/passes/index.js";import Io from"./commands/privacy-settings/index.js";import To from"./commands/hooks/index.js";import Ao from"./commands/files/index.js";import Do from"./commands/branch/index.js";import No from"./commands/agents/index.js";import Po from"./commands/plugin/index.js";import Lo from"./commands/reload-plugins/index.js";import Bo from"./commands/rewind/index.js";import Fo from"./commands/heapdump/index.js";import $o from"./commands/mock-limits/index.js";import Uo from"./commands/bridge-kick.js";import Ko from"./commands/version.js";import Wo from"./commands/summary/index.js";import{resetLimits as Go,resetLimitsNonInteractive as Yo}from"./commands/reset-limits/index.js";import Ho from"./commands/ant-trace/index.js";import zo from"./commands/perf-issue/index.js";import qo from"./commands/sandbox-toggle/index.js";import Xo from"./commands/stickers/index.js";import Vo from"./commands/advisor.js";import{logError as Jo}from"./utils/log.js";import{MalformedCommandError as Qo,toError as Zo}from"./utils/errors.js";import{logForDebugging as om}from"./utils/debug.js";import{getSkillDirCommands as mm,clearSkillCaches as nm,getDynamicSkills as im}from"./skills/loadSkillsDir.js";import{getBundledSkills as em}from"./skills/bundledSkills.js";import{getBuiltinPluginSkillCommands as sm}from"./plugins/builtinPlugins.js";import{getPluginCommands as rm,clearPluginCommandCache as tm,getPluginSkills as am,clearPluginSkillsCache as dm}from"./utils/plugins/loadPluginCommands.js";import{isCoreSkillsEnabled as lm,loadCoreSkillCommandSources as cm}from"./core/skills/index.js";import pm from"lodash-es/memoize.js";import{isUsing3PServices as fm,isClaudeAISubscriber as um}from"./utils/auth.js";import{isFirstPartyAnthropicBaseUrl as jm}from"./utils/model/providers.js";import xm from"./commands/env/index.js";import gm from"./commands/exit/index.js";import Sm from"./commands/export/index.js";import hm from"./commands/model/index.js";import km from"./commands/profile/index.js";import Cm from"./commands/policy/index.js";import bm from"./commands/run/index.js";import wm from"./commands/workspace/index.js";import ym from"./commands/provider/index.js";import Em from"./commands/tag/index.js";import vm from"./commands/team-auto/index.js";import Rm from"./commands/orchestrate/index.js";import _m from"./commands/swarm-auto/index.js";import Mm from"./commands/swarm-init/index.js";import Om from"./commands/team/index.js";import Im from"./commands/limites/index.js";import Tm from"./commands/objetivo/index.js";import Am from"./commands/resumen/index.js";import Dm from"./commands/output-style/index.js";import Nm from"./commands/remote-env/index.js";import Pm from"./commands/upgrade/index.js";import Lm from"./commands/rate-limit-options/index.js";import Bm from"./commands/statusline.js";import Fm from"./commands/effort/index.js";import $m from"./commands/stats/index.js";import Um from"./commands/oauth-refresh/index.js";import Km from"./commands/debug-tool-call/index.js";import{getSettingSourceName as Wm}from"./utils/settings/constants.js";import{isCommandEnabled as Gm}from"./types/command.js";export{getCommandName,isCommandEnabled}from"./types/command.js";export const INTERNAL_ONLY_COMMANDS=[s,D,io,p,j,b,t,a,_,...jo?[jo]:[],$o,Uo,Ko,...ko?[ko]:[],...ho?[ho]:[],Go,Yo,B,H,Wo,X,Ho,zo,xm,Um,Km,mo,e].filter(Boolean);const Ym=pm(()=>[i,Vo,No,Do,r,l,c,x,g,f,u,S,h,k,C,w,Fm,gm,Mo,Ao,Fo,E,v,R,M,T,A,N,y,P,Tm,L,hm,km,Cm,bm,wm,ym,Dm,Nm,Po,F,Am,$,Lo,U,K,Y,z,$m,q,Bm,Xo,Em,vm,Rm,_m,Mm,Om,Im,so,ro,d,W,G,Bo,no,eo,Pm,Lm,to,...go?[go]:[],...wo?[wo]:[],...yo?[yo]:[],...ao?[ao]:[],...lo?[lo]:[],...co?[co]:[],...po?[po]:[],...fo?[fo]:[],...uo?[uo]:[],Eo,vo,Ro,_o,Io,To,Sm,qo,I,O(),Oo,...bo?[bo]:[],V,J,Q,Z,oo,...xo?[xo]:[],...Co?[Co]:[],..."ant"!==process.env.USER_TYPE||process.env.IS_DEMO?[]:INTERNAL_ONLY_COMMANDS]);export const builtInCommandNames=pm(()=>new Set(Ym().flatMap(o=>[o.name||"",...o.aliases?.filter(Boolean)??[]].map(o=>o.toLowerCase()))));async function withTimeout(o,m,n,i){let e;try{let s=!1;return await Promise.race([n(),new Promise(o=>{e=setTimeout(()=>{s=!0,o(i)},m)})]).finally(()=>{s&&om(`${o} timed out after ${m}ms while loading commands. Continuing with fallback.`)})}catch(m){return om(`${o} failed while loading commands: ${m instanceof Error?m.message:String(m)}`),i}finally{e&&clearTimeout(e)}}async function getSkills(o){try{if(lm())return await cm(o);const[m,n]=await Promise.all([mm(o).catch(o=>(Jo(Zo(o)),om("Skill directory commands failed to load, continuing without them"),[])),am().catch(o=>(Jo(Zo(o)),om("Plugin skills failed to load, continuing without them"),[]))]),i=em(),e=sm();return om(`getSkills returning: ${m.length} skill dir commands, ${n.length} plugin skills, ${i.length} bundled skills, ${e.length} builtin plugin skills`),{skillDirCommands:m,pluginSkills:n,bundledSkills:i,builtinPluginSkills:e}}catch(o){return Jo(Zo(o)),om("Unexpected error in getSkills, returning empty"),{skillDirCommands:[],pluginSkills:[],bundledSkills:[],builtinPluginSkills:[]}}}const Hm=o("WORKFLOW_SCRIPTS")?n("./tools/WorkflowTool/createWorkflowCommand.js").getWorkflowCommands:null;export function meetsAvailabilityRequirement(o){if(!o.availability)return!0;for(const m of o.availability)switch(m){case"claude-ai":if(um())return!0;break;case"console":if(!um()&&!fm()&&jm())return!0;break;default:break}return!1}const zm=pm(async o=>{const[{skillDirCommands:m,pluginSkills:n,bundledSkills:i,builtinPluginSkills:e},s,r]=await Promise.all([getSkills(o),withTimeout("getPluginCommands",1e4,()=>rm(),[]),withTimeout("getWorkflowCommands",1e4,()=>Hm?Hm(o):Promise.resolve([]),[])]);return[...i,...e,...m,...r,...s,...n,...Ym()]});export async function getCommands(o){const m=await zm(o),n=im(),i=m.filter(o=>meetsAvailabilityRequirement(o)&&Gm(o));if(0===n.length)return i;const e=new Set(i.map(o=>o.name)),s=n.filter(o=>!e.has(o.name)&&meetsAvailabilityRequirement(o)&&Gm(o));if(0===s.length)return preferNativeBridgeCommands(i);const r=new Set(Ym().map(o=>o.name)),t=i.findIndex(o=>r.has(o.name));return preferNativeBridgeCommands(-1===t?[...i,...s]:[...i.slice(0,t),...s,...i.slice(t)])}function preferNativeBridgeCommands(o){const m=new Set(["whatsapp","telegram","canal-global"]),n=new Map;for(const i of o){const o=i.name.toLowerCase();if(!m.has(o)){n.has(o)||n.set(o,i);continue}const e=n.get(o);if(!e){n.set(o,i);continue}const s="local-jsx"===e.type&&void 0===e.source,r="local-jsx"===i.type&&void 0===i.source;!s&&r&&n.set(o,i)}return o.filter(o=>n.get(o.name.toLowerCase())===o)}export function clearCommandMemoizationCaches(){zm.cache?.clear?.(),getSkillToolCommands.cache?.clear?.(),getSlashCommandToolSkills.cache?.clear?.(),So?.()}export function clearCommandsCache(){clearCommandMemoizationCaches(),tm(),dm(),nm()}export function getMcpSkillCommands(m){return o("MCP_SKILLS")?m.filter(o=>"prompt"===o.type&&"mcp"===o.loadedFrom&&!o.disableModelInvocation):[]}export const getSkillToolCommands=pm(async o=>(await getCommands(o)).filter(o=>"prompt"===o.type&&!o.disableModelInvocation&&"builtin"!==o.source&&("bundled"===o.loadedFrom||"skills"===o.loadedFrom||"commands_DEPRECATED"===o.loadedFrom||o.hasUserSpecifiedDescription||o.whenToUse)));export const getSlashCommandToolSkills=pm(async o=>{try{return(await getCommands(o)).filter(o=>"prompt"===o.type&&"builtin"!==o.source&&(o.hasUserSpecifiedDescription||o.whenToUse)&&("skills"===o.loadedFrom||"plugin"===o.loadedFrom||"bundled"===o.loadedFrom||o.disableModelInvocation))}catch(o){return Jo(Zo(o)),om("Returning empty skills array due to load failure"),[]}});export const REMOTE_SAFE_COMMANDS=new Set([Y,gm,l,E,so,c,to,k,f,r,d,_o,M,Bm,Xo,P]);export const BRIDGE_SAFE_COMMANDS=new Set([x,l,k,Wo,$,Ao].filter(o=>null!==o));export function isBridgeSafeCommand(o){return"local-jsx"!==o.type&&("prompt"===o.type||BRIDGE_SAFE_COMMANDS.has(o))}export function filterCommandsForRemoteMode(o){return o.filter(o=>REMOTE_SAFE_COMMANDS.has(o))}export function findCommand(o,m){if(!o)return;const n=o.toLowerCase();return m.find(o=>o?.name?.toLowerCase()===n||o?.aliases?.some(o=>o?.toLowerCase()===n))}export function hasCommand(o,m){return void 0!==findCommand(o,m)}export function getCommand(o,m){if(!o)throw new Error("El nombre del comando no puede estar vacío");const n=findCommand(o,m);if(!n)throw new Qo(`Comando /${o} no encontrado. Usa /help para ver los comandos disponibles.`);return n}export function formatDescriptionWithSource(o){if("prompt"!==o.type)return o.description;if("workflow"===o.kind)return`${o.description} (flujo)`;if("plugin"===o.source){const m=o.pluginInfo?.pluginManifest.name;return m?`(${m}) ${o.description}`:`${o.description} (complemento)`}return"builtin"===o.source||"mcp"===o.source?o.description:"bundled"===o.source?`${o.description} (incluido)`:`${o.description} (${Wm(o.source)})`}
|
|
1
|
+
import{feature as o}from"./recovery/bunBundleShim.js";import{createRequire as m}from"module";const n=m(import.meta.url);import i from"./commands/add-dir/index.js";import e from"./commands/autofix-pr/index.js";import s from"./commands/backfill-sessions/index.js";import r from"./commands/btw/index.js";import t from"./commands/good-claude/index.js";import a from"./commands/issue/index.js";import d from"./commands/feedback/index.js";import l from"./commands/clear/index.js";import c from"./commands/color/index.js";import p from"./commands/commit.js";import f from"./commands/copy/index.js";import u from"./commands/desktop/index.js";import j from"./commands/commit-push-pr.js";import x from"./commands/compact/index.js";import g from"./commands/config/index.js";import{context as S,contextNonInteractive as h}from"./commands/context/index.js";import k from"./commands/cost/index.js";import C from"./commands/diff/index.js";import b from"./commands/ctx_viz/index.js";import w from"./commands/doctor/index.js";import y from"./commands/memory/index.js";import E from"./commands/heartbeat/index.js";import v from"./commands/help/index.js";import R from"./commands/ide/index.js";import _ from"./commands/init.js";import M from"./commands/init-verifiers.js";import O from"./commands/keybindings/index.js";import I from"./commands/login/index.js";import T from"./commands/logout/index.js";import A from"./commands/install-github-app/index.js";import D from"./commands/install-slack-app/index.js";import N from"./commands/break-cache/index.js";import P from"./commands/mcp/index.js";import L from"./commands/mobile/index.js";import B from"./commands/agent/index.js";import F from"./commands/onboarding/index.js";import $ from"./commands/pr_comments/index.js";import U from"./commands/release-notes/index.js";import K from"./commands/rename/index.js";import W from"./commands/resume/index.js";import G,{ultrareview as Y}from"./commands/review.js";import H from"./commands/session/index.js";import z from"./commands/share/index.js";import q from"./commands/skills/index.js";import X from"./commands/status/index.js";import V from"./commands/teleport/index.js";import J from"./commands/telegram/index.js";import Q from"./commands/whatsapp/index.js";import Z from"./commands/canal-global/index.js";import oo from"./commands/playwright/index.js";import mo from"./commands/webapp/index.js";const no="ant"===process.env.USER_TYPE?n("./commands/agents-platform/index.js").default:null;import io from"./commands/security-review.js";import eo from"./commands/bughunter/index.js";import so from"./commands/terminalSetup/index.js";import ro from"./commands/theme/index.js";import to from"./commands/timeline/index.js";import ao from"./commands/vim/index.js";const lo=o("PROACTIVE")||o("KAIROS")?n("./commands/proactive.js").default:null,co=o("KAIROS")||o("KAIROS_BRIEF")?n("./commands/brief.js").default:null,po=o("KAIROS")?n("./commands/assistant/index.js").default:null,fo=o("BRIDGE_MODE")?n("./commands/bridge/index.js").default:null,uo=o("DAEMON")&&o("BRIDGE_MODE")?n("./commands/remoteControlServer/index.js").default:null,jo=n("./commands/voice/index.js").default,xo=o("HISTORY_SNIP")?n("./commands/force-snip.js").default:null,go=o("WORKFLOW_SCRIPTS")?n("./commands/workflows/index.js").default:null,So=o("CCR_REMOTE_SETUP")?n("./commands/remote-setup/index.js").default:null,ho=o("EXPERIMENTAL_SKILL_SEARCH")?n("./services/skillSearch/localSearch.js").clearSkillIndexCache:null,ko=o("KAIROS_GITHUB_WEBHOOKS")?n("./commands/subscribe-pr.js").default:null,Co=o("ULTRAPLAN")?n("./commands/ultraplan.js").default:null,bo=o("TORCH")?n("./commands/torch.js").default:null,wo=o("UDS_INBOX")?n("./commands/peers/index.js").default:null,yo=o("FORK_SUBAGENT")?n("./commands/fork/index.js").default:null,Eo=o("BUDDY")?n("./commands/buddy/index.js").default:null;import vo from"./commands/thinkback/index.js";import Ro from"./commands/thinkback-play/index.js";import _o from"./commands/permissions/index.js";import Mo from"./commands/plan/index.js";import Oo from"./commands/fast/index.js";import Io from"./commands/passes/index.js";import To from"./commands/privacy-settings/index.js";import Ao from"./commands/hooks/index.js";import Do from"./commands/files/index.js";import No from"./commands/branch/index.js";import Po from"./commands/agents/index.js";import Lo from"./commands/plugin/index.js";import Bo from"./commands/reload-plugins/index.js";import Fo from"./commands/rewind/index.js";import $o from"./commands/heapdump/index.js";import Uo from"./commands/mock-limits/index.js";import Ko from"./commands/bridge-kick.js";import Wo from"./commands/version.js";import Go from"./commands/summary/index.js";import{resetLimits as Yo,resetLimitsNonInteractive as Ho}from"./commands/reset-limits/index.js";import zo from"./commands/ant-trace/index.js";import qo from"./commands/perf-issue/index.js";import Xo from"./commands/sandbox-toggle/index.js";import Vo from"./commands/stickers/index.js";import Jo from"./commands/advisor.js";import{logError as Qo}from"./utils/log.js";import{MalformedCommandError as Zo,toError as om}from"./utils/errors.js";import{logForDebugging as mm}from"./utils/debug.js";import{getSkillDirCommands as nm,clearSkillCaches as im,getDynamicSkills as em}from"./skills/loadSkillsDir.js";import{getBundledSkills as sm}from"./skills/bundledSkills.js";import{getBuiltinPluginSkillCommands as rm}from"./plugins/builtinPlugins.js";import{getPluginCommands as tm,clearPluginCommandCache as am,getPluginSkills as dm,clearPluginSkillsCache as lm}from"./utils/plugins/loadPluginCommands.js";import{isCoreSkillsEnabled as cm,loadCoreSkillCommandSources as pm}from"./core/skills/index.js";import fm from"lodash-es/memoize.js";import{isUsing3PServices as um,isClaudeAISubscriber as jm}from"./utils/auth.js";import{isFirstPartyAnthropicBaseUrl as xm}from"./utils/model/providers.js";import gm from"./commands/env/index.js";import Sm from"./commands/exit/index.js";import hm from"./commands/export/index.js";import km from"./commands/model/index.js";import Cm from"./commands/profile/index.js";import bm from"./commands/policy/index.js";import wm from"./commands/run/index.js";import ym from"./commands/workspace/index.js";import Em from"./commands/provider/index.js";import vm from"./commands/tag/index.js";import Rm from"./commands/team-auto/index.js";import _m from"./commands/orchestrate/index.js";import Mm from"./commands/swarm-auto/index.js";import Om from"./commands/swarm-init/index.js";import Im from"./commands/team/index.js";import Tm from"./commands/limites/index.js";import Am from"./commands/objetivo/index.js";import Dm from"./commands/resumen/index.js";import Nm from"./commands/output-style/index.js";import Pm from"./commands/remote-env/index.js";import Lm from"./commands/upgrade/index.js";import Bm from"./commands/rate-limit-options/index.js";import Fm from"./commands/statusline.js";import $m from"./commands/effort/index.js";import Um from"./commands/stats/index.js";import Km from"./commands/oauth-refresh/index.js";import Wm from"./commands/debug-tool-call/index.js";import{getSettingSourceName as Gm}from"./utils/settings/constants.js";import{isCommandEnabled as Ym}from"./types/command.js";export{getCommandName,isCommandEnabled}from"./types/command.js";export const INTERNAL_ONLY_COMMANDS=[s,N,eo,p,j,b,t,a,M,...xo?[xo]:[],Uo,Ko,Wo,...Co?[Co]:[],...ko?[ko]:[],Yo,Ho,F,z,Go,V,zo,qo,gm,Km,Wm,no,e].filter(Boolean);const Hm=fm(()=>[i,Jo,Po,No,r,l,c,x,g,f,u,S,h,k,C,w,$m,Sm,Oo,Do,$o,E,v,R,_,O,A,D,P,y,L,Am,B,km,Cm,bm,wm,ym,Em,Nm,Pm,Lo,$,Dm,U,Bo,K,W,H,q,Um,X,Fm,Vo,vm,Rm,_m,Mm,Om,Im,Tm,ro,to,d,G,Y,Fo,io,so,Lm,Bm,ao,...So?[So]:[],...yo?[yo]:[],...Eo?[Eo]:[],...lo?[lo]:[],...co?[co]:[],...po?[po]:[],...fo?[fo]:[],...uo?[uo]:[],...jo?[jo]:[],vo,Ro,_o,Mo,To,Ao,hm,Xo,T,I(),Io,...wo?[wo]:[],J,Q,Z,oo,mo,...go?[go]:[],...bo?[bo]:[],..."ant"!==process.env.USER_TYPE||process.env.IS_DEMO?[]:INTERNAL_ONLY_COMMANDS]);export const builtInCommandNames=fm(()=>new Set(Hm().flatMap(o=>[o.name||"",...o.aliases?.filter(Boolean)??[]].map(o=>o.toLowerCase()))));async function withTimeout(o,m,n,i){let e;try{let s=!1;return await Promise.race([n(),new Promise(o=>{e=setTimeout(()=>{s=!0,o(i)},m)})]).finally(()=>{s&&mm(`${o} timed out after ${m}ms while loading commands. Continuing with fallback.`)})}catch(m){return mm(`${o} failed while loading commands: ${m instanceof Error?m.message:String(m)}`),i}finally{e&&clearTimeout(e)}}async function getSkills(o){try{if(cm())return await pm(o);const[m,n]=await Promise.all([nm(o).catch(o=>(Qo(om(o)),mm("Skill directory commands failed to load, continuing without them"),[])),dm().catch(o=>(Qo(om(o)),mm("Plugin skills failed to load, continuing without them"),[]))]),i=sm(),e=rm();return mm(`getSkills returning: ${m.length} skill dir commands, ${n.length} plugin skills, ${i.length} bundled skills, ${e.length} builtin plugin skills`),{skillDirCommands:m,pluginSkills:n,bundledSkills:i,builtinPluginSkills:e}}catch(o){return Qo(om(o)),mm("Unexpected error in getSkills, returning empty"),{skillDirCommands:[],pluginSkills:[],bundledSkills:[],builtinPluginSkills:[]}}}const zm=o("WORKFLOW_SCRIPTS")?n("./tools/WorkflowTool/createWorkflowCommand.js").getWorkflowCommands:null;export function meetsAvailabilityRequirement(o){if(!o.availability)return!0;for(const m of o.availability)switch(m){case"claude-ai":if(jm())return!0;break;case"console":if(!jm()&&!um()&&xm())return!0;break;default:break}return!1}const qm=fm(async o=>{const[{skillDirCommands:m,pluginSkills:n,bundledSkills:i,builtinPluginSkills:e},s,r]=await Promise.all([getSkills(o),withTimeout("getPluginCommands",1e4,()=>tm(),[]),withTimeout("getWorkflowCommands",1e4,()=>zm?zm(o):Promise.resolve([]),[])]);return[...i,...e,...m,...r,...s,...n,...Hm()]});export async function getCommands(o){const m=await qm(o),n=em(),i=m.filter(o=>meetsAvailabilityRequirement(o)&&Ym(o));if(0===n.length)return i;const e=new Set(i.map(o=>o.name)),s=n.filter(o=>!e.has(o.name)&&meetsAvailabilityRequirement(o)&&Ym(o));if(0===s.length)return preferNativeBridgeCommands(i);const r=new Set(Hm().map(o=>o.name)),t=i.findIndex(o=>r.has(o.name));return preferNativeBridgeCommands(-1===t?[...i,...s]:[...i.slice(0,t),...s,...i.slice(t)])}function preferNativeBridgeCommands(o){const m=new Set(["whatsapp","telegram","canal-global"]),n=new Map;for(const i of o){const o=i.name.toLowerCase();if(!m.has(o)){n.has(o)||n.set(o,i);continue}const e=n.get(o);if(!e){n.set(o,i);continue}const s="local-jsx"===e.type&&void 0===e.source,r="local-jsx"===i.type&&void 0===i.source;!s&&r&&n.set(o,i)}return o.filter(o=>n.get(o.name.toLowerCase())===o)}export function clearCommandMemoizationCaches(){qm.cache?.clear?.(),getSkillToolCommands.cache?.clear?.(),getSlashCommandToolSkills.cache?.clear?.(),ho?.()}export function clearCommandsCache(){clearCommandMemoizationCaches(),am(),lm(),im()}export function getMcpSkillCommands(m){return o("MCP_SKILLS")?m.filter(o=>"prompt"===o.type&&"mcp"===o.loadedFrom&&!o.disableModelInvocation):[]}export const getSkillToolCommands=fm(async o=>(await getCommands(o)).filter(o=>"prompt"===o.type&&!o.disableModelInvocation&&"builtin"!==o.source&&("bundled"===o.loadedFrom||"skills"===o.loadedFrom||"commands_DEPRECATED"===o.loadedFrom||o.hasUserSpecifiedDescription||o.whenToUse)));export const getSlashCommandToolSkills=fm(async o=>{try{return(await getCommands(o)).filter(o=>"prompt"===o.type&&"builtin"!==o.source&&(o.hasUserSpecifiedDescription||o.whenToUse)&&("skills"===o.loadedFrom||"plugin"===o.loadedFrom||"bundled"===o.loadedFrom||o.disableModelInvocation))}catch(o){return Qo(om(o)),mm("Returning empty skills array due to load failure"),[]}});export const REMOTE_SAFE_COMMANDS=new Set([H,Sm,l,v,ro,c,ao,k,f,r,d,Mo,O,Fm,Vo,L]);export const BRIDGE_SAFE_COMMANDS=new Set([x,l,k,Go,U,Do].filter(o=>null!==o));export function isBridgeSafeCommand(o){return"local-jsx"!==o.type&&("prompt"===o.type||BRIDGE_SAFE_COMMANDS.has(o))}export function filterCommandsForRemoteMode(o){return o.filter(o=>REMOTE_SAFE_COMMANDS.has(o))}export function findCommand(o,m){if(!o)return;const n=o.toLowerCase();return m.find(o=>o?.name?.toLowerCase()===n||o?.aliases?.some(o=>o?.toLowerCase()===n))}export function hasCommand(o,m){return void 0!==findCommand(o,m)}export function getCommand(o,m){if(!o)throw new Error("El nombre del comando no puede estar vacío");const n=findCommand(o,m);if(!n)throw new Zo(`Comando /${o} no encontrado. Usa /help para ver los comandos disponibles.`);return n}export function formatDescriptionWithSource(o){if("prompt"!==o.type)return o.description;if("workflow"===o.kind)return`${o.description} (flujo)`;if("plugin"===o.source){const m=o.pluginInfo?.pluginManifest.name;return m?`(${m}) ${o.description}`:`${o.description} (complemento)`}return"builtin"===o.source||"mcp"===o.source?o.description:"bundled"===o.source?`${o.description} (incluido)`:`${o.description} (${Gm(o.source)})`}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as s}from"react/compiler-runtime";import{Text as n}from"../ink.js";import{saveGlobalConfig as t}from"../utils/config.js";import{Select as c}from"./CustomSelect/index.js";import{Dialog as r}from"./design-system/Dialog.js";export function ApproveApiKey(i){const m=s(17),{customApiKeyTruncated:l,onDone:a}=i;let p;m[0]!==l||m[1]!==a?(p=function(e){e:switch(e){case"yes":t(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,approved:[...e.customApiKeyResponses?.approved??[],l]}})),a(!0);break e;case"no":t(e=>({...e,customApiKeyResponses:{...e.customApiKeyResponses,rejected:[...e.customApiKeyResponses?.rejected??[],l]}})),a(!1)}},m[0]=l,m[1]=a,m[2]=p):p=m[2];const u=p;let d,y,f,h,A,_,b,j;return m[3]!==u?(d=()=>u("no"),m[3]=u,m[4]=d):d=m[4],m[5]===Symbol.for("react.memo_cache_sentinel")?(y=e(n,{bold:!0,children:"ANTHROPIC_API_KEY"}),m[5]=y):y=m[5],m[6]!==l?(f=o(n,{children:[y,o(n,{children:[": sk-ant-...",l]})]}),m[6]=l,m[7]=f):f=m[7],m[8]===Symbol.for("react.memo_cache_sentinel")?(h=e(n,{children:"¿Quieres usar esta API key?"}),m[8]=h):h=m[8],m[9]===Symbol.for("react.memo_cache_sentinel")?(A={label:"Yes",value:"yes"},m[9]=A):A=m[9],m[10]===Symbol.for("react.memo_cache_sentinel")?(_=[A,{label:o(n,{children:["No (",e(n,{bold:!0,children:"recommended"}),")"]}),value:"no"}],m[10]=_):_=m[10],m[11]!==u?(b=e(c,{defaultValue:"no",defaultFocusValue:"no",options:_,onChange:e=>u(e),onCancel:()=>u("no")}),m[11]=u,m[12]=b):b=m[12],m[13]!==d||m[14]!==f||m[15]!==b?(j=o(r,{title:"Detected a custom API key in your environment",color:"warning",onCancel:d,children:[f,h,b]}),m[13]=d,m[14]=f,m[15]=b,m[16]=j):j=m[16],j}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as n}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{Text as a}from"../ink.js";import{Select as o}from"./CustomSelect/index.js";import{Dialog as r}from"./design-system/Dialog.js";export function ChannelDowngradeDialog(i){const l=t(17),{currentVersion:s,onChoice:c}=i;let m;l[0]!==c?(m=function(e){c(e)},l[0]=c,l[1]=m):m=l[1];const u=m;let d;l[2]!==c?(d=function(){c("cancel")},l[2]=c,l[3]=d):d=l[3];const h=d;let p,f,g;l[4]!==s?(p=e(a,{children:["El canal estable puede tener una versión más antigua que la que estás ejecutando actualmente (",s,")."]}),l[4]=s,l[5]=p):p=l[5],l[6]===Symbol.for("react.memo_cache_sentinel")?(f=n(a,{dimColor:!0,children:"¿Cómo te gustaría manejarlo?"}),l[6]=f):f=l[6],l[7]===Symbol.for("react.memo_cache_sentinel")?(g={label:"Permitir posible degradación a versión estable",value:"downgrade"},l[7]=g):g=l[7];const b=`Mantener versión actual (${s}) hasta que estable se ponga al día`;let j,C,v;return l[8]!==b?(j=[g,{label:b,value:"stay"}],l[8]=b,l[9]=j):j=l[9],l[10]!==u||l[11]!==j?(C=n(o,{options:j,onChange:u}),l[10]=u,l[11]=j,l[12]=C):C=l[12],l[13]!==h||l[14]!==p||l[15]!==C?(v=e(r,{title:"Switch to Stable Channel",onCancel:h,color:"permission",hideBorder:!0,hideInputGuide:!0,children:[p,f,C]}),l[13]=h,l[14]=p,l[15]=C,l[16]=v):v=l[16],v}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as i from"react";import{Box as l,Text as o}from"../../ink.js";import{Select as r}from"../CustomSelect/select.js";import{PermissionDialog as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as i from"react";import{Box as l,Text as o}from"../../ink.js";import{Select as r}from"../CustomSelect/select.js";import{PermissionDialog as s}from"../permissions/PermissionDialog.js";export function PluginHintMenu({pluginName:a,pluginDescription:t,marketplaceName:c,sourceCommand:d,onResponse:m}){const u=i.useRef(m);u.current=m,i.useEffect(()=>{const e=setTimeout(e=>e.current("no"),3e4,u);return()=>clearTimeout(e)},[]);const h=[{label:n(o,{children:["Yes, install ",e(o,{bold:!0,children:a})]}),value:"yes"},{label:"No",value:"no"},{label:"No, and don't show plugin installation hints again",value:"disable"}];return e(s,{title:"Plugin Recommendation",children:n(l,{flexDirection:"column",paddingX:2,paddingY:1,children:[e(l,{marginBottom:1,children:n(o,{dimColor:!0,children:["The ",e(o,{bold:!0,children:d})," command suggests installing a plugin."]})}),n(l,{children:[e(o,{dimColor:!0,children:"Plugin:"}),n(o,{children:[" ",a]})]}),n(l,{children:[e(o,{dimColor:!0,children:"Marketplace:"}),n(o,{children:[" ",c]})]}),t&&e(l,{children:e(o,{dimColor:!0,children:t})}),e(l,{marginTop:1,children:e(o,{children:"¿Quieres instalarlo?"})}),e(l,{children:e(r,{options:h,onChange:function(e){switch(e){case"yes":m("yes");break;case"disable":m("disable");break;default:m("no")}},onCancel:()=>m("no")})})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useCallback as i,useEffect as n,useRef as a,useState as s}from"react";import{logEvent as l}from"../services/analytics/index.js";import{installOAuthTokens as c}from"../cli/handlers/auth.js";import{useTerminalSize as d}from"../hooks/useTerminalSize.js";import{setClipboard as u}from"../ink/termio/osc.js";import{useTerminalNotification as m}from"../ink/useTerminalNotification.js";import{Box as p,Link as h,Text as g}from"../ink.js";import{useKeybinding as f}from"../keybindings/useKeybinding.js";import{getSSLErrorHint as _}from"../services/api/errorUtils.js";import{sendNotification as v}from"../services/notifier.js";import{OAuthService as y}from"../services/oauth/index.js";import{getOAuthRequestDetails as C}from"../services/oauth/client.js";import{checkGeminiGoogleCredentialsValid as A,getOauthAccountInfo as b,saveGeminiGoogleOAuthTokens as x,saveProviderApiKey as k,validateForceLoginOrg as O}from"../utils/auth.js";import{startGeminiCliOAuthFlow as P}from"../services/oauth/geminiCli.js";import{resolveProviderProfile as I}from"../utils/model/providerProfiles.js";import{logError as S}from"../utils/log.js";import{getVisibleProvider as D}from"../utils/model/providerCatalog.js";import{getConfiguredProviderBaseUrl as T,setProviderBaseUrl as w}from"../utils/model/providerBaseUrls.js";import{getSettings_DEPRECATED as j}from"../utils/settings/settings.js";import{Select as M}from"./CustomSelect/select.js";import{KeyboardShortcutHint as U}from"./design-system/KeyboardShortcutHint.js";import{Spinner as R}from"./Spinner.js";import G from"./TextInput.js";const E=["deepseek","minimax","openrouter","zai","nvidia","ollama","openai","claudeai","gemini-google","gemini-api","console"];function sortLoginProviderOptions(e){const o=new Map(E.map((e,o)=>[e,o]));return[...e].sort((e,r)=>(o.get(e.value)??Number.MAX_SAFE_INTEGER)-(o.get(r.value)??Number.MAX_SAFE_INTEGER))}const B="Pega aqui el codigo si se solicita > ";function formatOAuthDebugDetails(e,o){if("openai"!==e)return"";const r=C({provider:e,port:o,isManual:!1});return[`authorize=${r.authorizeUrl}`,`redirect_uri=${r.redirectUri}`,`scope=${r.scopes.join(" ")}`].join("\n")}export function ConsoleOAuthFlow({onDone:r,startingMessage:t,mode:C="login",forceLoginMethod:b,profileName:T}){const M=j()||{},R=b??M.forceLoginMethod,G=M.forceLoginOrgUUID,E="claudeai"===R?"Método de acceso preseleccionado: Plan de suscripción (Claude Pro/Max)":"console"===R?"Método de acceso preseleccionado: Facturación por uso de API (Anthropic Console)":"openai"===R?"Método de acceso preseleccionado: OpenAI / Codex OAuth":null,B=m(),[L,z]=s(()=>"setup-token"===C||"claudeai"===R||"console"===R||"openai"===R?{state:"ready_to_start"}:{state:"idle"}),[K,N]=s(""),[F,$]=s(0),[W]=s(()=>new y),[V,X]=s(()=>"openai"===R?"openai":"anthropic"),[Y,q]=s(()=>"setup-token"===C||"claudeai"===R),[H,Z]=s(!1),[J,Q]=s(!1),ee=d().columns-37-1,[oe,re]=s(""),[te,ie]=s(0),[ne,ae]=s(""),[se,le]=s(0);n(()=>{"claudeai"===R?l("tengu_oauth_claudeai_forced",{}):"console"===R&&l("tengu_oauth_console_forced",{})},[R]),n(()=>{if("about_to_retry"===L.state){const e=setTimeout(z,1e3,L.nextState);return()=>clearTimeout(e)}},[L]),f("confirm:yes",()=>{l("tengu_oauth_success",{loginWithClaudeAi:Y}),r(V)},{context:"Confirmation",isActive:"success"===L.state&&"setup-token"!==C}),n(()=>{if("success"===L.state&&!process.stdin.isTTY){const e=setTimeout(()=>{l("tengu_oauth_success",{loginWithClaudeAi:Y}),r(V)},800);return()=>clearTimeout(e)}},[L.state,V,Y,r]),f("confirm:yes",()=>{z({state:"idle"})},{context:"Confirmation",isActive:"platform_setup"===L.state}),f("confirm:yes",()=>{ue()},{context:"Confirmation",isActive:"provider_google_setup"===L.state}),f("confirm:yes",()=>{"error"===L.state&&L.toRetry&&(N(""),z({state:"about_to_retry",nextState:L.toRetry}))},{context:"Confirmation",isActive:"error"===L.state&&!!L.toRetry}),f("cancel",()=>{z({state:"idle"})},{context:"Confirmation",isActive:"provider_api_key_input"===L.state||"provider_local_setup"===L.state||"provider_google_setup"===L.state||"error"===L.state}),n(()=>{"c"===K&&"waiting_for_login"===L.state&&H&&!J&&(u(L.url).then(e=>{e&&process.stdout.write(e),Q(!0),setTimeout(Q,2e3,!1)}),N(""))},[K,L,H,J]);const ce=i(async(e,o)=>{const t=e.trim();if(t)try{await k(o,t),re(""),ie(0);const e=D(o).label;v({message:`API key de ${e} guardada`,notificationType:"auth_success"},B),r(o)}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_api_key_input",provider:o}})}else z({state:"error",message:"Debes ingresar una API key.",toRetry:{state:"provider_api_key_input",provider:o}})},[r,B]),de=i((e,o)=>{const t=e.trim();if(t)try{const e=w(o,t);ae(e),le(0),v({message:`URL de ${D(o).label} guardada`,notificationType:"auth_success"},B),r(o)}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_local_setup",provider:o}})}else z({state:"error",message:"Debes ingresar una URL para Ollama.",toRetry:{state:"provider_local_setup",provider:o}})},[r,B]),ue=i(async()=>{z({state:"provider_google_auth_running"});try{if(await A())return void r("gemini-google");const e=await P();x(e);if(!await A())return v({message:"OAuth de Gemini guardado; Code Assist no valido el proyecto de cuota",notificationType:"auth_success"},B),void r("gemini-google");v({message:"Credenciales de Gemini Google listas",notificationType:"auth_success"},B),r("gemini-google")}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_google_setup"}})}},[r,B]),me=i(async()=>{try{l("tengu_oauth_flow_start",{loginWithClaudeAi:Y,provider:V});const e=await W.startOAuthFlow(async e=>{z({state:"waiting_for_login",url:e}),setTimeout(Z,3e3,!0)},{loginWithClaudeAi:Y,provider:V,inferenceOnly:"setup-token"===C,expiresIn:"setup-token"===C?31536e3:void 0,orgUUID:G}).catch(e=>{const o=e.message.includes("Token exchange failed"),r=_(e),t=W.getPort(),i="openai"===V&&t?formatOAuthDebugDetails(V,t):"";throw z({state:"error",message:r??(o?"No se pudo intercambiar el codigo de autorizacion por el token de acceso. Intentalo de nuevo."+(i?`\n${i}`:""):e.message),toRetry:"setup-token"===C?{state:"ready_to_start"}:{state:"idle"}}),l("tengu_oauth_token_exchange_error",{error:e.message,ssl_error:null!==r}),e});if("setup-token"===C)z({state:"success",token:e.accessToken});else{z({state:"creating_api_key"});const o=T?I("openai"===V?"openai":"anthropic",T):void 0;if(await c(e,V,o?.id),"anthropic"===V){const e=await O();if(!e.valid)throw new Error(e.message)}z({state:"success"}),v({message:"openai"===V?"Inicio de sesión con OpenAI / Codex completado":"Inicio de sesión en Context Code completado",notificationType:"auth_success"},B)}}catch(e){const o=e.message,r=_(e),t=W.getPort(),i="openai"===V&&t?formatOAuthDebugDetails(V,t):"";z({state:"error",message:r??("openai"===V&&i&&!o.includes("redirect_uri=")?`${o}\n${i}`:o),toRetry:{state:"setup-token"===C?"ready_to_start":"idle"}}),l("tengu_oauth_error",{error:o,ssl_error:null!==r})}},[V,W,Z,Y,C,G,B]),pe=a(!1);return n(()=>{"ready_to_start"!==L.state||pe.current||(pe.current=!0,process.nextTick((e,o)=>{e(),o.current=!1},me,pe))},[L.state,me]),n(()=>{if("setup-token"===C&&"success"===L.state){const e=setTimeout((e,o)=>{l("tengu_oauth_success",{loginWithClaudeAi:e}),o(V)},500,Y,r,V);return()=>clearTimeout(e)}},[C,L,Y,r,V]),n(()=>()=>{W.cleanup()},[W]),e(p,{flexDirection:"column",gap:1,children:["waiting_for_login"===L.state&&H&&e(p,{flexDirection:"column",gap:1,paddingBottom:1,children:[e(p,{paddingX:1,children:[e(g,{dimColor:!0,children:["Browser didn't open? Use the url below to sign in"," "]}),o(g,J?{color:"success",children:"(Copied!)"}:{dimColor:!0,children:o(U,{shortcut:"c",action:"copiar",parens:!0})})]}),o(h,{url:L.url,children:o(g,{dimColor:!0,children:L.url})})]},"urlToCopy"),"setup-token"===C&&"success"===L.state&&L.token&&e(p,{flexDirection:"column",gap:1,paddingTop:1,children:[o(g,{color:"success",children:"✓ Long-lived authentication token created successfully!"}),e(p,{flexDirection:"column",gap:1,children:[o(g,{children:"Your OAuth token (valid for 1 year):"}),o(g,{color:"warning",children:L.token}),o(g,{dimColor:!0,children:"Store this token securely. You won't be able to see it again."}),o(g,{dimColor:!0,children:"Use this token by setting: export CONTEXT_CODE_OAUTH_TOKEN=<token>"})]})]},"tokenOutput"),o(p,{paddingLeft:1,flexDirection:"column",gap:1,children:o(OAuthStatusMessage,{oauthStatus:L,oauthProvider:V,mode:C,startingMessage:t,forcedMethodMessage:E,showPastePrompt:H,pastedCode:K,setPastedCode:N,cursorOffset:F,setCursorOffset:$,textInputColumns:ee,handleSubmitCode:async function(e,o){try{const[r,t]=e.split("#");if(!r||!t)return void z({state:"error",message:"Codigo invalido. Asegurate de copiar el codigo completo",toRetry:{state:"waiting_for_login",url:o}});l("tengu_oauth_manual_entry",{}),W.handleManualAuthCodeInput({authorizationCode:r,state:t})}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"waiting_for_login",url:o}})}},setOAuthStatus:z,setLoginWithClaudeAi:q,setOAuthProvider:X,providerApiKey:oe,setProviderApiKey:re,providerApiKeyCursorOffset:te,setProviderApiKeyCursorOffset:ie,handleProviderApiKeySubmit:ce,providerBaseUrl:ne,setProviderBaseUrlInput:ae,providerBaseUrlCursorOffset:se,setProviderBaseUrlCursorOffset:le,handleProviderBaseUrlSubmit:de,onDone:r})})]})}function OAuthStatusMessage(i){const n=t(68),{oauthStatus:a,oauthProvider:s,mode:c,startingMessage:d,forcedMethodMessage:u,showPastePrompt:m,pastedCode:f,setPastedCode:_,cursorOffset:v,setCursorOffset:y,textInputColumns:C,handleSubmitCode:A,setOAuthStatus:x,setLoginWithClaudeAi:k,setOAuthProvider:O,providerApiKey:P,setProviderApiKey:I,providerApiKeyCursorOffset:S,setProviderApiKeyCursorOffset:w,handleProviderApiKeySubmit:j,providerBaseUrl:U,setProviderBaseUrlInput:E,providerBaseUrlCursorOffset:L,setProviderBaseUrlCursorOffset:z,handleProviderBaseUrlSubmit:K,onDone:N}=i;switch(a.state){case"idle":{const r=d||"Context Code puede usarse con tu suscripción de Claude, la facturación de Anthropic Console o OpenAI / Codex OAuth.";let t,i,a,s,c,u,m;return n[0]!==r?(t=o(g,{bold:!0,children:r}),n[0]=r,n[1]=t):t=n[1],n[2]===Symbol.for("react.memo_cache_sentinel")?(i=o(g,{children:"Selecciona el metodo de acceso:"}),n[2]=i):i=n[2],n[3]===Symbol.for("react.memo_cache_sentinel")?(a={label:e(g,{children:["Claude account with subscription ·"," ",o(g,{dimColor:!0,children:"Pro, Max, Team, or Enterprise"}),!1,"\n"]}),value:"claudeai"},n[3]=a):a=n[3],n[4]===Symbol.for("react.memo_cache_sentinel")?(s={label:e(g,{children:["Anthropic Console account ·"," ",o(g,{dimColor:!0,children:"API usage billing"}),"\n"]}),value:"console"},n[4]=s):s=n[4],n[5]===Symbol.for("react.memo_cache_sentinel")?(c=[a,s,{label:e(g,{children:["Cuenta de OpenAI / Codex ·"," ",o(g,{dimColor:!0,children:"Login OAuth"}),"\n"]}),value:"openai"},{label:e(g,{children:["OpenRouter ·"," ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"openrouter"},{label:e(g,{children:["Ollama ·"," ",o(g,{dimColor:!0,children:"Servidor local compatible"}),"\n"]}),value:"ollama"},{label:e(g,{children:["Gemini API - ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"gemini-api"},{label:e(g,{children:["Gemini Google - ",o(g,{dimColor:!0,children:"OAuth/ADC de Google"}),"\n"]}),value:"gemini-google"},{label:e(g,{children:["Z.AI ·"," ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"zai"},{label:e(g,{children:["MiniMax ·"," ",o(g,{dimColor:!0,children:"API key / Anthropic-compatible"}),"\n"]}),value:"minimax"},{label:e(g,{children:["NVIDIA API ·"," ",o(g,{dimColor:!0,children:"API key / build.nvidia.com"}),"\n"]}),value:"nvidia"},{label:e(g,{children:["DeepSeek ·"," ",o(g,{dimColor:!0,children:"API key / contexto 1M (V4)"}),"\n"]}),value:"deepseek"}],n[5]=c):c=n[5],n[6]!==k||n[7]!==x||n[8]!==O||n[65]!==N?(u=o(p,{children:o(M,{options:sortLoginProviderOptions(c),onChange:e=>{"platform"===e?(l("tengu_oauth_platform_selected",{}),x({state:"platform_setup"})):"openai"===e?(l("tengu_oauth_openai_selected",{}),O("openai"),k(!1),x({state:"ready_to_start"})):"openrouter"===e?x({state:"provider_api_key_input",provider:"openrouter"}):"gemini-api"===e||"zai"===e||"minimax"===e||"nvidia"===e||"deepseek"===e?x({state:"provider_api_key_input",provider:e}):"gemini-google"===e?x({state:"provider_google_setup"}):"ollama"===e||"ollama-cloud"===e?(E(T(e)),z(0),x({state:"provider_local_setup",provider:e})):(O("anthropic"),x({state:"ready_to_start"}),"claudeai"===e?(l("tengu_oauth_claudeai_selected",{}),k(!0)):(l("tengu_oauth_console_selected",{}),k(!1)))}})}),n[6]=k,n[7]=x,n[8]=O,n[65]=N,n[66]=u):u=n[66],n[10]!==t||n[11]!==u?(m=e(p,{flexDirection:"column",gap:1,marginTop:1,children:[t,i,u]}),n[10]=t,n[11]=u,n[12]=m):m=n[12],m}case"provider_api_key_input":{let r,t,i,s;if(n[50]!==a.provider?(r=e(g,{bold:!0,children:["Ingresa la API key de ",D(a.provider).label]}),n[50]=a.provider,n[51]=r):r=n[51],n[52]!==a.provider){const r=D(a.provider);t=e(p,{flexDirection:"column",gap:0,children:[o(g,{dimColor:!0,children:r.description}),e(g,{dimColor:!0,children:["Siguiente paso: ",r.setup.nextStep]})]}),n[52]=a.provider,n[53]=t}else t=n[53];return n[54]!==P||n[55]!==S||n[56]!==I||n[57]!==w||n[58]!==C||n[59]!==j?(i=e(p,{children:[o(g,{children:"API key > "}),o(G,{value:P,onChange:I,onSubmit:e=>j(e,a.provider),cursorOffset:S,onChangeCursorOffset:w,columns:C,mask:"*"})]}),n[54]=P,n[55]=S,n[56]=I,n[57]=w,n[58]=C,n[59]=j,n[60]=i):i=n[60],n[61]!==r||n[62]!==t||n[63]!==i?(s=e(p,{flexDirection:"column",gap:1,children:[r,t,i]}),n[61]=r,n[62]=t,n[63]=i,n[64]=s):s=n[64],s}case"provider_local_setup":{const r=D(a.provider);return e(p,{flexDirection:"column",gap:1,children:[o(g,{bold:!0,children:r.label}),o(g,{dimColor:!0,children:r.setup.intro}),o(g,{dimColor:!0,children:r.setup.nextStep}),o(g,{children:"URL del servidor > "}),o(p,{children:o(G,{value:U,onChange:E,onSubmit:e=>K(e,a.provider),cursorOffset:L,onChangeCursorOffset:z,columns:C})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la URL y continuar."]})]})}case"provider_google_setup":return e(p,{flexDirection:"column",gap:1,children:[o(g,{bold:!0,children:"Gemini Google OAuth"}),o(g,{dimColor:!0,children:"Context Code usara el flujo OAuth compatible con Gemini CLI y abrira Google en el navegador."}),o(g,{dimColor:!0,children:"Se guardara el access token y refresh token en el perfil activo de Gemini Google."}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para iniciar sesion con tu cuenta de Google."]})]});case"provider_google_auth_running":return e(p,{children:[o(R,{}),o(g,{children:"Abriendo Google OAuth para Gemini..."})]});case"platform_setup":{let r,t,i,a,s,l,c,d;return n[12]===Symbol.for("react.memo_cache_sentinel")?(r=o(g,{bold:!0,children:"Usando plataformas de terceros"}),n[12]=r):r=n[12],n[13]===Symbol.for("react.memo_cache_sentinel")?(t=o(g,{children:"Context Code soporta Amazon Bedrock, Microsoft Foundry y Vertex AI. Configura las variables de entorno requeridas y luego reinicia Context Code."}),i=o(g,{children:"Si formas parte de una organización empresarial, contacta a tu administrador para las instrucciones de configuración."}),n[13]=t,n[14]=i):(t=n[13],i=n[14]),n[15]===Symbol.for("react.memo_cache_sentinel")?(a=o(g,{bold:!0,children:"Documentation:"}),n[15]=a):a=n[15],n[16]===Symbol.for("react.memo_cache_sentinel")?(s=e(g,{children:["· Amazon Bedrock:"," ",o(h,{url:"https://context.iaforged.com/docs/en/amazon-bedrock",children:"https://context.iaforged.com/docs/en/amazon-bedrock"})]}),n[16]=s):s=n[16],n[17]===Symbol.for("react.memo_cache_sentinel")?(l=e(g,{children:["· Microsoft Foundry:"," ",o(h,{url:"https://context.iaforged.com/docs/en/microsoft-foundry",children:"https://context.iaforged.com/docs/en/microsoft-foundry"})]}),n[17]=l):l=n[17],n[18]===Symbol.for("react.memo_cache_sentinel")?(c=e(p,{flexDirection:"column",marginTop:1,children:[a,s,l,e(g,{children:["· Vertex AI:"," ",o(h,{url:"https://context.iaforged.com/docs/en/google-vertex-ai",children:"https://context.iaforged.com/docs/en/google-vertex-ai"})]})]}),n[18]=c):c=n[18],n[19]===Symbol.for("react.memo_cache_sentinel")?(d=e(p,{flexDirection:"column",gap:1,marginTop:1,children:[r,e(p,{flexDirection:"column",gap:1,children:[t,i,c,o(p,{marginTop:1,children:e(g,{dimColor:!0,children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para volver a las opciones de acceso."]})})]})]}),n[19]=d):d=n[19],d}case"waiting_for_login":{let r,t,i,s;return n[20]!==u?(r=u&&o(p,{children:o(g,{dimColor:!0,children:u})}),n[20]=u,n[21]=r):r=n[21],n[22]!==m?(t=!m&&e(p,{children:[o(R,{}),o(g,{children:"Abriendo el navegador para iniciar sesión…"})]}),n[22]=m,n[23]=t):t=n[23],n[24]!==v||n[25]!==A||n[26]!==a.url||n[27]!==f||n[28]!==y||n[29]!==_||n[30]!==m||n[31]!==C?(i=m&&e(p,{children:[o(g,{children:B}),o(G,{value:f,onChange:_,onSubmit:e=>A(e,a.url),cursorOffset:v,onChangeCursorOffset:y,columns:C,mask:"*"})]}),n[24]=v,n[25]=A,n[26]=a.url,n[27]=f,n[28]=y,n[29]=_,n[30]=m,n[31]=C,n[32]=i):i=n[32],n[33]!==r||n[34]!==t||n[35]!==i?(s=e(p,{flexDirection:"column",gap:1,children:[r,t,i]}),n[33]=r,n[34]=t,n[35]=i,n[36]=s):s=n[36],s}case"creating_api_key":{let r;return n[37]===Symbol.for("react.memo_cache_sentinel")?(r=o(p,{flexDirection:"column",gap:1,children:e(p,{children:[o(R,{}),o(g,{children:"Creando API key para Context Code…"})]})}),n[37]=r):r=n[37],r}case"about_to_retry":{let e;return n[38]===Symbol.for("react.memo_cache_sentinel")?(e=o(p,{flexDirection:"column",gap:1,children:o(g,{color:"permission",children:"Reintentando…"})}),n[38]=e):e=n[38],e}case"success":{let t,i;if(n[39]!==c||n[40]!==a.token){const i="openai"===s?"Inicio de sesión en OpenAI / Codex exitoso. Presiona ":"Inicio de sesión exitoso. Presiona ";t="setup-token"===c&&a.token?null:e(r,{children:[b()?.emailAddress?e(g,{dimColor:!0,children:["Sesión iniciada como"," ",o(g,{children:b()?.emailAddress})]}):null,e(g,{color:"success",children:[i,o(g,{bold:!0,children:"Enter"})," para continuar…"]})]}),n[39]=c,n[40]=a.token,n[41]=t}else t=n[41];return n[42]!==t?(i=o(p,{flexDirection:"column",children:t}),n[42]=t,n[43]=i):i=n[43],i}case"error":{let r,t,i;return n[44]!==a.message?(r=e(g,{color:"error",children:["OAuth error: ",a.message]}),n[44]=a.message,n[45]=r):r=n[45],n[46]!==a.toRetry?(t=a.toRetry&&o(p,{marginTop:1,children:e(g,{color:"permission",children:["Press ",o(g,{bold:!0,children:"Enter"})," to retry."]})}),n[46]=a.toRetry,n[47]=t):t=n[47],n[48]!==r||n[49]!==t?(i=e(p,{flexDirection:"column",gap:1,children:[r,t]}),n[48]=r,n[49]=t,n[50]=i):i=n[50],i}default:return null}}
|
|
1
|
+
import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useCallback as i,useEffect as n,useRef as a,useState as s}from"react";import{logEvent as l}from"../services/analytics/index.js";import{installOAuthTokens as c}from"../cli/handlers/auth.js";import{useTerminalSize as d}from"../hooks/useTerminalSize.js";import{setClipboard as u}from"../ink/termio/osc.js";import{useTerminalNotification as m}from"../ink/useTerminalNotification.js";import{Box as p,Link as h,Text as g}from"../ink.js";import{useKeybinding as f}from"../keybindings/useKeybinding.js";import{getSSLErrorHint as _}from"../services/api/errorUtils.js";import{sendNotification as v}from"../services/notifier.js";import{OAuthService as y}from"../services/oauth/index.js";import{getOAuthRequestDetails as C}from"../services/oauth/client.js";import{checkGeminiGoogleCredentialsValid as A,getOauthAccountInfo as b,saveGeminiGoogleOAuthTokens as x,saveProviderApiKey as k,validateForceLoginOrg as O}from"../utils/auth.js";import{startGeminiCliOAuthFlow as P}from"../services/oauth/geminiCli.js";import{resolveProviderProfile as I}from"../utils/model/providerProfiles.js";import{logError as S}from"../utils/log.js";import{getVisibleProvider as D}from"../utils/model/providerCatalog.js";import{getConfiguredProviderBaseUrl as T,setProviderBaseUrl as w}from"../utils/model/providerBaseUrls.js";import{getSettings_DEPRECATED as j}from"../utils/settings/settings.js";import{Select as M}from"./CustomSelect/select.js";import{KeyboardShortcutHint as U}from"./design-system/KeyboardShortcutHint.js";import{Spinner as R}from"./Spinner.js";import G from"./TextInput.js";const E=["deepseek","minimax","openrouter","zai","nvidia","ollama","openai","claudeai","gemini-google","gemini-api","console"];function sortLoginProviderOptions(e){const o=new Map(E.map((e,o)=>[e,o]));return[...e].sort((e,r)=>(o.get(e.value)??Number.MAX_SAFE_INTEGER)-(o.get(r.value)??Number.MAX_SAFE_INTEGER))}const B="Pega aqui el codigo si se solicita > ";function formatOAuthDebugDetails(e,o){if("openai"!==e)return"";const r=C({provider:e,port:o,isManual:!1});return[`authorize=${r.authorizeUrl}`,`redirect_uri=${r.redirectUri}`,`scope=${r.scopes.join(" ")}`].join("\n")}export function ConsoleOAuthFlow({onDone:r,startingMessage:t,mode:C="login",forceLoginMethod:b,profileName:T}){const M=j()||{},R=b??M.forceLoginMethod,G=M.forceLoginOrgUUID,E="claudeai"===R?"Método de acceso preseleccionado: Plan de suscripción (Context Pro/Max)":"console"===R?"Método de acceso preseleccionado: Facturación por uso de API (Anthropic Console)":"openai"===R?"Método de acceso preseleccionado: OpenAI / Codex OAuth":null,B=m(),[L,z]=s(()=>"setup-token"===C||"claudeai"===R||"console"===R||"openai"===R?{state:"ready_to_start"}:{state:"idle"}),[K,N]=s(""),[F,$]=s(0),[W]=s(()=>new y),[V,X]=s(()=>"openai"===R?"openai":"anthropic"),[Y,q]=s(()=>"setup-token"===C||"claudeai"===R),[H,Z]=s(!1),[J,Q]=s(!1),ee=d().columns-37-1,[oe,re]=s(""),[te,ie]=s(0),[ne,ae]=s(""),[se,le]=s(0);n(()=>{"claudeai"===R?l("tengu_oauth_claudeai_forced",{}):"console"===R&&l("tengu_oauth_console_forced",{})},[R]),n(()=>{if("about_to_retry"===L.state){const e=setTimeout(z,1e3,L.nextState);return()=>clearTimeout(e)}},[L]),f("confirm:yes",()=>{l("tengu_oauth_success",{loginWithClaudeAi:Y}),r(V)},{context:"Confirmation",isActive:"success"===L.state&&"setup-token"!==C}),n(()=>{if("success"===L.state&&!process.stdin.isTTY){const e=setTimeout(()=>{l("tengu_oauth_success",{loginWithClaudeAi:Y}),r(V)},800);return()=>clearTimeout(e)}},[L.state,V,Y,r]),f("confirm:yes",()=>{z({state:"idle"})},{context:"Confirmation",isActive:"platform_setup"===L.state}),f("confirm:yes",()=>{ue()},{context:"Confirmation",isActive:"provider_google_setup"===L.state}),f("confirm:yes",()=>{"error"===L.state&&L.toRetry&&(N(""),z({state:"about_to_retry",nextState:L.toRetry}))},{context:"Confirmation",isActive:"error"===L.state&&!!L.toRetry}),f("cancel",()=>{z({state:"idle"})},{context:"Confirmation",isActive:"provider_api_key_input"===L.state||"provider_local_setup"===L.state||"provider_google_setup"===L.state||"error"===L.state}),n(()=>{"c"===K&&"waiting_for_login"===L.state&&H&&!J&&(u(L.url).then(e=>{e&&process.stdout.write(e),Q(!0),setTimeout(Q,2e3,!1)}),N(""))},[K,L,H,J]);const ce=i(async(e,o)=>{const t=e.trim();if(t)try{await k(o,t),re(""),ie(0);const e=D(o).label;v({message:`API key de ${e} guardada`,notificationType:"auth_success"},B),r(o)}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_api_key_input",provider:o}})}else z({state:"error",message:"Debes ingresar una API key.",toRetry:{state:"provider_api_key_input",provider:o}})},[r,B]),de=i((e,o)=>{const t=e.trim();if(t)try{const e=w(o,t);ae(e),le(0),v({message:`URL de ${D(o).label} guardada`,notificationType:"auth_success"},B),r(o)}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_local_setup",provider:o}})}else z({state:"error",message:"Debes ingresar una URL para Ollama.",toRetry:{state:"provider_local_setup",provider:o}})},[r,B]),ue=i(async()=>{z({state:"provider_google_auth_running"});try{if(await A())return void r("gemini-google");const e=await P();x(e);if(!await A())return v({message:"OAuth de Gemini guardado; Code Assist no valido el proyecto de cuota",notificationType:"auth_success"},B),void r("gemini-google");v({message:"Credenciales de Gemini Google listas",notificationType:"auth_success"},B),r("gemini-google")}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"provider_google_setup"}})}},[r,B]),me=i(async()=>{try{l("tengu_oauth_flow_start",{loginWithClaudeAi:Y,provider:V});const e=await W.startOAuthFlow(async e=>{z({state:"waiting_for_login",url:e}),setTimeout(Z,3e3,!0)},{loginWithClaudeAi:Y,provider:V,inferenceOnly:"setup-token"===C,expiresIn:"setup-token"===C?31536e3:void 0,orgUUID:G}).catch(e=>{const o=e.message.includes("Token exchange failed"),r=_(e),t=W.getPort(),i="openai"===V&&t?formatOAuthDebugDetails(V,t):"";throw z({state:"error",message:r??(o?"No se pudo intercambiar el codigo de autorizacion por el token de acceso. Intentalo de nuevo."+(i?`\n${i}`:""):e.message),toRetry:"setup-token"===C?{state:"ready_to_start"}:{state:"idle"}}),l("tengu_oauth_token_exchange_error",{error:e.message,ssl_error:null!==r}),e});if("setup-token"===C)z({state:"success",token:e.accessToken});else{z({state:"creating_api_key"});const o=T?I("openai"===V?"openai":"anthropic",T):void 0;if(await c(e,V,o?.id),"anthropic"===V){const e=await O();if(!e.valid)throw new Error(e.message)}z({state:"success"}),v({message:"openai"===V?"Inicio de sesión con OpenAI / Codex completado":"Inicio de sesión en Context Code completado",notificationType:"auth_success"},B)}}catch(e){const o=e.message,r=_(e),t=W.getPort(),i="openai"===V&&t?formatOAuthDebugDetails(V,t):"";z({state:"error",message:r??("openai"===V&&i&&!o.includes("redirect_uri=")?`${o}\n${i}`:o),toRetry:{state:"setup-token"===C?"ready_to_start":"idle"}}),l("tengu_oauth_error",{error:o,ssl_error:null!==r})}},[V,W,Z,Y,C,G,B]),pe=a(!1);return n(()=>{"ready_to_start"!==L.state||pe.current||(pe.current=!0,process.nextTick((e,o)=>{e(),o.current=!1},me,pe))},[L.state,me]),n(()=>{if("setup-token"===C&&"success"===L.state){const e=setTimeout((e,o)=>{l("tengu_oauth_success",{loginWithClaudeAi:e}),o(V)},500,Y,r,V);return()=>clearTimeout(e)}},[C,L,Y,r,V]),n(()=>()=>{W.cleanup()},[W]),e(p,{flexDirection:"column",gap:1,children:["waiting_for_login"===L.state&&H&&e(p,{flexDirection:"column",gap:1,paddingBottom:1,children:[e(p,{paddingX:1,children:[e(g,{dimColor:!0,children:["Browser didn't open? Use the url below to sign in"," "]}),o(g,J?{color:"success",children:"(Copied!)"}:{dimColor:!0,children:o(U,{shortcut:"c",action:"copiar",parens:!0})})]}),o(h,{url:L.url,children:o(g,{dimColor:!0,children:L.url})})]},"urlToCopy"),"setup-token"===C&&"success"===L.state&&L.token&&e(p,{flexDirection:"column",gap:1,paddingTop:1,children:[o(g,{color:"success",children:"✓ Long-lived authentication token created successfully!"}),e(p,{flexDirection:"column",gap:1,children:[o(g,{children:"Your OAuth token (valid for 1 year):"}),o(g,{color:"warning",children:L.token}),o(g,{dimColor:!0,children:"Store this token securely. You won't be able to see it again."}),o(g,{dimColor:!0,children:"Use this token by setting: export CONTEXT_CODE_OAUTH_TOKEN=<token>"})]})]},"tokenOutput"),o(p,{paddingLeft:1,flexDirection:"column",gap:1,children:o(OAuthStatusMessage,{oauthStatus:L,oauthProvider:V,mode:C,startingMessage:t,forcedMethodMessage:E,showPastePrompt:H,pastedCode:K,setPastedCode:N,cursorOffset:F,setCursorOffset:$,textInputColumns:ee,handleSubmitCode:async function(e,o){try{const[r,t]=e.split("#");if(!r||!t)return void z({state:"error",message:"Codigo invalido. Asegurate de copiar el codigo completo",toRetry:{state:"waiting_for_login",url:o}});l("tengu_oauth_manual_entry",{}),W.handleManualAuthCodeInput({authorizationCode:r,state:t})}catch(e){S(e),z({state:"error",message:e.message,toRetry:{state:"waiting_for_login",url:o}})}},setOAuthStatus:z,setLoginWithClaudeAi:q,setOAuthProvider:X,providerApiKey:oe,setProviderApiKey:re,providerApiKeyCursorOffset:te,setProviderApiKeyCursorOffset:ie,handleProviderApiKeySubmit:ce,providerBaseUrl:ne,setProviderBaseUrlInput:ae,providerBaseUrlCursorOffset:se,setProviderBaseUrlCursorOffset:le,handleProviderBaseUrlSubmit:de,onDone:r})})]})}function OAuthStatusMessage(i){const n=t(68),{oauthStatus:a,oauthProvider:s,mode:c,startingMessage:d,forcedMethodMessage:u,showPastePrompt:m,pastedCode:f,setPastedCode:_,cursorOffset:v,setCursorOffset:y,textInputColumns:C,handleSubmitCode:A,setOAuthStatus:x,setLoginWithClaudeAi:k,setOAuthProvider:O,providerApiKey:P,setProviderApiKey:I,providerApiKeyCursorOffset:S,setProviderApiKeyCursorOffset:w,handleProviderApiKeySubmit:j,providerBaseUrl:U,setProviderBaseUrlInput:E,providerBaseUrlCursorOffset:L,setProviderBaseUrlCursorOffset:z,handleProviderBaseUrlSubmit:K,onDone:N}=i;switch(a.state){case"idle":{const r=d||"Context Code puede usarse con tu suscripción de Claude, la facturación de Anthropic Console o OpenAI / Codex OAuth.";let t,i,a,s,c,u,m;return n[0]!==r?(t=o(g,{bold:!0,children:r}),n[0]=r,n[1]=t):t=n[1],n[2]===Symbol.for("react.memo_cache_sentinel")?(i=o(g,{children:"Selecciona el metodo de acceso:"}),n[2]=i):i=n[2],n[3]===Symbol.for("react.memo_cache_sentinel")?(a={label:e(g,{children:["Claude account with subscription ·"," ",o(g,{dimColor:!0,children:"Pro, Max, Team, or Enterprise"}),!1,"\n"]}),value:"claudeai"},n[3]=a):a=n[3],n[4]===Symbol.for("react.memo_cache_sentinel")?(s={label:e(g,{children:["Anthropic Console account ·"," ",o(g,{dimColor:!0,children:"API usage billing"}),"\n"]}),value:"console"},n[4]=s):s=n[4],n[5]===Symbol.for("react.memo_cache_sentinel")?(c=[a,s,{label:e(g,{children:["Cuenta de OpenAI / Codex ·"," ",o(g,{dimColor:!0,children:"Login OAuth"}),"\n"]}),value:"openai"},{label:e(g,{children:["OpenRouter ·"," ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"openrouter"},{label:e(g,{children:["Ollama ·"," ",o(g,{dimColor:!0,children:"Servidor local compatible"}),"\n"]}),value:"ollama"},{label:e(g,{children:["Gemini API - ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"gemini-api"},{label:e(g,{children:["Gemini Google - ",o(g,{dimColor:!0,children:"OAuth/ADC de Google"}),"\n"]}),value:"gemini-google"},{label:e(g,{children:["Z.AI ·"," ",o(g,{dimColor:!0,children:"API key / OpenAI-compatible"}),"\n"]}),value:"zai"},{label:e(g,{children:["MiniMax ·"," ",o(g,{dimColor:!0,children:"API key / Anthropic-compatible"}),"\n"]}),value:"minimax"},{label:e(g,{children:["NVIDIA API ·"," ",o(g,{dimColor:!0,children:"API key / build.nvidia.com"}),"\n"]}),value:"nvidia"},{label:e(g,{children:["DeepSeek ·"," ",o(g,{dimColor:!0,children:"API key / contexto 1M (V4)"}),"\n"]}),value:"deepseek"}],n[5]=c):c=n[5],n[6]!==k||n[7]!==x||n[8]!==O||n[65]!==N?(u=o(p,{children:o(M,{options:sortLoginProviderOptions(c),onChange:e=>{"platform"===e?(l("tengu_oauth_platform_selected",{}),x({state:"platform_setup"})):"openai"===e?(l("tengu_oauth_openai_selected",{}),O("openai"),k(!1),x({state:"ready_to_start"})):"openrouter"===e?x({state:"provider_api_key_input",provider:"openrouter"}):"gemini-api"===e||"zai"===e||"minimax"===e||"nvidia"===e||"deepseek"===e?x({state:"provider_api_key_input",provider:e}):"gemini-google"===e?x({state:"provider_google_setup"}):"ollama"===e||"ollama-cloud"===e?(E(T(e)),z(0),x({state:"provider_local_setup",provider:e})):(O("anthropic"),x({state:"ready_to_start"}),"claudeai"===e?(l("tengu_oauth_claudeai_selected",{}),k(!0)):(l("tengu_oauth_console_selected",{}),k(!1)))}})}),n[6]=k,n[7]=x,n[8]=O,n[65]=N,n[66]=u):u=n[66],n[10]!==t||n[11]!==u?(m=e(p,{flexDirection:"column",gap:1,marginTop:1,children:[t,i,u]}),n[10]=t,n[11]=u,n[12]=m):m=n[12],m}case"provider_api_key_input":{let r,t,i,s;if(n[50]!==a.provider?(r=e(g,{bold:!0,children:["Ingresa la API key de ",D(a.provider).label]}),n[50]=a.provider,n[51]=r):r=n[51],n[52]!==a.provider){const r=D(a.provider);t=e(p,{flexDirection:"column",gap:0,children:[o(g,{dimColor:!0,children:r.description}),e(g,{dimColor:!0,children:["Siguiente paso: ",r.setup.nextStep]})]}),n[52]=a.provider,n[53]=t}else t=n[53];return n[54]!==P||n[55]!==S||n[56]!==I||n[57]!==w||n[58]!==C||n[59]!==j?(i=e(p,{children:[o(g,{children:"API key > "}),o(G,{value:P,onChange:I,onSubmit:e=>j(e,a.provider),cursorOffset:S,onChangeCursorOffset:w,columns:C,mask:"*"})]}),n[54]=P,n[55]=S,n[56]=I,n[57]=w,n[58]=C,n[59]=j,n[60]=i):i=n[60],n[61]!==r||n[62]!==t||n[63]!==i?(s=e(p,{flexDirection:"column",gap:1,children:[r,t,i]}),n[61]=r,n[62]=t,n[63]=i,n[64]=s):s=n[64],s}case"provider_local_setup":{const r=D(a.provider);return e(p,{flexDirection:"column",gap:1,children:[o(g,{bold:!0,children:r.label}),o(g,{dimColor:!0,children:r.setup.intro}),o(g,{dimColor:!0,children:r.setup.nextStep}),o(g,{children:"URL del servidor > "}),o(p,{children:o(G,{value:U,onChange:E,onSubmit:e=>K(e,a.provider),cursorOffset:L,onChangeCursorOffset:z,columns:C})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la URL y continuar."]})]})}case"provider_google_setup":return e(p,{flexDirection:"column",gap:1,children:[o(g,{bold:!0,children:"Gemini Google OAuth"}),o(g,{dimColor:!0,children:"Context Code usara el flujo OAuth compatible con Gemini CLI y abrira Google en el navegador."}),o(g,{dimColor:!0,children:"Se guardara el access token y refresh token en el perfil activo de Gemini Google."}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para iniciar sesion con tu cuenta de Google."]})]});case"provider_google_auth_running":return e(p,{children:[o(R,{}),o(g,{children:"Abriendo Google OAuth para Gemini..."})]});case"platform_setup":{let r,t,i,a,s,l,c,d;return n[12]===Symbol.for("react.memo_cache_sentinel")?(r=o(g,{bold:!0,children:"Usando plataformas de terceros"}),n[12]=r):r=n[12],n[13]===Symbol.for("react.memo_cache_sentinel")?(t=o(g,{children:"Context Code soporta Amazon Bedrock, Microsoft Foundry y Vertex AI. Configura las variables de entorno requeridas y luego reinicia Context Code."}),i=o(g,{children:"Si formas parte de una organización empresarial, contacta a tu administrador para las instrucciones de configuración."}),n[13]=t,n[14]=i):(t=n[13],i=n[14]),n[15]===Symbol.for("react.memo_cache_sentinel")?(a=o(g,{bold:!0,children:"Documentation:"}),n[15]=a):a=n[15],n[16]===Symbol.for("react.memo_cache_sentinel")?(s=e(g,{children:["· Amazon Bedrock:"," ",o(h,{url:"https://context.iaforged.com/docs/en/amazon-bedrock",children:"https://context.iaforged.com/docs/en/amazon-bedrock"})]}),n[16]=s):s=n[16],n[17]===Symbol.for("react.memo_cache_sentinel")?(l=e(g,{children:["· Microsoft Foundry:"," ",o(h,{url:"https://context.iaforged.com/docs/en/microsoft-foundry",children:"https://context.iaforged.com/docs/en/microsoft-foundry"})]}),n[17]=l):l=n[17],n[18]===Symbol.for("react.memo_cache_sentinel")?(c=e(p,{flexDirection:"column",marginTop:1,children:[a,s,l,e(g,{children:["· Vertex AI:"," ",o(h,{url:"https://context.iaforged.com/docs/en/google-vertex-ai",children:"https://context.iaforged.com/docs/en/google-vertex-ai"})]})]}),n[18]=c):c=n[18],n[19]===Symbol.for("react.memo_cache_sentinel")?(d=e(p,{flexDirection:"column",gap:1,marginTop:1,children:[r,e(p,{flexDirection:"column",gap:1,children:[t,i,c,o(p,{marginTop:1,children:e(g,{dimColor:!0,children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para volver a las opciones de acceso."]})})]})]}),n[19]=d):d=n[19],d}case"waiting_for_login":{let r,t,i,s;return n[20]!==u?(r=u&&o(p,{children:o(g,{dimColor:!0,children:u})}),n[20]=u,n[21]=r):r=n[21],n[22]!==m?(t=!m&&e(p,{children:[o(R,{}),o(g,{children:"Abriendo el navegador para iniciar sesión…"})]}),n[22]=m,n[23]=t):t=n[23],n[24]!==v||n[25]!==A||n[26]!==a.url||n[27]!==f||n[28]!==y||n[29]!==_||n[30]!==m||n[31]!==C?(i=m&&e(p,{children:[o(g,{children:B}),o(G,{value:f,onChange:_,onSubmit:e=>A(e,a.url),cursorOffset:v,onChangeCursorOffset:y,columns:C,mask:"*"})]}),n[24]=v,n[25]=A,n[26]=a.url,n[27]=f,n[28]=y,n[29]=_,n[30]=m,n[31]=C,n[32]=i):i=n[32],n[33]!==r||n[34]!==t||n[35]!==i?(s=e(p,{flexDirection:"column",gap:1,children:[r,t,i]}),n[33]=r,n[34]=t,n[35]=i,n[36]=s):s=n[36],s}case"creating_api_key":{let r;return n[37]===Symbol.for("react.memo_cache_sentinel")?(r=o(p,{flexDirection:"column",gap:1,children:e(p,{children:[o(R,{}),o(g,{children:"Creando API key para Context Code…"})]})}),n[37]=r):r=n[37],r}case"about_to_retry":{let e;return n[38]===Symbol.for("react.memo_cache_sentinel")?(e=o(p,{flexDirection:"column",gap:1,children:o(g,{color:"permission",children:"Reintentando…"})}),n[38]=e):e=n[38],e}case"success":{let t,i;if(n[39]!==c||n[40]!==a.token){const i="openai"===s?"Inicio de sesión en OpenAI / Codex exitoso. Presiona ":"Inicio de sesión exitoso. Presiona ";t="setup-token"===c&&a.token?null:e(r,{children:[b()?.emailAddress?e(g,{dimColor:!0,children:["Sesión iniciada como"," ",o(g,{children:b()?.emailAddress})]}):null,e(g,{color:"success",children:[i,o(g,{bold:!0,children:"Enter"})," para continuar…"]})]}),n[39]=c,n[40]=a.token,n[41]=t}else t=n[41];return n[42]!==t?(i=o(p,{flexDirection:"column",children:t}),n[42]=t,n[43]=i):i=n[43],i}case"error":{let r,t,i;return n[44]!==a.message?(r=e(g,{color:"error",children:["OAuth error: ",a.message]}),n[44]=a.message,n[45]=r):r=n[45],n[46]!==a.toRetry?(t=a.toRetry&&o(p,{marginTop:1,children:e(g,{color:"permission",children:["Press ",o(g,{bold:!0,children:"Enter"})," to retry."]})}),n[46]=a.toRetry,n[47]=t):t=n[47],n[48]!==r||n[49]!==t?(i=e(p,{flexDirection:"column",gap:1,children:[r,t]}),n[48]=r,n[49]=t,n[50]=i):i=n[50],i}default:return null}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{Box as n,Link as r,Text as s}from"../ink.js";import{Select as i}from"./CustomSelect/index.js";import{Dialog as c}from"./design-system/Dialog.js";export function CostThresholdDialog(
|
|
1
|
+
import{jsx as o,jsxs as e}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{Box as n,Link as r,Text as s}from"../ink.js";import{Select as i}from"./CustomSelect/index.js";import{Dialog as c}from"./design-system/Dialog.js";export function CostThresholdDialog(a){const m=t(7),{onDone:l}=a;let d,f,h,p;return m[0]===Symbol.for("react.memo_cache_sentinel")?(d=e(n,{flexDirection:"column",children:[o(s,{children:"Más información sobre cómo monitorear tu gasto:"}),o(r,{url:"https://code.claude.com/docs/en/costs"})]}),m[0]=d):d=m[0],m[1]===Symbol.for("react.memo_cache_sentinel")?(f=[{value:"ok",label:"Entendido, ¡gracias!"}],m[1]=f):f=m[1],m[2]!==l?(h=o(i,{options:f,onChange:l}),m[2]=l,m[3]=h):h=m[3],m[4]!==l||m[5]!==h?(p=e(c,{title:"Has gastado $5 en la API de Anthropic en esta sesión.",onCancel:l,children:[d,h]}),m[4]=l,m[5]=h,m[6]=p):p=m[6],p}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import o from"chalk";import e,{useContext as n}from"react";import{Text as i}from"../ink.js";import{getShortcutDisplay as c}from"../keybindings/shortcutFormat.js";import{useShortcutDisplay as s}from"../keybindings/useShortcutDisplay.js";import{KeyboardShortcutHint as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import o from"chalk";import e,{useContext as n}from"react";import{Text as i}from"../ink.js";import{getShortcutDisplay as c}from"../keybindings/shortcutFormat.js";import{useShortcutDisplay as s}from"../keybindings/useShortcutDisplay.js";import{KeyboardShortcutHint as a}from"./design-system/KeyboardShortcutHint.js";import{InVirtualListContext as m}from"./messageActions.js";const p=e.createContext(!1);export function SubAgentProvider(o){const e=t(2),{children:n}=o;let i;return e[0]!==n?(i=r(p.Provider,{value:!0,children:n}),e[0]=n,e[1]=i):i=e[1],i}export function CtrlOToExpand(){const o=t(2),e=n(p),c=n(m),l=s("app:toggleTranscript","Global","ctrl+o");if(e||c)return null;let u;return o[0]!==l?(u=r(i,{dimColor:!0,children:r(a,{shortcut:l,action:"expand",parens:!0})}),o[0]=l,o[1]=u):u=o[1],u}export function ctrlOToExpand(){const r=c("app:toggleTranscript","Global","ctrl+o");return o.dim(`(${r} para expandir)`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as i,jsxs as n}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import t from"figures";import l,{useEffect as s,useRef as r,useState as d}from"react";import{useDeclaredCursor as c}from"../../ink/hooks/use-declared-cursor.js";import{stringWidth as a}from"../../ink/stringWidth.js";import{Ansi as u,Box as p,Text as m}from"../../ink.js";import{count as h}from"../../utils/array.js";import{SelectInputOption as g}from"./select-input-option.js";import{SelectOption as v}from"./select-option.js";import{useSelectInput as b}from"./use-select-input.js";import{useSelectState as x}from"./use-select-state.js";function getTextContent(e){return"string"==typeof e?e:"number"==typeof e?String(e):e?Array.isArray(e)?e.map(getTextContent).join(""):l.isValidElement(e)?getTextContent(e.props.children):"":""}export function Select(l){const c=o(72),{isDisabled:f,hideIndexes:w,visibleOptionCount:S,highlightText:I,options:C,defaultValue:F,onCancel:y,onChange:O,onFocus:D,defaultFocusValue:T,layout:_,disableSelection:V,inlineDescriptions:A,onUpFromFirstItem:j,onDownFromLastItem:U,onInputModeToggle:E,onOpenEditor:k,onImagePaste:M,pastedContents:L,onRemoveImage:R}=l,P=void 0!==f&&f,W=void 0!==w&&w,$=void 0===S?5:S,G=void 0===_?"compact":_,q=void 0!==V&&V,z=void 0!==A&&A,[B,H]=d(!1),[J,K]=d(0);let N;c[0]!==C?(N=()=>{const e=new Map;return C.forEach(i=>{"input"===i.type&&i.initialValue&&e.set(i.value,i.initialValue)}),e},c[0]=C,c[1]=N):N=c[1];const[Q,X]=d(N);let Y;c[2]===Symbol.for("react.memo_cache_sentinel")?(Y=new Map,c[2]=Y):Y=c[2];const Z=r(Y);let ee,ie,ne;c[3]!==Q||c[4]!==C?(ie=()=>{for(const e of C)if("input"===e.type&&void 0!==e.initialValue){const i=Z.current.get(e.value)??"",n=Q.get(e.value)??"",o=e.initialValue;o!==i&&n===i&&X(i=>{const n=new Map(i);return n.set(e.value,o),n}),Z.current.set(e.value,o)}},ee=[C,Q],c[3]=Q,c[4]=C,c[5]=ee,c[6]=ie):(ee=c[5],ie=c[6]),s(ie,ee),c[7]!==T||c[8]!==F||c[9]!==y||c[10]!==O||c[11]!==D||c[12]!==C||c[13]!==$?(ne={visibleOptionCount:$,options:C,defaultValue:F,onChange:O,onCancel:y,onFocus:D,focusValue:T},c[7]=T,c[8]=F,c[9]=y,c[10]=O,c[11]=D,c[12]=C,c[13]=$,c[14]=ne):ne=c[14];const oe=x(ne),te=q||!!W&&"numeric";let le,se,re,de,ce,ae,ue;if(c[15]!==L?(le=()=>{if(L&&Object.values(L).some(_temp)){const e=h(Object.values(L),_temp2);return H(!0),K(e-1),!0}return!1},c[15]=L,c[16]=le):le=c[16],c[17]!==B||c[18]!==Q||c[19]!==P||c[20]!==U||c[21]!==E||c[22]!==j||c[23]!==C||c[24]!==oe||c[25]!==te||c[26]!==le?(se={isDisabled:P,disableSelection:te,state:oe,options:C,isMultiSelect:!1,onUpFromFirstItem:j,onDownFromLastItem:U,onInputModeToggle:E,inputValues:Q,imagesSelected:B,onEnterImageSelection:le},c[17]=B,c[18]=Q,c[19]=P,c[20]=U,c[21]=E,c[22]=j,c[23]=C,c[24]=oe,c[25]=te,c[26]=le,c[27]=se):se=c[27],b(se),c[28]!==W||c[29]!==I||c[30]!==B||c[31]!==z||c[32]!==Q||c[33]!==P||c[34]!==G||c[35]!==y||c[36]!==O||c[37]!==M||c[38]!==k||c[39]!==R||c[40]!==C.length||c[41]!==L||c[42]!==J||c[43]!==oe.focusedValue||c[44]!==oe.options||c[45]!==oe.value||c[46]!==oe.visibleFromIndex||c[47]!==oe.visibleOptions||c[48]!==oe.visibleToIndex){ae=Symbol.for("react.early_return_sentinel");e:{const o={container:_temp3,highlightedText:_temp4};if("expanded"===G){let t;c[53]!==oe.options.length?(t=oe.options.length.toString(),c[53]=oe.options.length,c[54]=t):t=c[54];const l=t.length;ae=e(p,{...o.container(),children:oe.visibleOptions.map((t,s)=>{const r=t.index===oe.visibleFromIndex,d=t.index===oe.visibleToIndex-1,c=oe.visibleToIndex<C.length,a=oe.visibleFromIndex>0,h=oe.visibleFromIndex+s+1,b=!P&&oe.focusedValue===t.value,x=oe.value===t.value;if("input"===t.type){const i=Q.has(t.value)?Q.get(t.value):t.initialValue||"";return e(g,{option:t,isFocused:b,isSelected:x,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&r,maxIndexWidth:l,index:h,inputValue:i,onInputChange:e=>{X(i=>{const n=new Map(i);return n.set(t.value,e),n})},onSubmit:e=>{const i=L&&Object.values(L).some(_temp5);e.trim()||i||t.allowEmptySubmitToCancel?O?.(t.value):y?.()},onExit:y,layout:"expanded",showLabel:z,onOpenEditor:k,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:M,pastedContents:L,onRemoveImage:R,imagesSelected:B,selectedImageIndex:J,onImagesSelectedChange:H,onSelectedImageIndexChange:K},String(t.value))}let f=t.label;if("string"==typeof t.label&&I&&t.label.includes(I)){const l=t.label,s=l.indexOf(I);f=n(i,{children:[l.slice(0,s),e(m,{...o.highlightedText(),children:I}),l.slice(s+I.length)]})}const w=!0===t.disabled,S=w?void 0:x?"success":b?"suggestion":void 0;return n(p,{flexDirection:"column",flexShrink:0,children:[e(v,{isFocused:b,isSelected:x,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&r,children:e(m,{dimColor:w,color:S,children:f})}),t.description&&e(p,{paddingLeft:2,children:e(m,{dimColor:w||!1!==t.dimDescription,color:S,children:e(u,{children:t.description})})}),e(m,{children:" "})]},String(t.value))})});break e}if("compact-vertical"===G){let t;c[55]!==W||c[56]!==oe.options?(t=W?0:oe.options.length.toString().length,c[55]=W,c[56]=oe.options,c[57]=t):t=c[57];const l=t;ae=e(p,{...o.container(),children:oe.visibleOptions.map((t,s)=>{const r=t.index===oe.visibleFromIndex,d=t.index===oe.visibleToIndex-1,c=oe.visibleToIndex<C.length,a=oe.visibleFromIndex>0,h=oe.visibleFromIndex+s+1,b=!P&&oe.focusedValue===t.value,x=oe.value===t.value;if("input"===t.type){const i=Q.has(t.value)?Q.get(t.value):t.initialValue||"";return e(g,{option:t,isFocused:b,isSelected:x,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&r,maxIndexWidth:l,index:h,inputValue:i,onInputChange:e=>{X(i=>{const n=new Map(i);return n.set(t.value,e),n})},onSubmit:e=>{const i=L&&Object.values(L).some(_temp6);e.trim()||i||t.allowEmptySubmitToCancel?O?.(t.value):y?.()},onExit:y,layout:"compact",showLabel:z,onOpenEditor:k,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:M,pastedContents:L,onRemoveImage:R,imagesSelected:B,selectedImageIndex:J,onImagesSelectedChange:H,onSelectedImageIndexChange:K},String(t.value))}let f=t.label;if("string"==typeof t.label&&I&&t.label.includes(I)){const l=t.label,s=l.indexOf(I);f=n(i,{children:[l.slice(0,s),e(m,{...o.highlightedText(),children:I}),l.slice(s+I.length)]})}const w=!0===t.disabled;return n(p,{flexDirection:"column",flexShrink:0,children:[e(v,{isFocused:b,isSelected:x,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&r,children:n(i,{children:[!W&&e(m,{dimColor:!0,children:`${h}.`.padEnd(l+1)}),e(m,{dimColor:w,color:w?void 0:x?"success":b?"suggestion":void 0,children:f})]})}),t.description&&e(p,{paddingLeft:W?4:l+4,children:e(m,{dimColor:w||!1!==t.dimDescription,color:w?void 0:x?"success":b?"suggestion":void 0,children:e(u,{children:t.description})})})]},String(t.value))})});break e}let l;c[58]!==W||c[59]!==oe.options?(l=W?0:oe.options.length.toString().length,c[58]=W,c[59]=oe.options,c[60]=l):l=c[60];const s=l,r=oe.visibleOptions.some(_temp7),d=!z&&!r&&oe.visibleOptions.some(_temp8),h=oe.visibleOptions.map((t,l)=>{const s=t.index===oe.visibleFromIndex,r=t.index===oe.visibleToIndex-1,d=oe.visibleToIndex<C.length,c=oe.visibleFromIndex>0,a=oe.visibleFromIndex+l+1,u=!P&&oe.focusedValue===t.value,p=oe.value===t.value,h=!0===t.disabled;let g=t.label;if("string"==typeof t.label&&I&&t.label.includes(I)){const l=t.label,s=l.indexOf(I);g=n(i,{children:[l.slice(0,s),e(m,{...o.highlightedText(),children:I}),l.slice(s+I.length)]})}return{option:t,index:a,label:g,isFocused:u,isSelected:p,isOptionDisabled:h,shouldShowDownArrow:d&&r,shouldShowUpArrow:c&&s}});if(d){let i;c[61]!==W||c[62]!==s?(i=e=>{if("input"===e.option.type)return 0;const i=getTextContent(e.option.label),n=W?0:s+2,o=e.isSelected?2:0;return 2+n+a(i)+o},c[61]=W,c[62]=s,c[63]=i):i=c[63];const l=Math.max(...h.map(i));let r;c[64]!==W||c[65]!==s||c[66]!==l?(r=i=>{if("input"===i.option.type)return null;const o=getTextContent(i.option.label),r=W?0:s+2,d=i.isSelected?2:0,c=2+r+a(o)+d,h=l-c;return n(TwoColumnRow,{isFocused:i.isFocused,children:[n(p,{flexDirection:"row",flexShrink:0,children:[i.isFocused?e(m,{color:"suggestion",children:t.pointer}):i.shouldShowDownArrow?e(m,{dimColor:!0,children:t.arrowDown}):i.shouldShowUpArrow?e(m,{dimColor:!0,children:t.arrowUp}):e(m,{children:" "}),e(m,{children:" "}),n(m,{dimColor:i.isOptionDisabled,color:i.isOptionDisabled?void 0:i.isSelected?"success":i.isFocused?"suggestion":void 0,children:[!W&&e(m,{dimColor:!0,children:`${i.index}.`.padEnd(s+2)}),i.label]}),i.isSelected&&n(m,{color:"success",children:[" ",t.tick]}),h>0&&e(m,{children:" ".repeat(h)})]}),e(p,{flexGrow:1,marginLeft:2,children:e(m,{wrap:"wrap",dimColor:i.isOptionDisabled||!1!==i.option.dimDescription,color:i.isOptionDisabled?void 0:i.isSelected?"success":i.isFocused?"suggestion":void 0,children:e(u,{children:i.option.description||" "})})})]},String(i.option.value))},c[64]=W,c[65]=s,c[66]=l,c[67]=r):r=c[67],ae=e(p,{...o.container(),children:h.map(r)});break e}re=p,de=o.container(),ce=oe.visibleOptions.map((t,l)=>{if("input"===t.type){const i=Q.has(t.value)?Q.get(t.value):t.initialValue||"",n=t.index===oe.visibleFromIndex,o=t.index===oe.visibleToIndex-1,r=oe.visibleToIndex<C.length,d=oe.visibleFromIndex>0,c=oe.visibleFromIndex+l+1,a=!P&&oe.focusedValue===t.value,u=oe.value===t.value;return e(g,{option:t,isFocused:a,isSelected:u,shouldShowDownArrow:r&&o,shouldShowUpArrow:d&&n,maxIndexWidth:s,index:c,inputValue:i,onInputChange:e=>{X(i=>{const n=new Map(i);return n.set(t.value,e),n})},onSubmit:e=>{const i=L&&Object.values(L).some(_temp9);e.trim()||i||t.allowEmptySubmitToCancel?O?.(t.value):y?.()},onExit:y,layout:"compact",showLabel:z,onOpenEditor:k,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:M,pastedContents:L,onRemoveImage:R,imagesSelected:B,selectedImageIndex:J,onImagesSelectedChange:H,onSelectedImageIndexChange:K},String(t.value))}let r=t.label;if("string"==typeof t.label&&I&&t.label.includes(I)){const l=t.label,s=l.indexOf(I);r=n(i,{children:[l.slice(0,s),e(m,{...o.highlightedText(),children:I}),l.slice(s+I.length)]})}const d=t.index===oe.visibleFromIndex,c=t.index===oe.visibleToIndex-1,a=oe.visibleToIndex<C.length,h=oe.visibleFromIndex>0,b=oe.visibleFromIndex+l+1,x=!P&&oe.focusedValue===t.value,f=oe.value===t.value,w=!0===t.disabled;return n(v,{isFocused:x,isSelected:f,shouldShowDownArrow:a&&c,shouldShowUpArrow:h&&d,children:[n(p,{flexDirection:"row",flexShrink:0,children:[!W&&e(m,{dimColor:!0,children:`${b}.`.padEnd(s+2)}),n(m,{dimColor:w,color:w?void 0:f?"success":x?"suggestion":void 0,children:[r,z&&t.description&&n(m,{dimColor:w||!1!==t.dimDescription,children:[" ",t.description]})]})]}),!z&&t.description&&e(p,{flexShrink:99,marginLeft:2,children:e(m,{wrap:"wrap-trim",dimColor:w||!1!==t.dimDescription,color:w?void 0:f?"success":x?"suggestion":void 0,children:e(u,{children:t.description})})})]},String(t.value))})}c[28]=W,c[29]=I,c[30]=B,c[31]=z,c[32]=Q,c[33]=P,c[34]=G,c[35]=y,c[36]=O,c[37]=M,c[38]=k,c[39]=R,c[40]=C.length,c[41]=L,c[42]=J,c[43]=oe.focusedValue,c[44]=oe.options,c[45]=oe.value,c[46]=oe.visibleFromIndex,c[47]=oe.visibleOptions,c[48]=oe.visibleToIndex,c[49]=re,c[50]=de,c[51]=ce,c[52]=ae}else re=c[49],de=c[50],ce=c[51],ae=c[52];return ae!==Symbol.for("react.early_return_sentinel")?ae:(c[68]!==re||c[69]!==de||c[70]!==ce?(ue=e(re,{...de,children:ce}),c[68]=re,c[69]=de,c[70]=ce,c[71]=ue):ue=c[71],ue)}function _temp9(e){return"image"===e.type}function _temp8(e){return e.description}function _temp7(e){return"input"===e.type}function _temp6(e){return"image"===e.type}function _temp5(e){return"image"===e.type}function _temp4(){return{bold:!0}}function _temp3(){return{flexDirection:"column"}}function _temp2(e){return"image"===e.type}function _temp(e){return"image"===e.type}function TwoColumnRow(i){const n=o(5),{isFocused:t,children:l}=i;let s;n[0]!==t?(s={line:0,column:0,active:t},n[0]=t,n[1]=s):s=n[1];const r=c(s);let d;return n[2]!==l||n[3]!==r?(d=e(p,{ref:r,flexDirection:"row",children:l}),n[2]=l,n[3]=r,n[4]=d):d=n[4],d}
|
|
1
|
+
import{jsx as e,jsxs as i,Fragment as o}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import t from"figures";import l,{useEffect as r,useRef as s,useState as d}from"react";import{useDeclaredCursor as c}from"../../ink/hooks/use-declared-cursor.js";import{stringWidth as a}from"../../ink/stringWidth.js";import{Ansi as u,Box as p,Text as m}from"../../ink.js";import{count as h}from"../../utils/array.js";import{SelectInputOption as g}from"./select-input-option.js";import{SelectOption as v}from"./select-option.js";import{useSelectInput as b}from"./use-select-input.js";import{useSelectState as f}from"./use-select-state.js";import{isWebappRunning as x,broadcastInteractiveSelect as S,getWebappUrl as w}from"../../webapp/server.js";function getTextContent(e){return"string"==typeof e?e:"number"==typeof e?String(e):e?Array.isArray(e)?e.map(getTextContent).join(""):l.isValidElement(e)?getTextContent(e.props.children):"":""}export function Select(l){const c=n(72),{isDisabled:I,hideIndexes:C,visibleOptionCount:y,highlightText:F,options:O,defaultValue:T,onCancel:D,onChange:A,onFocus:_,defaultFocusValue:V,layout:E,disableSelection:j,inlineDescriptions:k,onUpFromFirstItem:U,onDownFromLastItem:M,onInputModeToggle:L,onOpenEditor:P,onImagePaste:R,pastedContents:z,onRemoveImage:W}=l,q=void 0!==I&&I,$=void 0!==C&&C,G=void 0===y?5:y,J=void 0===E?"compact":E,N=void 0!==j&&j,B=void 0!==k&&k,[H,K]=d(!1),[Q,X]=d(!1),[Y,Z]=d(null);r(()=>{if(x()){K(!0);const e=Math.random().toString(36).substring(2,9),{title:i,description:o}=function(e){const i=JSON.stringify(e).toLowerCase();return i.includes("claude")||i.includes("openai")||i.includes("deepseek")||i.includes("gemini")?i.includes("gpt-")||i.includes("claude-3")||i.includes("deepseek-")?{title:"Seleccionar Modelo de IA",description:"Elige el modelo específico de inteligencia artificial que deseas utilizar para las respuestas."}:{title:"Seleccionar Proveedor de IA",description:"Elige el proveedor de inteligencia artificial (ej. Anthropic, OpenAI, DeepSeek, Google) que motorizará las consultas."}:i.includes("workspace")||i.includes("repository")||i.includes("repositorio")?{title:"Seleccionar Espacio de Trabajo",description:"Selecciona el repositorio de código local activo en el que deseas realizar operaciones."}:i.includes("profile")||i.includes("perfil")||i.includes("profiles")?{title:"Seleccionar Perfil de IA",description:"Elige el perfil de configuración personalizado para tu proveedor de IA activo."}:{title:"Selección Interactiva",description:"Por favor, selecciona una de las opciones disponibles en la interfaz web de Context Code."}}(O),n=O.map(e=>({label:getTextContent(e.label)||String(e.value),value:String(e.value)})),t=T?String(T):void 0;S(e,i,n,o,t).then(e=>{X(!0);const i=O.find(i=>String(i.value)===e);A?.(i?i.value:e)}).catch(e=>{Z(e.message||String(e)),D?.()})}},[O,T]);const[ee,ie]=d(!1),[oe,ne]=d(0);if(H&&!Q)return i(p,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan",children:[e(m,{color:"cyan",bold:!0,children:"✨ Interacción de Selección Transferida a la WebApp"}),e(m,{color:"white",children:"Por favor, selecciona una opción en tu navegador:"}),e(m,{bold:!0,color:"cyan",children:w()}),Y?i(m,{color:"red",children:["Error: ",Y]}):e(m,{dimColor:!0,children:"Esperando respuesta del usuario..."})]});let te;c[0]!==O?(te=()=>{const e=new Map;return O.forEach(i=>{"input"===i.type&&i.initialValue&&e.set(i.value,i.initialValue)}),e},c[0]=O,c[1]=te):te=c[1];const[le,re]=d(te);let se;c[2]===Symbol.for("react.memo_cache_sentinel")?(se=new Map,c[2]=se):se=c[2];const de=s(se);let ce,ae,ue;c[3]!==le||c[4]!==O?(ae=()=>{for(const e of O)if("input"===e.type&&void 0!==e.initialValue){const i=de.current.get(e.value)??"",o=le.get(e.value)??"",n=e.initialValue;n!==i&&o===i&&re(i=>{const o=new Map(i);return o.set(e.value,n),o}),de.current.set(e.value,n)}},ce=[O,le],c[3]=le,c[4]=O,c[5]=ce,c[6]=ae):(ce=c[5],ae=c[6]),r(ae,ce),c[7]!==V||c[8]!==T||c[9]!==D||c[10]!==A||c[11]!==_||c[12]!==O||c[13]!==G?(ue={visibleOptionCount:G,options:O,defaultValue:T,onChange:A,onCancel:D,onFocus:_,focusValue:V},c[7]=V,c[8]=T,c[9]=D,c[10]=A,c[11]=_,c[12]=O,c[13]=G,c[14]=ue):ue=c[14];const pe=f(ue),me=N||!!$&&"numeric";let he,ge,ve,be,fe,xe,Se;if(c[15]!==z?(he=()=>{if(z&&Object.values(z).some(_temp)){const e=h(Object.values(z),_temp2);return ie(!0),ne(e-1),!0}return!1},c[15]=z,c[16]=he):he=c[16],c[17]!==ee||c[18]!==le||c[19]!==q||c[20]!==M||c[21]!==L||c[22]!==U||c[23]!==O||c[24]!==pe||c[25]!==me||c[26]!==he?(ge={isDisabled:q,disableSelection:me,state:pe,options:O,isMultiSelect:!1,onUpFromFirstItem:U,onDownFromLastItem:M,onInputModeToggle:L,inputValues:le,imagesSelected:ee,onEnterImageSelection:he},c[17]=ee,c[18]=le,c[19]=q,c[20]=M,c[21]=L,c[22]=U,c[23]=O,c[24]=pe,c[25]=me,c[26]=he,c[27]=ge):ge=c[27],b(ge),c[28]!==$||c[29]!==F||c[30]!==ee||c[31]!==B||c[32]!==le||c[33]!==q||c[34]!==J||c[35]!==D||c[36]!==A||c[37]!==R||c[38]!==P||c[39]!==W||c[40]!==O.length||c[41]!==z||c[42]!==oe||c[43]!==pe.focusedValue||c[44]!==pe.options||c[45]!==pe.value||c[46]!==pe.visibleFromIndex||c[47]!==pe.visibleOptions||c[48]!==pe.visibleToIndex){xe=Symbol.for("react.early_return_sentinel");e:{const n={container:_temp3,highlightedText:_temp4};if("expanded"===J){let t;c[53]!==pe.options.length?(t=pe.options.length.toString(),c[53]=pe.options.length,c[54]=t):t=c[54];const l=t.length;xe=e(p,{...n.container(),children:pe.visibleOptions.map((t,r)=>{const s=t.index===pe.visibleFromIndex,d=t.index===pe.visibleToIndex-1,c=pe.visibleToIndex<O.length,a=pe.visibleFromIndex>0,h=pe.visibleFromIndex+r+1,b=!q&&pe.focusedValue===t.value,f=pe.value===t.value;if("input"===t.type){const i=le.has(t.value)?le.get(t.value):t.initialValue||"";return e(g,{option:t,isFocused:b,isSelected:f,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&s,maxIndexWidth:l,index:h,inputValue:i,onInputChange:e=>{re(i=>{const o=new Map(i);return o.set(t.value,e),o})},onSubmit:e=>{const i=z&&Object.values(z).some(_temp5);e.trim()||i||t.allowEmptySubmitToCancel?A?.(t.value):D?.()},onExit:D,layout:"expanded",showLabel:B,onOpenEditor:P,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:R,pastedContents:z,onRemoveImage:W,imagesSelected:ee,selectedImageIndex:oe,onImagesSelectedChange:ie,onSelectedImageIndexChange:ne},String(t.value))}let x=t.label;if("string"==typeof t.label&&F&&t.label.includes(F)){const l=t.label,r=l.indexOf(F);x=i(o,{children:[l.slice(0,r),e(m,{...n.highlightedText(),children:F}),l.slice(r+F.length)]})}const S=!0===t.disabled,w=S?void 0:f?"success":b?"suggestion":void 0;return i(p,{flexDirection:"column",flexShrink:0,children:[e(v,{isFocused:b,isSelected:f,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&s,children:e(m,{dimColor:S,color:w,children:x})}),t.description&&e(p,{paddingLeft:2,children:e(m,{dimColor:S||!1!==t.dimDescription,color:w,children:e(u,{children:t.description})})}),e(m,{children:" "})]},String(t.value))})});break e}if("compact-vertical"===J){let t;c[55]!==$||c[56]!==pe.options?(t=$?0:pe.options.length.toString().length,c[55]=$,c[56]=pe.options,c[57]=t):t=c[57];const l=t;xe=e(p,{...n.container(),children:pe.visibleOptions.map((t,r)=>{const s=t.index===pe.visibleFromIndex,d=t.index===pe.visibleToIndex-1,c=pe.visibleToIndex<O.length,a=pe.visibleFromIndex>0,h=pe.visibleFromIndex+r+1,b=!q&&pe.focusedValue===t.value,f=pe.value===t.value;if("input"===t.type){const i=le.has(t.value)?le.get(t.value):t.initialValue||"";return e(g,{option:t,isFocused:b,isSelected:f,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&s,maxIndexWidth:l,index:h,inputValue:i,onInputChange:e=>{re(i=>{const o=new Map(i);return o.set(t.value,e),o})},onSubmit:e=>{const i=z&&Object.values(z).some(_temp6);e.trim()||i||t.allowEmptySubmitToCancel?A?.(t.value):D?.()},onExit:D,layout:"compact",showLabel:B,onOpenEditor:P,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:R,pastedContents:z,onRemoveImage:W,imagesSelected:ee,selectedImageIndex:oe,onImagesSelectedChange:ie,onSelectedImageIndexChange:ne},String(t.value))}let x=t.label;if("string"==typeof t.label&&F&&t.label.includes(F)){const l=t.label,r=l.indexOf(F);x=i(o,{children:[l.slice(0,r),e(m,{...n.highlightedText(),children:F}),l.slice(r+F.length)]})}const S=!0===t.disabled;return i(p,{flexDirection:"column",flexShrink:0,children:[e(v,{isFocused:b,isSelected:f,shouldShowDownArrow:c&&d,shouldShowUpArrow:a&&s,children:i(o,{children:[!$&&e(m,{dimColor:!0,children:`${h}.`.padEnd(l+1)}),e(m,{dimColor:S,color:S?void 0:f?"success":b?"suggestion":void 0,children:x})]})}),t.description&&e(p,{paddingLeft:$?4:l+4,children:e(m,{dimColor:S||!1!==t.dimDescription,color:S?void 0:f?"success":b?"suggestion":void 0,children:e(u,{children:t.description})})})]},String(t.value))})});break e}let l;c[58]!==$||c[59]!==pe.options?(l=$?0:pe.options.length.toString().length,c[58]=$,c[59]=pe.options,c[60]=l):l=c[60];const r=l,s=pe.visibleOptions.some(_temp7),d=!B&&!s&&pe.visibleOptions.some(_temp8),h=pe.visibleOptions.map((t,l)=>{const r=t.index===pe.visibleFromIndex,s=t.index===pe.visibleToIndex-1,d=pe.visibleToIndex<O.length,c=pe.visibleFromIndex>0,a=pe.visibleFromIndex+l+1,u=!q&&pe.focusedValue===t.value,p=pe.value===t.value,h=!0===t.disabled;let g=t.label;if("string"==typeof t.label&&F&&t.label.includes(F)){const l=t.label,r=l.indexOf(F);g=i(o,{children:[l.slice(0,r),e(m,{...n.highlightedText(),children:F}),l.slice(r+F.length)]})}return{option:t,index:a,label:g,isFocused:u,isSelected:p,isOptionDisabled:h,shouldShowDownArrow:d&&s,shouldShowUpArrow:c&&r}});if(d){let o;c[61]!==$||c[62]!==r?(o=e=>{if("input"===e.option.type)return 0;const i=getTextContent(e.option.label),o=$?0:r+2,n=e.isSelected?2:0;return 2+o+a(i)+n},c[61]=$,c[62]=r,c[63]=o):o=c[63];const l=Math.max(...h.map(o));let s;c[64]!==$||c[65]!==r||c[66]!==l?(s=o=>{if("input"===o.option.type)return null;const n=getTextContent(o.option.label),s=$?0:r+2,d=o.isSelected?2:0,c=2+s+a(n)+d,h=l-c;return i(TwoColumnRow,{isFocused:o.isFocused,children:[i(p,{flexDirection:"row",flexShrink:0,children:[o.isFocused?e(m,{color:"suggestion",children:t.pointer}):o.shouldShowDownArrow?e(m,{dimColor:!0,children:t.arrowDown}):o.shouldShowUpArrow?e(m,{dimColor:!0,children:t.arrowUp}):e(m,{children:" "}),e(m,{children:" "}),i(m,{dimColor:o.isOptionDisabled,color:o.isOptionDisabled?void 0:o.isSelected?"success":o.isFocused?"suggestion":void 0,children:[!$&&e(m,{dimColor:!0,children:`${o.index}.`.padEnd(r+2)}),o.label]}),o.isSelected&&i(m,{color:"success",children:[" ",t.tick]}),h>0&&e(m,{children:" ".repeat(h)})]}),e(p,{flexGrow:1,marginLeft:2,children:e(m,{wrap:"wrap",dimColor:o.isOptionDisabled||!1!==o.option.dimDescription,color:o.isOptionDisabled?void 0:o.isSelected?"success":o.isFocused?"suggestion":void 0,children:e(u,{children:o.option.description||" "})})})]},String(o.option.value))},c[64]=$,c[65]=r,c[66]=l,c[67]=s):s=c[67],xe=e(p,{...n.container(),children:h.map(s)});break e}ve=p,be=n.container(),fe=pe.visibleOptions.map((t,l)=>{if("input"===t.type){const i=le.has(t.value)?le.get(t.value):t.initialValue||"",o=t.index===pe.visibleFromIndex,n=t.index===pe.visibleToIndex-1,s=pe.visibleToIndex<O.length,d=pe.visibleFromIndex>0,c=pe.visibleFromIndex+l+1,a=!q&&pe.focusedValue===t.value,u=pe.value===t.value;return e(g,{option:t,isFocused:a,isSelected:u,shouldShowDownArrow:s&&n,shouldShowUpArrow:d&&o,maxIndexWidth:r,index:c,inputValue:i,onInputChange:e=>{re(i=>{const o=new Map(i);return o.set(t.value,e),o})},onSubmit:e=>{const i=z&&Object.values(z).some(_temp9);e.trim()||i||t.allowEmptySubmitToCancel?A?.(t.value):D?.()},onExit:D,layout:"compact",showLabel:B,onOpenEditor:P,resetCursorOnUpdate:t.resetCursorOnUpdate,onImagePaste:R,pastedContents:z,onRemoveImage:W,imagesSelected:ee,selectedImageIndex:oe,onImagesSelectedChange:ie,onSelectedImageIndexChange:ne},String(t.value))}let s=t.label;if("string"==typeof t.label&&F&&t.label.includes(F)){const l=t.label,r=l.indexOf(F);s=i(o,{children:[l.slice(0,r),e(m,{...n.highlightedText(),children:F}),l.slice(r+F.length)]})}const d=t.index===pe.visibleFromIndex,c=t.index===pe.visibleToIndex-1,a=pe.visibleToIndex<O.length,h=pe.visibleFromIndex>0,b=pe.visibleFromIndex+l+1,f=!q&&pe.focusedValue===t.value,x=pe.value===t.value,S=!0===t.disabled;return i(v,{isFocused:f,isSelected:x,shouldShowDownArrow:a&&c,shouldShowUpArrow:h&&d,children:[i(p,{flexDirection:"row",flexShrink:0,children:[!$&&e(m,{dimColor:!0,children:`${b}.`.padEnd(r+2)}),i(m,{dimColor:S,color:S?void 0:x?"success":f?"suggestion":void 0,children:[s,B&&t.description&&i(m,{dimColor:S||!1!==t.dimDescription,children:[" ",t.description]})]})]}),!B&&t.description&&e(p,{flexShrink:99,marginLeft:2,children:e(m,{wrap:"wrap-trim",dimColor:S||!1!==t.dimDescription,color:S?void 0:x?"success":f?"suggestion":void 0,children:e(u,{children:t.description})})})]},String(t.value))})}c[28]=$,c[29]=F,c[30]=ee,c[31]=B,c[32]=le,c[33]=q,c[34]=J,c[35]=D,c[36]=A,c[37]=R,c[38]=P,c[39]=W,c[40]=O.length,c[41]=z,c[42]=oe,c[43]=pe.focusedValue,c[44]=pe.options,c[45]=pe.value,c[46]=pe.visibleFromIndex,c[47]=pe.visibleOptions,c[48]=pe.visibleToIndex,c[49]=ve,c[50]=be,c[51]=fe,c[52]=xe}else ve=c[49],be=c[50],fe=c[51],xe=c[52];return xe!==Symbol.for("react.early_return_sentinel")?xe:(c[68]!==ve||c[69]!==be||c[70]!==fe?(Se=e(ve,{...be,children:fe}),c[68]=ve,c[69]=be,c[70]=fe,c[71]=Se):Se=c[71],Se)}function _temp9(e){return"image"===e.type}function _temp8(e){return e.description}function _temp7(e){return"input"===e.type}function _temp6(e){return"image"===e.type}function _temp5(e){return"image"===e.type}function _temp4(){return{bold:!0}}function _temp3(){return{flexDirection:"column"}}function _temp2(e){return"image"===e.type}function _temp(e){return"image"===e.type}function TwoColumnRow(i){const o=n(5),{isFocused:t,children:l}=i;let r;o[0]!==t?(r={line:0,column:0,active:t},o[0]=t,o[1]=r):r=o[1];const s=c(r);let d;return o[2]!==l||o[3]!==s?(d=e(p,{ref:s,flexDirection:"row",children:l}),o[2]=l,o[3]=s,o[4]=d):d=o[4],d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import{useEffect as r,useState as n}from"react";import{Box as s,Text as i,useInput as a}from"../ink.js";import{openBrowser as c}from"../utils/browser.js";import{getDesktopInstallStatus as l,openCurrentSessionInDesktop as p}from"../utils/desktopDeepLink.js";import{errorMessage as d}from"../utils/errors.js";import{gracefulShutdown as m}from"../utils/gracefulShutdown.js";import{flushSessionStorage as u}from"../utils/sessionStorage.js";import{LoadingState as f}from"./design-system/LoadingState.js";const h="https://clau.de/desktop";export function getDownloadUrl(){return"win32"===process.platform?"https://claude.ai/api/desktop/win32/x64/exe/latest/redirect":"https://claude.ai/api/desktop/darwin/universal/dmg/latest/redirect"}export function DesktopHandoff(m){const k=o(20),{onDone:g}=m,[w,y]=n("checking"),[x,D]=n(null),[j,_]=n("");let v,C,S,b;if(k[0]!==x||k[1]!==g||k[2]!==w?(v=e=>{"error"!==w?"prompt-download"===w&&("y"===e||"Y"===e?(c(getDownloadUrl()).catch(_temp),g(`Starting download. Re-run /desktop once you’ve installed the app.\nLearn more at ${h}`,{display:"system"})):"n"!==e&&"N"!==e||g(`The desktop app is required for /desktop. Learn more at ${h}`,{display:"system"})):g(x??"Unknown error",{display:"system"})},k[0]=x,k[1]=g,k[2]=w,k[3]=v):v=k[3],a(v),k[4]!==g?(C=()=>{(async function(){y("checking");const e=await l();if("not-installed"===e.status)return _("Context Desktop no está instalado."),void y("prompt-download");if("version-too-old"===e.status)return _(`Context Desktop necesita actualizarse (encontrada v${e.version}, se requiere v1.1.2396+).`),void y("prompt-download");y("flushing"),await u(),y("opening");const t=await p();if(!t.success)return D(t.error??"Error al abrir Context Desktop"),void y("error");y("success"),setTimeout(_temp2,500,g)})().catch(e=>{D(d(e)),y("error")})},S=[g],k[4]=g,k[5]=C,k[6]=S):(C=k[5],S=k[6]),r(C,S),"error"===w){let o,r,n;return k[7]!==x?(o=e(i,{color:"error",children:["Error: ",x]}),k[7]=x,k[8]=o):o=k[8],k[9]===Symbol.for("react.memo_cache_sentinel")?(r=t(i,{dimColor:!0,children:"Presiona cualquier tecla para continuar…"}),k[9]=r):r=k[9],k[10]!==o?(n=e(s,{flexDirection:"column",paddingX:2,children:[o,r]}),k[10]=o,k[11]=n):n=k[11],n}if("prompt-download"===w){let o,r,n;return k[12]!==j?(o=t(i,{children:j}),k[12]=j,k[13]=o):o=k[13],k[14]===Symbol.for("react.memo_cache_sentinel")?(r=t(i,{children:"¿Descargar ahora? (y/n)"}),k[14]=r):r=k[14],k[15]!==o?(n=e(s,{flexDirection:"column",paddingX:2,children:[o,r]}),k[15]=o,k[16]=n):n=k[16],n}k[17]===Symbol.for("react.memo_cache_sentinel")?(b={checking:"Verificando Context Desktop…",flushing:"Guardando sesión…",opening:"Abriendo Context Desktop…",success:"Abriendo en Context Desktop…"},k[17]=b):b=k[17];const L=b[w];let q;return k[18]!==L?(q=t(f,{message:L}),k[18]=L,k[19]=q):q=k[19],q}async function _temp2(e){e("Sesión transferida a Context Desktop",{display:"system"}),await m(0,"other")}function _temp(){}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as n,useState as s}from"react";import{Box as r,Text as l}from"../../ink.js";import{getDynamicConfig_CACHED_MAY_BE_STALE as i}from"../../services/analytics/growthbook.js";import{logEvent as p}from"../../services/analytics/index.js";import{getGlobalConfig as a,saveGlobalConfig as c}from"../../utils/config.js";import{Select as m}from"../CustomSelect/select.js";import{DesktopHandoff as u}from"../DesktopHandoff.js";import{PermissionDialog as d}from"../permissions/PermissionDialog.js";const f={enable_shortcut_tip:!1,enable_startup_dialog:!1};export function getDesktopUpsellConfig(){return i("tengu_desktop_upsell",f)}export function shouldShowDesktopUpsellStartup(){if("darwin"!==process.platform&&("win32"!==process.platform||"x64"!==process.arch))return!1;if(!getDesktopUpsellConfig().enable_startup_dialog)return!1;const e=a();return!e.desktopUpsellDismissed&&!((e.desktopUpsellSeenCount??0)>=3)}export function DesktopUpsellStartup(i){const p=t(14),{onDone:a}=i,[f,_]=s(!1);let k
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as n,useState as s}from"react";import{Box as r,Text as l}from"../../ink.js";import{getDynamicConfig_CACHED_MAY_BE_STALE as i}from"../../services/analytics/growthbook.js";import{logEvent as p}from"../../services/analytics/index.js";import{getGlobalConfig as a,saveGlobalConfig as c}from"../../utils/config.js";import{Select as m}from"../CustomSelect/select.js";import{DesktopHandoff as u}from"../DesktopHandoff.js";import{PermissionDialog as d}from"../permissions/PermissionDialog.js";const f={enable_shortcut_tip:!1,enable_startup_dialog:!1};export function getDesktopUpsellConfig(){return i("tengu_desktop_upsell",f)}export function shouldShowDesktopUpsellStartup(){if("darwin"!==process.platform&&("win32"!==process.platform||"x64"!==process.arch))return!1;if(!getDesktopUpsellConfig().enable_startup_dialog)return!1;const e=a();return!e.desktopUpsellDismissed&&!((e.desktopUpsellSeenCount??0)>=3)}export function DesktopUpsellStartup(i){const p=t(14),{onDone:a}=i,[f,_]=s(!1);let h,k;if(p[0]===Symbol.for("react.memo_cache_sentinel")?(h=[],p[0]=h):h=p[0],n(_temp,h),f){let o;return p[1]!==a?(o=e(u,{onDone:()=>a()}),p[1]=a,p[2]=o):o=p[2],o}p[3]!==a?(k=function(e){switch(e){case"try":return void _(!0);case"never":return c(_temp2),void a();case"not-now":return void a()}},p[3]=a,p[4]=k):k=p[4];const g=k;let C,D,S;p[5]===Symbol.for("react.memo_cache_sentinel")?(C={label:"Abrir en Context Code Desktop",value:"try"},p[5]=C):C=p[5],p[6]===Symbol.for("react.memo_cache_sentinel")?(D={label:"Ahora no",value:"not-now"},p[6]=D):D=p[6],p[7]===Symbol.for("react.memo_cache_sentinel")?(S=[C,D,{label:"Don't ask again",value:"never"}],p[7]=S):S=p[7];const b=S;let v,x,w;return p[8]===Symbol.for("react.memo_cache_sentinel")?(v=e(r,{marginBottom:1,children:e(l,{children:"Same Context Code with visual diffs, live app preview, parallel sessions, and more."})}),p[8]=v):v=p[8],p[9]!==g?(x=()=>g("not-now"),p[9]=g,p[10]=x):x=p[10],p[11]!==g||p[12]!==x?(w=e(d,{title:"Try Context Code Desktop",children:o(r,{flexDirection:"column",paddingX:2,paddingY:1,children:[v,e(m,{options:b,onChange:g,onCancel:x})]})}),p[11]=g,p[12]=x,p[13]=w):w=p[13],w}function _temp2(e){return e.desktopUpsellDismissed?e:{...e,desktopUpsellDismissed:!0}}function _temp(){const e=(a().desktopUpsellSeenCount??0)+1;c(o=>(o.desktopUpsellSeenCount??0)>=e?o:{...o,desktopUpsellSeenCount:e}),p("tengu_desktop_upsell_shown",{seen_count:e})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{join as r}from"path";import{useCallback as n,useState as i}from"react";import{useTerminalSize as t}from"../hooks/useTerminalSize.js";import{setClipboard as s}from"../ink/termio/osc.js";import{Box as a,Text as c}from"../ink.js";import{useKeybinding as l}from"../keybindings/useKeybinding.js";import{getCwd as m}from"../utils/cwd.js";import{writeFileSync_DEPRECATED as p}from"../utils/slowOperations.js";import{ConfigurableShortcutHint as u}from"./ConfigurableShortcutHint.js";import{Select as f}from"./CustomSelect/select.js";import{Byline as d}from"./design-system/Byline.js";import{Dialog as g}from"./design-system/Dialog.js";import{KeyboardShortcutHint as h}from"./design-system/KeyboardShortcutHint.js";import x from"./TextInput.js";export function ExportDialog({content:C,defaultFilename:v,onDone:j}){const[,b]=i(null),[y,E]=i(v),[k,S]=i(v.length),[w,D]=i(!1),{columns:G}=t(),O=n(()=>{D(!1),b(null)},[]),T=n(()=>{w?O():j({success:!1,message:"Exportación cancelada"})},[w,O,j]);return l("confirm:no",T,{context:"Settings",isActive:w}),e(g,{title:"Export Conversation",subtitle:"Select export method:",color:"permission",onCancel:T,inputGuide:function(r){return w?o(d,{children:[e(h,{shortcut:"Enter",action:"guardar"}),e(u,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"volver"})]}):r.pending?o(c,{children:["Presiona ",r.keyName," de nuevo para salir"]}):e(u,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})},isCancelActive:!w,children:w?o(a,{flexDirection:"column",children:[e(c,{children:"Enter filename:"}),o(a,{flexDirection:"row",gap:1,marginTop:1,children:[e(c,{children:">"}),e(x,{value:y,onChange:E,onSubmit:()=>{const e=y.endsWith(".txt")?y:y.replace(/\.[^.]+$/,"")+".txt",o=r(m(),e);try{p(o,C,{encoding:"utf-8",flush:!0}),j({success:!0,message:`Conversación exportada a: ${o}`})}catch(e){j({success:!1,message:`Error al exportar la conversación: ${e instanceof Error?e.message:"Error desconocido"}`})}},focus:!0,showCursor:!0,columns:G,cursorOffset:k,onChangeCursorOffset:S})]})]}):e(f,{options:[{label:"Copiar al portapapeles",value:"clipboard",description:"Copiar la conversación al portapapeles del sistema"},{label:"Guardar en archivo",value:"file",description:"Guardar la conversación en un archivo en el directorio actual"}],onChange:async e=>{if("clipboard"===e){const e=await s(C);e&&process.stdout.write(e),j({success:!0,message:"Conversación copiada al portapapeles"})}else"file"===e&&(b("file"),D(!0))},onCancel:T})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MACRO as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as r}from"react/jsx-runtime";import n from"axios";import{readFile as o,stat as i}from"fs/promises";import{useCallback as s,useEffect as a,useState as c}from"react";import{getLastAPIRequest as l}from"../bootstrap/state.js";import{logEventTo1P as u}from"../services/analytics/firstPartyEventLogger.js";import{logEvent as d}from"../services/analytics/index.js";import{getLastAssistantMessage as m,normalizeMessagesForAPI as p}from"../utils/messages.js";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{Box as f,Text as h,useInput as b}from"../ink.js";import{useKeybinding as E}from"../keybindings/useKeybinding.js";import{queryHaiku as y}from"../services/api/claude.js";import{startsWithApiErrorPrefix as A}from"../services/api/errors.js";import{checkAndRefreshOAuthTokenIfNeeded as k}from"../utils/auth.js";import{openBrowser as I}from"../utils/browser.js";import{logForDebugging as C}from"../utils/debug.js";import{env as S}from"../utils/env.js";import{getGitState as _,getIsGit as T}from"../utils/git.js";import{getAuthHeaders as D,getUserAgent as R}from"../utils/http.js";import{getInMemoryErrors as v,logError as w}from"../utils/log.js";import{isEssentialTrafficOnly as x}from"../utils/privacyLevel.js";import{extractTeammateTranscriptsFromTasks as j,getTranscriptPath as z,loadAllSubagentTranscriptsFromDisk as P,MAX_TRANSCRIPT_READ_BYTES as O}from"../utils/sessionStorage.js";import{jsonStringify as F}from"../utils/slowOperations.js";import{asSystemPrompt as G}from"../utils/systemPromptType.js";import{ConfigurableShortcutHint as L}from"./ConfigurableShortcutHint.js";import{Byline as U}from"./design-system/Byline.js";import{Dialog as B}from"./design-system/Dialog.js";import{KeyboardShortcutHint as Z}from"./design-system/KeyboardShortcutHint.js";import $ from"./TextInput.js";export function redactSensitiveInfo(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,'"[REDACTED_API_KEY]"'),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,"[REDACTED_API_KEY]"),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,'AWS key: "[REDACTED_AWS_KEY]"'),t=t.replace(/(AKIA[A-Z0-9]{16})/g,"[REDACTED_AWS_KEY]"),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,"[REDACTED_GCP_KEY]"),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,"[REDACTED_GCP_SERVICE_ACCOUNT]"),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,"$1[REDACTED_API_KEY]"),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,"$1[REDACTED_TOKEN]"),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_AWS_VALUE]"),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_GCP_VALUE]"),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED]"),t}function getSanitizedErrorLogs(){return v().map(e=>{const t={...e};return t&&"string"==typeof t.error&&(t.error=redactSensitiveInfo(t.error)),t})}async function loadRawTranscriptJsonl(){try{const e=z(),{size:t}=await i(e);return t>O?(C(`Skipping raw transcript read: file too large (${t} bytes)`,{level:"warn"}),null):await o(e,"utf-8")}catch{return null}}export function Feedback({abortSignal:n,messages:o,initialDescription:i,onDone:y,backgroundTasks:A={}}){const[k,C]=c("userInput"),[D,R]=c(0),[v,w]=c(i??""),[x,z]=c(null),[O,F]=c(null),[G,K]=c({isGit:!1,gitState:null}),[N,H]=c(null),W=g().columns-4;a(()=>{!async function(){const e=await T();let t=null;e&&(t=await _()),K({isGit:e,gitState:t})}()},[]);const Y=s(async()=>{C("submitting"),F(null),z(null);const t=getSanitizedErrorLogs(),r=m(o),i=r?.requestId??null,[s,a]=await Promise.all([P(),loadRawTranscriptJsonl()]),c={...s,...j(A)},g={latestAssistantMessageId:i,message_count:o.length,datetime:(new Date).toISOString(),description:v,platform:S.platform,gitRepo:G.isGit,terminal:S.terminal,version:e.VERSION,transcript:p(o),errors:t,lastApiRequest:l(),...Object.keys(c).length>0&&{subagentTranscripts:c},...a&&{rawTranscriptJsonl:a}},[f,h]=await Promise.all([submitFeedback(g,n),generateTitle(v,n)]);H(h),f.success?(f.feedbackId&&(z(f.feedbackId),d("tengu_bug_report_submitted",{feedback_id:f.feedbackId,last_assistant_message_id:i}),u("tengu_bug_report_description",{feedback_id:f.feedbackId,description:redactSensitiveInfo(v)})),C("done")):(f.isZdrOrg?F("Feedback collection is not available for organizations with custom data retention policies."):F("Could not submit feedback. Please try again later."),C("userInput"))},[v,G.isGit,o]),V=s(()=>{y("done"!==k?"Feedback / bug report cancelled":O?"Error submitting feedback / bug report":"Feedback / bug report submitted",{display:"system"})},[k,O,y]);return E("confirm:no",V,{context:"Settings",isActive:"userInput"===k}),b((e,t)=>{if("done"!==k)O&&"userInput"!==k?y("Error submitting feedback / bug report",{display:"system"}):"consent"!==k||!t.return&&" "!==e||Y();else{if(t.return&&N){const e=createGitHubIssueUrl(x??"",N,v,getSanitizedErrorLogs());I(e)}y(O?"Error submitting feedback / bug report":"Feedback / bug report submitted",{display:"system"})}}),r(B,{title:"Submit Feedback / Bug Report",onCancel:V,isCancelActive:"userInput"!==k,inputGuide:e=>e.pending?r(h,{children:["Presiona ",e.keyName," de nuevo para salir"]}):"userInput"===k?r(U,{children:[t(Z,{shortcut:"Enter",action:"continuar"}),t(L,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]}):"consent"===k?r(U,{children:[t(Z,{shortcut:"Enter",action:"enviar"}),t(L,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]}):null,children:["userInput"===k&&r(f,{flexDirection:"column",gap:1,children:[t(h,{children:"Describe the issue below:"}),t($,{value:v,onChange:e=>{w(e),O&&F(null)},columns:W,onSubmit:()=>C("consent"),onExitMessage:()=>y("Feedback cancelled",{display:"system"}),cursorOffset:D,onChangeCursorOffset:R,showCursor:!0}),O&&r(f,{flexDirection:"column",gap:1,children:[t(h,{color:"error",children:O}),t(h,{dimColor:!0,children:"Editar y presionar Enter para reintentar, o Esc para cancelar"})]})]}),"consent"===k&&r(f,{flexDirection:"column",children:[t(h,{children:"This report will include:"}),r(f,{marginLeft:2,flexDirection:"column",children:[r(h,{children:["- Your feedback / bug description:"," ",t(h,{dimColor:!0,children:v})]}),r(h,{children:["- Environment info:"," ",r(h,{dimColor:!0,children:[S.platform,", ",S.terminal,", v",e.VERSION]})]}),G.gitState&&r(h,{children:["- Git repo metadata:"," ",r(h,{dimColor:!0,children:[G.gitState.branchName,G.gitState.commitHash?`, ${G.gitState.commitHash.slice(0,7)}`:"",G.gitState.remoteUrl?` @ ${G.gitState.remoteUrl}`:"",!G.gitState.isHeadOnRemote&&", not synced",!G.gitState.isClean&&", has local changes"]})]}),t(h,{children:"- Current session transcript"})]}),t(f,{marginTop:1,children:r(h,{wrap:"wrap",dimColor:!0,children:["We will use your feedback to debug related issues or to improve"," ","Context Code's functionality (eg. to reduce the risk of bugs occurring in the future)."]})}),t(f,{marginTop:1,children:r(h,{children:["Press ",t(h,{bold:!0,children:"Enter"})," to confirm and submit."]})})]}),"submitting"===k&&t(f,{flexDirection:"row",gap:1,children:t(h,{children:"Submitting report…"})}),"done"===k&&r(f,{flexDirection:"column",children:[t(h,O?{color:"error",children:O}:{color:"success",children:"Thank you for your report!"}),x&&r(h,{dimColor:!0,children:["Feedback ID: ",x]}),r(f,{marginTop:1,children:[t(h,{children:"Press "}),t(h,{bold:!0,children:"Enter "}),t(h,{children:"to open your browser and draft a GitHub issue, or any other key to close."})]})]})]})}export function createGitHubIssueUrl(t,r,n,o){const i=redactSensitiveInfo(r),s=`**Bug Description**\n${redactSensitiveInfo(n)}\n\n**Environment Info**\n- Platform: ${S.platform}\n- Terminal: ${S.terminal}\n- Version: ${e.VERSION||"unknown"}\n- Feedback ID: ${t}\n\n**Errors**\n\`\`\`json\n`,a="\n```\n",c=F(o),l=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent(i)}&labels=user-reported,bug&body=`,u=encodeURIComponent(s),d=encodeURIComponent(a),m=encodeURIComponent("\n**Note:** Content was truncated.\n"),p=encodeURIComponent(c),g=7250-l.length-u.length-d.length-m.length;if(g<=0){const e=encodeURIComponent("…"),t=50,r=7250-l.length-e.length-m.length-t;let n=encodeURIComponent(s+c+a);if(n.length>r){n=n.slice(0,r);const e=n.lastIndexOf("%");e>=n.length-2&&(n=n.slice(0,e))}return l+n+e+m}if(p.length<=g)return l+u+p+d;const f=encodeURIComponent("…");let h=p.slice(0,g-f.length-50);const b=h.lastIndexOf("%");return b>=h.length-2&&(h=h.slice(0,b)),l+u+h+f+d+m}async function generateTitle(e,t){try{const r=await y({systemPrompt:G(["Generate a concise, technical issue title (max 80 chars) for a public GitHub issue based on this bug report for Context Code.","Context Code is an agentic coding CLI based on the Anthropic API.","The title should:","- Include the type of issue [Bug] or [Feature Request] as the first thing in the title","- Be concise, specific and descriptive of the actual problem","- Use technical terminology appropriate for a software issue",'- For error messages, extract the key error (e.g., "Missing Tool Result Block" rather than the full message)',"- Be direct and clear for developers to understand the problem",'- If you cannot determine a clear issue, use "Bug Report: [brief description]"',"- Any LLM API errors are from the Anthropic API, not from any other model provider","Your response will be directly used as the title of the Github issue, and as such should not contain any other commentary or explaination",'Examples of good titles include: "[Bug] Auto-Compact triggers to soon", "[Bug] Anthropic API Error: Missing Tool Result Block", "[Bug] Error: Invalid Model Name for Opus"']),userPrompt:e,signal:t,options:{hasAppendSystemPrompt:!1,toolChoice:void 0,isNonInteractiveSession:!1,agents:[],querySource:"feedback",mcpTools:[]}}),n="text"===r.message.content[0]?.type?r.message.content[0].text:"Bug Report";return A(n)?createFallbackTitle(e):n}catch(t){return w(t),createFallbackTitle(e)}}function createFallbackTitle(e){const t=e.split("\n")[0]||"";if(t.length<=60&&t.length>5)return t;let r=t.slice(0,60);if(t.length>60){const e=r.lastIndexOf(" ");e>30&&(r=r.slice(0,e)),r+="..."}return r.length<10?"Bug Report":r}function sanitizeAndLogError(e){if(e instanceof Error){const t=new Error(redactSensitiveInfo(e.message));e.stack&&(t.stack=redactSensitiveInfo(e.stack)),w(t)}else{const t=redactSensitiveInfo(String(e));w(new Error(t))}}async function submitFeedback(e,t){if(x())return{success:!1};try{await k();const r=D();if(r.error)return{success:!1};const o={"Content-Type":"application/json","User-Agent":R(),...r.headers},i=await n.post("https://api.anthropic.com/api/claude_cli_feedback",{content:F(e)},{headers:o,timeout:3e4,signal:t});if(200===i.status){const e=i.data;return e?.feedback_id?{success:!0,feedbackId:e.feedback_id}:(sanitizeAndLogError(new Error("Failed to submit feedback: request did not return feedback_id")),{success:!1})}return sanitizeAndLogError(new Error("Failed to submit feedback:"+i.status)),{success:!1}}catch(e){if(n.isCancel(e))return{success:!1};if(n.isAxiosError(e)&&403===e.response?.status){const t=e.response.data;if("permission_error"===t?.error?.type&&t?.error?.message?.includes("Custom data retention settings"))return sanitizeAndLogError(new Error("Cannot submit feedback because custom data retention settings are enabled")),{success:!1,isZdrOrg:!0}}return sanitizeAndLogError(e),{success:!1}}}
|
|
1
|
+
import{MACRO as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as r}from"react/jsx-runtime";import n from"axios";import{readFile as o,stat as i}from"fs/promises";import{useCallback as s,useEffect as a,useState as c}from"react";import{getLastAPIRequest as l}from"../bootstrap/state.js";import{logEventTo1P as u}from"../services/analytics/firstPartyEventLogger.js";import{logEvent as d}from"../services/analytics/index.js";import{getLastAssistantMessage as m,normalizeMessagesForAPI as p}from"../utils/messages.js";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{Box as f,Text as h,useInput as b}from"../ink.js";import{useKeybinding as E}from"../keybindings/useKeybinding.js";import{queryHaiku as A}from"../services/api/claude.js";import{startsWithApiErrorPrefix as I}from"../services/api/errors.js";import{checkAndRefreshOAuthTokenIfNeeded as y}from"../utils/auth.js";import{openBrowser as C}from"../utils/browser.js";import{logForDebugging as k}from"../utils/debug.js";import{env as S}from"../utils/env.js";import{getGitState as _,getIsGit as T}from"../utils/git.js";import{getAuthHeaders as R,getUserAgent as D}from"../utils/http.js";import{getInMemoryErrors as v,logError as j}from"../utils/log.js";import{isEssentialTrafficOnly as w}from"../utils/privacyLevel.js";import{extractTeammateTranscriptsFromTasks as x,getTranscriptPath as z,loadAllSubagentTranscriptsFromDisk as P,MAX_TRANSCRIPT_READ_BYTES as O}from"../utils/sessionStorage.js";import{jsonStringify as G}from"../utils/slowOperations.js";import{asSystemPrompt as U}from"../utils/systemPromptType.js";import{ConfigurableShortcutHint as L}from"./ConfigurableShortcutHint.js";import{Byline as F}from"./design-system/Byline.js";import{Dialog as B}from"./design-system/Dialog.js";import{KeyboardShortcutHint as Z}from"./design-system/KeyboardShortcutHint.js";import $ from"./TextInput.js";export function redactSensitiveInfo(e){let t=e;return t=t.replace(/"(sk-ant[^\s"']{24,})"/g,'"[REDACTED_API_KEY]"'),t=t.replace(/(?<![A-Za-z0-9"'])(sk-ant-?[A-Za-z0-9_-]{10,})(?![A-Za-z0-9"'])/g,"[REDACTED_API_KEY]"),t=t.replace(/AWS key: "(AWS[A-Z0-9]{20,})"/g,'AWS key: "[REDACTED_AWS_KEY]"'),t=t.replace(/(AKIA[A-Z0-9]{16})/g,"[REDACTED_AWS_KEY]"),t=t.replace(/(?<![A-Za-z0-9])(AIza[A-Za-z0-9_-]{35})(?![A-Za-z0-9])/g,"[REDACTED_GCP_KEY]"),t=t.replace(/(?<![A-Za-z0-9])([a-z0-9-]+@[a-z0-9-]+\.iam\.gserviceaccount\.com)(?![A-Za-z0-9])/g,"[REDACTED_GCP_SERVICE_ACCOUNT]"),t=t.replace(/(["']?x-api-key["']?\s*[:=]\s*["']?)[^"',\s)}\]]+/gi,"$1[REDACTED_API_KEY]"),t=t.replace(/(["']?authorization["']?\s*[:=]\s*["']?(bearer\s+)?)[^"',\s)}\]]+/gi,"$1[REDACTED_TOKEN]"),t=t.replace(/(AWS[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_AWS_VALUE]"),t=t.replace(/(GOOGLE[_-][A-Za-z0-9_]+\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED_GCP_VALUE]"),t=t.replace(/((API[-_]?KEY|TOKEN|SECRET|PASSWORD)\s*[=:]\s*)["']?[^"',\s)}\]]+["']?/gi,"$1[REDACTED]"),t}function getSanitizedErrorLogs(){return v().map(e=>{const t={...e};return t&&"string"==typeof t.error&&(t.error=redactSensitiveInfo(t.error)),t})}async function loadRawTranscriptJsonl(){try{const e=z(),{size:t}=await i(e);return t>O?(k(`Skipping raw transcript read: file too large (${t} bytes)`,{level:"warn"}),null):await o(e,"utf-8")}catch{return null}}export function Feedback({abortSignal:n,messages:o,initialDescription:i,onDone:A,backgroundTasks:I={}}){const[y,k]=c("userInput"),[R,D]=c(0),[v,j]=c(i??""),[w,z]=c(null),[O,G]=c(null),[U,K]=c({isGit:!1,gitState:null}),[N,H]=c(null),W=g().columns-4;a(()=>{!async function(){const e=await T();let t=null;e&&(t=await _()),K({isGit:e,gitState:t})}()},[]);const Y=s(async()=>{k("submitting"),G(null),z(null);const t=getSanitizedErrorLogs(),r=m(o),i=r?.requestId??null,[s,a]=await Promise.all([P(),loadRawTranscriptJsonl()]),c={...s,...x(I)},g={latestAssistantMessageId:i,message_count:o.length,datetime:(new Date).toISOString(),description:v,platform:S.platform,gitRepo:U.isGit,terminal:S.terminal,version:e.VERSION,transcript:p(o),errors:t,lastApiRequest:l(),...Object.keys(c).length>0&&{subagentTranscripts:c},...a&&{rawTranscriptJsonl:a}},[f,h]=await Promise.all([submitFeedback(g,n),generateTitle(v,n)]);H(h),f.success?(f.feedbackId&&(z(f.feedbackId),d("tengu_bug_report_submitted",{feedback_id:f.feedbackId,last_assistant_message_id:i}),u("tengu_bug_report_description",{feedback_id:f.feedbackId,description:redactSensitiveInfo(v)})),k("done")):(f.isZdrOrg?G("Feedback collection is not available for organizations with custom data retention policies."):G("Could not submit feedback. Please try again later."),k("userInput"))},[v,U.isGit,o]),M=s(()=>{A("done"!==y?"Feedback / bug report cancelled":O?"Error submitting feedback / bug report":"Feedback / bug report submitted",{display:"system"})},[y,O,A]);return E("confirm:no",M,{context:"Settings",isActive:"userInput"===y}),b((e,t)=>{if("done"!==y)O&&"userInput"!==y?A("Error submitting feedback / bug report",{display:"system"}):"consent"!==y||!t.return&&" "!==e||Y();else{if(t.return&&N){const e=createGitHubIssueUrl(w??"",N,v,getSanitizedErrorLogs());C(e)}A(O?"Error submitting feedback / bug report":"Feedback / bug report submitted",{display:"system"})}}),r(B,{title:"Submit Feedback / Bug Report",onCancel:M,isCancelActive:"userInput"!==y,inputGuide:e=>e.pending?r(h,{children:["Presiona ",e.keyName," de nuevo para salir"]}):"userInput"===y?r(F,{children:[t(Z,{shortcut:"Enter",action:"continuar"}),t(L,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]}):"consent"===y?r(F,{children:[t(Z,{shortcut:"Enter",action:"enviar"}),t(L,{action:"confirm:no",context:"Confirmation",fallback:"Esc",description:"cancelar"})]}):null,children:["userInput"===y&&r(f,{flexDirection:"column",gap:1,children:[t(h,{children:"Describe el problema abajo:"}),t($,{value:v,onChange:e=>{j(e),O&&G(null)},columns:W,onSubmit:()=>k("consent"),onExitMessage:()=>A("Retroalimentación cancelada",{display:"system"}),cursorOffset:R,onChangeCursorOffset:D,showCursor:!0}),O&&r(f,{flexDirection:"column",gap:1,children:[t(h,{color:"error",children:O}),t(h,{dimColor:!0,children:"Editar y presionar Enter para reintentar, o Esc para cancelar"})]})]}),"consent"===y&&r(f,{flexDirection:"column",children:[t(h,{children:"Este reporte incluirá:"}),r(f,{marginLeft:2,flexDirection:"column",children:[r(h,{children:["- Tu retroalimentación / descripción del bug:"," ",t(h,{dimColor:!0,children:v})]}),r(h,{children:["- Información del entorno:"," ",r(h,{dimColor:!0,children:[S.platform,", ",S.terminal,", v",e.VERSION]})]}),U.gitState&&r(h,{children:["- Metadatos del repo Git:"," ",r(h,{dimColor:!0,children:[U.gitState.branchName,U.gitState.commitHash?`, ${U.gitState.commitHash.slice(0,7)}`:"",U.gitState.remoteUrl?` @ ${U.gitState.remoteUrl}`:"",!U.gitState.isHeadOnRemote&&", no sincronizado",!U.gitState.isClean&&", tiene cambios locales"]})]}),t(h,{children:"- Transcripción de la sesión actual"})]}),t(f,{marginTop:1,children:r(h,{wrap:"wrap",dimColor:!0,children:["Usaremos tu retroalimentación para depurar problemas relacionados o mejorar"," ","la funcionalidad de Context Code (p. ej. reducir el riesgo de que ocurran bugs en el futuro)."]})}),t(f,{marginTop:1,children:r(h,{children:["Presiona ",t(h,{bold:!0,children:"Enter"})," para confirmar y enviar."]})})]}),"submitting"===y&&t(f,{flexDirection:"row",gap:1,children:t(h,{children:"Enviando reporte…"})}),"done"===y&&r(f,{flexDirection:"column",children:[t(h,O?{color:"error",children:O}:{color:"success",children:"¡Gracias por tu reporte!"}),w&&r(h,{dimColor:!0,children:["ID de retroalimentación: ",w]}),r(f,{marginTop:1,children:[t(h,{children:"Presiona "}),t(h,{bold:!0,children:"Enter "}),t(h,{children:"to open your browser and draft a GitHub issue, or any other key to close."})]})]})]})}export function createGitHubIssueUrl(t,r,n,o){const i=redactSensitiveInfo(r),s=`**Bug Description**\n${redactSensitiveInfo(n)}\n\n**Environment Info**\n- Platform: ${S.platform}\n- Terminal: ${S.terminal}\n- Version: ${e.VERSION||"unknown"}\n- Feedback ID: ${t}\n\n**Errors**\n\`\`\`json\n`,a="\n```\n",c=G(o),l=`https://github.com/anthropics/claude-code/issues/new?title=${encodeURIComponent(i)}&labels=user-reported,bug&body=`,u=encodeURIComponent(s),d=encodeURIComponent(a),m=encodeURIComponent("\n**Note:** Content was truncated.\n"),p=encodeURIComponent(c),g=7250-l.length-u.length-d.length-m.length;if(g<=0){const e=encodeURIComponent("…"),t=50,r=7250-l.length-e.length-m.length-t;let n=encodeURIComponent(s+c+a);if(n.length>r){n=n.slice(0,r);const e=n.lastIndexOf("%");e>=n.length-2&&(n=n.slice(0,e))}return l+n+e+m}if(p.length<=g)return l+u+p+d;const f=encodeURIComponent("…");let h=p.slice(0,g-f.length-50);const b=h.lastIndexOf("%");return b>=h.length-2&&(h=h.slice(0,b)),l+u+h+f+d+m}async function generateTitle(e,t){try{const r=await A({systemPrompt:U(["Generate a concise, technical issue title (max 80 chars) for a public GitHub issue based on this bug report for Context Code.","Context Code is an agentic coding CLI based on the Anthropic API.","The title should:","- Include the type of issue [Bug] or [Feature Request] as the first thing in the title","- Be concise, specific and descriptive of the actual problem","- Use technical terminology appropriate for a software issue",'- For error messages, extract the key error (e.g., "Missing Tool Result Block" rather than the full message)',"- Be direct and clear for developers to understand the problem",'- If you cannot determine a clear issue, use "Bug Report: [brief description]"',"- Any LLM API errors are from the Anthropic API, not from any other model provider","Your response will be directly used as the title of the Github issue, and as such should not contain any other commentary or explaination",'Examples of good titles include: "[Bug] Auto-Compact triggers to soon", "[Bug] Anthropic API Error: Missing Tool Result Block", "[Bug] Error: Invalid Model Name for Opus"']),userPrompt:e,signal:t,options:{hasAppendSystemPrompt:!1,toolChoice:void 0,isNonInteractiveSession:!1,agents:[],querySource:"feedback",mcpTools:[]}}),n="text"===r.message.content[0]?.type?r.message.content[0].text:"Bug Report";return I(n)?createFallbackTitle(e):n}catch(t){return j(t),createFallbackTitle(e)}}function createFallbackTitle(e){const t=e.split("\n")[0]||"";if(t.length<=60&&t.length>5)return t;let r=t.slice(0,60);if(t.length>60){const e=r.lastIndexOf(" ");e>30&&(r=r.slice(0,e)),r+="..."}return r.length<10?"Bug Report":r}function sanitizeAndLogError(e){if(e instanceof Error){const t=new Error(redactSensitiveInfo(e.message));e.stack&&(t.stack=redactSensitiveInfo(e.stack)),j(t)}else{const t=redactSensitiveInfo(String(e));j(new Error(t))}}async function submitFeedback(e,t){if(w())return{success:!1};try{await y();const r=R();if(r.error)return{success:!1};const o={"Content-Type":"application/json","User-Agent":D(),...r.headers},i=await n.post("https://api.anthropic.com/api/claude_cli_feedback",{content:G(e)},{headers:o,timeout:3e4,signal:t});if(200===i.status){const e=i.data;return e?.feedback_id?{success:!0,feedbackId:e.feedback_id}:(sanitizeAndLogError(new Error("Failed to submit feedback: request did not return feedback_id")),{success:!1})}return sanitizeAndLogError(new Error("Failed to submit feedback:"+i.status)),{success:!1}}catch(e){if(n.isCancel(e))return{success:!1};if(n.isAxiosError(e)&&403===e.response?.status){const t=e.response.data;if("permission_error"===t?.error?.type&&t?.error?.message?.includes("Custom data retention settings"))return sanitizeAndLogError(new Error("Cannot submit feedback because custom data retention settings are enabled")),{success:!1,isZdrOrg:!0}}return sanitizeAndLogError(e),{success:!1}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import{logEvent as r}from"../../services/analytics/index.js";import{Box as s,Text as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import{logEvent as r}from"../../services/analytics/index.js";import{Box as s,Text as i}from"../../ink.js";import{FeedbackSurveyView as o,isValidResponseInput as l}from"./FeedbackSurveyView.js";import{TranscriptSharePrompt as a}from"./TranscriptSharePrompt.js";import{useDebouncedDigitInput as c}from"./useDebouncedDigitInput.js";export function FeedbackSurvey(r){const c=n(16),{state:u,lastResponse:m,handleSelect:p,handleTranscriptSelect:d,inputValue:f,setInputValue:h,onRequestFeedback:b,message:k}=r;if("closed"===u)return null;if("thanks"===u){let t;return c[0]!==f||c[1]!==m||c[2]!==b||c[3]!==h?(t=e(FeedbackSurveyThanks,{lastResponse:m,inputValue:f,setInputValue:h,onRequestFeedback:b}),c[0]=f,c[1]=m,c[2]=b,c[3]=h,c[4]=t):t=c[4],t}if("submitted"===u){let n;return c[5]===Symbol.for("react.memo_cache_sentinel")?(n=e(s,{marginTop:1,children:t(i,{color:"success",children:["✓"," Thanks for sharing your transcript!"]})}),c[5]=n):n=c[5],n}if("submitting"===u){let n;return c[6]===Symbol.for("react.memo_cache_sentinel")?(n=e(s,{marginTop:1,children:t(i,{dimColor:!0,children:["Sharing transcript","…"]})}),c[6]=n):n=c[6],n}if("transcript_prompt"===u){if(!d)return null;if(f&&!["1","2","3"].includes(f))return null;let t;return c[7]!==d||c[8]!==f||c[9]!==h?(t=e(a,{onSelect:d,inputValue:f,setInputValue:h}),c[7]=d,c[8]=f,c[9]=h,c[10]=t):t=c[10],t}if(f&&!l(f))return null;let V;return c[11]!==p||c[12]!==f||c[13]!==k||c[14]!==h?(V=e(o,{onSelect:p,inputValue:f,setInputValue:h,message:k}),c[11]=p,c[12]=f,c[13]=k,c[14]=h,c[15]=V):V=c[15],V}const isFollowUpDigit=e=>"1"===e;function FeedbackSurveyThanks(o){const l=n(12),{lastResponse:a,inputValue:u,setInputValue:m,onRequestFeedback:p}=o,d=p&&"good"===a,f=Boolean(d);let h,b;l[0]!==a||l[1]!==p?(h=()=>{r("tengu_feedback_survey_event",{event_type:"followup_accepted",response:a}),p?.()},l[0]=a,l[1]=p,l[2]=h):h=l[2],l[3]!==u||l[4]!==m||l[5]!==f||l[6]!==h?(b={inputValue:u,setInputValue:m,isValidDigit:isFollowUpDigit,enabled:f,once:!0,onDigit:h},l[3]=u,l[4]=m,l[5]=f,l[6]=h,l[7]=b):b=l[7],c(b);const k="/feedback";let V,g;return l[8]===Symbol.for("react.memo_cache_sentinel")?(V=e(i,{color:"success",children:"¡Gracias por la retroalimentación!"}),l[8]=V):V=l[8],l[9]!==a||l[10]!==d?(g=t(s,{marginTop:1,flexDirection:"column",children:[V,d?t(i,{dimColor:!0,children:["(Optional) Press [",e(i,{color:"ansi:cyan",children:"1"}),"] to tell us what went well "," · ",k]}):"bad"===a?e(i,{dimColor:!0,children:"Use /issue to report model behavior issues."}):t(i,{dimColor:!0,children:["Use ",k," to share detailed feedback anytime."]})]}),l[9]=a,l[10]=d,l[11]=g):g=l[11],g}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{c as i}from"react/compiler-runtime";import{Box as o,Text as c}from"../../ink.js";import{useDebouncedDigitInput as r}from"./useDebouncedDigitInput.js";const t=["0","1","2","3"],l={0:"dismissed",1:"bad",2:"fine",3:"good"};export const isValidResponseInput=e=>t.includes(e);export function FeedbackSurveyView(t){const s=i(15),{onSelect:a,inputValue:d,setInputValue:m,message:h}=t,u=void 0===h?"¿Cómo está Context en esta sesión? (opcional)":h;let p,f,y,_,b,V,g,x,S;return s[0]!==a?(p=e=>a(l[e]),s[0]=a,s[1]=p):p=s[1],s[2]!==d||s[3]!==m||s[4]!==p?(f={inputValue:d,setInputValue:m,isValidDigit:isValidResponseInput,onDigit:p},s[2]=d,s[3]=m,s[4]=p,s[5]=f):f=s[5],r(f),s[6]===Symbol.for("react.memo_cache_sentinel")?(y=e(c,{color:"ansi:cyan",children:"● "}),s[6]=y):y=s[6],s[7]!==u?(_=n(o,{children:[y,e(c,{bold:!0,children:u})]}),s[7]=u,s[8]=_):_=s[8],s[9]===Symbol.for("react.memo_cache_sentinel")?(b=e(o,{width:10,children:n(c,{children:[e(c,{color:"ansi:cyan",children:"1"}),": Bad"]})}),s[9]=b):b=s[9],s[10]===Symbol.for("react.memo_cache_sentinel")?(V=e(o,{width:10,children:n(c,{children:[e(c,{color:"ansi:cyan",children:"2"}),": Fine"]})}),s[10]=V):V=s[10],s[11]===Symbol.for("react.memo_cache_sentinel")?(g=e(o,{width:10,children:n(c,{children:[e(c,{color:"ansi:cyan",children:"3"}),": Good"]})}),s[11]=g):g=s[11],s[12]===Symbol.for("react.memo_cache_sentinel")?(x=n(o,{marginLeft:2,children:[b,V,g,e(o,{children:n(c,{children:[e(c,{color:"ansi:cyan",children:"0"}),": Dismiss"]})})]}),s[12]=x):x=s[12],s[13]!==_?(S=n(o,{flexDirection:"column",marginTop:1,children:[_,x]}),s[13]=_,s[14]=S):S=s[14],S}
|