ms-types 0.8.9 → 0.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-types",
3
- "version": "0.8.9",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/types/global.d.ts CHANGED
@@ -161,6 +161,24 @@ declare function setAgentFastMode(enabled: boolean): boolean;
161
161
  */
162
162
  declare function getAgentFastMode(): boolean;
163
163
 
164
+ /**
165
+ * 设置脚本 CPU 自动限流
166
+ * @param enabled 是否开启自动限流
167
+ * @returns 实际是否开启自动限流
168
+ * @description 默认开启。开启后,脚本 API 在 CPU 占用接近系统杀进程阈值时会轻微让步,降低被系统终止的风险
169
+ * @example
170
+ * const enabled = setCpuAutoThrottle(true);
171
+ */
172
+ declare function setCpuAutoThrottle(enabled: boolean): boolean;
173
+
174
+ /**
175
+ * 获取脚本 CPU 自动限流当前状态,默认开启
176
+ * @returns 当前是否开启自动限流
177
+ * @example
178
+ * const enabled = getCpuAutoThrottle();
179
+ */
180
+ declare function getCpuAutoThrottle(): boolean;
181
+
164
182
  /**
165
183
  * 打印调试日志 - 输出调试级别的日志
166
184
  * 用于详细的程序执行信息、变量值和状态信息、函数调用跟踪
package/types/system.d.ts CHANGED
@@ -161,15 +161,16 @@ declare namespace system {
161
161
  function notify(msg: string, title?: string, id?: string): void;
162
162
  /**
163
163
  * 获取内存使用信息
164
- * @returns 内存使用信息,包含已使用内存、可用内存、总内存和使用率(单位:MB)
164
+ * @returns 内存使用信息,包含应用占用、系统可用/总量、系统已用和系统占用率(单位:MB)
165
165
  * @example
166
166
  * const memInfo = system.getMemoryInfo()
167
- * logi(`已使用: ${memInfo.used}MB, 可用: ${memInfo.available}MB, 总计: ${memInfo.total}MB, 使用率: ${memInfo.usagePercentage}%`)
167
+ * logi(`应用: ${memInfo.used}MB, 系统: ${memInfo.systemUsed}/${memInfo.total}MB, 占用: ${memInfo.usagePercentage}%`)
168
168
  */
169
169
  function getMemoryInfo(): {
170
170
  used: number;
171
171
  available: number;
172
172
  total: number;
173
+ systemUsed: number;
173
174
  usagePercentage: number;
174
175
  };
175
176
  /**
@@ -196,6 +197,22 @@ declare namespace system {
196
197
  * logi(`系统总内存: ${totalMemory}MB`)
197
198
  */
198
199
  function getTotalMemory(): number;
200
+ /**
201
+ * 获取系统已用内存
202
+ * @returns 系统已用内存大小(单位:MB,物理内存总量减去可用内存)
203
+ * @example
204
+ * const systemUsed = system.getSystemUsedMemory()
205
+ * logi(`系统已用内存: ${systemUsed}MB`)
206
+ */
207
+ function getSystemUsedMemory(): number;
208
+ /**
209
+ * 获取 CPU 使用率
210
+ * @returns 当前应用 CPU 使用率(百分比)
211
+ * @example
212
+ * const cpuUsage = system.getCpuUsage()
213
+ * logi(`CPU 使用率: ${cpuUsage}%`)
214
+ */
215
+ function getCpuUsage(): number;
199
216
 
200
217
  /**
201
218
  * 启动 Agent 服务
@@ -157,6 +157,24 @@ declare function $设置Agent快速模式(是否开启: 布尔值): 布尔值;
157
157
  */
158
158
  declare function $获取Agent快速模式(): 布尔值;
159
159
 
160
+ /**
161
+ * 设置脚本 CPU 自动限流
162
+ * @param 是否开启 是否开启自动限流
163
+ * @returns 实际是否开启自动限流
164
+ * @description 默认开启。开启后,脚本 API 在 CPU 占用接近系统杀进程阈值时会轻微让步,降低被系统终止的风险
165
+ * @example
166
+ * const 是否开启 = $设置CPU自动限流(true);
167
+ */
168
+ declare function $设置CPU自动限流(是否开启: 布尔值): 布尔值;
169
+
170
+ /**
171
+ * 获取脚本 CPU 自动限流当前状态,默认开启
172
+ * @returns 当前是否开启自动限流
173
+ * @example
174
+ * const 是否开启 = $获取CPU自动限流();
175
+ */
176
+ declare function $获取CPU自动限流(): 布尔值;
177
+
160
178
  /**
161
179
  * 打印调试日志 - 输出调试级别的日志
162
180
  * 用于详细的程序执行信息、变量值和状态信息、函数调用跟踪
@@ -161,15 +161,16 @@ declare namespace $系统 {
161
161
  function 发送系统通知(消息: 字符串, 标题?: 字符串, 通知ID?: 字符串): 无返回值;
162
162
  /**
163
163
  * 获取内存使用信息
164
- * @returns 内存使用信息,包含已使用内存、可用内存、总内存和使用率(单位:MB)
164
+ * @returns 内存使用信息,包含应用占用、系统可用/总量、系统已用和系统占用率(单位:MB)
165
165
  * @example
166
166
  * const 内存信息 = $系统.获取内存使用信息()
167
- * $打印信息日志(`已使用: ${内存信息.used}MB, 可用: ${内存信息.available}MB, 总计: ${内存信息.total}MB, 使用率: ${内存信息.usagePercentage}%`)
167
+ * $打印信息日志(`应用: ${内存信息.used}MB, 系统: ${内存信息.systemUsed}/${内存信息.total}MB, 占用: ${内存信息.usagePercentage}%`)
168
168
  */
169
169
  function 获取内存使用信息(): {
170
170
  used: 数字;
171
171
  available: 数字;
172
172
  total: 数字;
173
+ systemUsed: 数字;
173
174
  usagePercentage: 数字;
174
175
  };
175
176
  /**
@@ -196,6 +197,22 @@ declare namespace $系统 {
196
197
  * $打印信息日志(`系统总内存: ${总内存}MB`)
197
198
  */
198
199
  function 获取系统总内存(): 数字;
200
+ /**
201
+ * 获取系统已用内存
202
+ * @returns 系统已用内存大小(单位:MB,物理内存总量减去可用内存)
203
+ * @example
204
+ * const 系统已用内存 = $系统.获取系统已用内存()
205
+ * $打印信息日志(`系统已用内存: ${系统已用内存}MB`)
206
+ */
207
+ function 获取系统已用内存(): 数字;
208
+ /**
209
+ * 获取 CPU 使用率
210
+ * @returns 当前应用 CPU 使用率(百分比)
211
+ * @example
212
+ * const CPU使用率 = $系统.获取CPU使用率()
213
+ * $打印信息日志(`CPU 使用率: ${CPU使用率}%`)
214
+ */
215
+ function 获取CPU使用率(): 数字;
199
216
 
200
217
  /**
201
218
  * 启动 Agent 服务