@pickaxeproject/react 6.23.2 → 6.23.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),a=require("copy-to-clipboard"),r=require("framer-motion"),o=require("../../Icons/terminal.svg.js"),i=require("../../Icons/copy.svg.js"),n=require("../../Icons/check.svg.js"),c=require("../../Icons/chevron-down.svg.js"),l=require("../../../common/api/utils.js"),u=require("../../../common/api/api.js"),d=require("../../../common/utils.js"),p=require("../../Core/Modal/index.js"),m=require("../../Core/Modal/Body.js"),h=require("../../Core/Modal/CloseButton.js"),x=require("../../../hooks/pickaxe/usePickaxeContext.js"),j=require("../../../hooks/studio/useStyleFontSize.js"),b=require("../Addons/Auth/hooks/useAuthContext.js"),g=require("./PickaxeSimpleButton.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=y(a);const v={codex:"Codex",claude:"Claude Code",cursor:"Cursor",vscode:"VS Code",other:"Other"};exports.default=()=>{const{colors:a,styles:y,deploymentId:C,deploymentType:k,mcpEnabled:w,mcpGuestId:N,pickaxeId:O,sender:I,translations:q}=x.usePickaxeContext(),{token:S}=b.useAuthContext(),$=j.useStyleFontSize(),[R,A]=t.useState(!1),[P,M]=t.useState(!1),[_,z]=t.useState(!1),[U,T]=t.useState(null),[E,B]=t.useState(!1),[L,F]=t.useState(!1),[G,J]=t.useState("codex"),W=(e,s)=>{var t;return null!==(t=null==q?void 0:q[e])&&void 0!==t?t:s},H=t.useMemo((()=>{if(!C)return"";const e=process.env.NEXT_PUBLIC_API_MCP_URL||"https://mcp.pickaxe.co",s=new URL(e),t=s.pathname.replace(/\/+$/,"");return s.pathname=t.endsWith("/deployment")?t:`${t}/deployment`,s.searchParams.set("id",C),s.toString()}),[C]),K=S||U,V=t.useMemo((()=>{if(!K)return"";const e=`Bearer ${K}`;return"codex"===G?`[mcp_servers.pickaxe]\nurl = "${H}"\nhttp_headers = { Authorization = "${e}" }`:"claude"===G?`claude mcp add --transport http --scope user pickaxe "${H}" --header "Authorization: ${e}"`:"vscode"===G?JSON.stringify({servers:{pickaxe:{type:"http",url:H,headers:{Authorization:e}}}},null,2):"cursor"===G?JSON.stringify({mcpServers:{pickaxe:{url:H,headers:{Authorization:e}}}},null,2):`URL: ${H}\nAuthorization: ${e}`}),[G,H,K]);if(!w||!C)return null;return s.jsxs(s.Fragment,{children:[s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsxs(g.default,Object.assign({className:"h-8 w-8 shrink-0 justify-center rounded-full",color:a.accent,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(u.api2.post("/track",{event:"useWithAIAppClick",guestId:N||I||d.initializeEmbedUserId(),metadata:{pickaxeId:O,deploymentId:C,deploymentType:k||"unknown",surface:"react"}}).catch((()=>{})),A(!0),!K&&!E){B(!0),F(!1);try{const e=N||I||d.initializeEmbedUserId(),s=yield l.default.post("/pickaxe/mcp-session",{deploymentId:C,guestId:e});if(!s.data.success||!s.data.token)throw new Error("Guest MCP session was not created");T(s.data.token)}catch(e){console.error("[pxe] failed to prepare MCP configuration",e),F(!0)}finally{B(!1)}}})),onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1)},{children:[s.jsx(o.default,{className:"h-5 w-5"}),s.jsx("span",Object.assign({className:"sr-only"},{children:W("mcp-use-with-ai-app","Use with an AI app")}))]})),s.jsx(r.AnimatePresence,{children:P?s.jsx(r.motion.div,Object.assign({className:"absolute right-0 top-10 z-20 w-max rounded px-3 py-2 text-xs font-medium",style:{background:a.accent,color:a.accentText},initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}},{children:W("mcp-use-with-ai-app","Use with an AI app")})):null})]})),s.jsx(p.default,Object.assign({isOpen:R,onChange:A},{children:s.jsx(m.default,Object.assign({portalClassName:"dark"===y.theme?"dark":void 0,wrapperClassName:"mx-4 w-[min(92vw,560px)]",className:"w-full overflow-hidden p-0",style:Object.assign({backgroundColor:a.secondary,borderColor:`${a.accent}40`,borderRadius:y.cornerRadius,color:a.secondaryText},"Real Head Pro"!==y.font&&{fontFamily:y.font})},{children:s.jsxs("div",Object.assign({className:"flex flex-col gap-5 p-6"},{children:[s.jsxs("div",Object.assign({className:"flex items-start justify-between gap-4"},{children:[s.jsxs("div",{children:[s.jsx("h2",Object.assign({className:`${$.h4} font-semibold`},{children:W("mcp-use-agent-in-ai-app","Use this agent in your AI app")})),s.jsx("p",Object.assign({className:`${$.b3} mt-1 opacity-70`},{children:W(S?"mcp-connect-description":"mcp-connect-description-guest",S?"Connect through MCP. Requests will be sent as your signed-in Studio user.":"Connect through MCP. Requests will be sent as this visitor.")}))]}),s.jsx(h.default,{className:"shrink-0"})]})),s.jsxs("label",Object.assign({className:`${$.l2} flex flex-col gap-2 font-medium`},{children:[W("mcp-ai-app","AI app"),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("select",Object.assign({className:"w-full appearance-none border py-2 pl-3 pr-10 outline-none",style:{backgroundColor:a.primary,borderColor:`${a.accent}40`,borderRadius:y.cornerRadius,color:a.text},value:G,onChange:e=>J(e.target.value)},{children:Object.entries(v).map((([e,t])=>s.jsx("option",Object.assign({value:e},{children:"other"===e?W("other","Other"):t}),e)))})),s.jsx(c.default,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2",style:{color:a.text}})]}))]})),E?s.jsx("div",Object.assign({className:"min-h-24 animate-pulse border p-4",role:"status",style:{backgroundColor:a.primary,borderColor:`${a.accent}40`,borderRadius:y.cornerRadius}},{children:s.jsx("span",Object.assign({className:"sr-only"},{children:W("mcp-preparing-configuration","Preparing your private configuration…")}))})):L?s.jsx("p",Object.assign({className:`${$.b3} border p-4`,style:{backgroundColor:a.primary,borderColor:`${a.accent}40`,borderRadius:y.cornerRadius,color:a.text}},{children:W("mcp-configuration-unavailable","This private configuration is unavailable. Close and try again.")})):V?s.jsxs("div",Object.assign({className:"relative min-w-0"},{children:[s.jsx("pre",Object.assign({className:"max-h-64 w-full overflow-auto whitespace-pre-wrap break-all border p-4 pr-12 text-xs",style:{backgroundColor:a.primary,borderColor:`${a.accent}40`,borderRadius:y.cornerRadius,color:a.text}},{children:V})),s.jsx("button",Object.assign({type:"button",className:"absolute right-3 top-3 border p-2 transition-opacity hover:opacity-70",style:{backgroundColor:a.accent,borderColor:a.accent,borderRadius:y.cornerRadius,color:a.accentText},"aria-label":W("mcp-copy-configuration","Copy MCP configuration"),onClick:()=>{V&&(f.default(V),z(!0),window.setTimeout((()=>z(!1)),1800))}},{children:_?s.jsx(n.default,{className:"h-4 w-4"}):s.jsx(i.default,{className:"h-4 w-4"})}))]})):null,s.jsx("p",Object.assign({className:`${$.b4} opacity-60`},{children:W("mcp-private-configuration-note","Keep this configuration private. It contains your Studio session token and stops working when that session expires.")}))]}))}))}))]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as a,useMemo as s}from"react";import n from"copy-to-clipboard";import{AnimatePresence as i,motion as c}from"framer-motion";import l from"../../Icons/terminal.svg.js";import p from"../../Icons/copy.svg.js";import d from"../../Icons/check.svg.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as a,useMemo as s}from"react";import n from"copy-to-clipboard";import{AnimatePresence as i,motion as c}from"framer-motion";import l from"../../Icons/terminal.svg.js";import p from"../../Icons/copy.svg.js";import d from"../../Icons/check.svg.js";import m from"../../Icons/chevron-down.svg.js";import u from"../../../common/api/utils.js";import{api2 as h}from"../../../common/api/api.js";import{initializeEmbedUserId as b}from"../../../common/utils.js";import g from"../../Core/Modal/index.js";import f from"../../Core/Modal/Body.js";import y from"../../Core/Modal/CloseButton.js";import{usePickaxeContext as v}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as x}from"../../../hooks/studio/useStyleFontSize.js";import{useAuthContext as j}from"../Addons/Auth/hooks/useAuthContext.js";import C from"./PickaxeSimpleButton.js";const k={codex:"Codex",claude:"Claude Code",cursor:"Cursor",vscode:"VS Code",other:"Other"},w=()=>{const{colors:w,styles:N,deploymentId:O,deploymentType:I,mcpEnabled:$,mcpGuestId:R,pickaxeId:A,sender:P,translations:M}=v(),{token:S}=j(),T=x(),[_,z]=a(!1),[U,B]=a(!1),[L,E]=a(!1),[q,F]=a(null),[G,J]=a(!1),[W,H]=a(!1),[K,V]=a("codex"),X=(e,o)=>{var r;return null!==(r=null==M?void 0:M[e])&&void 0!==r?r:o},D=s((()=>{if(!O)return"";const e=process.env.NEXT_PUBLIC_API_MCP_URL||"https://mcp.pickaxe.co",o=new URL(e),r=o.pathname.replace(/\/+$/,"");return o.pathname=r.endsWith("/deployment")?r:`${r}/deployment`,o.searchParams.set("id",O),o.toString()}),[O]),Q=S||q,Y=s((()=>{if(!Q)return"";const e=`Bearer ${Q}`;return"codex"===K?`[mcp_servers.pickaxe]\nurl = "${D}"\nhttp_headers = { Authorization = "${e}" }`:"claude"===K?`claude mcp add --transport http --scope user pickaxe "${D}" --header "Authorization: ${e}"`:"vscode"===K?JSON.stringify({servers:{pickaxe:{type:"http",url:D,headers:{Authorization:e}}}},null,2):"cursor"===K?JSON.stringify({mcpServers:{pickaxe:{url:D,headers:{Authorization:e}}}},null,2):`URL: ${D}\nAuthorization: ${e}`}),[K,D,Q]);if(!$||!O)return null;return o(r,{children:[o("div",Object.assign({className:"relative"},{children:[o(C,Object.assign({className:"h-8 w-8 shrink-0 justify-center rounded-full",color:w.accent,onClick:()=>e(void 0,void 0,void 0,(function*(){if(h.post("/track",{event:"useWithAIAppClick",guestId:R||P||b(),metadata:{pickaxeId:A,deploymentId:O,deploymentType:I||"unknown",surface:"react"}}).catch((()=>{})),z(!0),!Q&&!G){J(!0),H(!1);try{const e=R||P||b(),o=yield u.post("/pickaxe/mcp-session",{deploymentId:O,guestId:e});if(!o.data.success||!o.data.token)throw new Error("Guest MCP session was not created");F(o.data.token)}catch(e){console.error("[pxe] failed to prepare MCP configuration",e),H(!0)}finally{J(!1)}}})),onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1)},{children:[t(l,{className:"h-5 w-5"}),t("span",Object.assign({className:"sr-only"},{children:X("mcp-use-with-ai-app","Use with an AI app")}))]})),t(i,{children:U?t(c.div,Object.assign({className:"absolute right-0 top-10 z-20 w-max rounded px-3 py-2 text-xs font-medium",style:{background:w.accent,color:w.accentText},initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}},{children:X("mcp-use-with-ai-app","Use with an AI app")})):null})]})),t(g,Object.assign({isOpen:_,onChange:z},{children:t(f,Object.assign({portalClassName:"dark"===N.theme?"dark":void 0,wrapperClassName:"mx-4 w-[min(92vw,560px)]",className:"w-full overflow-hidden p-0",style:Object.assign({backgroundColor:w.secondary,borderColor:`${w.accent}40`,borderRadius:N.cornerRadius,color:w.secondaryText},"Real Head Pro"!==N.font&&{fontFamily:N.font})},{children:o("div",Object.assign({className:"flex flex-col gap-5 p-6"},{children:[o("div",Object.assign({className:"flex items-start justify-between gap-4"},{children:[o("div",{children:[t("h2",Object.assign({className:`${T.h4} font-semibold`},{children:X("mcp-use-agent-in-ai-app","Use this agent in your AI app")})),t("p",Object.assign({className:`${T.b3} mt-1 opacity-70`},{children:X(S?"mcp-connect-description":"mcp-connect-description-guest",S?"Connect through MCP. Requests will be sent as your signed-in Studio user.":"Connect through MCP. Requests will be sent as this visitor.")}))]}),t(y,{className:"shrink-0"})]})),o("label",Object.assign({className:`${T.l2} flex flex-col gap-2 font-medium`},{children:[X("mcp-ai-app","AI app"),o("div",Object.assign({className:"relative"},{children:[t("select",Object.assign({className:"w-full appearance-none border py-2 pl-3 pr-10 outline-none",style:{backgroundColor:w.primary,borderColor:`${w.accent}40`,borderRadius:N.cornerRadius,color:w.text},value:K,onChange:e=>V(e.target.value)},{children:Object.entries(k).map((([e,o])=>t("option",Object.assign({value:e},{children:"other"===e?X("other","Other"):o}),e)))})),t(m,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2",style:{color:w.text}})]}))]})),G?t("div",Object.assign({className:"min-h-24 animate-pulse border p-4",role:"status",style:{backgroundColor:w.primary,borderColor:`${w.accent}40`,borderRadius:N.cornerRadius}},{children:t("span",Object.assign({className:"sr-only"},{children:X("mcp-preparing-configuration","Preparing your private configuration…")}))})):W?t("p",Object.assign({className:`${T.b3} border p-4`,style:{backgroundColor:w.primary,borderColor:`${w.accent}40`,borderRadius:N.cornerRadius,color:w.text}},{children:X("mcp-configuration-unavailable","This private configuration is unavailable. Close and try again.")})):Y?o("div",Object.assign({className:"relative min-w-0"},{children:[t("pre",Object.assign({className:"max-h-64 w-full overflow-auto whitespace-pre-wrap break-all border p-4 pr-12 text-xs",style:{backgroundColor:w.primary,borderColor:`${w.accent}40`,borderRadius:N.cornerRadius,color:w.text}},{children:Y})),t("button",Object.assign({type:"button",className:"absolute right-3 top-3 border p-2 transition-opacity hover:opacity-70",style:{backgroundColor:w.accent,borderColor:w.accent,borderRadius:N.cornerRadius,color:w.accentText},"aria-label":X("mcp-copy-configuration","Copy MCP configuration"),onClick:()=>{Y&&(n(Y),E(!0),window.setTimeout((()=>E(!1)),1800))}},{children:t(L?d:p,{className:"h-4 w-4"})}))]})):null,t("p",Object.assign({className:`${T.b4} opacity-60`},{children:X("mcp-private-configuration-note","Keep this configuration private. It contains your Studio session token and stops working when that session expires.")}))]}))}))}))]})};export{w as default};
|