@iaforged/context-code 2.3.1 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/context-bootstrap.js +7 -5
  2. package/dist/src/QueryEngine.js +1 -1
  3. package/dist/src/cli/handlers/auth.js +1 -1
  4. package/dist/src/cli/handlers/modelList.js +1 -1
  5. package/dist/src/cli/structuredIO.js +1 -1
  6. package/dist/src/commands/branch/index.js +1 -1
  7. package/dist/src/commands/login/login.js +1 -1
  8. package/dist/src/commands/profile/index.js +1 -1
  9. package/dist/src/commands/profile/profile.js +1 -1
  10. package/dist/src/commands/provider/index.js +1 -1
  11. package/dist/src/commands/provider/provider.js +1 -1
  12. package/dist/src/components/BaseTextInput.js +1 -1
  13. package/dist/src/components/ConsoleOAuthFlow.js +1 -1
  14. package/dist/src/components/LogoV2/AnimatedClawd.js +1 -1
  15. package/dist/src/components/LogoV2/Clawd.js +1 -1
  16. package/dist/src/components/LogoV2/LogoV2.js +1 -1
  17. package/dist/src/components/LogoV2/Opus1mMergeNotice.js +1 -1
  18. package/dist/src/components/LogoV2/WelcomeV2.js +1 -1
  19. package/dist/src/components/ModelPicker.js +1 -1
  20. package/dist/src/components/PromptInput/PromptInputFooterLeftSide.js +1 -1
  21. package/dist/src/components/SessionTokenFooter.js +1 -0
  22. package/dist/src/components/Spinner.js +1 -1
  23. package/dist/src/components/Stats.js +1 -1
  24. package/dist/src/components/TeleportProgress.js +1 -1
  25. package/dist/src/components/TextInput.js +1 -1
  26. package/dist/src/components/design-system/ThemeProvider.js +1 -1
  27. package/dist/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.js +1 -1
  28. package/dist/src/constants/oauth.js +1 -1
  29. package/dist/src/core/providers/providerCore.js +1 -1
  30. package/dist/src/hooks/useTypeahead.js +1 -1
  31. package/dist/src/main.js +1 -1
  32. package/dist/src/query/stopHooks.js +1 -1
  33. package/dist/src/screens/REPL.js +1 -1
  34. package/dist/src/services/PromptSuggestion/promptSuggestion.js +1 -1
  35. package/dist/src/services/analytics/config.js +1 -1
  36. package/dist/src/services/analytics/datadog.js +1 -1
  37. package/dist/src/services/api/openai.js +1 -1
  38. package/dist/src/services/mcp/config.js +1 -1
  39. package/dist/src/services/oauth/auth-code-listener.js +1 -1
  40. package/dist/src/services/oauth/client.js +1 -1
  41. package/dist/src/services/oauth/geminiCli.js +1 -1
  42. package/dist/src/services/tips/tipRegistry.js +1 -1
  43. package/dist/src/services/toolUseSummary/toolUseSummaryGenerator.js +1 -1
  44. package/dist/src/tools/BriefTool/UI.js +1 -1
  45. package/dist/src/utils/auth.js +1 -1
  46. package/dist/src/utils/claudeInChrome/setup.js +1 -1
  47. package/dist/src/utils/computerControlMcp/mcpServer.js +1 -1
  48. package/dist/src/utils/computerControlMcp/server/.gitattributes +18 -0
  49. package/dist/src/utils/computerControlMcp/server/Dockerfile +25 -0
  50. package/dist/src/utils/computerControlMcp/server/LICENSE +21 -0
  51. package/dist/src/utils/computerControlMcp/server/MANIFEST.in +10 -0
  52. package/dist/src/utils/computerControlMcp/server/README.md +193 -0
  53. package/dist/src/utils/computerControlMcp/server/demonstration.gif +0 -0
  54. package/dist/src/utils/computerControlMcp/server/icon.png +0 -0
  55. package/dist/src/utils/computerControlMcp/server/pyproject.toml +52 -0
  56. package/dist/src/utils/computerControlMcp/server/smithery.yaml +13 -0
  57. package/dist/src/utils/computerControlMcp/server/src/README.md +12 -0
  58. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/FZYTK.TTF +0 -0
  59. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/__init__.py +11 -0
  60. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/__main__.py +21 -0
  61. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/cli.py +128 -0
  62. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/core.py +1008 -0
  63. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/gui.py +126 -0
  64. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/server.py +15 -0
  65. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/test.py +346 -0
  66. package/dist/src/utils/computerControlMcp/server/src/computer_control_mcp/test_image.png +0 -0
  67. package/dist/src/utils/computerControlMcp/server/tests/README.md +22 -0
  68. package/dist/src/utils/computerControlMcp/server/tests/conftest.py +10 -0
  69. package/dist/src/utils/computerControlMcp/server/tests/rapidocr_test.py +21 -0
  70. package/dist/src/utils/computerControlMcp/server/tests/run_cli.py +9 -0
  71. package/dist/src/utils/computerControlMcp/server/tests/run_server.py +15 -0
  72. package/dist/src/utils/computerControlMcp/server/tests/setup.py +16 -0
  73. package/dist/src/utils/computerControlMcp/server/tests/test_computer_control.py +161 -0
  74. package/dist/src/utils/computerControlMcp/server/tests/test_screenshot.py +14 -0
  75. package/dist/src/utils/computerControlMcp/server/tests/test_wgc_env_var.py +42 -0
  76. package/dist/src/utils/computerControlMcp/server/tests/test_wgc_screenshot.py +67 -0
  77. package/dist/src/utils/computerControlMcp/server/uv.lock +4986 -0
  78. package/dist/src/utils/computerControlMcp/setup.js +1 -1
  79. package/dist/src/utils/envUtils.js +1 -1
  80. package/dist/src/utils/git.js +1 -1
  81. package/dist/src/utils/localInstaller.js +1 -1
  82. package/dist/src/utils/logoV2Utils.js +1 -1
  83. package/dist/src/utils/model/configs.js +1 -1
  84. package/dist/src/utils/model/model.js +1 -1
  85. package/dist/src/utils/model/modelAllowlist.js +1 -1
  86. package/dist/src/utils/model/modelOptions.js +1 -1
  87. package/dist/src/utils/model/providerBaseUrls.js +1 -1
  88. package/dist/src/utils/model/providerCatalog.js +1 -1
  89. package/dist/src/utils/model/providerModels.js +1 -1
  90. package/dist/src/utils/model/providerProfiles.js +1 -1
  91. package/dist/src/utils/model/providerProfilesDb.js +1 -1
  92. package/dist/src/utils/model/providers.js +1 -1
  93. package/dist/src/utils/model/validateModel.js +1 -1
  94. package/dist/src/utils/ripgrep.js +1 -1
  95. package/dist/src/utils/sembleMcp/setup.js +1 -1
  96. package/dist/src/utils/theme.js +1 -1
  97. package/dist/src/utils/themes/bootstrap.js +1 -1
  98. package/dist/src/utils/themes/opencodeMapper.js +1 -1
  99. package/dist/webapp/chunk-VAB2VXFI.js +1 -1
  100. package/dist/webapp/main-MTQLKGXD.js +1 -1
  101. package/dist/webapp/ngsw.json +1 -1
  102. package/dist/webapp/polyfills-7R4CRVNH.js +1 -1
  103. package/package.json +1 -1
