@bigduu/bamboo-agent 0.0.0-stage → 2026.11.50
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/LICENSE +21 -0
- package/README.md +20 -2
- package/bamboo-sidecars-v3.json +74 -0
- package/bin/bamboo.cjs +130 -0
- package/browser-runtime/host.cjs +4334 -0
- package/browser-runtime/package-lock.json +27 -0
- package/browser-runtime/package.json +13 -0
- package/package.json +42 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bamboo Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bamboo Agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install the Bamboo CLI with Node.js 22.14 or newer.
|
|
4
|
+
|
|
5
|
+
~~~sh
|
|
6
|
+
npm install --global @bigduu/bamboo-agent
|
|
7
|
+
bamboo --version
|
|
8
|
+
~~~
|
|
9
|
+
|
|
10
|
+
The first invocation downloads the corresponding executable from the exact
|
|
11
|
+
version of the official GitHub Release. The launcher verifies its size and
|
|
12
|
+
SHA-256 against the included manifest and stores it in the per-user cache.
|
|
13
|
+
Subsequent invocations verify and use the cached executable.
|
|
14
|
+
|
|
15
|
+
Bamboo supports macOS ARM64, Linux x64 and ARM64, and Windows x64 and ARM64.
|
|
16
|
+
The Linux binaries use the GNU runtime. The package includes the Release's
|
|
17
|
+
Browser Host and its pinned JavaScript dependency. Browser automation uses
|
|
18
|
+
an available Chromium installation.
|
|
19
|
+
|
|
20
|
+
See the [Bamboo releases](https://github.com/bigduu/Bamboo-agent/releases)
|
|
21
|
+
and [Bamboo documentation](https://github.com/bigduu/Bamboo-agent).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 3,
|
|
3
|
+
"version": "2026.11.50",
|
|
4
|
+
"sourceRevision": "08349582e073daba1a5e3674464a885b75427c79",
|
|
5
|
+
"artifacts": [
|
|
6
|
+
{
|
|
7
|
+
"target": "aarch64-apple-darwin",
|
|
8
|
+
"buildMode": "embedded",
|
|
9
|
+
"embeddedFrontend": true,
|
|
10
|
+
"format": "raw",
|
|
11
|
+
"assetName": "bamboo-aarch64-apple-darwin",
|
|
12
|
+
"sha256": "a629cde2ebb9fffe8444dc44cd06a53955f16fc83c58691bd5683429b6f86a30",
|
|
13
|
+
"sizeBytes": 274197216
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"target": "aarch64-pc-windows-msvc",
|
|
17
|
+
"buildMode": "embedded",
|
|
18
|
+
"embeddedFrontend": true,
|
|
19
|
+
"format": "raw",
|
|
20
|
+
"assetName": "bamboo-aarch64-pc-windows-msvc.exe",
|
|
21
|
+
"sha256": "8110f3efc59eb72a24265f18bdbf207c03537759f7227b09e7aaec98fce9e8b3",
|
|
22
|
+
"sizeBytes": 222359552
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"target": "aarch64-unknown-linux-gnu",
|
|
26
|
+
"buildMode": "embedded",
|
|
27
|
+
"embeddedFrontend": true,
|
|
28
|
+
"format": "raw",
|
|
29
|
+
"assetName": "bamboo-aarch64-unknown-linux-gnu",
|
|
30
|
+
"sha256": "02b86cdabddab1a36e2c98490bdfe67ede3719364c236d38e3741068f83e73c8",
|
|
31
|
+
"sizeBytes": 300449056
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"target": "x86_64-pc-windows-msvc",
|
|
35
|
+
"buildMode": "embedded",
|
|
36
|
+
"embeddedFrontend": true,
|
|
37
|
+
"format": "raw",
|
|
38
|
+
"assetName": "bamboo-x86_64-pc-windows-msvc.exe",
|
|
39
|
+
"sha256": "46579b33c01d0b77b8da25076bf70d00e42e49eabc6af1a07ac80b68ed0c36cc",
|
|
40
|
+
"sizeBytes": 269241856
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"target": "x86_64-unknown-linux-gnu",
|
|
44
|
+
"buildMode": "embedded",
|
|
45
|
+
"embeddedFrontend": true,
|
|
46
|
+
"format": "raw",
|
|
47
|
+
"assetName": "bamboo-x86_64-unknown-linux-gnu",
|
|
48
|
+
"sha256": "bb69dd52c5c82337dccbfed17d6da218836a23567c580df367d05571588ab374",
|
|
49
|
+
"sizeBytes": 314850128
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"browserHost": {
|
|
53
|
+
"assetName": "bamboo-browser-host-v1.tar.gz",
|
|
54
|
+
"sha256": "504012f0cf2f75a4c62063bb7b6711f25e12d23bdcecebd208b4624f1e9eb8d9",
|
|
55
|
+
"sizeBytes": 47295,
|
|
56
|
+
"files": [
|
|
57
|
+
{
|
|
58
|
+
"path": "browser-runtime/host.cjs",
|
|
59
|
+
"sha256": "ecdc2bb96fa63c219d721603d7ca245f79cf0fd7b820577dbc26c696414a762f",
|
|
60
|
+
"sizeBytes": 196265
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"path": "browser-runtime/package-lock.json",
|
|
64
|
+
"sha256": "a2291d32fcc0ee9480f6d6349d4aafc0190f2c527cfd8203c9bd01e60c9e4db0",
|
|
65
|
+
"sizeBytes": 700
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"path": "browser-runtime/package.json",
|
|
69
|
+
"sha256": "b4aef2d6078031cb2a900ddfb15b1180c494c012cf17e855c3e28f84eb52fb29",
|
|
70
|
+
"sizeBytes": 637
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
package/bin/bamboo.cjs
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const { spawn } = require('node:child_process')
|
|
5
|
+
const { createHash } = require('node:crypto')
|
|
6
|
+
const { once } = require('node:events')
|
|
7
|
+
const { constants, createWriteStream } = require('node:fs')
|
|
8
|
+
const { lstat, mkdir, mkdtemp, open, rename, rm } = require('node:fs/promises')
|
|
9
|
+
const os = require('node:os')
|
|
10
|
+
const path = require('node:path')
|
|
11
|
+
const { Readable, Transform } = require('node:stream')
|
|
12
|
+
const { pipeline } = require('node:stream/promises')
|
|
13
|
+
const manifest = require('../bamboo-sidecars-v3.json')
|
|
14
|
+
const { version } = require('../package.json')
|
|
15
|
+
|
|
16
|
+
const targets = {
|
|
17
|
+
'darwin-arm64': 'aarch64-apple-darwin',
|
|
18
|
+
'linux-arm64': 'aarch64-unknown-linux-gnu',
|
|
19
|
+
'linux-x64': 'x86_64-unknown-linux-gnu',
|
|
20
|
+
'win32-arm64': 'aarch64-pc-windows-msvc',
|
|
21
|
+
'win32-x64': 'x86_64-pc-windows-msvc',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function cacheRoot() {
|
|
25
|
+
const override = process.env.BAMBOO_NPM_CACHE_DIR
|
|
26
|
+
if (override) {
|
|
27
|
+
if (!path.isAbsolute(override)) throw new Error('BAMBOO_NPM_CACHE_DIR must be absolute')
|
|
28
|
+
return override
|
|
29
|
+
}
|
|
30
|
+
if (process.platform === 'win32') {
|
|
31
|
+
const local = process.env.LOCALAPPDATA
|
|
32
|
+
return path.join(local && path.isAbsolute(local) ? local : path.join(os.homedir(), 'AppData', 'Local'), 'Bamboo', 'npm')
|
|
33
|
+
}
|
|
34
|
+
const xdg = process.env.XDG_CACHE_HOME
|
|
35
|
+
if (xdg && path.isAbsolute(xdg)) return path.join(xdg, 'bamboo-agent', 'npm')
|
|
36
|
+
return path.join(os.homedir(), process.platform === 'darwin' ? 'Library/Caches' : '.cache', 'bamboo-agent', 'npm')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function matchesPublishedBinary(file, entry) {
|
|
40
|
+
let stat
|
|
41
|
+
try {
|
|
42
|
+
stat = await lstat(file)
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error.code === 'ENOENT') return false
|
|
45
|
+
throw error
|
|
46
|
+
}
|
|
47
|
+
if (!stat.isFile() || stat.size !== entry.sizeBytes) return false
|
|
48
|
+
const handle = await open(file, constants.O_RDONLY | (constants.O_NOFOLLOW || 0))
|
|
49
|
+
try {
|
|
50
|
+
const hash = createHash('sha256')
|
|
51
|
+
for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk)
|
|
52
|
+
return hash.digest('hex') === entry.sha256
|
|
53
|
+
} finally {
|
|
54
|
+
await handle.close()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function verifyDownload(entry) {
|
|
59
|
+
const hash = createHash('sha256')
|
|
60
|
+
let bytes = 0
|
|
61
|
+
return new Transform({
|
|
62
|
+
transform(chunk, encoding, done) {
|
|
63
|
+
bytes += chunk.length
|
|
64
|
+
if (bytes > entry.sizeBytes) return done(new Error('Download exceeds the published binary size'))
|
|
65
|
+
hash.update(chunk)
|
|
66
|
+
done(null, chunk)
|
|
67
|
+
},
|
|
68
|
+
flush(done) {
|
|
69
|
+
if (bytes !== entry.sizeBytes || hash.digest('hex') !== entry.sha256) {
|
|
70
|
+
return done(new Error('Download does not match the published binary SHA-256 and size'))
|
|
71
|
+
}
|
|
72
|
+
done()
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function ensureExecutable(entry) {
|
|
78
|
+
const root = path.join(cacheRoot(), version, entry.target)
|
|
79
|
+
const destination = path.join(root, entry.assetName)
|
|
80
|
+
await mkdir(root, { recursive: true, mode: 0o700 })
|
|
81
|
+
if (await matchesPublishedBinary(destination, entry)) return destination
|
|
82
|
+
|
|
83
|
+
const temporary = await mkdtemp(path.join(root, '.download-'))
|
|
84
|
+
const file = path.join(temporary, entry.assetName)
|
|
85
|
+
try {
|
|
86
|
+
process.stderr.write('Downloading Bamboo ' + version + ' for ' + entry.target + '\n')
|
|
87
|
+
const url = 'https://github.com/bigduu/Bamboo-agent/releases/download/v' + version + '/' + entry.assetName
|
|
88
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(10 * 60 * 1000) })
|
|
89
|
+
if (!response.ok || !response.body) throw new Error('GitHub Release download failed (HTTP ' + response.status + ')')
|
|
90
|
+
await pipeline(Readable.fromWeb(response.body), verifyDownload(entry), createWriteStream(file, { flags: 'wx', mode: 0o700 }))
|
|
91
|
+
try {
|
|
92
|
+
await rename(file, destination)
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (!await matchesPublishedBinary(destination, entry)) throw error
|
|
95
|
+
}
|
|
96
|
+
return destination
|
|
97
|
+
} finally {
|
|
98
|
+
await rm(temporary, { recursive: true, force: true })
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function main() {
|
|
103
|
+
if (manifest.schemaVersion !== 3 || manifest.version !== version) {
|
|
104
|
+
throw new Error('The included Bamboo release manifest does not match this package version')
|
|
105
|
+
}
|
|
106
|
+
const target = targets[process.platform + '-' + process.arch]
|
|
107
|
+
const entry = manifest.artifacts.find((candidate) => candidate.target === target)
|
|
108
|
+
if (!entry) throw new Error('Bamboo ' + version + ' has no executable for ' + process.platform + '/' + process.arch)
|
|
109
|
+
const executable = await ensureExecutable(entry)
|
|
110
|
+
const env = {
|
|
111
|
+
...process.env,
|
|
112
|
+
BAMBOO_BROWSER_HOST_SCRIPT: process.env.BAMBOO_BROWSER_HOST_SCRIPT || path.join(__dirname, '..', 'browser-runtime', 'host.cjs'),
|
|
113
|
+
BAMBOO_BROWSER_NODE: process.env.BAMBOO_BROWSER_NODE || process.execPath,
|
|
114
|
+
}
|
|
115
|
+
const child = spawn(executable, process.argv.slice(2), { stdio: 'inherit', env })
|
|
116
|
+
const signals = ['SIGINT', 'SIGTERM']
|
|
117
|
+
const handlers = signals.map((signal) => () => child.kill(signal))
|
|
118
|
+
signals.forEach((signal, index) => process.on(signal, handlers[index]))
|
|
119
|
+
try {
|
|
120
|
+
const [code, signal] = await once(child, 'exit')
|
|
121
|
+
process.exitCode = code ?? 128 + (os.constants.signals[signal] ?? 1)
|
|
122
|
+
} finally {
|
|
123
|
+
signals.forEach((signal, index) => process.off(signal, handlers[index]))
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
main().catch((error) => {
|
|
128
|
+
process.stderr.write('Bamboo: ' + error.message + '\n')
|
|
129
|
+
process.exitCode = 1
|
|
130
|
+
})
|