freestyle-sandboxes 0.0.52 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/inde.d.cts +1 -1
- package/dist/ai/inde.d.mts +1 -1
- package/dist/ai/index.d.cts +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/inde.d.cts +11 -8
- package/dist/inde.d.mts +11 -8
- package/dist/index.cjs +10 -15
- package/dist/index.d.cts +11 -8
- package/dist/index.d.mts +11 -8
- package/dist/index.mjs +10 -15
- package/dist/langgraph/inde.d.cts +1 -1
- package/dist/langgraph/inde.d.mts +1 -1
- package/dist/langgraph/index.d.cts +1 -1
- package/dist/langgraph/index.d.mts +1 -1
- package/dist/mastra/inde.d.cts +1 -1
- package/dist/mastra/inde.d.mts +1 -1
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.mts +1 -1
- package/dist/react/dev-server/index..d.cts +3 -3
- package/dist/react/dev-server/index..d.mts +3 -3
- package/dist/react/dev-server/index.cjs +6 -6
- package/dist/react/dev-server/index.d.cts +3 -3
- package/dist/react/dev-server/index.d.mts +3 -3
- package/dist/react/dev-server/index.mjs +6 -6
- package/dist/types.gen-BqN1t03N.d.ts +842 -0
- package/dist/utils/inde.d.cts +1 -1
- package/dist/utils/inde.d.mts +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/openapi/types.gen.ts +12 -0
- package/openapi.json +1 -1
- package/package.json +2 -2
- package/src/index.ts +20 -23
- package/src/react/dev-server/index.tsx +7 -7
- package/src/react/dev-server/types.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -797,60 +797,57 @@ export class FreestyleSandboxes {
|
|
|
797
797
|
* ephemeral so you should call this function every time you need a url. Do
|
|
798
798
|
* not store the url in your database!
|
|
799
799
|
*/
|
|
800
|
-
async requestDevServer(
|
|
800
|
+
async requestDevServer({
|
|
801
|
+
repoUrl,
|
|
802
|
+
repoId,
|
|
803
|
+
}: {
|
|
804
|
+
/**
|
|
805
|
+
* @deprecated
|
|
806
|
+
*/
|
|
807
|
+
repoUrl?: string,
|
|
808
|
+
repoId?: string, repo?: string
|
|
809
|
+
}) {
|
|
810
|
+
|
|
801
811
|
function formatHook(serverUrl: string, repoUrl: string) {
|
|
802
812
|
const hook =
|
|
803
813
|
serverUrl +
|
|
804
814
|
"/__freestyle_dev_server/update/git?repo=" +
|
|
805
815
|
encodeURIComponent(repoUrl);
|
|
806
|
-
|
|
807
|
-
console.log(hook);
|
|
808
816
|
return hook;
|
|
809
817
|
}
|
|
810
818
|
|
|
811
|
-
let repoId: string;
|
|
812
|
-
if ("repoId" in repo) {
|
|
813
|
-
repoId = repo.repoId;
|
|
814
|
-
} else if ("repoUrl" in repo) {
|
|
815
|
-
const parts = repo.repoUrl.split("/");
|
|
816
|
-
repoId = parts[parts.length - 1]; // Get the last part of the URL path
|
|
817
|
-
} else {
|
|
818
|
-
throw new Error("Either repoId or repoUrl must be provided");
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
const repoUrl =
|
|
822
|
-
(process.env.GIT_URL ?? "https://git.freestyle.sh/") + repoId;
|
|
823
|
-
|
|
824
819
|
const response = await sandbox_openapi.handleEphemeralDevServer({
|
|
825
820
|
client: this.client,
|
|
826
821
|
body: {
|
|
822
|
+
// @ts-ignore
|
|
823
|
+
repo: repo || repoUrl,
|
|
827
824
|
repoId: repoId,
|
|
828
825
|
},
|
|
829
826
|
});
|
|
830
827
|
|
|
831
828
|
if (response.data.isNew) {
|
|
829
|
+
const rId = repoId || repoUrl.split("/").at(-1)!;
|
|
830
|
+
|
|
832
831
|
await this.createGitTrigger({
|
|
833
|
-
repoId:
|
|
832
|
+
repoId: rId,
|
|
834
833
|
action: {
|
|
835
|
-
endpoint: formatHook(response.data?.url!, repoUrl),
|
|
836
|
-
action: "webhook"
|
|
834
|
+
endpoint: formatHook(response.data?.url!, repoUrl || `https://git.freestyle.sh/${rId}`),
|
|
835
|
+
action: "webhook"
|
|
837
836
|
},
|
|
838
837
|
trigger: {
|
|
839
838
|
event: "push",
|
|
840
839
|
},
|
|
841
|
-
})
|
|
840
|
+
});
|
|
842
841
|
}
|
|
843
842
|
|
|
844
843
|
if (!response.data) {
|
|
845
844
|
throw new Error(`Failed to request dev server: ${response.error}`);
|
|
846
845
|
}
|
|
847
|
-
|
|
848
846
|
return {
|
|
849
847
|
...response.data,
|
|
850
848
|
// @ts-ignore
|
|
851
849
|
mcpEphemeralUrl:
|
|
852
|
-
(response.data as
|
|
853
|
-
response.data.url + "/mcp",
|
|
850
|
+
(response.data as any).mcpEphemeralUrl || response.data.url + "/mcp",
|
|
854
851
|
// @ts-ignore
|
|
855
852
|
ephemeralUrl: response.data.ephemeralUrl ?? response.data.url,
|
|
856
853
|
};
|
|
@@ -39,11 +39,11 @@ export function DefaultLoadingComponent({
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function FreestyleDevServer({
|
|
42
|
-
repoUrl,
|
|
43
42
|
loadingComponent,
|
|
44
43
|
actions,
|
|
44
|
+
repoId,
|
|
45
45
|
}: {
|
|
46
|
-
|
|
46
|
+
repoId: string;
|
|
47
47
|
loadingComponent?: (props: {
|
|
48
48
|
devCommandRunning: boolean;
|
|
49
49
|
installCommandRunning: boolean;
|
|
@@ -55,7 +55,7 @@ export function FreestyleDevServer({
|
|
|
55
55
|
<QueryClientProvider client={queryClient}>
|
|
56
56
|
<FreestyleDevServerInner
|
|
57
57
|
loadingComponent={loadingComponent ?? DefaultLoadingComponent}
|
|
58
|
-
|
|
58
|
+
repoId={repoId}
|
|
59
59
|
actions={actions}
|
|
60
60
|
/>
|
|
61
61
|
</QueryClientProvider>
|
|
@@ -63,11 +63,11 @@ export function FreestyleDevServer({
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function FreestyleDevServerInner({
|
|
66
|
-
|
|
66
|
+
repoId,
|
|
67
67
|
loadingComponent,
|
|
68
68
|
actions: { requestDevServer },
|
|
69
69
|
}: {
|
|
70
|
-
|
|
70
|
+
repoId: string;
|
|
71
71
|
loadingComponent: (props: {
|
|
72
72
|
devCommandRunning: boolean;
|
|
73
73
|
installCommandRunning: boolean;
|
|
@@ -76,8 +76,8 @@ function FreestyleDevServerInner({
|
|
|
76
76
|
actions: RequestDevServerActions;
|
|
77
77
|
}) {
|
|
78
78
|
const { data, isLoading } = useQuery({
|
|
79
|
-
queryKey: ["dev-server",
|
|
80
|
-
queryFn: async () => await requestDevServer({
|
|
79
|
+
queryKey: ["dev-server", repoId],
|
|
80
|
+
queryFn: async () => await requestDevServer({ repoId: repoId }),
|
|
81
81
|
refetchInterval: 1000,
|
|
82
82
|
});
|
|
83
83
|
|