@freestyle-sh/with-uv 0.2.0 → 0.2.1

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { VmWith, VmWithInstance, CreateVmOptions } from 'freestyle-sandboxes';
1
+ import { VmWith, VmWithInstance, VmSpec } from 'freestyle-sandboxes';
2
2
  import { VmRunCodeInstance, JSONValue, RunCodeResponse, VmRunCode } from '@freestyle-sh/with-type-run-code';
3
3
 
4
4
  type UvOptions = {
@@ -12,14 +12,14 @@ type UvResolvedOptions = {
12
12
  declare class VmUv extends VmWith<VmUvInstance> implements VmRunCode<VmRunCodeInstance> {
13
13
  options: UvResolvedOptions;
14
14
  constructor(options?: UvOptions);
15
- configure(existingConfig: CreateVmOptions): CreateVmOptions | Promise<CreateVmOptions>;
15
+ configureSnapshotSpec(spec: VmSpec): VmSpec;
16
16
  createInstance(): VmUvInstance;
17
17
  installServiceName(): string;
18
18
  }
19
19
  declare class VmUvInstance extends VmWithInstance implements VmRunCodeInstance {
20
20
  builder: VmUv;
21
21
  constructor(builder: VmUv);
22
- runCode<Result extends JSONValue = any>({ code, }: {
22
+ runCode<Result extends JSONValue = any>(args: string | {
23
23
  code: string;
24
24
  }): Promise<RunCodeResponse<Result>>;
25
25
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { VmWith, VmTemplate, VmWithInstance } from 'freestyle-sandboxes';
1
+ import { VmWith, VmSpec, VmWithInstance } from 'freestyle-sandboxes';
2
2
 
3
3
  class VmUv extends VmWith {
4
4
  options;
@@ -9,7 +9,7 @@ class VmUv extends VmWith {
9
9
  pythonVersion: options?.pythonVersion ?? "3.14"
10
10
  };
11
11
  }
12
- configure(existingConfig) {
12
+ configureSnapshotSpec(spec) {
13
13
  const versionArg = this.options.version ? `UV_VERSION="${this.options.version}" ` : "";
14
14
  const installScript = `#!/bin/bash
15
15
  set -e
@@ -20,8 +20,9 @@ ${versionArg}curl -LsSf https://astral.sh/uv/install.sh | sh
20
20
  `;
21
21
  const uvInit = `export PATH="/opt/uv/bin:$PATH"
22
22
  `;
23
- const uvConfig = {
24
- template: new VmTemplate({
23
+ return this.composeSpecs(
24
+ spec,
25
+ new VmSpec({
25
26
  additionalFiles: {
26
27
  "/opt/install-uv.sh": {
27
28
  content: installScript
@@ -42,8 +43,7 @@ ${versionArg}curl -LsSf https://astral.sh/uv/install.sh | sh
42
43
  ]
43
44
  }
44
45
  })
45
- };
46
- return this.compose(existingConfig, uvConfig);
46
+ );
47
47
  }
48
48
  createInstance() {
49
49
  return new VmUvInstance(this);
@@ -58,9 +58,8 @@ class VmUvInstance extends VmWithInstance {
58
58
  super();
59
59
  this.builder = builder;
60
60
  }
61
- async runCode({
62
- code
63
- }) {
61
+ async runCode(args) {
62
+ const code = typeof args === "string" ? args : args.code;
64
63
  const result = await this.vm.exec({
65
64
  command: `/opt/uv/bin/uv run python -c "${code.replace(/"/g, '\\"')}"`
66
65
  });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@freestyle-sh/with-uv",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "dependencies": {
6
- "freestyle-sandboxes": "^0.1.2",
7
- "@freestyle-sh/with-type-run-code": "^0.2.0"
6
+ "freestyle-sandboxes": "^0.1.8",
7
+ "@freestyle-sh/with-type-run-code": "^0.2.1"
8
8
  },
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",