@@ -1 +1 @@
1
- import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import{c as i}from"react/compiler-runtime";import{useCallback as t,useEffect as n,useRef as a,useState as s}from"react";import{logEvent as l}from"../services/analytics/index.js";import{installOAuthTokens as d}from"../cli/handlers/auth.js";import{useTerminalSize as c}from"../hooks/useTerminalSize.js";import{setClipboard as u}from"../ink/termio/osc.js";import{useTerminalNotification as p}from"../ink/useTerminalNotification.js";import{Box as m,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 C}from"../services/oauth/index.js";import{getOAuthRequestDetails as y}from"../services/oauth/client.js";import{checkGeminiGoogleCredentialsValid as b,getOauthAccountInfo as A,saveGeminiGoogleOAuthTokens as k,saveProviderApiKey as P,validateForceLoginOrg as x}from"../utils/auth.js";import{startGeminiCliOAuthFlow as O}from"../services/oauth/geminiCli.js";import{ensureProviderProfile as I,isProfiledProvider as S,resolveProviderProfile as w,setActiveProviderProfile as z,setProviderProfileLastModel as D}from"../utils/model/providerProfiles.js";import{setStoredActiveProviderPreference as M,setStoredLastModelForProvider as T}from"../utils/model/providerProfilesDb.js";import{logError as j}from"../utils/log.js";import{getVisibleProvider as E}from"../utils/model/providerCatalog.js";import{getConfiguredProviderBaseUrl as R,setProviderBaseUrl as U}from"../utils/model/providerBaseUrls.js";import{getSettings_DEPRECATED as K}from"../utils/settings/settings.js";import{setCustomProviderModels as W}from"../utils/config.js";import{Select as L}from"./CustomSelect/select.js";import{KeyboardShortcutHint as G}from"./design-system/KeyboardShortcutHint.js";import{Spinner as B}from"./Spinner.js";import N from"./TextInput.js";const $=["deepseek","minimax","openrouter","zai","nvidia","ollama","openai","claudeai","gemini-google","gemini-api","console"];function sortLoginProviderOptions(e){const o=new Map($.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 F="Pega aqui el codigo si se solicita > ";function formatOAuthDebugDetails(e,o){if("openai"!==e)return"";const r=y({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:i,mode:y="login",forceLoginMethod:A,profileName:R}){const L=K()||{},B=A??L.forceLoginMethod,N=L.forceLoginOrgUUID,$="claudeai"===B?"Método de acceso preseleccionado: Plan de suscripción (Context Pro/Max)":"console"===B?"Método de acceso preseleccionado: Facturación por uso de API (Anthropic Console)":"openai"===B?"Método de acceso preseleccionado: OpenAI / Codex OAuth":null,F=p(),[V,X]=s(()=>"setup-token"===y||"claudeai"===B||"console"===B||"openai"===B?{state:"ready_to_start"}:{state:"idle"}),[Y,q]=s(""),[H,Z]=s(0),[J]=s(()=>new C),[Q,ee]=s(()=>"openai"===B?"openai":"anthropic"),[oe,re]=s(()=>"setup-token"===y||"claudeai"===B),[ie,te]=s(!1),[ne,ae]=s(!1),se=c().columns-37-1,[le,de]=s(""),[ce,ue]=s(0),[pe,me]=s(""),[he,ge]=s(0),[fe,_e]=s(""),[ve,Ce]=s(""),[ye,be]=s(""),[Ae,ke]=s(0),[Pe,xe]=s(0),[Oe,Ie]=s(0);n(()=>{"claudeai"===B?l("tengu_oauth_claudeai_forced",{}):"console"===B&&l("tengu_oauth_console_forced",{})},[B]),n(()=>{if("about_to_retry"===V.state){const e=setTimeout(X,1e3,V.nextState);return()=>clearTimeout(e)}},[V]),f("confirm:yes",()=>{l("tengu_oauth_success",{loginWithClaudeAi:oe}),r(Q)},{context:"Confirmation",isActive:"success"===V.state&&"setup-token"!==y}),n(()=>{if("success"===V.state&&!process.stdin.isTTY){const e=setTimeout(()=>{l("tengu_oauth_success",{loginWithClaudeAi:oe}),r(Q)},800);return()=>clearTimeout(e)}},[V.state,Q,oe,r]),f("confirm:yes",()=>{X({state:"idle"})},{context:"Confirmation",isActive:"platform_setup"===V.state}),f("confirm:yes",()=>{De()},{context:"Confirmation",isActive:"provider_google_setup"===V.state}),f("confirm:yes",()=>{"error"===V.state&&V.toRetry&&(q(""),X({state:"about_to_retry",nextState:V.toRetry}))},{context:"Confirmation",isActive:"error"===V.state&&!!V.toRetry}),f("cancel",()=>{X({state:"idle"})},{context:"Confirmation",isActive:"provider_api_key_input"===V.state||"provider_local_setup"===V.state||"provider_google_setup"===V.state||"error"===V.state}),n(()=>{"c"===Y&&"waiting_for_login"===V.state&&ie&&!ne&&(u(V.url).then(e=>{e&&process.stdout.write(e),ae(!0),setTimeout(ae,2e3,!1)}),q(""))},[Y,V,ie,ne]);const Se=t(async(e,o)=>{const i=e.trim();if(i)try{await P(o,i),de(""),ue(0);const e=E(o).label;v({message:`API key de ${e} guardada`,notificationType:"auth_success"},F),r(o)}catch(e){j(e),X({state:"error",message:e.message,toRetry:{state:"provider_api_key_input",provider:o}})}else X({state:"error",message:"Debes ingresar una API key.",toRetry:{state:"provider_api_key_input",provider:o}})},[r,F]),we=t((e,o)=>{const i=e.trim();if(i)try{const e=U(o,i);me(e),ge(0),v({message:`URL de ${E(o).label} guardada`,notificationType:"auth_success"},F),r(o)}catch(e){j(e),X({state:"error",message:e.message,toRetry:{state:"provider_local_setup",provider:o}})}else X({state:"error",message:"Debes ingresar una URL para Ollama.",toRetry:{state:"provider_local_setup",provider:o}})},[r,F]),ze=t((e,o,i)=>{const t=V;if("custom_provider_wizard"===t.state&&t.provider)if("endpoint"===e){const e=o.trim();if(e&&!e.startsWith("http"))return void X({state:"error",message:"La URL debe empezar con http:// o https://.",toRetry:t});if(!e)return void X({state:"error",message:"El endpoint es obligatorio. Ejemplo: http://localhost:8001/v1",toRetry:t});X({state:"custom_provider_wizard",provider:t.provider,step:"api_key",apiKey:t.apiKey,endpoint:e,model:t.model})}else if("api_key"===e){const e=o.trim();if(!e)return void X({state:"error",message:"La API key no puede estar vacia.",toRetry:t});X({state:"custom_provider_wizard",provider:t.provider,step:"model_list",apiKey:e,endpoint:t.endpoint,model:"",availableModels:[],modelsLoading:!0});const r=new AbortController,i=setTimeout(()=>r.abort(),15e3);fetch(`${t.endpoint}/models`,{headers:{Authorization:`Bearer ${e}`},signal:r.signal}).then(e=>e.json()).then(e=>{clearTimeout(i);const o=e.data?.map(e=>e.id)||[];X(e=>"custom_provider_wizard"!==e.state||"model_list"!==e.step?e:{...e,availableModels:o,modelsLoading:!1})}).catch(e=>{clearTimeout(i),j(e),X(e=>"custom_provider_wizard"!==e.state||"model_list"!==e.step?e:{...e,availableModels:[],modelsLoading:!1})})}else if("model"===e){const e=i&&i.length>0?i:"model_list"===t.step&&Array.isArray(t.availableModels)?t.availableModels:[];let n=null;try{if(S(t.provider))if(R&&R.trim()){const e=I(t.provider,R.trim());z(e.id),n=e.id}else n=w(t.provider,{createIfMissing:!0})?.id??null}catch(e){j(e)}P(t.provider,t.apiKey).then(()=>{U(t.provider,t.endpoint);try{M(t.provider)}catch(e){j(e)}const i=o?.trim();if(i)try{T(t.provider,i),S(t.provider)&&D(t.provider,i)}catch(e){j(e)}if(e.length>0)try{W(t.provider,e,n)}catch(e){j(e)}v({message:`Configuracion de ${E(t.provider).label} guardada`,notificationType:"auth_success"},F),r(t.provider)}).catch(e=>{j(e),X({state:"error",message:e.message,toRetry:t})})}},[r,F,V,R]),De=t(async()=>{X({state:"provider_google_auth_running"});try{if(await b())return void r("gemini-google");const e=await O();k(e);if(!await b())return v({message:"OAuth de Gemini guardado; Code Assist no valido el proyecto de cuota",notificationType:"auth_success"},F),void r("gemini-google");v({message:"Credenciales de Gemini Google listas",notificationType:"auth_success"},F),r("gemini-google")}catch(e){j(e),X({state:"error",message:e.message,toRetry:{state:"provider_google_setup"}})}},[r,F]),Me=t(async()=>{try{l("tengu_oauth_flow_start",{loginWithClaudeAi:oe,provider:Q});const e=await J.startOAuthFlow(async e=>{X({state:"waiting_for_login",url:e}),setTimeout(te,3e3,!0)},{loginWithClaudeAi:oe,provider:Q,inferenceOnly:"setup-token"===y,expiresIn:"setup-token"===y?31536e3:void 0,orgUUID:N}).catch(e=>{const o=e.message.includes("Token exchange failed"),r=_(e),i=J.getPort(),t="openai"===Q&&i?formatOAuthDebugDetails(Q,i):"";throw X({state:"error",message:r??(o?"No se pudo intercambiar el codigo de autorizacion por el token de acceso. Intentalo de nuevo."+(t?`\n${t}`:""):e.message),toRetry:"setup-token"===y?{state:"ready_to_start"}:{state:"idle"}}),l("tengu_oauth_token_exchange_error",{error:e.message,ssl_error:null!==r}),e});if("setup-token"===y)X({state:"success",token:e.accessToken});else{X({state:"creating_api_key"});const o=R?w("openai"===Q?"openai":"anthropic",R):void 0;if(await d(e,Q,o?.id),"anthropic"===Q){const e=await x();if(!e.valid)throw new Error(e.message)}X({state:"success"}),v({message:"openai"===Q?"Inicio de sesión con OpenAI / Codex completado":"Inicio de sesión en Context Code completado",notificationType:"auth_success"},F)}}catch(e){const o=e.message,r=_(e),i=J.getPort(),t="openai"===Q&&i?formatOAuthDebugDetails(Q,i):"";X({state:"error",message:r??("openai"===Q&&t&&!o.includes("redirect_uri=")?`${o}\n${t}`:o),toRetry:{state:"setup-token"===y?"ready_to_start":"idle"}}),l("tengu_oauth_error",{error:o,ssl_error:null!==r})}},[Q,J,te,oe,y,N,F]),Te=a(!1);return n(()=>{"ready_to_start"!==V.state||Te.current||(Te.current=!0,process.nextTick((e,o)=>{e(),o.current=!1},Me,Te))},[V.state,Me]),n(()=>{if("setup-token"===y&&"success"===V.state){const e=setTimeout((e,o)=>{l("tengu_oauth_success",{loginWithClaudeAi:e}),o(Q)},500,oe,r,Q);return()=>clearTimeout(e)}},[y,V,oe,r,Q]),n(()=>()=>{J.cleanup()},[J]),e(m,{flexDirection:"column",gap:1,children:["waiting_for_login"===V.state&&ie&&e(m,{flexDirection:"column",gap:1,paddingBottom:1,children:[e(m,{paddingX:1,children:[e(g,{dimColor:!0,children:["Browser didn't open? Use the url below to sign in"," "]}),o(g,ne?{color:"success",children:"(Copied!)"}:{dimColor:!0,children:o(G,{shortcut:"c",action:"copiar",parens:!0})})]}),o(h,{url:V.url,children:o(g,{dimColor:!0,children:V.url})})]},"urlToCopy"),"setup-token"===y&&"success"===V.state&&V.token&&e(m,{flexDirection:"column",gap:1,paddingTop:1,children:[o(g,{color:"success",children:"✓ Long-lived authentication token created successfully!"}),e(m,{flexDirection:"column",gap:1,children:[o(g,{children:"Your OAuth token (valid for 1 year):"}),o(g,{color:"warning",children:V.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(m,{paddingLeft:1,flexDirection:"column",gap:1,children:o(OAuthStatusMessage,{oauthStatus:V,oauthProvider:Q,mode:y,startingMessage:i,forcedMethodMessage:$,showPastePrompt:ie,pastedCode:Y,setPastedCode:q,cursorOffset:H,setCursorOffset:Z,textInputColumns:se,handleSubmitCode:async function(e,o){try{const[r,i]=e.split("#");if(!r||!i)return void X({state:"error",message:"Codigo invalido. Asegurate de copiar el codigo completo",toRetry:{state:"waiting_for_login",url:o}});l("tengu_oauth_manual_entry",{}),J.handleManualAuthCodeInput({authorizationCode:r,state:i})}catch(e){j(e),X({state:"error",message:e.message,toRetry:{state:"waiting_for_login",url:o}})}},setOAuthStatus:X,setLoginWithClaudeAi:re,setOAuthProvider:ee,providerApiKey:le,setProviderApiKey:de,providerApiKeyCursorOffset:ce,setProviderApiKeyCursorOffset:ue,handleProviderApiKeySubmit:Se,providerBaseUrl:pe,setProviderBaseUrlInput:me,providerBaseUrlCursorOffset:he,setProviderBaseUrlCursorOffset:ge,handleProviderBaseUrlSubmit:we,onDone:r,wizardApiKey:fe,setWizardApiKey:_e,wizardEndpoint:ve,setWizardEndpoint:Ce,wizardModel:ye,setWizardModel:be,wizardApiKeyCursor:Ae,setWizardApiKeyCursor:ke,wizardEndpointCursor:Pe,setWizardEndpointCursor:xe,wizardModelCursor:Oe,setWizardModelCursor:Ie,handleCustomProviderWizardSubmit:ze})})]})}function OAuthStatusMessage(t){const n=i(68),{oauthStatus:a,oauthProvider:s,mode:d,startingMessage:c,forcedMethodMessage:u,showPastePrompt:p,pastedCode:f,setPastedCode:_,cursorOffset:v,setCursorOffset:C,textInputColumns:y,handleSubmitCode:b,setOAuthStatus:k,setLoginWithClaudeAi:P,setOAuthProvider:x,providerApiKey:O,setProviderApiKey:I,providerApiKeyCursorOffset:S,setProviderApiKeyCursorOffset:w,handleProviderApiKeySubmit:z,providerBaseUrl:D,setProviderBaseUrlInput:M,providerBaseUrlCursorOffset:T,setProviderBaseUrlCursorOffset:j,handleProviderBaseUrlSubmit:U,onDone:K,wizardApiKey:W,setWizardApiKey:G,wizardEndpoint:$,setWizardEndpoint:V,wizardModel:X,setWizardModel:Y,wizardApiKeyCursor:q,setWizardApiKeyCursor:H,wizardEndpointCursor:Z,setWizardEndpointCursor:J,wizardModelCursor:Q,setWizardModelCursor:ee,handleCustomProviderWizardSubmit:oe}=t;switch(a.state){case"idle":{const r=c||"Context Code puede usarse con tu suscripción de Claude, la facturación de Anthropic Console o OpenAI / Codex OAuth.";let i,t,a,s,d,u,p;return n[0]!==r?(i=o(g,{bold:!0,children:r}),n[0]=r,n[1]=i):i=n[1],n[2]===Symbol.for("react.memo_cache_sentinel")?(t=o(g,{children:"Selecciona el metodo de acceso:"}),n[2]=t):t=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")?(d=[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"},{label:e(g,{children:["Custom OpenAI ·"," ",o(g,{dimColor:!0,children:"Wizard API key + endpoint"}),"\n"]}),value:"custom-openai"},{label:e(g,{children:["Custom Anthropic ·"," ",o(g,{dimColor:!0,children:"Wizard API key + endpoint"}),"\n"]}),value:"custom-anthropic"}],n[5]=d):d=n[5],n[6]!==P||n[7]!==k||n[8]!==x||n[65]!==K?(u=o(m,{children:o(L,{options:sortLoginProviderOptions(d),onChange:e=>{"platform"===e?(l("tengu_oauth_platform_selected",{}),k({state:"platform_setup"})):"openai"===e?(l("tengu_oauth_openai_selected",{}),x("openai"),P(!1),k({state:"ready_to_start"})):"openrouter"===e?k({state:"provider_api_key_input",provider:"openrouter"}):"gemini-api"===e||"zai"===e||"minimax"===e||"nvidia"===e||"deepseek"===e?k({state:"provider_api_key_input",provider:e}):"gemini-google"===e?k({state:"provider_google_setup"}):"ollama"===e||"ollama-cloud"===e?(M(R(e)),j(0),k({state:"provider_local_setup",provider:e})):"custom-openai"===e||"custom-anthropic"===e?k({state:"custom_provider_wizard",provider:e,step:"endpoint",apiKey:"",endpoint:"",model:""}):(x("anthropic"),k({state:"ready_to_start"}),"claudeai"===e?(l("tengu_oauth_claudeai_selected",{}),P(!0)):(l("tengu_oauth_console_selected",{}),P(!1)))}})}),n[6]=P,n[7]=k,n[8]=x,n[65]=K,n[66]=u):u=n[66],n[10]!==i||n[11]!==u?(p=e(m,{flexDirection:"column",gap:1,marginTop:1,children:[i,t,u]}),n[10]=i,n[11]=u,n[12]=p):p=n[12],p}case"provider_api_key_input":{let r,i,t,s;if(n[50]!==a.provider?(r=e(g,{bold:!0,children:["Ingresa la API key de ",E(a.provider).label]}),n[50]=a.provider,n[51]=r):r=n[51],n[52]!==a.provider){const r=E(a.provider);i=e(m,{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]=i}else i=n[53];return n[54]!==O||n[55]!==S||n[56]!==I||n[57]!==w||n[58]!==y||n[59]!==z?(t=e(m,{children:[o(g,{children:"API key > "}),o(N,{value:O,onChange:I,onSubmit:e=>z(e,a.provider),cursorOffset:S,onChangeCursorOffset:w,columns:y,mask:"*"})]}),n[54]=O,n[55]=S,n[56]=I,n[57]=w,n[58]=y,n[59]=z,n[60]=t):t=n[60],n[61]!==r||n[62]!==i||n[63]!==t?(s=e(m,{flexDirection:"column",gap:1,children:[r,i,t]}),n[61]=r,n[62]=i,n[63]=t,n[64]=s):s=n[64],s}case"provider_local_setup":{const r=E(a.provider);return e(m,{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(m,{children:o(N,{value:D,onChange:M,onSubmit:e=>U(e,a.provider),cursorOffset:T,onChangeCursorOffset:j,columns:y})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la URL y continuar."]})]})}case"provider_google_setup":return e(m,{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(m,{children:[o(B,{}),o(g,{children:"Abriendo Google OAuth para Gemini..."})]});case"custom_provider_wizard":{const r=E(a.provider),i="custom-openai"===a.provider?"https://api.openai.com/v1":"https://api.anthropic.com/v1";if("endpoint"===a.step)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 1/3"]}),o(g,{dimColor:!0,children:"URL del servidor API (ej: http://localhost:8001/v1)"}),o(g,{children:"Endpoint > "}),o(m,{children:o(N,{value:$,onChange:V,onSubmit:oe.bind(null,"endpoint"),cursorOffset:Z,onChangeCursorOffset:J,columns:y})}),e(g,{dimColor:!0,children:["Default: ",i]}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para continuar."]})]});if("api_key"===a.step)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 2/3"]}),e(g,{dimColor:!0,children:["Ingresa tu API key para ",r.label,"."]}),o(g,{children:"API key > "}),o(m,{children:o(N,{value:W,onChange:G,onSubmit:oe.bind(null,"api_key"),cursorOffset:q,onChangeCursorOffset:H,columns:y,mask:"*"})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para obtener modelos disponibles."]})]});if("model_list"===a.step){if(a.modelsLoading)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Cargando modelos..."]}),e(m,{children:[o(B,{}),e(g,{children:[" Obteniendo lista de modelos desde ",a.endpoint,"/models"]})]})]});const i=a.availableModels||[];if(i.length>0){const t=i.map(e=>({label:e,value:e}));return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 3/3"]}),o(g,{dimColor:!0,children:"Selecciona un modelo de la lista:"}),o(m,{children:o(L,{options:t,onChange:e=>{k(o=>({...o,model:e})),oe("model",e,i)}})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la configuracion."]})]})}return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 3/3"]}),o(g,{dimColor:!0,children:"No se pudo obtener la lista de modelos."}),o(g,{dimColor:!0,children:"Ingresa el nombre del modelo manualmente."}),o(g,{dimColor:!0,children:"Podras cambiarlo luego con el comando /model."}),o(g,{children:"Modelo > "}),o(m,{children:o(N,{value:X,onChange:Y,onSubmit:oe.bind(null,"model"),cursorOffset:Q,onChangeCursorOffset:ee,columns:y})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la configuracion."]})]})}break}case"platform_setup":{let r,i,t,a,s,l,d,c;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")?(i=o(g,{children:"Context Code soporta Amazon Bedrock, Microsoft Foundry y Vertex AI. Configura las variables de entorno requeridas y luego reinicia Context Code."}),t=o(g,{children:"Si formas parte de una organización empresarial, contacta a tu administrador para las instrucciones de configuración."}),n[13]=i,n[14]=t):(i=n[13],t=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://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]}),n[16]=s):s=n[16],n[17]===Symbol.for("react.memo_cache_sentinel")?(l=e(g,{children:["· Microsoft Foundry:"," ",o(h,{url:"https://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]}),n[17]=l):l=n[17],n[18]===Symbol.for("react.memo_cache_sentinel")?(d=e(m,{flexDirection:"column",marginTop:1,children:[a,s,l,e(g,{children:["· Vertex AI:"," ",o(h,{url:"https://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]})]}),n[18]=d):d=n[18],n[19]===Symbol.for("react.memo_cache_sentinel")?(c=e(m,{flexDirection:"column",gap:1,marginTop:1,children:[r,e(m,{flexDirection:"column",gap:1,children:[i,t,d,o(m,{marginTop:1,children:e(g,{dimColor:!0,children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para volver a las opciones de acceso."]})})]})]}),n[19]=c):c=n[19],c}case"waiting_for_login":{let r,i,t,s;return n[20]!==u?(r=u&&o(m,{children:o(g,{dimColor:!0,children:u})}),n[20]=u,n[21]=r):r=n[21],n[22]!==p?(i=!p&&e(m,{children:[o(B,{}),o(g,{children:"Abriendo el navegador para iniciar sesión…"})]}),n[22]=p,n[23]=i):i=n[23],n[24]!==v||n[25]!==b||n[26]!==a.url||n[27]!==f||n[28]!==C||n[29]!==_||n[30]!==p||n[31]!==y?(t=p&&e(m,{children:[o(g,{children:F}),o(N,{value:f,onChange:_,onSubmit:e=>b(e,a.url),cursorOffset:v,onChangeCursorOffset:C,columns:y,mask:"*"})]}),n[24]=v,n[25]=b,n[26]=a.url,n[27]=f,n[28]=C,n[29]=_,n[30]=p,n[31]=y,n[32]=t):t=n[32],n[33]!==r||n[34]!==i||n[35]!==t?(s=e(m,{flexDirection:"column",gap:1,children:[r,i,t]}),n[33]=r,n[34]=i,n[35]=t,n[36]=s):s=n[36],s}case"creating_api_key":{let r;return n[37]===Symbol.for("react.memo_cache_sentinel")?(r=o(m,{flexDirection:"column",gap:1,children:e(m,{children:[o(B,{}),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(m,{flexDirection:"column",gap:1,children:o(g,{color:"permission",children:"Reintentando…"})}),n[38]=e):e=n[38],e}case"success":{let i,t;if(n[39]!==d||n[40]!==a.token){const t="openai"===s?"Inicio de sesión en OpenAI / Codex exitoso. Presiona ":"Inicio de sesión exitoso. Presiona ";i="setup-token"===d&&a.token?null:e(r,{children:[A()?.emailAddress?e(g,{dimColor:!0,children:["Sesión iniciada como"," ",o(g,{children:A()?.emailAddress})]}):null,e(g,{color:"success",children:[t,o(g,{bold:!0,children:"Enter"})," para continuar…"]})]}),n[39]=d,n[40]=a.token,n[41]=i}else i=n[41];return n[42]!==i?(t=o(m,{flexDirection:"column",children:i}),n[42]=i,n[43]=t):t=n[43],t}case"error":{let r,i,t;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?(i=a.toRetry&&o(m,{marginTop:1,children:e(g,{color:"permission",children:["Press ",o(g,{bold:!0,children:"Enter"})," to retry."]})}),n[46]=a.toRetry,n[47]=i):i=n[47],n[48]!==r||n[49]!==i?(t=e(m,{flexDirection:"column",gap:1,children:[r,i]}),n[48]=r,n[49]=i,n[50]=t):t=n[50],t}default:return null}}
1
+ import{jsxs as e,jsx as o,Fragment as r}from"react/jsx-runtime";import{c as i}from"react/compiler-runtime";import{useCallback as t,useEffect as n,useRef as a,useState as s}from"react";import{logEvent as l}from"../services/analytics/index.js";import{installOAuthTokens as d}from"../cli/handlers/auth.js";import{useTerminalSize as c}from"../hooks/useTerminalSize.js";import{setClipboard as u}from"../ink/termio/osc.js";import{useTerminalNotification as p}from"../ink/useTerminalNotification.js";import{Box as m,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 C}from"../services/oauth/index.js";import{getOAuthRequestDetails as y}from"../services/oauth/client.js";import{checkGeminiGoogleCredentialsValid as b,getOauthAccountInfo as A,saveGeminiGoogleOAuthTokens as k,saveProviderApiKey as P,validateForceLoginOrg as x}from"../utils/auth.js";import{startGeminiCliOAuthFlow as I}from"../services/oauth/geminiCli.js";import{ensureProviderProfile as O,isProfiledProvider as S,resolveProviderProfile as z,setActiveProviderProfile as w,setProviderProfileLastModel as D}from"../utils/model/providerProfiles.js";import{setStoredActiveProviderPreference as M,setStoredLastModelForProvider as T}from"../utils/model/providerProfilesDb.js";import{logError as j}from"../utils/log.js";import{getVisibleProvider as E}from"../utils/model/providerCatalog.js";import{getConfiguredProviderBaseUrl as R,setProviderBaseUrl as U}from"../utils/model/providerBaseUrls.js";import{getSettings_DEPRECATED as K}from"../utils/settings/settings.js";import{setCustomProviderModels as W}from"../utils/config.js";import{Select as L}from"./CustomSelect/select.js";import{KeyboardShortcutHint as G}from"./design-system/KeyboardShortcutHint.js";import{Spinner as B}from"./Spinner.js";import N from"./TextInput.js";const F=["deepseek","minimax","openrouter","zai","nvidia","ollama","openai","claudeai","gemini-google","gemini-api","console","xai","gmi","novita","stepfun","huggingface","opencode-zen","arcee","alibaba","kimi"];function sortLoginProviderOptions(e){const o=new Map(F.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 $="Pega aqui el codigo si se solicita > ";function formatOAuthDebugDetails(e,o){if("openai"!==e)return"";const r=y({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:i,mode:y="login",forceLoginMethod:A,profileName:R}){const L=K()||{},B=A??L.forceLoginMethod,N=L.forceLoginOrgUUID,F="claudeai"===B?"Método de acceso preseleccionado: Plan de suscripción (Context Pro/Max)":"console"===B?"Método de acceso preseleccionado: Facturación por uso de API (Anthropic Console)":"openai"===B?"Método de acceso preseleccionado: OpenAI / Codex OAuth":null,$=p(),[H,V]=s(()=>"setup-token"===y||"claudeai"===B||"console"===B||"openai"===B?{state:"ready_to_start"}:{state:"idle"}),[X,Y]=s(""),[q,Z]=s(0),[Q]=s(()=>new C),[J,ee]=s(()=>"openai"===B?"openai":"anthropic"),[oe,re]=s(()=>"setup-token"===y||"claudeai"===B),[ie,te]=s(!1),[ne,ae]=s(!1),se=c().columns-37-1,[le,de]=s(""),[ce,ue]=s(0),[pe,me]=s(""),[he,ge]=s(0),[fe,_e]=s(""),[ve,Ce]=s(""),[ye,be]=s(""),[Ae,ke]=s(0),[Pe,xe]=s(0),[Ie,Oe]=s(0);n(()=>{"claudeai"===B?l("tengu_oauth_claudeai_forced",{}):"console"===B&&l("tengu_oauth_console_forced",{})},[B]),n(()=>{if("about_to_retry"===H.state){const e=setTimeout(V,1e3,H.nextState);return()=>clearTimeout(e)}},[H]),f("confirm:yes",()=>{l("tengu_oauth_success",{loginWithClaudeAi:oe}),r(J)},{context:"Confirmation",isActive:"success"===H.state&&"setup-token"!==y}),n(()=>{if("success"===H.state&&!process.stdin.isTTY){const e=setTimeout(()=>{l("tengu_oauth_success",{loginWithClaudeAi:oe}),r(J)},800);return()=>clearTimeout(e)}},[H.state,J,oe,r]),f("confirm:yes",()=>{V({state:"idle"})},{context:"Confirmation",isActive:"platform_setup"===H.state}),f("confirm:yes",()=>{De()},{context:"Confirmation",isActive:"provider_google_setup"===H.state}),f("confirm:yes",()=>{"error"===H.state&&H.toRetry&&(Y(""),V({state:"about_to_retry",nextState:H.toRetry}))},{context:"Confirmation",isActive:"error"===H.state&&!!H.toRetry}),f("cancel",()=>{V({state:"idle"})},{context:"Confirmation",isActive:"provider_api_key_input"===H.state||"provider_local_setup"===H.state||"provider_google_setup"===H.state||"error"===H.state}),n(()=>{"c"===X&&"waiting_for_login"===H.state&&ie&&!ne&&(u(H.url).then(e=>{e&&process.stdout.write(e),ae(!0),setTimeout(ae,2e3,!1)}),Y(""))},[X,H,ie,ne]);const Se=t(async(e,o)=>{const i=e.trim();if(i)try{await P(o,i),de(""),ue(0);const e=E(o).label;v({message:`API key de ${e} guardada`,notificationType:"auth_success"},$),r(o)}catch(e){j(e),V({state:"error",message:e.message,toRetry:{state:"provider_api_key_input",provider:o}})}else V({state:"error",message:"Debes ingresar una API key.",toRetry:{state:"provider_api_key_input",provider:o}})},[r,$]),ze=t((e,o)=>{const i=e.trim();if(i)try{const e=U(o,i);me(e),ge(0),v({message:`URL de ${E(o).label} guardada`,notificationType:"auth_success"},$),r(o)}catch(e){j(e),V({state:"error",message:e.message,toRetry:{state:"provider_local_setup",provider:o}})}else V({state:"error",message:"Debes ingresar una URL para Ollama.",toRetry:{state:"provider_local_setup",provider:o}})},[r,$]),we=t((e,o,i)=>{const t=H;if("custom_provider_wizard"===t.state&&t.provider)if("endpoint"===e){const e=o.trim();if(e&&!e.startsWith("http"))return void V({state:"error",message:"La URL debe empezar con http:// o https://.",toRetry:t});if(!e)return void V({state:"error",message:"El endpoint es obligatorio. Ejemplo: http://localhost:8001/v1",toRetry:t});V({state:"custom_provider_wizard",provider:t.provider,step:"api_key",apiKey:t.apiKey,endpoint:e,model:t.model})}else if("api_key"===e){const e=o.trim();if(!e)return void V({state:"error",message:"La API key no puede estar vacia.",toRetry:t});V({state:"custom_provider_wizard",provider:t.provider,step:"model_list",apiKey:e,endpoint:t.endpoint,model:"",availableModels:[],modelsLoading:!0});const r=new AbortController,i=setTimeout(()=>r.abort(),3e5);fetch(`${t.endpoint}/models`,{headers:{Authorization:`Bearer ${e}`},signal:r.signal}).then(e=>e.json()).then(e=>{clearTimeout(i);const o=e.data?.map(e=>e.id)||[];V(e=>"custom_provider_wizard"!==e.state||"model_list"!==e.step?e:{...e,availableModels:o,modelsLoading:!1})}).catch(e=>{clearTimeout(i),j(e),V(e=>"custom_provider_wizard"!==e.state||"model_list"!==e.step?e:{...e,availableModels:[],modelsLoading:!1})})}else if("model"===e){const e=i&&i.length>0?i:"model_list"===t.step&&Array.isArray(t.availableModels)?t.availableModels:[];let n=null;try{if(S(t.provider))if(R&&R.trim()){const e=O(t.provider,R.trim());w(e.id),n=e.id}else n=z(t.provider,{createIfMissing:!0})?.id??null}catch(e){j(e)}P(t.provider,t.apiKey).then(()=>{U(t.provider,t.endpoint);try{M(t.provider)}catch(e){j(e)}const i=o?.trim();if(i)try{T(t.provider,i),S(t.provider)&&D(t.provider,i)}catch(e){j(e)}if(e.length>0)try{W(t.provider,e,n)}catch(e){j(e)}v({message:`Configuracion de ${E(t.provider).label} guardada`,notificationType:"auth_success"},$),r(t.provider)}).catch(e=>{j(e),V({state:"error",message:e.message,toRetry:t})})}},[r,$,H,R]),De=t(async()=>{V({state:"provider_google_auth_running"});try{if(await b())return void r("gemini-google");const e=await I();k(e);if(!await b())return v({message:"OAuth de Gemini guardado; Code Assist no valido el proyecto de cuota",notificationType:"auth_success"},$),void r("gemini-google");v({message:"Credenciales de Gemini Google listas",notificationType:"auth_success"},$),r("gemini-google")}catch(e){j(e),V({state:"error",message:e.message,toRetry:{state:"provider_google_setup"}})}},[r,$]),Me=t(async()=>{try{l("tengu_oauth_flow_start",{loginWithClaudeAi:oe,provider:J});const e=await Q.startOAuthFlow(async e=>{V({state:"waiting_for_login",url:e}),setTimeout(te,3e3,!0)},{loginWithClaudeAi:oe,provider:J,inferenceOnly:"setup-token"===y,expiresIn:"setup-token"===y?31536e3:void 0,orgUUID:N}).catch(e=>{const o=e.message.includes("Token exchange failed"),r=_(e),i=Q.getPort(),t="openai"===J&&i?formatOAuthDebugDetails(J,i):"";throw V({state:"error",message:r??(o?"No se pudo intercambiar el codigo de autorizacion por el token de acceso. Intentalo de nuevo."+(t?`\n${t}`:""):e.message),toRetry:"setup-token"===y?{state:"ready_to_start"}:{state:"idle"}}),l("tengu_oauth_token_exchange_error",{error:e.message,ssl_error:null!==r}),e});if("setup-token"===y)V({state:"success",token:e.accessToken});else{V({state:"creating_api_key"});const o=R?z("openai"===J?"openai":"anthropic",R):void 0;if(await d(e,J,o?.id),"anthropic"===J){const e=await x();if(!e.valid)throw new Error(e.message)}V({state:"success"}),v({message:"openai"===J?"Inicio de sesión con OpenAI / Codex completado":"Inicio de sesión en Context Code completado",notificationType:"auth_success"},$)}}catch(e){const o=e.message,r=_(e),i=Q.getPort(),t="openai"===J&&i?formatOAuthDebugDetails(J,i):"";V({state:"error",message:r??("openai"===J&&t&&!o.includes("redirect_uri=")?`${o}\n${t}`:o),toRetry:{state:"setup-token"===y?"ready_to_start":"idle"}}),l("tengu_oauth_error",{error:o,ssl_error:null!==r})}},[J,Q,te,oe,y,N,$]),Te=a(!1);return n(()=>{"ready_to_start"!==H.state||Te.current||(Te.current=!0,process.nextTick((e,o)=>{e(),o.current=!1},Me,Te))},[H.state,Me]),n(()=>{if("setup-token"===y&&"success"===H.state){const e=setTimeout((e,o)=>{l("tengu_oauth_success",{loginWithClaudeAi:e}),o(J)},500,oe,r,J);return()=>clearTimeout(e)}},[y,H,oe,r,J]),n(()=>()=>{Q.cleanup()},[Q]),e(m,{flexDirection:"column",gap:1,children:["waiting_for_login"===H.state&&ie&&e(m,{flexDirection:"column",gap:1,paddingBottom:1,children:[e(m,{paddingX:1,children:[e(g,{dimColor:!0,children:["Browser didn't open? Use the url below to sign in"," "]}),o(g,ne?{color:"success",children:"(Copied!)"}:{dimColor:!0,children:o(G,{shortcut:"c",action:"copiar",parens:!0})})]}),o(h,{url:H.url,children:o(g,{dimColor:!0,children:H.url})})]},"urlToCopy"),"setup-token"===y&&"success"===H.state&&H.token&&e(m,{flexDirection:"column",gap:1,paddingTop:1,children:[o(g,{color:"success",children:"✓ Long-lived authentication token created successfully!"}),e(m,{flexDirection:"column",gap:1,children:[o(g,{children:"Your OAuth token (valid for 1 year):"}),o(g,{color:"warning",children:H.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(m,{paddingLeft:1,flexDirection:"column",gap:1,children:o(OAuthStatusMessage,{oauthStatus:H,oauthProvider:J,mode:y,startingMessage:i,forcedMethodMessage:F,showPastePrompt:ie,pastedCode:X,setPastedCode:Y,cursorOffset:q,setCursorOffset:Z,textInputColumns:se,handleSubmitCode:async function(e,o){try{const[r,i]=e.split("#");if(!r||!i)return void V({state:"error",message:"Codigo invalido. Asegurate de copiar el codigo completo",toRetry:{state:"waiting_for_login",url:o}});l("tengu_oauth_manual_entry",{}),Q.handleManualAuthCodeInput({authorizationCode:r,state:i})}catch(e){j(e),V({state:"error",message:e.message,toRetry:{state:"waiting_for_login",url:o}})}},setOAuthStatus:V,setLoginWithClaudeAi:re,setOAuthProvider:ee,providerApiKey:le,setProviderApiKey:de,providerApiKeyCursorOffset:ce,setProviderApiKeyCursorOffset:ue,handleProviderApiKeySubmit:Se,providerBaseUrl:pe,setProviderBaseUrlInput:me,providerBaseUrlCursorOffset:he,setProviderBaseUrlCursorOffset:ge,handleProviderBaseUrlSubmit:ze,onDone:r,wizardApiKey:fe,setWizardApiKey:_e,wizardEndpoint:ve,setWizardEndpoint:Ce,wizardModel:ye,setWizardModel:be,wizardApiKeyCursor:Ae,setWizardApiKeyCursor:ke,wizardEndpointCursor:Pe,setWizardEndpointCursor:xe,wizardModelCursor:Ie,setWizardModelCursor:Oe,handleCustomProviderWizardSubmit:we})})]})}function OAuthStatusMessage(t){const n=i(68),{oauthStatus:a,oauthProvider:s,mode:d,startingMessage:c,forcedMethodMessage:u,showPastePrompt:p,pastedCode:f,setPastedCode:_,cursorOffset:v,setCursorOffset:C,textInputColumns:y,handleSubmitCode:b,setOAuthStatus:k,setLoginWithClaudeAi:P,setOAuthProvider:x,providerApiKey:I,setProviderApiKey:O,providerApiKeyCursorOffset:S,setProviderApiKeyCursorOffset:z,handleProviderApiKeySubmit:w,providerBaseUrl:D,setProviderBaseUrlInput:M,providerBaseUrlCursorOffset:T,setProviderBaseUrlCursorOffset:j,handleProviderBaseUrlSubmit:U,onDone:K,wizardApiKey:W,setWizardApiKey:G,wizardEndpoint:F,setWizardEndpoint:H,wizardModel:V,setWizardModel:X,wizardApiKeyCursor:Y,setWizardApiKeyCursor:q,wizardEndpointCursor:Z,setWizardEndpointCursor:Q,wizardModelCursor:J,setWizardModelCursor:ee,handleCustomProviderWizardSubmit:oe}=t;switch(a.state){case"idle":{const r=c||"Context Code puede usarse con tu suscripción de Claude, la facturación de Anthropic Console o OpenAI / Codex OAuth.";let i,t,a,s,d,u,p;return n[0]!==r?(i=o(g,{bold:!0,children:r}),n[0]=r,n[1]=i):i=n[1],n[2]===Symbol.for("react.memo_cache_sentinel")?(t=o(g,{children:"Selecciona el metodo de acceso:"}),n[2]=t):t=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")?(d=[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"},{label:e(g,{children:["xAI / Grok ·"," ",o(g,{dimColor:!0,children:"API key / api.x.ai"}),"\n"]}),value:"xai"},{label:e(g,{children:["GMI Cloud ·"," ",o(g,{dimColor:!0,children:"API key / api.gmi-serving.com"}),"\n"]}),value:"gmi"},{label:e(g,{children:["NovitaAI ·"," ",o(g,{dimColor:!0,children:"API key / novita.ai"}),"\n"]}),value:"novita"},{label:e(g,{children:["StepFun ·"," ",o(g,{dimColor:!0,children:"API key / stepfun.ai"}),"\n"]}),value:"stepfun"},{label:e(g,{children:["HuggingFace ·"," ",o(g,{dimColor:!0,children:"Token HF / router.huggingface.co"}),"\n"]}),value:"huggingface"},{label:e(g,{children:["OpenCode Zen ·"," ",o(g,{dimColor:!0,children:"API key / opencode.ai/zen"}),"\n"]}),value:"opencode-zen"},{label:e(g,{children:["Arcee AI ·"," ",o(g,{dimColor:!0,children:"API key / api.arcee.ai"}),"\n"]}),value:"arcee"},{label:e(g,{children:["Alibaba / Qwen ·"," ",o(g,{dimColor:!0,children:"API key / DashScope compatible"}),"\n"]}),value:"alibaba"},{label:e(g,{children:["Kimi / Moonshot ·"," ",o(g,{dimColor:!0,children:"API key / api.moonshot.ai"}),"\n"]}),value:"kimi"},{label:e(g,{children:["Custom OpenAI ·"," ",o(g,{dimColor:!0,children:"Wizard API key + endpoint"}),"\n"]}),value:"custom-openai"},{label:e(g,{children:["Custom Anthropic ·"," ",o(g,{dimColor:!0,children:"Wizard API key + endpoint"}),"\n"]}),value:"custom-anthropic"}],n[5]=d):d=n[5],n[6]!==P||n[7]!==k||n[8]!==x||n[65]!==K?(u=o(m,{children:o(L,{options:sortLoginProviderOptions(d),onChange:e=>{"platform"===e?(l("tengu_oauth_platform_selected",{}),k({state:"platform_setup"})):"openai"===e?(l("tengu_oauth_openai_selected",{}),x("openai"),P(!1),k({state:"ready_to_start"})):"openrouter"===e?k({state:"provider_api_key_input",provider:"openrouter"}):"gemini-api"===e||"zai"===e||"minimax"===e||"nvidia"===e||"deepseek"===e||"xai"===e||"gmi"===e||"novita"===e||"stepfun"===e||"huggingface"===e||"opencode-zen"===e||"arcee"===e||"alibaba"===e||"kimi"===e?k({state:"provider_api_key_input",provider:e}):"gemini-google"===e?k({state:"provider_google_setup"}):"ollama"===e||"ollama-cloud"===e?(M(R(e)),j(0),k({state:"provider_local_setup",provider:e})):"custom-openai"===e||"custom-anthropic"===e?k({state:"custom_provider_wizard",provider:e,step:"endpoint",apiKey:"",endpoint:"",model:""}):(x("anthropic"),k({state:"ready_to_start"}),"claudeai"===e?(l("tengu_oauth_claudeai_selected",{}),P(!0)):(l("tengu_oauth_console_selected",{}),P(!1)))}})}),n[6]=P,n[7]=k,n[8]=x,n[65]=K,n[66]=u):u=n[66],n[10]!==i||n[11]!==u?(p=e(m,{flexDirection:"column",gap:1,marginTop:1,children:[i,t,u]}),n[10]=i,n[11]=u,n[12]=p):p=n[12],p}case"provider_api_key_input":{let r,i,t,s;if(n[50]!==a.provider?(r=e(g,{bold:!0,children:["Ingresa la API key de ",E(a.provider).label]}),n[50]=a.provider,n[51]=r):r=n[51],n[52]!==a.provider){const r=E(a.provider);i=e(m,{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]=i}else i=n[53];return n[54]!==I||n[55]!==S||n[56]!==O||n[57]!==z||n[58]!==y||n[59]!==w?(t=e(m,{children:[o(g,{children:"API key > "}),o(N,{value:I,onChange:O,onSubmit:e=>w(e,a.provider),cursorOffset:S,onChangeCursorOffset:z,columns:y,mask:"*"})]}),n[54]=I,n[55]=S,n[56]=O,n[57]=z,n[58]=y,n[59]=w,n[60]=t):t=n[60],n[61]!==r||n[62]!==i||n[63]!==t?(s=e(m,{flexDirection:"column",gap:1,children:[r,i,t]}),n[61]=r,n[62]=i,n[63]=t,n[64]=s):s=n[64],s}case"provider_local_setup":{const r=E(a.provider);return e(m,{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(m,{children:o(N,{value:D,onChange:M,onSubmit:e=>U(e,a.provider),cursorOffset:T,onChangeCursorOffset:j,columns:y})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la URL y continuar."]})]})}case"provider_google_setup":return e(m,{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(m,{children:[o(B,{}),o(g,{children:"Abriendo Google OAuth para Gemini..."})]});case"custom_provider_wizard":{const r=E(a.provider),i="custom-openai"===a.provider?"https://api.openai.com/v1":"https://api.anthropic.com/v1";if("endpoint"===a.step)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 1/3"]}),o(g,{dimColor:!0,children:"URL del servidor API (ej: http://localhost:8001/v1)"}),o(g,{children:"Endpoint > "}),o(m,{children:o(N,{value:F,onChange:H,onSubmit:oe.bind(null,"endpoint"),cursorOffset:Z,onChangeCursorOffset:Q,columns:y})}),e(g,{dimColor:!0,children:["Default: ",i]}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para continuar."]})]});if("api_key"===a.step)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 2/3"]}),e(g,{dimColor:!0,children:["Ingresa tu API key para ",r.label,"."]}),o(g,{children:"API key > "}),o(m,{children:o(N,{value:W,onChange:G,onSubmit:oe.bind(null,"api_key"),cursorOffset:Y,onChangeCursorOffset:q,columns:y,mask:"*"})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para obtener modelos disponibles."]})]});if("model_list"===a.step){if(a.modelsLoading)return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Cargando modelos..."]}),e(m,{children:[o(B,{}),e(g,{children:[" Obteniendo lista de modelos desde ",a.endpoint,"/models"]})]})]});const i=a.availableModels||[];if(i.length>0){const t=i.map(e=>({label:e,value:e}));return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 3/3"]}),o(g,{dimColor:!0,children:"Selecciona un modelo de la lista:"}),o(m,{children:o(L,{options:t,onChange:e=>{k(o=>({...o,model:e})),oe("model",e,i)}})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la configuracion."]})]})}return e(m,{flexDirection:"column",gap:1,children:[e(g,{bold:!0,children:[r.label," - Paso 3/3"]}),o(g,{dimColor:!0,children:"No se pudo obtener la lista de modelos."}),o(g,{dimColor:!0,children:"Ingresa el nombre del modelo manualmente."}),o(g,{dimColor:!0,children:"Podras cambiarlo luego con el comando /model."}),o(g,{children:"Modelo > "}),o(m,{children:o(N,{value:V,onChange:X,onSubmit:oe.bind(null,"model"),cursorOffset:J,onChangeCursorOffset:ee,columns:y})}),e(g,{color:"success",children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para guardar la configuracion."]})]})}break}case"platform_setup":{let r,i,t,a,s,l,d,c;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")?(i=o(g,{children:"Context Code soporta Amazon Bedrock, Microsoft Foundry y Vertex AI. Configura las variables de entorno requeridas y luego reinicia Context Code."}),t=o(g,{children:"Si formas parte de una organización empresarial, contacta a tu administrador para las instrucciones de configuración."}),n[13]=i,n[14]=t):(i=n[13],t=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://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]}),n[16]=s):s=n[16],n[17]===Symbol.for("react.memo_cache_sentinel")?(l=e(g,{children:["· Microsoft Foundry:"," ",o(h,{url:"https://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]}),n[17]=l):l=n[17],n[18]===Symbol.for("react.memo_cache_sentinel")?(d=e(m,{flexDirection:"column",marginTop:1,children:[a,s,l,e(g,{children:["· Vertex AI:"," ",o(h,{url:"https://docs.iaforged.com/",children:"https://docs.iaforged.com/"})]})]}),n[18]=d):d=n[18],n[19]===Symbol.for("react.memo_cache_sentinel")?(c=e(m,{flexDirection:"column",gap:1,marginTop:1,children:[r,e(m,{flexDirection:"column",gap:1,children:[i,t,d,o(m,{marginTop:1,children:e(g,{dimColor:!0,children:["Presiona ",o(g,{bold:!0,children:"Enter"})," para volver a las opciones de acceso."]})})]})]}),n[19]=c):c=n[19],c}case"waiting_for_login":{let r,i,t,s;return n[20]!==u?(r=u&&o(m,{children:o(g,{dimColor:!0,children:u})}),n[20]=u,n[21]=r):r=n[21],n[22]!==p?(i=!p&&e(m,{children:[o(B,{}),o(g,{children:"Abriendo el navegador para iniciar sesión…"})]}),n[22]=p,n[23]=i):i=n[23],n[24]!==v||n[25]!==b||n[26]!==a.url||n[27]!==f||n[28]!==C||n[29]!==_||n[30]!==p||n[31]!==y?(t=p&&e(m,{children:[o(g,{children:$}),o(N,{value:f,onChange:_,onSubmit:e=>b(e,a.url),cursorOffset:v,onChangeCursorOffset:C,columns:y,mask:"*"})]}),n[24]=v,n[25]=b,n[26]=a.url,n[27]=f,n[28]=C,n[29]=_,n[30]=p,n[31]=y,n[32]=t):t=n[32],n[33]!==r||n[34]!==i||n[35]!==t?(s=e(m,{flexDirection:"column",gap:1,children:[r,i,t]}),n[33]=r,n[34]=i,n[35]=t,n[36]=s):s=n[36],s}case"creating_api_key":{let r;return n[37]===Symbol.for("react.memo_cache_sentinel")?(r=o(m,{flexDirection:"column",gap:1,children:e(m,{children:[o(B,{}),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(m,{flexDirection:"column",gap:1,children:o(g,{color:"permission",children:"Reintentando…"})}),n[38]=e):e=n[38],e}case"success":{let i,t;if(n[39]!==d||n[40]!==a.token){const t="openai"===s?"Inicio de sesión en OpenAI / Codex exitoso. Presiona ":"Inicio de sesión exitoso. Presiona ";i="setup-token"===d&&a.token?null:e(r,{children:[A()?.emailAddress?e(g,{dimColor:!0,children:["Sesión iniciada como"," ",o(g,{children:A()?.emailAddress})]}):null,e(g,{color:"success",children:[t,o(g,{bold:!0,children:"Enter"})," para continuar…"]})]}),n[39]=d,n[40]=a.token,n[41]=i}else i=n[41];return n[42]!==i?(t=o(m,{flexDirection:"column",children:i}),n[42]=i,n[43]=t):t=n[43],t}case"error":{let r,i,t;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?(i=a.toRetry&&o(m,{marginTop:1,children:e(g,{color:"permission",children:["Press ",o(g,{bold:!0,children:"Enter"})," to retry."]})}),n[46]=a.toRetry,n[47]=i):i=n[47],n[48]!==r||n[49]!==i?(t=e(m,{flexDirection:"column",gap:1,children:[r,i]}),n[48]=r,n[49]=i,n[50]=t):t=n[50],t}default:return null}}
@@ -1 +1 @@
1
- import{jsx as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as e,useRef as r,useState as n}from"react";import{Box as l}from"../../ink.js";import{getInitialSettings as i}from"../../utils/settings/settings.js";import{Clawd as f}from"./Clawd.js";function hold(o,t,e){return Array.from({length:e},()=>({pose:o,offset:t}))}const s=[...hold("default",1,2),...hold("arms-up",0,3),...hold("default",0,1),...hold("default",1,2),...hold("arms-up",0,3),...hold("default",0,1)],u=[...hold("look-right",0,5),...hold("look-left",0,5),...hold("default",0,1)],c=[s,u],d={pose:"default",offset:0},incrementFrame=o=>o+1;export function AnimatedClawd(){const u=t(8),{pose:m,bounceOffset:a,onClick:h}=function(){const[o]=n(()=>i().prefersReducedMotion??!1),[t,l]=n(-1),f=r(s),onClick=()=>{o||-1!==t||(f.current=c[Math.floor(Math.random()*c.length)],l(0))};e(()=>{if(-1===t)return;if(t>=f.current.length)return void l(-1);const o=setTimeout(l,60,incrementFrame);return()=>clearTimeout(o)},[t]);const u=f.current,m=t>=0&&t<u.length?u[t]:d;return{pose:m.pose,bounceOffset:m.offset,onClick}}();let p,g,k;return u[0]!==m?(p=o(f,{pose:m}),u[0]=m,u[1]=p):p=u[1],u[2]!==a||u[3]!==p?(g=o(l,{marginTop:a,flexShrink:0,children:p}),u[2]=a,u[3]=p,u[4]=g):g=u[4],u[5]!==h||u[6]!==g?(k=o(l,{height:3,flexDirection:"column",onClick:h,children:g}),u[5]=h,u[6]=g,u[7]=k):k=u[7],k}
1
+ import{jsx as o}from"react/jsx-runtime";import{c as t}from"react/compiler-runtime";import{useEffect as e,useRef as r,useState as n}from"react";import{Box as l}from"../../ink.js";import{getInitialSettings as i}from"../../utils/settings/settings.js";import{Clawd as f}from"./Clawd.js";function hold(o,t,e){return Array.from({length:e},()=>({pose:o,offset:t}))}const s=[...hold("default",1,2),...hold("arms-up",0,3),...hold("default",0,1),...hold("default",1,2),...hold("arms-up",0,3),...hold("default",0,1)],u=[...hold("look-right",0,5),...hold("look-left",0,5),...hold("default",0,1)],c=[s,u],d={pose:"default",offset:0},incrementFrame=o=>o+1;export function AnimatedClawd(){const u=t(8),{pose:m,bounceOffset:a,onClick:h}=function(){const[o]=n(()=>i().prefersReducedMotion??!1),[t,l]=n(-1),f=r(s),onClick=()=>{o||-1!==t||(f.current=c[Math.floor(Math.random()*c.length)],l(0))};e(()=>{if(-1===t)return;if(t>=f.current.length)return void l(-1);const o=setTimeout(l,60,incrementFrame);return()=>clearTimeout(o)},[t]);const u=f.current,m=t>=0&&t<u.length?u[t]:d;return{pose:m.pose,bounceOffset:m.offset,onClick}}();let p,g,k;return u[0]!==m?(p=o(f,{pose:m}),u[0]=m,u[1]=p):p=u[1],u[2]!==a||u[3]!==p?(g=o(l,{marginTop:a,flexShrink:0,children:p}),u[2]=a,u[3]=p,u[4]=g):g=u[4],u[5]!==h||u[6]!==g?(k=o(l,{height:5,flexDirection:"column",onClick:h,children:g}),u[5]=h,u[6]=g,u[7]=k):k=u[7],k}
@@ -1 +1 @@
1
- import{jsx as o,jsxs as l}from"react/jsx-runtime";import{Box as r,Text as e}from"../../ink.js";export function Clawd({pose:c="default"}={}){const[d,t,i]={default:["╭─┬─┬─╮","│C│T│X│","╰─┴─┴─╯"],"arms-up":["╭▲┬▲┬▲╮","│C│T│X│","╰─┴─┴─╯"],"look-left":["╭─┬─┬─╮","│◀│T│X│","╰─┴─┴─╯"],"look-right":["╭─┬─┬─╮","│C│T│▶│","╰─┴─┴─╯"]}[c];return l(r,{flexDirection:"column",alignItems:"center",children:[o(e,{color:"clawd_body",children:d}),o(e,{color:"clawd_body",bold:!0,children:t}),o(e,{color:"clawd_body",dimColor:!0,children:i})]})}
1
+ import{jsx as o}from"react/jsx-runtime";import{Box as r,Text as e}from"../../ink.js";const t=["██████ ██████ ██ ██","██ ██ ████ ","██ ██ ██ ","██ ██ ████ ","██████ ██ ██ ██"],c=["white","white","clawd_body","clawd_body","clawd_body"];export function Clawd(i={}){return o(r,{flexDirection:"column",alignItems:"center",children:t.map((r,t)=>o(e,{color:c[t],bold:!0,children:r},t))})}
@@ -1 +1 @@
1
- import{MACRO as e,feature as o}from"../../recovery/bunBundleShim.js";import{jsx as r,jsxs as n,Fragment as t}from"react/jsx-runtime";import{createRequire as s}from"module";const i=s(import.meta.url);import{c}from"react/compiler-runtime";import{Box as l,Text as m,color as a}from"../../ink.js";import{useTerminalSize as d}from"../../hooks/useTerminalSize.js";import{stringWidth as _}from"../../ink/stringWidth.js";import{getLayoutMode as p,calculateLayoutDimensions as C,calculateOptimalLeftWidth as E,formatWelcomeMessage as f,truncatePath as h,getRecentActivitySync as u,getRecentReleaseNotesSync as O,getLogoDisplayData as T}from"../../utils/logoV2Utils.js";import{truncate as D}from"../../utils/format.js";import{getDisplayPath as X}from"../../utils/file.js";import{Clawd as S}from"./Clawd.js";import{FeedColumn as g}from"./FeedColumn.js";import{createRecentActivityFeed as N,createWhatsNewFeed as U,createProjectOnboardingFeed as L,createGuestPassesFeed as v}from"./feedConfigs.js";import{getGlobalConfig as I,saveGlobalConfig as M}from"../../utils/config.js";import{resolveThemeSetting as b}from"../../utils/systemTheme.js";import{getInitialSettings as j}from"../../utils/settings/settings.js";import{isDebugMode as F,isDebugToStdErr as x,getDebugLogPath as R}from"../../utils/debug.js";import{useEffect as A,useState as y}from"react";import{getSteps as P,shouldShowProjectOnboarding as $,incrementProjectOnboardingSeenCount as w}from"../../projectOnboardingState.js";import{CondensedLogo as z}from"./CondensedLogo.js";import{OffscreenFreeze as V}from"../OffscreenFreeze.js";import{checkForReleaseNotesSync as G}from"../../utils/releaseNotes.js";import{getDumpPromptsPath as k}from"../../services/api/dumpPrompts.js";import{isEnvTruthy as W}from"../../utils/envUtils.js";import{getStartupPerfLogPath as H,isDetailedProfilingEnabled as K}from"../../utils/startupProfiler.js";import{EmergencyTip as Y}from"./EmergencyTip.js";import{VoiceModeNotice as B}from"./VoiceModeNotice.js";import{Opus1mMergeNotice as q}from"./Opus1mMergeNotice.js";const J=o("KAIROS")||o("KAIROS_CHANNELS")?i("./ChannelsNotice.js"):null;import{SandboxManager as Q}from"../../utils/sandbox/sandbox-adapter.js";import{useShowGuestPassesUpsell as Z,incrementGuestPassesSeenCount as ee}from"./GuestPassesUpsell.js";import{useShowOverageCreditUpsell as oe,incrementOverageCreditUpsellSeenCount as re,createOverageCreditFeed as ne}from"./OverageCreditUpsell.js";import{useAppState as te}from"../../state/AppState.js";import{getEffortSuffix as se}from"../../utils/effort.js";import{useMainLoopModel as ie}from"../../hooks/useMainLoopModel.js";import{renderModelSetting as ce}from"../../utils/model/model.js";export function LogoV2(){const o=c(94),s=u(),i=I().oauthAccount?.displayName??"",{columns:X}=d();let k;o[0]===Symbol.for("react.memo_cache_sentinel")?(k=$(),o[0]=k):k=o[0];const H=k;let K;o[1]===Symbol.for("react.memo_cache_sentinel")?(K=Q.isSandboxingEnabled(),o[1]=K):K=o[1];const le=K,me=Z(),ae=oe(),de=te(_temp),_e=te(_temp2),pe=I();let Ce;try{Ce=O(3)}catch{Ce=[]}const[Ee]=y(()=>{const e=j().companyAnnouncements;if(e&&0!==e.length)return 1===pe.numStartups?e[0]:e[Math.floor(Math.random()*e.length)]}),{hasReleaseNotes:fe}=G(pe.lastReleaseNotesSeen);let he,ue,Oe;o[2]===Symbol.for("react.memo_cache_sentinel")?(he=()=>{I().lastReleaseNotesSeen!==e.VERSION&&(M(_temp3),H&&w())},o[2]=he):he=o[2],o[3]!==pe?(ue=[pe,H],o[3]=pe,o[4]=ue):ue=o[4],A(he,ue),o[5]===Symbol.for("react.memo_cache_sentinel")?(Oe=!(fe||H||W(process.env.CONTEXT_CODE_FORCE_FULL_LOGO)||W(process.env.CLAUDE_CODE_FORCE_FULL_LOGO)),o[5]=Oe):Oe=o[5];const Te=Oe;let De,Xe,Se,ge;o[6]!==me?(De=()=>{!me||H||Te||ee()},Xe=[me,H,Te],o[6]=me,o[7]=De,o[8]=Xe):(De=o[7],Xe=o[8]),A(De,Xe),o[9]!==me||o[10]!==ae?(Se=()=>{!ae||H||me||Te||re()},ge=[ae,H,me,Te],o[9]=me,o[10]=ae,o[11]=Se,o[12]=ge):(Se=o[11],ge=o[12]),A(Se,ge);const Ne=ie(),Ue=ce(Ne),{version:Le,cwd:ve,billingType:Ie,agentName:Me}=T(),be=de??Me,je=Ue+se(Ne,_e);let Fe;o[13]!==je?(Fe=D(je,30),o[13]=je,o[14]=Fe):Fe=o[14];const xe=Fe;if(!(fe||H||W(process.env.CONTEXT_CODE_FORCE_FULL_LOGO)||W(process.env.CLAUDE_CODE_FORCE_FULL_LOGO))){let e,s,i,c,a,d,_,p,C,E,f,h,u;return o[15]===Symbol.for("react.memo_cache_sentinel")?(e=r(z,{}),s=r(B,{}),i=r(q,{}),c=J&&r(J.ChannelsNotice,{}),a=F()&&n(l,{paddingLeft:2,flexDirection:"column",children:[r(m,{color:"warning",children:"Debug mode enabled"}),n(m,{dimColor:!0,children:["Logging to: ",x()?"stderr":R()]})]}),d=r(Y,{}),_=(process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION)&&n(l,{paddingLeft:2,flexDirection:"column",children:[n(m,{dimColor:!0,children:["tmux session: ",process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION]}),r(m,{dimColor:!0,children:process.env.CONTEXT_CODE_TMUX_PREFIX_CONFLICTS??process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Claude uses ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),o[15]=e,o[16]=s,o[17]=i,o[18]=c,o[19]=a,o[20]=d,o[21]=_):(e=o[15],s=o[16],i=o[17],c=o[18],a=o[19],d=o[20],_=o[21]),o[22]!==Ee||o[23]!==pe?(p=Ee&&n(l,{paddingLeft:2,flexDirection:"column",children:[!process.env.IS_DEMO&&pe.oauthAccount?.organizationName&&n(m,{dimColor:!0,children:["Message from ",pe.oauthAccount.organizationName,":"]}),r(m,{children:Ee})]}),o[22]=Ee,o[23]=pe,o[24]=p):p=o[24],o[25]===Symbol.for("react.memo_cache_sentinel")?(C=!1,E=!1,f=!1,h=!1,o[25]=C,o[26]=E,o[27]=f,o[28]=h):(C=o[25],E=o[26],f=o[27],h=o[28]),o[29]!==p?(u=n(t,{children:[e,s,i,c,a,d,_,p,C,E,f,h]}),o[29]=p,o[30]=u):u=o[30],u}const Re=p(X),Ae=b(I().theme),ye=` ${a("claude",Ae)("CTX")} ${a("inactive",Ae)(`v${Le}`)} `,Pe=a("claude",Ae)(" CTX ");if("compact"===Re){let e=f(i);if(_(e)>X-4){let r;o[31]===Symbol.for("react.memo_cache_sentinel")?(r=f(null),o[31]=r):r=o[31],e=r}const s=h(ve,Math.max(X-4,10));let c,a,d,p,C,E,u,O,T;return o[32]!==Pe?(c={content:Pe,position:"top",align:"start",offset:1},o[32]=Pe,o[33]=c):c=o[33],o[34]===Symbol.for("react.memo_cache_sentinel")?(a=r(l,{marginY:1,children:r(S,{})}),o[34]=a):a=o[34],o[35]!==xe?(d=r(m,{dimColor:!0,children:xe}),o[35]=xe,o[36]=d):d=o[36],o[37]===Symbol.for("react.memo_cache_sentinel")?(p=r(B,{}),C=r(q,{}),E=J&&r(J.ChannelsNotice,{}),o[37]=p,o[38]=C,o[39]=E):(p=o[37],C=o[38],E=o[39]),o[40]!==le?(u=le&&r(l,{marginTop:1,flexDirection:"column",children:r(m,{color:"warning",children:"Tus comandos bash se ejecutarán en sandbox. Desactiva con /sandbox."})}),o[40]=le,o[41]=u):u=o[41],o[42]===Symbol.for("react.memo_cache_sentinel")?(O=!1,T=!1,o[42]=O,o[43]=T):(O=o[42],T=o[43]),n(t,{children:[r(V,{children:n(l,{flexDirection:"column",borderStyle:"round",borderColor:"claude",borderText:c,paddingX:2,paddingY:1,alignItems:"center",width:X,children:[r(m,{color:"claude",children:"CTX"}),r(m,{bold:!0,children:e}),a,r(m,{dimColor:!0,children:xe}),r(m,{dimColor:!0,children:Ie}),be?n(m,{dimColor:!0,children:["@",be]}):null,r(m,{dimColor:!0,children:s})]})}),p,C,E,u,O,T]})}const $e=f(i),we=!process.env.IS_DEMO&&pe.oauthAccount?.organizationName?`${xe} · ${Ie} · ${pe.oauthAccount.organizationName}`:`${xe} · ${Ie}`,ze=be?49-_(be)-3:50,Ve=h(ve,Math.max(ze,10)),Ge=be?`@${be} · ${Ve}`:Ve,ke=E($e,Ge,we),{leftWidth:We,rightWidth:He}=C(X,Re,ke),Ke=V,Ye=l;let Be;o[44]!==ye?(Be={content:ye,position:"top",align:"start",offset:3},o[44]=ye,o[45]=Be):Be=o[45];const qe=l,Je="column";let Qe,Ze,eo,oo,ro,no,to;o[46]!==$e?(Qe=r(l,{marginTop:1,children:r(m,{bold:!0,children:$e})}),o[46]=$e,o[47]=Qe):Qe=o[47],o[48]===Symbol.for("react.memo_cache_sentinel")?(Ze=r(S,{}),o[48]=Ze):Ze=o[48],o[49]!==we?(eo=r(m,{dimColor:!0,children:we}),o[49]=we,o[50]=eo):eo=o[50],o[51]!==Ge?(oo=r(m,{dimColor:!0,children:Ge}),o[51]=Ge,o[52]=oo):oo=o[52],o[53]!==eo||o[54]!==oo?(ro=n(l,{flexDirection:"column",alignItems:"center",children:[r(m,{color:"claude",children:"CTX"}),eo,oo]}),o[53]=eo,o[54]=oo,o[55]=ro):ro=o[55],o[56]!==We||o[57]!==Qe||o[58]!==ro?(no=n(l,{flexDirection:"column",width:We,justifyContent:"space-between",alignItems:"center",minHeight:11,children:[Qe,Ze,ro]}),o[56]=We,o[57]=Qe,o[58]=ro,o[59]=no):no=o[59],o[60]!==Re?(to=null,o[60]=Re,o[61]=to):to=o[61];const so=r(g,{feeds:H?[L(P()),N(s)]:me?[N(s),v()]:ae?[N(s),ne()]:[N(s),U(Ce)],maxWidth:Math.max(We,He)});let io,co,lo,mo,ao,_o,po,Co,Eo,fo,ho,uo,Oo,To,Do,Xo;return o[62]!==qe||o[63]!==Je||o[64]!==no||o[65]!==to||o[66]!==so?(io=n(qe,{flexDirection:Je,paddingX:2,gap:2,children:[no,to,so]}),o[62]=qe,o[63]=Je,o[64]=no,o[65]=to,o[66]=so,o[67]=io):io=o[67],o[68]!==Ye||o[69]!==Be||o[70]!==io?(co=r(Ye,{flexDirection:"column",borderStyle:"round",borderColor:"claude",borderText:Be,children:io}),o[68]=Ye,o[69]=Be,o[70]=io,o[71]=co):co=o[71],o[72]!==Ke||o[73]!==co?(lo=r(Ke,{children:co}),o[72]=Ke,o[73]=co,o[74]=lo):lo=o[74],o[75]===Symbol.for("react.memo_cache_sentinel")?(mo=r(B,{}),ao=r(q,{}),_o=J&&r(J.ChannelsNotice,{}),po=F()&&n(l,{paddingLeft:2,flexDirection:"column",children:[r(m,{color:"warning",children:"Debug mode enabled"}),n(m,{dimColor:!0,children:["Logging to: ",x()?"stderr":R()]})]}),Co=r(Y,{}),Eo=(process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION)&&n(l,{paddingLeft:2,flexDirection:"column",children:[n(m,{dimColor:!0,children:["tmux session: ",process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION]}),r(m,{dimColor:!0,children:process.env.CONTEXT_CODE_TMUX_PREFIX_CONFLICTS??process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Claude uses ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),o[75]=mo,o[76]=ao,o[77]=_o,o[78]=po,o[79]=Co,o[80]=Eo):(mo=o[75],ao=o[76],_o=o[77],po=o[78],Co=o[79],Eo=o[80]),o[81]!==Ee||o[82]!==pe?(fo=Ee&&n(l,{paddingLeft:2,flexDirection:"column",children:[!process.env.IS_DEMO&&pe.oauthAccount?.organizationName&&n(m,{dimColor:!0,children:["Message from ",pe.oauthAccount.organizationName,":"]}),r(m,{children:Ee})]}),o[81]=Ee,o[82]=pe,o[83]=fo):fo=o[83],o[84]!==le?(ho=le&&r(l,{paddingLeft:2,flexDirection:"column",children:r(m,{color:"warning",children:"Tus comandos bash se ejecutarán en sandbox. Desactiva con /sandbox."})}),o[84]=le,o[85]=ho):ho=o[85],o[86]===Symbol.for("react.memo_cache_sentinel")?(uo=!1,Oo=!1,To=!1,Do=!1,o[86]=uo,o[87]=Oo,o[88]=To,o[89]=Do):(uo=o[86],Oo=o[87],To=o[88],Do=o[89]),o[90]!==lo||o[91]!==fo||o[92]!==ho?(Xo=n(t,{children:[lo,mo,ao,_o,po,Co,Eo,fo,ho,uo,Oo,To,Do]}),o[90]=lo,o[91]=fo,o[92]=ho,o[93]=Xo):Xo=o[93],Xo}function _temp3(o){return o.lastReleaseNotesSeen===e.VERSION?o:{...o,lastReleaseNotesSeen:e.VERSION}}function _temp2(e){return e.effortValue}function _temp(e){return e.agent}
1
+ import{MACRO as e,feature as o}from"../../recovery/bunBundleShim.js";import{jsx as n,jsxs as r,Fragment as t}from"react/jsx-runtime";import{createRequire as i}from"module";const s=i(import.meta.url);import{c}from"react/compiler-runtime";import{Box as l,Text as m,color as a}from"../../ink.js";import{useTerminalSize as d}from"../../hooks/useTerminalSize.js";import{stringWidth as _}from"../../ink/stringWidth.js";import{getLayoutMode as p,calculateLayoutDimensions as C,formatWelcomeMessage as f,truncatePath as h,getRecentActivitySync as E,getRecentReleaseNotesSync as u,getLogoDisplayData as O}from"../../utils/logoV2Utils.js";import{truncate as T}from"../../utils/format.js";import{getDisplayPath as D}from"../../utils/file.js";import{Clawd as X}from"./Clawd.js";import{FeedColumn as g}from"./FeedColumn.js";import{createRecentActivityFeed as S,createWhatsNewFeed as N,createProjectOnboardingFeed as U,createGuestPassesFeed as L}from"./feedConfigs.js";import{getGlobalConfig as I,saveGlobalConfig as x}from"../../utils/config.js";import{resolveThemeSetting as v}from"../../utils/systemTheme.js";import{getInitialSettings as M}from"../../utils/settings/settings.js";import{isDebugMode as j,isDebugToStdErr as F,getDebugLogPath as b}from"../../utils/debug.js";import{useEffect as R,useState as A}from"react";import{getSteps as P,shouldShowProjectOnboarding as y,incrementProjectOnboardingSeenCount as $}from"../../projectOnboardingState.js";import{CondensedLogo as w}from"./CondensedLogo.js";import{OffscreenFreeze as z}from"../OffscreenFreeze.js";import{checkForReleaseNotesSync as V}from"../../utils/releaseNotes.js";import{getDumpPromptsPath as G}from"../../services/api/dumpPrompts.js";import{isEnvTruthy as k}from"../../utils/envUtils.js";import{getStartupPerfLogPath as W,isDetailedProfilingEnabled as H}from"../../utils/startupProfiler.js";import{EmergencyTip as K}from"./EmergencyTip.js";import{VoiceModeNotice as Y}from"./VoiceModeNotice.js";import{Opus1mMergeNotice as B}from"./Opus1mMergeNotice.js";const q=o("KAIROS")||o("KAIROS_CHANNELS")?s("./ChannelsNotice.js"):null;import{SandboxManager as J}from"../../utils/sandbox/sandbox-adapter.js";import{useShowGuestPassesUpsell as Q,incrementGuestPassesSeenCount as Z}from"./GuestPassesUpsell.js";import{useShowOverageCreditUpsell as ee,incrementOverageCreditUpsellSeenCount as oe,createOverageCreditFeed as ne}from"./OverageCreditUpsell.js";import{useAppState as re}from"../../state/AppState.js";import{getEffortSuffix as te}from"../../utils/effort.js";import{useMainLoopModel as ie}from"../../hooks/useMainLoopModel.js";import{renderModelSetting as se}from"../../utils/model/model.js";const ce=120;export function LogoV2(){const o=c(94),i=E(),s=I().oauthAccount?.displayName??"",{columns:D}=d();let G;o[0]===Symbol.for("react.memo_cache_sentinel")?(G=y(),o[0]=G):G=o[0];const W=G;let H;o[1]===Symbol.for("react.memo_cache_sentinel")?(H=J.isSandboxingEnabled(),o[1]=H):H=o[1];const le=H,me=Q(),ae=ee(),de=re(_temp),_e=re(_temp2),pe=I();let Ce;try{Ce=u(3)}catch{Ce=[]}const[fe]=A(()=>{const e=M().companyAnnouncements;if(e&&0!==e.length)return 1===pe.numStartups?e[0]:e[Math.floor(Math.random()*e.length)]}),{hasReleaseNotes:he}=V(pe.lastReleaseNotesSeen);let Ee,ue,Oe;o[2]===Symbol.for("react.memo_cache_sentinel")?(Ee=()=>{I().lastReleaseNotesSeen!==e.VERSION&&(x(_temp3),W&&$())},o[2]=Ee):Ee=o[2],o[3]!==pe?(ue=[pe,W],o[3]=pe,o[4]=ue):ue=o[4],R(Ee,ue),o[5]===Symbol.for("react.memo_cache_sentinel")?(Oe=!(he||W||k(process.env.CONTEXT_CODE_FORCE_FULL_LOGO)||k(process.env.CLAUDE_CODE_FORCE_FULL_LOGO)),o[5]=Oe):Oe=o[5];const Te=Oe;let De,Xe,ge,Se;o[6]!==me?(De=()=>{!me||W||Te||Z()},Xe=[me,W,Te],o[6]=me,o[7]=De,o[8]=Xe):(De=o[7],Xe=o[8]),R(De,Xe),o[9]!==me||o[10]!==ae?(ge=()=>{!ae||W||me||Te||oe()},Se=[ae,W,me,Te],o[9]=me,o[10]=ae,o[11]=ge,o[12]=Se):(ge=o[11],Se=o[12]),R(ge,Se);const Ne=ie(),Ue=se(Ne),{version:Le,cwd:Ie,billingType:xe,agentName:ve}=O(),Me=de??ve,je=Ue+te(Ne,_e);let Fe;o[13]!==je?(Fe=T(je,100),o[13]=je,o[14]=Fe):Fe=o[14];const be=Fe;if(!(he||W||k(process.env.CONTEXT_CODE_FORCE_FULL_LOGO)||k(process.env.CLAUDE_CODE_FORCE_FULL_LOGO))){let e,i,s,c,a,d,_,p,C,f,h,E,u;return o[15]===Symbol.for("react.memo_cache_sentinel")?(e=n(w,{}),i=n(Y,{}),s=n(B,{}),c=q&&n(q.ChannelsNotice,{}),a=j()&&r(l,{paddingLeft:2,flexDirection:"column",children:[n(m,{color:"warning",children:"Debug mode enabled"}),r(m,{dimColor:!0,children:["Logging to: ",F()?"stderr":b()]})]}),d=n(K,{}),_=(process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION)&&r(l,{paddingLeft:2,flexDirection:"column",children:[r(m,{dimColor:!0,children:["tmux session: ",process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION]}),n(m,{dimColor:!0,children:process.env.CONTEXT_CODE_TMUX_PREFIX_CONFLICTS??process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Claude uses ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),o[15]=e,o[16]=i,o[17]=s,o[18]=c,o[19]=a,o[20]=d,o[21]=_):(e=o[15],i=o[16],s=o[17],c=o[18],a=o[19],d=o[20],_=o[21]),o[22]!==fe||o[23]!==pe?(p=fe&&r(l,{paddingLeft:2,flexDirection:"column",children:[!process.env.IS_DEMO&&pe.oauthAccount?.organizationName&&r(m,{dimColor:!0,children:["Message from ",pe.oauthAccount.organizationName,":"]}),n(m,{children:fe})]}),o[22]=fe,o[23]=pe,o[24]=p):p=o[24],o[25]===Symbol.for("react.memo_cache_sentinel")?(C=!1,f=!1,h=!1,E=!1,o[25]=C,o[26]=f,o[27]=h,o[28]=E):(C=o[25],f=o[26],h=o[27],E=o[28]),o[29]!==p?(u=r(t,{children:[e,i,s,c,a,d,_,p,C,f,h,E]}),o[29]=p,o[30]=u):u=o[30],u}const Re=p(D),Ae=v(I().theme),Pe=` ${a("context",Ae)("CTX")} ${a("inactive",Ae)(`v${Le}`)} `,ye=a("context",Ae)(" CTX ");if("compact"===Re){let e=f(s);if(_(e)>D-4){let n;o[31]===Symbol.for("react.memo_cache_sentinel")?(n=f(null),o[31]=n):n=o[31],e=n}const i=h(Ie,Math.max(D-4,10));let c,a,d,p,C,E,u,O,T;return o[32]!==ye?(c={content:ye,position:"top",align:"start",offset:1},o[32]=ye,o[33]=c):c=o[33],o[34]===Symbol.for("react.memo_cache_sentinel")?(a=n(l,{marginY:1,children:n(X,{})}),o[34]=a):a=o[34],o[35]!==be?(d=n(m,{dimColor:!0,children:be}),o[35]=be,o[36]=d):d=o[36],o[37]===Symbol.for("react.memo_cache_sentinel")?(p=n(Y,{}),C=n(B,{}),E=q&&n(q.ChannelsNotice,{}),o[37]=p,o[38]=C,o[39]=E):(p=o[37],C=o[38],E=o[39]),o[40]!==le?(u=le&&n(l,{marginTop:1,flexDirection:"column",children:n(m,{color:"warning",children:"Tus comandos bash se ejecutarán en sandbox. Desactiva con /sandbox."})}),o[40]=le,o[41]=u):u=o[41],o[42]===Symbol.for("react.memo_cache_sentinel")?(O=!1,T=!1,o[42]=O,o[43]=T):(O=o[42],T=o[43]),r(t,{children:[n(z,{children:r(l,{flexDirection:"column",paddingX:2,paddingY:1,alignItems:"center",width:D,children:[n(m,{color:"context",children:"CTX"}),n(m,{bold:!0,children:e}),a,n(m,{dimColor:!0,children:be}),n(m,{dimColor:!0,children:xe}),Me?r(m,{dimColor:!0,children:["@",Me]}):null,n(m,{dimColor:!0,children:i})]})}),p,C,E,u,O,T]})}const $e=f(s),we=(ze=pe.oauthAccount?.organizationName,ze?ze.replace(/\s*,\s*(Inc\.|Inc|LLC|Ltd\.|Ltd|S\.A\.|S\.A|Corp\.|Corp)\b/gi,"").trim():"");var ze;const Ve=`${be} · ${xe}`,Ge=!process.env.IS_DEMO&&we?`Organización: ${we}`:null,ke=Me?119-_(Me)-3:ce,We=h(Ie,Math.max(ke,10)),He=Me?`@${Me} · ${We}`:We,Ke=Math.max(_($e),23+_(He),23+_(Ve),Ge?23+_(Ge):0),Ye=Math.min(Ke+4,ce),{leftWidth:Be,rightWidth:qe}=C(D,Re,Ye),Je=z,Qe=l;let Ze;o[44]!==Pe?(Ze={content:Pe,position:"top",align:"start",offset:3},o[44]=Pe,o[45]=Ze):Ze=o[45];const eo=l,oo="column";let no,ro,to,io,so,co,lo;o[46]!==$e?(no=n(l,{marginTop:1,children:n(m,{bold:!0,children:$e})}),o[46]=$e,o[47]=no):no=o[47],o[48]===Symbol.for("react.memo_cache_sentinel")?(ro=n(l,{alignSelf:"flex-start",children:n(X,{})}),o[48]=ro):ro=o[48],o[49]!==Ve||o[50]!==Ge?(to=r(l,{flexDirection:"column",alignItems:"flex-start",children:[n(m,{dimColor:!0,children:Ve}),Ge&&n(m,{dimColor:!0,children:Ge})]}),o[49]=Ve,o[50]=to):to=o[50],o[51]!==He?(io=n(m,{dimColor:!0,children:He}),o[51]=He,o[52]=io):io=o[52],o[53]!==to||o[54]!==io?(so=r(l,{flexDirection:"column",alignItems:"center",children:[n(m,{color:"context",children:"CTX"}),to,io]}),o[53]=to,o[54]=io,o[55]=so):so=o[55],o[56]!==Be||o[57]!==no||o[58]!==so?(co=r(l,{flexDirection:"column",width:Be,minHeight:11,children:[n(l,{alignSelf:"flex-start",children:no}),r(l,{flexDirection:"row",alignItems:"center",gap:3,marginTop:1,children:[n(l,{flexDirection:"column",alignItems:"center",width:20,children:n(X,{})}),r(l,{flexDirection:"column",alignItems:"flex-start",flexGrow:1,width:Be-23,children:[to,io]})]})]}),o[56]=Be,o[57]=no,o[58]=so,o[59]=co):co=o[59],o[60]!==Re?(lo=null,o[60]=Re,o[61]=lo):lo=o[61];const mo=n(g,{feeds:W?[U(P()),S(i)]:me?[S(i),L()]:ae?[S(i),ne()]:[S(i),N(Ce)],maxWidth:Math.max(Be,qe)});let ao,_o,po,Co,fo,ho,Eo,uo,Oo,To,Do,Xo,go,So,No,Uo;return o[62]!==eo||o[63]!==oo||o[64]!==co||o[65]!==lo||o[66]!==mo?(ao=r(eo,{flexDirection:oo,paddingX:2,gap:2,children:[co,lo]}),o[62]=eo,o[63]=oo,o[64]=co,o[65]=lo,o[66]=mo,o[67]=ao):ao=o[67],o[68]!==Qe||o[69]!==Ze||o[70]!==ao?(_o=n(Qe,{flexDirection:"column",children:ao}),o[68]=Qe,o[69]=Ze,o[70]=ao,o[71]=_o):_o=o[71],o[72]!==Je||o[73]!==_o?(po=n(Je,{children:_o}),o[72]=Je,o[73]=_o,o[74]=po):po=o[74],o[75]===Symbol.for("react.memo_cache_sentinel")?(Co=n(Y,{}),fo=n(B,{}),ho=q&&n(q.ChannelsNotice,{}),Eo=j()&&r(l,{paddingLeft:2,flexDirection:"column",children:[n(m,{color:"warning",children:"Debug mode enabled"}),r(m,{dimColor:!0,children:["Logging to: ",F()?"stderr":b()]})]}),uo=n(K,{}),Oo=(process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION)&&r(l,{paddingLeft:2,flexDirection:"column",children:[r(m,{dimColor:!0,children:["tmux session: ",process.env.CONTEXT_CODE_TMUX_SESSION??process.env.CLAUDE_CODE_TMUX_SESSION]}),n(m,{dimColor:!0,children:process.env.CONTEXT_CODE_TMUX_PREFIX_CONFLICTS??process.env.CLAUDE_CODE_TMUX_PREFIX_CONFLICTS?`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d (press prefix twice - Claude uses ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX})`:`Detach: ${process.env.CONTEXT_CODE_TMUX_PREFIX??process.env.CLAUDE_CODE_TMUX_PREFIX} d`})]}),o[75]=Co,o[76]=fo,o[77]=ho,o[78]=Eo,o[79]=uo,o[80]=Oo):(Co=o[75],fo=o[76],ho=o[77],Eo=o[78],uo=o[79],Oo=o[80]),o[81]!==fe||o[82]!==pe?(To=fe&&r(l,{paddingLeft:2,flexDirection:"column",children:[!process.env.IS_DEMO&&pe.oauthAccount?.organizationName&&r(m,{dimColor:!0,children:["Message from ",pe.oauthAccount.organizationName,":"]}),n(m,{children:fe})]}),o[81]=fe,o[82]=pe,o[83]=To):To=o[83],o[84]!==le?(Do=le&&n(l,{paddingLeft:2,flexDirection:"column",children:n(m,{color:"warning",children:"Tus comandos bash se ejecutarán en sandbox. Desactiva con /sandbox."})}),o[84]=le,o[85]=Do):Do=o[85],o[86]===Symbol.for("react.memo_cache_sentinel")?(Xo=!1,go=!1,So=!1,No=!1,o[86]=Xo,o[87]=go,o[88]=So,o[89]=No):(Xo=o[86],go=o[87],So=o[88],No=o[89]),o[90]!==po||o[91]!==To||o[92]!==Do?(Uo=r(t,{children:[po,Co,fo,ho,Eo,uo,Oo,To,Do,Xo,go,So,No]}),o[90]=po,o[91]=To,o[92]=Do,o[93]=Uo):Uo=o[93],Uo}function _temp3(o){return o.lastReleaseNotesSeen===e.VERSION?o:{...o,lastReleaseNotesSeen:e.VERSION}}function _temp2(e){return e.effortValue}function _temp(e){return e.agent}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{useEffect as t,useState as m}from"react";import{UP_ARROW as i}from"../../constants/figures.js";import{Box as s,Text as n}from"../../ink.js";import{getGlobalConfig as c,saveGlobalConfig as u}from"../../utils/config.js";import{isOpus1mMergeEnabled as p}from"../../utils/model/model.js";import{AnimatedAsterisk as f}from"./AnimatedAsterisk.js";export function shouldShowOpus1mMergeNotice(){return p()&&(c().opus1mMergeNoticeSeenCount??0)<6}export function Opus1mMergeNotice(){const p=r(4),[l]=m(shouldShowOpus1mMergeNotice);let a,d,g;return p[0]!==l?(a=()=>{if(!l)return;const e=(c().opus1mMergeNoticeSeenCount??0)+1;u(o=>(o.opus1mMergeNoticeSeenCount??0)>=e?o:{...o,opus1mMergeNoticeSeenCount:e})},d=[l],p[0]=l,p[1]=a,p[2]=d):(a=p[1],d=p[2]),t(a,d),l?(p[3]===Symbol.for("react.memo_cache_sentinel")?(g=o(s,{paddingLeft:2,children:[e(f,{char:i}),o(n,{dimColor:!0,children:[" ","Opus now defaults to 1M context · 5x more room, same pricing"]})]}),p[3]=g):g=p[3],g):null}
1
+ import{jsx as e,jsxs as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{useEffect as t,useState as i}from"react";import{UP_ARROW as m}from"../../constants/figures.js";import{Box as s,Text as n}from"../../ink.js";import{getGlobalConfig as c,saveGlobalConfig as u}from"../../utils/config.js";import{isOpus1mMergeEnabled as p}from"../../utils/model/model.js";import{AnimatedAsterisk as f}from"./AnimatedAsterisk.js";export function shouldShowOpus1mMergeNotice(){return p()&&(c().opus1mMergeNoticeSeenCount??0)<0}export function Opus1mMergeNotice(){const p=r(4),[a]=i(shouldShowOpus1mMergeNotice);let l,d,g;return p[0]!==a?(l=()=>{if(!a)return;const e=(c().opus1mMergeNoticeSeenCount??0)+1;u(o=>(o.opus1mMergeNoticeSeenCount??0)>=e?o:{...o,opus1mMergeNoticeSeenCount:e})},d=[a],p[0]=a,p[1]=l,p[2]=d):(l=p[1],d=p[2]),t(l,d),a?(p[3]===Symbol.for("react.memo_cache_sentinel")?(g=o(s,{paddingLeft:2,children:[e(f,{char:m}),o(n,{dimColor:!0,children:[" ","Opus ahora tiene 1M de contexto por defecto · 5x más espacio, mismo precio"]})]}),p[3]=g):g=p[3],g):null}
@@ -1 +1 @@
1
- import{MACRO as r}from"../../recovery/bunBundleShim.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Box as i,Text as n}from"../../ink.js";import{Clawd as d}from"./Clawd.js";export function WelcomeV2(){return e(i,{flexDirection:"column",width:54,children:o(i,{borderStyle:"round",borderColor:"claude",paddingX:3,paddingY:1,flexDirection:"column",alignItems:"center",children:[e(n,{color:"claude",children:"CTX"}),e(n,{bold:!0,children:"Context Code"}),o(n,{dimColor:!0,children:["v",r.VERSION]}),e(i,{marginTop:1,marginBottom:1,children:e(d,{})}),e(n,{children:"Lee, edita y ejecuta sin perder contexto."}),e(n,{dimColor:!0,children:"Configuracion inicial"})]})})}
1
+ import{MACRO as r}from"../../recovery/bunBundleShim.js";import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Box as i,Text as n}from"../../ink.js";import{Clawd as t}from"./Clawd.js";export function WelcomeV2(){return e(i,{flexDirection:"column",width:54,children:o(i,{borderStyle:"round",borderColor:"context",paddingX:3,paddingY:1,flexDirection:"column",alignItems:"center",children:[e(n,{color:"context",children:"CTX"}),e(n,{bold:!0,children:"Context Code"}),o(n,{dimColor:!0,children:["v",r.VERSION]}),e(i,{marginTop:1,marginBottom:1,children:e(t,{})}),e(n,{children:"Lee, edita y ejecuta sin perder contexto."}),e(n,{dimColor:!0,children:"Configuracion inicial"})]})})}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import r from"lodash-es/capitalize.js";import*as i from"react";import{useMemo as n,useState as l}from"react";import{useExitOnCtrlCDWithKeybindings as a}from"../hooks/useExitOnCtrlCDWithKeybindings.js";import{logEvent as s}from"../services/analytics/index.js";import{FAST_MODE_MODEL_DISPLAY as c,isFastModeAvailable as d,isFastModeCooldown as m,isFastModeEnabled as u}from"../utils/fastMode.js";import{Box as f,Text as p,useInput as h}from"../ink.js";import{useKeybindings as v}from"../keybindings/useKeybinding.js";import{useAppState as g,useSetAppState as b}from"../state/AppState.js";import{getGlobalConfig as C,saveGlobalConfig as j}from"../utils/config.js";import{convertEffortValueToLevel as x,getDefaultEffortForModel as E,modelSupportsEffort as P,modelSupportsMaxEffort as S,resolvePickerEffortPersistence as O,toPersistableEffort as M}from"../utils/effort.js";import{getDefaultMainLoopModel as k,modelDisplayString as w,parseUserSpecifiedModel as y}from"../utils/model/model.js";import{getModelOptions as L}from"../utils/model/modelOptions.js";import{getAPIProvider as V}from"../utils/model/providers.js";import{getSettingsForSource as F,updateSettingsForSource as _}from"../utils/settings/settings.js";import{ConfigurableShortcutHint as D}from"./ConfigurableShortcutHint.js";import{Select as I}from"./CustomSelect/index.js";import{Byline as A}from"./design-system/Byline.js";import{KeyboardShortcutHint as H}from"./design-system/KeyboardShortcutHint.js";import{Pane as R}from"./design-system/Pane.js";import{effortLevelToSymbol as B}from"./EffortIndicator.js";const z="__NO_PREFERENCE__",N="__MODEL_HEADER__";function writePickerState(e){j(o=>({...o,modelPickerFavorites:e.favorites,modelPickerRecent:e.recent}))}function providerLabel(e){switch(e){case"firstParty":return"Claude";case"openai":return"OpenAI";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";case"ollama-cloud":return"Ollama Cloud";case"gemini-api":return"Gemini API";case"gemini-google":return"Gemini Google";case"zai":return"Z.AI";case"minimax":return"MiniMax";case"nvidia":return"NVIDIA";default:return e}}function asSelectValue(e){return null===e?z:e}function isHeaderValue(e){return e?.startsWith(N)??!1}function resolveOptionModel(e){if(e&&!isHeaderValue(e))return e===z?k():y(e)}function getDefaultEffortLevelForOption(e){const o=resolveOptionModel(e)??k(),t=E(o);return void 0!==t?x(t):"high"}function EffortLevelIndicator({effort:o}){return e(p,{color:o?"claude":"subtle",children:B(o??"low")})}export function ModelPicker({initial:j,sessionModel:E,onSelect:k,onCancel:y,isStandaloneCommand:B,showFastModeNotice:$,headerText:G,skipSettingsWrite:K,onOpenProvider:U}){const W=b(),T=a(),Z=null===j?z:j,[q,J]=l(Z),[Q,X]=l(()=>function(){const e=C();return{favorites:e.modelPickerFavorites??[],recent:e.modelPickerRecent??[]}}()),Y=g(e=>!!u()&&e.fastMode),[ee,oe]=l(!1),te=g(e=>e.effortValue),[re,ie]=l(void 0!==te?x(te):void 0),[ne,le]=l([]);i.useEffect(()=>{(async()=>{const e=V();if("openai"===e||"openrouter"===e||"ollama"===e||"ollama-cloud"===e||"gemini-api"===e||"gemini-google"===e||"zai"===e||"minimax"===e||"nvidia"===e||"deepseek"===e||"custom-openai"===e){const{getCachedProviderModels:o,fetchProviderModels:t}=await import("../utils/model/providerModels.js"),r=o(e);if(r)le(r);else{const o=await t(e);le(o)}}})()},[]);const ae=n(()=>L(Y??!1),[Y]),se=n(()=>{if(0===ne.length)return ae;const e=new Set;return[...ae,...ne].filter(o=>{const t=o.value??z;return!e.has(t)&&(e.add(t),!0)})},[ae,ne]),ce=n(()=>null===j||se.some(e=>e.value===j)?se:[...se,{value:j,label:w(j),description:"Modelo actual"}],[j,se]),de=n(()=>new Map(ce.map(e=>[asSelectValue(e.value),e])),[ce]),me=n(()=>{const e=ce.map(e=>asSelectValue(e.value)),o=new Set(e),t=Q.favorites.filter(e=>o.has(e)),r=Q.recent.filter(e=>e!==z&&o.has(e)&&!t.includes(e)),i=e.filter(e=>!t.includes(e)&&!r.includes(e)),n=[];if(t.length>0){n.push({value:`${N}:favorites`,label:"Favorites",disabled:!0});for(const e of t){const o=de.get(e);o&&n.push({value:e,label:`★ ${o.label}`,description:o.description})}}if(r.length>0){n.push({value:`${N}:recent`,label:"Recent",disabled:!0});for(const e of r){const o=de.get(e);o&&n.push({value:e,label:o.label,description:o.description})}}n.push({value:`${N}:provider`,label:providerLabel(V()),disabled:!0});for(const e of i){const o=de.get(e);o&&n.push({value:e,label:o.label,description:o.description})}return n},[de,ce,Q.favorites,Q.recent]),ue=n(()=>me.some(e=>e.value===Z&&!e.disabled)?Z:me.find(e=>!e.disabled)?.value,[me,Z]),fe=Math.min(10,me.length),pe=Math.max(0,me.length-fe),he=me.find(e=>e.value===q)?.label,ve=resolveOptionModel(q),ge=!!ve&&P(ve),be=!!ve&&S(ve),Ce=getDefaultEffortLevelForOption(q),je="max"!==re||be?re:"high",handleCycleEffort=e=>{ge&&(ie(o=>function(e,o,t){const r=t?["low","medium","high","max"]:["low","medium","high"],i=r.indexOf(e),n=-1!==i?i:r.indexOf("high");return"right"===o?r[(n+1)%r.length]:r[(n-1+r.length)%r.length]}(o??Ce,e,be)),oe(!0))};v({"modelPicker:decreaseEffort":()=>handleCycleEffort("left"),"modelPicker:increaseEffort":()=>handleCycleEffort("right")},{context:"ModelPicker"}),h((e,o)=>{const t=q;if(t&&!isHeaderValue(t)){if(o.ctrl&&"f"===e.toLowerCase()&&t!==z){const e=Q.favorites.includes(t)?Q.favorites.filter(e=>e!==t):[t,...Q.favorites].slice(0,25),o={...Q,favorites:e};return X(o),void writePickerState(o)}o.ctrl&&"a"===e.toLowerCase()&&U&&U()}});const xe=q&&!isHeaderValue(q)&&q!==z&&Q.favorites.includes(q)?"Unfavorite":"Favorite",Ee=o(f,{flexDirection:"column",children:[o(f,{marginBottom:1,flexDirection:"column",children:[e(p,{color:"remember",bold:!0,children:"Seleccionar modelo"}),e(p,{dimColor:!0,children:G??"Cambia entre modelos. Se aplica a esta sesion y a futuras sesiones de Context Code. Para otros nombres de modelo, usa --model."}),E&&o(p,{dimColor:!0,children:["Usando ",w(E)," en esta sesion (definido por el modo plan). Al elegir otro modelo se deshace este ajuste."]})]}),o(f,{flexDirection:"column",marginBottom:1,children:[e(I,{defaultValue:Z,defaultFocusValue:ue,options:me,onChange:e=>{if(isHeaderValue(e))return;if(s("tengu_model_command_menu_effort",{effort:re}),!K){const o=O(re,getDefaultEffortLevelForOption(e),F("userSettings")?.effortLevel,ee),t=M(o);void 0!==t&&_("userSettings",{effortLevel:t}),W(e=>({...e,effortValue:o}))}const o=ee&&ve&&P(ve)?re:void 0,t=[e,...Q.recent.filter(o=>o!==e)].slice(0,15),r={...Q,recent:t};X(r),writePickerState(r),k(function(e){return e===z?null:e}(e),o)},onFocus:e=>{J(e),ee||void 0!==te||isHeaderValue(e)||ie(getDefaultEffortLevelForOption(e))},onCancel:y??(()=>{}),visibleOptionCount:fe,hideIndexes:!0,layout:"compact-vertical"}),pe>0&&e(f,{paddingLeft:3,children:o(p,{dimColor:!0,children:["y ",pe," más…"]})})]}),e(f,{marginBottom:1,flexDirection:"column",children:o(p,ge?{dimColor:!0,children:[e(EffortLevelIndicator,{effort:je})," ",r("low"===je?"bajo":"medium"===je?"medio":"high"===je?"alto":"máximo")," ","esfuerzo",je===Ce?" (predeterminado)":""," ",e(p,{color:"subtle",children:"← → para ajustar"})]}:{color:"subtle",children:[e(EffortLevelIndicator,{effort:void 0})," Esfuerzo no soportado",he?` para ${String(he)}`:""]})}),u()?$?e(f,{marginBottom:1,children:o(p,{dimColor:!0,children:["El modo rápido está ",e(p,{bold:!0,children:"ACTIVADO"})," y disponible solo con"," ",c," (/fast). Cambiar a otros modelos desactivará el modo rápido."]})}):d()&&!m()?e(f,{marginBottom:1,children:o(p,{dimColor:!0,children:["Usa ",e(p,{bold:!0,children:"/fast"})," para activar el modo rápido (solo"," ",c,")."]})}):null:null,B&&e(p,{dimColor:!0,italic:!0,children:T.pending?o(t,{children:["Presiona ",T.keyName," de nuevo para salir"]}):o(A,{children:[e(H,{shortcut:"Enter",action:"confirmar"}),e(H,{shortcut:"Ctrl+F",action:xe}),e(H,{shortcut:"Ctrl+A",action:"Provider"}),e(D,{action:"select:cancel",context:"Seleccionar",fallback:"Esc",description:"salir"})]})})]});return B?e(R,{color:"permission",children:Ee}):Ee}
1
+ import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import r from"lodash-es/capitalize.js";import*as i from"react";import{useMemo as n,useState as l}from"react";import{useExitOnCtrlCDWithKeybindings as s}from"../hooks/useExitOnCtrlCDWithKeybindings.js";import{logEvent as a}from"../services/analytics/index.js";import{FAST_MODE_MODEL_DISPLAY as c,isFastModeAvailable as d,isFastModeCooldown as u,isFastModeEnabled as f}from"../utils/fastMode.js";import{Box as m,Text as p,useInput as h}from"../ink.js";import{useKeybindings as v}from"../keybindings/useKeybinding.js";import{useAppState as g,useSetAppState as b}from"../state/AppState.js";import{getGlobalConfig as C,saveGlobalConfig as j}from"../utils/config.js";import{convertEffortValueToLevel as x,getDefaultEffortForModel as E,modelSupportsEffort as S,modelSupportsMaxEffort as O,resolvePickerEffortPersistence as P,toPersistableEffort as k}from"../utils/effort.js";import{getDefaultMainLoopModel as M,modelDisplayString as w,parseUserSpecifiedModel as y}from"../utils/model/model.js";import{getModelOptions as L}from"../utils/model/modelOptions.js";import{getAPIProvider as V,isOpenAICompatibleProvider as D}from"../utils/model/providers.js";import{getSettingsForSource as F,updateSettingsForSource as _}from"../utils/settings/settings.js";import{ConfigurableShortcutHint as A}from"./ConfigurableShortcutHint.js";import{Select as I}from"./CustomSelect/index.js";import{Byline as H}from"./design-system/Byline.js";import{KeyboardShortcutHint as R}from"./design-system/KeyboardShortcutHint.js";import{Pane as z}from"./design-system/Pane.js";import{effortLevelToSymbol as B}from"./EffortIndicator.js";const N="__NO_PREFERENCE__",$="__MODEL_HEADER__";function writePickerState(e){j(o=>({...o,modelPickerFavorites:e.favorites,modelPickerRecent:e.recent}))}function providerLabel(e){switch(e){case"firstParty":return"Claude";case"openai":return"OpenAI";case"openrouter":return"OpenRouter";case"ollama":return"Ollama";case"ollama-cloud":return"Ollama Cloud";case"gemini-api":return"Gemini API";case"gemini-google":return"Gemini Google";case"zai":return"Z.AI";case"minimax":return"MiniMax";case"nvidia":return"NVIDIA";case"deepseek":return"DeepSeek";case"custom-openai":return"OpenAI personalizado";case"custom-anthropic":return"Anthropic personalizado";default:return e}}function asSelectValue(e){return null===e?N:e}function isHeaderValue(e){return e?.startsWith($)??!1}function resolveOptionModel(e){if(e&&!isHeaderValue(e))return e===N?M():y(e)}function getDefaultEffortLevelForOption(e){const o=resolveOptionModel(e)??M(),t=E(o);return void 0!==t?x(t):"high"}function EffortLevelIndicator({effort:o}){return e(p,{color:o?"claude":"subtle",children:B(o??"low")})}export function ModelPicker({initial:j,sessionModel:E,onSelect:M,onCancel:y,isStandaloneCommand:B,showFastModeNotice:G,headerText:K,skipSettingsWrite:W,onOpenProvider:T}){const U=b(),Q=s(),Z=null===j?N:j,[q,J]=l(Z),[X,Y]=l(()=>function(){const e=C();return{favorites:e.modelPickerFavorites??[],recent:e.modelPickerRecent??[]}}()),ee=g(e=>!!f()&&e.fastMode),[oe,te]=l(!1),re=g(e=>e.effortValue),[ie,ne]=l(void 0!==re?x(re):void 0),[le,se]=l([]);i.useEffect(()=>{(async()=>{const e=V();if(D(e)){const{getCachedProviderModels:o,fetchProviderModels:t}=await import("../utils/model/providerModels.js"),r=o(e);if(r)se(r);else{const o=await t(e);se(o)}}})()},[]);const ae=n(()=>L(ee??!1),[ee]),ce=n(()=>{if(0===le.length)return ae;const e=new Set;return[...ae,...le].filter(o=>{const t=o.value??N;return!e.has(t)&&(e.add(t),!0)})},[ae,le]),de=n(()=>null===j||ce.some(e=>e.value===j)?ce:[...ce,{value:j,label:w(j),description:"Modelo actual"}],[j,ce]),ue=n(()=>new Map(de.map(e=>[asSelectValue(e.value),e])),[de]),fe=n(()=>{const e=de.map(e=>asSelectValue(e.value)),o=new Set(e),t=X.favorites.filter(e=>o.has(e)),r=X.recent.filter(e=>e!==N&&o.has(e)&&!t.includes(e)),i=e.filter(e=>!t.includes(e)&&!r.includes(e)),n=[];if(t.length>0){n.push({value:`${$}:favorites`,label:"Favoritos",disabled:!0});for(const e of t){const o=ue.get(e);o&&n.push({value:e,label:`★ ${o.label}`,description:o.description})}}if(r.length>0){n.push({value:`${$}:recent`,label:"Recientes",disabled:!0});for(const e of r){const o=ue.get(e);o&&n.push({value:e,label:o.label,description:o.description})}}n.push({value:`${$}:provider`,label:providerLabel(V()),disabled:!0});for(const e of i){const o=ue.get(e);o&&n.push({value:e,label:o.label,description:o.description})}return n},[ue,de,X.favorites,X.recent]),me=n(()=>fe.some(e=>e.value===Z&&!e.disabled)?Z:fe.find(e=>!e.disabled)?.value,[fe,Z]),pe=Math.min(10,fe.length),he=Math.max(0,fe.length-pe),ve=fe.find(e=>e.value===q)?.label,ge=resolveOptionModel(q),be=!!ge&&S(ge),Ce=!!ge&&O(ge),je=getDefaultEffortLevelForOption(q),xe="max"!==ie||Ce?ie:"high",handleCycleEffort=e=>{be&&(ne(o=>function(e,o,t){const r=t?["low","medium","high","max"]:["low","medium","high"],i=r.indexOf(e),n=-1!==i?i:r.indexOf("high");return"right"===o?r[(n+1)%r.length]:r[(n-1+r.length)%r.length]}(o??je,e,Ce)),te(!0))};v({"modelPicker:decreaseEffort":()=>handleCycleEffort("left"),"modelPicker:increaseEffort":()=>handleCycleEffort("right")},{context:"ModelPicker"}),h((e,o)=>{const t=q;if(t&&!isHeaderValue(t)){if(o.ctrl&&"f"===e.toLowerCase()&&t!==N){const e=X.favorites.includes(t)?X.favorites.filter(e=>e!==t):[t,...X.favorites].slice(0,25),o={...X,favorites:e};return Y(o),void writePickerState(o)}o.ctrl&&"a"===e.toLowerCase()&&T&&T()}});const Ee=q&&!isHeaderValue(q)&&q!==N&&X.favorites.includes(q)?"Quitar favorito":"Favorito",Se=o(m,{flexDirection:"column",children:[o(m,{marginBottom:1,flexDirection:"column",children:[e(p,{color:"remember",bold:!0,children:"Seleccionar modelo"}),e(p,{dimColor:!0,children:K??"Cambia entre modelos. Se aplica a esta sesion y a futuras sesiones de Context Code. Para otros nombres de modelo, usa --model."}),E&&o(p,{dimColor:!0,children:["Usando ",w(E)," en esta sesion (definido por el modo plan). Al elegir otro modelo se deshace este ajuste."]})]}),o(m,{flexDirection:"column",marginBottom:1,children:[e(I,{defaultValue:Z,defaultFocusValue:me,options:fe,onChange:e=>{if(isHeaderValue(e))return;if(a("tengu_model_command_menu_effort",{effort:ie}),!W){const o=P(ie,getDefaultEffortLevelForOption(e),F("userSettings")?.effortLevel,oe),t=k(o);void 0!==t&&_("userSettings",{effortLevel:t}),U(e=>({...e,effortValue:o}))}const o=oe&&ge&&S(ge)?ie:void 0,t=[e,...X.recent.filter(o=>o!==e)].slice(0,15),r={...X,recent:t};Y(r),writePickerState(r),M(function(e){return e===N?null:e}(e),o)},onFocus:e=>{J(e),oe||void 0!==re||isHeaderValue(e)||ne(getDefaultEffortLevelForOption(e))},onCancel:y??(()=>{}),visibleOptionCount:pe,hideIndexes:!0,layout:"compact-vertical"}),he>0&&e(m,{paddingLeft:3,children:o(p,{dimColor:!0,children:["y ",he," más…"]})})]}),e(m,{marginBottom:1,flexDirection:"column",children:o(p,be?{dimColor:!0,children:[e(EffortLevelIndicator,{effort:xe})," ",r("low"===xe?"bajo":"medium"===xe?"medio":"high"===xe?"alto":"máximo")," ","esfuerzo",xe===je?" (predeterminado)":""," ",e(p,{color:"subtle",children:"← → para ajustar"})]}:{color:"subtle",children:[e(EffortLevelIndicator,{effort:void 0})," Esfuerzo no soportado",ve?` para ${String(ve)}`:""]})}),f()?G?e(m,{marginBottom:1,children:o(p,{dimColor:!0,children:["El modo rápido está ",e(p,{bold:!0,children:"ACTIVADO"})," y disponible solo con"," ",c," (/fast). Cambiar a otros modelos desactivará el modo rápido."]})}):d()&&!u()?e(m,{marginBottom:1,children:o(p,{dimColor:!0,children:["Usa ",e(p,{bold:!0,children:"/fast"})," para activar el modo rápido (solo"," ",c,")."]})}):null:null,B&&e(p,{dimColor:!0,italic:!0,children:Q.pending?o(t,{children:["Presiona ",Q.keyName," de nuevo para salir"]}):o(H,{children:[e(R,{shortcut:"Enter",action:"confirmar"}),e(R,{shortcut:"Ctrl+F",action:Ee}),e(R,{shortcut:"Ctrl+A",action:"Proveedor"}),e(A,{action:"select:cancel",context:"Seleccionar",fallback:"Esc",description:"salir"})]})})]});return B?e(z,{color:"permission",children:Se}):Se}
@@ -1 +1 @@
1
- import{feature as e}from"../../recovery/bunBundleShim.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{createRequire as r}from"module";const s=r(import.meta.url);import{c as i}from"react/compiler-runtime";const n=e("COORDINATOR_MODE")?s("../../coordinator/coordinatorMode.js"):void 0;import{Box as a,Text as l,Link as c}from"../../ink.js";import m from"figures";import{useEffect as u,useMemo as d,useRef as h,useState as p,useSyncExternalStore as f}from"react";import{isVimModeEnabled as g}from"./utils.js";import{useShortcutDisplay as S}from"../../keybindings/useShortcutDisplay.js";import{isDefaultMode as k,permissionModeSymbol as C,permissionModeTitle as v,getModeColor as j}from"../../utils/permissions/PermissionMode.js";import{BackgroundTaskStatus as O}from"../tasks/BackgroundTaskStatus.js";import{isBackgroundTask as E}from"../../tasks/types.js";import{isPanelAgentTask as b}from"../../tasks/LocalAgentTask/LocalAgentTask.js";import{getVisibleAgentTasks as y}from"../CoordinatorAgentStatus.js";import{count as I}from"../../utils/array.js";import{shouldHideTasksFooter as x}from"../tasks/taskStatusUtils.js";import{isAgentSwarmsEnabled as T}from"../../utils/agentSwarmsEnabled.js";import{TeamStatus as w}from"../teams/TeamStatus.js";import{isInProcessEnabled as M}from"../../utils/swarm/backends/registry.js";import{useAppState as P,useAppStateStore as _}from"../../state/AppState.js";import{getIsRemoteMode as D}from"../../bootstrap/state.js";import V from"./HistorySearchInput.js";import{usePrStatus as A}from"../../hooks/usePrStatus.js";import{KeyboardShortcutHint as F}from"../design-system/KeyboardShortcutHint.js";import{Byline as R}from"../design-system/Byline.js";import{useTerminalSize as H}from"../../hooks/useTerminalSize.js";import{useTasksV2 as L}from"../../hooks/useTasksV2.js";import{formatDuration as U}from"../../utils/format.js";import{VoiceWarmupHint as N}from"./VoiceIndicator.js";import{useVoiceEnabled as B}from"../../hooks/useVoiceEnabled.js";import{useVoiceState as Y}from"../../context/voice.js";import{isFullscreenEnvEnabled as K}from"../../utils/fullscreen.js";import{isXtermJs as Q}from"../../ink/terminal.js";import{useHasSelection as z,useSelection as G}from"../../ink/hooks/use-selection.js";import{getGlobalConfig as W,saveGlobalConfig as q}from"../../utils/config.js";import{getPlatform as J}from"../../utils/platform.js";import{PrBadge as X}from"../PrBadge.js";const Z=e("PROACTIVE")||e("KAIROS")?s("../../proactive/index.js"):null,NO_OP_SUBSCRIBE=e=>()=>{},NULL=()=>null;function ProactiveCountdown(){const e=i(7),o=f(Z?.subscribeToProactiveChanges??NO_OP_SUBSCRIBE,Z?.getNextTickAt??NULL,NULL),[r,s]=p(null);let n,a;if(e[0]!==o?(n=()=>{if(null===o)return void s(null);const update=function(){const e=Math.max(0,Math.ceil((o-Date.now())/1e3));s(e)};update();const e=setInterval(update,1e3);return()=>clearInterval(e)},a=[o],e[0]=o,e[1]=n,e[2]=a):(n=e[1],a=e[2]),u(n,a),null===r)return null;const c=1e3*r;let m,d;return e[3]!==c?(m=U(c,{mostSignificantOnly:!0}),e[3]=c,e[4]=m):m=e[4],e[5]!==m?(d=t(l,{dimColor:!0,children:["esperando"," ",m]}),e[5]=m,e[6]=d):d=e[6],d}export function PromptInputFooterLeftSide(e){const r=i(27),{exitMessage:s,vimMode:n,mode:c,toolPermissionContext:m,suppressHint:u,isLoading:d,tasksSelected:h,teamsSelected:p,tmuxSelected:f,teammateFooterIndex:S,isPasting:k,isSearching:C,historyQuery:v,setHistoryQuery:j,historyFailedMatch:O,onOpenTasksDialog:E}=e;if(s.show){let e;return r[0]!==s.key?(e=t(l,{dimColor:!0,children:["Presiona ",s.key," de nuevo para salir"]},"exit-message"),r[0]=s.key,r[1]=e):e=r[1],e}if(k){let e;return r[2]===Symbol.for("react.memo_cache_sentinel")?(e=o(l,{dimColor:!0,children:"Pegando texto…"},"pasting-message"),r[2]=e):e=r[2],e}let b;r[3]!==C||r[4]!==n?(b=g()&&"INSERT"===n&&!C,r[3]=C,r[4]=n,r[5]=b):b=r[5];const y=b;let I,x;r[6]!==O||r[7]!==v||r[8]!==C||r[9]!==j?(I=C&&o(V,{value:v,onChange:j,historyFailedMatch:O}),r[6]=O,r[7]=v,r[8]=C,r[9]=j,r[10]=I):I=r[10],r[11]!==y?(x=y?o(l,{dimColor:!0,children:"-- INSERT --"},"vim-insert"):null,r[11]=y,r[12]=x):x=r[12];const T=!u&&!y;let w,M;return r[13]!==d||r[14]!==c||r[15]!==E||r[16]!==T||r[17]!==h||r[18]!==S||r[19]!==p||r[20]!==f||r[21]!==m?(w=o(ModeIndicator,{mode:c,toolPermissionContext:m,showHint:T,isLoading:d,tasksSelected:h,teamsSelected:p,teammateFooterIndex:S,tmuxSelected:f,onOpenTasksDialog:E}),r[13]=d,r[14]=c,r[15]=E,r[16]=T,r[17]=h,r[18]=S,r[19]=p,r[20]=f,r[21]=m,r[22]=w):w=r[22],r[23]!==I||r[24]!==x||r[25]!==w?(M=t(a,{justifyContent:"flex-start",gap:1,children:[I,x,w]}),r[23]=I,r[24]=x,r[25]=w,r[26]=M):M=r[26],M}function ModeIndicator({mode:r,toolPermissionContext:s,showHint:i,isLoading:g,tasksSelected:V,teamsSelected:U,tmuxSelected:$,teammateFooterIndex:ee,onOpenTasksDialog:te}){const{columns:oe}=H(),re=S("chat:cycleMode","Chat","shift+tab"),se=P(e=>e.tasks),ie=P(e=>e.teamContext),ne=_(),[ae]=p(()=>ne.getState().remoteSessionUrl),le=P(e=>e.viewSelectionMode),ce=P(e=>e.viewingAgentTaskId),me=P(e=>e.expandedView),ue="teammates"===me,de=A(g,isPrStatusEnabled()),he=(P(e=>"ant"===process.env.USER_TYPE&&void 0!==e.tungstenActiveSession),f(Z?.subscribeToProactiveChanges??NO_OP_SUBSCRIBE,Z?.getNextTickAt??NULL,NULL)),pe=!!e("VOICE_MODE")&&B(),fe=e("VOICE_MODE")?Y(e=>e.voiceState):"idle",ge=!!e("VOICE_MODE")&&Y(e=>e.voiceWarmingUp),Se=z(),ke=G().getState,Ce=null!==he,ve=!!e("COORDINATOR_MODE")&&!0===n?.isCoordinatorMode(),je=d(()=>I(Object.values(se),e=>E(e)&&!("ant"===process.env.USER_TYPE&&b(e))),[se]),Oe=L(),Ee=void 0!==Oe&&Oe.length>0,be=S("chat:cancel","Chat","esc").toLowerCase(),ye=S("app:toggleTodos","Global","ctrl+t"),Ie=S("chat:killAgents","Chat","ctrl+x ctrl+k"),xe=e("VOICE_MODE")?S("voice:pushToTalk","Chat","Space"):"",[Te]=e("VOICE_MODE")?p(()=>(W().voiceFooterHintSeenCount??0)<3):[!1],we=e("VOICE_MODE")?h(!1):null;u(()=>{if(e("VOICE_MODE")){if(!pe||!Te)return;if(we?.current)return;we&&(we.current=!0);const e=(W().voiceFooterHintSeenCount??0)+1;q(t=>(t.voiceFooterHintSeenCount??0)>=e?t:{...t,voiceFooterHintSeenCount:e})}},[pe,Te]);const Me=P(e=>"kill-agents-confirm"===e.notifications.current?.key),Pe=T()&&!M()&&void 0!==ie&&I(Object.values(ie.teammates),e=>"team-lead"!==e.name)>0;if("bash"===r)return o(l,{color:"bashBorder",children:"! para modo bash"});const _e=s?.mode,De=!k(_e),Ve=ce?se[ce]:void 0,Ae="viewing-agent"===le&&"in_process_teammate"===Ve?.type,Fe=Ae&&null!=Ve&&"running"!==Ve.status,Re=je>0||Ae,He=(ve||De?1:0)+(Re?1:0)+(Pe?1:0),Le=isPrStatusEnabled()&&null!==de.number&&null!==de.reviewState&&null!==de.url&&He<2&&(0===He||oe>=80),Ue=He<2,Ne=!ue&&Re&&Object.values(se).some(e=>"in_process_teammate"===e.type)||!ue&&Ae,Be=_e&&De&&!D()?t(l,{color:j(_e),children:[C(_e)," ",v(_e).toLowerCase()," activado",Ue&&t(l,{dimColor:!0,children:[" ",o(F,{shortcut:re,action:"cambiar",parens:!0})]})]},"mode"):null,Ye=[...ae?[o(c,{url:ae,children:t(l,{color:"ide",children:[m.circleDouble," remoto"]})},"remote")]:[],...(process.env.USER_TYPE,[]),...T()&&Pe?[o(w,{teamsSelected:U,showHint:i&&!Re},"teams")]:[],...Le?[o(X,{number:de.number,url:de.url,reviewState:de.reviewState},"pr-status")]:[]],Ke=Object.values(se).some(e=>"in_process_teammate"===e.type&&"running"===e.status),Qe=Object.values(se).some(e=>"local_agent"===e.type&&"running"===e.status),ze=i?function(e,t,r,s,i,n,a,c,m){let u;if(a)switch(n){case"none":u="mostrar tareas";break;case"tasks":u="mostrar compañeros";break;case"teammates":u="ocultar"}else u="tasks"===n?"ocultar tareas":"mostrar tareas";const d=i||a;return[...e?[o(l,{dimColor:!0,children:o(F,{shortcut:t,action:"interrumpir"})},"esc")]:[],...e||!c||m?[]:[o(l,{dimColor:!0,children:o(F,{shortcut:s,action:"detener agentes"})},"kill-agents")],...d?[o(l,{dimColor:!0,children:o(F,{shortcut:r,action:u})},"toggle-tasks")]:[]]}(!!g,be,ye,Ie,!!Ee,me,!!Ke,!!Qe,!!Me):[];if(Fe?Ye.push(o(l,{dimColor:!0,children:o(F,{shortcut:be,action:"volver al líder"})},"esc-return")):(e("PROACTIVE")||e("KAIROS"))&&Ce?Ye.push(o(ProactiveCountdown,{},"proactive")):!Ne&&i&&Ye.push(...ze),Ne){const e=[...Be?[Be]:[],...Ye,...Fe?[]:ze];return t(a,{flexDirection:"column",children:[o(a,{children:o(O,{tasksSelected:V,isViewingTeammate:Ae,teammateFooterIndex:ee,isLeaderIdle:!g,onOpenDialog:te})}),e.length>0&&o(a,{children:o(R,{children:e})})]})}const Ge="ant"===process.env.USER_TYPE&&y(se).length>0,We=!Re||Ne||x(se,ue)?null:o(O,{tasksSelected:V,isViewingTeammate:Ae,teammateFooterIndex:ee,isLeaderIdle:!g,onOpenDialog:te});0!==Ye.length||We||Be||!i||Ye.push(o(l,{dimColor:!0,children:"? para atajos"},"shortcuts-hint"));const qe=W().copyOnSelect??!0,Je=Se&&(!qe||Q());if(e("VOICE_MODE")&&pe&&ge)Ye.push(o(N,{},"voice-warmup"));else if(K()&&Je){const e="macos"===J(),r=e&&(ke()?.lastPressHadAlt??!1);Ye.push(o(l,{dimColor:!0,children:t(R,{children:[!qe&&o(F,{shortcut:"ctrl+c",action:"copy"}),Q()&&(r?o(l,{children:"ajusta macOptionClickForcesSelection en la configuración de VS Code"}):o(F,{shortcut:e?"option+click":"shift+click",action:"selección nativa"}))]})},"selection-copy"))}else e("VOICE_MODE")&&Ye.length>0&&i&&pe&&"idle"===fe&&0===ze.length&&Te&&Ye.push(t(l,{dimColor:!0,children:["mantén ",xe," para hablar"]},"voice-hint"));return(We||Ge)&&i&&!Pe&&Ye.push(o(l,{dimColor:!0,children:o(F,V?{shortcut:"Enter",action:"ver tareas"}:{shortcut:"↓",action:"gestionar"})},"manage-tasks")),0!==Ye.length||We||Be?t(a,{height:1,overflow:"hidden",children:[Be&&t(a,{flexShrink:0,children:[Be,(We||Ye.length>0)&&o(l,{dimColor:!0,children:" · "})]}),We&&t(a,{flexShrink:0,children:[We,Ye.length>0&&o(l,{dimColor:!0,children:" · "})]}),Ye.length>0&&o(l,{wrap:"truncate",children:o(R,{children:Ye})})]}):K()?o(l,{children:" "}):null}function isPrStatusEnabled(){return W().prStatusFooterEnabled??!0}
1
+ import{feature as e}from"../../recovery/bunBundleShim.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{createRequire as r}from"module";const s=r(import.meta.url);import{c as i}from"react/compiler-runtime";const n=e("COORDINATOR_MODE")?s("../../coordinator/coordinatorMode.js"):void 0;import{Box as a,Text as l,Link as c}from"../../ink.js";import m from"figures";import{useEffect as u,useMemo as d,useRef as h,useState as p,useSyncExternalStore as f}from"react";import{isVimModeEnabled as g}from"./utils.js";import{useShortcutDisplay as S}from"../../keybindings/useShortcutDisplay.js";import{isDefaultMode as k,permissionModeSymbol as v,permissionModeTitle as C,getModeColor as j}from"../../utils/permissions/PermissionMode.js";import{BackgroundTaskStatus as O}from"../tasks/BackgroundTaskStatus.js";import{isBackgroundTask as E}from"../../tasks/types.js";import{isPanelAgentTask as b}from"../../tasks/LocalAgentTask/LocalAgentTask.js";import{getVisibleAgentTasks as y}from"../CoordinatorAgentStatus.js";import{count as I}from"../../utils/array.js";import{shouldHideTasksFooter as x}from"../tasks/taskStatusUtils.js";import{isAgentSwarmsEnabled as T}from"../../utils/agentSwarmsEnabled.js";import{TeamStatus as w}from"../teams/TeamStatus.js";import{isInProcessEnabled as M}from"../../utils/swarm/backends/registry.js";import{useAppState as P,useAppStateStore as _}from"../../state/AppState.js";import{getIsRemoteMode as D}from"../../bootstrap/state.js";import V from"./HistorySearchInput.js";import{usePrStatus as A}from"../../hooks/usePrStatus.js";import{KeyboardShortcutHint as F}from"../design-system/KeyboardShortcutHint.js";import{Byline as R}from"../design-system/Byline.js";import{useTerminalSize as H}from"../../hooks/useTerminalSize.js";import{useTasksV2 as L}from"../../hooks/useTasksV2.js";import{formatDuration as U}from"../../utils/format.js";import{VoiceWarmupHint as N}from"./VoiceIndicator.js";import{useVoiceEnabled as B}from"../../hooks/useVoiceEnabled.js";import{useVoiceState as Y}from"../../context/voice.js";import{isFullscreenEnvEnabled as K}from"../../utils/fullscreen.js";import{isXtermJs as Q}from"../../ink/terminal.js";import{useHasSelection as z,useSelection as G}from"../../ink/hooks/use-selection.js";import{getGlobalConfig as W,saveGlobalConfig as q}from"../../utils/config.js";import{getPlatform as J}from"../../utils/platform.js";import{PrBadge as X}from"../PrBadge.js";const Z=e("PROACTIVE")||e("KAIROS")?s("../../proactive/index.js"):null,NO_OP_SUBSCRIBE=e=>()=>{},NULL=()=>null;function ProactiveCountdown(){const e=i(7),o=f(Z?.subscribeToProactiveChanges??NO_OP_SUBSCRIBE,Z?.getNextTickAt??NULL,NULL),[r,s]=p(null);let n,a;if(e[0]!==o?(n=()=>{if(null===o)return void s(null);const update=function(){const e=Math.max(0,Math.ceil((o-Date.now())/1e3));s(e)};update();const e=setInterval(update,1e3);return()=>clearInterval(e)},a=[o],e[0]=o,e[1]=n,e[2]=a):(n=e[1],a=e[2]),u(n,a),null===r)return null;const c=1e3*r;let m,d;return e[3]!==c?(m=U(c,{mostSignificantOnly:!0}),e[3]=c,e[4]=m):m=e[4],e[5]!==m?(d=t(l,{dimColor:!0,children:["esperando"," ",m]}),e[5]=m,e[6]=d):d=e[6],d}export function PromptInputFooterLeftSide(e){const r=i(27),{exitMessage:s,vimMode:n,mode:c,toolPermissionContext:m,suppressHint:u,isLoading:d,tasksSelected:h,teamsSelected:p,tmuxSelected:f,teammateFooterIndex:S,isPasting:k,isSearching:v,historyQuery:C,setHistoryQuery:j,historyFailedMatch:O,onOpenTasksDialog:E}=e;if(s.show){let e;return r[0]!==s.key?(e=t(l,{dimColor:!0,children:["Presiona ",s.key," de nuevo para salir"]},"exit-message"),r[0]=s.key,r[1]=e):e=r[1],e}if(k){let e;return r[2]===Symbol.for("react.memo_cache_sentinel")?(e=o(l,{dimColor:!0,children:"Pegando texto…"},"pasting-message"),r[2]=e):e=r[2],e}let b;r[3]!==v||r[4]!==n?(b=g()&&"INSERT"===n&&!v,r[3]=v,r[4]=n,r[5]=b):b=r[5];const y=b;let I,x;r[6]!==O||r[7]!==C||r[8]!==v||r[9]!==j?(I=v&&o(V,{value:C,onChange:j,historyFailedMatch:O}),r[6]=O,r[7]=C,r[8]=v,r[9]=j,r[10]=I):I=r[10],r[11]!==y?(x=y?o(l,{dimColor:!0,children:"-- INSERT --"},"vim-insert"):null,r[11]=y,r[12]=x):x=r[12];const T=!u&&!y;let w,M;return r[13]!==d||r[14]!==c||r[15]!==E||r[16]!==T||r[17]!==h||r[18]!==S||r[19]!==p||r[20]!==f||r[21]!==m?(w=o(ModeIndicator,{mode:c,toolPermissionContext:m,showHint:T,isLoading:d,tasksSelected:h,teamsSelected:p,teammateFooterIndex:S,tmuxSelected:f,onOpenTasksDialog:E}),r[13]=d,r[14]=c,r[15]=E,r[16]=T,r[17]=h,r[18]=S,r[19]=p,r[20]=f,r[21]=m,r[22]=w):w=r[22],r[23]!==I||r[24]!==x||r[25]!==w?(M=t(a,{justifyContent:"flex-start",gap:1,children:[I,x,w]}),r[23]=I,r[24]=x,r[25]=w,r[26]=M):M=r[26],M}function ModeIndicator({mode:r,toolPermissionContext:s,showHint:i,isLoading:g,tasksSelected:V,teamsSelected:U,tmuxSelected:$,teammateFooterIndex:ee,onOpenTasksDialog:te}){const{columns:oe}=H(),re=S("chat:cycleMode","Chat","shift+tab"),se=P(e=>e.tasks),ie=P(e=>e.teamContext),ne=_(),[ae]=p(()=>ne.getState().remoteSessionUrl),le=P(e=>e.viewSelectionMode),ce=P(e=>e.viewingAgentTaskId),me=P(e=>e.expandedView),ue="teammates"===me,de=A(g,isPrStatusEnabled()),he=(P(e=>"ant"===process.env.USER_TYPE&&void 0!==e.tungstenActiveSession),f(Z?.subscribeToProactiveChanges??NO_OP_SUBSCRIBE,Z?.getNextTickAt??NULL,NULL)),pe=!!e("VOICE_MODE")&&B(),fe=e("VOICE_MODE")?Y(e=>e.voiceState):"idle",ge=!!e("VOICE_MODE")&&Y(e=>e.voiceWarmingUp),Se=z(),ke=G().getState,ve=null!==he,Ce=!!e("COORDINATOR_MODE")&&!0===n?.isCoordinatorMode(),je=d(()=>I(Object.values(se),e=>E(e)&&!("ant"===process.env.USER_TYPE&&b(e))),[se]),Oe=L(),Ee=void 0!==Oe&&Oe.length>0,be=S("chat:cancel","Chat","esc").toLowerCase(),ye=S("app:toggleTodos","Global","ctrl+t"),Ie=S("chat:killAgents","Chat","ctrl+x ctrl+k"),xe=e("VOICE_MODE")?S("voice:pushToTalk","Chat","Space"):"",[Te]=e("VOICE_MODE")?p(()=>(W().voiceFooterHintSeenCount??0)<3):[!1],we=e("VOICE_MODE")?h(!1):null;u(()=>{if(e("VOICE_MODE")){if(!pe||!Te)return;if(we?.current)return;we&&(we.current=!0);const e=(W().voiceFooterHintSeenCount??0)+1;q(t=>(t.voiceFooterHintSeenCount??0)>=e?t:{...t,voiceFooterHintSeenCount:e})}},[pe,Te]);const Me=P(e=>"kill-agents-confirm"===e.notifications.current?.key),Pe=T()&&!M()&&void 0!==ie&&I(Object.values(ie.teammates),e=>"team-lead"!==e.name)>0;if("bash"===r)return o(l,{color:"bashBorder",children:"! para modo bash"});const _e=s?.mode,De=!k(_e),Ve=ce?se[ce]:void 0,Ae="viewing-agent"===le&&"in_process_teammate"===Ve?.type,Fe=Ae&&null!=Ve&&"running"!==Ve.status,Re=je>0||Ae,He=(Ce||De?1:0)+(Re?1:0)+(Pe?1:0),Le=isPrStatusEnabled()&&null!==de.number&&null!==de.reviewState&&null!==de.url&&He<2&&(0===He||oe>=80),Ue=He<2,Ne=!ue&&Re&&Object.values(se).some(e=>"in_process_teammate"===e.type)||!ue&&Ae,Be=_e&&De&&!D()?t(l,{color:j(_e),children:[v(_e)," ",C(_e).toLowerCase()," activado",Ue&&t(l,{dimColor:!0,children:[" ",o(F,{shortcut:re,action:"cambiar",parens:!0})]})]},"mode"):null,Ye=[...ae?[o(c,{url:ae,children:t(l,{color:"ide",children:[m.circleDouble," remoto"]})},"remote")]:[],...(process.env.USER_TYPE,[]),...T()&&Pe?[o(w,{teamsSelected:U,showHint:i&&!Re},"teams")]:[],...Le?[o(X,{number:de.number,url:de.url,reviewState:de.reviewState},"pr-status")]:[]],Ke=Object.values(se).some(e=>"in_process_teammate"===e.type&&"running"===e.status),Qe=Object.values(se).some(e=>"local_agent"===e.type&&"running"===e.status),ze=i?function(e,t,r,s,i,n,a,c,m){let u;if(a)switch(n){case"none":u="mostrar tareas";break;case"tasks":u="mostrar compañeros";break;case"teammates":u="ocultar"}else u="tasks"===n?"ocultar tareas":"mostrar tareas";const d=i||a;return[...e?[o(l,{dimColor:!0,children:o(F,{shortcut:t,action:"interrumpir"})},"esc")]:[],...e||!c||m?[]:[o(l,{dimColor:!0,children:o(F,{shortcut:s,action:"detener agentes"})},"kill-agents")],...d?[o(l,{dimColor:!0,children:o(F,{shortcut:r,action:u})},"toggle-tasks")]:[]]}(!!g,be,ye,Ie,!!Ee,me,!!Ke,!!Qe,!!Me):[];if(Fe?Ye.push(o(l,{dimColor:!0,children:o(F,{shortcut:be,action:"volver al líder"})},"esc-return")):(e("PROACTIVE")||e("KAIROS"))&&ve?Ye.push(o(ProactiveCountdown,{},"proactive")):!Ne&&i&&Ye.push(...ze),Ne){const e=[...Be?[Be]:[],...Ye,...Fe?[]:ze];return t(a,{flexDirection:"column",children:[o(a,{children:o(O,{tasksSelected:V,isViewingTeammate:Ae,teammateFooterIndex:ee,isLeaderIdle:!g,onOpenDialog:te})}),e.length>0&&o(a,{children:o(R,{children:e})})]})}const Ge="ant"===process.env.USER_TYPE&&y(se).length>0,We=!Re||Ne||x(se,ue)?null:o(O,{tasksSelected:V,isViewingTeammate:Ae,teammateFooterIndex:ee,isLeaderIdle:!g,onOpenDialog:te}),qe=W().copyOnSelect??!0,Je=Se&&(!qe||Q());if(e("VOICE_MODE")&&pe&&ge)Ye.push(o(N,{},"voice-warmup"));else if(K()&&Je){const e="macos"===J(),r=e&&(ke()?.lastPressHadAlt??!1);Ye.push(o(l,{dimColor:!0,children:t(R,{children:[!qe&&o(F,{shortcut:"ctrl+c",action:"copy"}),Q()&&(r?o(l,{children:"ajusta macOptionClickForcesSelection en la configuración de VS Code"}):o(F,{shortcut:e?"option+click":"shift+click",action:"selección nativa"}))]})},"selection-copy"))}else e("VOICE_MODE")&&Ye.length>0&&i&&pe&&"idle"===fe&&0===ze.length&&Te&&Ye.push(t(l,{dimColor:!0,children:["mantén ",xe," para hablar"]},"voice-hint"));return(We||Ge)&&i&&!Pe&&Ye.push(o(l,{dimColor:!0,children:o(F,V?{shortcut:"Enter",action:"ver tareas"}:{shortcut:"↓",action:"gestionar"})},"manage-tasks")),0!==Ye.length||We||Be?t(a,{height:1,overflow:"hidden",children:[Be&&t(a,{flexShrink:0,children:[Be,(We||Ye.length>0)&&o(l,{dimColor:!0,children:" · "})]}),We&&t(a,{flexShrink:0,children:[We,Ye.length>0&&o(l,{dimColor:!0,children:" · "})]}),Ye.length>0&&o(l,{wrap:"truncate",children:o(R,{children:Ye})})]}):K()?o(l,{children:" "}):null}function isPrStatusEnabled(){return W().prStatusFooterEnabled??!0}
@@ -0,0 +1 @@
1
+ import{jsxs as o,jsx as r}from"react/jsx-runtime";import{getTotalCost as e,getTotalInputTokens as t,getTotalOutputTokens as i}from"../cost-tracker.js";import{useMainLoopModel as n}from"../hooks/useMainLoopModel.js";import{Box as s,Text as m}from"../ink.js";import{getAPIProvider as l}from"../utils/model/providers.js";import{getCurrentUsage as d}from"../utils/tokens.js";function formatNumber(o){return o>=1e6?`${(o/1e6).toFixed(2)}M`:o>=1e3?`${(o/1e3).toFixed(1)}k`:String(o)}export const SessionTokenFooter=({messages:c})=>{const a=l(),u=n(),f=t(),p=i(),h=d(c),k=h?.input_tokens??0,j=h?.output_tokens??0,x=e(),b="firstParty"===a||"openai"===a||"bedrock"===a||"vertex"===a||"foundry"===a;return r(s,{paddingX:2,children:o(m,{dimColor:!0,children:[a," · ",u||"sin modelo"," ",o(m,{color:"cyan",children:["↑ ",formatNumber(f)]})," / ",o(m,{color:"green",children:["↓ ",formatNumber(p)]})," tokens en esta sesion",h&&o(m,{dimColor:!0,children:[" · ultima respuesta: ",r(m,{color:"cyan",children:formatNumber(k)})," / ",r(m,{color:"green",children:formatNumber(j)})]}),x>0&&o(m,{dimColor:!0,children:[" · ",o(m,{color:"yellow",children:["$",x.toFixed(4)]}),b?"":" (estimado)"]})]})})};
@@ -1 +1 @@
1
- import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as r,Fragment as n}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import{Box as i,Text as s}from"../ink.js";import{useEffect as a,useMemo as l,useRef as c,useState as m}from"react";import{computeGlimmerIndex as d,computeShimmerSegments as u,SHIMMER_INTERVAL_MS as p}from"../bridge/bridgeStatusUtil.js";import{getKairosActive as f,getUserMsgOptIn as h}from"../bootstrap/state.js";import{getFeatureValue_CACHED_MAY_BE_STALE as g}from"../services/analytics/growthbook.js";import{isEnvTruthy as v}from"../utils/envUtils.js";import{count as I}from"../utils/array.js";import j from"lodash-es/sample.js";import{formatDuration as T,formatNumber as b}from"../utils/format.js";import{activityManager as k}from"../utils/activityManager.js";import{getSpinnerVerbs as x}from"../constants/spinnerVerbs.js";import{MessageResponse as S}from"./MessageResponse.js";import{TaskListV2 as w}from"./TaskListV2.js";import{useTasksV2 as C}from"../hooks/useTasksV2.js";import{useAppState as M}from"../state/AppState.js";import{useTerminalSize as R}from"../hooks/useTerminalSize.js";import{stringWidth as _}from"../ink/stringWidth.js";import{getDefaultCharacters as D}from"./Spinner/index.js";import{SpinnerAnimationRow as y}from"./Spinner/SpinnerAnimationRow.js";import{useSettings as A}from"../hooks/useSettings.js";import{isInProcessTeammateTask as O}from"../tasks/InProcessTeammateTask/types.js";import{isBackgroundTask as $}from"../tasks/types.js";import{getAllInProcessTeammateTasks as B}from"../tasks/InProcessTeammateTask/InProcessTeammateTask.js";import{getEffortSuffix as E}from"../utils/effort.js";import{getMainLoopModel as V}from"../utils/model/model.js";import{getViewedTeammateTask as L}from"../state/selectors.js";import{TEARDROP_ASTERISK as U}from"../constants/figures.js";import P from"figures";import{getCurrentTurnTokenBudget as W,getTurnOutputTokens as F}from"../bootstrap/state.js";import{TeammateSpinnerTree as K}from"./Spinner/TeammateSpinnerTree.js";import{useAnimationFrame as q}from"../ink.js";import{getGlobalConfig as z}from"../utils/config.js";const N=D(),G=[...N,...[...N].reverse()];export function SpinnerWithVerb(r){const n=M(e=>e.isBriefOnly),o=M(e=>e.viewingAgentTaskId),i=!(!e("KAIROS")&&!e("KAIROS_BRIEF"))&&l(()=>v(process.env.CONTEXT_CODE_BRIEF)||v(process.env.CLAUDE_CODE_BRIEF),[]);return(e("KAIROS")||e("KAIROS_BRIEF"))&&(f()||h()&&(i||g("tengu_kairos_brief",!1)))&&n&&!o?t(BriefSpinner,{mode:r.mode,overrideMessage:r.overrideMessage}):t(SpinnerWithVerbInner,{...r})}function SpinnerWithVerbInner({mode:n,loadingStartTimeRef:o,totalPausedMsRef:l,pauseStartTimeRef:d,spinnerTip:u,responseLengthRef:p,overrideColor:f,overrideShimmerColor:h,overrideMessage:g,spinnerSuffix:v,verbose:I,hasActiveTools:_=!1,leaderIsIdle:D=!1}){const $=A().prefersReducedMotion??!1,q=M(e=>e.tasks),z=M(e=>e.viewingAgentTaskId),N=M(e=>e.expandedView),G="tasks"===N,X="teammates"===N,H=M(e=>e.selectedIPAgentIndex),J=M(e=>e.viewSelectionMode),Q=z?L({viewingAgentTaskId:z,tasks:q}):void 0,{columns:Y}=R(),Z=C(),[ee,te]=m(null),re=c(null);a(()=>{let e=null,t=null;if("thinking"===n)null===re.current&&(re.current=Date.now(),te("thinking"));else if(null!==re.current){const r=Date.now()-re.current,n=Date.now()-re.current,o=Math.max(0,2e3-n);re.current=null;const showDuration=()=>{te(r),t=setTimeout(te,2e3,null)};o>0?e=setTimeout(showDuration,o):showDuration()}return()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[n]);const ne=Z?.find(e=>"pending"!==e.status&&"completed"!==e.status),oe=function(e){if(!e)return;const t=e.filter(e=>"pending"===e.status);if(0===t.length)return;const r=new Set(e.filter(e=>"completed"!==e.status).map(e=>e.id));return t.find(e=>!e.blockedBy.some(e=>r.has(e)))??t[0]}(Z),[ie]=m(()=>j(x())),se=g??ne?.activeForm??ne?.subject??ie,ae=(Q&&!Q.isIdle?Q.spinnerVerb??ie:se)+"...";a(()=>{const e="spinner-"+n;return k.startCLIActivity(e),()=>{k.endCLIActivity(e)}},[n]);const le=M(e=>e.effortValue),ce=E(V(),le),me=B(q).filter(e=>"running"===e.status),de=me.length>0,ue=de&&me.every(e=>e.isIdle);let pe=0;if(!X)for(const e of Object.values(q))O(e)&&"running"===e.status&&e.progress?.tokenCount&&(pe+=e.progress.tokenCount);const fe=null!==d.current?d.current-o.current-l.current:Date.now()-o.current-l.current,he=Math.round(p.current/4),ge=f??"claude",ve=h??"claudeShimmer";if(D&&de&&!Q)return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(i,{flexDirection:"row",flexWrap:"wrap",marginTop:1,width:"100%",children:r(s,{dimColor:!0,children:[U," Inactivo",!ue&&" · companeros ejecutandose"]})}),X&&t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderTokenCount:he,leaderIdleText:"Inactivo"})]});if(Q?.isIdle){const e=ue?`${U} Trabajo durante ${T(Date.now()-Q.startTime)}`:`${U} Inactivo`;return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(i,{flexDirection:"row",flexWrap:"wrap",marginTop:1,width:"100%",children:t(s,{dimColor:!0,children:e})}),X&&de&&t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderVerb:D?void 0:se,leaderIdleText:D?"Inactivo":void 0,leaderTokenCount:he})]})}const Ie=u;let je=null;if(e("TOKEN_BUDGET")){const e=W();if(null!==e&&e>0){const t=F();if(t>=e)je=`Objetivo: ${b(t)} usados (${b(e)} min ${P.tick})`;else{const r=Math.round(t/e*100),n=fe>5e3&&t>=2e3?t/fe:0,o=n>0?` · ~${T((e-t)/n,{mostSignificantOnly:!0})}`:"";je=`Objetivo: ${b(t)} / ${b(e)} (${r}%)${o}`}}}return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(y,{mode:n,reducedMotion:$,hasActiveTools:_,responseLengthRef:p,message:ae,messageColor:ge,shimmerColor:ve,overrideColor:f,loadingStartTimeRef:o,totalPausedMsRef:l,pauseStartTimeRef:d,spinnerSuffix:v,verbose:I,columns:Y,hasRunningTeammates:de,teammateTokens:pe,foregroundedTeammate:Q,leaderIsIdle:D,thinkingStatus:ee,effortSuffix:ce}),X&&de?t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderVerb:D?void 0:se,leaderIdleText:D?"Inactivo":void 0,leaderTokenCount:he}):G&&Z&&Z.length>0?t(i,{width:"100%",flexDirection:"column",children:t(S,{children:t(w,{tasks:Z})})}):oe||Ie||je?r(i,{width:"100%",flexDirection:"column",children:[je&&t(S,{children:t(s,{dimColor:!0,children:je})}),(oe||Ie)&&t(S,{children:t(s,{dimColor:!0,children:oe?`Siguiente: ${oe.subject}`:`Consejo: ${Te=Ie,"Double-tap esc to rewind the code and/or conversation to a previous point in time"===Te?"Pulsa dos veces Esc para rebobinar el codigo y/o la conversacion a un punto anterior en el tiempo":"Double-tap esc to rewind the conversation to a previous point in time"===Te?"Pulsa dos veces Esc para rebobinar la conversacion a un punto anterior en el tiempo":"Use /btw to ask a quick side question without interrupting Claude's current work"===Te||"Usa /btw para hacer una pregunta rapida sin interrumpir el trabajo actual de Context"===Te?"Usa /btw para hacer una pregunta rápida sin interrumpir el trabajo actual de Context":"Use /clear to start fresh when switching topics and free up context"===Te?"Usa /clear para empezar de cero al cambiar de tema y liberar contexto":Te}`})})]}):null]});var Te}function BriefSpinner(e){const l=o(31),{mode:c,overrideMessage:f}=e,h=A().prefersReducedMotion??!1,[g]=m(_temp4),v=f??g,I=M(_temp5);let j,T;l[0]!==c?(j=()=>{const e="spinner-"+c;return k.startCLIActivity(e),()=>{k.endCLIActivity(e)}},T=[c],l[0]=c,l[1]=j,l[2]=T):(j=l[1],T=l[2]),a(j,T);const[,b]=q(h?null:120),x=M(_temp6),S="reconnecting"===I||"disconnected"===I,w="reconnecting"===I?"Reconectando":"Desconectado",C=Math.floor(b/300)%3;let D;l[3]!==C||l[4]!==h?(D=h?"… ":".".repeat(C+1).padEnd(3),l[3]=C,l[4]=h,l[5]=D):D=l[5];const y=D;let O;l[6]!==v?(O=_(v),l[6]=v,l[7]=O):O=l[7];const $=O;let B;if(l[8]!==h||l[9]!==S||l[10]!==b||l[11]!==v||l[12]!==$){const e=h||S?-100:d(Math.floor(b/p),$);B=u(v,e),l[8]=h,l[9]=S,l[10]=b,l[11]=v,l[12]=$,l[13]=B}else B=l[13];const{before:E,shimmer:V,after:L}=B,{columns:U}=R(),P=x>0?`${x} en segundo plano`:"";let W;l[14]!==w||l[15]!==S||l[16]!==$?(W=S?_(w):$,l[14]=w,l[15]=S,l[16]=$,l[17]=W):W=l[17];const F=W+3,K=Math.max(1,U-2-F-_(P));let z,N,G;return l[18]!==L||l[19]!==E||l[20]!==w||l[21]!==y||l[22]!==V||l[23]!==S?(z=S?t(s,{color:"error",children:w+y}):r(n,{children:[E?t(s,{dimColor:!0,children:E}):null,V?t(s,{children:V}):null,L?t(s,{dimColor:!0,children:L}):null,t(s,{dimColor:!0,children:y})]}),l[18]=L,l[19]=E,l[20]=w,l[21]=y,l[22]=V,l[23]=S,l[24]=z):z=l[24],l[25]!==K||l[26]!==P?(N=P?r(n,{children:[t(s,{children:" ".repeat(K)}),t(s,{color:"subtle",children:P})]}):null,l[25]=K,l[26]=P,l[27]=N):N=l[27],l[28]!==z||l[29]!==N?(G=r(i,{flexDirection:"row",width:"100%",marginTop:1,paddingLeft:2,children:[z,N]}),l[28]=z,l[29]=N,l[30]=G):G=l[30],G}function _temp6(e){return I(Object.values(e.tasks),$)+e.remoteBackgroundTaskCount}function _temp5(e){return e.remoteConnectionStatus}function _temp4(){return j(x())??"Trabajando"}export function BriefIdleStatus(){const e=o(9),a=M(_temp7),l=M(_temp8),{columns:c}=R(),m="reconnecting"===a||"disconnected"===a?"reconnecting"===a?"Reconectando…":"Desconectado":"",d=l>0?`${l} en segundo plano`:"";if(!m&&!d){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(i,{height:2}),e[0]=r):r=e[0],r}const u=Math.max(1,c-2-_(m)-_(d));let p,f,h;return e[1]!==m?(p=m?t(s,{color:"error",children:m}):null,e[1]=m,e[2]=p):p=e[2],e[3]!==u||e[4]!==d?(f=d?r(n,{children:[t(s,{children:" ".repeat(u)}),t(s,{color:"subtle",children:d})]}):null,e[3]=u,e[4]=d,e[5]=f):f=e[5],e[6]!==p||e[7]!==f?(h=t(i,{marginTop:1,paddingLeft:2,children:r(s,{children:[p,f]})}),e[6]=p,e[7]=f,e[8]=h):h=e[8],h}function _temp8(e){return I(Object.values(e.tasks),$)+e.remoteBackgroundTaskCount}function _temp7(e){return e.remoteConnectionStatus}export function Spinner(){const e=o(8),r=A().prefersReducedMotion??!1,[n,a]=q(r?null:120);if(r){let r,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(s,{color:"text",children:"*"}),e[0]=r):r=e[0],e[1]!==n?(o=t(i,{ref:n,flexWrap:"wrap",height:1,width:2,children:r}),e[1]=n,e[2]=o):o=e[2],o}const l=Math.floor(a/120)%G.length,c=G[l];let m,d;return e[3]!==c?(m=t(s,{color:"text",children:c}),e[3]=c,e[4]=m):m=e[4],e[5]!==n||e[6]!==m?(d=t(i,{ref:n,flexWrap:"wrap",height:1,width:2,children:m}),e[5]=n,e[6]=m,e[7]=d):d=e[7],d}
1
+ import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as r,Fragment as n}from"react/jsx-runtime";import{c as o}from"react/compiler-runtime";import{Box as i,Text as s}from"../ink.js";import{useEffect as a,useMemo as l,useRef as c,useState as m}from"react";import{computeGlimmerIndex as d,computeShimmerSegments as u,SHIMMER_INTERVAL_MS as p}from"../bridge/bridgeStatusUtil.js";import{getKairosActive as f,getUserMsgOptIn as h}from"../bootstrap/state.js";import{getFeatureValue_CACHED_MAY_BE_STALE as g}from"../services/analytics/growthbook.js";import{isEnvTruthy as v}from"../utils/envUtils.js";import{count as I}from"../utils/array.js";import j from"lodash-es/sample.js";import{formatDuration as T,formatNumber as b}from"../utils/format.js";import{activityManager as x}from"../utils/activityManager.js";import{getSpinnerVerbs as k}from"../constants/spinnerVerbs.js";import{MessageResponse as S}from"./MessageResponse.js";import{TaskListV2 as w}from"./TaskListV2.js";import{useTasksV2 as C}from"../hooks/useTasksV2.js";import{useAppState as M}from"../state/AppState.js";import{useTerminalSize as R}from"../hooks/useTerminalSize.js";import{stringWidth as _}from"../ink/stringWidth.js";import{getDefaultCharacters as D}from"./Spinner/index.js";import{SpinnerAnimationRow as y}from"./Spinner/SpinnerAnimationRow.js";import{useSettings as A}from"../hooks/useSettings.js";import{isInProcessTeammateTask as O}from"../tasks/InProcessTeammateTask/types.js";import{isBackgroundTask as $}from"../tasks/types.js";import{getAllInProcessTeammateTasks as B}from"../tasks/InProcessTeammateTask/InProcessTeammateTask.js";import{getEffortSuffix as E}from"../utils/effort.js";import{getMainLoopModel as V}from"../utils/model/model.js";import{getViewedTeammateTask as L}from"../state/selectors.js";import{TEARDROP_ASTERISK as U}from"../constants/figures.js";import P from"figures";import{getCurrentTurnTokenBudget as W,getTurnOutputTokens as F}from"../bootstrap/state.js";import{TeammateSpinnerTree as K}from"./Spinner/TeammateSpinnerTree.js";import{useAnimationFrame as q}from"../ink.js";import{getGlobalConfig as z}from"../utils/config.js";const N=D(),G=[...N,...[...N].reverse()];export function SpinnerWithVerb(r){const n=M(e=>e.isBriefOnly),o=M(e=>e.viewingAgentTaskId),i=!(!e("KAIROS")&&!e("KAIROS_BRIEF"))&&l(()=>v(process.env.CONTEXT_CODE_BRIEF)||v(process.env.CLAUDE_CODE_BRIEF),[]);return(e("KAIROS")||e("KAIROS_BRIEF"))&&(f()||h()&&(i||g("tengu_kairos_brief",!1)))&&n&&!o?t(BriefSpinner,{mode:r.mode,overrideMessage:r.overrideMessage}):t(SpinnerWithVerbInner,{...r})}function SpinnerWithVerbInner({mode:n,loadingStartTimeRef:o,totalPausedMsRef:l,pauseStartTimeRef:d,spinnerTip:u,responseLengthRef:p,overrideColor:f,overrideShimmerColor:h,overrideMessage:g,spinnerSuffix:v,verbose:I,hasActiveTools:_=!1,leaderIsIdle:D=!1}){const $=A().prefersReducedMotion??!1,q=M(e=>e.tasks),z=M(e=>e.viewingAgentTaskId),N=M(e=>e.expandedView),G="tasks"===N,X="teammates"===N,H=M(e=>e.selectedIPAgentIndex),J=M(e=>e.viewSelectionMode),Q=z?L({viewingAgentTaskId:z,tasks:q}):void 0,{columns:Y}=R(),Z=C(),[ee,te]=m(null),re=c(null);a(()=>{let e=null,t=null;if("thinking"===n)null===re.current&&(re.current=Date.now(),te("thinking"));else if(null!==re.current){const r=Date.now()-re.current,n=Date.now()-re.current,o=Math.max(0,2e3-n);re.current=null;const showDuration=()=>{te(r),t=setTimeout(te,2e3,null)};o>0?e=setTimeout(showDuration,o):showDuration()}return()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[n]);const ne=Z?.find(e=>"pending"!==e.status&&"completed"!==e.status),oe=function(e){if(!e)return;const t=e.filter(e=>"pending"===e.status);if(0===t.length)return;const r=new Set(e.filter(e=>"completed"!==e.status).map(e=>e.id));return t.find(e=>!e.blockedBy.some(e=>r.has(e)))??t[0]}(Z),[ie]=m(()=>j(k())),se=g??ne?.activeForm??ne?.subject??ie,ae=(Q&&!Q.isIdle?Q.spinnerVerb??ie:se)+"...";a(()=>{const e="spinner-"+n;return x.startCLIActivity(e),()=>{x.endCLIActivity(e)}},[n]);const le=M(e=>e.effortValue),ce=E(V(),le),me=B(q).filter(e=>"running"===e.status),de=me.length>0,ue=de&&me.every(e=>e.isIdle);let pe=0;if(!X)for(const e of Object.values(q))O(e)&&"running"===e.status&&e.progress?.tokenCount&&(pe+=e.progress.tokenCount);const fe=null!==d.current?d.current-o.current-l.current:Date.now()-o.current-l.current,he=Math.round(p.current/4),ge=f??"context",ve=h??"contextShimmer";if(D&&de&&!Q)return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(i,{flexDirection:"row",flexWrap:"wrap",marginTop:1,width:"100%",children:r(s,{dimColor:!0,children:[U," Inactivo",!ue&&" · companeros ejecutandose"]})}),X&&t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderTokenCount:he,leaderIdleText:"Inactivo"})]});if(Q?.isIdle){const e=ue?`${U} Trabajo durante ${T(Date.now()-Q.startTime)}`:`${U} Inactivo`;return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(i,{flexDirection:"row",flexWrap:"wrap",marginTop:1,width:"100%",children:t(s,{dimColor:!0,children:e})}),X&&de&&t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderVerb:D?void 0:se,leaderIdleText:D?"Inactivo":void 0,leaderTokenCount:he})]})}const Ie=u;let je=null;if(e("TOKEN_BUDGET")){const e=W();if(null!==e&&e>0){const t=F();if(t>=e)je=`Objetivo: ${b(t)} usados (${b(e)} min ${P.tick})`;else{const r=Math.round(t/e*100),n=fe>5e3&&t>=2e3?t/fe:0,o=n>0?` · ~${T((e-t)/n,{mostSignificantOnly:!0})}`:"";je=`Objetivo: ${b(t)} / ${b(e)} (${r}%)${o}`}}}return r(i,{flexDirection:"column",width:"100%",alignItems:"flex-start",children:[t(y,{mode:n,reducedMotion:$,hasActiveTools:_,responseLengthRef:p,message:ae,messageColor:ge,shimmerColor:ve,overrideColor:f,loadingStartTimeRef:o,totalPausedMsRef:l,pauseStartTimeRef:d,spinnerSuffix:v,verbose:I,columns:Y,hasRunningTeammates:de,teammateTokens:pe,foregroundedTeammate:Q,leaderIsIdle:D,thinkingStatus:ee,effortSuffix:ce}),X&&de?t(K,{selectedIndex:H,isInSelectionMode:"selecting-agent"===J,allIdle:ue,leaderVerb:D?void 0:se,leaderIdleText:D?"Inactivo":void 0,leaderTokenCount:he}):G&&Z&&Z.length>0?t(i,{width:"100%",flexDirection:"column",children:t(S,{children:t(w,{tasks:Z})})}):oe||Ie||je?r(i,{width:"100%",flexDirection:"column",children:[je&&t(S,{children:t(s,{dimColor:!0,children:je})}),(oe||Ie)&&t(S,{children:t(s,{dimColor:!0,children:oe?`Siguiente: ${oe.subject}`:`Consejo: ${Te=Ie,"Double-tap esc to rewind the code and/or conversation to a previous point in time"===Te?"Pulsa dos veces Esc para rebobinar el codigo y/o la conversacion a un punto anterior en el tiempo":"Double-tap esc to rewind the conversation to a previous point in time"===Te?"Pulsa dos veces Esc para rebobinar la conversacion a un punto anterior en el tiempo":"Use /btw to ask a quick side question without interrupting Claude's current work"===Te||"Usa /btw para hacer una pregunta rapida sin interrumpir el trabajo actual de Context"===Te?"Usa /btw para hacer una pregunta rápida sin interrumpir el trabajo actual de Context":"Use /clear to start fresh when switching topics and free up context"===Te?"Usa /clear para empezar de cero al cambiar de tema y liberar contexto":Te}`})})]}):null]});var Te}function BriefSpinner(e){const l=o(31),{mode:c,overrideMessage:f}=e,h=A().prefersReducedMotion??!1,[g]=m(_temp4),v=f??g,I=M(_temp5);let j,T;l[0]!==c?(j=()=>{const e="spinner-"+c;return x.startCLIActivity(e),()=>{x.endCLIActivity(e)}},T=[c],l[0]=c,l[1]=j,l[2]=T):(j=l[1],T=l[2]),a(j,T);const[,b]=q(h?null:120),k=M(_temp6),S="reconnecting"===I||"disconnected"===I,w="reconnecting"===I?"Reconectando":"Desconectado",C=Math.floor(b/300)%3;let D;l[3]!==C||l[4]!==h?(D=h?"… ":".".repeat(C+1).padEnd(3),l[3]=C,l[4]=h,l[5]=D):D=l[5];const y=D;let O;l[6]!==v?(O=_(v),l[6]=v,l[7]=O):O=l[7];const $=O;let B;if(l[8]!==h||l[9]!==S||l[10]!==b||l[11]!==v||l[12]!==$){const e=h||S?-100:d(Math.floor(b/p),$);B=u(v,e),l[8]=h,l[9]=S,l[10]=b,l[11]=v,l[12]=$,l[13]=B}else B=l[13];const{before:E,shimmer:V,after:L}=B,{columns:U}=R(),P=k>0?`${k} en segundo plano`:"";let W;l[14]!==w||l[15]!==S||l[16]!==$?(W=S?_(w):$,l[14]=w,l[15]=S,l[16]=$,l[17]=W):W=l[17];const F=W+3,K=Math.max(1,U-2-F-_(P));let z,N,G;return l[18]!==L||l[19]!==E||l[20]!==w||l[21]!==y||l[22]!==V||l[23]!==S?(z=S?t(s,{color:"error",children:w+y}):r(n,{children:[E?t(s,{dimColor:!0,children:E}):null,V?t(s,{children:V}):null,L?t(s,{dimColor:!0,children:L}):null,t(s,{dimColor:!0,children:y})]}),l[18]=L,l[19]=E,l[20]=w,l[21]=y,l[22]=V,l[23]=S,l[24]=z):z=l[24],l[25]!==K||l[26]!==P?(N=P?r(n,{children:[t(s,{children:" ".repeat(K)}),t(s,{color:"subtle",children:P})]}):null,l[25]=K,l[26]=P,l[27]=N):N=l[27],l[28]!==z||l[29]!==N?(G=r(i,{flexDirection:"row",width:"100%",marginTop:1,paddingLeft:2,children:[z,N]}),l[28]=z,l[29]=N,l[30]=G):G=l[30],G}function _temp6(e){return I(Object.values(e.tasks),$)+e.remoteBackgroundTaskCount}function _temp5(e){return e.remoteConnectionStatus}function _temp4(){return j(k())??"Trabajando"}export function BriefIdleStatus(){const e=o(9),a=M(_temp7),l=M(_temp8),{columns:c}=R(),m="reconnecting"===a||"disconnected"===a?"reconnecting"===a?"Reconectando…":"Desconectado":"",d=l>0?`${l} en segundo plano`:"";if(!m&&!d){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(i,{height:2}),e[0]=r):r=e[0],r}const u=Math.max(1,c-2-_(m)-_(d));let p,f,h;return e[1]!==m?(p=m?t(s,{color:"error",children:m}):null,e[1]=m,e[2]=p):p=e[2],e[3]!==u||e[4]!==d?(f=d?r(n,{children:[t(s,{children:" ".repeat(u)}),t(s,{color:"subtle",children:d})]}):null,e[3]=u,e[4]=d,e[5]=f):f=e[5],e[6]!==p||e[7]!==f?(h=t(i,{marginTop:1,paddingLeft:2,children:r(s,{children:[p,f]})}),e[6]=p,e[7]=f,e[8]=h):h=e[8],h}function _temp8(e){return I(Object.values(e.tasks),$)+e.remoteBackgroundTaskCount}function _temp7(e){return e.remoteConnectionStatus}export function Spinner(){const e=o(8),r=A().prefersReducedMotion??!1,[n,a]=q(r?null:120);if(r){let r,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(s,{color:"text",children:"*"}),e[0]=r):r=e[0],e[1]!==n?(o=t(i,{ref:n,flexWrap:"wrap",height:1,width:2,children:r}),e[1]=n,e[2]=o):o=e[2],o}const l=Math.floor(a/120)%G.length,c=G[l];let m,d;return e[3]!==c?(m=t(s,{color:"text",children:c}),e[3]=c,e[4]=m):m=e[4],e[5]!==n||e[6]!==m?(d=t(i,{ref:n,flexWrap:"wrap",height:1,width:2,children:m}),e[5]=n,e[6]=m,e[7]=d):d=e[7],d}
@@ -1 +1 @@
1
- import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import a from"figures";import{Suspense as l,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as w}from"../ink.js";import{useKeybinding as S}from"../keybindings/useKeybinding.js";import{getGlobalConfig as x}from"../utils/config.js";import{formatDuration as D,formatNumber as v}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as C}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as A,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as F}from"./design-system/Pane.js";import{Tab as L,Tabs as R,useTabHeaderFocus as P}from"./design-system/Tabs.js";import{Spinner as B}from"./Spinner.js";const E={"7d":"Últimos 7 días","30d":"Últimos 30 días",all:"Todo el tiempo"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=C("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const a=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando tus estadísticas de Context Code…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(l,{fallback:c,children:t(StatsContent,{allTimePromise:a,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:l,onClose:d}=o,g=c(l),[b,O]=m("all");let P;s[0]===Symbol.for("react.memo_cache_sentinel")?(P={},s[0]=P):P=s[0];const[E,I]=m(P),[U,W]=m(!1),[N,z]=m("Overview"),[q,G]=m(null);let K,Q;s[1]!==b||s[2]!==E?(K=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),C(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=K,s[4]=Q):(K=s[3],Q=s[4]),u(K,Q);const J="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),V="success"===g.type?g.data:null;let X;s[5]!==d?(X=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=X):X=s[6];const Y=X;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],S("confirm:no",Y,Z),s[8]!==N||s[9]!==b||s[10]!==J||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&z(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&J&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=A(_(x().theme)),h=e=>f(e,o.claude),r=18,s=40,a=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),l=i.length+t.length,c=Math.max(2,s-l),u=(n+":").padEnd(a);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const l=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=l[0],u=l.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",v(u)));n.push(""),n.push(row("Sessions",v(t.totalSessions),"Longest session",t.longestSession?D(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),a=bucket(6,10),l=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(a,pct(a)),"11+ shot",fmtBucket(l,pct(l)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${a.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${a.circle} Total: ${i.magenta(v(r))} tokens`),t.push("");const l=n.slice(0,3);for(const[e,n]of l){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${a.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${v(n.inputTokens)} · Out: ${v(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",a=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(a)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(J,N,G)},s[8]=N,s[9]=b,s[10]=J,s[11]=d,s[12]=ee):ee=s[12],w(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Error al cargar estadísticas: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"Aún no hay estadísticas disponibles. ¡Comienza a usar Context Code!"})}),s[15]=e):e=s[15],e}if(!J||!V){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando estadísticas…"})]}),s[16]=e):e=s[16],e}s[17]!==V||s[18]!==b||s[19]!==J||s[20]!==U?(te=t(L,{title:"Resumen",children:t(OverviewTab,{stats:J,allTimeStats:V,dateRange:b,isLoading:U})}),s[17]=V,s[18]=b,s[19]=J,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==J||s[24]!==U?(ne=t(L,{title:"Modelos",children:t(ModelsTab,{stats:J,dateRange:b,isLoading:U})}),s[22]=b,s[23]=J,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"claude",defaultTab:"Resumen",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=q?` · ${"copying…"===q?"copiando…":"copied!"===q?"¡copiado!":"copy failed"===q?"copia fallida":q}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(F,{color:"claude",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let a,l,c,u;return o[0]!==s?(a=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"claude",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=a):a=o[1],o[2]!==a?(l=t(T,{children:a}),o[2]=a,o[3]=l):l=o[3],o[4]!==i?(c=i&&t(B,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==l||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[l,c]}),o[6]=l,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:a}){const{columns:l}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:l})})}),t(DateRangeSelector,{dateRange:i,isLoading:a}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Modelo favorito:"," ",t(y,{color:"claude",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Tokens totales:"," ",t(y,{color:"claude",children:v(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sesiones:"," ",t(y,{color:"claude",children:v(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Sesión más larga:"," ",t(y,{color:"claude",children:D(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Días activos: ",t(y,{color:"claude",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha más larga:"," ",t(y,{color:"claude",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"día":"días"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Día más activo:"," ",t(y,{color:"claude",children:(w=r.peakActivityDay,new Date(w).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha actual:"," ",t(y,{color:"claude",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"día":"días"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Distribución de turnos (shots)"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"claude",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"claude",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"claude",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"claude",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Promedio/sesión:"," ",t(y,{color:"claude",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var w}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`Has usado ~${Math.floor(e)} veces más tokens que en ${o.name}`):n.push(`Has usado el mismo número de tokens que en ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Tu sesión más larga es ~${Math.floor(o)} veces más larga que ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:l}=e,{headerFocused:c,focusHeader:u}=P(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),S=!c;let x;if(o[0]!==S?(x={isActive:S},o[0]=S,o[1]=x):x=o[1],w((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},x),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const D=k.reduce(_temp9,0),v=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),C=M.slice(j),_=d>0,A=d<k.length-4,O=k.length>4;let F;o[3]!==i||o[4]!==l?(F=t(DateRangeSelector,{dateRange:i,isLoading:l}),o[3]=i,o[4]=l,o[5]=F):F=o[5];const L=T,R=C.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)});let B,E;return o[6]!==L||o[7]!==R?(B=t(L,{flexDirection:"column",width:36,children:R}),o[6]=L,o[7]=R,o[8]=B):B=o[8],o[9]!==A||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?a.arrowUp:" "," ",A?a.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," de"," ",k.length," modelos (↑↓ para desplazar)"]})}),o[9]=A,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[v&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens por día"}),t(b,{children:v.chart}),t(y,{color:"subtle",children:v.xAxisLabels}),t(T,{children:v.legend.map(_temp1)})]}),F,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)})}),B]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:l}=e,c=(i.inputTokens+i.outputTokens)/l*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,w,S;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[a.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=v(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=v(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(w=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=w):w=o[17],o[18]!==f||o[19]!==w?(S=n(T,{flexDirection:"column",children:[f,w]}),o[18]=f,o[19]=w,o[20]=S):S=o[20],S}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const l=A(_(x().theme)),c=[O(l.suggestion),O(l.success),O(l.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[l.suggestion,l.success,l.warning];d.push({model:j(t),coloredBullet:f(a.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let a=" ".repeat(n),l=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-l);a+=" ".repeat(n)+t,l=e+t.length}return a}(i,i.length,7)}}
1
+ import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as t,jsxs as n,Fragment as o}from"react/jsx-runtime";import{c as r}from"react/compiler-runtime";import{plot as s}from"asciichart";import i from"chalk";import a from"figures";import{Suspense as l,use as c,useEffect as u,useMemo as d,useState as m}from"react";import p from"strip-ansi";import{useTerminalSize as g}from"../hooks/useTerminalSize.js";import{applyColor as f}from"../ink/colorize.js";import{stringWidth as k}from"../ink/stringWidth.js";import{Ansi as b,Box as T,Text as y,useInput as x}from"../ink.js";import{useKeybinding as w}from"../keybindings/useKeybinding.js";import{getGlobalConfig as S}from"../utils/config.js";import{formatDuration as D,formatNumber as v}from"../utils/format.js";import{generateHeatmap as M}from"../utils/heatmap.js";import{renderModelName as j}from"../utils/model/model.js";import{copyAnsiToClipboard as $}from"../utils/screenshotClipboard.js";import{aggregateClaudeCodeStatsForRange as C}from"../utils/stats.js";import{resolveThemeSetting as _}from"../utils/systemTheme.js";import{getTheme as A,themeColorToAnsi as O}from"../utils/theme.js";import{Pane as F}from"./design-system/Pane.js";import{Tab as L,Tabs as R,useTabHeaderFocus as P}from"./design-system/Tabs.js";import{Spinner as B}from"./Spinner.js";const E={"7d":"Últimos 7 días","30d":"Últimos 30 días",all:"Todo el tiempo"},H=["all","7d","30d"];export function Stats(e){const o=r(4),{onClose:s}=e;let i;o[0]===Symbol.for("react.memo_cache_sentinel")?(i=C("all").then(e=>e&&0!==e.totalSessions?{type:"success",data:e}:{type:"empty"}).catch(e=>({type:"error",message:e instanceof Error?e.message:"Failed to load stats"})),o[0]=i):i=o[0];const a=i;let c,u;return o[1]===Symbol.for("react.memo_cache_sentinel")?(c=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando tus estadísticas de Context Code…"})]}),o[1]=c):c=o[1],o[2]!==s?(u=t(l,{fallback:c,children:t(StatsContent,{allTimePromise:a,onClose:s})}),o[2]=s,o[3]=u):u=o[3],u}function StatsContent(o){const s=r(34),{allTimePromise:l,onClose:d}=o,g=c(l),[b,O]=m("all");let P;s[0]===Symbol.for("react.memo_cache_sentinel")?(P={},s[0]=P):P=s[0];const[E,I]=m(P),[U,W]=m(!1),[N,z]=m("Overview"),[q,G]=m(null);let K,Q;s[1]!==b||s[2]!==E?(K=()=>{if("all"===b)return;if(E[b])return;let e=!1;return W(!0),C(b).then(t=>{e||(I(e=>({...e,[b]:t})),W(!1))}).catch(()=>{e||W(!1)}),()=>{e=!0}},Q=[b,E],s[1]=b,s[2]=E,s[3]=K,s[4]=Q):(K=s[3],Q=s[4]),u(K,Q);const J="all"===b?"success"===g.type?g.data:null:E[b]??("success"===g.type?g.data:null),V="success"===g.type?g.data:null;let X;s[5]!==d?(X=()=>{d("Stats dialog dismissed",{display:"system"})},s[5]=d,s[6]=X):X=s[6];const Y=X;let Z,ee,te,ne,oe;if(s[7]===Symbol.for("react.memo_cache_sentinel")?(Z={context:"Confirmation"},s[7]=Z):Z=s[7],w("confirm:no",Y,Z),s[8]!==N||s[9]!==b||s[10]!==J||s[11]!==d?(ee=(t,n)=>{!n.ctrl||"c"!==t&&"d"!==t||d("Stats dialog dismissed",{display:"system"}),n.tab&&z(_temp),"r"!==t||n.ctrl||n.meta||O(function(e){const t=H.indexOf(e);return H[(t+1)%H.length]}(b)),n.ctrl&&"s"===t&&J&&async function(t,n,o){o("copying…");const r=function(t,n){const o=[];"Overview"===n?o.push(...function(t){const n=[],o=A(_(S().theme)),h=e=>f(e,o.context),r=18,s=40,a=18,row=(e,t,n,o)=>{const i=(e+":").padEnd(r),l=i.length+t.length,c=Math.max(2,s-l),u=(n+":").padEnd(a);return i+h(t)+" ".repeat(c)+u+h(o)};t.dailyActivity.length>0&&(n.push(M(t.dailyActivity,{terminalWidth:56})),n.push(""));const l=Object.entries(t.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),c=l[0],u=l.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0);c&&n.push(row("Favorite model",j(c[0]),"Total tokens",v(u)));n.push(""),n.push(row("Sessions",v(t.totalSessions),"Longest session",t.longestSession?D(t.longestSession.duration):"N/A"));const d=`${t.streaks.currentStreak} ${1===t.streaks.currentStreak?"day":"days"}`,m=`${t.streaks.longestStreak} ${1===t.streaks.longestStreak?"day":"days"}`;n.push(row("Current streak",d,"Longest streak",m));const p=`${t.activeDays}/${t.totalDays}`,g=null!==t.peakActivityHour?`${t.peakActivityHour}:00-${t.peakActivityHour+1}:00`:"N/A";n.push(row("Active days",p,"Peak hour",g)),!1;if(e("SHOT_STATS")&&t.shotDistribution){const e=t.shotDistribution,o=Object.values(e).reduce((e,t)=>e+t,0);if(o>0){const t=(Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0)/o).toFixed(1),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/o*100),fmtBucket=(e,t)=>`${e} (${t}%)`,s=bucket(1,1),i=bucket(2,5),a=bucket(6,10),l=bucket(11);n.push(""),n.push("Shot distribution"),n.push(row("1-shot",fmtBucket(s,pct(s)),"2–5 shot",fmtBucket(i,pct(i)))),n.push(row("6–10 shot",fmtBucket(a,pct(a)),"11+ shot",fmtBucket(l,pct(l)))),n.push(`${"Avg/session:".padEnd(r)}${h(t)}`)}}n.push("");const k=generateFunFactoid(t,u);return n.push(h(k)),n.push(i.gray(`Stats from the last ${t.totalDays} days`)),n}(t)):o.push(...function(e){const t=[],n=Object.entries(e.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens));if(0===n.length)return t.push(i.gray("No model usage data available")),t;const o=n[0],r=n.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),s=generateTokenChart(e.dailyModelTokens,n.map(([e])=>e),80);if(s){t.push(i.bold("Tokens per Day")),t.push(s.chart),t.push(i.gray(s.xAxisLabels));const e=s.legend.map(e=>`${e.coloredBullet} ${e.model}`).join(" · ");t.push(e),t.push("")}t.push(`${a.star} Favorite: ${i.magenta.bold(j(o?.[0]||""))} · ${a.circle} Total: ${i.magenta(v(r))} tokens`),t.push("");const l=n.slice(0,3);for(const[e,n]of l){const o=((n.inputTokens+n.outputTokens)/r*100).toFixed(1);t.push(`${a.bullet} ${i.bold(j(e))} ${i.gray(`(${o}%)`)}`),t.push(i.dim(` In: ${v(n.inputTokens)} · Out: ${v(n.outputTokens)}`))}return t}(t));for(;o.length>0&&""===p(o[o.length-1]).trim();)o.pop();if(o.length>0){const e=o[o.length-1],t=k(e),r="Overview"===n?70:80,s="/stats",a=Math.max(2,r-t-s.length);o[o.length-1]=e+" ".repeat(a)+i.gray(s)}return o.join("\n")}(t,n),s=await $(r);o(s.success?"copied!":"copy failed"),setTimeout(o,2e3,null)}(J,N,G)},s[8]=N,s[9]=b,s[10]=J,s[11]=d,s[12]=ee):ee=s[12],x(ee),"error"===g.type){let e;return s[13]!==g.message?(e=t(T,{marginTop:1,children:n(y,{color:"error",children:["Error al cargar estadísticas: ",g.message]})}),s[13]=g.message,s[14]=e):e=s[14],e}if("empty"===g.type){let e;return s[15]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{marginTop:1,children:t(y,{color:"warning",children:"Aún no hay estadísticas disponibles. ¡Comienza a usar Context Code!"})}),s[15]=e):e=s[15],e}if(!J||!V){let e;return s[16]===Symbol.for("react.memo_cache_sentinel")?(e=n(T,{marginTop:1,children:[t(B,{}),t(y,{children:" Cargando estadísticas…"})]}),s[16]=e):e=s[16],e}s[17]!==V||s[18]!==b||s[19]!==J||s[20]!==U?(te=t(L,{title:"Resumen",children:t(OverviewTab,{stats:J,allTimeStats:V,dateRange:b,isLoading:U})}),s[17]=V,s[18]=b,s[19]=J,s[20]=U,s[21]=te):te=s[21],s[22]!==b||s[23]!==J||s[24]!==U?(ne=t(L,{title:"Modelos",children:t(ModelsTab,{stats:J,dateRange:b,isLoading:U})}),s[22]=b,s[23]=J,s[24]=U,s[25]=ne):ne=s[25],s[26]!==te||s[27]!==ne?(oe=t(T,{flexDirection:"row",gap:1,marginBottom:1,children:n(R,{title:"",color:"context",defaultTab:"Resumen",children:[te,ne]})}),s[26]=te,s[27]=ne,s[28]=oe):oe=s[28];const re=q?` · ${"copying…"===q?"copiando…":"copied!"===q?"¡copiado!":"copy failed"===q?"copia fallida":q}`:"";let se,ie;return s[29]!==re?(se=t(T,{paddingLeft:2,children:n(y,{dimColor:!0,children:["Esc para cancelar · r para recorrer fechas · ctrl+s para copiar",re]})}),s[29]=re,s[30]=se):se=s[30],s[31]!==se||s[32]!==oe?(ie=n(F,{color:"context",children:[oe,se]}),s[31]=se,s[32]=oe,s[33]=ie):ie=s[33],ie}function _temp(e){return"Overview"===e?"Models":"Overview"}function DateRangeSelector(e){const o=r(9),{dateRange:s,isLoading:i}=e;let a,l,c,u;return o[0]!==s?(a=H.map((e,o)=>n(y,{children:[o>0&&t(y,{dimColor:!0,children:" · "}),t(y,e===s?{bold:!0,color:"context",children:E[e]}:{dimColor:!0,children:E[e]})]},e)),o[0]=s,o[1]=a):a=o[1],o[2]!==a?(l=t(T,{children:a}),o[2]=a,o[3]=l):l=o[3],o[4]!==i?(c=i&&t(B,{}),o[4]=i,o[5]=c):c=o[5],o[6]!==l||o[7]!==c?(u=n(T,{marginBottom:1,gap:1,children:[l,c]}),o[6]=l,o[7]=c,o[8]=u):u=o[8],u}function OverviewTab({stats:r,allTimeStats:s,dateRange:i,isLoading:a}){const{columns:l}=g(),c=Object.entries(r.modelUsage).sort(([,e],[,t])=>t.inputTokens+t.outputTokens-(e.inputTokens+e.outputTokens)),u=c[0],m=c.reduce((e,[,t])=>e+t.inputTokens+t.outputTokens,0),p=d(()=>generateFunFactoid(r,m),[r,m]),f="7d"===i?7:"30d"===i?30:r.totalDays;let k=null;if(e("SHOT_STATS")&&r.shotDistribution){const e=r.shotDistribution,t=Object.values(e).reduce((e,t)=>e+t,0);if(t>0){const n=Object.entries(e).reduce((e,[t,n])=>e+parseInt(t,10)*n,0),bucket=(t,n)=>Object.entries(e).filter(([e])=>{const o=parseInt(e,10);return o>=t&&(void 0===n||o<=n)}).reduce((e,[,t])=>e+t,0),pct=e=>Math.round(e/t*100),o=bucket(1,1),r=bucket(2,5),s=bucket(6,10),i=bucket(11);k={avgShots:(n/t).toFixed(1),buckets:[{label:"1-shot",count:o,pct:pct(o)},{label:"2–5 shot",count:r,pct:pct(r)},{label:"6–10 shot",count:s,pct:pct(s)},{label:"11+ shot",count:i,pct:pct(i)}]}}}return n(T,{flexDirection:"column",marginTop:1,children:[s.dailyActivity.length>0&&t(T,{flexDirection:"column",marginBottom:1,children:t(b,{children:M(s.dailyActivity,{terminalWidth:l})})}),t(DateRangeSelector,{dateRange:i,isLoading:a}),n(T,{flexDirection:"row",gap:4,marginBottom:1,children:[t(T,{flexDirection:"column",width:28,children:u&&n(y,{wrap:"truncate",children:["Modelo favorito:"," ",t(y,{color:"context",bold:!0,children:j(u[0])})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Tokens totales:"," ",t(y,{color:"context",children:v(m)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Sesiones:"," ",t(y,{color:"context",children:v(r.totalSessions)})]})}),t(T,{flexDirection:"column",width:28,children:r.longestSession&&n(y,{wrap:"truncate",children:["Sesión más larga:"," ",t(y,{color:"context",children:D(r.longestSession.duration)})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Días activos: ",t(y,{color:"context",children:r.activeDays}),n(y,{color:"subtle",children:["/",f]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha más larga:"," ",t(y,{color:"context",bold:!0,children:r.streaks.longestStreak})," ",1===r.streaks.longestStreak?"día":"días"]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:r.peakActivityDay&&n(y,{wrap:"truncate",children:["Día más activo:"," ",t(y,{color:"context",children:(x=r.peakActivityDay,new Date(x).toLocaleDateString("en-US",{month:"short",day:"numeric"}))})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Racha actual:"," ",t(y,{color:"context",bold:!0,children:s.streaks.currentStreak})," ",1===s.streaks.currentStreak?"día":"días"]})})]}),!1,k&&n(o,{children:[t(T,{marginTop:1,children:t(y,{children:"Distribución de turnos (shots)"})}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[0].label,":"," ",t(y,{color:"context",children:k.buckets[0].count}),n(y,{color:"subtle",children:[" (",k.buckets[0].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[1].label,":"," ",t(y,{color:"context",children:k.buckets[1].count}),n(y,{color:"subtle",children:[" (",k.buckets[1].pct,"%)"]})]})})]}),n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[2].label,":"," ",t(y,{color:"context",children:k.buckets[2].count}),n(y,{color:"subtle",children:[" (",k.buckets[2].pct,"%)"]})]})}),t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:[k.buckets[3].label,":"," ",t(y,{color:"context",children:k.buckets[3].count}),n(y,{color:"subtle",children:[" (",k.buckets[3].pct,"%)"]})]})})]}),t(T,{flexDirection:"row",gap:4,children:t(T,{flexDirection:"column",width:28,children:n(y,{wrap:"truncate",children:["Promedio/sesión:"," ",t(y,{color:"context",children:k.avgShots})]})})})]}),p&&t(T,{marginTop:1,children:t(y,{color:"suggestion",children:p})})]});var x}const I=[{name:"The Little Prince",tokens:22e3},{name:"The Old Man and the Sea",tokens:35e3},{name:"A Christmas Carol",tokens:37e3},{name:"Animal Farm",tokens:39e3},{name:"Fahrenheit 451",tokens:6e4},{name:"The Great Gatsby",tokens:62e3},{name:"Slaughterhouse-Five",tokens:64e3},{name:"Brave New World",tokens:83e3},{name:"The Catcher in the Rye",tokens:95e3},{name:"Harry Potter and the Philosopher's Stone",tokens:103e3},{name:"The Hobbit",tokens:123e3},{name:"1984",tokens:123e3},{name:"To Kill a Mockingbird",tokens:13e4},{name:"Pride and Prejudice",tokens:156e3},{name:"Dune",tokens:244e3},{name:"Moby-Dick",tokens:268e3},{name:"Crime and Punishment",tokens:274e3},{name:"A Game of Thrones",tokens:381e3},{name:"Anna Karenina",tokens:468e3},{name:"Don Quixote",tokens:52e4},{name:"The Lord of the Rings",tokens:576e3},{name:"The Count of Monte Cristo",tokens:603e3},{name:"Les Misérables",tokens:689e3},{name:"War and Peace",tokens:73e4}],U=[{name:"a TED talk",minutes:18},{name:"an episode of The Office",minutes:22},{name:"listening to Abbey Road",minutes:47},{name:"a yoga class",minutes:60},{name:"a World Cup soccer match",minutes:90},{name:"a half marathon (average time)",minutes:120},{name:"the movie Inception",minutes:148},{name:"watching Titanic",minutes:195},{name:"a transatlantic flight",minutes:420},{name:"a full night of sleep",minutes:480}];function generateFunFactoid(e,t){const n=[];if(t>0){const e=I.filter(e=>t>=e.tokens);for(const o of e){const e=t/o.tokens;e>=2?n.push(`Has usado ~${Math.floor(e)} veces más tokens que en ${o.name}`):n.push(`Has usado el mismo número de tokens que en ${o.name}`)}}if(e.longestSession){const t=e.longestSession.duration/6e4;for(const e of U){const o=t/e.minutes;o>=2&&n.push(`Tu sesión más larga es ~${Math.floor(o)} veces más larga que ${e.name}`)}}if(0===n.length)return"";return n[Math.floor(Math.random()*n.length)]}function ModelsTab(e){const o=r(15),{stats:s,dateRange:i,isLoading:l}=e,{headerFocused:c,focusHeader:u}=P(),[d,p]=m(0),{columns:f}=g(),k=Object.entries(s.modelUsage).sort(_temp7),w=!c;let S;if(o[0]!==w?(S={isActive:w},o[0]=w,o[1]=S):S=o[1],x((e,t)=>{t.downArrow&&d<k.length-4&&p(e=>Math.min(e+2,k.length-4)),t.upArrow&&(d>0?p(_temp8):u())},S),0===k.length){let e;return o[2]===Symbol.for("react.memo_cache_sentinel")?(e=t(T,{children:t(y,{color:"subtle",children:"No model usage data available"})}),o[2]=e):e=o[2],e}const D=k.reduce(_temp9,0),v=generateTokenChart(s.dailyModelTokens,k.map(_temp0),f),M=k.slice(d,d+4),j=Math.ceil(M.length/2),$=M.slice(0,j),C=M.slice(j),_=d>0,A=d<k.length-4,O=k.length>4;let F;o[3]!==i||o[4]!==l?(F=t(DateRangeSelector,{dateRange:i,isLoading:l}),o[3]=i,o[4]=l,o[5]=F):F=o[5];const L=T,R=C.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)});let B,E;return o[6]!==L||o[7]!==R?(B=t(L,{flexDirection:"column",width:36,children:R}),o[6]=L,o[7]=R,o[8]=B):B=o[8],o[9]!==A||o[10]!==_||o[11]!==k||o[12]!==d||o[13]!==O?(E=O&&t(T,{marginTop:1,children:n(y,{color:"subtle",children:[_?a.arrowUp:" "," ",A?a.arrowDown:" "," ",d+1,"-",Math.min(d+4,k.length)," de"," ",k.length," modelos (↑↓ para desplazar)"]})}),o[9]=A,o[10]=_,o[11]=k,o[12]=d,o[13]=O,o[14]=E):E=o[14],n(T,{flexDirection:"column",marginTop:1,children:[v&&n(T,{flexDirection:"column",marginBottom:1,children:[t(y,{bold:!0,children:"Tokens por día"}),t(b,{children:v.chart}),t(y,{color:"subtle",children:v.xAxisLabels}),t(T,{children:v.legend.map(_temp1)})]}),F,n(T,{flexDirection:"row",gap:4,children:[t(T,{flexDirection:"column",width:36,children:$.map(e=>{const[n,o]=e;return t(ModelEntry,{model:n,usage:o,totalTokens:D},n)})}),B]}),E]})}function _temp1(e,o){return n(y,{children:[o>0?" · ":"",t(b,{children:e.coloredBullet})," ",e.model]},e.model)}function _temp0(e){const[t]=e;return t}function _temp9(e,t){const[,n]=t;return e+n.inputTokens+n.outputTokens}function _temp8(e){return Math.max(e-2,0)}function _temp7(e,t){const[,n]=e,[,o]=t;return o.inputTokens+o.outputTokens-(n.inputTokens+n.outputTokens)}function ModelEntry(e){const o=r(21),{model:s,usage:i,totalTokens:l}=e,c=(i.inputTokens+i.outputTokens)/l*100;let u;o[0]!==c?(u=c.toFixed(1),o[0]=c,o[1]=u):u=o[1];const d=u;let m,p,g,f,k,b,x,w;return o[2]!==s?(m=j(s),o[2]=s,o[3]=m):m=o[3],o[4]!==m?(p=t(y,{bold:!0,children:m}),o[4]=m,o[5]=p):p=o[5],o[6]!==d?(g=n(y,{color:"subtle",children:["(",d,"%)"]}),o[6]=d,o[7]=g):g=o[7],o[8]!==p||o[9]!==g?(f=n(y,{children:[a.bullet," ",p," ",g]}),o[8]=p,o[9]=g,o[10]=f):f=o[10],o[11]!==i.inputTokens?(k=v(i.inputTokens),o[11]=i.inputTokens,o[12]=k):k=o[12],o[13]!==i.outputTokens?(b=v(i.outputTokens),o[13]=i.outputTokens,o[14]=b):b=o[14],o[15]!==k||o[16]!==b?(x=n(y,{color:"subtle",children:[" ","In: ",k," · Out:"," ",b]}),o[15]=k,o[16]=b,o[17]=x):x=o[17],o[18]!==f||o[19]!==x?(w=n(T,{flexDirection:"column",children:[f,x]}),o[18]=f,o[19]=x,o[20]=w):w=o[20],w}function generateTokenChart(e,t,n){if(e.length<2||0===t.length)return null;const o=n-7,r=Math.min(52,Math.max(20,o));let i;if(e.length>=r)i=e.slice(-r);else{const t=Math.floor(r/e.length);i=[];for(const n of e)for(let e=0;e<t;e++)i.push(n)}const l=A(_(S().theme)),c=[O(l.suggestion),O(l.success),O(l.warning)],u=[],d=[],m=t.slice(0,3);for(let e=0;e<m.length;e++){const t=m[e],n=i.map(e=>e.tokensByModel[t]||0);if(n.some(e=>e>0)){u.push(n);const o=[l.suggestion,l.success,l.warning];d.push({model:j(t),coloredBullet:f(a.bullet,o[e%o.length])})}}if(0===u.length)return null;return{chart:s(u,{height:8,colors:c.slice(0,u.length),format:e=>{let t;return t=e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"k":e.toFixed(0),t.padStart(6)}}),legend:d,xAxisLabels:function(e,t,n){if(0===e.length)return"";const o=Math.min(4,Math.max(2,Math.floor(e.length/8))),r=e.length-6,s=Math.floor(r/(o-1))||1,i=[];for(let t=0;t<o;t++){const n=Math.min(t*s,e.length-1),o=new Date(e[n].date).toLocaleDateString("en-US",{month:"short",day:"numeric"});i.push({pos:n,label:o})}let a=" ".repeat(n),l=0;for(const{pos:e,label:t}of i){const n=Math.max(1,e-l);a+=" ".repeat(n)+t,l=e+t.length}return a}(i,i.length,7)}}
@@ -1 +1 @@
1
- import{jsxs as e,jsx as r}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import o from"figures";import{useState as t}from"react";import{Box as i,Text as l,useAnimationFrame as a}from"../ink.js";import{AppStateProvider as c}from"../state/AppState.js";import{checkOutTeleportedSessionBranch as s,processMessagesForTeleportResume as d,teleportResumeCodeSession as m}from"../utils/teleport.js";const h=["◐","◓","◑","◒"],p=[{key:"validating",label:"Validando sesión"},{key:"fetching_logs",label:"Obteniendo registros de la sesión"},{key:"fetching_branch",label:"Obteniendo información de la rama"},{key:"checking_out",label:"Cambiando a la rama"}];export function TeleportProgress(t){const c=n(16),{currentStep:s,sessionId:d}=t,[m,f]=a(100),g=Math.floor(f/100)%h.length;let u;c[0]!==s?(u=e=>e.key===s,c[0]=s,c[1]=u):u=c[1];const b=p.findIndex(u),k=h[g];let x,y,j,w,C;return c[2]!==k?(x=r(i,{marginBottom:1,children:e(l,{bold:!0,color:"claude",children:[k," Teletransportando sesión…"]})}),c[2]=k,c[3]=x):x=c[3],c[4]!==d?(y=d&&r(i,{marginBottom:1,children:r(l,{dimColor:!0,children:d})}),c[4]=d,c[5]=y):y=c[5],c[6]!==b||c[7]!==g?(j=p.map((n,t)=>{const a=t===b,c=t>b;let s,d;return t<b?(s=o.tick,d="green"):a?(s=h[g],d="claude"):(s=o.circle,d=void 0),e(i,{flexDirection:"row",children:[r(i,{width:2,children:r(l,{color:d,dimColor:c,children:s})}),r(l,{dimColor:c,bold:a,children:n.label})]},n.key)}),c[6]=b,c[7]=g,c[8]=j):j=c[8],c[9]!==j?(w=r(i,{flexDirection:"column",marginLeft:2,children:j}),c[9]=j,c[10]=w):w=c[10],c[11]!==m||c[12]!==x||c[13]!==y||c[14]!==w?(C=e(i,{ref:m,flexDirection:"column",paddingX:1,paddingY:1,children:[x,y,w]}),c[11]=m,c[12]=x,c[13]=y,c[14]=w,c[15]=C):C=c[15],C}export async function teleportWithProgress(e,n){let setStep=()=>{};e.render(r(c,{children:r(function(){const[e,o]=t("validating");return setStep=o,r(TeleportProgress,{currentStep:e,sessionId:n})},{})}));const o=await m(n,setStep);setStep("checking_out");const{branchName:i,branchError:l}=await s(o.branch);return{messages:d(o.log,l),branchName:i}}
1
+ import{jsxs as e,jsx as r}from"react/jsx-runtime";import{c as n}from"react/compiler-runtime";import t from"figures";import{useState as o}from"react";import{Box as i,Text as l,useAnimationFrame as c}from"../ink.js";import{AppStateProvider as a}from"../state/AppState.js";import{checkOutTeleportedSessionBranch as s,processMessagesForTeleportResume as d,teleportResumeCodeSession as m}from"../utils/teleport.js";const h=["◐","◓","◑","◒"],p=[{key:"validating",label:"Validando sesión"},{key:"fetching_logs",label:"Obteniendo registros de la sesión"},{key:"fetching_branch",label:"Obteniendo información de la rama"},{key:"checking_out",label:"Cambiando a la rama"}];export function TeleportProgress(o){const a=n(16),{currentStep:s,sessionId:d}=o,[m,f]=c(100),g=Math.floor(f/100)%h.length;let u;a[0]!==s?(u=e=>e.key===s,a[0]=s,a[1]=u):u=a[1];const b=p.findIndex(u),x=h[g];let k,y,j,w,C;return a[2]!==x?(k=r(i,{marginBottom:1,children:e(l,{bold:!0,color:"context",children:[x," Teletransportando sesión…"]})}),a[2]=x,a[3]=k):k=a[3],a[4]!==d?(y=d&&r(i,{marginBottom:1,children:r(l,{dimColor:!0,children:d})}),a[4]=d,a[5]=y):y=a[5],a[6]!==b||a[7]!==g?(j=p.map((n,o)=>{const c=o===b,a=o>b;let s,d;return o<b?(s=t.tick,d="green"):c?(s=h[g],d="context"):(s=t.circle,d=void 0),e(i,{flexDirection:"row",children:[r(i,{width:2,children:r(l,{color:d,dimColor:a,children:s})}),r(l,{dimColor:a,bold:c,children:n.label})]},n.key)}),a[6]=b,a[7]=g,a[8]=j):j=a[8],a[9]!==j?(w=r(i,{flexDirection:"column",marginLeft:2,children:j}),a[9]=j,a[10]=w):w=a[10],a[11]!==m||a[12]!==k||a[13]!==y||a[14]!==w?(C=e(i,{ref:m,flexDirection:"column",paddingX:1,paddingY:1,children:[k,y,w]}),a[11]=m,a[12]=k,a[13]=y,a[14]=w,a[15]=C):C=a[15],C}export async function teleportWithProgress(e,n){let setStep=()=>{};e.render(r(a,{children:r(function(){const[e,t]=o("validating");return setStep=t,r(TeleportProgress,{currentStep:e,sessionId:n})},{})}));const t=await m(n,setStep);setStep("checking_out");const{branchName:i,branchError:l}=await s(t.branch);return{messages:d(t.log,l),branchName:i}}
@@ -1 +1 @@
1
- import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as o,jsxs as r}from"react/jsx-runtime";import t from"chalk";import{useMemo as i,useRef as n,useState as s,useEffect as l}from"react";import{useVoiceState as a}from"../context/voice.js";import{useClipboardImageHint as c}from"../hooks/useClipboardImageHint.js";import{useSettings as u}from"../hooks/useSettings.js";import{useTextInput as d}from"../hooks/useTextInput.js";import{Box as m,color as p,useAnimationFrame as h,useTerminalFocus as f,useTheme as g,Text as v}from"../ink.js";import{isEnvTruthy as C}from"../utils/envUtils.js";import{BaseTextInput as x}from"./BaseTextInput.js";import{hueToRgb as b}from"./Spinner/utils.js";import{isWebappRunning as E,broadcastInteractiveInput as I,getWebappUrl as y}from"../webapp/server.js";const S=" ▁▂▃▄▅▆▇█";export default function TextInput(T){const[k,D]=s(!1),[j,M]=s(!1),[O,P]=s(null);l(()=>{if(E()&&!T.multiline){D(!0);const e=Math.random().toString(36).substring(2,9),{title:o,description:r,placeholder:t}=function(e){const o=(e.placeholder||e.value||"").toLowerCase();return e.mask||o.includes("api")||o.includes("key")||o.includes("token")||o.includes("password")||o.includes("contraseña")?{title:"Introducir Clave de API / Token Confidencial",description:"Por seguridad, introduce tu API Key o Token de acceso en este campo seguro y enmascarado.",placeholder:"sk-..."}:o.includes("host")||o.includes("url")||o.includes("puerto")||o.includes("port")?{title:"Configurar Dirección / Servidor",description:"Introduce la dirección URL, host o puerto del servicio que deseas configurar.",placeholder:"http://localhost:..."}:{title:"Entrada de Texto Requerida",description:"Por favor, introduce el valor solicitado para continuar con la operación en curso.",placeholder:"Escribe aquí..."}}(T),i=T.value?String(T.value):void 0;I(e,o,r,T.placeholder||t,T.mask,i).then(e=>{M(!0),T.onSubmit?.(e)}).catch(e=>{P(e.message||String(e)),T.onExit?.()})}},[T.multiline,T.value]);const[w]=g(),A=f();if(k&&!j)return r(m,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan",children:[o(v,{color:"cyan",bold:!0,children:"✨ Interacción de Entrada Transferida a la WebApp"}),o(v,{color:"white",children:"Por favor, escribe el valor requerido en tu navegador:"}),o(v,{bold:!0,color:"cyan",children:y()}),O?r(v,{color:"red",children:["Error: ",O]}):o(v,{dimColor:!0,children:"Esperando respuesta del usuario..."})]});const L=i(()=>C(process.env.CONTEXT_CODE_ACCESSIBILITY)||C(process.env.CLAUDE_CODE_ACCESSIBILITY),[]),H=u().prefersReducedMotion??!1,U="recording"===(e("VOICE_MODE")?a(e=>e.voiceState):"idle"),_=e("VOICE_MODE")?a(e=>e.voiceAudioLevels):[],F=n(new Array(1).fill(0)),R=U&&!H,[V,q]=e("VOICE_MODE")?h(R?50:null):[()=>{},0];c(A,!!T.onImagePaste);let B;if(A&&!L)if(U&&!H){const e=F.current,o=_.length>0?_[_.length-1]??0:0,r=Math.min(1.8*o,1);e[0]=.7*(e[0]??0)+r*(1-.7);const i=e[0]??0,n=Math.max(1,Math.min(Math.round(8*i),8)),s=o<.15,l=q/1e3*90%360,{r:a,g:c,b:u}=s?{r:128,g:128,b:128}:b(l);B=()=>t.rgb(a,c,u)(S[n])}else B=t.inverse;else B=e=>e;const K=d({value:T.value,onChange:T.onChange,onSubmit:T.onSubmit,onExit:T.onExit,onExitMessage:T.onExitMessage,onHistoryReset:T.onHistoryReset,onHistoryUp:T.onHistoryUp,onHistoryDown:T.onHistoryDown,onClearInput:T.onClearInput,focus:T.focus,mask:T.mask,multiline:T.multiline,cursorChar:T.showCursor?" ":"",highlightPastedText:T.highlightPastedText,invert:B,themeText:p("text",w),columns:T.columns,maxVisibleLines:T.maxVisibleLines,onImagePaste:T.onImagePaste,disableCursorMovementForUpDownKeys:T.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:T.disableEscapeDoublePress,externalOffset:T.cursorOffset,onOffsetChange:T.onChangeCursorOffset,inputFilter:T.inputFilter,inlineGhostText:T.inlineGhostText,dim:t.dim});return o(m,{ref:V,children:o(x,{inputState:K,terminalFocus:A,highlights:T.highlights,invert:B,hidePlaceholderText:U,...T})})}
1
+ import{feature as e}from"../recovery/bunBundleShim.js";import{jsx as o,jsxs as r}from"react/jsx-runtime";import t from"chalk";import{useMemo as i,useRef as n,useState as s,useEffect as l}from"react";import{useVoiceState as a}from"../context/voice.js";import{useClipboardImageHint as c}from"../hooks/useClipboardImageHint.js";import{useSettings as u}from"../hooks/useSettings.js";import{useTextInput as d}from"../hooks/useTextInput.js";import{Box as m,color as p,useAnimationFrame as h,useTerminalFocus as f,useTheme as g,Text as v}from"../ink.js";import{isEnvTruthy as C}from"../utils/envUtils.js";import{BaseTextInput as x}from"./BaseTextInput.js";import{hueToRgb as b}from"./Spinner/utils.js";import{isWebappRunning as E,broadcastInteractiveInput as I,getWebappUrl as y}from"../webapp/server.js";const S=" ▁▂▃▄▅▆▇█";export default function TextInput(T){const[k,D]=s(!1),[j,M]=s(!1),[O,P]=s(null);l(()=>{if(E()&&!T.multiline&&!T.mask){D(!0);const e=Math.random().toString(36).substring(2,9),{title:o,description:r,placeholder:t}=function(e){const o=(e.placeholder||e.value||"").toLowerCase();return e.mask||o.includes("api")||o.includes("key")||o.includes("token")||o.includes("password")||o.includes("contraseña")?{title:"Introducir Clave de API / Token Confidencial",description:"Por seguridad, introduce tu API Key o Token de acceso en este campo seguro y enmascarado.",placeholder:"sk-..."}:o.includes("host")||o.includes("url")||o.includes("puerto")||o.includes("port")?{title:"Configurar Dirección / Servidor",description:"Introduce la dirección URL, host o puerto del servicio que deseas configurar.",placeholder:"http://localhost:..."}:{title:"Entrada de Texto Requerida",description:"Por favor, introduce el valor solicitado para continuar con la operación en curso.",placeholder:"Escribe aquí..."}}(T),i=T.value?String(T.value):void 0;I(e,o,r,T.placeholder||t,T.mask,i).then(e=>{M(!0),T.onSubmit?.(e)}).catch(e=>{P(e.message||String(e)),T.onExit?.()})}},[T.multiline,T.value]);const[w]=g(),A=f();if(k&&!j)return r(m,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:"cyan",children:[o(v,{color:"cyan",bold:!0,children:"✨ Interacción de Entrada Transferida a la WebApp"}),o(v,{color:"white",children:"Por favor, escribe el valor requerido en tu navegador:"}),o(v,{bold:!0,color:"cyan",children:y()}),O?r(v,{color:"red",children:["Error: ",O]}):o(v,{dimColor:!0,children:"Esperando respuesta del usuario..."})]});const L=i(()=>C(process.env.CONTEXT_CODE_ACCESSIBILITY)||C(process.env.CLAUDE_CODE_ACCESSIBILITY),[]),H=u().prefersReducedMotion??!1,U="recording"===(e("VOICE_MODE")?a(e=>e.voiceState):"idle"),_=e("VOICE_MODE")?a(e=>e.voiceAudioLevels):[],F=n(new Array(1).fill(0)),R=U&&!H,[V,q]=e("VOICE_MODE")?h(R?50:null):[()=>{},0];c(A,!!T.onImagePaste);let B;if(A&&!L)if(U&&!H){const e=F.current,o=_.length>0?_[_.length-1]??0:0,r=Math.min(1.8*o,1);e[0]=.7*(e[0]??0)+r*(1-.7);const i=e[0]??0,n=Math.max(1,Math.min(Math.round(8*i),8)),s=o<.15,l=q/1e3*90%360,{r:a,g:c,b:u}=s?{r:128,g:128,b:128}:b(l);B=()=>t.rgb(a,c,u)(S[n])}else B=t.inverse;else B=e=>e;const K=d({value:T.value,onChange:T.onChange,onSubmit:T.onSubmit,onExit:T.onExit,onExitMessage:T.onExitMessage,onHistoryReset:T.onHistoryReset,onHistoryUp:T.onHistoryUp,onHistoryDown:T.onHistoryDown,onClearInput:T.onClearInput,focus:T.focus,mask:T.mask,multiline:T.multiline,cursorChar:T.showCursor?" ":"",highlightPastedText:T.highlightPastedText,invert:B,themeText:p("text",w),columns:T.columns,maxVisibleLines:T.maxVisibleLines,onImagePaste:T.onImagePaste,disableCursorMovementForUpDownKeys:T.disableCursorMovementForUpDownKeys,disableEscapeDoublePress:T.disableEscapeDoublePress,externalOffset:T.cursorOffset,onOffsetChange:T.onChangeCursorOffset,inputFilter:T.inputFilter,inlineGhostText:T.inlineGhostText,dim:t.dim});return o(m,{ref:V,children:o(x,{inputState:K,terminalFocus:A,highlights:T.highlights,invert:B,hidePlaceholderText:U,...T})})}