ai-world-sdk 1.5.1 → 1.5.2

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.
@@ -0,0 +1,2 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerVersionCommand(program: Command): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerVersionCommand = registerVersionCommand;
4
+ const child_process_1 = require("child_process");
5
+ const output_1 = require("../output");
6
+ const utils_1 = require("../utils");
7
+ function getLatestVersion() {
8
+ try {
9
+ return (0, child_process_1.execSync)('npm view ai-world-sdk version', {
10
+ encoding: 'utf-8',
11
+ timeout: 10000,
12
+ stdio: ['pipe', 'pipe', 'pipe'],
13
+ }).trim();
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
19
+ function compareVersions(current, latest) {
20
+ const a = current.split('.').map(Number);
21
+ const b = latest.split('.').map(Number);
22
+ for (let i = 0; i < 3; i++) {
23
+ if ((a[i] || 0) < (b[i] || 0))
24
+ return -1;
25
+ if ((a[i] || 0) > (b[i] || 0))
26
+ return 1;
27
+ }
28
+ return 0;
29
+ }
30
+ function registerVersionCommand(program) {
31
+ program
32
+ .command('version')
33
+ .description('显示版本号并检查更新')
34
+ .action(() => {
35
+ try {
36
+ const currentVersion = require('../../../package.json').version;
37
+ const latest = getLatestVersion();
38
+ const result = {
39
+ current: currentVersion,
40
+ };
41
+ if (latest) {
42
+ result.latest = latest;
43
+ const cmp = compareVersions(currentVersion, latest);
44
+ if (cmp < 0) {
45
+ result.updateAvailable = true;
46
+ result.updateCommand = 'npm install -g ai-world-sdk';
47
+ }
48
+ else {
49
+ result.updateAvailable = false;
50
+ }
51
+ }
52
+ else {
53
+ result.latest = null;
54
+ result.updateAvailable = null;
55
+ }
56
+ (0, output_1.outputJSON)(result);
57
+ }
58
+ catch (e) {
59
+ (0, utils_1.handleError)(e, 'version');
60
+ }
61
+ });
62
+ }
package/dist/cli/index.js CHANGED
@@ -14,6 +14,7 @@ program
14
14
  .option('--plugin-id <id>', '插件 ID')
15
15
  .option('--format <fmt>', '输出格式: json | table', 'json')
16
16
  .option('--debug', '启用调试输出');
17
+ const version_1 = require("./commands/version");
17
18
  const auth_1 = require("./commands/auth");
18
19
  const config_cmd_1 = require("./commands/config-cmd");
19
20
  const text_1 = require("./commands/text");
@@ -28,6 +29,7 @@ const admin_1 = require("./commands/admin");
28
29
  const stats_1 = require("./commands/stats");
29
30
  const shared_1 = require("./commands/shared");
30
31
  const chrome_1 = require("./commands/chrome");
32
+ (0, version_1.registerVersionCommand)(program);
31
33
  (0, auth_1.registerAuthCommands)(program);
32
34
  (0, config_cmd_1.registerConfigCommands)(program);
33
35
  (0, text_1.registerTextCommands)(program);
package/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
11
11
  */
12
- export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.1";
12
+ export declare const SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.2";
13
13
  /**
14
14
  * 版本兼容性错误
15
15
  */
@@ -34,8 +34,8 @@ declare class SDKConfig {
34
34
  private _authenticated;
35
35
  private _authCheckPromise;
36
36
  private _currentUser;
37
- readonly sdkSignature = "AI_WORLD_SDK_V:1.5.1";
38
- readonly sdkVersion = "1.5.1";
37
+ readonly sdkSignature = "AI_WORLD_SDK_V:1.5.2";
38
+ readonly sdkVersion = "1.5.2";
39
39
  constructor();
40
40
  /**
41
41
  * Set global base URL
package/dist/config.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.sdkConfig = exports.VersionCompatibilityError = exports.SDK_SIGNATURE = void 0;
8
8
  // SDK 版本号(构建时自动从 package.json 更新)
9
9
  // 此版本号会在运行 npm run build 时自动从 package.json 读取并更新
10
- const SDK_VERSION = "1.5.1";
10
+ const SDK_VERSION = "1.5.2";
11
11
  /**
12
12
  * SDK 特征码 - 用于在构建后的 JS 文件中识别 SDK 版本
13
13
  * 格式: AI_WORLD_SDK_V:版本号
@@ -15,7 +15,7 @@ const SDK_VERSION = "1.5.1";
15
15
  *
16
16
  * 注意: {VERSION} 占位符会在构建时被替换为实际版本号
17
17
  */
18
- exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.1";
18
+ exports.SDK_SIGNATURE = "AI_WORLD_SDK_V:1.5.2";
19
19
  /**
20
20
  * 版本兼容性错误
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-world-sdk",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "TypeScript SDK for AI World Platform - Chat Models, Image Generation, and Video Generation",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",