@tapi-dev/sdk 0.1.27 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +20 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2183,6 +2183,7 @@ export async function tryOpenExistingPortableStudioServer(options, manifest, fet
2183
2183
  return { opened: false, reason: "identity_mismatch" };
2184
2184
  }
2185
2185
  const launchUrl = studioLaunchUrl(record.baseUrl, options);
2186
+ await requestExistingStudioRuntimeCleanup(record.baseUrl, fetchImpl);
2186
2187
  openBrowserImpl(launchUrl);
2187
2188
  console.log(`Opened existing Tapi Studio ${record.manifestVersion || manifest.version}: ${launchUrl}`);
2188
2189
  return { opened: true, baseUrl: record.baseUrl };
@@ -2192,6 +2193,25 @@ export async function tryOpenExistingPortableStudioServer(options, manifest, fet
2192
2193
  return { opened: false, reason: formatError(error) };
2193
2194
  }
2194
2195
  }
2196
+ async function requestExistingStudioRuntimeCleanup(baseUrl, fetchImpl = fetch) {
2197
+ const url = `${baseUrl.replace(/\/+$/, "")}/api/studio/control/cleanup-runtime-session`;
2198
+ try {
2199
+ const response = await fetchWithTimeout(url, {
2200
+ method: "POST",
2201
+ headers: {
2202
+ Accept: "application/json",
2203
+ "Content-Type": "application/json",
2204
+ },
2205
+ body: JSON.stringify({ reason: "tapi_studio_reopen" }),
2206
+ }, 5_000, fetchImpl);
2207
+ if (!response.ok && response.status !== 404) {
2208
+ console.warn(`Tapi Studio runtime cleanup returned HTTP ${response.status}; opening Studio anyway.`);
2209
+ }
2210
+ }
2211
+ catch (error) {
2212
+ console.warn(`Tapi Studio runtime cleanup failed: ${formatError(error)}. Opening Studio anyway.`);
2213
+ }
2214
+ }
2195
2215
  async function ensurePortableStudioServer(options) {
2196
2216
  const event = await createCliWideEvent("tapi_cli.studio_server_ensure", {
2197
2217
  sdk_version: sdkVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapi-dev/sdk",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",