@fastgpt-plugin/cli 0.2.0-alpha.3 → 0.2.0

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/index.js +23 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { kebabCase } from "es-toolkit";
11
11
  import fs$1, { createWriteStream } from "node:fs";
12
12
  import os from "node:os";
13
13
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
14
- import { Box, Text, render, useInput } from "ink";
14
+ import { Box, Text, render, useApp, useInput } from "ink";
15
15
  import React from "react";
16
16
  import { createHash, randomUUID } from "node:crypto";
17
17
  import { Readable } from "stream";
@@ -526,7 +526,7 @@ var CheckCommand = class extends BaseCommand {
526
526
  //#endregion
527
527
  //#region package.json
528
528
  var name = "@fastgpt-plugin/cli";
529
- var version = "0.2.0-alpha.3";
529
+ var version = "0.2.0";
530
530
 
531
531
  //#endregion
532
532
  //#region src/constants.ts
@@ -2246,12 +2246,13 @@ async function assertPathExists(targetPath, message) {
2246
2246
  //#region src/debug/gateway.ts
2247
2247
  const GATEWAY_DUPLICATE_CONNECTION_CODE = "connection_gateway.session_already_bound";
2248
2248
  const GATEWAY_HEARTBEAT_INTERVAL_MS = 5e3;
2249
- async function connectDebugGateway({ targets, options, onLog }) {
2249
+ async function connectDebugGateway({ targets, options, onLog, onReconnect }) {
2250
2250
  if (targets.length === 0) throw new Error("Gateway debug targets cannot be empty");
2251
2251
  if (options.reconnect) return connectReconnectingDebugGateway({
2252
2252
  targets,
2253
2253
  options,
2254
- onLog
2254
+ onLog,
2255
+ onReconnect
2255
2256
  });
2256
2257
  return connectSingleDebugGateway({
2257
2258
  targets,
@@ -2259,7 +2260,7 @@ async function connectDebugGateway({ targets, options, onLog }) {
2259
2260
  onLog
2260
2261
  });
2261
2262
  }
2262
- async function connectReconnectingDebugGateway({ targets, options, onLog }) {
2263
+ async function connectReconnectingDebugGateway({ targets, options, onLog, onReconnect }) {
2263
2264
  let closed = false;
2264
2265
  let current = null;
2265
2266
  let currentSession = null;
@@ -2282,6 +2283,7 @@ async function connectReconnectingDebugGateway({ targets, options, onLog }) {
2282
2283
  options: currentOptions,
2283
2284
  onLog
2284
2285
  });
2286
+ if (currentSession) onReconnect?.(current.session);
2285
2287
  currentSession = current.session;
2286
2288
  await current.closed;
2287
2289
  } catch (error) {
@@ -2860,7 +2862,10 @@ async function runRemoteDebugSessionOnce({ entriesInput, options, commandName })
2860
2862
  const gateway = await connectDebugGateway({
2861
2863
  targets,
2862
2864
  options: gatewayOptions,
2863
- onLog: (message) => reporter.log(`[gateway] ${message}`)
2865
+ onLog: (message) => reporter.log(`[gateway] ${message}`),
2866
+ onReconnect: (session) => {
2867
+ reporter.ready(session.sessionScope.source ?? currentGatewayOptions.source ?? "-");
2868
+ }
2864
2869
  });
2865
2870
  reporter.attachClose(({ force }) => {
2866
2871
  gateway.close();
@@ -2947,7 +2952,10 @@ async function runWatchRemoteDebugSession({ entriesInput, options, commandName }
2947
2952
  const connectedGateway = await connectDebugGateway({
2948
2953
  targets: initialTargets,
2949
2954
  options: gatewayOptions,
2950
- onLog: (message) => reporter.log(`[gateway] ${message}`)
2955
+ onLog: (message) => reporter.log(`[gateway] ${message}`),
2956
+ onReconnect: (session) => {
2957
+ reporter.ready(session.sessionScope.source ?? currentGatewayOptions.source ?? "-");
2958
+ }
2951
2959
  });
2952
2960
  gateway = connectedGateway;
2953
2961
  reporter.attachClose(({ force }) => {
@@ -3223,13 +3231,13 @@ var TuiRemoteDebugReporter = class {
3223
3231
  this.closeSession?.({ force });
3224
3232
  if (force && !this.closeSession) process.exit(130);
3225
3233
  };
3226
- requestConfigureConnectionKey = () => {
3234
+ requestConfigureConnectionKey = (suspendTerminal) => {
3227
3235
  if (this.configuring) return;
3228
3236
  if (!this.configureConnectionKey) {
3229
3237
  this.log("connection key 配置入口尚未就绪。");
3230
3238
  return;
3231
3239
  }
3232
- this.runConfigureConnectionKey();
3240
+ this.runConfigureConnectionKey(suspendTerminal);
3233
3241
  };
3234
3242
  constructor(summary) {
3235
3243
  this.summary = summary;
@@ -3286,15 +3294,16 @@ var TuiRemoteDebugReporter = class {
3286
3294
  instance.unmount();
3287
3295
  await Promise.race([instance.waitUntilExit(), setTimeout$1(50)]).catch(() => void 0);
3288
3296
  }
3289
- async runConfigureConnectionKey() {
3297
+ async runConfigureConnectionKey(suspendTerminal) {
3290
3298
  if (!this.configureConnectionKey) return;
3291
3299
  const previousStatus = this.status;
3292
3300
  this.configuring = true;
3293
3301
  this.status = "configuring";
3294
3302
  this.rerender();
3295
3303
  try {
3296
- await this.unmount();
3297
- await this.configureConnectionKey();
3304
+ await suspendTerminal(async () => {
3305
+ await this.configureConnectionKey?.();
3306
+ });
3298
3307
  this.status = "connecting";
3299
3308
  this.log("已更新 connection key,正在重新连接 Connection Gateway。");
3300
3309
  } catch (error) {
@@ -3320,12 +3329,13 @@ var TuiRemoteDebugReporter = class {
3320
3329
  }
3321
3330
  };
3322
3331
  function RemoteDebugInkApp({ summary, status, source, logs, onClose, onConfigureConnectionKey }) {
3332
+ const { suspendTerminal } = useApp();
3323
3333
  useInput((inputValue, key) => {
3324
3334
  if (key.ctrl && inputValue === "c") {
3325
3335
  onClose();
3326
3336
  return;
3327
3337
  }
3328
- if (inputValue === "c") onConfigureConnectionKey();
3338
+ if (inputValue === "c") onConfigureConnectionKey(suspendTerminal);
3329
3339
  });
3330
3340
  const statusMeta = getTuiStatusMeta(status);
3331
3341
  const sourceLabel = source === "-" ? "waiting for bind" : source;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastgpt-plugin/cli",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "publishConfig": {