@adep/cli 0.5.8 → 0.5.10

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 +308 -45
  2. package/dist/vite.js +41 -2
  3. package/package.json +10 -7
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"
@@ -1249,7 +1254,7 @@ function rpcReply(worker, id, ok, payload) {
1249
1254
  ...payload?.error === void 0 ? {} : { error: payload.error }
1250
1255
  });
1251
1256
  }
1252
- var WorkerFunctionExecutor;
1257
+ var DEFAULT_FETCH_TIMEOUT_MS, WorkerFunctionExecutor;
1253
1258
  var init_worker_executor = __esm({
1254
1259
  "packages/runtime/src/functions/runtime/worker-executor.ts"() {
1255
1260
  "use strict";
@@ -1257,14 +1262,17 @@ var init_worker_executor = __esm({
1257
1262
  init_resolve();
1258
1263
  init_domain();
1259
1264
  init_function_timeout();
1265
+ DEFAULT_FETCH_TIMEOUT_MS = 1e4;
1260
1266
  WorkerFunctionExecutor = class {
1261
1267
  depsConfig;
1262
1268
  fetchConfig;
1269
+ fetchTimeoutMs;
1263
1270
  parity;
1264
1271
  timeoutMaxMs;
1265
1272
  constructor(options = {}) {
1266
1273
  this.depsConfig = options.deps;
1267
1274
  this.fetchConfig = options.fetch;
1275
+ this.fetchTimeoutMs = options.fetchTimeoutMs;
1268
1276
  this.parity = options.parity === true;
1269
1277
  this.timeoutMaxMs = options.timeoutMaxMs;
1270
1278
  }
@@ -1282,7 +1290,11 @@ var init_worker_executor = __esm({
1282
1290
  const timeoutMs = budget.timeoutMs;
1283
1291
  const memoryLimitMb = input2.memoryLimitMb ?? DEFAULT_MEMORY_LIMIT_MB;
1284
1292
  const deps = this.depsConfig === void 0 ? void 0 : resolveExecutionDeps(this.depsConfig, input2.project.id, input2.files["package.json"]);
1285
- const effectiveFetchConfig = this.fetchConfig === void 0 ? void 0 : input2.fetchAllowlist === void 0 ? this.fetchConfig : { ...this.fetchConfig, allowlist: input2.fetchAllowlist };
1293
+ const effectiveFetchConfig = input2.fetchAllowlist === void 0 ? this.fetchConfig : {
1294
+ allowlist: input2.fetchAllowlist,
1295
+ timeoutMs: this.fetchConfig?.timeoutMs ?? this.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS,
1296
+ ...this.fetchConfig?.maxResponseBytes === void 0 ? {} : { maxResponseBytes: this.fetchConfig.maxResponseBytes }
1297
+ };
1286
1298
  const logs = [];
1287
1299
  if (budget.clamped) {
1288
1300
  logs.push(
@@ -3885,6 +3897,33 @@ function createSimRealtimeCapability() {
3885
3897
  const [channel, data] = args;
3886
3898
  return sim.publish(channel, data);
3887
3899
  }
3900
+ case "issueTicket": {
3901
+ const [input2] = args;
3902
+ if (typeof input2 !== "object" || input2 === null) {
3903
+ throw realtimeError(
3904
+ REALTIME_CODES.invalidArg,
3905
+ "\u7B7E\u53D1\u7968\u636E\u9700\u8981\u4E00\u4E2A\u8F93\u5165\u5BF9\u8C61 { subject, channels, ttlSeconds? }"
3906
+ );
3907
+ }
3908
+ const subject = input2.subject;
3909
+ const channels = input2.channels;
3910
+ if (typeof subject !== "string" || subject.length === 0) {
3911
+ throw realtimeError(
3912
+ REALTIME_CODES.invalidArg,
3913
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26 subject\uFF08\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6\uFF09"
3914
+ );
3915
+ }
3916
+ if (!Array.isArray(channels) || channels.length === 0 || channels.some((c) => typeof c !== "string")) {
3917
+ throw realtimeError(
3918
+ REALTIME_CODES.invalidArg,
3919
+ "\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"
3920
+ );
3921
+ }
3922
+ throw realtimeError(
3923
+ REALTIME_CODES.unsupportedArg,
3924
+ "\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"
3925
+ );
3926
+ }
3888
3927
  case "subscribe": {
3889
3928
  if (buffers.size >= MAX_SUBSCRIPTIONS) {
3890
3929
  throw realtimeError(
@@ -10193,14 +10232,15 @@ __export(storage_exports, {
10193
10232
  storageDownload: () => storageDownload,
10194
10233
  storageList: () => storageList,
10195
10234
  storageRemove: () => storageRemove,
10196
- storageUpload: () => storageUpload
10235
+ storageUpload: () => storageUpload,
10236
+ visibilityNotice: () => visibilityNotice
10197
10237
  });
10198
10238
  import { mkdir as mkdir15, readFile as readFile24, stat as stat14, writeFile as writeFile15 } from "node:fs/promises";
10199
10239
  import { basename as basename5, dirname as dirname12, extname as extname2, join as join32, resolve as resolve15 } from "node:path";
10200
10240
  function envQuery2(options) {
10201
10241
  return options.environment === void 0 ? "" : `?environment=${options.environment}`;
10202
10242
  }
10203
- async function open4(paths, options) {
10243
+ async function open5(paths, options) {
10204
10244
  const client = await createClient(paths);
10205
10245
  const project2 = await resolveSlug(resolve15(options.cwd), options.slug);
10206
10246
  return { client, project: project2 };
@@ -10234,7 +10274,7 @@ function contentTypeOf(path) {
10234
10274
  return map2[extname2(path).toLowerCase()] ?? "application/octet-stream";
10235
10275
  }
10236
10276
  async function storageUpload(paths, options) {
10237
- const { client, project: project2 } = await open4(paths, options);
10277
+ const { client, project: project2 } = await open5(paths, options);
10238
10278
  const local = resolve15(options.file);
10239
10279
  const info = await stat14(local).catch(() => null);
10240
10280
  if (info === null || !info.isFile()) {
@@ -10259,8 +10299,12 @@ async function storageUpload(paths, options) {
10259
10299
  const body = await response.json();
10260
10300
  return { ...body.file, ...body.signedUrl === void 0 ? {} : { signedUrl: body.signedUrl } };
10261
10301
  }
10302
+ function visibilityNotice(result) {
10303
+ if (result.visibility !== "private") return null;
10304
+ return "\u63D0\u793A\uFF1Avisibility=private\uFF08\u7F3A\u7701\uFF09\u2014\u2014\u79C1\u6709\u6587\u4EF6\u7ECF\u7AD9\u70B9\u6258\u7BA1\u9762\u4E0D\u53EF\u89C1\uFF1B\u82E5\u8FD9\u662F\u7AD9\u70B9\u6587\u4EF6\uFF08\u5982 site/data/*\uFF09\u9700\u516C\u5F00\u8BBF\u95EE\uFF0C\u8BF7\u52A0 --visibility public \u91CD\u65B0\u4E0A\u4F20";
10305
+ }
10262
10306
  async function storageList(paths, options) {
10263
- const { client, project: project2 } = await open4(paths, options);
10307
+ const { client, project: project2 } = await open5(paths, options);
10264
10308
  const search = new URLSearchParams();
10265
10309
  if (options.prefix !== void 0) search.set("prefix", options.prefix);
10266
10310
  if (options.environment !== void 0) search.set("environment", options.environment);
@@ -10284,7 +10328,7 @@ async function resolveDownloadUrl(client, project2, path, environment) {
10284
10328
  return url2;
10285
10329
  }
10286
10330
  async function storageDownload(paths, options) {
10287
- const { client, project: project2 } = await open4(paths, options);
10331
+ const { client, project: project2 } = await open5(paths, options);
10288
10332
  const url2 = await resolveDownloadUrl(client, project2, options.path, options.environment);
10289
10333
  const response = await client.download(url2, "STORAGE_DOWNLOAD_FAILED");
10290
10334
  const bytes = Buffer.from(await response.arrayBuffer());
@@ -10294,7 +10338,7 @@ async function storageDownload(paths, options) {
10294
10338
  return { path: options.path, output: output2, size: bytes.length };
10295
10339
  }
10296
10340
  async function storageRemove(paths, options) {
10297
- const { client, project: project2 } = await open4(paths, options);
10341
+ const { client, project: project2 } = await open5(paths, options);
10298
10342
  return client.request(
10299
10343
  `/api/v1/projects/${project2}/files/${encodeURIComponent(options.path)}${envQuery2(options)}`,
10300
10344
  { method: "DELETE" }
@@ -10319,13 +10363,13 @@ __export(hosting_exports, {
10319
10363
  import { readdir as readdir11, readFile as readFile25, stat as stat15 } from "node:fs/promises";
10320
10364
  import { spawnSync } from "node:child_process";
10321
10365
  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) {
10366
+ async function open6(paths, options) {
10323
10367
  const client = await createClient(paths);
10324
10368
  const project2 = await resolveSlug(resolve16(options.cwd), options.slug);
10325
10369
  return { client, project: project2 };
10326
10370
  }
10327
10371
  async function hostingInfo(paths, options) {
10328
- const { client, project: project2 } = await open5(paths, options);
10372
+ const { client, project: project2 } = await open6(paths, options);
10329
10373
  const body = await client.request(`/api/v1/projects/${project2}/hosting`);
10330
10374
  return {
10331
10375
  config: body.config,
@@ -10357,7 +10401,7 @@ async function collectSiteFiles(dir) {
10357
10401
  return files;
10358
10402
  }
10359
10403
  async function hostingDeploy(paths, options) {
10360
- const { client, project: project2 } = await open5(paths, options);
10404
+ const { client, project: project2 } = await open6(paths, options);
10361
10405
  const log = options.log ?? ((line) => process.stdout.write(`${line}
10362
10406
  `));
10363
10407
  if (options.build !== void 0) {
@@ -10436,7 +10480,7 @@ async function hostingDeploy(paths, options) {
10436
10480
  return { config: config2.config, siteUrl: info.siteUrl, uploaded, reused, identical, builtAt };
10437
10481
  }
10438
10482
  async function hostingPull(paths, options) {
10439
- const { client } = await open5(paths, options);
10483
+ const { client } = await open6(paths, options);
10440
10484
  const log = options.log ?? ((line) => process.stdout.write(`${line}
10441
10485
  `));
10442
10486
  const info = await hostingInfo(paths, options);
@@ -10459,7 +10503,7 @@ async function hostingPull(paths, options) {
10459
10503
  return { siteUrl: info.siteUrl, outputDir, files };
10460
10504
  }
10461
10505
  async function hostingConfig(paths, options) {
10462
- const { client, project: project2 } = await open5(paths, options);
10506
+ const { client, project: project2 } = await open6(paths, options);
10463
10507
  const body = {};
10464
10508
  if (options.enabled !== void 0) body["enabled"] = options.enabled;
10465
10509
  if (options.spa !== void 0) body["spaMode"] = options.spa;
@@ -10917,8 +10961,8 @@ var init_release_check = __esm({
10917
10961
  });
10918
10962
 
10919
10963
  // 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";
10964
+ import { readdir as readdir13, readFile as readFile32 } from "node:fs/promises";
10965
+ import { join as join39, relative as relative9, sep as sep5 } from "node:path";
10922
10966
  function extractSpecifiers(line) {
10923
10967
  const out = [];
10924
10968
  const patterns = [
@@ -10962,7 +11006,7 @@ function classify(specifier) {
10962
11006
  return null;
10963
11007
  }
10964
11008
  async function scanFunctionSources(rootDir, functionsDir) {
10965
- const base = join38(rootDir, functionsDir);
11009
+ const base = join39(rootDir, functionsDir);
10966
11010
  const findings = [];
10967
11011
  async function walk(current) {
10968
11012
  let entries;
@@ -10972,7 +11016,7 @@ async function scanFunctionSources(rootDir, functionsDir) {
10972
11016
  return;
10973
11017
  }
10974
11018
  for (const entry of entries) {
10975
- const abs = join38(current, entry.name);
11019
+ const abs = join39(current, entry.name);
10976
11020
  if (entry.isDirectory()) {
10977
11021
  if (SKIP_DIRS.has(entry.name)) continue;
10978
11022
  await walk(abs);
@@ -10983,7 +11027,7 @@ async function scanFunctionSources(rootDir, functionsDir) {
10983
11027
  if (entry.name.endsWith(".d.ts")) continue;
10984
11028
  let content;
10985
11029
  try {
10986
- content = await readFile31(abs, "utf8");
11030
+ content = await readFile32(abs, "utf8");
10987
11031
  } catch {
10988
11032
  continue;
10989
11033
  }
@@ -11112,7 +11156,7 @@ var init_version = __esm({
11112
11156
  manifest = requireJson("../package.json");
11113
11157
  CLI_VERSION = typeof manifest.version === "string" && manifest.version.length > 0 ? manifest.version : "0.0.0";
11114
11158
  RELEASE_TASKS = Array.isArray(manifest.adep?.releaseTasks) ? manifest.adep.releaseTasks.filter((item) => typeof item === "string") : [];
11115
- BUILD_COMMIT = "08ca68b9".trim() !== "" ? "08ca68b9".trim() : null;
11159
+ BUILD_COMMIT = "d45faf6c".trim() !== "" ? "d45faf6c".trim() : null;
11116
11160
  }
11117
11161
  });
11118
11162
 
@@ -11126,9 +11170,9 @@ __export(doctor_exports, {
11126
11170
  runDoctor: () => runDoctor
11127
11171
  });
11128
11172
  import { createRequire as createRequire3 } from "node:module";
11129
- import { readFile as readFile32, stat as stat18 } from "node:fs/promises";
11173
+ import { readFile as readFile33, stat as stat18 } from "node:fs/promises";
11130
11174
  import { homedir } from "node:os";
11131
- import { join as join39 } from "node:path";
11175
+ import { join as join40 } from "node:path";
11132
11176
  import { parse as parseYaml } from "yaml";
11133
11177
  function minimumReleaseAgeMinutes(raw) {
11134
11178
  const text = raw.trim();
@@ -11152,7 +11196,7 @@ function hitFromEnvironment(env) {
11152
11196
  }
11153
11197
  async function readTextOrNull(file2) {
11154
11198
  try {
11155
- return await readFile32(file2, "utf8");
11199
+ return await readFile33(file2, "utf8");
11156
11200
  } catch {
11157
11201
  return null;
11158
11202
  }
@@ -11193,8 +11237,8 @@ async function hitFromNpmrc(file2, label) {
11193
11237
  }
11194
11238
  async function detectSupplyChainPolicy(cwd, env = process.env, home = homedir()) {
11195
11239
  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");
11240
+ const globalConfig2 = xdg !== void 0 && xdg !== "" ? join40(xdg, "pnpm", "config.yaml") : join40(home, ".config", "pnpm", "config.yaml");
11241
+ 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
11242
  return {
11199
11243
  minimumReleaseAge: hit === null ? { minutes: null, source: null, raw: null, warning: null } : { minutes: hit.minutes, source: hit.source, raw: hit.raw, warning: hit.warning }
11200
11244
  };
@@ -11229,7 +11273,7 @@ async function credentialMode(file2) {
11229
11273
  async function runDoctor(paths, cwd = process.cwd()) {
11230
11274
  const credentials = await loadCredentials(paths);
11231
11275
  const server = credentials?.server ?? resolveServer();
11232
- const credentialsFile = credentials !== null ? join39(paths.credentialsDir, `${slotNameFor(credentials.server)}.json`) : paths.credentialsFile;
11276
+ const credentialsFile = credentials !== null ? join40(paths.credentialsDir, `${slotNameFor(credentials.server)}.json`) : paths.credentialsFile;
11233
11277
  const mode = await credentialMode(credentialsFile);
11234
11278
  const offline = await isOffline();
11235
11279
  const health = await probeServer(server);
@@ -11361,7 +11405,7 @@ function pickBreakingNotices(parsed, status, version2, newerVersions) {
11361
11405
  }
11362
11406
  async function readOwnChangelog() {
11363
11407
  try {
11364
- return await readFile32(createRequire3(import.meta.url).resolve("../CHANGELOG.md"), "utf8");
11408
+ return await readFile33(createRequire3(import.meta.url).resolve("../CHANGELOG.md"), "utf8");
11365
11409
  } catch {
11366
11410
  return null;
11367
11411
  }
@@ -14491,6 +14535,7 @@ var ADEP_ENV_DTS = `/**
14491
14535
  * \u5951\u7EA6\u552F\u4E00\u771F\u76F8\u6E90 = packages/types/src/\uFF1B\u540C\u6E90\u4EA7\u7269\u8FD8\u6709 Web IDE \u955C\u50CF
14492
14536
  * \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
14537
  * \u6F02\u79FB\u95E8 = scripts/lib/__tests__/contract-mirrors.test.ts\u3002
14538
+ * \u955C\u50CF\u7248\u672C = @adep/types@0.4.7\uFF08generate:contracts \u751F\u6210\u65F6\u6233\uFF09
14494
14539
  */
14495
14540
 
14496
14541
  /* ---------- HTTP \u89E6\u53D1\u4E0A\u4E0B\u6587\uFF08FunctionContext \u955C\u50CF\uFF09 ---------- */
@@ -14813,6 +14858,29 @@ interface AdepCloudRealtimeReceipt {
14813
14858
  delivered: number
14814
14859
  }
14815
14860
 
14861
+ /**
14862
+ * \u5E94\u7528\u4E91\u51FD\u6570\u7B7E\u53D1\u5B9E\u65F6\u7968\u636E\u7684\u5165\u53C2\uFF08RT-008\uFF09\u3002
14863
+ * - 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
14864
+ * \u7ED1\u5B9A\u8FDB\u7968\u636E claims\uFF0C\u9632\u7968\u636E\u8DE8\u4E3B\u4F53\u590D\u7528\uFF09\u3002
14865
+ * - 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
14866
+ * \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
14867
+ * \u21D2 \u65E0\u4EFB\u4F55\u8BA2\u9605\u6388\u6743\uFF08fail closed\uFF09\u3002
14868
+ * - 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
14869
+ * \u672C\u5730 sim \u4E0D\u4E0E\u7EBF\u4E0A\u540C\u53C2\u503C\u65F6 fail loud\u3002
14870
+ */
14871
+ interface AdepCloudRealtimeTicketInput {
14872
+ subject: string
14873
+ channels: string[]
14874
+ ttlSeconds?: number
14875
+ }
14876
+
14877
+ /** \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 */
14878
+ interface AdepCloudRealtimeTicketReceipt {
14879
+ ticket: string
14880
+ expiresIn: number
14881
+ masked: string
14882
+ }
14883
+
14816
14884
  /** subscribe \u56DE\u6267\uFF1Asubscription \u662F\u540E\u7EED receive / unsubscribe \u7684\u53E5\u67C4\uFF08\u4E0D\u900F\u660E\u5B57\u7B26\u4E32\uFF09\u3002 */
14817
14885
  interface AdepCloudRealtimeSubscription {
14818
14886
  subscription: string
@@ -14832,6 +14900,12 @@ interface AdepCloudRealtime {
14832
14900
  * \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
14901
  */
14834
14902
  publish(channel: string, data: unknown, except?: string): Promise<AdepCloudRealtimeReceipt>
14903
+ /**
14904
+ * \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
14905
+ * \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
14906
+ * \u4E0D\u4F9D\u8D56\u5E73\u53F0 better-auth \u4F1A\u8BDD\uFF08\u5E94\u7528\u7528\u6237\u4E0D\u662F\u5E73\u53F0\u7528\u6237\uFF09\u3002
14907
+ */
14908
+ issueTicket(input: AdepCloudRealtimeTicketInput): Promise<AdepCloudRealtimeTicketReceipt>
14835
14909
  /** \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
14910
  subscribe(channel: string): Promise<AdepCloudRealtimeSubscription>
14837
14911
  /** \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 */
@@ -15556,7 +15630,7 @@ export default defineConfig({
15556
15630
  },
15557
15631
  })
15558
15632
  `;
15559
- var GITIGNORE = "node_modules/\ndata/\n.adep/\nsite/\n";
15633
+ var GITIGNORE = "node_modules/\ndata/\n.adep/\nsite/\n.wbapp_*\n";
15560
15634
  var PNPM_WORKSPACE_YAML = `# pnpm \u914D\u7F6E\uFF08pnpm 10 \u8D77\u4ECE\u8FD9\u91CC\u8BFB\u53D6\uFF1Bpackage.json \u7684 pnpm \u5B57\u6BB5\u53EA\u5BF9 pnpm 9 \u53CA\u66F4\u65E9\u751F\u6548\uFF09
15561
15635
  #
15562
15636
  # pnpm 10+ \u9ED8\u8BA4\u4E0D\u6267\u884C\u4F9D\u8D56\u7684\u6784\u5EFA\u811A\u672C\uFF08\u4F9B\u5E94\u94FE\u5B89\u5168\u9ED8\u8BA4\uFF09\u3002esbuild \u662F vite / @adep/cli \u7684
@@ -38848,7 +38922,7 @@ function registerApp(program2, ctx) {
38848
38922
  // packages/cli/src/import-cf.ts
38849
38923
  init_adep_config();
38850
38924
  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";
38925
+ 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
38926
  import { basename as basename3, dirname as dirname11, join as join27, relative as relative3, resolve as resolve11 } from "node:path";
38853
38927
  var TomlSyntaxError = class extends Error {
38854
38928
  constructor(message) {
@@ -39349,7 +39423,7 @@ function renderMigrationReport(config2, result) {
39349
39423
  "",
39350
39424
  `- worker\uFF1A\`${config2.main ?? "(\u65E0 main)"}\` \u2192 \`functions/${result.workerName}/\``,
39351
39425
  `- 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" : "",
39426
+ 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
39427
  `- KV \u7ED1\u5B9A\uFF1A${result.mapping.kv} \u4E2A`,
39354
39428
  `- D1 \u7ED1\u5B9A\uFF1A${result.mapping.d1} \u4E2A`,
39355
39429
  `- R2 \u7ED1\u5B9A\uFF1A${result.mapping.r2} \u4E2A`,
@@ -39433,14 +39507,13 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39433
39507
  }
39434
39508
  const { cfBindings, environment } = bindingsFromWrangler(config2);
39435
39509
  const devVars = await readDevVars(sourceDir);
39436
- const mergedEnv = environment === void 0 && Object.keys(devVars).length === 0 ? void 0 : { ...environment, ...devVars };
39437
39510
  const files = [];
39438
39511
  const warnings = [];
39439
39512
  const adepConfig = {
39440
39513
  name: workerName,
39441
39514
  functionsDir: "functions",
39442
39515
  functions_prefix: "/api",
39443
- ...mergedEnv === void 0 ? {} : { environment: mergedEnv },
39516
+ ...environment === void 0 ? {} : { environment },
39444
39517
  ...cfBindings === void 0 ? {} : { cfBindings }
39445
39518
  };
39446
39519
  const configText = renderAdepConfig(adepConfig, {
@@ -39449,6 +39522,29 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39449
39522
  await mkdir13(outDir, { recursive: true });
39450
39523
  await writeFile14(join27(outDir, "adep.config.ts"), configText, "utf8");
39451
39524
  files.push("adep.config.ts");
39525
+ const secretCount = Object.keys(devVars).length;
39526
+ if (secretCount > 0) {
39527
+ const envLocalText = `# \u7531 adep import cf \u751F\u6210\uFF1A.dev.vars\uFF08\u672C\u5730\u5F00\u53D1\u5BC6\u94A5\uFF09\u8FC1\u5230\u8FD9\u91CC\u3002
39528
+ # \u672C\u5730 dev/serve \u81EA\u52A8\u88C5\u8F7D\u5E76\u8986\u76D6 adep.config.ts \u7684 environment\uFF1B
39529
+ # \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
39530
+ ` + Object.entries(devVars).map(([key, value]) => `${key}=${value}`).join("\n") + "\n";
39531
+ const handle = await open4(join27(outDir, ".env.local"), "w", 384);
39532
+ try {
39533
+ await handle.writeFile(envLocalText, "utf8");
39534
+ } finally {
39535
+ await handle.close();
39536
+ }
39537
+ files.push(".env.local");
39538
+ warnings.push(
39539
+ `.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`
39540
+ );
39541
+ await writeFile14(
39542
+ join27(outDir, ".gitignore"),
39543
+ "# 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",
39544
+ "utf8"
39545
+ );
39546
+ files.push(".gitignore");
39547
+ }
39452
39548
  await writeFile14(join27(outDir, "package.json"), renderImportPackageJson(workerName), "utf8");
39453
39549
  files.push("package.json");
39454
39550
  let mainCopied = false;
@@ -39546,14 +39642,15 @@ async function importCfProject(cwd, sourceDir, options = {}) {
39546
39642
  }
39547
39643
  }
39548
39644
  const mapping = {
39549
- vars: Object.keys(mergedEnv ?? {}).length,
39645
+ vars: Object.keys(environment ?? {}).length,
39550
39646
  kv: config2.kv_namespaces?.length ?? 0,
39551
39647
  d1: config2.d1_databases?.length ?? 0,
39552
39648
  r2: config2.r2_buckets?.length ?? 0,
39553
39649
  dos: dosMigrated,
39554
39650
  crons: config2.triggers?.crons ?? [],
39555
39651
  assets: assetsCopied,
39556
- secretsFromDevVars: Object.keys(devVars).length > 0
39652
+ secretsFromDevVars: secretCount > 0,
39653
+ secretsCount: secretCount
39557
39654
  };
39558
39655
  const unsupported = unsupportedFromWrangler(config2);
39559
39656
  const migration = renderMigrationReport(config2, {
@@ -40860,9 +40957,98 @@ ${renderDrift(diff, { indexStatements: true }).join("\n")}`
40860
40957
 
40861
40958
  // packages/cli/src/commands/env.ts
40862
40959
  init_auth();
40863
- init_env();
40864
- import { readFile as readFile30, writeFile as writeFile17 } from "node:fs/promises";
40960
+ import { readFile as readFile31, writeFile as writeFile17 } from "node:fs/promises";
40961
+ import { join as join38 } from "node:path";
40962
+
40963
+ // packages/cli/src/env-push.ts
40964
+ init_auth();
40965
+ init_client();
40966
+ import { readFile as readFile30 } from "node:fs/promises";
40865
40967
  import { join as join37 } from "node:path";
40968
+ var SECRET_KEY_RE = /SECRET|TOKEN|APPKEY|API_KEY|(^|_)KEY|PASSWORD|PASSWD|PRIVATE/i;
40969
+ function looksSecret(key, forcedSecret, forcedPublic) {
40970
+ if (forcedPublic.has(key)) return false;
40971
+ if (forcedSecret.has(key)) return true;
40972
+ return SECRET_KEY_RE.test(key);
40973
+ }
40974
+ function parseKeyList(raw) {
40975
+ if (raw === void 0 || raw.trim() === "") return /* @__PURE__ */ new Set();
40976
+ return new Set(
40977
+ raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0)
40978
+ );
40979
+ }
40980
+ function parseEnvText(text) {
40981
+ const out = {};
40982
+ for (const line of text.split(/\r?\n/)) {
40983
+ const trimmed = line.trim();
40984
+ if (trimmed === "" || trimmed.startsWith("#")) continue;
40985
+ const eq = trimmed.indexOf("=");
40986
+ if (eq <= 0) continue;
40987
+ const key = trimmed.slice(0, eq).trim();
40988
+ out[key] = trimmed.slice(eq + 1).trim().replace(/^['"]|['"]$/g, "");
40989
+ }
40990
+ return out;
40991
+ }
40992
+ async function envPush(paths, cwd, options = {}) {
40993
+ const environment = options.environment ?? "dev";
40994
+ const forcedSecret = parseKeyList(options.secretKeys);
40995
+ const forcedPublic = parseKeyList(options.publicKeys);
40996
+ const file2 = options.file ?? ".env.local";
40997
+ const text = await readFile30(join37(cwd, file2), "utf8").catch(() => {
40998
+ throw new CliError(
40999
+ "ENV_FILE_MISSING",
41000
+ `\u627E\u4E0D\u5230 ${join37(cwd, file2)}\uFF1A\u5148 adep env set \u6216 adep env push --file <path>`
41001
+ );
41002
+ });
41003
+ const vars = parseEnvText(text);
41004
+ const keys = Object.keys(vars);
41005
+ if (keys.length === 0) {
41006
+ 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`);
41007
+ }
41008
+ const skipped = keys.filter((key) => (vars[key] ?? "") === "");
41009
+ if (options.dryRun === true) {
41010
+ return {
41011
+ projectId: "",
41012
+ environment,
41013
+ pushed: keys.filter((key) => !skipped.includes(key)).map((key) => ({ key, isSecret: looksSecret(key, forcedSecret, forcedPublic), ok: false })),
41014
+ skipped
41015
+ };
41016
+ }
41017
+ const client = await createClient(paths);
41018
+ const project2 = await resolveProjectId(client, cwd, options.slug);
41019
+ const pushed = [];
41020
+ for (const key of keys) {
41021
+ if (skipped.includes(key)) continue;
41022
+ const isSecret = looksSecret(key, forcedSecret, forcedPublic);
41023
+ try {
41024
+ await client.request(`/api/v1/projects/${project2.id}/env`, {
41025
+ method: "POST",
41026
+ body: { environment, key, value: vars[key], isSecret }
41027
+ });
41028
+ pushed.push({ key, isSecret, ok: true });
41029
+ } catch (error62) {
41030
+ pushed.push({
41031
+ key,
41032
+ isSecret,
41033
+ ok: false,
41034
+ error: error62 instanceof Error ? error62.message : String(error62)
41035
+ });
41036
+ }
41037
+ }
41038
+ return { projectId: project2.id, environment, pushed, skipped };
41039
+ }
41040
+ async function envRemote(paths, cwd, options = {}) {
41041
+ const environment = options.environment ?? "dev";
41042
+ const client = await createClient(paths);
41043
+ const project2 = await resolveProjectId(client, cwd, options.slug);
41044
+ const listed = await client.request(
41045
+ `/api/v1/projects/${project2.id}/env?environment=${environment}`
41046
+ );
41047
+ return { projectId: project2.id, environment, vars: listed.vars ?? [] };
41048
+ }
41049
+
41050
+ // packages/cli/src/commands/env.ts
41051
+ init_env();
40866
41052
  var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
40867
41053
  function upsertEnvLine(content, key, value) {
40868
41054
  const lines = content.split(/\r?\n/);
@@ -40902,7 +41088,7 @@ function mergeEnvKeyEntries(env, local) {
40902
41088
  return entries;
40903
41089
  }
40904
41090
  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");
41091
+ 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
41092
  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
41093
  const command = ctx.io("env list");
40908
41094
  await command.run(async () => {
@@ -40913,10 +41099,11 @@ function registerEnv(program2, ctx) {
40913
41099
  envKeyCount: views.env === null ? 0 : Object.keys(views.env).length,
40914
41100
  localKeyCount: views.local === null ? 0 : Object.keys(views.local).length,
40915
41101
  keys,
40916
- // 远端对照面(显式不可达,不静默):CLI 暂无项目 env 读取端点,端点与推送面另立 FN 线单。
41102
+ // 远端对照面(显式分开,不静默混排):本地视图只认 .env / .env.local;
41103
+ // 平台侧是另一份 env(线上函数读的是它)——用 `adep env remote` 对照。
40917
41104
  remote: {
40918
41105
  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"
41106
+ 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
41107
  }
40921
41108
  };
40922
41109
  command.ok(data, () => {
@@ -40957,10 +41144,14 @@ function registerEnv(program2, ctx) {
40957
41144
  source,
40958
41145
  overridden: source === ".env.local" && inEnv !== void 0
40959
41146
  };
40960
- command.ok(data, () => [`${key}=${value}\uFF08\u6765\u6E90 ${source}${data.overridden ? "\uFF0C\u8986\u76D6 .env" : ""}\uFF09`]);
41147
+ command.ok(data, () => [
41148
+ `${key}=${value}\uFF08\u6765\u6E90 ${source}${data.overridden ? "\uFF0C\u8986\u76D6 .env" : ""}\uFF09`
41149
+ ]);
40961
41150
  });
40962
41151
  });
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) => {
41152
+ envCommand.command("set <key> <value...>").description(
41153
+ "\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"
41154
+ ).action(async (key, valueParts) => {
40964
41155
  const command = ctx.io("env set");
40965
41156
  await command.run(async () => {
40966
41157
  if (!ENV_KEY_RE.test(key)) {
@@ -40970,7 +41161,7 @@ function registerEnv(program2, ctx) {
40970
41161
  );
40971
41162
  }
40972
41163
  const value = valueParts.join(" ");
40973
- const localPath = join37(ctx.cwd, ".env.local");
41164
+ const localPath = join38(ctx.cwd, ".env.local");
40974
41165
  const existing = await readFileText(localPath);
40975
41166
  const replaced = findEnvLine(existing, key) !== void 0;
40976
41167
  await writeFile17(localPath, upsertEnvLine(existing, key, value), "utf8");
@@ -40981,9 +41172,79 @@ function registerEnv(program2, ctx) {
40981
41172
  ]);
40982
41173
  });
40983
41174
  });
41175
+ envCommand.command("push").description(
41176
+ "\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"
41177
+ ).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) => {
41178
+ const command = ctx.io("env push");
41179
+ await command.run(async () => {
41180
+ const environment = flags["environment"];
41181
+ if (environment !== void 0 && !["dev", "staging", "prod"].includes(environment)) {
41182
+ throw new CliError(
41183
+ "INVALID_ENVIRONMENT",
41184
+ `\u73AF\u5883\u69FD "${environment}" \u975E\u6CD5\uFF1A\u53EF\u9009 dev / staging / prod`
41185
+ );
41186
+ }
41187
+ const file2 = flags["file"];
41188
+ const secretKeys = flags["secret"];
41189
+ const publicKeys = flags["public"];
41190
+ const projectSlug = flags["project"];
41191
+ const result = await envPush(ctx.paths, ctx.cwd, {
41192
+ ...environment === void 0 ? {} : { environment },
41193
+ ...file2 === void 0 ? {} : { file: file2 },
41194
+ dryRun: flags["dryRun"] === true,
41195
+ ...secretKeys === void 0 ? {} : { secretKeys },
41196
+ ...publicKeys === void 0 ? {} : { publicKeys },
41197
+ ...projectSlug === void 0 ? {} : { slug: projectSlug }
41198
+ });
41199
+ const dry = flags["dryRun"] === true;
41200
+ command.ok(
41201
+ {
41202
+ dryRun: dry,
41203
+ projectId: result.projectId,
41204
+ environment: result.environment,
41205
+ keys: result.pushed.map((item) => ({
41206
+ key: item.key,
41207
+ isSecret: item.isSecret,
41208
+ ok: item.ok
41209
+ })),
41210
+ skipped: result.skipped
41211
+ },
41212
+ () => [
41213
+ `${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`,
41214
+ ...result.pushed.map((item) => {
41215
+ const tag = item.isSecret ? "secret" : "public";
41216
+ if (dry) return ` ${item.key}\uFF08${tag}\uFF09`;
41217
+ return item.ok ? ` \u2713 ${item.key}\uFF08${tag}\uFF09` : ` \u2717 ${item.key} \u2192 ${item.error ?? "\u5931\u8D25"}`;
41218
+ }),
41219
+ ...result.skipped.length > 0 ? [`\u8DF3\u8FC7\u7A7A\u503C\u952E\uFF1A${result.skipped.join(", ")}`] : [],
41220
+ "\u503C\u4E0D\u56DE\u663E\uFF1Bsecret \u5728\u5E73\u53F0\u4FA7\u52A0\u5BC6\u843D\u5E93\uFF0Cenv remote \u53EA\u56DE\u63A9\u7801\u3002"
41221
+ ]
41222
+ );
41223
+ });
41224
+ });
41225
+ 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) => {
41226
+ const command = ctx.io("env remote");
41227
+ await command.run(async () => {
41228
+ const environment = flags["environment"];
41229
+ if (environment !== void 0 && !["dev", "staging", "prod"].includes(environment)) {
41230
+ throw new CliError(
41231
+ "INVALID_ENVIRONMENT",
41232
+ `\u73AF\u5883\u69FD "${environment}" \u975E\u6CD5\uFF1A\u53EF\u9009 dev / staging / prod`
41233
+ );
41234
+ }
41235
+ const result = await envRemote(ctx.paths, ctx.cwd, {
41236
+ ...environment === void 0 ? {} : { environment },
41237
+ ...flags["project"] === void 0 ? {} : { slug: flags["project"] }
41238
+ });
41239
+ command.ok(result, () => [
41240
+ `\u5E73\u53F0 ${result.environment}\uFF08\u9879\u76EE ${result.projectId}\uFF09\u5171 ${result.vars.length} \u952E\uFF1A`,
41241
+ ...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" : ""}`)
41242
+ ]);
41243
+ });
41244
+ });
40984
41245
  }
40985
41246
  async function readFileText(path) {
40986
- return readFile30(path, "utf8").catch(() => "");
41247
+ return readFile31(path, "utf8").catch(() => "");
40987
41248
  }
40988
41249
  function findEnvLine(content, key) {
40989
41250
  for (const line of content.split(/\r?\n/)) {
@@ -41023,13 +41284,13 @@ function registerStorage(program2, ctx) {
41023
41284
  const storage = program2.command("storage").description("\u4E91\u5B58\u50A8 / \u6587\u4EF6\u5B58\u50A8\uFF1A\u4E0A\u4F20 / \u4E0B\u8F7D / \u5217\u8868 / \u5220\u9664");
41024
41285
  storage.command("upload").description("\u4E0A\u4F20\u5355\u4E2A\u6587\u4EF6\uFF08multipart\uFF1B\u5355\u6587\u4EF6 \u2264 50MB\uFF09").argument("<file>", "\u672C\u5730\u6587\u4EF6\u8DEF\u5F84").requiredOption("--path <remote-path>", "\u6876\u5185\u76EE\u6807\u8DEF\u5F84\uFF08\u5982 avatars/a.png\uFF09").option(
41025
41286
  "--visibility <public|private>",
41026
- "public \u76F4\u8FDE / private \u7B7E\u540D\uFF08\u7F3A\u7701 private\uFF09",
41287
+ "public \u76F4\u8FDE / private \u7B7E\u540D\uFF08\u7F3A\u7701 private\u2014\u2014\u79C1\u6709\u6587\u4EF6\u7ECF\u7AD9\u70B9\u6258\u7BA1\u9762\u4E0D\u53EF\u89C1\uFF0C\u7AD9\u70B9\u6587\u4EF6\u987B\u663E\u5F0F public\uFF09",
41027
41288
  "private"
41028
41289
  ).option("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug\uFF08\u7F3A\u7701\u53D6 adep.config.ts \u7684 name\uFF09").action(async (file2, flags) => {
41029
41290
  const command = ctx.io("storage upload");
41030
41291
  await command.run(async () => {
41031
41292
  const { environment, source } = await ctx.env();
41032
- const { storageUpload: storageUpload2 } = await Promise.resolve().then(() => (init_storage2(), storage_exports));
41293
+ const { storageUpload: storageUpload2, visibilityNotice: visibilityNotice2 } = await Promise.resolve().then(() => (init_storage2(), storage_exports));
41033
41294
  const result = await storageUpload2(ctx.paths, {
41034
41295
  cwd: ctx.cwd,
41035
41296
  file: file2,
@@ -41039,6 +41300,8 @@ function registerStorage(program2, ctx) {
41039
41300
  ...flags.project === void 0 ? {} : { slug: flags.project }
41040
41301
  });
41041
41302
  command.line(`\u73AF\u5883\uFF1A${environment}\uFF08${describeEnvironmentSource(source)}\uFF09`);
41303
+ const notice = visibilityNotice2(result);
41304
+ if (notice !== null) command.line(notice);
41042
41305
  command.ok(result, (data) => {
41043
41306
  const r = data;
41044
41307
  const lines = [`\u5DF2\u4E0A\u4F20 ${r.path}\uFF08${r.visibility}\uFF0C${formatBytes(r.size)}\uFF09`];
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"
@@ -331,14 +336,17 @@ function rpcReply(worker, id, ok, payload) {
331
336
  ...payload?.error === void 0 ? {} : { error: payload.error }
332
337
  });
333
338
  }
339
+ var DEFAULT_FETCH_TIMEOUT_MS = 1e4;
334
340
  var WorkerFunctionExecutor = class {
335
341
  depsConfig;
336
342
  fetchConfig;
343
+ fetchTimeoutMs;
337
344
  parity;
338
345
  timeoutMaxMs;
339
346
  constructor(options = {}) {
340
347
  this.depsConfig = options.deps;
341
348
  this.fetchConfig = options.fetch;
349
+ this.fetchTimeoutMs = options.fetchTimeoutMs;
342
350
  this.parity = options.parity === true;
343
351
  this.timeoutMaxMs = options.timeoutMaxMs;
344
352
  }
@@ -356,7 +364,11 @@ var WorkerFunctionExecutor = class {
356
364
  const timeoutMs = budget.timeoutMs;
357
365
  const memoryLimitMb = input.memoryLimitMb ?? DEFAULT_MEMORY_LIMIT_MB;
358
366
  const deps = this.depsConfig === void 0 ? void 0 : resolveExecutionDeps(this.depsConfig, input.project.id, input.files["package.json"]);
359
- const effectiveFetchConfig = this.fetchConfig === void 0 ? void 0 : input.fetchAllowlist === void 0 ? this.fetchConfig : { ...this.fetchConfig, allowlist: input.fetchAllowlist };
367
+ const effectiveFetchConfig = input.fetchAllowlist === void 0 ? this.fetchConfig : {
368
+ allowlist: input.fetchAllowlist,
369
+ timeoutMs: this.fetchConfig?.timeoutMs ?? this.fetchTimeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS,
370
+ ...this.fetchConfig?.maxResponseBytes === void 0 ? {} : { maxResponseBytes: this.fetchConfig.maxResponseBytes }
371
+ };
360
372
  const logs = [];
361
373
  if (budget.clamped) {
362
374
  logs.push(
@@ -2855,6 +2867,33 @@ function createSimRealtimeCapability() {
2855
2867
  const [channel, data] = args;
2856
2868
  return sim.publish(channel, data);
2857
2869
  }
2870
+ case "issueTicket": {
2871
+ const [input] = args;
2872
+ if (typeof input !== "object" || input === null) {
2873
+ throw realtimeError(
2874
+ REALTIME_CODES.invalidArg,
2875
+ "\u7B7E\u53D1\u7968\u636E\u9700\u8981\u4E00\u4E2A\u8F93\u5165\u5BF9\u8C61 { subject, channels, ttlSeconds? }"
2876
+ );
2877
+ }
2878
+ const subject = input.subject;
2879
+ const channels = input.channels;
2880
+ if (typeof subject !== "string" || subject.length === 0) {
2881
+ throw realtimeError(
2882
+ REALTIME_CODES.invalidArg,
2883
+ "\u7B7E\u53D1\u7968\u636E\u5FC5\u987B\u5E26 subject\uFF08\u5E94\u7528\u4FA7\u7528\u6237\u6807\u8BC6\uFF09"
2884
+ );
2885
+ }
2886
+ if (!Array.isArray(channels) || channels.length === 0 || channels.some((c) => typeof c !== "string")) {
2887
+ throw realtimeError(
2888
+ REALTIME_CODES.invalidArg,
2889
+ "\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"
2890
+ );
2891
+ }
2892
+ throw realtimeError(
2893
+ REALTIME_CODES.unsupportedArg,
2894
+ "\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"
2895
+ );
2896
+ }
2858
2897
  case "subscribe": {
2859
2898
  if (buffers.size >= MAX_SUBSCRIPTIONS) {
2860
2899
  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.10",
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",
@@ -35,14 +38,14 @@
35
38
  "esbuild": "0.28.2",
36
39
  "yaml": "2.9.1",
37
40
  "zod": "^4.6.6",
38
- "@adep/app-runtime": "0.1.1",
39
- "@adep/crypto": "0.1.1",
40
- "@adep/cf-compat": "0.1.4",
41
41
  "@adep/vite-plugin": "0.1.13",
42
- "@adep/runtime": "0.3.16"
42
+ "@adep/cf-compat": "0.1.4",
43
+ "@adep/runtime": "0.3.18",
44
+ "@adep/app-runtime": "0.1.1",
45
+ "@adep/crypto": "0.1.1"
43
46
  },
44
47
  "devDependencies": {
45
- "@adep/types": "0.4.5"
48
+ "@adep/types": "0.4.7"
46
49
  },
47
50
  "scripts": {
48
51
  "test": "vitest run",