acp: publish goose ACP client and acp binary as separate npm packages (#11846)

This commit is contained in:
Lifei Zhou
2026-09-04 15:14:36 +00:00
committed by GitHub
parent 4fee10daae
commit 31557a5f96
89 changed files with 1300 additions and 1132 deletions
-2
View File
@@ -1,6 +1,4 @@
# This is a reusable workflow that builds the CLI for multiple platforms.
# It doesn't get triggered on its own. It gets used by:
# - publish-npm.yml
#
# Platform Build Strategy:
# - Linux standard (x86_64 + aarch64): Builds inside manylinux_2_28 container for glibc 2.28+ compat
+35 -2
View File
@@ -32,6 +32,40 @@ jobs:
code:
- '!documentation/**'
goose-acp-npm-packages:
name: goose ACP npm packages
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.code == 'true' || github.event_name != 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install dependencies
run: source bin/activate-hermit && pnpm --dir ui install --frozen-lockfile
- name: Check npm versions
run: source bin/activate-hermit && node ui/scripts/npm-versions.mjs check
- name: Test goose-acp
run: source bin/activate-hermit && pnpm --dir ui/goose-acp test
- name: Pack npm packages
run: |
source bin/activate-hermit
set -euo pipefail
client_pack_dir="$RUNNER_TEMP/goose-acp-client"
wrapper_pack_dir="$RUNNER_TEMP/goose-acp"
mkdir -p "$client_pack_dir" "$wrapper_pack_dir"
pnpm --dir ui/goose-acp-client pack --pack-destination "$client_pack_dir"
pnpm --dir ui/goose-acp pack --pack-destination "$wrapper_pack_dir"
wrapper_tarball=$(find "$wrapper_pack_dir" -name '*.tgz' -print -quit)
tar -xzf "$wrapper_tarball" -C "$wrapper_pack_dir"
node ui/scripts/npm-versions.mjs check-packed-wrapper \
"$wrapper_pack_dir/package/package.json"
rust-format:
name: Check Rust Code Format
runs-on: ubuntu-latest
@@ -273,7 +307,6 @@ jobs:
run: |
source ./bin/activate-hermit
cd ui/desktop && pnpm install --frozen-lockfile
cd ../sdk && pnpm install --frozen-lockfile
- name: Check ACP Artifacts are Up-to-Date
run: |
@@ -283,7 +316,7 @@ jobs:
- name: Check ACP Client SDK
run: |
source ./bin/activate-hermit
cd ui/sdk
cd ui/goose-acp-client
pnpm run lint
gdk-api-docs-check:
+46 -187
View File
@@ -1,215 +1,74 @@
name: Publish to npm
name: Goose ACP npm release
on:
workflow_call:
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
inputs:
release_tag:
description: Versioned Goose release to package, for example v1.49.0
required: true
type: string
publish:
description: Publish the verified tarballs to npm
required: true
type: boolean
default: false
permissions:
contents: read
jobs:
build-cli:
uses: ./.github/workflows/build-cli.yml
# Build npm packages (no environment needed)
build:
name: Build npm packages
pack:
name: Pack npm packages
runs-on: ubuntu-latest
needs: [build-cli]
outputs:
version: ${{ steps.prepare.outputs.version }}
steps:
- name: Checkout
- name: Checkout release tag
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '24.10.0'
registry-url: 'https://registry.npmjs.org'
always-auth: true
ref: ${{ inputs.release_tag }}
- name: Setup pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
version: 10.30.3
- name: Download freshly-built goose CLI binaries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: goose-*
path: /tmp/cli-artifacts
- name: Place binaries into goose-binary packages
run: |
set -euo pipefail
echo "Available CLI artifacts:"
find /tmp/cli-artifacts -maxdepth 2 -type d | sort
# Map: npm platform name -> upstream artifact directory name (target triple)
declare -A PLATFORM_MAP=(
[darwin-arm64]=aarch64-apple-darwin
[darwin-x64]=x86_64-apple-darwin
[linux-arm64]=aarch64-unknown-linux-gnu
[linux-x64]=x86_64-unknown-linux-gnu
[win32-x64]=x86_64-pc-windows-msvc
)
for platform in "${!PLATFORM_MAP[@]}"; do
target="${PLATFORM_MAP[$platform]}"
artifact_dir="/tmp/cli-artifacts/goose-${target}"
pkg_dir="ui/goose-binary/goose-binary-${platform}/bin"
mkdir -p "${pkg_dir}"
if [[ "${platform}" == "win32-x64" ]]; then
archive="${artifact_dir}/goose-${target}.zip"
if [[ ! -f "${archive}" ]]; then
echo "::error::Missing Windows CLI artifact: ${archive}"
exit 1
fi
rm -rf /tmp/goose-extract
unzip -o "${archive}" -d /tmp/goose-extract
cp /tmp/goose-extract/goose-package/goose.exe "${pkg_dir}/goose.exe"
else
archive="${artifact_dir}/goose-${target}.tar.bz2"
if [[ ! -f "${archive}" ]]; then
echo "::error::Missing CLI artifact: ${archive}"
exit 1
fi
rm -rf /tmp/goose-extract
mkdir -p /tmp/goose-extract
tar -xjf "${archive}" -C /tmp/goose-extract
cp /tmp/goose-extract/goose "${pkg_dir}/goose"
chmod +x "${pkg_dir}/goose"
fi
echo " ✅ ${platform} (${target})"
done
- name: List downloaded binaries (debug)
run: find ui/goose-binary -name 'goose*' -type f | sort
- name: Install dependencies
run: |
cd ui
pnpm install --frozen-lockfile
- name: Build packages
run: |
cd ui/sdk
pnpm run build:ts
- name: Compatibility check (SDK client ↔ goose binary)
- name: Prepare npm package tarballs
id: prepare
env:
GOOSE_BINARY: ${{ github.workspace }}/ui/goose-binary/goose-binary-linux-x64/bin/goose
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
cd ui/sdk
pnpm run check:compat
bash ui/scripts/prepare-npm-packages.sh \
"$RELEASE_TAG" "$RUNNER_TEMP/npm-packages"
echo "version=${RELEASE_TAG#v}" >> "$GITHUB_OUTPUT"
- name: Upload built packages
- name: Upload npm package tarballs
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-packages
path: ui/
name: npm-packages-${{ steps.prepare.outputs.version }}
path: ${{ runner.temp }}/npm-packages
if-no-files-found: error
retention-days: 7
- name: Build summary
run: |
{
echo "## 📦 Build Summary"
echo ""
echo "### Source"
echo "Commit: \`${GITHUB_SHA}\`"
echo ""
echo "### Goose CLI Binaries"
echo "✅ Built from this commit for all platforms:"
for dir in ui/goose-binary/goose-binary-*/; do
platform=$(basename "$dir" | sed 's/goose-binary-//')
echo " - $platform"
done
echo ""
echo "### npm Packages"
cd ui
for pkg in sdk goose-binary/*/; do
if [ -f "$pkg/package.json" ]; then
name=$(jq -r '.name' "$pkg/package.json")
version=$(jq -r '.version' "$pkg/package.json")
echo "- $name@$version"
fi
done
} >> "$GITHUB_STEP_SUMMARY"
retention-days: 30
publish:
name: Publish to npm
name: Publish npm packages
if: ${{ inputs.publish }}
needs: pack
runs-on: ubuntu-latest
needs: [build]
environment: npm-production-publishing
permissions:
id-token: write # Required for npm trusted publishing (OIDC)
contents: read
id-token: write
steps:
- name: Download built packages
- name: Checkout release tag
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.release_tag }}
- name: Download npm package tarballs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: npm-packages
path: ui/
name: npm-packages-${{ needs.pack.outputs.version }}
path: ${{ runner.temp }}/npm-packages
- name: Restore executable bits on goose binaries
run: find ui/goose-binary -name 'goose' -type f -exec chmod +x {} +
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '24.10.0'
registry-url: 'https://registry.npmjs.org'
always-auth: true
- name: Setup pnpm
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
with:
version: 10.30.3
- name: Publish to npm
run: |
cd ui
# Publish each package individually so one failure doesn't abort the rest.
# Skips packages whose version is already published (409/403).
failed=0
for pkg in sdk goose-binary/*/; do
if [ -f "$pkg/package.json" ]; then
name=$(jq -r '.name' "$pkg/package.json")
version=$(jq -r '.version' "$pkg/package.json")
echo "Publishing $name@$version..."
if (cd "$pkg" && pnpm publish --access public --no-git-checks --provenance); then
echo " ✅ $name@$version published"
else
# Check if it failed because the version already exists
if npm view "$name@$version" version > /dev/null 2>&1; then
echo " ⏭️ $name@$version already published, skipping"
else
echo " ❌ $name@$version failed to publish"
failed=1
fi
fi
fi
done
if [ "$failed" -eq 1 ]; then
echo "::error::One or more packages failed to publish"
exit 1
fi
- name: Publish summary
if: always()
run: |
cd ui
{
echo "## 🚀 Published Packages"
echo ""
for pkg in sdk goose-binary/*/; do
if [ -f "$pkg/package.json" ]; then
name=$(jq -r '.name' "$pkg/package.json")
version=$(jq -r '.version' "$pkg/package.json")
echo "- $name@$version"
fi
done
} >> "$GITHUB_STEP_SUMMARY"
- name: Publish verified tarballs
env:
PACK_DIR: ${{ runner.temp }}/npm-packages
RELEASE_VERSION: ${{ needs.pack.outputs.version }}
run: bash ui/scripts/publish-npm-packages.sh "$PACK_DIR" "$RELEASE_VERSION"
+1
View File
@@ -26,6 +26,7 @@ target/
# UI
node_modules
/.pnpm-store/
./ui/desktop/out
# Generated goose DLLs (built at build time, not checked in)
+15 -7
View File
@@ -156,7 +156,7 @@ check-acp-artifacts: generate-acp-types generate-acp-docs
#!/usr/bin/env bash
set -e
echo "🔍 Checking generated ACP artifacts are up-to-date..."
if ! git diff --exit-code crates/goose/acp-schema.json crates/goose/acp-meta.json ui/sdk/src/generated/; then
if ! git diff --exit-code crates/goose/acp-schema.json crates/goose/acp-meta.json ui/goose-acp-client/src/generated/; then
echo ""
echo "❌ ACP generated files are out of date!"
echo ""
@@ -174,8 +174,8 @@ generate-acp-schema:
# Generate ACP TypeScript types from JSON schema (requires generate-acp-schema first)
generate-acp-types: generate-acp-schema
@echo "Generating ACP TypeScript types..."
cd ui/sdk && npx tsx generate-schema.ts
@echo "ACP TypeScript types generated in ui/sdk/src/generated/"
cd ui/goose-acp-client && npx tsx generate-schema.ts
@echo "ACP TypeScript types generated for the ACP client package."
# Generate ACP documentation from the existing JSON schema and metadata
generate-acp-docs:
@@ -183,11 +183,11 @@ generate-acp-docs:
node documentation/scripts/generate-acp-docs.js
@echo "ACP documentation generated for the docs build."
# Build SDK TypeScript package (schema + types + compile)
build-sdk: generate-acp-types
# Build ACP client TypeScript package (schema + types + compile)
build-acp-client: generate-acp-types
@echo "Compiling ACP TypeScript..."
cd ui/sdk && pnpm run build:ts
@echo "ACP package built."
cd ui/goose-acp-client && pnpm run build:ts
@echo "ACP client package built."
# Generate manpages for the CLI
generate-manpages:
@@ -298,8 +298,13 @@ bump-version version:
@just validate {{ version }} || exit 1
@uvx --from=toml-cli toml set --toml-path=Cargo.toml "workspace.package.version" {{ version }}
@cd ui/desktop && npm pkg set "version={{ version }}"
@node ui/scripts/npm-versions.mjs set {{ version }}
# update Cargo.lock after bumping versions in Cargo.toml
@cargo update --workspace
@just check-npm-versions
check-npm-versions:
@node ui/scripts/npm-versions.mjs check
# rebuild canonical model registry and mapping report from models.dev
build-canonical-models:
@@ -313,6 +318,9 @@ prepare-release version:
Cargo.toml \
Cargo.lock \
ui/desktop/package.json \
ui/goose-acp-client/package.json \
ui/goose-acp/package.json \
ui/goose-binary/*/package.json \
ui/pnpm-lock.yaml \
crates/goose-provider-types/src/canonical/data/canonical_models.json \
crates/goose-provider-types/src/canonical/data/provider_metadata.json
+3 -3
View File
@@ -81,10 +81,10 @@ Write-Host " Dependencies installed." -ForegroundColor Green
Write-Host ""
# Step 4: Build desktop assets
Write-Host "[5/7] Building Goose SDK, clearing Vite cache, and compiling i18n messages..." -ForegroundColor Yellow
pnpm run build-goose-sdk
Write-Host "[5/7] Building Goose ACP client, clearing Vite cache, and compiling i18n messages..." -ForegroundColor Yellow
pnpm run build-goose-acp-client
if ($LASTEXITCODE -ne 0) {
Write-Host "Goose SDK build or Vite cache cleanup failed!" -ForegroundColor Red
Write-Host "Goose ACP client build or Vite cache cleanup failed!" -ForegroundColor Red
Pop-Location
exit 1
}
+7 -7
View File
@@ -9,16 +9,16 @@
},
"main": ".vite/build/main.js",
"scripts": {
"postinstall": "pnpm run build-goose-sdk",
"postinstall": "pnpm run build-goose-acp-client",
"typecheck": "tsc --noEmit",
"build-goose-sdk": "pnpm --filter @aaif/goose-sdk run build && pnpm run clean-vite-cache",
"build-goose-acp-client": "pnpm --filter @aaif/goose-acp-client run build && pnpm run clean-vite-cache",
"clean-vite-cache": "node scripts/clean-vite-cache.js",
"start-gui": "pnpm run build-goose-sdk && pnpm run i18n:compile && electron-forge start",
"start-gui-debug": "pnpm run build-goose-sdk && pnpm run i18n:compile && electron-forge start -- --inspect=9229",
"start-gui": "pnpm run build-goose-acp-client && pnpm run i18n:compile && electron-forge start",
"start-gui-debug": "pnpm run build-goose-acp-client && pnpm run i18n:compile && electron-forge start -- --inspect=9229",
"start": "cd ../.. && just run-ui",
"start:test-error": "GOOSE_TEST_ERROR=true electron-forge start",
"package": "pnpm run build-goose-sdk && pnpm run i18n:compile && electron-forge package",
"make": "pnpm run build-goose-sdk && pnpm run i18n:compile && electron-forge make",
"package": "pnpm run build-goose-acp-client && pnpm run i18n:compile && electron-forge package",
"make": "pnpm run build-goose-acp-client && pnpm run i18n:compile && electron-forge make",
"bundle:default": "node scripts/prepare-platform-binaries.js && pnpm run make && BUNDLE_NAME=\"${GOOSE_BUNDLE_NAME:-Goose}\" && APP_DIR=\"out/${BUNDLE_NAME}-darwin-arm64\" && APP_BUNDLE=\"${APP_DIR}/${BUNDLE_NAME}.app\" && (cd \"$APP_DIR\" && ditto -c -k --sequesterRsrc --keepParent \"${BUNDLE_NAME}.app\" \"${BUNDLE_NAME}.zip\")",
"bundle:intel": "node scripts/prepare-platform-binaries.js && pnpm run make --arch=x64 && BUNDLE_NAME=\"${GOOSE_BUNDLE_NAME:-Goose}\" && APP_DIR=\"out/${BUNDLE_NAME}-darwin-x64\" && APP_BUNDLE=\"${APP_DIR}/${BUNDLE_NAME}.app\" && (cd \"$APP_DIR\" && ditto -c -k --sequesterRsrc --keepParent \"${BUNDLE_NAME}.app\" \"${BUNDLE_NAME}_intel_mac.zip\")",
"debug": "echo 'run --remote-debugging-port=8315' && BUNDLE_NAME=\"${GOOSE_BUNDLE_NAME:-Goose}\" && lldb \"out/${BUNDLE_NAME}-darwin-arm64/${BUNDLE_NAME}.app\"",
@@ -49,7 +49,7 @@
"i18n:validate-locale": "node scripts/i18n-validate-locale.js"
},
"dependencies": {
"@aaif/goose-sdk": "workspace:*",
"@aaif/goose-acp-client": "workspace:*",
"@agentclientprotocol/sdk": "1.3.0",
"@mcp-ui/client": "6.1.0",
"@modelcontextprotocol/ext-apps": "^1.1.1",
@@ -3,7 +3,7 @@ import { createSession } from '../sessions';
import type { ExtensionConfig } from '../types/extensions';
import type { Session } from '../types/session';
import type { FixedExtensionEntry } from '../components/ConfigContext';
import type { GooseExtension, GooseExtensionEntry } from '@aaif/goose-sdk';
import type { GooseExtension, GooseExtensionEntry } from '@aaif/goose-acp-client';
import { getConfiguredGooseExtensions } from '../acp/extensions';
import { acpChatSessionController } from '../acp/chatSessionController';
import { beginConfiguredRecipeParameterScope } from '../acp/recipeParamRequests';
@@ -37,7 +37,7 @@ const transport = vi.hoisted(() => ({
createWebSocketStream: vi.fn(),
}));
vi.mock('@aaif/goose-sdk', () => ({
vi.mock('@aaif/goose-acp-client', () => ({
DEFAULT_GOOSE_MCP_HOST_CAPABILITIES: {},
}));
@@ -1,4 +1,4 @@
import type { AgentMention, AvailableCommand } from '@aaif/goose-sdk';
import type { AgentMention, AvailableCommand } from '@aaif/goose-acp-client';
import { describe, expect, it } from 'vitest';
import { agentMentionToDisplayItem, availableCommandToDisplayItem } from '../autocomplete';
@@ -1,4 +1,4 @@
import type { GooseSessionNotification_unstable } from '@aaif/goose-sdk';
import type { GooseSessionNotification_unstable } from '@aaif/goose-acp-client';
import { describe, expect, it } from 'vitest';
import type { Message, MessageUsage } from '../../types/message';
import { applyGooseSessionNotification } from '../adapter/gooseSessionNotifications';
+1 -1
View File
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { RecipeDto } from '@aaif/goose-sdk';
import type { RecipeDto } from '@aaif/goose-acp-client';
import { getAcpClient } from '../acpConnection';
import { encodeRecipe, listRecipes, parseRecipe, saveRecipe } from '../recipe';
@@ -1,4 +1,4 @@
import type { RequestRecipeParams_unstable } from '@aaif/goose-sdk';
import type { RequestRecipeParams_unstable } from '@aaif/goose-acp-client';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
type RecipeParamRequestsModule = typeof import('../recipeParamRequests');
@@ -1,4 +1,4 @@
import type { GooseSessionNotification_unstable } from '@aaif/goose-sdk';
import type { GooseSessionNotification_unstable } from '@aaif/goose-acp-client';
import type { RequestPermissionRequest, SessionNotification } from '@agentclientprotocol/sdk';
import { describe, expect, it } from 'vitest';
import { getToolResponses, type Message, type NotificationEvent } from '../../types/message';
+1 -1
View File
@@ -1,4 +1,4 @@
import { DEFAULT_GOOSE_MCP_HOST_CAPABILITIES } from '@aaif/goose-sdk';
import { DEFAULT_GOOSE_MCP_HOST_CAPABILITIES } from '@aaif/goose-acp-client';
import { methods, PROTOCOL_VERSION, type InitializeResponse } from '@agentclientprotocol/sdk';
import { createWebSocketStream } from '@agentclientprotocol/sdk/experimental/ws-client';
import packageJson from '../../package.json';
@@ -1,4 +1,4 @@
import type { GooseSessionNotification_unstable } from '@aaif/goose-sdk';
import type { GooseSessionNotification_unstable } from '@aaif/goose-acp-client';
import type { MessageUsage } from '../../types/message';
import { type AcpChatStateChange, type AdapterState, messagesChange } from './shared';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { AgentMention, AvailableCommand } from '@aaif/goose-sdk';
import type { AgentMention, AvailableCommand } from '@aaif/goose-acp-client';
import type { DisplayItem } from '../components/MentionPopover';
import { getAcpClient } from './acpConnection';
+1 -1
View File
@@ -1,7 +1,7 @@
import type {
GooseSessionNotification_unstable,
ProviderDeviceCodeNotification_unstable,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import type { SessionNotification } from '@agentclientprotocol/sdk';
import { AppEvents } from '../constants/events';
import { maybeHandlePlatformEvent } from '../utils/platform_events';
+1 -1
View File
@@ -1,5 +1,5 @@
import { v7 as uuidv7 } from 'uuid';
import type { GooseExtension } from '@aaif/goose-sdk';
import type { GooseExtension } from '@aaif/goose-acp-client';
import { AppEvents } from '../constants/events';
import { ChatState } from '../types/chatState';
import type { Session } from '../types/session';
+1 -1
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import type { GooseSessionNotification_unstable } from '@aaif/goose-sdk';
import type { GooseSessionNotification_unstable } from '@aaif/goose-acp-client';
import type { SessionNotification } from '@agentclientprotocol/sdk';
import type { TokenState } from '../types/chat';
import { ChatState } from '../types/chatState';
+1 -1
View File
@@ -2,7 +2,7 @@ import type {
DictationDownloadProgress,
DictationLocalModelStatus,
DictationProviderStatusEntry,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
export type { DictationProviderStatusEntry };
+1 -1
View File
@@ -1,5 +1,5 @@
import type { ExtensionConfig, ExtensionEntry } from '../types/extensions';
import type { GooseExtension, GooseExtensionEntry } from '@aaif/goose-sdk';
import type { GooseExtension, GooseExtensionEntry } from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
export type ConfiguredExtensionEntry = ExtensionEntry & { configKey?: string };
+1 -1
View File
@@ -16,7 +16,7 @@ import {
zGooseSessionNotification_unstable,
zProviderDeviceCodeNotification_unstable,
zRequestRecipeParams_unstable,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
const [gooseSessionUpdate, providerDeviceCode] = GOOSE_EXT_NOTIFICATIONS;
const [gooseRecipeParamsRequest] = GOOSE_EXT_AGENT_REQUESTS;
+1 -1
View File
@@ -5,7 +5,7 @@ import type {
LocalInferenceModelDownloadRequest_unstable,
LocalInferenceModelDto,
LocalInferenceModelSettingsDto,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
export type LocalModelResponse = LocalInferenceModelDto;
+1 -1
View File
@@ -1,5 +1,5 @@
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import type { ToolListItem } from '@aaif/goose-sdk';
import type { ToolListItem } from '@aaif/goose-acp-client';
import type { GooseApp } from '../types/apps';
import { getAcpClient } from './acpConnection';
import { normalizeAcpError } from './errors';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { ToolListItem, ToolPermissionEntry, ToolPermissionLevel } from '@aaif/goose-sdk';
import type { ToolListItem, ToolPermissionEntry, ToolPermissionLevel } from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
export type { ToolListItem, ToolPermissionEntry, ToolPermissionLevel };
+1 -1
View File
@@ -1,5 +1,5 @@
import { methods, type ContentBlock, type PromptResponse } from '@agentclientprotocol/sdk';
import type { SteerSessionRequest_unstable, SteerSessionResponse_unstable } from '@aaif/goose-sdk';
import type { SteerSessionRequest_unstable, SteerSessionResponse_unstable } from '@aaif/goose-acp-client';
import type { Message } from '../types/message';
import { getAcpClient } from './acpConnection';
+1 -1
View File
@@ -1,7 +1,7 @@
import type {
GetPromptResponse_unstable,
PromptTemplateEntry,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
export type PromptTemplate = PromptTemplateEntry;
+1 -1
View File
@@ -7,7 +7,7 @@ import type {
RefreshProviderInventoryResponse_unstable,
ProviderTemplateCatalogEntryDto,
ProviderTemplateDto,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { methods } from '@agentclientprotocol/sdk';
import type {
ProviderDetails,
+1 -1
View File
@@ -3,7 +3,7 @@ import type {
SaveRecipeResponse_unstable,
ScanRecipeResponse_unstable,
RecipeListEntryDto,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
let inFlightListRecipes: Promise<RecipeListEntryDto[]> | null = null;
+1 -1
View File
@@ -2,7 +2,7 @@ import type {
RecipeParameterDto,
RecipeParamsResponse_unstable,
RequestRecipeParams_unstable,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { v7 as uuidv7 } from 'uuid';
export interface AcpRecipeParamRequest {
+1 -1
View File
@@ -5,7 +5,7 @@ import type {
RunScheduleNowResponse_unstable,
ScheduledJobDto,
SessionInfo,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
let inFlightListSchedules: Promise<ScheduledJobDto[]> | null = null;
@@ -1,4 +1,4 @@
import type { GooseSessionNotification_unstable } from '@aaif/goose-sdk';
import type { GooseSessionNotification_unstable } from '@aaif/goose-acp-client';
import type { SessionNotification } from '@agentclientprotocol/sdk';
import type { Message } from '../types/message';
import {
+1 -1
View File
@@ -6,7 +6,7 @@ import {
type NewSessionRequest,
type SessionInfo,
} from '@agentclientprotocol/sdk';
import type { GooseExtension, SessionExportFormat, SessionImportSource } from '@aaif/goose-sdk';
import type { GooseExtension, SessionExportFormat, SessionImportSource } from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
import type { ExtensionLoadResult } from '../types/extensions';
import type { Session } from '../types/session';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { SourceEntry, SourceType } from '@aaif/goose-sdk';
import type { SourceEntry, SourceType } from '@aaif/goose-acp-client';
import { getAcpClient } from './acpConnection';
const SKILL_SOURCE_TYPES: SourceType[] = ['skill', 'builtinSkill'];
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
import type { ScheduledJobDto } from '@aaif/goose-sdk';
import type { ScheduledJobDto } from '@aaif/goose-acp-client';
import { errorMessage } from '../../utils/conversionUtils';
import { defineMessages, useIntl } from '../../i18n';
import {
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useCallback } from 'react';
import type { ScheduledJobDto, SessionInfo } from '@aaif/goose-sdk';
import type { ScheduledJobDto, SessionInfo } from '@aaif/goose-acp-client';
import { Button } from '../ui/button';
import { ScrollArea } from '../ui/scroll-area';
import BackButton from '../ui/BackButton';
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useMemo, FormEvent, useCallback, useRef } from 'react';
import type { ScheduledJobDto } from '@aaif/goose-sdk';
import type { ScheduledJobDto } from '@aaif/goose-acp-client';
import { Card } from '../ui/card';
import { Button } from '../ui/button';
import { Input } from '../ui/input';
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useLocation } from 'react-router';
import type { ScheduledJobDto } from '@aaif/goose-sdk';
import type { ScheduledJobDto } from '@aaif/goose-acp-client';
import {
acpListSchedules,
acpCreateSchedule,
@@ -1,7 +1,7 @@
import { render, screen, type RenderOptions, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import type { ScheduledJobDto } from '@aaif/goose-sdk';
import type { ScheduledJobDto } from '@aaif/goose-acp-client';
import { IntlTestWrapper } from '../../../i18n/test-utils';
import { CronPicker } from '../CronPicker';
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, type RenderOptions, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ScheduledJobDto } from '@aaif/goose-sdk';
import type { ScheduledJobDto } from '@aaif/goose-acp-client';
import { ScheduleModal } from '../ScheduleModal';
import { IntlTestWrapper } from '../../../i18n/test-utils';
import { listSavedRecipes } from '../../../recipe/recipe_management';
@@ -54,7 +54,7 @@ import {
acpShareSessionNostr,
type SessionListItem,
} from '../../acp/sessions';
import type { SessionExportFormat } from '@aaif/goose-sdk';
import type { SessionExportFormat } from '@aaif/goose-acp-client';
import { acpChatSessionActions } from '../../acp/chatSessionStore';
import { cancelAcpPermissionRequestsForSession } from '../../acp/permissionRequests';
import { cancelAcpElicitationRequestsForSession } from '../../acp/elicitationRequests';
@@ -2,7 +2,7 @@ import React, { memo, useMemo, useCallback, useState } from 'react';
import { ProviderCard } from './subcomponents/ProviderCard';
import CardContainer from './subcomponents/CardContainer';
import ProviderConfigurationModal from './modal/ProviderConfigurationModal';
import type { CustomProviderConfigDto } from '@aaif/goose-sdk';
import type { CustomProviderConfigDto } from '@aaif/goose-acp-client';
import type { ProviderDetails, UpdateCustomProviderRequest } from '../../../types/providers';
import {
acpCreateCustomProviderFromRequest,
@@ -3,7 +3,7 @@ import { Button } from '../../../../ui/button';
import { Search, ExternalLink, Check } from 'lucide-react';
import { Input } from '../../../../ui/input';
import { Select } from '../../../../ui/Select';
import type { ProviderTemplateCatalogEntryDto, ProviderTemplateDto } from '@aaif/goose-sdk';
import type { ProviderTemplateCatalogEntryDto, ProviderTemplateDto } from '@aaif/goose-acp-client';
import {
acpGetProviderTemplate,
acpListProviderCatalogEntries,
@@ -4,7 +4,7 @@ import { Select } from '../../../../../ui/Select';
import { Button } from '../../../../../ui/button';
import { SecureStorageNotice } from '../SecureStorageNotice';
import type { UpdateCustomProviderRequest } from '../../../../../../types/providers';
import type { ProviderTemplateDto } from '@aaif/goose-sdk';
import type { ProviderTemplateDto } from '@aaif/goose-acp-client';
import { Plus, X, Trash2, AlertTriangle, ExternalLink, Search, Settings } from 'lucide-react';
import { cn } from '../../../../../../utils';
import ProviderCatalogPicker from '../ProviderCatalogPicker';
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import type { ProviderDeviceCodeNotification_unstable } from '@aaif/goose-sdk';
import type { ProviderDeviceCodeNotification_unstable } from '@aaif/goose-acp-client';
export function useProviderDeviceCode(providerId: string) {
const [deviceCode, setDeviceCode] = useState<ProviderDeviceCodeNotification_unstable | null>(
+1 -1
View File
@@ -4,7 +4,7 @@ import type {
RecipeListEntryDto,
RecipeParameterDto,
RecipeSettingsDto,
} from '@aaif/goose-sdk';
} from '@aaif/goose-acp-client';
import {
decodeRecipe as acpDecodeRecipe,
encodeRecipe as acpEncodeRecipe,
+1 -1
View File
@@ -1,4 +1,4 @@
import { zRecipeDto } from '@aaif/goose-sdk';
import { zRecipeDto } from '@aaif/goose-acp-client';
import { z } from 'zod';
type JsonSchema = Record<string, unknown>;
+1 -1
View File
@@ -1,4 +1,4 @@
import type { RecipeExtensionDto } from '@aaif/goose-sdk';
import type { RecipeExtensionDto } from '@aaif/goose-acp-client';
export type Envs = Record<string, string>;
+3 -3
View File
@@ -9,12 +9,12 @@ export default defineConfig({
plugins: [tailwindcss()],
// Vite caches a copy of @aaif/goose-sdk and doesn't notice when we rebuild it
// Vite caches a copy of @aaif/goose-acp-client and doesn't notice when we rebuild it
// locally, so it serves stale code until you clear node_modules/.vite by hand.
// Excluding it makes Vite always read the latest ui/sdk/dist build.
// Excluding it makes Vite always read the latest ui/goose-acp-client/dist build.
// Dev-server only — release builds ignore optimizeDeps.
optimizeDeps: {
exclude: ['@aaif/goose-sdk'],
exclude: ['@aaif/goose-acp-client'],
},
build: {
+2
View File
@@ -0,0 +1,2 @@
dist/
node_modules/
+64
View File
@@ -0,0 +1,64 @@
# @aaif/goose-acp-client
TypeScript client library for communicating with Goose over an existing Agent
Client Protocol (ACP) transport.
This package provides:
- TypeScript types and Zod validators for Goose ACP extension methods
- `GooseExtClient` for calling Goose extension methods
- Client capability definitions and MCP Apps helpers
It does not install, resolve, or start the Goose executable. Applications own
the transport and process lifecycle.
## Installation
```bash
npm install @aaif/goose-acp-client @agentclientprotocol/sdk
```
## Usage
Compose the Goose extension client with the standard ACP SDK:
```typescript
import {
client as createAcpClient,
methods,
PROTOCOL_VERSION,
type Stream,
} from "@agentclientprotocol/sdk";
import { GooseExtClient } from "@aaif/goose-acp-client";
async function connectToGoose(stream: Stream) {
const app = createAcpClient({ name: "my-product" });
const connection = app.connect(stream);
const goose = new GooseExtClient(connection.agent);
await connection.agent.request(methods.agent.initialize, {
protocolVersion: PROTOCOL_VERSION,
clientInfo: {
name: "my-product",
version: "1.0.0",
},
clientCapabilities: {},
});
return { connection, goose };
}
```
The application creates and owns the `stream`, including its connection and
process lifecycle. Call `connection.close()` when the application no longer
needs the connection.
## Development
From `ui/goose-acp-client`:
```bash
pnpm run build
```
The generated TypeScript types come from the Rust schemas in `crates/goose`.
@@ -1,7 +1,7 @@
{
"name": "@aaif/goose-sdk",
"version": "0.20.2",
"description": "Agent Client Protocol (ACP) SDK for Goose AI agent",
"name": "@aaif/goose-acp-client",
"version": "1.49.0",
"description": "TypeScript client library for Goose over Agent Client Protocol (ACP)",
"license": "Apache-2.0",
"repository": {
"type": "git",
@@ -21,10 +21,6 @@
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./node": {
"types": "./dist/resolve-binary.d.ts",
"default": "./dist/resolve-binary.js"
}
},
"files": [
@@ -33,12 +29,10 @@
"scripts": {
"build": "npm run generate && npm run build:ts",
"build:ts": "tsc",
"build:native": "tsx scripts/build-native.ts",
"build:native:all": "tsx scripts/build-native.ts --all",
"generate": "tsx generate-schema.ts",
"lint": "tsc --noEmit",
"format": "prettier --write src/",
"check:compat": "node scripts/check-binary-compat.mjs"
"format": "prettier --write src/ generate-schema.ts",
"prepack": "npm run build"
},
"dependencies": {
"@modelcontextprotocol/ext-apps": "^0.3.1",
@@ -48,13 +42,6 @@
"peerDependencies": {
"@agentclientprotocol/sdk": "^1.3.0"
},
"optionalDependencies": {
"@aaif/goose-binary-darwin-arm64": "workspace:*",
"@aaif/goose-binary-darwin-x64": "workspace:*",
"@aaif/goose-binary-linux-arm64": "workspace:*",
"@aaif/goose-binary-linux-x64": "workspace:*",
"@aaif/goose-binary-win32-x64": "workspace:*"
},
"devDependencies": {
"@agentclientprotocol/sdk": "1.3.0",
"@hey-api/openapi-ts": "^0.99.0",
@@ -7,7 +7,6 @@
"esModuleInterop": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"outDir": "./dist",
"rootDir": "./src",
},
+2
View File
@@ -0,0 +1,2 @@
dist/
node_modules/
+63
View File
@@ -0,0 +1,63 @@
# @aaif/goose-acp
Install and resolve the Goose executable through npm.
This package distributes the Goose CLI using platform-specific optional npm
dependencies. It does not contain or depend on the Goose ACP client.
## Installation
```bash
npm install @aaif/goose-acp
```
The matching `@aaif/goose-binary-*` package is installed automatically. Do not
install a platform package directly; `@aaif/goose-acp` provides the supported
`goose` command.
## Usage
Run the Goose CLI installed by the package:
```bash
npx goose acp
npx goose serve
```
The launcher forwards arguments and standard input, output, and error streams to
the native executable. It preserves the executable's exit status and forwards
termination signals.
Resolve the executable path programmatically:
```typescript
import { resolveGooseBinary } from "@aaif/goose-acp";
const binaryPath = resolveGooseBinary();
```
`resolveGooseBinary()` first uses `GOOSE_BINARY` when it is set. Otherwise, it
selects the package matching `process.platform` and `process.arch`. In both
cases it verifies that the executable exists and returns an absolute path.
Use the override to run a locally built or custom Goose executable:
```bash
GOOSE_BINARY=/path/to/goose npx goose acp
```
`GOOSE_BINARY` must point directly to a native Goose executable, not a
`node_modules/.bin/goose` command shim.
Supported platforms:
| Operating system | Architecture |
| ---------------- | ------------ |
| macOS | ARM64 |
| macOS | x64 |
| Linux | ARM64 |
| Linux | x64 |
| Windows | x64 |
Package managers must install optional dependencies. If optional dependencies
are disabled, the resolver reports which platform package is missing.
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env node
import { spawn } from "node:child_process";
import { resolveGooseBinary } from "../dist/index.js";
const forwardedSignals =
process.platform === "win32"
? ["SIGINT", "SIGTERM"]
: ["SIGHUP", "SIGINT", "SIGTERM"];
try {
const binaryPath = resolveGooseBinary();
const child = spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",
});
const signalHandlers = new Map();
for (const signal of forwardedSignals) {
const handler = () => {
if (child.exitCode === null && child.signalCode === null) {
child.kill(signal);
}
};
signalHandlers.set(signal, handler);
process.on(signal, handler);
}
const removeSignalHandlers = () => {
for (const [signal, handler] of signalHandlers) {
process.off(signal, handler);
}
};
child.once("error", (error) => {
removeSignalHandlers();
reportError(error);
process.exitCode = 1;
});
child.once("exit", (code, signal) => {
removeSignalHandlers();
if (signal) {
try {
process.kill(process.pid, signal);
} catch {
process.exitCode = signalExitCode(signal);
}
return;
}
process.exitCode = code ?? 1;
});
} catch (error) {
reportError(error);
process.exitCode = 1;
}
function reportError(error) {
const message = error instanceof Error ? error.message : String(error);
console.error(`goose: ${message}`);
}
function signalExitCode(signal) {
switch (signal) {
case "SIGHUP":
return 129;
case "SIGINT":
return 130;
case "SIGTERM":
return 143;
default:
return 1;
}
}
+52
View File
@@ -0,0 +1,52 @@
{
"name": "@aaif/goose-acp",
"version": "1.49.0",
"description": "Install and resolve the Goose executable through npm",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"keywords": [
"goose",
"ai",
"agent",
"acp",
"binary"
],
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"bin": {
"goose": "./bin/goose.mjs"
},
"files": [
"bin",
"dist"
],
"scripts": {
"build": "tsc",
"test": "npm run build && node --test test/*.test.mjs",
"lint": "tsc --noEmit",
"format": "prettier --write src/ test/ bin/",
"prepack": "npm run build"
},
"optionalDependencies": {
"@aaif/goose-binary-darwin-arm64": "workspace:*",
"@aaif/goose-binary-darwin-x64": "workspace:*",
"@aaif/goose-binary-linux-arm64": "workspace:*",
"@aaif/goose-binary-linux-x64": "workspace:*",
"@aaif/goose-binary-win32-x64": "workspace:*"
},
"devDependencies": {
"@types/node": "^26.2.0",
"prettier": "^3.9.6",
"typescript": "~5.9.3"
}
}
+1
View File
@@ -0,0 +1 @@
export { resolveGooseBinary } from "./resolve-binary.js";
+84
View File
@@ -0,0 +1,84 @@
import { statSync } from "node:fs";
import { createRequire } from "node:module";
import { dirname, resolve } from "node:path";
const PLATFORM_PACKAGES: Record<string, string> = {
"darwin-arm64": "@aaif/goose-binary-darwin-arm64",
"darwin-x64": "@aaif/goose-binary-darwin-x64",
"linux-arm64": "@aaif/goose-binary-linux-arm64",
"linux-x64": "@aaif/goose-binary-linux-x64",
"win32-x64": "@aaif/goose-binary-win32-x64",
};
const require = createRequire(import.meta.url);
export interface BinaryResolverDependencies {
resolvePackageJson(specifier: string): string;
isFile(path: string): boolean;
}
const resolverDependencies: BinaryResolverDependencies = {
resolvePackageJson: (specifier) => require.resolve(specifier),
isFile: (path) => {
try {
return statSync(path).isFile();
} catch {
return false;
}
},
};
export function resolveGooseBinary(): string {
const override = process.env.GOOSE_BINARY?.trim();
if (override) {
const binaryPath = resolve(override);
if (!resolverDependencies.isFile(binaryPath)) {
throw new Error(`GOOSE_BINARY does not point to a file: ${binaryPath}.`);
}
return binaryPath;
}
return resolveGooseBinaryForRuntime(
process.platform,
process.arch,
resolverDependencies,
);
}
export function resolveGooseBinaryForRuntime(
platform: string,
arch: string,
dependencies: BinaryResolverDependencies,
): string {
const platformKey = `${platform}-${arch}`;
const packageName = PLATFORM_PACKAGES[platformKey];
if (!packageName) {
throw new Error(
`No Goose npm binary is available for ${platformKey}. Supported platforms: ${Object.keys(PLATFORM_PACKAGES).join(", ")}.`,
);
}
let packageJsonPath: string;
try {
packageJsonPath = dependencies.resolvePackageJson(
`${packageName}/package.json`,
);
} catch (cause) {
throw new Error(
`Goose binary package ${packageName} is not installed. Reinstall @aaif/goose-acp with optional dependencies enabled.`,
{ cause },
);
}
const executableName = platform === "win32" ? "goose.exe" : "goose";
const binaryPath = resolve(dirname(packageJsonPath), "bin", executableName);
if (!dependencies.isFile(binaryPath)) {
throw new Error(
`Goose executable from ${packageName} was not found at ${binaryPath}.`,
);
}
return binaryPath;
}
+181
View File
@@ -0,0 +1,181 @@
import assert from "node:assert/strict";
import { spawn, spawnSync } from "node:child_process";
import {
chmodSync,
copyFileSync,
cpSync,
mkdirSync,
mkdtempSync,
rmSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { after, test } from "node:test";
import { fileURLToPath } from "node:url";
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const tempDirs = [];
const platformPackageNames = {
"darwin-arm64": "@aaif/goose-binary-darwin-arm64",
"darwin-x64": "@aaif/goose-binary-darwin-x64",
"linux-arm64": "@aaif/goose-binary-linux-arm64",
"linux-x64": "@aaif/goose-binary-linux-x64",
"win32-x64": "@aaif/goose-binary-win32-x64",
};
function createLauncherHarness() {
const root = mkdtempSync(join(tmpdir(), "goose-acp-launcher-"));
tempDirs.push(root);
const scopeDir = join(root, "node_modules", "@aaif");
const wrapperDir = join(scopeDir, "goose-acp");
mkdirSync(wrapperDir, { recursive: true });
cpSync(join(packageRoot, "dist"), join(wrapperDir, "dist"), {
recursive: true,
});
mkdirSync(join(wrapperDir, "bin"));
copyFileSync(
join(packageRoot, "bin", "goose.mjs"),
join(wrapperDir, "bin", "goose.mjs"),
);
const platformKey = `${process.platform}-${process.arch}`;
const packageName = platformPackageNames[platformKey];
assert.ok(packageName, `test does not support ${platformKey}`);
const platformPackageDir = join(scopeDir, packageName.slice("@aaif/".length));
const platformBinDir = join(platformPackageDir, "bin");
const executableName = process.platform === "win32" ? "goose.exe" : "goose";
const executablePath = join(platformBinDir, executableName);
mkdirSync(platformBinDir, { recursive: true });
writeFileSync(
join(platformPackageDir, "package.json"),
JSON.stringify({ name: packageName, version: "0.20.2" }),
);
if (process.platform === "win32") {
copyFileSync(process.execPath, executablePath);
} else {
writeFileSync(
executablePath,
'#!/bin/sh\nexec "$GOOSE_ACP_TEST_NODE" "$@"\n',
);
}
chmodSync(executablePath, 0o755);
return join(wrapperDir, "bin", "goose.mjs");
}
function runLauncher(args, input) {
const launcherPath = createLauncherHarness();
const result = spawnSync(process.execPath, [launcherPath, ...args], {
encoding: "utf8",
env: {
...process.env,
GOOSE_BINARY: "",
GOOSE_ACP_TEST_NODE: process.execPath,
},
input,
});
assert.equal(result.error, undefined);
return result;
}
function waitForExit(child, timeoutMs = 5_000) {
return new Promise((resolvePromise, reject) => {
const timeout = setTimeout(() => {
child.kill("SIGKILL");
reject(new Error(`launcher did not exit within ${timeoutMs}ms`));
}, timeoutMs);
child.once("exit", (code, signal) => {
clearTimeout(timeout);
resolvePromise({ code, signal });
});
});
}
function waitForOutput(stream, expected, timeoutMs = 5_000) {
return new Promise((resolvePromise, reject) => {
let output = "";
const timeout = setTimeout(() => {
reject(new Error(`did not receive ${JSON.stringify(expected)}`));
}, timeoutMs);
stream.setEncoding("utf8");
stream.on("data", (chunk) => {
output += chunk;
if (output.includes(expected)) {
clearTimeout(timeout);
resolvePromise(output);
}
});
});
}
after(() => {
for (const dir of tempDirs) {
rmSync(dir, { recursive: true, force: true });
}
});
test("forwards arguments, stdin, stdout, and stderr", () => {
const script = [
'const fs = require("node:fs");',
'const input = fs.readFileSync(0, "utf8");',
"console.log(JSON.stringify({ args: process.argv.slice(1), input }));",
'console.error("native stderr");',
].join("");
const result = runLauncher(
["-e", script, "first", "two words"],
"native stdin",
);
assert.equal(result.status, 0);
assert.deepEqual(JSON.parse(result.stdout), {
args: ["first", "two words"],
input: "native stdin",
});
assert.equal(result.stderr.trim(), "native stderr");
});
test("preserves a nonzero native exit status", () => {
const result = runLauncher(["-e", "process.exit(37)"]);
assert.equal(result.status, 37);
});
test(
"forwards termination and preserves signal termination",
{ skip: process.platform === "win32" },
async (t) => {
const launcherPath = createLauncherHarness();
const child = spawn(
process.execPath,
[launcherPath, "-e", 'console.log("ready"); setInterval(() => {}, 1000)'],
{
env: {
...process.env,
GOOSE_BINARY: "",
GOOSE_ACP_TEST_NODE: process.execPath,
},
stdio: ["ignore", "pipe", "pipe"],
},
);
t.after(() => {
if (child.exitCode === null && child.signalCode === null) {
child.kill("SIGKILL");
}
});
await waitForOutput(child.stdout, "ready");
child.kill("SIGTERM");
const result = await waitForExit(child);
assert.equal(result.code, null);
assert.equal(result.signal, "SIGTERM");
},
);
+131
View File
@@ -0,0 +1,131 @@
import assert from "node:assert/strict";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import test from "node:test";
import { isAbsolute, join, relative, resolve } from "node:path";
import * as publicApi from "../dist/index.js";
import { resolveGooseBinaryForRuntime } from "../dist/resolve-binary.js";
const supportedPlatforms = [
["darwin", "arm64", "@aaif/goose-binary-darwin-arm64", "goose"],
["darwin", "x64", "@aaif/goose-binary-darwin-x64", "goose"],
["linux", "arm64", "@aaif/goose-binary-linux-arm64", "goose"],
["linux", "x64", "@aaif/goose-binary-linux-x64", "goose"],
["win32", "x64", "@aaif/goose-binary-win32-x64", "goose.exe"],
];
function setGooseBinary(t, value) {
const original = process.env.GOOSE_BINARY;
process.env.GOOSE_BINARY = value;
t.after(() => {
if (original === undefined) {
delete process.env.GOOSE_BINARY;
} else {
process.env.GOOSE_BINARY = original;
}
});
}
for (const [
platform,
arch,
packageName,
executableName,
] of supportedPlatforms) {
test(`resolves ${platform}-${arch}`, () => {
let resolvedSpecifier;
let checkedPath;
const fixturePackageRoot = join("/fixtures", packageName);
const result = resolveGooseBinaryForRuntime(platform, arch, {
resolvePackageJson(specifier) {
resolvedSpecifier = specifier;
return join(fixturePackageRoot, "package.json");
},
isFile(path) {
checkedPath = path;
return true;
},
});
assert.equal(resolvedSpecifier, `${packageName}/package.json`);
assert.equal(result, resolve(fixturePackageRoot, "bin", executableName));
assert.equal(checkedPath, result);
assert.equal(isAbsolute(result), true);
});
}
test("exports only the public resolver from the package root", () => {
assert.deepEqual(Object.keys(publicApi), ["resolveGooseBinary"]);
});
test("uses GOOSE_BINARY as an explicit override", (t) => {
const directory = mkdtempSync(join(tmpdir(), "goose-acp-override-"));
const binaryPath = join(directory, "goose");
writeFileSync(binaryPath, "");
setGooseBinary(t, relative(process.cwd(), binaryPath));
t.after(() => {
rmSync(directory, { recursive: true, force: true });
});
assert.equal(publicApi.resolveGooseBinary(), binaryPath);
});
test("rejects an invalid GOOSE_BINARY override", (t) => {
setGooseBinary(t, "missing-goose-binary");
assert.throws(
() => publicApi.resolveGooseBinary(),
/GOOSE_BINARY does not point to a file/,
);
});
test("reports unsupported platform and architecture combinations", () => {
assert.throws(
() =>
resolveGooseBinaryForRuntime("freebsd", "x64", {
resolvePackageJson() {
throw new Error("should not resolve a package");
},
isFile() {
return false;
},
}),
/No Goose npm binary is available for freebsd-x64/,
);
});
test("reports a missing optional platform package", () => {
assert.throws(
() =>
resolveGooseBinaryForRuntime("linux", "x64", {
resolvePackageJson() {
throw new Error("module not found");
},
isFile() {
return false;
},
}),
/Goose binary package @aaif\/goose-binary-linux-x64 is not installed/,
);
});
test("reports a missing executable in an installed platform package", () => {
assert.throws(
() =>
resolveGooseBinaryForRuntime("darwin", "arm64", {
resolvePackageJson() {
return join(
"/fixtures",
"@aaif/goose-binary-darwin-arm64/package.json",
);
},
isFile() {
return false;
},
}),
/Goose executable from @aaif\/goose-binary-darwin-arm64 was not found/,
);
});
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "nodenext",
"strict": true,
"skipLibCheck": true,
"declaration": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src"]
}
+14 -40
View File
@@ -13,45 +13,19 @@ This directory contains the npm package scaffolding for distributing the
| `@aaif/goose-binary-linux-x64` | Linux x64 |
| `@aaif/goose-binary-win32-x64` | Windows x64 |
## Building
From the repository root:
```bash
# Build for current platform only
cd ui/sdk
npm run build:native
# Build for all platforms (requires cross-compilation toolchains)
npm run build:native:all
# Build for specific platform(s)
npx tsx scripts/build-native.ts darwin-arm64 linux-x64
```
The built binaries are placed into `ui/goose-binary/goose-binary-{platform}/bin/`.
These directories are git-ignored.
Linux native binaries are built with local inference Vulkan support. Linux build
hosts need Vulkan headers and `glslc`; Linux runtime hosts need the Vulkan loader
package, such as `libvulkan1` on Debian/Ubuntu or `vulkan-loader` on RPM-based
distributions.
## Publishing
Publishing is handled by GitHub Actions. See `.github/workflows/publish-npm.yml`.
For manual publishing:
```bash
# From repository root
./ui/scripts/publish.sh --real
```
This will publish all native packages along with `@aaif/goose-sdk`.
## Usage
These packages are installed as optional dependencies by `@aaif/goose-sdk`, which
resolves the appropriate package for the user's platform automatically. See
`ui/sdk/src/resolve-binary.ts` for how the binary path is resolved.
These are platform-specific implementation dependencies and are not intended
to be installed directly. Install `@aaif/goose-acp` instead. It installs the
appropriate package automatically and provides the `goose` command. Each
binary package contains its native executable. Its platform-specific internal
command preserves executable permissions during npm packing;
`@aaif/goose-acp` remains the sole owner of the supported `goose` command.
## Release preparation
The `.github/workflows/publish-npm.yml` workflow downloads the binaries from an
exact versioned Goose release and prepares the platform package tarballs.
By default it only uploads the verified tarballs as a workflow artifact. Set
the manual `publish` input to publish them through the protected npm production
environment.
@@ -1,15 +1,12 @@
{
"name": "@aaif/goose-binary-darwin-arm64",
"version": "0.20.2",
"version": "1.49.0",
"description": "Goose binary for macOS ARM64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"bin": {
"goose": "bin/goose"
},
"keywords": [
"goose",
"ai",
@@ -22,6 +19,9 @@
"cpu": [
"arm64"
],
"bin": {
"goose-binary-darwin-arm64": "./bin/goose"
},
"files": [
"bin/goose"
]
@@ -1,15 +1,12 @@
{
"name": "@aaif/goose-binary-darwin-x64",
"version": "0.20.2",
"version": "1.49.0",
"description": "Goose binary for macOS x64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"bin": {
"goose": "bin/goose"
},
"keywords": [
"goose",
"ai",
@@ -22,6 +19,9 @@
"cpu": [
"x64"
],
"bin": {
"goose-binary-darwin-x64": "./bin/goose"
},
"files": [
"bin/goose"
]
@@ -1,15 +1,12 @@
{
"name": "@aaif/goose-binary-linux-arm64",
"version": "0.20.2",
"version": "1.49.0",
"description": "Goose binary for Linux ARM64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"bin": {
"goose": "bin/goose"
},
"keywords": [
"goose",
"ai",
@@ -22,6 +19,9 @@
"cpu": [
"arm64"
],
"bin": {
"goose-binary-linux-arm64": "./bin/goose"
},
"files": [
"bin/goose"
]
@@ -1,15 +1,12 @@
{
"name": "@aaif/goose-binary-linux-x64",
"version": "0.20.2",
"version": "1.49.0",
"description": "Goose binary for Linux x64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"bin": {
"goose": "bin/goose"
},
"keywords": [
"goose",
"ai",
@@ -22,6 +19,9 @@
"cpu": [
"x64"
],
"bin": {
"goose-binary-linux-x64": "./bin/goose"
},
"files": [
"bin/goose"
]
@@ -1,15 +1,12 @@
{
"name": "@aaif/goose-binary-win32-x64",
"version": "0.20.2",
"version": "1.49.0",
"description": "Goose binary for Windows x64",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aaif-goose/goose.git"
},
"bin": {
"goose": "bin/goose.exe"
},
"keywords": [
"goose",
"ai",
@@ -22,6 +19,9 @@
"cpu": [
"x64"
],
"bin": {
"goose-binary-win32-x64": "./bin/goose.exe"
},
"files": [
"bin/goose.exe"
]
+2 -1
View File
@@ -1,7 +1,8 @@
{
"private": true,
"workspaces": [
"sdk",
"goose-acp-client",
"goose-acp",
"desktop",
"goose-binary/*"
],
+40 -28
View File
@@ -18,9 +18,9 @@ importers:
desktop:
dependencies:
'@aaif/goose-sdk':
'@aaif/goose-acp-client':
specifier: workspace:*
version: link:../sdk
version: link:../goose-acp-client
'@agentclientprotocol/sdk':
specifier: 1.3.0
version: 1.3.0(zod@4.4.3)
@@ -332,17 +332,35 @@ importers:
specifier: ^4.1.10
version: 4.1.10(@opentelemetry/api@1.9.0)(@types/node@26.2.0)(@vitest/coverage-v8@4.1.10)(@vitest/ui@4.1.10)(jsdom@28.1.0)(vite@8.2.1(@types/node@26.2.0)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.50.0)(tsx@4.23.12)(yaml@2.8.2))
goose-binary/goose-binary-darwin-arm64: {}
goose-acp:
devDependencies:
'@types/node':
specifier: ^26.2.0
version: 26.2.0
prettier:
specifier: ^3.9.6
version: 3.9.6
typescript:
specifier: ~5.9.3
version: 5.9.3
optionalDependencies:
'@aaif/goose-binary-darwin-arm64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-darwin-arm64
'@aaif/goose-binary-darwin-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-darwin-x64
'@aaif/goose-binary-linux-arm64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-linux-arm64
'@aaif/goose-binary-linux-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-linux-x64
'@aaif/goose-binary-win32-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-win32-x64
goose-binary/goose-binary-darwin-x64: {}
goose-binary/goose-binary-linux-arm64: {}
goose-binary/goose-binary-linux-x64: {}
goose-binary/goose-binary-win32-x64: {}
sdk:
goose-acp-client:
dependencies:
'@modelcontextprotocol/ext-apps':
specifier: ^0.3.1
@@ -372,22 +390,16 @@ importers:
typescript:
specifier: ~5.9.3
version: 5.9.3
optionalDependencies:
'@aaif/goose-binary-darwin-arm64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-darwin-arm64
'@aaif/goose-binary-darwin-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-darwin-x64
'@aaif/goose-binary-linux-arm64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-linux-arm64
'@aaif/goose-binary-linux-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-linux-x64
'@aaif/goose-binary-win32-x64':
specifier: workspace:*
version: link:../goose-binary/goose-binary-win32-x64
goose-binary/goose-binary-darwin-arm64: {}
goose-binary/goose-binary-darwin-x64: {}
goose-binary/goose-binary-linux-arm64: {}
goose-binary/goose-binary-linux-x64: {}
goose-binary/goose-binary-win32-x64: {}
packages:
+2 -1
View File
@@ -1,5 +1,6 @@
packages:
- 'sdk'
- 'goose-acp-client'
- 'goose-acp'
- 'desktop'
- 'goose-binary/*'
+156
View File
@@ -0,0 +1,156 @@
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const uiDirectory = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const repositoryRoot = resolve(uiDirectory, "..");
const wrapperPath = resolve(uiDirectory, "goose-acp/package.json");
const binaryPlatforms = [
"darwin-arm64",
"darwin-x64",
"linux-arm64",
"linux-x64",
"win32-x64",
];
const binaryPackages = binaryPlatforms.map(
(platform) => `@aaif/goose-binary-${platform}`,
);
const packagePaths = [
resolve(uiDirectory, "goose-acp-client/package.json"),
wrapperPath,
...binaryPlatforms.map((platform) =>
resolve(uiDirectory, `goose-binary/goose-binary-${platform}/package.json`),
),
];
function readJson(path) {
return JSON.parse(readFileSync(path, "utf8"));
}
function writeJson(path, value) {
writeFileSync(path, `${JSON.stringify(value, null, 2)}\n`);
}
function readCargoVersion() {
const cargoToml = readFileSync(resolve(repositoryRoot, "Cargo.toml"), "utf8");
const workspacePackage = cargoToml.match(
/\[workspace\.package\]([\s\S]*?)(?:\n\[|$)/,
)?.[1];
const version = workspacePackage?.match(/^version\s*=\s*"([^"]+)"/m)?.[1];
if (!version) {
throw new Error("Could not read workspace.package.version from Cargo.toml");
}
return version;
}
function setVersions(version) {
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(version)) {
throw new Error(`Invalid version: ${version}`);
}
for (const path of packagePaths) {
const manifest = readJson(path);
manifest.version = version;
writeJson(path, manifest);
}
console.log(`Updated Goose npm packages to ${version}`);
}
function checkVersions() {
const expectedVersion = readCargoVersion();
const errors = [];
const desktop = readJson(resolve(uiDirectory, "desktop/package.json"));
if (desktop.version !== expectedVersion) {
errors.push(
`goose-app is ${desktop.version}; expected ${expectedVersion} from Cargo.toml`,
);
}
for (const path of packagePaths) {
const manifest = readJson(path);
if (manifest.version !== expectedVersion) {
errors.push(
`${manifest.name} is ${manifest.version}; expected ${expectedVersion}`,
);
}
}
const wrapper = readJson(wrapperPath);
for (const packageName of binaryPackages) {
const expectedSpecifier = "workspace:*";
const actualSpecifier = wrapper.optionalDependencies?.[packageName];
if (actualSpecifier !== expectedSpecifier) {
errors.push(
`${packageName} uses ${actualSpecifier ?? "no specifier"}; expected ${expectedSpecifier}`,
);
}
}
if (errors.length > 0) {
throw new Error(
`Goose version alignment failed:\n- ${errors.join("\n- ")}`,
);
}
console.log(`Goose versions are aligned at ${expectedVersion}`);
return expectedVersion;
}
function checkReleaseVersion(version) {
const expectedVersion = checkVersions();
if (version !== expectedVersion) {
throw new Error(
`Release is ${version}; expected ${expectedVersion} from Cargo.toml`,
);
}
console.log(`Goose versions match release ${version}`);
}
function checkPackedWrapper(path) {
const expectedVersion = readCargoVersion();
const wrapper = readJson(resolve(path));
const errors = [];
for (const packageName of binaryPackages) {
const actualSpecifier = wrapper.optionalDependencies?.[packageName];
if (actualSpecifier !== expectedVersion) {
errors.push(
`${packageName} uses ${actualSpecifier ?? "no specifier"}; expected ${expectedVersion}`,
);
}
}
if (errors.length > 0) {
throw new Error(
`Packed Goose wrapper version check failed:\n- ${errors.join("\n- ")}`,
);
}
console.log(`Packed Goose wrapper uses binary version ${expectedVersion}`);
}
const [command, argument] = process.argv.slice(2);
try {
if (command === "set" && argument) {
setVersions(argument);
} else if (command === "check" && !argument) {
checkVersions();
} else if (command === "check-release" && argument) {
checkReleaseVersion(argument);
} else if (command === "check-packed-wrapper" && argument) {
checkPackedWrapper(argument);
} else {
throw new Error(
"Usage: node ui/scripts/npm-versions.mjs <set VERSION|check|check-release VERSION|check-packed-wrapper PATH>",
);
}
} catch (error) {
console.error(error.message);
process.exitCode = 1;
}
+168
View File
@@ -0,0 +1,168 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo "Usage: $0 RELEASE_TAG OUTPUT_DIRECTORY" >&2
exit 1
fi
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
release_tag="$1"
release_version="${release_tag#v}"
output_dir="$2"
repository="${GITHUB_REPOSITORY:-aaif-goose/goose}"
work_dir="$(mktemp -d)"
asset_dir="$work_dir/assets"
extract_root="$work_dir/extracted"
wrapper_extract_dir="$work_dir/wrapper"
smoke_dir="$work_dir/smoke"
trap 'rm -rf "$work_dir"' EXIT
mkdir -p "$asset_dir" "$wrapper_extract_dir" "$smoke_dir"
download_release_binaries() {
gh release download "$release_tag" \
--repo "$repository" \
--dir "$asset_dir" \
--pattern 'goose-aarch64-apple-darwin.tar.bz2' \
--pattern 'goose-x86_64-apple-darwin.tar.bz2' \
--pattern 'goose-aarch64-unknown-linux-gnu.tar.bz2' \
--pattern 'goose-x86_64-unknown-linux-gnu.tar.bz2' \
--pattern 'goose-x86_64-pc-windows-msvc.zip'
}
copy_unix_binary() {
local platform="$1"
local target="$2"
local extract_dir="$extract_root/$platform"
local destination="$repo_root/ui/goose-binary/goose-binary-$platform/bin/goose"
mkdir -p "$extract_dir" "$(dirname "$destination")"
tar -xjf "$asset_dir/goose-$target.tar.bz2" -C "$extract_dir"
test -f "$extract_dir/goose"
rm -f "$destination"
install -m 755 "$extract_dir/goose" "$destination"
}
copy_release_binaries() {
copy_unix_binary darwin-arm64 aarch64-apple-darwin
copy_unix_binary darwin-x64 x86_64-apple-darwin
copy_unix_binary linux-arm64 aarch64-unknown-linux-gnu
copy_unix_binary linux-x64 x86_64-unknown-linux-gnu
local extract_dir="$extract_root/win32-x64"
local destination="$repo_root/ui/goose-binary/goose-binary-win32-x64/bin/goose.exe"
mkdir -p "$extract_dir" "$(dirname "$destination")"
unzip -q "$asset_dir/goose-x86_64-pc-windows-msvc.zip" -d "$extract_dir"
test -f "$extract_dir/goose-package/goose.exe"
rm -f "$destination"
install -m 755 "$extract_dir/goose-package/goose.exe" "$destination"
}
assert_version() {
local subject="$1"
local actual_version="$2"
if [[ "$actual_version" != "$release_version" ]]; then
echo "$subject is $actual_version; expected $release_version" >&2
exit 1
fi
}
current_platform() {
"$repo_root/bin/node" -p '`${process.platform}-${process.arch}`'
}
current_platform_binary() {
local platform
local executable="goose"
platform="$(current_platform)"
case "$platform" in
darwin-arm64 | darwin-x64 | linux-arm64 | linux-x64) ;;
win32-x64) executable="goose.exe" ;;
*)
echo "No Goose npm binary is available for $platform" >&2
return 1
;;
esac
echo "$repo_root/ui/goose-binary/goose-binary-$platform/bin/$executable"
}
verify_release_versions() {
local binary
binary="$(current_platform_binary)"
"$repo_root/bin/node" "$repo_root/ui/scripts/npm-versions.mjs" \
check-release "$release_version"
assert_version "Current-platform binary" \
"$("$binary" --version | xargs)"
}
pack_packages() {
local packages=(
ui/goose-binary/goose-binary-darwin-arm64
ui/goose-binary/goose-binary-darwin-x64
ui/goose-binary/goose-binary-linux-arm64
ui/goose-binary/goose-binary-linux-x64
ui/goose-binary/goose-binary-win32-x64
ui/goose-acp
ui/goose-acp-client
)
local package
mkdir -p "$output_dir"
for package in "${packages[@]}"; do
"$repo_root/bin/pnpm" --dir "$repo_root/$package" pack \
--pack-destination "$output_dir"
done
tar -xzf "$output_dir/aaif-goose-acp-$release_version.tgz" \
-C "$wrapper_extract_dir"
"$repo_root/bin/node" "$repo_root/ui/scripts/npm-versions.mjs" \
check-packed-wrapper "$wrapper_extract_dir/package/package.json"
(
cd "$output_dir"
sha256sum -- *.tgz > SHA256SUMS
)
}
verify_packed_wrapper() {
local platform
platform="$(current_platform)"
(
cd "$smoke_dir"
"$repo_root/bin/npm" init --yes >/dev/null
"$repo_root/bin/pnpm" add \
"$output_dir/aaif-goose-binary-$platform-$release_version.tgz" \
"$output_dir/aaif-goose-acp-$release_version.tgz"
assert_version "Packed wrapper" \
"$(env -u GOOSE_BINARY "$repo_root/bin/pnpm" exec goose --version | xargs)"
)
}
echo "Preparing npm packages for $release_tag"
echo "Downloading release binaries"
download_release_binaries
echo "Copying binaries into platform packages"
copy_release_binaries
echo "Installing workspace dependencies"
"$repo_root/bin/pnpm" --dir "$repo_root/ui" install --frozen-lockfile
echo "Verifying release versions"
verify_release_versions
echo "Packing npm packages"
pack_packages
echo "Verifying the packed wrapper"
verify_packed_wrapper
echo "Prepared npm package tarballs in $output_dir"
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -ne 2 ]]; then
echo "Usage: $0 PACKAGE_DIRECTORY RELEASE_VERSION" >&2
exit 1
fi
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
package_dir="$1"
release_version="$2"
packages=(
@aaif/goose-binary-darwin-arm64
@aaif/goose-binary-darwin-x64
@aaif/goose-binary-linux-arm64
@aaif/goose-binary-linux-x64
@aaif/goose-binary-win32-x64
@aaif/goose-acp
@aaif/goose-acp-client
)
calculate_integrity() {
"$repo_root/bin/node" -e '
const { createHash } = require("node:crypto");
const { readFileSync } = require("node:fs");
const digest = createHash("sha512")
.update(readFileSync(process.argv[1]))
.digest("base64");
console.log(`sha512-${digest}`);
' "$1"
}
publish_package() {
local package_name="$1"
local tarball="$package_dir/aaif-${package_name#@aaif/}-$release_version.tgz"
local package_spec="$package_name@$release_version"
local published_integrity
local local_integrity
local view_output
test -f "$tarball"
local_integrity="$(calculate_integrity "$tarball")"
if view_output=$("$repo_root/bin/npm" view \
"$package_spec" dist.integrity 2>&1); then
published_integrity="$view_output"
if [[ "$published_integrity" != "$local_integrity" ]]; then
echo "$package_spec is already published with different contents" >&2
exit 1
fi
echo "$package_spec is already published with matching contents"
return
fi
if [[ "$view_output" != *"E404"* ]]; then
echo "$view_output" >&2
return 1
fi
"$repo_root/bin/npm" publish "$tarball" --access public --provenance
}
(
cd "$package_dir"
sha256sum --check SHA256SUMS
)
for package_name in "${packages[@]}"; do
publish_package "$package_name"
done
-226
View File
@@ -1,226 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Builds and publishes all @aaif npm packages:
# @aaif/goose-sdk — ACP TypeScript SDK
# @aaif/goose-binary-* — platform-specific goose CLI binaries
#
# NOTE: @aaif/goose (the terminal TUI, formerly ui/text) is DEPRECATED and no
# longer built or published. See ui/text/README.md.
#
# Linux binaries are built inside Docker containers on their native arch.
# macOS binaries are built natively (requires macOS host with Rust).
# Windows is skipped (no cross-compilation support yet).
#
# Usage:
# ./ui/scripts/publish.sh # dry run
# ./ui/scripts/publish.sh --real # publish to npmjs.org
#
# Requires:
# - Docker with buildx (linux/amd64 + linux/arm64)
# - Rust toolchain with aarch64-apple-darwin and x86_64-apple-darwin targets
# - pnpm
# - NPM_PUBLISH_TOKEN env var (or ~/.npm-publish-token file)
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
NATIVE_DIR="${REPO_ROOT}/ui/goose-binary"
SDK_DIR="${REPO_ROOT}/ui/sdk"
REGISTRY="https://registry.npmjs.org"
DOCKER_IMAGE="rust:1.92-bookworm"
DRY_RUN=true
if [[ "${1:-}" == "--real" ]]; then
DRY_RUN=false
echo "==> REAL publish to ${REGISTRY}"
else
echo "==> Dry run (pass --real to publish for real)"
fi
# Resolve NPM token
if [[ -z "${NPM_PUBLISH_TOKEN:-}" ]]; then
TOKEN_FILE="${HOME}/.npm-publish-token"
if [[ -f "${TOKEN_FILE}" ]]; then
NPM_PUBLISH_TOKEN="$(cat "${TOKEN_FILE}")"
export NPM_PUBLISH_TOKEN
echo "==> Loaded NPM_PUBLISH_TOKEN from ${TOKEN_FILE}"
else
echo "ERROR: NPM_PUBLISH_TOKEN not set and ${TOKEN_FILE} not found" >&2
exit 1
fi
fi
# ---------------------------------------------------------------------------
# Step 1: Build macOS binaries natively
# ---------------------------------------------------------------------------
build_macos() {
local platform="$1" target="$2"
local pkg_dir="${NATIVE_DIR}/goose-binary-${platform}/bin"
echo "==> Building goose for ${platform} (${target}) natively"
cargo build --release --target "${target}" --bin goose --manifest-path "${REPO_ROOT}/Cargo.toml"
mkdir -p "${pkg_dir}"
cp "${REPO_ROOT}/target/${target}/release/goose" "${pkg_dir}/goose"
chmod +x "${pkg_dir}/goose"
echo " ✅ ${pkg_dir}/goose"
}
build_macos darwin-arm64 aarch64-apple-darwin
build_macos darwin-x64 x86_64-apple-darwin
# ---------------------------------------------------------------------------
# Step 2: Build Linux binaries in Docker on native arch
# ---------------------------------------------------------------------------
DOCKER_BUILD_SCRIPT='#!/bin/bash
set -euo pipefail
apt-get update -qq
apt-get install -y -qq --no-install-recommends \
build-essential cmake pkg-config libssl-dev libdbus-1-dev \
libclang-dev protobuf-compiler libprotobuf-dev ca-certificates \
libvulkan-dev libvulkan1 glslc >/dev/null 2>&1
echo "==> Compiling goose (this takes a while)..."
cargo build --release --bin goose --features vulkan
cp /build/target/release/goose /output/goose
echo "==> Done"
'
build_linux_docker() {
local platform="$1" docker_platform="$2"
local pkg_dir="${NATIVE_DIR}/goose-binary-${platform}/bin"
echo "==> Building goose for ${platform} in Docker (${docker_platform})"
mkdir -p "${pkg_dir}"
# Create a temporary directory with only what cargo needs.
# This avoids sending multi-GB Docker contexts.
local ctx
ctx="$(mktemp -d)"
trap "rm -rf '${ctx}'" RETURN 2>/dev/null || true
# Copy Rust source
rsync -a --delete \
--exclude='target/' \
--exclude='.git/' \
--exclude='node_modules/' \
--exclude='documentation/' \
--exclude='ui/desktop/' \
--exclude='ui/goose-binary/*/bin/' \
--exclude='evals/' \
--exclude='.hermit/' \
--exclude='*.jsonl' \
--exclude='bench_results/' \
"${REPO_ROOT}/" "${ctx}/"
# Write a minimal Dockerfile into the context
cat > "${ctx}/Dockerfile.npm-build" <<'DEOF'
FROM rust:1.92-bookworm
RUN apt-get update -qq && \
apt-get install -y -qq --no-install-recommends \
build-essential cmake pkg-config libssl-dev libdbus-1-dev \
libclang-dev protobuf-compiler libprotobuf-dev ca-certificates \
libvulkan-dev libvulkan1 glslc >/dev/null 2>&1 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY . .
RUN mkdir -p /output && \
cargo build --release --bin goose --features vulkan && \
cp target/release/goose /output/goose
DEOF
# Build in Docker and extract the binary
local iid="goose-npm-build-${platform}-$$"
docker build \
--platform "${docker_platform}" \
-f "${ctx}/Dockerfile.npm-build" \
-t "${iid}" \
"${ctx}"
# Extract binary from the image
local cid
cid="$(docker create --platform "${docker_platform}" "${iid}" /bin/true)"
docker cp "${cid}:/output/goose" "${pkg_dir}/goose"
docker rm "${cid}" >/dev/null
docker rmi "${iid}" >/dev/null 2>&1 || true
rm -rf "${ctx}"
echo " ✅ ${pkg_dir}/goose"
}
build_linux_docker linux-x64 linux/amd64
build_linux_docker linux-arm64 linux/arm64
# ---------------------------------------------------------------------------
# Step 3: Verify all binaries
# ---------------------------------------------------------------------------
echo ""
echo "==> Verifying binaries"
for plat in darwin-arm64 darwin-x64 linux-arm64 linux-x64; do
bin="${NATIVE_DIR}/goose-binary-${plat}/bin/goose"
if [[ ! -f "${bin}" ]]; then
echo " ❌ MISSING: ${bin}"
exit 1
fi
size=$(stat -f%z "${bin}" 2>/dev/null || stat -c%s "${bin}" 2>/dev/null)
size_mb=$(( size / 1048576 ))
filetype=$(file -b "${bin}" | head -c 60)
echo " ✅ ${plat}: ${size_mb} MB — ${filetype}"
done
# ---------------------------------------------------------------------------
# Step 4: Build TypeScript packages
# ---------------------------------------------------------------------------
echo ""
echo "==> Building @aaif/goose-sdk"
(cd "${SDK_DIR}" && pnpm run build:ts)
# ---------------------------------------------------------------------------
# Step 5: Publish
# ---------------------------------------------------------------------------
echo ""
PUBLISH_ARGS=(--access public --no-git-checks --registry "${REGISTRY}" --tag latest)
if [[ "${DRY_RUN}" == "true" ]]; then
PUBLISH_ARGS+=(--dry-run)
fi
# Write a temporary .npmrc for authentication
NPMRC_BAK=""
UI_NPMRC="${REPO_ROOT}/ui/.npmrc"
if [[ -f "${UI_NPMRC}" ]]; then
NPMRC_BAK="$(cat "${UI_NPMRC}")"
fi
# Append auth token for npmjs.org
if ! grep -q "registry.npmjs.org/:_authToken" "${UI_NPMRC}" 2>/dev/null; then
echo "//registry.npmjs.org/:_authToken=\${NPM_PUBLISH_TOKEN}" >> "${UI_NPMRC}"
fi
cleanup_npmrc() {
if [[ -n "${NPMRC_BAK}" ]]; then
echo "${NPMRC_BAK}" > "${UI_NPMRC}"
else
# Remove the line we added
sed -i.bak '/registry.npmjs.org\/:_authToken/d' "${UI_NPMRC}" && rm -f "${UI_NPMRC}.bak"
fi
}
trap cleanup_npmrc EXIT
# Publish order matters: dependencies first
echo "==> Publishing @aaif/goose-sdk"
(cd "${REPO_ROOT}/ui" && pnpm publish "${PUBLISH_ARGS[@]}" sdk)
echo "==> Publishing native binary packages"
for plat in darwin-arm64 darwin-x64 linux-arm64 linux-x64; do
pkg="goose-binary/goose-binary-${plat}"
echo " Publishing @aaif/goose-binary-${plat}"
(cd "${REPO_ROOT}/ui" && pnpm publish "${PUBLISH_ARGS[@]}" "${pkg}")
done
echo ""
if [[ "${DRY_RUN}" == "true" ]]; then
echo "✅ Dry run complete. Pass --real to publish for real."
else
echo "✅ All packages published to ${REGISTRY}"
fi
-6
View File
@@ -1,6 +0,0 @@
dist/
node_modules/
# Generated schema files (generated from Rust during build)
acp-schema.json
acp-meta.json
-147
View File
@@ -1,147 +0,0 @@
# @aaif/goose-sdk
TypeScript client library for the Goose Agent Client Protocol (ACP).
This package provides:
- TypeScript types and Zod validators for Goose ACP extension methods
- A client for communicating with the Goose ACP server
## Installation
```bash
npm install @aaif/goose-sdk @agentclientprotocol/sdk
```
The native `goose` binaries are distributed as optional dependencies
and will be automatically installed for your platform.
## Development
### Prerequisites
- Node.js 18+
- Rust toolchain
- (Optional) Cross-compilation toolchains for building all platforms
### Building
```bash
# Build everything (schema + TypeScript)
npm run build
# Build just the schema (requires Rust)
npm run build:schema
# Build just the TypeScript
npm run build:ts
# Build native binary for current platform
npm run build:native
# Build native binaries for all platforms
npm run build:native:all
```
### Local Development with npm link
To use this package locally in another project:
```bash
# In ui/sdk
npm run build
npm link
# In the consuming project
npm link @aaif/goose-sdk
```
### Schema Generation
The TypeScript types are generated from Rust schemas defined in `crates/goose`.
The build process:
1. Builds the `generate-acp-schema` Rust binary
2. Runs it to generate `acp-schema.json` and `acp-meta.json`
3. Uses `@hey-api/openapi-ts` to generate TypeScript types and Zod validators
4. Generates a typed client in `src/generated/client.gen.ts`
To regenerate schemas after changing Rust types:
```bash
npm run build:schema
```
## Native Binary Packages
Platform-specific npm packages for the `goose` binary are located in
`ui/goose-binary/`:
| Package | Platform |
| --------------------------------- | ------------------- |
| `@aaif/goose-binary-darwin-arm64` | macOS Apple Silicon |
| `@aaif/goose-binary-darwin-x64` | macOS Intel |
| `@aaif/goose-binary-linux-arm64` | Linux ARM64 |
| `@aaif/goose-binary-linux-x64` | Linux x64 |
| `@aaif/goose-binary-win32-x64` | Windows x64 |
These are published separately from `@aaif/goose-sdk`.
### Building Native Binaries
```bash
# Build for current platform
npm run build:native
# Build for all platforms (requires cross-compilation toolchains)
npm run build:native:all
# Build for specific platform(s)
npx tsx scripts/build-native.ts darwin-arm64 linux-x64
```
## Publishing
Publishing is handled by GitHub Actions. See `.github/workflows/publish-npm.yml`.
For manual publishing:
```bash
# From repository root
./ui/scripts/publish.sh --real
```
This will:
1. Build and publish `@aaif/goose-sdk`
2. Publish all native binary packages
## Usage
Compose the ACP client with the standard ACP SDK, then use `GooseExtClient` for
typed Goose extension methods:
```typescript
import {
client as createAcpClient,
methods,
PROTOCOL_VERSION,
} from "@agentclientprotocol/sdk";
import { createWebSocketStream } from "@agentclientprotocol/sdk/experimental/ws-client";
import { GooseExtClient } from "@aaif/goose-sdk";
const app = createAcpClient({ name: "my-client" });
const stream = createWebSocketStream("ws://localhost:3000/acp");
const connection = app.connect(stream);
const goose = new GooseExtClient(connection.agent);
await connection.agent.request(methods.agent.initialize, {
protocolVersion: PROTOCOL_VERSION,
clientInfo: { name: "my-client", version: "1.0.0" },
clientCapabilities: {},
});
const providers = await goose.providersList_unstable({ providerIds: [] });
```
See the [main documentation](../../README.md) for more details.
-139
View File
@@ -1,139 +0,0 @@
#!/usr/bin/env node
/**
* Builds the goose binary for target platforms and places them
* into the corresponding npm package directories under ui/goose-binary/.
*
* Usage:
* npm run build:native # build for current platform only
* npm run build:native:all # build for all platforms
* tsx scripts/build-native.ts darwin-arm64 # build specific platform
*
* Prerequisites:
* - Rust cross-compilation toolchains installed for each target
*/
import { execSync } from "child_process";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import { mkdirSync, copyFileSync, chmodSync, existsSync } from "fs";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const ROOT = resolve(__dirname, "../../..");
const NATIVE_DIR = resolve(ROOT, "ui/goose-binary");
const RUST_TARGETS: Record<string, string> = {
"darwin-arm64": "aarch64-apple-darwin",
"darwin-x64": "x86_64-apple-darwin",
"linux-arm64": "aarch64-unknown-linux-gnu",
"linux-x64": "x86_64-unknown-linux-gnu",
"win32-x64": "x86_64-pc-windows-msvc",
};
const PLATFORM_MAP: Record<string, string> = {
"darwin-arm64": "darwin-arm64",
"darwin-x64": "darwin-x64",
"linux-arm64": "linux-arm64",
"linux-x64": "linux-x64",
"win32-x64": "win32-x64",
};
function getCurrentPlatform(): string | null {
const platform = process.platform;
const arch = process.arch;
const key = `${platform}-${arch}`;
return PLATFORM_MAP[key] || null;
}
function buildTarget(platform: string): void {
const rustTarget = RUST_TARGETS[platform];
if (!rustTarget) {
throw new Error(`Unknown platform: ${platform}`);
}
const pkgDir = resolve(NATIVE_DIR, `goose-binary-${platform}`);
const binDir = resolve(pkgDir, "bin");
console.log(`==> Building goose for ${platform} (${rustTarget})`);
try {
const featureArgs = platform.startsWith("linux-")
? " --features vulkan"
: "";
execSync(
`cargo build --release --target ${rustTarget} --bin goose${featureArgs}`,
{
cwd: ROOT,
stdio: "inherit",
},
);
} catch (err) {
console.error(`Failed to build for ${platform}`);
throw err;
}
mkdirSync(binDir, { recursive: true });
const ext = platform.startsWith("win32") ? ".exe" : "";
const binaryName = `goose${ext}`;
const srcPath = resolve(ROOT, "target", rustTarget, "release", binaryName);
const destPath = resolve(binDir, binaryName);
if (!existsSync(srcPath)) {
throw new Error(`Binary not found at ${srcPath}`);
}
copyFileSync(srcPath, destPath);
chmodSync(destPath, 0o755);
console.log(` ✅ Placed binary at ${destPath}`);
}
async function main() {
const args = process.argv.slice(2);
const buildAll = args.includes("--all");
if (buildAll) {
console.log("==> Building for all platforms");
for (const platform of Object.keys(RUST_TARGETS)) {
try {
buildTarget(platform);
} catch (err) {
console.error(`Failed to build ${platform}:`, err);
process.exit(1);
}
}
} else if (args.length > 0 && !args[0].startsWith("--")) {
// Build specific platforms
for (const platform of args) {
if (!RUST_TARGETS[platform]) {
console.error(`Unknown platform: ${platform}`);
console.error(
`Valid platforms: ${Object.keys(RUST_TARGETS).join(", ")}`,
);
process.exit(1);
}
buildTarget(platform);
}
} else {
// Build for current platform only
const currentPlatform = getCurrentPlatform();
if (!currentPlatform) {
console.error(
`Unsupported platform: ${process.platform}-${process.arch}`,
);
console.error(`Valid platforms: ${Object.keys(RUST_TARGETS).join(", ")}`);
console.error(`Use --all to build for all platforms`);
process.exit(1);
}
console.log(`==> Building for current platform: ${currentPlatform}`);
buildTarget(currentPlatform);
}
console.log("==> Done. Native packages staged in ui/goose-binary/");
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
-209
View File
@@ -1,209 +0,0 @@
#!/usr/bin/env node
// Compatibility smoke test: boot the freshly-built goose binary via `goose acp`
// and call every read-only ACP method through the freshly-built SDK. The
// generated client validates every response with Zod, so any schema drift
// between the binary and the SDK client fails this check and blocks the
// publish.
//
// Run with:
// GOOSE_BINARY=/path/to/goose node ui/sdk/scripts/check-binary-compat.mjs
//
// Or via package script:
// GOOSE_BINARY=/path/to/goose pnpm --filter @aaif/goose-sdk run check:compat
import { spawn } from "node:child_process";
import { mkdtempSync, rmSync, existsSync, statSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { Readable, Writable } from "node:stream";
const SDK_ROOT = resolve(new URL("..", import.meta.url).pathname);
const SDK_DIST = join(SDK_ROOT, "dist");
if (!existsSync(SDK_DIST)) {
console.error(
`[compat] expected built SDK at ${SDK_DIST} — run pnpm build first`,
);
process.exit(1);
}
const GOOSE_BINARY = process.env.GOOSE_BINARY;
if (!GOOSE_BINARY || !existsSync(GOOSE_BINARY)) {
console.error(
`[compat] GOOSE_BINARY must point to a built goose binary (got: ${GOOSE_BINARY ?? "<unset>"})`,
);
process.exit(1);
}
const { GooseExtClient } = await import(join(SDK_DIST, "index.js"));
const {
client: createAcpClient,
methods,
PROTOCOL_VERSION,
ndJsonStream,
} = await import("@agentclientprotocol/sdk");
// Each entry is a read-only ACP method we expect to succeed against a fresh,
// unconfigured goose install. Platform-specific skips keep hardware-sensitive
// checks from turning local environment quirks into publish blockers.
const READ_ONLY_CHECKS = [
{
name: "providersList_unstable",
call: (c) => c.goose.providersList_unstable({ providerIds: [] }),
},
{
name: "providersCatalogList_unstable",
call: (c) => c.goose.providersCatalogList_unstable({}),
},
{
name: "providersSetupCatalogList_unstable",
call: (c) => c.goose.providersSetupCatalogList_unstable({}),
},
{
name: "defaultsRead_unstable",
call: (c) => c.goose.defaultsRead_unstable({}),
},
{
name: "preferencesRead_unstable",
call: (c) => c.goose.preferencesRead_unstable({}),
},
{
name: "sourcesList_unstable",
call: (c) => c.goose.sourcesList_unstable({}),
},
{
name: "dictationConfig_unstable",
skipIf: () => process.platform === "darwin",
skipReason:
"skipped on macOS because local-inference Metal probing can panic before returning a schema response",
call: (c) => c.goose.dictationConfig_unstable({}),
},
{
name: "dictationModelsList_unstable",
call: (c) => c.goose.dictationModelsList_unstable({}),
},
{
name: "configExtensionsList_unstable",
call: (c) => c.goose.configExtensionsList_unstable({}),
},
];
const sandbox = mkdtempSync(join(tmpdir(), "goose-compat-"));
const env = {
...process.env,
HOME: sandbox,
XDG_CONFIG_HOME: join(sandbox, ".config"),
XDG_DATA_HOME: join(sandbox, ".local/share"),
XDG_STATE_HOME: join(sandbox, ".local/state"),
XDG_CACHE_HOME: join(sandbox, ".cache"),
GOOSE_CONFIG_DIR: join(sandbox, ".config/goose"),
};
console.log(`[compat] using binary: ${GOOSE_BINARY}`);
console.log(`[compat] sandbox HOME: ${sandbox}`);
console.log(`[compat] binary size: ${statSync(GOOSE_BINARY).size} bytes`);
const child = spawn(GOOSE_BINARY, ["acp"], {
stdio: ["pipe", "pipe", "inherit"],
env,
});
let exitedEarly = false;
child.on("exit", (code, signal) => {
if (!exitedEarly) {
console.error(
`[compat] goose acp exited unexpectedly (code=${code} signal=${signal})`,
);
}
});
child.on("error", (err) => {
console.error(`[compat] failed to spawn goose acp: ${err.message}`);
process.exit(1);
});
const stream = ndJsonStream(
Writable.toWeb(child.stdin),
Readable.toWeb(child.stdout),
);
const app = createAcpClient({ name: "publish-npm-compat" })
.onRequest(methods.client.session.requestPermission, async () => ({
outcome: { outcome: "cancelled" },
}))
.onNotification(methods.client.session.update, async () => {});
const connection = app.connect(stream);
const client = {
connection,
goose: new GooseExtClient(connection.agent),
};
let failed = 0;
let passed = 0;
const timeout = (ms, label) =>
new Promise((_, reject) =>
setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms),
);
try {
await Promise.race([
client.connection.agent.request(methods.agent.initialize, {
protocolVersion: PROTOCOL_VERSION,
clientInfo: { name: "publish-npm-compat", version: "0.0.0" },
clientCapabilities: {},
}),
timeout(15_000, "initialize"),
]);
console.log("[compat] ✅ initialize");
for (const check of READ_ONLY_CHECKS) {
if (check.skipIf?.()) {
console.log(`[compat] ⏭️ ${check.name} (${check.skipReason})`);
continue;
}
try {
await Promise.race([check.call(client), timeout(15_000, check.name)]);
console.log(`[compat] ✅ ${check.name}`);
passed += 1;
} catch (err) {
failed += 1;
const msg =
err instanceof Error ? (err.stack ?? err.message) : String(err);
console.error(`[compat] ❌ ${check.name}`);
console.error(indent(msg, " "));
}
}
} finally {
exitedEarly = true;
connection.close();
child.kill("SIGTERM");
try {
rmSync(sandbox, { recursive: true, force: true });
} catch {
// best-effort cleanup
}
}
if (failed > 0) {
console.error(
`\n[compat] ${failed} check(s) failed, ${passed} passed — refusing to publish.`,
);
console.error(
"[compat] This means the SDK's generated client schema doesn't match what",
);
console.error(
"[compat] the goose binary returns. Regenerate the SDK or fix the server DTO.",
);
process.exit(1);
}
console.log(`\n[compat] all ${passed} checks passed.`);
process.exit(0);
function indent(s, prefix) {
return s
.split("\n")
.map((line) => prefix + line)
.join("\n");
}
-43
View File
@@ -1,43 +0,0 @@
import { createRequire } from "node:module";
import { dirname, join } from "node:path";
const PLATFORMS: Record<string, string> = {
"darwin-arm64": "@aaif/goose-binary-darwin-arm64",
"darwin-x64": "@aaif/goose-binary-darwin-x64",
"linux-arm64": "@aaif/goose-binary-linux-arm64",
"linux-x64": "@aaif/goose-binary-linux-x64",
"win32-x64": "@aaif/goose-binary-win32-x64",
};
/**
* Resolves the path to the goose binary.
*
* Resolution order:
* 1. `GOOSE_BINARY` environment variable (explicit override)
* 2. Platform-specific `@aaif/goose-binary-*` optional dependency
*
* @throws if no binary can be found
*/
export function resolveGooseBinary(): string {
const envBinary = process.env.GOOSE_BINARY;
if (envBinary) return envBinary;
const key = `${process.platform}-${process.arch}`;
const pkg = PLATFORMS[key];
if (!pkg) {
throw new Error(
`No goose binary available for ${key}. Set GOOSE_BINARY to the path of a goose binary.`,
);
}
try {
const require = createRequire(import.meta.url);
const pkgDir = dirname(require.resolve(`${pkg}/package.json`));
const binName = process.platform === "win32" ? "goose.exe" : "goose";
return join(pkgDir, "bin", binName);
} catch {
throw new Error(
`goose binary package ${pkg} is not installed. Set GOOSE_BINARY or install the native package.`,
);
}
}