@eddyskywalker/dsh-chatgpt-subscription 0.91.0 → 0.92.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/lib/codemode.js CHANGED
@@ -3269,26 +3269,35 @@ function isRealPtcRuntimeInstance(runtime) {
3269
3269
  }
3270
3270
  return false;
3271
3271
  }
3272
+ /** 安全读取可能是 Cordis Context 代理对象上的属性:未声明 inject 的服务属性优先走 `get()` 并吞掉反射异常。 */
3273
+ function safeReadProp(target, key) {
3274
+ if (typeof target !== "object" || target === null) return void 0;
3275
+ const record = target;
3276
+ if (typeof record["get"] === "function" && key !== "root" && key !== "ctx") try {
3277
+ const viaGet = record["get"].call(target, key);
3278
+ if (viaGet !== void 0) return viaGet;
3279
+ } catch {}
3280
+ try {
3281
+ return record[key];
3282
+ } catch {
3283
+ return;
3284
+ }
3285
+ }
3272
3286
  /** 从 Cordis ctx / loader 上尽量收集宿主运行根目录。 */
3273
3287
  function contextBaseDirs(source, roots) {
3274
3288
  if (typeof source !== "object" || source === null) return;
3275
- const record = source;
3276
3289
  const addDir = (value) => {
3277
3290
  if (typeof value === "string" && value.trim().length > 0) roots.add(value.trim());
3278
3291
  };
3279
- addDir(record["baseDir"]);
3280
- const root = record["root"];
3292
+ addDir(safeReadProp(source, "baseDir"));
3293
+ const root = safeReadProp(source, "root");
3281
3294
  if (typeof root === "object" && root !== null && root !== source) {
3282
- addDir(root["baseDir"]);
3283
- const rootLoader = root["loader"];
3284
- if (typeof rootLoader === "object" && rootLoader !== null) addDir(rootLoader["baseDir"]);
3285
- }
3286
- const loader = record["loader"];
3287
- if (typeof loader === "object" && loader !== null) addDir(loader["baseDir"]);
3288
- if (typeof record["get"] === "function") try {
3289
- const loaderService = record["get"].call(source, "loader");
3290
- if (typeof loaderService === "object" && loaderService !== null) addDir(loaderService["baseDir"]);
3291
- } catch {}
3295
+ addDir(safeReadProp(root, "baseDir"));
3296
+ const rootLoader = safeReadProp(root, "loader");
3297
+ if (typeof rootLoader === "object" && rootLoader !== null) addDir(safeReadProp(rootLoader, "baseDir"));
3298
+ }
3299
+ const loader = safeReadProp(source, "loader");
3300
+ if (typeof loader === "object" && loader !== null) addDir(safeReadProp(loader, "baseDir"));
3292
3301
  }
3293
3302
  /** 从给定根目录解析 `@deepseek-ai/dsh-ptc-runtime` 的真实入口 file:// URL(经过 realpathSync 归一化)。 */
3294
3303
  function resolvePtcRuntimeModuleUrl(rootDir) {
@@ -3350,7 +3359,7 @@ async function resolveHostPtcRuntimeClasses(runtime, ctx, extraRoots) {
3350
3359
  for (const dir of extraRoots) if (typeof dir === "string" && dir.trim().length > 0) roots.add(dir.trim());
3351
3360
  }
3352
3361
  contextBaseDirs(ctx, roots);
3353
- contextBaseDirs(rawRuntime["ctx"], roots);
3362
+ contextBaseDirs(safeReadProp(rawRuntime, "ctx"), roots);
3354
3363
  for (const dir of candidatePackageRoots()) roots.add(dir);
3355
3364
  const seenUrls = /* @__PURE__ */ new Set();
3356
3365
  const tryModule = async (specifier) => {