Skip to content

Commit 67b9020

Browse files
authored
chore: set goose binaries as executable in package.json (#8589)
1 parent fd93865 commit 67b9020

15 files changed

Lines changed: 453 additions & 391 deletions

File tree

ui/goose-binary/goose-binary-darwin-arm64/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "git+https://github.com/aaif-goose/goose.git"
99
},
10+
"bin": {
11+
"goose": "bin/goose"
12+
},
1013
"keywords": [
1114
"goose",
1215
"ai",

ui/goose-binary/goose-binary-darwin-x64/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "git+https://github.com/aaif-goose/goose.git"
99
},
10+
"bin": {
11+
"goose": "bin/goose"
12+
},
1013
"keywords": [
1114
"goose",
1215
"ai",

ui/goose-binary/goose-binary-linux-arm64/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "git+https://github.com/aaif-goose/goose.git"
99
},
10+
"bin": {
11+
"goose": "bin/goose"
12+
},
1013
"keywords": [
1114
"goose",
1215
"ai",

ui/goose-binary/goose-binary-linux-x64/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "git+https://github.com/aaif-goose/goose.git"
99
},
10+
"bin": {
11+
"goose": "bin/goose"
12+
},
1013
"keywords": [
1114
"goose",
1215
"ai",

ui/goose-binary/goose-binary-win32-x64/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"type": "git",
88
"url": "git+https://github.com/aaif-goose/goose.git"
99
},
10+
"bin": {
11+
"goose": "bin/goose.exe"
12+
},
1013
"keywords": [
1114
"goose",
1215
"ai",

ui/pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/scripts/publish.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ apt-get install -y -qq --no-install-recommends \
7979
echo "==> Compiling goose (this takes a while)..."
8080
cargo build --release --bin goose
8181
cp /build/target/release/goose /output/goose
82-
chmod +x /output/goose
8382
echo "==> Done"
8483
'
8584

@@ -123,8 +122,7 @@ WORKDIR /build
123122
COPY . .
124123
RUN mkdir -p /output && \
125124
cargo build --release --bin goose && \
126-
cp target/release/goose /output/goose && \
127-
chmod +x /output/goose
125+
cp target/release/goose /output/goose
128126
DEOF
129127

130128
# Build in Docker and extract the binary
@@ -141,7 +139,6 @@ DEOF
141139
docker cp "${cid}:/output/goose" "${pkg_dir}/goose"
142140
docker rm "${cid}" >/dev/null
143141
docker rmi "${iid}" >/dev/null 2>&1 || true
144-
chmod +x "${pkg_dir}/goose"
145142

146143
rm -rf "${ctx}"
147144

ui/sdk/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
"type": "module",
1818
"main": "./dist/index.js",
1919
"types": "./dist/index.d.ts",
20+
"exports": {
21+
".": {
22+
"types": "./dist/index.d.ts",
23+
"default": "./dist/index.js"
24+
},
25+
"./node": {
26+
"types": "./dist/resolve-binary.d.ts",
27+
"default": "./dist/resolve-binary.js"
28+
}
29+
},
2030
"files": [
2131
"dist"
2232
],
@@ -35,6 +45,13 @@
3545
"peerDependencies": {
3646
"@agentclientprotocol/sdk": "*"
3747
},
48+
"optionalDependencies": {
49+
"@aaif/goose-binary-darwin-arm64": "workspace:*",
50+
"@aaif/goose-binary-darwin-x64": "workspace:*",
51+
"@aaif/goose-binary-linux-arm64": "workspace:*",
52+
"@aaif/goose-binary-linux-x64": "workspace:*",
53+
"@aaif/goose-binary-win32-x64": "workspace:*"
54+
},
3855
"devDependencies": {
3956
"@agentclientprotocol/sdk": "^0.14.1",
4057
"@hey-api/openapi-ts": "^0.92.3",

ui/sdk/src/resolve-binary.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { createRequire } from "node:module";
2+
import { dirname, join } from "node:path";
3+
4+
const PLATFORMS: Record<string, string> = {
5+
"darwin-arm64": "@aaif/goose-binary-darwin-arm64",
6+
"darwin-x64": "@aaif/goose-binary-darwin-x64",
7+
"linux-arm64": "@aaif/goose-binary-linux-arm64",
8+
"linux-x64": "@aaif/goose-binary-linux-x64",
9+
"win32-x64": "@aaif/goose-binary-win32-x64",
10+
};
11+
12+
/**
13+
* Resolves the path to the goose binary.
14+
*
15+
* Resolution order:
16+
* 1. `GOOSE_BINARY` environment variable (explicit override)
17+
* 2. Platform-specific `@aaif/goose-binary-*` optional dependency
18+
*
19+
* @throws if no binary can be found
20+
*/
21+
export function resolveGooseBinary(): string {
22+
const envBinary = process.env.GOOSE_BINARY;
23+
if (envBinary) return envBinary;
24+
25+
const key = `${process.platform}-${process.arch}`;
26+
const pkg = PLATFORMS[key];
27+
if (!pkg) {
28+
throw new Error(
29+
`No goose binary available for ${key}. Set GOOSE_BINARY to the path of a goose binary.`,
30+
);
31+
}
32+
33+
try {
34+
const require = createRequire(import.meta.url);
35+
const pkgDir = dirname(require.resolve(`${pkg}/package.json`));
36+
const binName = process.platform === "win32" ? "goose.exe" : "goose";
37+
return join(pkgDir, "bin", binName);
38+
} catch {
39+
throw new Error(
40+
`goose binary package ${pkg} is not installed. Set GOOSE_BINARY or install the native package.`,
41+
);
42+
}
43+
}

ui/text/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
dist
22
node_modules
3-
server-binary.json

0 commit comments

Comments
 (0)