freestyle-sandboxes 0.0.68 → 0.0.70
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 +103 -25
- package/dist/inde.d.mts +103 -25
- package/dist/index-BBXyg0JQ.cjs +3253 -0
- package/dist/index-BQHqnjZK.mjs +3231 -0
- package/dist/index-CEEa9WHp.cjs +3238 -0
- package/dist/index-D1ulQeJR.mjs +3247 -0
- package/dist/index-DCF70Xbq.mjs +3246 -0
- package/dist/index-H7UNEAjs.cjs +3254 -0
- package/dist/index.cjs +249 -12
- package/dist/index.d-CXx1AdyW.d.ts +4210 -0
- package/dist/index.d.cts +103 -25
- package/dist/index.d.mts +103 -25
- package/dist/index.mjs +249 -12
- 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/types.gen-1sd31qLV.d.ts +172 -0
- package/dist/types.gen-627pxroW.d.ts +830 -0
- package/dist/types.gen-BCdfx7yt.d.ts +760 -0
- package/dist/types.gen-BVXmFV7d.d.ts +1299 -0
- package/dist/types.gen-BaMKzqxQ.d.ts +233 -0
- package/dist/types.gen-BtK6PMQy.d.ts +195 -0
- package/dist/types.gen-BuhQ5LpB.d.ts +764 -0
- package/dist/types.gen-BzRtj_TA.d.ts +725 -0
- package/dist/types.gen-C03gaIPq.d.ts +297 -0
- package/dist/types.gen-CMuCas4r.d.ts +183 -0
- package/dist/types.gen-CZUnqmzP.d.ts +789 -0
- package/dist/types.gen-CnEkmbco.d.ts +314 -0
- package/dist/types.gen-DDYpuDzZ.d.ts +764 -0
- package/dist/types.gen-DHmdEOOa.d.ts +172 -0
- package/dist/types.gen-DLYohMJT.d.ts +382 -0
- package/dist/types.gen-DbTb_SrD.d.ts +156 -0
- package/dist/types.gen-DkQ-Dbs1.d.ts +764 -0
- package/dist/{types.gen-BoJEFWW-.d.ts → types.gen-DyY7Deri.d.ts} +55 -1
- package/dist/types.gen-MBZCvIhE.d.ts +311 -0
- package/dist/types.gen-YhJAHBw8.d.ts +233 -0
- package/dist/types.gen-cCnnhnB6.d.ts +182 -0
- package/dist/types.gen-mg_JNXrq.d.ts +830 -0
- package/dist/types.gen-uDTr6v-7.d.ts +731 -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/sdk.gen.ts +71 -10
- package/openapi/types.gen.ts +233 -28
- package/openapi.json +1 -1
- package/package.json +2 -2
- package/src/dev-server.ts +92 -0
- package/src/index.ts +319 -27
- package/src/react/dev-server/index.tsx +3 -3
- package/.env +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,22 +1,100 @@
|
|
|
1
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, D as DeploymentSource, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponseV2, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse, C as CreateRepositoryResponseSuccess, q as HandleListRepositoriesResponse, r as HandleDeleteRepoResponse, G as GitIdentity, s as HandleDeleteIdentityResponse, A as AccessLevel, t as HandleGrantPermissionResponse, L as ListPermissionResponseSuccess, u as DescribePermissionResponseSuccess, v as CreatedToken, w as ListGitTokensResponseSuccess, x as HandleListGitTriggersResponse, y as GitTrigger, z as GitTriggerAction, B as HandleCreateGitTriggerResponse } from './types.gen-
|
|
2
|
-
export { J as AccessTokenInfo, I as AccessibleRepository, K as Behavior, M as BlobEncoding, N as BlobObject, O as CommitObject, P as CommitParent, Q as CommitTree, R as CreateDomainMappingRequest, S as CreateRecordParams, T as CreateRepoRequest, V as CreateRepoSource, U as CreateRepositoryRequest, X as CustomBuildOptions, E as DeploymentBuildOptions, Y as DeploymentLogEntry, _ as DeploymentState, $ as DevServer, a1 as DevServerRequest, a2 as DevServerStatusRequest, a3 as
|
|
1
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, D as DeploymentSource, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponseV2, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse, C as CreateRepositoryResponseSuccess, q as HandleListRepositoriesResponse, r as HandleDeleteRepoResponse, G as GitIdentity, s as HandleDeleteIdentityResponse, A as AccessLevel, t as HandleGrantPermissionResponse, L as ListPermissionResponseSuccess, u as DescribePermissionResponseSuccess, v as CreatedToken, w as ListGitTokensResponseSuccess, x as HandleListGitTriggersResponse, y as GitTrigger, z as GitTriggerAction, B as HandleCreateGitTriggerResponse } from './types.gen-BVXmFV7d.js';
|
|
2
|
+
export { J as AccessTokenInfo, I as AccessibleRepository, K as Behavior, M as BlobEncoding, N as BlobObject, O as CommitObject, P as CommitParent, Q as CommitTree, R as CreateDomainMappingRequest, S as CreateRecordParams, T as CreateRepoRequest, V as CreateRepoSource, U as CreateRepositoryRequest, X as CustomBuildOptions, E as DeploymentBuildOptions, Y as DeploymentLogEntry, _ as DeploymentState, $ as DevServer, a1 as DevServerRequest, a2 as DevServerStatusRequest, a3 as DevServerWatchFilesRequest, a4 as DnsRecord, a5 as DnsRecordData, a6 as DnsRecordKind, a7 as DomainVerificationRequest, a8 as ExecRequest, a9 as ExecuteLogEntry, aa as ExecuteRunInfo, ab as ExecuteRunState, ac as FileReadContent, ae as FreestyleCloudstateDeployConfiguration, af as FreestyleCloudstateDeployErrorResponse, ag as FreestyleDeleteDomainVerificationRequest, ah as FreestyleDeployWebErrorResponse, ai as FreestyleDeployWebPayload, aj as FreestyleDeployWebPayloadV2, ak as FreestyleDomainVerificationRequest, al as FreestyleExecuteScriptParams, am as FreestyleFile, an as FreestyleGetLogsResponse, ao as FreestyleJavaScriptLog, ap as FreestyleLogResponseObject, aq as FreestyleNetworkPermission, as as FreestyleVerifyDomainRequest, at as GitCommitPushRequest, au as GitContents, aw as GitContentsDirEntryItem, ax as GitReference, ay as GitRepositoryTrigger, aB as GrantPermissionRequest, aW as HandleBackupCloudstateData, aX as HandleBackupCloudstateError, bg as HandleCreateDomainVerificationData, bh as HandleCreateDomainVerificationError, cb as HandleCreateGitTokenData, cd as HandleCreateGitTokenError, cc as HandleCreateGitTokenResponse, cL as HandleCreateGitTriggerData, cM as HandleCreateGitTriggerError, bT as HandleCreateIdentityError, bS as HandleCreateIdentityResponse, a$ as HandleCreateRecordData, b1 as HandleCreateRecordError, b0 as HandleCreateRecordResponse, cj as HandleCreateRepoData, cl as HandleCreateRepoError, ck as HandleCreateRepoResponse, bb as HandleDeleteDomainMappingData, bd as HandleDeleteDomainMappingError, bc as HandleDeleteDomainMappingResponse, bi as HandleDeleteDomainVerificationData, bj as HandleDeleteDomainVerificationError, cN as HandleDeleteGitTriggerData, cP as HandleDeleteGitTriggerError, cO as HandleDeleteGitTriggerResponse, bU as HandleDeleteIdentityData, bV as HandleDeleteIdentityError, b2 as HandleDeleteRecordData, b4 as HandleDeleteRecordError, b3 as HandleDeleteRecordResponse, cm as HandleDeleteRepoData, cn as HandleDeleteRepoError, aT as HandleDeployCloudstateData, aV as HandleDeployCloudstateError, aU as HandleDeployCloudstateResponse, cV as HandleDeployWebData, cX as HandleDeployWebError, cW as HandleDeployWebResponse, cY as HandleDeployWebV2Data, c_ as HandleDeployWebV2Error, cZ as HandleDeployWebV2Response, bZ as HandleDescribePermissionData, b$ as HandleDescribePermissionError, b_ as HandleDescribePermissionResponse, bC as HandleDevServerStatusData, bE as HandleDevServerStatusError, bD as HandleDevServerStatusResponse, cG as HandleDownloadTarballData, cI as HandleDownloadTarballError, cH as HandleDownloadTarballResponse, bk as HandleEphemeralDevServerData, bm as HandleEphemeralDevServerError, bl as HandleEphemeralDevServerResponse, bn as HandleExecOnEphemeralDevServerData, bp as HandleExecOnEphemeralDevServerError, bo as HandleExecOnEphemeralDevServerResponse, bM as HandleExecuteScriptData, bO as HandleExecuteScriptError, bN as HandleExecuteScriptResponse, cr as HandleGetBlobData, ct as HandleGetBlobError, cs as HandleGetBlobResponse, cu as HandleGetCommitData, cw as HandleGetCommitError, cv as HandleGetCommitResponse, co as HandleGetContentsData, cq as HandleGetContentsError, cp as HandleGetContentsResponse, bK as HandleGetExecuteRunData, bL as HandleGetExecuteRunError, cQ as HandleGetLogsData, cR as HandleGetLogsError, cx as HandleGetRefBranchData, cz as HandleGetRefBranchError, cy as HandleGetRefBranchResponse, cS as HandleGetRefTagData, cU as HandleGetRefTagError, cT as HandleGetRefTagResponse, cA as HandleGetTagData, cC as HandleGetTagError, cB as HandleGetTagResponse, cD as HandleGetTreeData, cF as HandleGetTreeError, cE as HandleGetTreeResponse, d1 as HandleGetWebDeployDetailsData, bw as HandleGitCommitPushData, by as HandleGitCommitPushError, bx as HandleGitCommitPushResponse, c0 as HandleGrantPermissionData, c1 as HandleGrantPermissionError, b8 as HandleInsertDomainMappingData, ba as HandleInsertDomainMappingError, b9 as HandleInsertDomainMappingResponse, be as HandleListDomainVerificationRequestsError, b7 as HandleListDomainsError, bI as HandleListExecuteRunsData, bJ as HandleListExecuteRunsError, c8 as HandleListGitTokensData, ca as HandleListGitTokensError, c9 as HandleListGitTokensResponse, cJ as HandleListGitTriggersData, cK as HandleListGitTriggersError, bP as HandleListIdentitiesData, bR as HandleListIdentitiesError, bQ as HandleListIdentitiesResponse, bW as HandleListPermissionsData, bY as HandleListPermissionsError, bX as HandleListPermissionsResponse, aY as HandleListRecordsData, a_ as HandleListRecordsError, aZ as HandleListRecordsResponse, ch as HandleListRepositoriesData, ci as HandleListRepositoriesError, c$ as HandleListWebDeploysData, d0 as HandleListWebDeploysError, bt as HandleReadFileFromEphemeralDevServerData, bv as HandleReadFileFromEphemeralDevServerError, bu as HandleReadFileFromEphemeralDevServerResponse, ce as HandleRevokeGitTokenData, cg as HandleRevokeGitTokenError, cf as HandleRevokeGitTokenResponse, c2 as HandleRevokePermissionData, c4 as HandleRevokePermissionError, c3 as HandleRevokePermissionResponse, bz as HandleShutdownDevServerData, bB as HandleShutdownDevServerError, bA as HandleShutdownDevServerResponse, c5 as HandleUpdatePermissionData, c7 as HandleUpdatePermissionError, c6 as HandleUpdatePermissionResponse, bf as HandleVerifyDomainData, b5 as HandleVerifyWildcardData, b6 as HandleVerifyWildcardError, bF as HandleWatchDevServerFilesData, bH as HandleWatchDevServerFilesError, bG as HandleWatchDevServerFilesResponse, bq as HandleWriteFileFromEphemeralDevServerData, bs as HandleWriteFileFromEphemeralDevServerError, br as HandleWriteFileFromEphemeralDevServerResponse, aC as InternalServerError, aD as ListRecordsResponse, aE as NetworkPermissionData, aF as ReadFileEphemeralDevServerResponses, aG as ReadFileRequest, aH as RepositoryInfo, aI as RevokeGitTokenRequest, aJ as ShutdownDevServerRequest, aK as Signature, aL as TagObject, aM as TagTarget, aN as TreeEntry, aP as TreeObject, aQ as UpdatePermissionRequest, aR as Visibility, aS as WriteFileRequest, ar as action, aA as action2, az as event, Z as kind, a0 as kind2, ad as kind3, W as type, av as type2, aO as type3 } from './types.gen-BVXmFV7d.js';
|
|
3
3
|
|
|
4
|
+
interface FreestyleDevServer {
|
|
5
|
+
/**
|
|
6
|
+
* The URL for the dev server's HTTP API.
|
|
7
|
+
*/
|
|
8
|
+
ephemeralUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* The URL to the MCP endpoint for the dev server.
|
|
11
|
+
*/
|
|
12
|
+
mcpEphemeralUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* The URL for the VSCode server running in the dev server.
|
|
15
|
+
*/
|
|
16
|
+
codeServerUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the dev server was just created.
|
|
19
|
+
*/
|
|
20
|
+
isNew: boolean;
|
|
21
|
+
fs: FreestyleDevServerFilesystem;
|
|
22
|
+
process: FreestyleDevServerProcess;
|
|
23
|
+
/**
|
|
24
|
+
* Get the status of the dev server
|
|
25
|
+
*/
|
|
26
|
+
status(): Promise<{
|
|
27
|
+
installing: boolean;
|
|
28
|
+
devRunning: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Commit and push changes to the dev server repository
|
|
32
|
+
* @param message The commit message
|
|
33
|
+
*/
|
|
34
|
+
commitAndPush(message: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Shutdown the dev server
|
|
37
|
+
*/
|
|
38
|
+
shutdown(): Promise<{
|
|
39
|
+
success: boolean;
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
interface FreestyleDevServerFilesystem {
|
|
44
|
+
/**
|
|
45
|
+
* List files in the dev server directory
|
|
46
|
+
*/
|
|
47
|
+
ls(path?: string): Promise<Array<string>>;
|
|
48
|
+
/**
|
|
49
|
+
* Read a file from the dev server
|
|
50
|
+
* @param path The path to the file
|
|
51
|
+
* @param encoding The encoding to use (defaults to utf-8)
|
|
52
|
+
*/
|
|
53
|
+
readFile(path: string, encoding?: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Write a file to the dev server
|
|
56
|
+
* @param path The path to write to
|
|
57
|
+
* @param content The content to write
|
|
58
|
+
* @param encoding The encoding to use (defaults to utf-8)
|
|
59
|
+
*/
|
|
60
|
+
writeFile(path: string, content: string | ArrayBufferLike, encoding?: string): Promise<void>;
|
|
61
|
+
watch(): AsyncGenerator<{
|
|
62
|
+
eventType: string;
|
|
63
|
+
filename: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
interface FreestyleDevServerProcess {
|
|
67
|
+
/**
|
|
68
|
+
* Execute a command on the dev server
|
|
69
|
+
* @param cmd The command to execute
|
|
70
|
+
* @param background Whether to run the command in the background
|
|
71
|
+
*/
|
|
72
|
+
exec(cmd: string, background?: boolean): Promise<{
|
|
73
|
+
id: string;
|
|
74
|
+
isNew: boolean;
|
|
75
|
+
stdout?: string[];
|
|
76
|
+
stderr?: string[];
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type Options = {
|
|
81
|
+
/**
|
|
82
|
+
* The base URL for the API.
|
|
83
|
+
*/
|
|
84
|
+
baseUrl?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The API key to use for requests.
|
|
87
|
+
*/
|
|
88
|
+
apiKey?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Custom Headers to be sent with each request.
|
|
91
|
+
*/
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
};
|
|
4
94
|
declare class FreestyleSandboxes {
|
|
5
95
|
private client;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* The base URL for the API.
|
|
9
|
-
*/
|
|
10
|
-
baseUrl?: string;
|
|
11
|
-
/**
|
|
12
|
-
* The API key to use for requests.
|
|
13
|
-
*/
|
|
14
|
-
apiKey: string;
|
|
15
|
-
/**
|
|
16
|
-
* Custom Headers to be sent with each request.
|
|
17
|
-
*/
|
|
18
|
-
headers?: Record<string, string>;
|
|
19
|
-
});
|
|
96
|
+
options: Options;
|
|
97
|
+
constructor(options?: Options);
|
|
20
98
|
/**
|
|
21
99
|
* Execute a script in a sandbox.
|
|
22
100
|
*/
|
|
@@ -186,18 +264,18 @@ declare class FreestyleSandboxes {
|
|
|
186
264
|
*/
|
|
187
265
|
repoUrl?: string;
|
|
188
266
|
repoId?: string;
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated
|
|
269
|
+
*/
|
|
189
270
|
repo?: string;
|
|
190
271
|
baseId?: string;
|
|
191
272
|
devCommand?: string;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
devCommandRunning: boolean;
|
|
199
|
-
installCommandRunning: boolean;
|
|
200
|
-
}>;
|
|
273
|
+
preDevCommandOnce?: string;
|
|
274
|
+
envVars?: Record<string, string>;
|
|
275
|
+
computeClass?: string;
|
|
276
|
+
timeout?: number;
|
|
277
|
+
}): Promise<FreestyleDevServer>;
|
|
278
|
+
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
201
279
|
}
|
|
202
280
|
|
|
203
281
|
export { AccessLevel, CreateRepositoryResponseSuccess, CreatedToken, DeploymentSource, DescribePermissionResponseSuccess, FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponseV2, FreestyleExecuteScriptParamsConfiguration, FreestyleExecuteScriptResultSuccess, FreestyleSandboxes, GitIdentity, GitTrigger, GitTriggerAction, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleCreateGitTriggerResponse, HandleDeleteDomainVerificationResponse, HandleDeleteIdentityResponse, HandleDeleteRepoResponse, HandleGetExecuteRunResponse, HandleGetLogsResponse, HandleGrantPermissionResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleListExecuteRunsResponse, HandleListGitTriggersResponse, HandleListRepositoriesResponse, HandleListWebDeploysResponse, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleVerifyWildcardResponse, ListGitTokensResponseSuccess, ListPermissionResponseSuccess };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,22 +1,100 @@
|
|
|
1
|
-
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, D as DeploymentSource, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponseV2, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse, C as CreateRepositoryResponseSuccess, q as HandleListRepositoriesResponse, r as HandleDeleteRepoResponse, G as GitIdentity, s as HandleDeleteIdentityResponse, A as AccessLevel, t as HandleGrantPermissionResponse, L as ListPermissionResponseSuccess, u as DescribePermissionResponseSuccess, v as CreatedToken, w as ListGitTokensResponseSuccess, x as HandleListGitTriggersResponse, y as GitTrigger, z as GitTriggerAction, B as HandleCreateGitTriggerResponse } from './types.gen-
|
|
2
|
-
export { J as AccessTokenInfo, I as AccessibleRepository, K as Behavior, M as BlobEncoding, N as BlobObject, O as CommitObject, P as CommitParent, Q as CommitTree, R as CreateDomainMappingRequest, S as CreateRecordParams, T as CreateRepoRequest, V as CreateRepoSource, U as CreateRepositoryRequest, X as CustomBuildOptions, E as DeploymentBuildOptions, Y as DeploymentLogEntry, _ as DeploymentState, $ as DevServer, a1 as DevServerRequest, a2 as DevServerStatusRequest, a3 as
|
|
1
|
+
import { F as FreestyleExecuteScriptParamsConfiguration, a as FreestyleExecuteScriptResultSuccess, D as DeploymentSource, b as FreestyleDeployWebConfiguration, c as FreestyleDeployWebSuccessResponseV2, d as FreestyleCloudstateDeployRequest, e as FreestyleCloudstateDeploySuccessResponse, H as HandleBackupCloudstateResponse, f as HandleGetLogsResponse, g as HandleCreateDomainVerificationResponse, h as HandleVerifyDomainResponse, i as HandleVerifyDomainError, j as HandleListDomainsResponse, k as HandleListDomainVerificationRequestsResponse, l as HandleDeleteDomainVerificationResponse, m as HandleListWebDeploysResponse, n as HandleListExecuteRunsResponse, o as HandleGetExecuteRunResponse, p as HandleVerifyWildcardResponse, C as CreateRepositoryResponseSuccess, q as HandleListRepositoriesResponse, r as HandleDeleteRepoResponse, G as GitIdentity, s as HandleDeleteIdentityResponse, A as AccessLevel, t as HandleGrantPermissionResponse, L as ListPermissionResponseSuccess, u as DescribePermissionResponseSuccess, v as CreatedToken, w as ListGitTokensResponseSuccess, x as HandleListGitTriggersResponse, y as GitTrigger, z as GitTriggerAction, B as HandleCreateGitTriggerResponse } from './types.gen-BVXmFV7d.js';
|
|
2
|
+
export { J as AccessTokenInfo, I as AccessibleRepository, K as Behavior, M as BlobEncoding, N as BlobObject, O as CommitObject, P as CommitParent, Q as CommitTree, R as CreateDomainMappingRequest, S as CreateRecordParams, T as CreateRepoRequest, V as CreateRepoSource, U as CreateRepositoryRequest, X as CustomBuildOptions, E as DeploymentBuildOptions, Y as DeploymentLogEntry, _ as DeploymentState, $ as DevServer, a1 as DevServerRequest, a2 as DevServerStatusRequest, a3 as DevServerWatchFilesRequest, a4 as DnsRecord, a5 as DnsRecordData, a6 as DnsRecordKind, a7 as DomainVerificationRequest, a8 as ExecRequest, a9 as ExecuteLogEntry, aa as ExecuteRunInfo, ab as ExecuteRunState, ac as FileReadContent, ae as FreestyleCloudstateDeployConfiguration, af as FreestyleCloudstateDeployErrorResponse, ag as FreestyleDeleteDomainVerificationRequest, ah as FreestyleDeployWebErrorResponse, ai as FreestyleDeployWebPayload, aj as FreestyleDeployWebPayloadV2, ak as FreestyleDomainVerificationRequest, al as FreestyleExecuteScriptParams, am as FreestyleFile, an as FreestyleGetLogsResponse, ao as FreestyleJavaScriptLog, ap as FreestyleLogResponseObject, aq as FreestyleNetworkPermission, as as FreestyleVerifyDomainRequest, at as GitCommitPushRequest, au as GitContents, aw as GitContentsDirEntryItem, ax as GitReference, ay as GitRepositoryTrigger, aB as GrantPermissionRequest, aW as HandleBackupCloudstateData, aX as HandleBackupCloudstateError, bg as HandleCreateDomainVerificationData, bh as HandleCreateDomainVerificationError, cb as HandleCreateGitTokenData, cd as HandleCreateGitTokenError, cc as HandleCreateGitTokenResponse, cL as HandleCreateGitTriggerData, cM as HandleCreateGitTriggerError, bT as HandleCreateIdentityError, bS as HandleCreateIdentityResponse, a$ as HandleCreateRecordData, b1 as HandleCreateRecordError, b0 as HandleCreateRecordResponse, cj as HandleCreateRepoData, cl as HandleCreateRepoError, ck as HandleCreateRepoResponse, bb as HandleDeleteDomainMappingData, bd as HandleDeleteDomainMappingError, bc as HandleDeleteDomainMappingResponse, bi as HandleDeleteDomainVerificationData, bj as HandleDeleteDomainVerificationError, cN as HandleDeleteGitTriggerData, cP as HandleDeleteGitTriggerError, cO as HandleDeleteGitTriggerResponse, bU as HandleDeleteIdentityData, bV as HandleDeleteIdentityError, b2 as HandleDeleteRecordData, b4 as HandleDeleteRecordError, b3 as HandleDeleteRecordResponse, cm as HandleDeleteRepoData, cn as HandleDeleteRepoError, aT as HandleDeployCloudstateData, aV as HandleDeployCloudstateError, aU as HandleDeployCloudstateResponse, cV as HandleDeployWebData, cX as HandleDeployWebError, cW as HandleDeployWebResponse, cY as HandleDeployWebV2Data, c_ as HandleDeployWebV2Error, cZ as HandleDeployWebV2Response, bZ as HandleDescribePermissionData, b$ as HandleDescribePermissionError, b_ as HandleDescribePermissionResponse, bC as HandleDevServerStatusData, bE as HandleDevServerStatusError, bD as HandleDevServerStatusResponse, cG as HandleDownloadTarballData, cI as HandleDownloadTarballError, cH as HandleDownloadTarballResponse, bk as HandleEphemeralDevServerData, bm as HandleEphemeralDevServerError, bl as HandleEphemeralDevServerResponse, bn as HandleExecOnEphemeralDevServerData, bp as HandleExecOnEphemeralDevServerError, bo as HandleExecOnEphemeralDevServerResponse, bM as HandleExecuteScriptData, bO as HandleExecuteScriptError, bN as HandleExecuteScriptResponse, cr as HandleGetBlobData, ct as HandleGetBlobError, cs as HandleGetBlobResponse, cu as HandleGetCommitData, cw as HandleGetCommitError, cv as HandleGetCommitResponse, co as HandleGetContentsData, cq as HandleGetContentsError, cp as HandleGetContentsResponse, bK as HandleGetExecuteRunData, bL as HandleGetExecuteRunError, cQ as HandleGetLogsData, cR as HandleGetLogsError, cx as HandleGetRefBranchData, cz as HandleGetRefBranchError, cy as HandleGetRefBranchResponse, cS as HandleGetRefTagData, cU as HandleGetRefTagError, cT as HandleGetRefTagResponse, cA as HandleGetTagData, cC as HandleGetTagError, cB as HandleGetTagResponse, cD as HandleGetTreeData, cF as HandleGetTreeError, cE as HandleGetTreeResponse, d1 as HandleGetWebDeployDetailsData, bw as HandleGitCommitPushData, by as HandleGitCommitPushError, bx as HandleGitCommitPushResponse, c0 as HandleGrantPermissionData, c1 as HandleGrantPermissionError, b8 as HandleInsertDomainMappingData, ba as HandleInsertDomainMappingError, b9 as HandleInsertDomainMappingResponse, be as HandleListDomainVerificationRequestsError, b7 as HandleListDomainsError, bI as HandleListExecuteRunsData, bJ as HandleListExecuteRunsError, c8 as HandleListGitTokensData, ca as HandleListGitTokensError, c9 as HandleListGitTokensResponse, cJ as HandleListGitTriggersData, cK as HandleListGitTriggersError, bP as HandleListIdentitiesData, bR as HandleListIdentitiesError, bQ as HandleListIdentitiesResponse, bW as HandleListPermissionsData, bY as HandleListPermissionsError, bX as HandleListPermissionsResponse, aY as HandleListRecordsData, a_ as HandleListRecordsError, aZ as HandleListRecordsResponse, ch as HandleListRepositoriesData, ci as HandleListRepositoriesError, c$ as HandleListWebDeploysData, d0 as HandleListWebDeploysError, bt as HandleReadFileFromEphemeralDevServerData, bv as HandleReadFileFromEphemeralDevServerError, bu as HandleReadFileFromEphemeralDevServerResponse, ce as HandleRevokeGitTokenData, cg as HandleRevokeGitTokenError, cf as HandleRevokeGitTokenResponse, c2 as HandleRevokePermissionData, c4 as HandleRevokePermissionError, c3 as HandleRevokePermissionResponse, bz as HandleShutdownDevServerData, bB as HandleShutdownDevServerError, bA as HandleShutdownDevServerResponse, c5 as HandleUpdatePermissionData, c7 as HandleUpdatePermissionError, c6 as HandleUpdatePermissionResponse, bf as HandleVerifyDomainData, b5 as HandleVerifyWildcardData, b6 as HandleVerifyWildcardError, bF as HandleWatchDevServerFilesData, bH as HandleWatchDevServerFilesError, bG as HandleWatchDevServerFilesResponse, bq as HandleWriteFileFromEphemeralDevServerData, bs as HandleWriteFileFromEphemeralDevServerError, br as HandleWriteFileFromEphemeralDevServerResponse, aC as InternalServerError, aD as ListRecordsResponse, aE as NetworkPermissionData, aF as ReadFileEphemeralDevServerResponses, aG as ReadFileRequest, aH as RepositoryInfo, aI as RevokeGitTokenRequest, aJ as ShutdownDevServerRequest, aK as Signature, aL as TagObject, aM as TagTarget, aN as TreeEntry, aP as TreeObject, aQ as UpdatePermissionRequest, aR as Visibility, aS as WriteFileRequest, ar as action, aA as action2, az as event, Z as kind, a0 as kind2, ad as kind3, W as type, av as type2, aO as type3 } from './types.gen-BVXmFV7d.js';
|
|
3
3
|
|
|
4
|
+
interface FreestyleDevServer {
|
|
5
|
+
/**
|
|
6
|
+
* The URL for the dev server's HTTP API.
|
|
7
|
+
*/
|
|
8
|
+
ephemeralUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* The URL to the MCP endpoint for the dev server.
|
|
11
|
+
*/
|
|
12
|
+
mcpEphemeralUrl: string;
|
|
13
|
+
/**
|
|
14
|
+
* The URL for the VSCode server running in the dev server.
|
|
15
|
+
*/
|
|
16
|
+
codeServerUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the dev server was just created.
|
|
19
|
+
*/
|
|
20
|
+
isNew: boolean;
|
|
21
|
+
fs: FreestyleDevServerFilesystem;
|
|
22
|
+
process: FreestyleDevServerProcess;
|
|
23
|
+
/**
|
|
24
|
+
* Get the status of the dev server
|
|
25
|
+
*/
|
|
26
|
+
status(): Promise<{
|
|
27
|
+
installing: boolean;
|
|
28
|
+
devRunning: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Commit and push changes to the dev server repository
|
|
32
|
+
* @param message The commit message
|
|
33
|
+
*/
|
|
34
|
+
commitAndPush(message: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Shutdown the dev server
|
|
37
|
+
*/
|
|
38
|
+
shutdown(): Promise<{
|
|
39
|
+
success: boolean;
|
|
40
|
+
message: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
interface FreestyleDevServerFilesystem {
|
|
44
|
+
/**
|
|
45
|
+
* List files in the dev server directory
|
|
46
|
+
*/
|
|
47
|
+
ls(path?: string): Promise<Array<string>>;
|
|
48
|
+
/**
|
|
49
|
+
* Read a file from the dev server
|
|
50
|
+
* @param path The path to the file
|
|
51
|
+
* @param encoding The encoding to use (defaults to utf-8)
|
|
52
|
+
*/
|
|
53
|
+
readFile(path: string, encoding?: string): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Write a file to the dev server
|
|
56
|
+
* @param path The path to write to
|
|
57
|
+
* @param content The content to write
|
|
58
|
+
* @param encoding The encoding to use (defaults to utf-8)
|
|
59
|
+
*/
|
|
60
|
+
writeFile(path: string, content: string | ArrayBufferLike, encoding?: string): Promise<void>;
|
|
61
|
+
watch(): AsyncGenerator<{
|
|
62
|
+
eventType: string;
|
|
63
|
+
filename: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
interface FreestyleDevServerProcess {
|
|
67
|
+
/**
|
|
68
|
+
* Execute a command on the dev server
|
|
69
|
+
* @param cmd The command to execute
|
|
70
|
+
* @param background Whether to run the command in the background
|
|
71
|
+
*/
|
|
72
|
+
exec(cmd: string, background?: boolean): Promise<{
|
|
73
|
+
id: string;
|
|
74
|
+
isNew: boolean;
|
|
75
|
+
stdout?: string[];
|
|
76
|
+
stderr?: string[];
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
type Options = {
|
|
81
|
+
/**
|
|
82
|
+
* The base URL for the API.
|
|
83
|
+
*/
|
|
84
|
+
baseUrl?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The API key to use for requests.
|
|
87
|
+
*/
|
|
88
|
+
apiKey?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Custom Headers to be sent with each request.
|
|
91
|
+
*/
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
};
|
|
4
94
|
declare class FreestyleSandboxes {
|
|
5
95
|
private client;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* The base URL for the API.
|
|
9
|
-
*/
|
|
10
|
-
baseUrl?: string;
|
|
11
|
-
/**
|
|
12
|
-
* The API key to use for requests.
|
|
13
|
-
*/
|
|
14
|
-
apiKey: string;
|
|
15
|
-
/**
|
|
16
|
-
* Custom Headers to be sent with each request.
|
|
17
|
-
*/
|
|
18
|
-
headers?: Record<string, string>;
|
|
19
|
-
});
|
|
96
|
+
options: Options;
|
|
97
|
+
constructor(options?: Options);
|
|
20
98
|
/**
|
|
21
99
|
* Execute a script in a sandbox.
|
|
22
100
|
*/
|
|
@@ -186,18 +264,18 @@ declare class FreestyleSandboxes {
|
|
|
186
264
|
*/
|
|
187
265
|
repoUrl?: string;
|
|
188
266
|
repoId?: string;
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated
|
|
269
|
+
*/
|
|
189
270
|
repo?: string;
|
|
190
271
|
baseId?: string;
|
|
191
272
|
devCommand?: string;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
devCommandRunning: boolean;
|
|
199
|
-
installCommandRunning: boolean;
|
|
200
|
-
}>;
|
|
273
|
+
preDevCommandOnce?: string;
|
|
274
|
+
envVars?: Record<string, string>;
|
|
275
|
+
computeClass?: string;
|
|
276
|
+
timeout?: number;
|
|
277
|
+
}): Promise<FreestyleDevServer>;
|
|
278
|
+
fetch(path: string, init?: RequestInit): Promise<Response>;
|
|
201
279
|
}
|
|
202
280
|
|
|
203
281
|
export { AccessLevel, CreateRepositoryResponseSuccess, CreatedToken, DeploymentSource, DescribePermissionResponseSuccess, FreestyleCloudstateDeployRequest, FreestyleCloudstateDeploySuccessResponse, FreestyleDeployWebConfiguration, FreestyleDeployWebSuccessResponseV2, FreestyleExecuteScriptParamsConfiguration, FreestyleExecuteScriptResultSuccess, FreestyleSandboxes, GitIdentity, GitTrigger, GitTriggerAction, HandleBackupCloudstateResponse, HandleCreateDomainVerificationResponse, HandleCreateGitTriggerResponse, HandleDeleteDomainVerificationResponse, HandleDeleteIdentityResponse, HandleDeleteRepoResponse, HandleGetExecuteRunResponse, HandleGetLogsResponse, HandleGrantPermissionResponse, HandleListDomainVerificationRequestsResponse, HandleListDomainsResponse, HandleListExecuteRunsResponse, HandleListGitTriggersResponse, HandleListRepositoriesResponse, HandleListWebDeploysResponse, HandleVerifyDomainError, HandleVerifyDomainResponse, HandleVerifyWildcardResponse, ListGitTokensResponseSuccess, ListPermissionResponseSuccess };
|
package/dist/index.mjs
CHANGED
|
@@ -55,6 +55,42 @@ const handleEphemeralDevServer = (options) => {
|
|
|
55
55
|
url: "/ephemeral/v1/dev-servers"
|
|
56
56
|
});
|
|
57
57
|
};
|
|
58
|
+
const handleExecOnEphemeralDevServer = (options) => {
|
|
59
|
+
return (options?.client ?? client).post({
|
|
60
|
+
...options,
|
|
61
|
+
url: "/ephemeral/v1/dev-servers/exec"
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const handleWriteFileFromEphemeralDevServer = (options) => {
|
|
65
|
+
return (options?.client ?? client).put({
|
|
66
|
+
...options,
|
|
67
|
+
url: "/ephemeral/v1/dev-servers/files/{*filepath}"
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const handleReadFileFromEphemeralDevServer = (options) => {
|
|
71
|
+
return (options?.client ?? client).post({
|
|
72
|
+
...options,
|
|
73
|
+
url: "/ephemeral/v1/dev-servers/files/{*filepath}"
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const handleGitCommitPush = (options) => {
|
|
77
|
+
return (options?.client ?? client).post({
|
|
78
|
+
...options,
|
|
79
|
+
url: "/ephemeral/v1/dev-servers/git/commit-push"
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const handleShutdownDevServer = (options) => {
|
|
83
|
+
return (options?.client ?? client).post({
|
|
84
|
+
...options,
|
|
85
|
+
url: "/ephemeral/v1/dev-servers/shutdown"
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const handleDevServerStatus = (options) => {
|
|
89
|
+
return (options?.client ?? client).get({
|
|
90
|
+
...options,
|
|
91
|
+
url: "/ephemeral/v1/dev-servers/status"
|
|
92
|
+
});
|
|
93
|
+
};
|
|
58
94
|
const handleListExecuteRuns = (options) => {
|
|
59
95
|
return (options?.client ?? client).get({
|
|
60
96
|
...options,
|
|
@@ -190,7 +226,17 @@ const handleListWebDeploys = (options) => {
|
|
|
190
226
|
|
|
191
227
|
class FreestyleSandboxes {
|
|
192
228
|
client;
|
|
229
|
+
options;
|
|
193
230
|
constructor(options) {
|
|
231
|
+
this.options = options ?? {};
|
|
232
|
+
if (!options?.apiKey) {
|
|
233
|
+
this.options.apiKey = process.env.FREESTYLE_API_KEY;
|
|
234
|
+
}
|
|
235
|
+
if (!this.options.apiKey) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
"No API key provided. Please set the FREESTYLE_API_KEY environment variable or configure apiKey when constructing FreestyleSandboxes."
|
|
238
|
+
);
|
|
239
|
+
}
|
|
194
240
|
if (typeof Deno !== "undefined") {
|
|
195
241
|
class FreestyleRequest extends Request {
|
|
196
242
|
constructor(input, init) {
|
|
@@ -204,10 +250,10 @@ class FreestyleSandboxes {
|
|
|
204
250
|
Request = FreestyleRequest;
|
|
205
251
|
}
|
|
206
252
|
this.client = createClient({
|
|
207
|
-
baseUrl: options
|
|
253
|
+
baseUrl: this.options?.baseUrl ?? "https://api.freestyle.sh",
|
|
208
254
|
headers: {
|
|
209
|
-
Authorization: `Bearer ${options.apiKey}`,
|
|
210
|
-
...options
|
|
255
|
+
Authorization: `Bearer ${this.options.apiKey}`,
|
|
256
|
+
...this.options?.headers
|
|
211
257
|
}
|
|
212
258
|
});
|
|
213
259
|
}
|
|
@@ -795,7 +841,7 @@ ${response.error.message}`);
|
|
|
795
841
|
);
|
|
796
842
|
}
|
|
797
843
|
if (response.data.isNew) {
|
|
798
|
-
const rId = options.repoId || options.repoUrl
|
|
844
|
+
const rId = options.repoId || options.repoUrl?.split("/").at(-1);
|
|
799
845
|
await this.createGitTrigger({
|
|
800
846
|
repoId: rId,
|
|
801
847
|
action: {
|
|
@@ -813,17 +859,208 @@ ${response.error.message}`);
|
|
|
813
859
|
if (!response.data) {
|
|
814
860
|
throw new Error(`Failed to request dev server: ${response.error}`);
|
|
815
861
|
}
|
|
862
|
+
const data = response.data;
|
|
863
|
+
const devServerInstance = {
|
|
864
|
+
repoId: options.repoId || options.repo || "",
|
|
865
|
+
kind: "repo"
|
|
866
|
+
};
|
|
867
|
+
const client = this.client;
|
|
868
|
+
const that = this;
|
|
816
869
|
return {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
mcpEphemeralUrl:
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
870
|
+
isNew: data.isNew,
|
|
871
|
+
ephemeralUrl: data.ephemeralUrl ?? data.url,
|
|
872
|
+
mcpEphemeralUrl: data.mcpEphemeralUrl ?? data.url + "/mcp",
|
|
873
|
+
codeServerUrl: data.codeServerUrl ?? (data.ephemeralUrl ?? data.url) + "/__freestyle_code_server/?folder=/template",
|
|
874
|
+
async status() {
|
|
875
|
+
const response2 = await handleDevServerStatus({
|
|
876
|
+
client,
|
|
877
|
+
body: {
|
|
878
|
+
devServer: devServerInstance
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
if (response2.error) {
|
|
882
|
+
throw new Error(`Failed to get status: ${response2.error}`);
|
|
883
|
+
}
|
|
884
|
+
return {
|
|
885
|
+
installing: response2.data.installing,
|
|
886
|
+
devRunning: response2.data.devRunning
|
|
887
|
+
};
|
|
888
|
+
},
|
|
889
|
+
async commitAndPush(message) {
|
|
890
|
+
const response2 = await handleGitCommitPush({
|
|
891
|
+
client,
|
|
892
|
+
body: {
|
|
893
|
+
devServer: devServerInstance,
|
|
894
|
+
message
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
if (response2.error) {
|
|
898
|
+
throw new Error(`Failed to commit and push: ${response2.error}`);
|
|
899
|
+
}
|
|
900
|
+
},
|
|
901
|
+
async shutdown() {
|
|
902
|
+
const response2 = await handleShutdownDevServer({
|
|
903
|
+
client,
|
|
904
|
+
body: {
|
|
905
|
+
devServer: devServerInstance
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
if (response2.error) {
|
|
909
|
+
throw new Error(`Failed to shutdown dev server: ${response2.error}`);
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
success: response2.data.success,
|
|
913
|
+
message: response2.data.message
|
|
914
|
+
};
|
|
915
|
+
},
|
|
916
|
+
fs: {
|
|
917
|
+
async ls(path = "") {
|
|
918
|
+
const response2 = await handleReadFileFromEphemeralDevServer({
|
|
919
|
+
client,
|
|
920
|
+
path: {
|
|
921
|
+
filepath: path
|
|
922
|
+
},
|
|
923
|
+
body: {
|
|
924
|
+
devServer: devServerInstance,
|
|
925
|
+
encoding: "utf-8"
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
if (response2.error) {
|
|
929
|
+
throw new Error(`Failed to list directory: ${response2.error}`);
|
|
930
|
+
}
|
|
931
|
+
if (!response2.data?.content) {
|
|
932
|
+
return [];
|
|
933
|
+
}
|
|
934
|
+
if (response2.data.content.kind === "directory") {
|
|
935
|
+
return response2.data.content.files;
|
|
936
|
+
}
|
|
937
|
+
return [];
|
|
938
|
+
},
|
|
939
|
+
async *watch() {
|
|
940
|
+
const response2 = await that.fetch(
|
|
941
|
+
"/ephemeral/v1/dev-servers/watch-files",
|
|
942
|
+
{
|
|
943
|
+
method: "POST",
|
|
944
|
+
body: JSON.stringify({
|
|
945
|
+
devServer: {
|
|
946
|
+
repoId: devServerInstance.repoId,
|
|
947
|
+
kind: devServerInstance.kind
|
|
948
|
+
}
|
|
949
|
+
})
|
|
950
|
+
}
|
|
951
|
+
);
|
|
952
|
+
if (!response2.ok) {
|
|
953
|
+
throw new Error(
|
|
954
|
+
`Failed to fetch stream: ${response2.status} ${response2.statusText}`
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
if (!response2.body) {
|
|
958
|
+
throw new Error("Failed to fetch stream: No response body");
|
|
959
|
+
}
|
|
960
|
+
const reader = response2.body.getReader();
|
|
961
|
+
const decoder = new TextDecoder("utf-8");
|
|
962
|
+
let buffer = "";
|
|
963
|
+
while (true) {
|
|
964
|
+
const { done, value } = await reader.read();
|
|
965
|
+
if (done) break;
|
|
966
|
+
buffer += decoder.decode(value, { stream: true });
|
|
967
|
+
let newlineIndex;
|
|
968
|
+
while ((newlineIndex = buffer.indexOf("\n")) >= 0) {
|
|
969
|
+
const line = buffer.slice(0, newlineIndex).trim();
|
|
970
|
+
buffer = buffer.slice(newlineIndex + 1);
|
|
971
|
+
if (line) {
|
|
972
|
+
yield JSON.parse(line);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
if (buffer.trim()) {
|
|
977
|
+
yield JSON.parse(buffer.trim());
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
async readFile(path, encoding = "utf-8") {
|
|
981
|
+
const response2 = await handleReadFileFromEphemeralDevServer({
|
|
982
|
+
client,
|
|
983
|
+
path: {
|
|
984
|
+
filepath: path
|
|
985
|
+
},
|
|
986
|
+
body: {
|
|
987
|
+
devServer: devServerInstance,
|
|
988
|
+
encoding
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
if (response2.error) {
|
|
992
|
+
throw new Error(`Failed to read file: ${response2.error}`);
|
|
993
|
+
}
|
|
994
|
+
if (!response2.data?.content || response2.data.content.kind !== "file") {
|
|
995
|
+
throw new Error(`Not a file or file not found: ${path}`);
|
|
996
|
+
}
|
|
997
|
+
return response2.data.content.content;
|
|
998
|
+
},
|
|
999
|
+
async writeFile(path, content, encoding = "utf-8") {
|
|
1000
|
+
const contentStr = typeof content === "string" ? content : new TextDecoder(encoding).decode(content);
|
|
1001
|
+
const response2 = await handleWriteFileFromEphemeralDevServer({
|
|
1002
|
+
client,
|
|
1003
|
+
path: {
|
|
1004
|
+
filepath: path
|
|
1005
|
+
},
|
|
1006
|
+
body: {
|
|
1007
|
+
devServer: devServerInstance,
|
|
1008
|
+
content: contentStr,
|
|
1009
|
+
encoding
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
if (response2.error) {
|
|
1013
|
+
throw new Error(`Failed to write file: ${response2.error}`);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
process: {
|
|
1018
|
+
async exec(cmd, background = false) {
|
|
1019
|
+
const response2 = await handleExecOnEphemeralDevServer(
|
|
1020
|
+
{
|
|
1021
|
+
client,
|
|
1022
|
+
body: {
|
|
1023
|
+
devServer: devServerInstance,
|
|
1024
|
+
command: cmd,
|
|
1025
|
+
background
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
);
|
|
1029
|
+
if (response2.error) {
|
|
1030
|
+
throw new Error(`Failed to execute command: ${response2.error}`);
|
|
1031
|
+
}
|
|
1032
|
+
return {
|
|
1033
|
+
id: response2.data.id,
|
|
1034
|
+
isNew: response2.data.isNew,
|
|
1035
|
+
stdout: response2.data.stdout,
|
|
1036
|
+
stderr: response2.data.stderr
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
825
1040
|
};
|
|
826
1041
|
}
|
|
1042
|
+
fetch(path, init) {
|
|
1043
|
+
const headers = new Headers(init?.headers);
|
|
1044
|
+
for (const [key, value] of Object.entries(this.options.headers ?? {})) {
|
|
1045
|
+
if (!headers.has(key)) {
|
|
1046
|
+
headers.append(key, value);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
if (!headers.has("Authorization")) {
|
|
1050
|
+
headers.append("Authorization", `Bearer ${this.options.apiKey}`);
|
|
1051
|
+
}
|
|
1052
|
+
if (!headers.has("Content-Type")) {
|
|
1053
|
+
headers.append("Content-Type", "application/json");
|
|
1054
|
+
}
|
|
1055
|
+
const url = new URL(
|
|
1056
|
+
path,
|
|
1057
|
+
this.options.baseUrl ?? "https://api.freestyle.sh"
|
|
1058
|
+
);
|
|
1059
|
+
return fetch(url, {
|
|
1060
|
+
...init ?? {},
|
|
1061
|
+
headers
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
827
1064
|
}
|
|
828
1065
|
|
|
829
1066
|
export { FreestyleSandboxes };
|