diff --git a/.changeset/grumpy-glasses-grow.md b/.changeset/grumpy-glasses-grow.md new file mode 100644 index 00000000..39881ae0 --- /dev/null +++ b/.changeset/grumpy-glasses-grow.md @@ -0,0 +1,5 @@ +--- +"@calycode/cli": patch +--- + +chore: improve native host starting behaviour for more reliable process termination diff --git a/.changeset/pink-boats-grow.md b/.changeset/pink-boats-grow.md new file mode 100644 index 00000000..6de4a327 --- /dev/null +++ b/.changeset/pink-boats-grow.md @@ -0,0 +1,5 @@ +--- +"@calycode/cli": patch +--- + +chore: update go to 1.26 diff --git a/.github/workflows/build-bootstrapper.yml b/.github/workflows/build-bootstrapper.yml index 4c9fed52..6bac58b7 100644 --- a/.github/workflows/build-bootstrapper.yml +++ b/.github/workflows/build-bootstrapper.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Go uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff with: - go-version: "1.21" + go-version: "1.26.x" - name: Build Windows x64 working-directory: bootstrapper diff --git a/bootstrapper/Makefile b/bootstrapper/Makefile index 231b11a7..dccdac81 100644 --- a/bootstrapper/Makefile +++ b/bootstrapper/Makefile @@ -1,7 +1,7 @@ # CalyCode Bootstrapper Build # Produces standalone installers for Windows (exe) and macOS (macho binary). # -# Prerequisites: Go 1.21+ +# Prerequisites: Go 1.26+ # # Usage: # make all Build all targets diff --git a/bootstrapper/go.mod b/bootstrapper/go.mod index c4854a61..0b0e7c75 100644 --- a/bootstrapper/go.mod +++ b/bootstrapper/go.mod @@ -1,3 +1,3 @@ module github.com/calycode/xano-tools/bootstrapper -go 1.21 +go 1.26 diff --git a/packages/cli/src/commands/opencode/implementation.ts b/packages/cli/src/commands/opencode/implementation.ts index 431309de..69db3358 100644 --- a/packages/cli/src/commands/opencode/implementation.ts +++ b/packages/cli/src/commands/opencode/implementation.ts @@ -1031,8 +1031,17 @@ async function startNativeHost() { // Check if already running via fetch try { await fetch(serverUrl); - logger.log('Server already active on url', { serverUrl }); - sendMessage({ status: 'running', url: serverUrl, message: 'Server already active' }); + logger.log('Server already active on url; triggering restart to reconcile CORS/config drift', { + serverUrl, + extraOrigins, + requestedOcVersion, + }); + sendMessage({ + status: 'starting', + url: serverUrl, + message: 'Server already active; restarting to reconcile requested origins/config...', + }); + await restartServer(port, extraOrigins, requestedOcVersion); return; } catch (e) { // Not running, proceed diff --git a/packages/cli/src/index-bundled.ts b/packages/cli/src/index-bundled.ts index e1dd4ce2..d3e9c621 100644 --- a/packages/cli/src/index-bundled.ts +++ b/packages/cli/src/index-bundled.ts @@ -30,6 +30,22 @@ function escapeAppleScript(str: string): string { // If run with no arguments (double click), it triggers the init flow. // If run with arguments (CLI usage), it passes through to the standard program. +function isNativeHostLaunchArgs(extraArgs: string[]): boolean { + if (extraArgs.length === 0) { + return true; + } + + if (extraArgs.length === 2 && extraArgs[0] === '--oc-version' && !!extraArgs[1]) { + return true; + } + + if (extraArgs.length === 1 && extraArgs[0].startsWith('--oc-version=')) { + return true; + } + + return false; +} + (async () => { const isBundled = isSea(); const args = process.argv; @@ -40,8 +56,14 @@ function escapeAppleScript(str: string): string { // and manual "opencode native-host" invocations (Windows wrapper) const chromeExtensionArg = args.find((arg) => arg.startsWith('chrome-extension://')); const commandIndex = Math.max(args.lastIndexOf('opencode'), args.lastIndexOf('oc')); + const nativeHostExtraArgs = + commandIndex >= 0 && args[commandIndex + 1] === 'native-host' + ? args.slice(commandIndex + 2) + : []; const isNativeHostCommand = - commandIndex >= 0 && args[commandIndex + 1] === 'native-host' && commandIndex + 2 >= args.length; + commandIndex >= 0 && + args[commandIndex + 1] === 'native-host' && + isNativeHostLaunchArgs(nativeHostExtraArgs); if (chromeExtensionArg || isNativeHostCommand) { // We are running as a Native Host diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index c533d0df..5df1f949 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -8,12 +8,32 @@ import { exitIfLegacyXanoInvocation } from './utils/legacy-command-guard'; const args = process.argv; exitIfLegacyXanoInvocation(args); +function isNativeHostLaunchArgs(extraArgs: string[]): boolean { + if (extraArgs.length === 0) { + return true; + } + + if (extraArgs.length === 2 && extraArgs[0] === '--oc-version' && !!extraArgs[1]) { + return true; + } + + if (extraArgs.length === 1 && extraArgs[0].startsWith('--oc-version=')) { + return true; + } + + return false; +} + const chromeExtensionArg = args.find((arg) => arg.startsWith('chrome-extension://')); const commandIndex = Math.max(args.lastIndexOf('opencode'), args.lastIndexOf('oc')); +const nativeHostExtraArgs = + commandIndex >= 0 && args[commandIndex + 1] === 'native-host' + ? args.slice(commandIndex + 2) + : []; const isDirectNativeHostInvocation = commandIndex >= 0 && args[commandIndex + 1] === 'native-host' && - commandIndex + 2 >= args.length; + isNativeHostLaunchArgs(nativeHostExtraArgs); if (chromeExtensionArg || isDirectNativeHostInvocation) { startNativeHost();