@adep/cli 0.5.8 → 0.5.9

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 (3) hide show
  1. package/dist/index.js +288 -39
  2. package/dist/vite.js +33 -1
  3. package/package.json +8 -5
package/dist/index.js CHANGED
@@ -906,10 +906,15 @@ var init_capability_keys = __esm({
906
906
  subscriptionNotFound: "REALTIME_SUBSCRIPTION_NOT_FOUND",
907
907
  tooManySubscriptions: "REALTIME_TOO_MANY_SUBSCRIPTIONS",
908
908
  /** 线上独有:订阅授权策略(RT-002 `SubscriptionPolicy`)拒绝该 channel。 */
909
- channelDenied: "REALTIME_CHANNEL_DENIED"
909
+ channelDenied: "REALTIME_CHANNEL_DENIED",
910
+ /** 线上独有(RT-008):签票入参不合法(subject 缺失 / channels 非字符串数组 / TTL 越界)。 */
911
+ invalidArg: "REALTIME_INVALID_ARG",
912
+ /** 线上独有(RT-008):函数级签票超频(按项目固定窗口限流)。 */
913
+ ticketRateLimited: "REALTIME_TICKET_RATE_LIMITED"
910
914
  };
911
915
  REALTIME_CAPABILITY_METHODS = [
912
916
  "publish",
917
+ "issueTicket",
913
918
  "subscribe",
914
919
  "receive",
915
920
  "unsubscribe"
@@ -3885,6 +3890,33 @@ function createSimRealtimeCapability() {
3885
3890
  const [channel, data] = args;
3886
3891
  return sim.publish(channel, data);
3887
3892
  }
3893
+ case "issueTicket": {
3894
+ const [input2] = args;
3895
+ if (typeof input2 !== "object" || input2 === null) {
3896
+ throw realtimeError(
3897
+ REALTIME_CODES.invalidArg,
3898
+ "\u7B7E\u53D1\u7968\u636E\u9700\u8981\u4E00\u4E2A\u8F93\u5165\u5BF9\u8C61 { subject, channels, ttlSeconds? }"
3899
+ );
3900
+ }
3901
+ const subject = input2.subject;
3902
+ const channels = input2.channels;
3903
+ if (typeof subject !== "string" || subject.length === 0) {
3904
+ throw realtimeError(
3905
+ REALTIME_CODES.invalidArg,
3906
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26 subject\uFF08\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6\uFF09"
3907
+ );
3908
+ }
3909
+ if (!Array.isArray(channels) || channels.length === 0 || channels.some((c) => typeof c !== "string")) {
3910
+ throw realtimeError(
3911
+ REALTIME_CODES.invalidArg,
3912
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26\u975E\u7A7A channels \u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5E94\u7528\u7528\u6237\u7684\u7CBE\u786E\u8BA2\u9605\u767D\u540D\u5355\uFF09"
3913
+ );
3914
+ }
3915
+ throw realtimeError(
3916
+ REALTIME_CODES.unsupportedArg,
3917
+ "\u672C\u5730 sim \u4E0D\u7B7E\u53D1\u5B9E\u65F6\u7968\u636E\uFF08\u65E0 WS \u63E1\u624B\u9762\uFF0C\u7968\u636E\u65E0\u5904\u53EF\u7528\uFF09\uFF1B\u8BF7\u5728\u7EBF\u4E0A\u7684\u51FD\u6570\u6267\u884C\u9762\u4F7F\u7528 cloud.realtime.issueTicket"
3918
+ );
3919
+ }
3888
3920
  case "subscribe": {
3889
3921
  if (buffers.size >= MAX_SUBSCRIPTIONS) {
3890
3922
  throw realtimeError(
@@ -10200,7 +10232,7 @@ import { basename as basename5, dirname as dirname12, extname as extname2, join
10200
10232
  function envQuery2(options) {
10201
10233
  return options.environment === void 0 ? "" : `?environment=${options.environment}`;
10202
10234
  }
10203
- async function open4(paths, options) {
10235
+ async function open5(paths, options) {
10204
10236
  const client = await createClient(paths);
10205
10237
  const project2 = await resolveSlug(resolve15(options.cwd), options.slug);
10206
10238
  return { client, project: project2 };
@@ -10234,7 +10266,7 @@ function contentTypeOf(path) {
10234
10266
  return map2[extname2(path).toLowerCase()] ?? "application/octet-stream";
10235
10267
  }
10236
10268
  async function storageUpload(paths, options) {
10237
- const { client, project: project2 } = await open4(paths, options);
10269
+ const { client, project: project2 } = await open5(paths, options);
10238
10270
  const local = resolve15(options.file);
10239
10271
  const info = await stat14(local).catch(() => null);
10240
10272
  if (info === null || !info.isFile()) {
@@ -10260,7 +10292,7 @@ async function storageUpload(paths, options) {
10260
10292
  return { ...body.file, ...body.signedUrl === void 0 ? {} : { signedUrl: body.signedUrl } };
10261
10293
  }
10262
10294
  async function storageList(paths, options) {
10263
- const { client, project: project2 } = await open4(paths, options);
10295
+ const { client, project: project2 } = await open5(paths, options);
10264
10296
  const search = new URLSearchParams();
10265
10297
  if (options.prefix !== void 0) search.set("prefix", options.prefix);
10266
10298
  if (options.environment !== void 0) search.set("environment", options.environment);
@@ -10284,7 +10316,7 @@ async function resolveDownloadUrl(client, project2, path, environment) {
10284
10316
  return url2;
10285
10317
  }
10286
10318
  async function storageDownload(paths, options) {
10287
- const { client, project: project2 } = await open4(paths, options);
10319
+ const { client, project: project2 } = await open5(paths, options);
10288
10320
  const url2 = await resolveDownloadUrl(client, project2, options.path, options.environment);
10289
10321
  const response = await client.download(url2, "STORAGE_DOWNLOAD_FAILED");
10290
10322
  const bytes = Buffer.from(await response.arrayBuffer());
@@ -10294,7 +10326,7 @@ async function storageDownload(paths, options) {
10294
10326
  return { path: options.path, output: output2, size: bytes.length };
10295
10327
  }
10296
10328
  async function storageRemove(paths, options) {
10297
- const { client, project: project2 } = await open4(paths, options);
10329
+ const { client, project: project2 } = await open5(paths, options);
10298
10330
  return client.request(
10299
10331
  `/api/v1/projects/${project2}/files/${encodeURIComponent(options.path)}${envQuery2(options)}`,
10300
10332
  { method: "DELETE" }
@@ -10319,13 +10351,13 @@ __export(hosting_exports, {
10319
10351
  import { readdir as readdir11, readFile as readFile25, stat as stat15 } from "node:fs/promises";
10320
10352
  import { spawnSync } from "node:child_process";
10321
10353
  import { dirname as dirname13, join as join33, relative as relative7, resolve as resolve16, sep as sep3 } from "node:path";
10322
- async function open5(paths, options) {
10354
+ async function open6(paths, options) {
10323
10355
  const client = await createClient(paths);
10324
10356
  const project2 = await resolveSlug(resolve16(options.cwd), options.slug);
10325
10357
  return { client, project: project2 };
10326
10358
  }
10327
10359
  async function hostingInfo(paths, options) {
10328
- const { client, project: project2 } = await open5(paths, options);
10360
+ const { client, project: project2 } = await open6(paths, options);
10329
10361
  const body = await client.request(`/api/v1/projects/${project2}/hosting`);
10330
10362
  return {
10331
10363
  config: body.config,
@@ -10357,7 +10389,7 @@ async function collectSiteFiles(dir) {
10357
10389
  return files;
10358
10390
  }
10359
10391
  async function hostingDeploy(paths, options) {
10360
- const { client, project: project2 } = await open5(paths, options);
10392
+ const { client, project: project2 } = await open6(paths, options);
10361
10393
  const log = options.log ?? ((line) => process.stdout.write(`${line}
10362
10394
  `));
10363
10395
  if (options.build !== void 0) {
@@ -10436,7 +10468,7 @@ async function hostingDeploy(paths, options) {
10436
10468
  return { config: config2.config, siteUrl: info.siteUrl, uploaded, reused, identical, builtAt };
10437
10469
  }
10438
10470
  async function hostingPull(paths, options) {
10439
- const { client } = await open5(paths, options);
10471
+ const { client } = await open6(paths, options);
10440
10472
  const log = options.log ?? ((line) => process.stdout.write(`${line}
10441
10473
  `));
10442
10474
  const info = await hostingInfo(paths, options);
@@ -10459,7 +10491,7 @@ async function hostingPull(paths, options) {
10459
10491
  return { siteUrl: info.siteUrl, outputDir, files };
10460
10492
  }
10461
10493
  async function hostingConfig(paths, options) {
10462
- const { client, project: project2 } = await open5(paths, options);
10494
+ const { client, project: project2 } = await open6(paths, options);
10463
10495
  const body = {};
10464
10496
  if (options.enabled !== void 0) body["enabled"] = options.enabled;
10465
10497
  if (options.spa !== void 0) body["spaMode"] = options.spa;
@@ -10917,8 +10949,8 @@ var init_release_check = __esm({
10917
10949
  });
10918
10950
 
10919
10951
  // packages/cli/src/sandbox-scan.ts
10920
- import { readdir as readdir13, readFile as readFile31 } from "node:fs/promises";
10921
- import { join as join38, relative as relative9, sep as sep5 } from "node:path";
10952
+ import { readdir as readdir13, readFile as readFile32 } from "node:fs/promises";
10953
+ import { join as join39, relative as relative9, sep as sep5 } from "node:path";
10922
10954
  function extractSpecifiers(line) {
10923
10955
  const out = [];
10924
10956
  const patterns = [
@@ -10962,7 +10994,7 @@ function classify(specifier) {
10962
10994
  return null;
10963
10995
  }
10964
10996
  async function scanFunctionSources(rootDir, functionsDir) {
10965
- const base = join38(rootDir, functionsDir);
10997
+ const base = join39(rootDir, functionsDir);
10966
10998
  const findings = [];
10967
10999
  async function walk(current) {
10968
11000
  let entries;
@@ -10972,7 +11004,7 @@ async function scanFunctionSources(rootDir, functionsDir) {
10972
11004
  return;
10973
11005
  }
10974
11006
  for (const entry of entries) {
10975
- const abs = join38(current, entry.name);
11007
+ const abs = join39(current, entry.name);
10976
11008
  if (entry.isDirectory()) {
10977
11009
  if (SKIP_DIRS.has(entry.name)) continue;
10978
11010
  await walk(abs);
@@ -10983,7 +11015,7 @@ async function scanFunctionSources(rootDir, functionsDir) {
10983
11015
  if (entry.name.endsWith(".d.ts")) continue;
10984
11016
  let content;
10985
11017
  try {
10986
- content = await readFile31(abs, "utf8");
11018
+ content = await readFile32(abs, "utf8");
10987
11019
  } catch {
10988
11020
  continue;
10989
11021
  }
@@ -11112,7 +11144,7 @@ var init_version = __esm({
11112
11144
  manifest = requireJson("../package.json");
11113
11145
  CLI_VERSION = typeof manifest.version === "string" && manifest.version.length > 0 ? manifest.version : "0.0.0";
11114
11146
  RELEASE_TASKS = Array.isArray(manifest.adep?.releaseTasks) ? manifest.adep.releaseTasks.filter((item) => typeof item === "string") : [];
11115
- BUILD_COMMIT = "08ca68b9".trim() !== "" ? "08ca68b9".trim() : null;
11147
+ BUILD_COMMIT = "89404b79".trim() !== "" ? "89404b79".trim() : null;
11116
11148
  }
11117
11149
  });
11118
11150
 
@@ -11126,9 +11158,9 @@ __export(doctor_exports, {
11126
11158
  runDoctor: () => runDoctor
11127
11159
  });
11128
11160
  import { createRequire as createRequire3 } from "node:module";
11129
- import { readFile as readFile32, stat as stat18 } from "node:fs/promises";
11161
+ import { readFile as readFile33, stat as stat18 } from "node:fs/promises";
11130
11162
  import { homedir } from "node:os";
11131
- import { join as join39 } from "node:path";
11163
+ import { join as join40 } from "node:path";
11132
11164
  import { parse as parseYaml } from "yaml";
11133
11165
  function minimumReleaseAgeMinutes(raw) {
11134
11166
  const text = raw.trim();
@@ -11152,7 +11184,7 @@ function hitFromEnvironment(env) {
11152
11184
  }
11153
11185
  async function readTextOrNull(file2) {
11154
11186
  try {
11155
- return await readFile32(file2, "utf8");
11187
+ return await readFile33(file2, "utf8");
11156
11188
  } catch {
11157
11189
  return null;
11158
11190
  }
@@ -11193,8 +11225,8 @@ async function hitFromNpmrc(file2, label) {
11193
11225
  }
11194
11226
  async function detectSupplyChainPolicy(cwd, env = process.env, home = homedir()) {
11195
11227
  const xdg = env["XDG_CONFIG_HOME"]?.trim();
11196
- const globalConfig2 = xdg !== void 0 && xdg !== "" ? join39(xdg, "pnpm", "config.yaml") : join39(home, ".config", "pnpm", "config.yaml");
11197
- const hit = hitFromEnvironment(env) ?? await hitFromYamlConfig(join39(cwd, "pnpm-workspace.yaml"), "pnpm-workspace.yaml") ?? await hitFromNpmrc(join39(cwd, ".npmrc"), ".npmrc") ?? await hitFromYamlConfig(globalConfig2, "~/.config/pnpm/config.yaml") ?? await hitFromNpmrc(join39(home, ".npmrc"), "~/.npmrc");
11228
+ const globalConfig2 = xdg !== void 0 && xdg !== "" ? join40(xdg, "pnpm", "config.yaml") : join40(home, ".config", "pnpm", "config.yaml");
11229
+ const hit = hitFromEnvironment(env) ?? await hitFromYamlConfig(join40(cwd, "pnpm-workspace.yaml"), "pnpm-workspace.yaml") ?? await hitFromNpmrc(join40(cwd, ".npmrc"), ".npmrc") ?? await hitFromYamlConfig(globalConfig2, "~/.config/pnpm/config.yaml") ?? await hitFromNpmrc(join40(home, ".npmrc"), "~/.npmrc");
11198
11230
  return {
11199
11231
  minimumReleaseAge: hit === null ? { minutes: null, source: null, raw: null, warning: null } : { minutes: hit.minutes, source: hit.source, raw: hit.raw, warning: hit.warning }
11200
11232
  };
@@ -11229,7 +11261,7 @@ async function credentialMode(file2) {
11229
11261
  async function runDoctor(paths, cwd = process.cwd()) {
11230
11262
  const credentials = await loadCredentials(paths);
11231
11263
  const server = credentials?.server ?? resolveServer();
11232
- const credentialsFile = credentials !== null ? join39(paths.credentialsDir, `${slotNameFor(credentials.server)}.json`) : paths.credentialsFile;
11264
+ const credentialsFile = credentials !== null ? join40(paths.credentialsDir, `${slotNameFor(credentials.server)}.json`) : paths.credentialsFile;
11233
11265
  const mode = await credentialMode(credentialsFile);
11234
11266
  const offline = await isOffline();
11235
11267
  const health = await probeServer(server);
@@ -11361,7 +11393,7 @@ function pickBreakingNotices(parsed, status, version2, newerVersions) {
11361
11393
  }
11362
11394
  async function readOwnChangelog() {
11363
11395
  try {
11364
- return await readFile32(createRequire3(import.meta.url).resolve("../CHANGELOG.md"), "utf8");
11396
+ return await readFile33(createRequire3(import.meta.url).resolve("../CHANGELOG.md"), "utf8");
11365
11397
  } catch {
11366
11398
  return null;
11367
11399
  }
@@ -14491,6 +14523,7 @@ var ADEP_ENV_DTS = `/**
14491
14523
  * \u5951\u7EA6\u552F\u4E00\u771F\u76F8\u6E90 = packages/types/src/\uFF1B\u540C\u6E90\u4EA7\u7269\u8FD8\u6709 Web IDE \u955C\u50CF
14492
14524
  * \uFF08app/components/ide/adep.d.ts\uFF0C\u540C\u4E00\u4EFD\u751F\u6210\u5668\u8F93\u51FA + \u6D4F\u89C8\u5668\u6D4B\u8BD5\u5168\u5C40\uFF09\u3002
14493
14525
  * \u6F02\u79FB\u95E8 = scripts/lib/__tests__/contract-mirrors.test.ts\u3002
14526
+ * \u955C\u50CF\u7248\u672C = @adep/types@0.4.6\uFF08generate:contracts \u751F\u6210\u65F6\u6233\uFF09
14494
14527
  */
14495
14528
 
14496
14529
  /* ---------- HTTP \u89E6\u53D1\u4E0A\u4E0B\u6587\uFF08FunctionContext \u955C\u50CF\uFF09 ---------- */
@@ -14813,6 +14846,29 @@ interface AdepCloudRealtimeReceipt {
14813
14846
  delivered: number
14814
14847
  }
14815
14848
 
14849
+ /**
14850
+ * \u5E94\u7528\u4E91\u51FD\u6570\u7B7E\u53D1\u5B9E\u65F6\u7968\u636E\u7684\u5165\u53C2\uFF08RT-008\uFF09\u3002
14851
+ * - subject\uFF1A**\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6**\uFF08\u975E\u5E73\u53F0\u7528\u6237 id\uFF0C\u672C\u5730 sim \u4E0E\u7EBF\u4E0A\u90FD\u4E0D\u505A\u89E3\u6790\uFF0C\u53EA\u5F53\u4E0D\u900F\u660E\u4E32
14852
+ * \u7ED1\u5B9A\u8FDB\u7968\u636E claims\uFF0C\u9632\u7968\u636E\u8DE8\u4E3B\u4F53\u590D\u7528\uFF09\u3002
14853
+ * - channels\uFF1A\u8BE5\u7968\u636E\u53EF\u8BA2\u9605\u7684**\u7CBE\u786E channel \u767D\u540D\u5355**\u3002\u670D\u52A1\u7AEF\u4E0E\u300C\u8BA2\u9605\u6388\u6743\u7B56\u7565\u300D\u6C42\u503C\u53D6 AND
14854
+ * \uFF08\u51FD\u6570\u53EA\u80FD\u7B7E\u53D1\u5B83\u81EA\u5DF1 publish \u9762\u5185\u7684\u901A\u9053\uFF0C\u4E0D\u8DE8\u9879\u76EE\u6269\u6743\uFF09\uFF1Brole='app' \u7968\u7F3A\u7701\u65E0\u8BE5\u540D\u5355
14855
+ * \u21D2 \u65E0\u4EFB\u4F55\u8BA2\u9605\u6388\u6743\uFF08fail closed\uFF09\u3002
14856
+ * - ttlSeconds\uFF1A\u8FC7\u671F\u79D2\u6570\u3002\u7EBF\u4E0A\u5E73\u53F0\u4FA7\u6709\u786C\u6027\u4E0A\u9650\uFF08\u8D85\u4E0A\u9650\u629B REALTIME_INVALID_ARG\uFF09\uFF1B
14857
+ * \u672C\u5730 sim \u4E0D\u4E0E\u7EBF\u4E0A\u540C\u53C2\u503C\u65F6 fail loud\u3002
14858
+ */
14859
+ interface AdepCloudRealtimeTicketInput {
14860
+ subject: string
14861
+ channels: string[]
14862
+ ttlSeconds?: number
14863
+ }
14864
+
14865
+ /** \u7B7E\u7968\u56DE\u6267\uFF1Aticket \u660E\u6587\u53EA\u5728\u6B64\u51FA\u73B0\u4E00\u6B21\uFF0C\u6B64\u540E\u4E00\u5F8B\u8D70\u6253\u7801\uFF08\u89C4\u8303 \xA77\uFF1Bmasked \u4F9B\u65E5\u5FD7\u4E0E\u5C55\u793A\uFF09\u3002 */
14866
+ interface AdepCloudRealtimeTicketReceipt {
14867
+ ticket: string
14868
+ expiresIn: number
14869
+ masked: string
14870
+ }
14871
+
14816
14872
  /** subscribe \u56DE\u6267\uFF1Asubscription \u662F\u540E\u7EED receive / unsubscribe \u7684\u53E5\u67C4\uFF08\u4E0D\u900F\u660E\u5B57\u7B26\u4E32\uFF09\u3002 */
14817
14873
  interface AdepCloudRealtimeSubscription {
14818
14874
  subscription: string
@@ -14832,6 +14888,12 @@ interface AdepCloudRealtime {
14832
14888
  * \uFF08\u5355\u8FDB\u7A0B\u5185\u5B58\u5E7F\u64AD\u6CA1\u6709\u8FDE\u63A5\u8EAB\u4EFD\u53EF\u6BD4\u8F83\uFF0C\u89C1 sim/boundary.ts\uFF09\u3002
14833
14889
  */
14834
14890
  publish(channel: string, data: unknown, except?: string): Promise<AdepCloudRealtimeReceipt>
14891
+ /**
14892
+ * \u4EE5**\u51FD\u6570\u8EAB\u4EFD**\u4E3A\u5E94\u7528\u7528\u6237\u7B7E\u53D1\u4E00\u6B21\u6027\u63E1\u624B\u7968\u636E\uFF08RT-008\uFF09\uFF1A\u5E94\u7528\u81EA\u6709\u8D26\u53F7\u4F53\u7CFB\u5728
14893
+ * \u4E91\u51FD\u6570\u5185\u9274\u6743\u540E\uFF0C\u5230\u8FD9\u91CC\u6362\u53D6\u77ED\u65F6\u6548\u7968\u636E\uFF0C\u524D\u7AEF\u51ED\u7968\u5B8C\u6210 WS \u63E1\u624B\u3002
14894
+ * \u4E0D\u4F9D\u8D56\u5E73\u53F0 better-auth \u4F1A\u8BDD\uFF08\u5E94\u7528\u7528\u6237\u4E0D\u662F\u5E73\u53F0\u7528\u6237\uFF09\u3002
14895
+ */
14896
+ issueTicket(input: AdepCloudRealtimeTicketInput): Promise<AdepCloudRealtimeTicketReceipt>
14835
14897
  /** \u8BA2\u9605 channel\uFF0C\u53D6\u5F97\u4E00\u4E2A\u8F6E\u8BE2\u53E5\u67C4\uFF1B\u547D\u4E2D\u672C\u8BA2\u9605\u7684\u6D88\u606F\u7559\u5728\u5BBF\u4E3B\u7F13\u51B2\u3002 */
14836
14898
  subscribe(channel: string): Promise<AdepCloudRealtimeSubscription>
14837
14899
  /** \u53D6\u56DE\u5E76\u6E05\u7A7A\u8BE5\u53E5\u67C4\u7684\u7F13\u51B2\uFF08\u975E\u963B\u585E\uFF1B\u65E0\u6D88\u606F\u8FD4\u56DE\u7A7A\u6570\u7EC4\uFF09\u3002 */
@@ -38848,7 +38910,7 @@ function registerApp(program2, ctx) {
38848
38910
  // packages/cli/src/import-cf.ts
38849
38911
  init_adep_config();
38850
38912
  init_regexp();
38851
- import { copyFile as copyFile4, mkdir as mkdir13, readFile as readFile19, readdir as readdir8, stat as stat11, writeFile as writeFile14 } from "node:fs/promises";
38913
+ import { copyFile as copyFile4, mkdir as mkdir13, open as open4, readFile as readFile19, readdir as readdir8, stat as stat11, writeFile as writeFile14 } from "node:fs/promises";
38852
38914
  import { basename as basename3, dirname as dirname11, join as join27, relative as relative3, resolve as resolve11 } from "node:path";
38853
38915
  var TomlSyntaxError = class extends Error {
38854
38916
  constructor(message) {
@@ -39349,7 +39411,7 @@ function renderMigrationReport(config2, result) {
39349
39411
  "",
39350
39412
  `- worker\uFF1A\`${config2.main ?? "(\u65E0 main)"}\` \u2192 \`functions/${result.workerName}/\``,
39351
39413
  `- vars\uFF1A${result.mapping.vars} \u4E2A \u2192 adep.config.ts environment`,
39352
- result.mapping.secretsFromDevVars ? "- secrets\uFF08.dev.vars\uFF09\u2192 environment\uFF08\u5EFA\u8BAE\u4E0A\u7EBF\u524D\u8FC1\u5230\u5E73\u53F0 env \u7BA1\u7406\uFF09" : "",
39414
+ result.mapping.secretsFromDevVars ? `- secrets\uFF08.dev.vars\uFF09\u2192 .env.local\uFF080600\uFF0C\u5DF2\u5217\u5165\u751F\u6210\u7684 .gitignore\uFF1B\u672C\u5730 dev/serve \u81EA\u52A8\u88C5\u8F7D\uFF0C\u4E0A\u7EBF\u7528 \`adep env push\` \u63A8\u5E73\u53F0 env\uFF09` : "",
39353
39415
  `- KV \u7ED1\u5B9A\uFF1A${result.mapping.kv} \u4E2A`,
39354
39416
  `- D1 \u7ED1\u5B9A\uFF1A${result.mapping.d1} \u4E2A`,
39355
39417
  `- R2 \u7ED1\u5B9A\uFF1A${result.mapping.r2} \u4E2A`,
@@ -39433,14 +39495,13 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39433
39495
  }
39434
39496
  const { cfBindings, environment } = bindingsFromWrangler(config2);
39435
39497
  const devVars = await readDevVars(sourceDir);
39436
- const mergedEnv = environment === void 0 && Object.keys(devVars).length === 0 ? void 0 : { ...environment, ...devVars };
39437
39498
  const files = [];
39438
39499
  const warnings = [];
39439
39500
  const adepConfig = {
39440
39501
  name: workerName,
39441
39502
  functionsDir: "functions",
39442
39503
  functions_prefix: "/api",
39443
- ...mergedEnv === void 0 ? {} : { environment: mergedEnv },
39504
+ ...environment === void 0 ? {} : { environment },
39444
39505
  ...cfBindings === void 0 ? {} : { cfBindings }
39445
39506
  };
39446
39507
  const configText = renderAdepConfig(adepConfig, {
@@ -39449,6 +39510,29 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39449
39510
  await mkdir13(outDir, { recursive: true });
39450
39511
  await writeFile14(join27(outDir, "adep.config.ts"), configText, "utf8");
39451
39512
  files.push("adep.config.ts");
39513
+ const secretCount = Object.keys(devVars).length;
39514
+ if (secretCount > 0) {
39515
+ const envLocalText = `# \u7531 adep import cf \u751F\u6210\uFF1A.dev.vars\uFF08\u672C\u5730\u5F00\u53D1\u5BC6\u94A5\uFF09\u8FC1\u5230\u8FD9\u91CC\u3002
39516
+ # \u672C\u5730 dev/serve \u81EA\u52A8\u88C5\u8F7D\u5E76\u8986\u76D6 adep.config.ts \u7684 environment\uFF1B
39517
+ # \u4E0A\u7EBF\u7528 adep env push \u63A8\u5230\u5E73\u53F0 env\uFF08isSecret \u52A0\u5BC6\u843D\u5E93\uFF09\u3002\u672C\u6587\u4EF6\u7EDD\u4E0D\u5165\u5E93\u3002
39518
+ ` + Object.entries(devVars).map(([key, value]) => `${key}=${value}`).join("\n") + "\n";
39519
+ const handle = await open4(join27(outDir, ".env.local"), "w", 384);
39520
+ try {
39521
+ await handle.writeFile(envLocalText, "utf8");
39522
+ } finally {
39523
+ await handle.close();
39524
+ }
39525
+ files.push(".env.local");
39526
+ warnings.push(
39527
+ `.dev.vars \u7684 ${secretCount} \u4E2A\u5BC6\u94A5\u5DF2\u5199\u5165 .env.local\uFF080600\uFF0C\u4E0D\u8FDB adep.config.ts\uFF09\uFF1B\u672C\u5730 dev/serve \u76F4\u63A5\u751F\u6548\uFF0C\u4E0A\u7EBF\u7528 adep env push \u63A8\u5E73\u53F0 env`
39528
+ );
39529
+ await writeFile14(
39530
+ join27(outDir, ".gitignore"),
39531
+ "# adep import cf \u751F\u6210\uFF1A.env.local \u662F\u672C\u5730\u5BC6\u94A5\u8986\u76D6\u5C42\uFF08dev/serve \u81EA\u52A8\u88C5\u8F7D\uFF09\uFF0C\u7EDD\u4E0D\u5165\u5E93\n.env.local\n",
39532
+ "utf8"
39533
+ );
39534
+ files.push(".gitignore");
39535
+ }
39452
39536
  await writeFile14(join27(outDir, "package.json"), renderImportPackageJson(workerName), "utf8");
39453
39537
  files.push("package.json");
39454
39538
  let mainCopied = false;
@@ -39546,14 +39630,15 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39546
39630
  }
39547
39631
  }
39548
39632
  const mapping = {
39549
- vars: Object.keys(mergedEnv ?? {}).length,
39633
+ vars: Object.keys(environment ?? {}).length,
39550
39634
  kv: config2.kv_namespaces?.length ?? 0,
39551
39635
  d1: config2.d1_databases?.length ?? 0,
39552
39636
  r2: config2.r2_buckets?.length ?? 0,
39553
39637
  dos: dosMigrated,
39554
39638
  crons: config2.triggers?.crons ?? [],
39555
39639
  assets: assetsCopied,
39556
- secretsFromDevVars: Object.keys(devVars).length > 0
39640
+ secretsFromDevVars: secretCount > 0,
39641
+ secretsCount: secretCount
39557
39642
  };
39558
39643
  const unsupported = unsupportedFromWrangler(config2);
39559
39644
  const migration = renderMigrationReport(config2, {
@@ -40860,9 +40945,98 @@ ${renderDrift(diff, { indexStatements: true }).join("\n")}`
40860
40945
 
40861
40946
  // packages/cli/src/commands/env.ts
40862
40947
  init_auth();
40863
- init_env();
40864
- import { readFile as readFile30, writeFile as writeFile17 } from "node:fs/promises";
40948
+ import { readFile as readFile31, writeFile as writeFile17 } from "node:fs/promises";
40949
+ import { join as join38 } from "node:path";
40950
+
40951
+ // packages/cli/src/env-push.ts
40952
+ init_auth();
40953
+ init_client();
40954
+ import { readFile as readFile30 } from "node:fs/promises";
40865
40955
  import { join as join37 } from "node:path";
40956
+ var SECRET_KEY_RE = /SECRET|TOKEN|APPKEY|API_KEY|(^|_)KEY|PASSWORD|PASSWD|PRIVATE/i;
40957
+ function looksSecret(key, forcedSecret, forcedPublic) {
40958
+ if (forcedPublic.has(key)) return false;
40959
+ if (forcedSecret.has(key)) return true;
40960
+ return SECRET_KEY_RE.test(key);
40961
+ }
40962
+ function parseKeyList(raw) {
40963
+ if (raw === void 0 || raw.trim() === "") return /* @__PURE__ */ new Set();
40964
+ return new Set(
40965
+ raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0)
40966
+ );
40967
+ }
40968
+ function parseEnvText(text) {
40969
+ const out = {};
40970
+ for (const line of text.split(/\r?\n/)) {
40971
+ const trimmed = line.trim();
40972
+ if (trimmed === "" || trimmed.startsWith("#")) continue;
40973
+ const eq = trimmed.indexOf("=");
40974
+ if (eq <= 0) continue;
40975
+ const key = trimmed.slice(0, eq).trim();
40976
+ out[key] = trimmed.slice(eq + 1).trim().replace(/^['"]|['"]$/g, "");
40977
+ }
40978
+ return out;
40979
+ }
40980
+ async function envPush(paths, cwd, options = {}) {
40981
+ const environment = options.environment ?? "dev";
40982
+ const forcedSecret = parseKeyList(options.secretKeys);
40983
+ const forcedPublic = parseKeyList(options.publicKeys);
40984
+ const file2 = options.file ?? ".env.local";
40985
+ const text = await readFile30(join37(cwd, file2), "utf8").catch(() => {
40986
+ throw new CliError(
40987
+ "ENV_FILE_MISSING",
40988
+ `\u627E\u4E0D\u5230 ${join37(cwd, file2)}\uFF1A\u5148 adep env set \u6216 adep env push --file <path>`
40989
+ );
40990
+ });
40991
+ const vars = parseEnvText(text);
40992
+ const keys = Object.keys(vars);
40993
+ if (keys.length === 0) {
40994
+ throw new CliError("ENV_FILE_EMPTY", `${file2} \u91CC\u6CA1\u6709\u53EF\u63A8\u9001\u7684\u952E\uFF08\u7A7A\u6587\u4EF6\u6216\u53EA\u6709\u6CE8\u91CA\uFF09`);
40995
+ }
40996
+ const skipped = keys.filter((key) => (vars[key] ?? "") === "");
40997
+ if (options.dryRun === true) {
40998
+ return {
40999
+ projectId: "",
41000
+ environment,
41001
+ pushed: keys.filter((key) => !skipped.includes(key)).map((key) => ({ key, isSecret: looksSecret(key, forcedSecret, forcedPublic), ok: false })),
41002
+ skipped
41003
+ };
41004
+ }
41005
+ const client = await createClient(paths);
41006
+ const project2 = await resolveProjectId(client, cwd, options.slug);
41007
+ const pushed = [];
41008
+ for (const key of keys) {
41009
+ if (skipped.includes(key)) continue;
41010
+ const isSecret = looksSecret(key, forcedSecret, forcedPublic);
41011
+ try {
41012
+ await client.request(`/api/v1/projects/${project2.id}/env`, {
41013
+ method: "POST",
41014
+ body: { environment, key, value: vars[key], isSecret }
41015
+ });
41016
+ pushed.push({ key, isSecret, ok: true });
41017
+ } catch (error62) {
41018
+ pushed.push({
41019
+ key,
41020
+ isSecret,
41021
+ ok: false,
41022
+ error: error62 instanceof Error ? error62.message : String(error62)
41023
+ });
41024
+ }
41025
+ }
41026
+ return { projectId: project2.id, environment, pushed, skipped };
41027
+ }
41028
+ async function envRemote(paths, cwd, options = {}) {
41029
+ const environment = options.environment ?? "dev";
41030
+ const client = await createClient(paths);
41031
+ const project2 = await resolveProjectId(client, cwd, options.slug);
41032
+ const listed = await client.request(
41033
+ `/api/v1/projects/${project2.id}/env?environment=${environment}`
41034
+ );
41035
+ return { projectId: project2.id, environment, vars: listed.vars ?? [] };
41036
+ }
41037
+
41038
+ // packages/cli/src/commands/env.ts
41039
+ init_env();
40866
41040
  var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
40867
41041
  function upsertEnvLine(content, key, value) {
40868
41042
  const lines = content.split(/\r?\n/);
@@ -40902,7 +41076,7 @@ function mergeEnvKeyEntries(env, local) {
40902
41076
  return entries;
40903
41077
  }
40904
41078
  function registerEnv(program2, ctx) {
40905
- const envCommand = program2.command("env").description("\u9879\u76EE env \u53EF\u89C6\u5316\u4E0E\u672C\u5730\u5199\u5165\uFF08.env.local \u8986\u76D6 .env\uFF1B\u8FDC\u7AEF\u9879\u76EE env \u8D70\u5E73\u53F0\u63A7\u5236\u53F0\uFF09");
41079
+ const envCommand = program2.command("env").description("\u9879\u76EE env\uFF1A\u672C\u5730\u53EF\u89C6\u5316\u4E0E\u5199\u5165\uFF08.env.local \u8986\u76D6 .env\uFF09+ \u5E73\u53F0 env \u63A8\u9001/\u67E5\u770B");
40906
41080
  envCommand.command("list").description("\u5217\u51FA\u751F\u6548 env \u952E\u4E0E\u6765\u6E90\u6587\u4EF6\uFF08\u4E0D\u56DE\u663E\u503C\uFF1B\u8FDC\u7AEF\u4E0D\u53EF\u8FBE\u65F6\u6807\u6CE8\u539F\u56E0\uFF09").action(async () => {
40907
41081
  const command = ctx.io("env list");
40908
41082
  await command.run(async () => {
@@ -40913,10 +41087,11 @@ function registerEnv(program2, ctx) {
40913
41087
  envKeyCount: views.env === null ? 0 : Object.keys(views.env).length,
40914
41088
  localKeyCount: views.local === null ? 0 : Object.keys(views.local).length,
40915
41089
  keys,
40916
- // 远端对照面(显式不可达,不静默):CLI 暂无项目 env 读取端点,端点与推送面另立 FN 线单。
41090
+ // 远端对照面(显式分开,不静默混排):本地视图只认 .env / .env.local;
41091
+ // 平台侧是另一份 env(线上函数读的是它)——用 `adep env remote` 对照。
40917
41092
  remote: {
40918
41093
  available: false,
40919
- reason: "CLI \u6682\u65E0\u9879\u76EE env \u8BFB\u53D6\u7AEF\u70B9\uFF08\u8FDC\u7AEF\u5728\u5E73\u53F0\u63A7\u5236\u53F0\u7EF4\u62A4\uFF1BCLI \u8BFB\u5199\u8FDC\u7AEF\u53E6\u7ACB FN \u7EBF\u5355\uFF09"
41094
+ reason: "\u5E73\u53F0 env \u662F\u72EC\u7ACB\u7684\u4E00\u4EFD\uFF08\u7EBF\u4E0A\u51FD\u6570\u8BFB\u7684\u662F\u5B83\uFF09\uFF1Aadep env remote \u67E5\u770B\u3001adep env push \u63A8\u9001"
40920
41095
  }
40921
41096
  };
40922
41097
  command.ok(data, () => {
@@ -40957,10 +41132,14 @@ function registerEnv(program2, ctx) {
40957
41132
  source,
40958
41133
  overridden: source === ".env.local" && inEnv !== void 0
40959
41134
  };
40960
- command.ok(data, () => [`${key}=${value}\uFF08\u6765\u6E90 ${source}${data.overridden ? "\uFF0C\u8986\u76D6 .env" : ""}\uFF09`]);
41135
+ command.ok(data, () => [
41136
+ `${key}=${value}\uFF08\u6765\u6E90 ${source}${data.overridden ? "\uFF0C\u8986\u76D6 .env" : ""}\uFF09`
41137
+ ]);
40961
41138
  });
40962
41139
  });
40963
- envCommand.command("set <key> <value...>").description("\u5199\u5165 .env.local\uFF08\u8986\u76D6\u5C42\uFF1B\u503C\u53EF\u5F15\u53F7\u5305\u88F9\u4FDD\u5F62\uFF0C\u672A\u5F15\u53F7\u7684\u591A\u8BCD\u4EE5\u5355\u7A7A\u683C\u62FC\u63A5\uFF1B\u4E0B\u6B21 dev/serve \u88C5\u8F7D\u5373\u751F\u6548\uFF09").action(async (key, valueParts) => {
41140
+ envCommand.command("set <key> <value...>").description(
41141
+ "\u5199\u5165 .env.local\uFF08\u8986\u76D6\u5C42\uFF1B\u503C\u53EF\u5F15\u53F7\u5305\u88F9\u4FDD\u5F62\uFF0C\u672A\u5F15\u53F7\u7684\u591A\u8BCD\u4EE5\u5355\u7A7A\u683C\u62FC\u63A5\uFF1B\u4E0B\u6B21 dev/serve \u88C5\u8F7D\u5373\u751F\u6548\uFF09"
41142
+ ).action(async (key, valueParts) => {
40964
41143
  const command = ctx.io("env set");
40965
41144
  await command.run(async () => {
40966
41145
  if (!ENV_KEY_RE.test(key)) {
@@ -40970,7 +41149,7 @@ function registerEnv(program2, ctx) {
40970
41149
  );
40971
41150
  }
40972
41151
  const value = valueParts.join(" ");
40973
- const localPath = join37(ctx.cwd, ".env.local");
41152
+ const localPath = join38(ctx.cwd, ".env.local");
40974
41153
  const existing = await readFileText(localPath);
40975
41154
  const replaced = findEnvLine(existing, key) !== void 0;
40976
41155
  await writeFile17(localPath, upsertEnvLine(existing, key, value), "utf8");
@@ -40981,9 +41160,79 @@ function registerEnv(program2, ctx) {
40981
41160
  ]);
40982
41161
  });
40983
41162
  });
41163
+ envCommand.command("push").description(
41164
+ "\u628A\u672C\u5730 env \u6587\u4EF6\u63A8\u5230\u5E73\u53F0\u9879\u76EE env\uFF08\u7F3A\u7701 dev\uFF1B\u503C\u4E0D\u56DE\u663E\uFF1B--dry \u53EA\u5217\u952E\u3002isSecret \u6309\u952E\u540D\u542F\u53D1\u5F0F\u5224\u5B9A\uFF0C\u53EF\u7528 --secret/--public \u663E\u5F0F\u6307\u5B9A\uFF09"
41165
+ ).option("--environment <env>", "\u76EE\u6807\u73AF\u5883\u69FD dev/staging/prod\uFF08\u7F3A\u7701 dev\uFF09").option("--file <path>", "\u6E90 env \u6587\u4EF6\uFF08\u76F8\u5BF9 cwd\uFF0C\u7F3A\u7701 .env.local\uFF09").option("--secret <keys>", "\u5F3A\u5236\u6309 secret \u63A8\u9001\u7684\u952E\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--public <keys>", "\u5F3A\u5236\u6309\u516C\u5F00\u63A8\u9001\u7684\u952E\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--project <slug>", "\u76EE\u6807\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").option("--dry-run", "\u53EA\u5217\u5C06\u63A8\u9001\u7684\u952E\u4E0E secret \u5224\u5B9A\uFF0C\u4E0D\u53D1\u8BF7\u6C42").action(async (flags) => {
41166
+ const command = ctx.io("env push");
41167
+ await command.run(async () => {
41168
+ const environment = flags["environment"];
41169
+ if (environment !== void 0 && !["dev", "staging", "prod"].includes(environment)) {
41170
+ throw new CliError(
41171
+ "INVALID_ENVIRONMENT",
41172
+ `\u73AF\u5883\u69FD "${environment}" \u975E\u6CD5\uFF1A\u53EF\u9009 dev / staging / prod`
41173
+ );
41174
+ }
41175
+ const file2 = flags["file"];
41176
+ const secretKeys = flags["secret"];
41177
+ const publicKeys = flags["public"];
41178
+ const projectSlug = flags["project"];
41179
+ const result = await envPush(ctx.paths, ctx.cwd, {
41180
+ ...environment === void 0 ? {} : { environment },
41181
+ ...file2 === void 0 ? {} : { file: file2 },
41182
+ dryRun: flags["dryRun"] === true,
41183
+ ...secretKeys === void 0 ? {} : { secretKeys },
41184
+ ...publicKeys === void 0 ? {} : { publicKeys },
41185
+ ...projectSlug === void 0 ? {} : { slug: projectSlug }
41186
+ });
41187
+ const dry = flags["dryRun"] === true;
41188
+ command.ok(
41189
+ {
41190
+ dryRun: dry,
41191
+ projectId: result.projectId,
41192
+ environment: result.environment,
41193
+ keys: result.pushed.map((item) => ({
41194
+ key: item.key,
41195
+ isSecret: item.isSecret,
41196
+ ok: item.ok
41197
+ })),
41198
+ skipped: result.skipped
41199
+ },
41200
+ () => [
41201
+ `${dry ? "\u5C06\u63A8\u9001\uFF08dry-run\uFF0C\u672A\u53D1\u8BF7\u6C42\uFF09" : "\u63A8\u9001"}\u5230\u5E73\u53F0 ${result.environment}\uFF08\u9879\u76EE ${result.projectId}\uFF09\uFF1A`,
41202
+ ...result.pushed.map((item) => {
41203
+ const tag = item.isSecret ? "secret" : "public";
41204
+ if (dry) return ` ${item.key}\uFF08${tag}\uFF09`;
41205
+ return item.ok ? ` \u2713 ${item.key}\uFF08${tag}\uFF09` : ` \u2717 ${item.key} \u2192 ${item.error ?? "\u5931\u8D25"}`;
41206
+ }),
41207
+ ...result.skipped.length > 0 ? [`\u8DF3\u8FC7\u7A7A\u503C\u952E\uFF1A${result.skipped.join(", ")}`] : [],
41208
+ "\u503C\u4E0D\u56DE\u663E\uFF1Bsecret \u5728\u5E73\u53F0\u4FA7\u52A0\u5BC6\u843D\u5E93\uFF0Cenv remote \u53EA\u56DE\u63A9\u7801\u3002"
41209
+ ]
41210
+ );
41211
+ });
41212
+ });
41213
+ envCommand.command("remote").description("\u5217\u5E73\u53F0\u9879\u76EE env\uFF08secret \u53EA\u56DE\u63A9\u7801\u2014\u2014\u63A9\u7801\u7531\u670D\u52A1\u7AEF\u751F\u6210\uFF0CCLI \u4E0D\u78B0\u660E\u6587\uFF09").option("--environment <env>", "\u73AF\u5883\u69FD dev/staging/prod\uFF08\u7F3A\u7701 dev\uFF09").option("--project <slug>", "\u76EE\u6807\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").action(async (flags) => {
41214
+ const command = ctx.io("env remote");
41215
+ await command.run(async () => {
41216
+ const environment = flags["environment"];
41217
+ if (environment !== void 0 && !["dev", "staging", "prod"].includes(environment)) {
41218
+ throw new CliError(
41219
+ "INVALID_ENVIRONMENT",
41220
+ `\u73AF\u5883\u69FD "${environment}" \u975E\u6CD5\uFF1A\u53EF\u9009 dev / staging / prod`
41221
+ );
41222
+ }
41223
+ const result = await envRemote(ctx.paths, ctx.cwd, {
41224
+ ...environment === void 0 ? {} : { environment },
41225
+ ...flags["project"] === void 0 ? {} : { slug: flags["project"] }
41226
+ });
41227
+ command.ok(result, () => [
41228
+ `\u5E73\u53F0 ${result.environment}\uFF08\u9879\u76EE ${result.projectId}\uFF09\u5171 ${result.vars.length} \u952E\uFF1A`,
41229
+ ...result.vars.length === 0 ? [" \uFF08\u8BE5\u73AF\u5883\u69FD\u6CA1\u6709\u952E\u2014\u2014adep env push --environment " + result.environment + " \u63A8\u9001\uFF09"] : result.vars.map((v) => ` ${v.key}=${v.value}${v.isSecret ? "\uFF08secret\uFF09" : ""}`)
41230
+ ]);
41231
+ });
41232
+ });
40984
41233
  }
40985
41234
  async function readFileText(path) {
40986
- return readFile30(path, "utf8").catch(() => "");
41235
+ return readFile31(path, "utf8").catch(() => "");
40987
41236
  }
40988
41237
  function findEnvLine(content, key) {
40989
41238
  for (const line of content.split(/\r?\n/)) {
package/dist/vite.js CHANGED
@@ -36,10 +36,15 @@ var REALTIME_CAPABILITY_CODES = {
36
36
  subscriptionNotFound: "REALTIME_SUBSCRIPTION_NOT_FOUND",
37
37
  tooManySubscriptions: "REALTIME_TOO_MANY_SUBSCRIPTIONS",
38
38
  /** 线上独有:订阅授权策略(RT-002 `SubscriptionPolicy`)拒绝该 channel。 */
39
- channelDenied: "REALTIME_CHANNEL_DENIED"
39
+ channelDenied: "REALTIME_CHANNEL_DENIED",
40
+ /** 线上独有(RT-008):签票入参不合法(subject 缺失 / channels 非字符串数组 / TTL 越界)。 */
41
+ invalidArg: "REALTIME_INVALID_ARG",
42
+ /** 线上独有(RT-008):函数级签票超频(按项目固定窗口限流)。 */
43
+ ticketRateLimited: "REALTIME_TICKET_RATE_LIMITED"
40
44
  };
41
45
  var REALTIME_CAPABILITY_METHODS = [
42
46
  "publish",
47
+ "issueTicket",
43
48
  "subscribe",
44
49
  "receive",
45
50
  "unsubscribe"
@@ -2855,6 +2860,33 @@ function createSimRealtimeCapability() {
2855
2860
  const [channel, data] = args;
2856
2861
  return sim.publish(channel, data);
2857
2862
  }
2863
+ case "issueTicket": {
2864
+ const [input] = args;
2865
+ if (typeof input !== "object" || input === null) {
2866
+ throw realtimeError(
2867
+ REALTIME_CODES.invalidArg,
2868
+ "\u7B7E\u53D1\u7968\u636E\u9700\u8981\u4E00\u4E2A\u8F93\u5165\u5BF9\u8C61 { subject, channels, ttlSeconds? }"
2869
+ );
2870
+ }
2871
+ const subject = input.subject;
2872
+ const channels = input.channels;
2873
+ if (typeof subject !== "string" || subject.length === 0) {
2874
+ throw realtimeError(
2875
+ REALTIME_CODES.invalidArg,
2876
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26 subject\uFF08\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6\uFF09"
2877
+ );
2878
+ }
2879
+ if (!Array.isArray(channels) || channels.length === 0 || channels.some((c) => typeof c !== "string")) {
2880
+ throw realtimeError(
2881
+ REALTIME_CODES.invalidArg,
2882
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26\u975E\u7A7A channels \u5B57\u7B26\u4E32\u6570\u7EC4\uFF08\u5E94\u7528\u7528\u6237\u7684\u7CBE\u786E\u8BA2\u9605\u767D\u540D\u5355\uFF09"
2883
+ );
2884
+ }
2885
+ throw realtimeError(
2886
+ REALTIME_CODES.unsupportedArg,
2887
+ "\u672C\u5730 sim \u4E0D\u7B7E\u53D1\u5B9E\u65F6\u7968\u636E\uFF08\u65E0 WS \u63E1\u624B\u9762\uFF0C\u7968\u636E\u65E0\u5904\u53EF\u7528\uFF09\uFF1B\u8BF7\u5728\u7EBF\u4E0A\u7684\u51FD\u6570\u6267\u884C\u9762\u4F7F\u7528 cloud.realtime.issueTicket"
2888
+ );
2889
+ }
2858
2890
  case "subscribe": {
2859
2891
  if (buffers.size >= MAX_SUBSCRIPTIONS) {
2860
2892
  throw realtimeError(
package/package.json CHANGED
@@ -7,10 +7,13 @@
7
7
  },
8
8
  "homepage": "https://adep.top",
9
9
  "bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
10
- "version": "0.5.8",
10
+ "version": "0.5.9",
11
11
  "adep": {
12
12
  "releaseTasks": [
13
- "CORE-485"
13
+ "FN-062",
14
+ "RT-008",
15
+ "SEC-IMPORT-01",
16
+ "CLI-109"
14
17
  ]
15
18
  },
16
19
  "type": "module",
@@ -36,13 +39,13 @@
36
39
  "yaml": "2.9.1",
37
40
  "zod": "^4.6.6",
38
41
  "@adep/app-runtime": "0.1.1",
39
- "@adep/crypto": "0.1.1",
40
42
  "@adep/cf-compat": "0.1.4",
43
+ "@adep/runtime": "0.3.17",
41
44
  "@adep/vite-plugin": "0.1.13",
42
- "@adep/runtime": "0.3.16"
45
+ "@adep/crypto": "0.1.1"
43
46
  },
44
47
  "devDependencies": {
45
- "@adep/types": "0.4.5"
48
+ "@adep/types": "0.4.6"
46
49
  },
47
50
  "scripts": {
48
51
  "test": "vitest run",