@freestyle-sh/with-opencode 0.0.3 → 0.0.4
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 +2 -0
- package/dist/index.js +25 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ type OpenCodeOptions = {
|
|
|
20
20
|
web?: {
|
|
21
21
|
port?: number;
|
|
22
22
|
} & OpenCodeAuthOptions;
|
|
23
|
+
env?: Record<string, string>;
|
|
23
24
|
};
|
|
24
25
|
type OpenCodeResolvedOptions = {
|
|
25
26
|
server: {
|
|
@@ -28,6 +29,7 @@ type OpenCodeResolvedOptions = {
|
|
|
28
29
|
web: {
|
|
29
30
|
port: number;
|
|
30
31
|
} & ResolvedOpenCodeAuthOptions;
|
|
32
|
+
env: Record<string, string>;
|
|
31
33
|
};
|
|
32
34
|
declare class VmOpenCode extends VmWith<VmOpenCodeInstance> {
|
|
33
35
|
options: OpenCodeResolvedOptions;
|
package/dist/index.js
CHANGED
|
@@ -13,38 +13,43 @@ class VmOpenCode extends VmWith {
|
|
|
13
13
|
port: options?.server?.port ?? 4096,
|
|
14
14
|
...resolveAuth(options?.server)
|
|
15
15
|
},
|
|
16
|
-
web: {
|
|
16
|
+
web: {
|
|
17
|
+
port: options?.web?.port ?? 4097,
|
|
18
|
+
...resolveAuth(options?.web)
|
|
19
|
+
},
|
|
20
|
+
env: options?.env ?? {}
|
|
17
21
|
};
|
|
18
22
|
}
|
|
19
23
|
configureSnapshotSpec(spec) {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
24
|
+
const envExports = Object.entries(this.options.env).map(([k, v]) => `export ${k}="${v}"`).join("\n");
|
|
25
|
+
const webAuthEnv = this.options.web.username ? `export OPENCODE_SERVER_USERNAME="${this.options.web.username}"
|
|
26
|
+
export OPENCODE_SERVER_PASSWORD="${this.options.web.password}"` : "";
|
|
27
|
+
const serverAuthEnv = this.options.server.username ? `export OPENCODE_SERVER_USERNAME="${this.options.server.username}"
|
|
28
|
+
export OPENCODE_SERVER_PASSWORD="${this.options.server.password}"` : "";
|
|
22
29
|
return this.composeSpecs(
|
|
23
30
|
spec,
|
|
24
31
|
new VmSpec({
|
|
25
32
|
additionalFiles: {
|
|
26
33
|
"/opt/install-opencode.sh": {
|
|
27
|
-
content:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
curl -fsSL https://opencode.ai/install | bash
|
|
31
|
-
`
|
|
34
|
+
content: `#!/bin/bash
|
|
35
|
+
curl -fsSL https://opencode.ai/install | bash
|
|
36
|
+
`
|
|
32
37
|
},
|
|
33
38
|
"/opt/run-opencode-web.sh": {
|
|
34
|
-
content:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
content: `#!/bin/bash
|
|
40
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
41
|
+
${webAuthEnv}
|
|
42
|
+
${envExports}
|
|
43
|
+
/root/.opencode/bin/opencode web --hostname 0.0.0.0 --port ${this.options.web.port}
|
|
44
|
+
`
|
|
40
45
|
},
|
|
41
46
|
"/opt/run-opencode-server.sh": {
|
|
42
|
-
content:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
content: `#!/bin/bash
|
|
48
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
49
|
+
${serverAuthEnv}
|
|
50
|
+
${envExports}
|
|
51
|
+
/root/.opencode/bin/opencode serve --hostname 0.0.0.0 --port ${this.options.server.port}
|
|
52
|
+
`
|
|
48
53
|
}
|
|
49
54
|
},
|
|
50
55
|
systemd: {
|