Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-glasses-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@calycode/cli": patch
---

chore: improve native host starting behaviour for more reliable process termination
5 changes: 5 additions & 0 deletions .changeset/pink-boats-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@calycode/cli": patch
---

chore: update go to 1.26
2 changes: 1 addition & 1 deletion .github/workflows/build-bootstrapper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bootstrapper/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion bootstrapper/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/calycode/xano-tools/bootstrapper

go 1.21
go 1.26
13 changes: 11 additions & 2 deletions packages/cli/src/commands/opencode/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion packages/cli/src/index-bundled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
22 changes: 21 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down