@m-kopa/launchpad-cli 0.75.2 → 0.77.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bundle/upload.d.ts +16 -0
  3. package/dist/bundle/upload.d.ts.map +1 -1
  4. package/dist/cli.js +2072 -442
  5. package/dist/commands/admin-cli-sessions.d.ts +6 -0
  6. package/dist/commands/admin-cli-sessions.d.ts.map +1 -0
  7. package/dist/commands/admin.d.ts.map +1 -1
  8. package/dist/commands/agreement.d.ts +44 -0
  9. package/dist/commands/agreement.d.ts.map +1 -0
  10. package/dist/commands/app-lints.d.ts +14 -0
  11. package/dist/commands/app-lints.d.ts.map +1 -0
  12. package/dist/commands/deploy.d.ts.map +1 -1
  13. package/dist/commands/disable.d.ts +42 -0
  14. package/dist/commands/disable.d.ts.map +1 -0
  15. package/dist/commands/init.d.ts +8 -0
  16. package/dist/commands/init.d.ts.map +1 -1
  17. package/dist/commands/login.d.ts +4 -1
  18. package/dist/commands/login.d.ts.map +1 -1
  19. package/dist/commands/skills.d.ts +1 -1
  20. package/dist/commands/skills.d.ts.map +1 -1
  21. package/dist/commands/validate.d.ts.map +1 -1
  22. package/dist/dispatcher.d.ts.map +1 -1
  23. package/dist/http/api-client.d.ts +16 -2
  24. package/dist/http/api-client.d.ts.map +1 -1
  25. package/dist/http/error-envelope.d.ts +13 -1
  26. package/dist/http/error-envelope.d.ts.map +1 -1
  27. package/dist/http/errors.d.ts +18 -0
  28. package/dist/http/errors.d.ts.map +1 -1
  29. package/dist/scaffold/secure-api-template.d.ts +57 -0
  30. package/dist/scaffold/secure-api-template.d.ts.map +1 -0
  31. package/dist/version.d.ts +1 -1
  32. package/package.json +2 -2
  33. package/skills/README.md +6 -0
  34. package/skills/launchpad-content-pr/SKILL.md +48 -7
  35. package/skills/launchpad-deploy/SKILL.md +208 -8
  36. package/skills/launchpad-deploy-status/SKILL.md +88 -3
  37. package/skills/launchpad-destroy/SKILL.md +29 -3
  38. package/skills/launchpad-identity/SKILL.md +31 -1
  39. package/skills/launchpad-ingest/SKILL.md +15 -7
  40. package/skills/launchpad-integration-contract/SKILL.md +276 -0
  41. package/skills/launchpad-onboard/SKILL.md +21 -1
  42. package/skills/launchpad-report/SKILL.md +1 -1
  43. package/skills/launchpad-status/SKILL.md +8 -1
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
21
  // src/version.ts
22
- var CLI_VERSION = "0.75.2";
22
+ var CLI_VERSION = "0.77.0";
23
23
 
24
24
  // src/config.ts
25
25
  import { readFileSync } from "node:fs";
@@ -116,9 +116,15 @@ function decodeErrorText(text, context) {
116
116
  };
117
117
  }
118
118
  }
119
- function formatErrorEnvelope(envelope) {
119
+ var REVOCATION_UNAVAILABLE_CODE = "revocation_unavailable";
120
+ var DEFAULT_REVOCATION_RETRY_AFTER_SEC = 30;
121
+ function revocationUnavailableMessage(retryAfterSec = DEFAULT_REVOCATION_RETRY_AFTER_SEC) {
122
+ return "the Launchpad session check is temporarily unavailable, so the request was not run. " + `Retry in about ${retryAfterSec} s. ` + "Do not run `launchpad login` again: logging in again does not help, " + "this is a platform fault, not a problem with your session.";
123
+ }
124
+ function formatErrorEnvelope(envelope, options = {}) {
125
+ const message = envelope.code === REVOCATION_UNAVAILABLE_CODE ? revocationUnavailableMessage(options.retryAfterSec) : envelope.message;
120
126
  const lines = [
121
- `bot returned HTTP ${envelope.status} for ${envelope.endpoint} ` + `[${envelope.code}]: ${envelope.message}`
127
+ `bot returned HTTP ${envelope.status} for ${envelope.endpoint} ` + `[${envelope.code}]: ${message}`
122
128
  ];
123
129
  if (envelope.source !== undefined || envelope.sourceSha !== undefined) {
124
130
  lines.push(`source: ${envelope.source ?? "unspecified"}` + (envelope.sourceSha === undefined ? "" : ` @ ${envelope.sourceSha ?? "none"}`));
@@ -230,6 +236,18 @@ class UnauthenticatedError extends Error {
230
236
  class ForbiddenError extends Error {
231
237
  code = "forbidden";
232
238
  }
239
+ var EXIT_AGREEMENT_REQUIRED = 43;
240
+
241
+ class AgreementRequiredError extends ForbiddenError {
242
+ reason;
243
+ version;
244
+ constructor(message, reason, version) {
245
+ super(message);
246
+ this.name = "AgreementRequiredError";
247
+ this.reason = reason;
248
+ this.version = version;
249
+ }
250
+ }
233
251
 
234
252
  class NotFoundError extends Error {
235
253
  serverCode;
@@ -291,6 +309,16 @@ class ApiError extends Error {
291
309
  }
292
310
  }
293
311
 
312
+ class RevocationUnavailableError extends ApiError {
313
+ retryAfterSec;
314
+ constructor(envelope, retryAfterSec) {
315
+ super(envelope);
316
+ this.name = "RevocationUnavailableError";
317
+ this.retryAfterSec = retryAfterSec;
318
+ this.message = formatErrorEnvelope(envelope, { retryAfterSec });
319
+ }
320
+ }
321
+
294
322
  class TransportError extends Error {
295
323
  code = "transport_error";
296
324
  }
@@ -1098,6 +1126,14 @@ function buildAuthorizationUrl(params) {
1098
1126
 
1099
1127
  // src/http/api-client.ts
1100
1128
  var MAX_ERROR_BODY_BYTES = 256 * 1024;
1129
+ var MAX_REVOCATION_RETRY_AFTER_SEC = 30;
1130
+ var revocationRetryHooks = {
1131
+ sleep: (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)),
1132
+ notice: (line) => {
1133
+ process.stderr.write(`${line}
1134
+ `);
1135
+ }
1136
+ };
1101
1137
  async function apiJson(cfg, opts, fetcher = fetch) {
1102
1138
  const res = await apiRaw(cfg, opts, fetcher);
1103
1139
  let parsed;
@@ -1141,11 +1177,29 @@ async function apiRaw(cfg, opts, fetcher = fetch) {
1141
1177
  };
1142
1178
  if (body !== undefined)
1143
1179
  init.body = body;
1144
- let res;
1145
- try {
1146
- res = await fetcher(url, init);
1147
- } catch (e) {
1148
- throw recordedFault(new TransportError(`network error calling ${url}: ${describe7(e)}`));
1180
+ if (opts.signal !== undefined)
1181
+ init.signal = opts.signal;
1182
+ const send = async () => {
1183
+ try {
1184
+ return await fetcher(url, init);
1185
+ } catch (e) {
1186
+ throw recordedFault(new TransportError(`network error calling ${url}: ${describe7(e)}`));
1187
+ }
1188
+ };
1189
+ let res = await send();
1190
+ if (res.status === 503 && await isRevocationUnavailable(res)) {
1191
+ const retryAfterSec = readRetryAfterSec(res);
1192
+ if (retryAfterSec <= MAX_REVOCATION_RETRY_AFTER_SEC) {
1193
+ await res.body?.cancel().catch(() => {
1194
+ return;
1195
+ });
1196
+ revocationRetryHooks.notice(`launchpad: the session check is temporarily unavailable; retrying once in ${retryAfterSec} s. ` + "Do not run `launchpad login` again.");
1197
+ await revocationRetryHooks.sleep(retryAfterSec * 1000);
1198
+ res = await send();
1199
+ }
1200
+ if (res.status === 503 && await isRevocationUnavailable(res)) {
1201
+ throw recordedFault(new RevocationUnavailableError(await readErrorEnvelope(res, opts.path), readRetryAfterSec(res)));
1202
+ }
1149
1203
  }
1150
1204
  if (res.status === 426) {
1151
1205
  throw recordedFault(await decodeUpgradeRequired(res, opts.path));
@@ -1156,6 +1210,9 @@ async function apiRaw(cfg, opts, fetcher = fetch) {
1156
1210
  }
1157
1211
  if (res.status === 403) {
1158
1212
  const envelope = await readErrorEnvelope(res, opts.path);
1213
+ if (envelope.code === "agreement_required") {
1214
+ throw recordedFault(new AgreementRequiredError(`${envelope.serverMessage ?? "You need to accept the Launchpad access agreement."}` + "\nRun `launchpad agreement show` to read it, then `launchpad agreement accept`.", envelope.reason ?? "none", null));
1215
+ }
1159
1216
  const hint = forbiddenHint(envelope, opts.path);
1160
1217
  throw recordedFault(new ForbiddenError(`bot returned 403 for ${opts.path}: ${formatErrorEnvelope(envelope)}` + (hint === null ? "" : `
1161
1218
  ${hint}`)));
@@ -1174,6 +1231,21 @@ ${hint}`)));
1174
1231
  clearFault();
1175
1232
  return res;
1176
1233
  }
1234
+ async function isRevocationUnavailable(res) {
1235
+ const body = await readErrorText(res.clone());
1236
+ if (body.kind !== "text")
1237
+ return false;
1238
+ const envelope = decodeErrorText(body.text, {
1239
+ status: res.status,
1240
+ endpoint: ""
1241
+ });
1242
+ return envelope.code === REVOCATION_UNAVAILABLE_CODE;
1243
+ }
1244
+ function readRetryAfterSec(res) {
1245
+ const raw = res.headers.get("retry-after");
1246
+ const n = raw === null ? NaN : Number.parseInt(raw, 10);
1247
+ return Number.isFinite(n) && n > 0 ? n : DEFAULT_REVOCATION_RETRY_AFTER_SEC;
1248
+ }
1177
1249
  async function decodeUpgradeRequired(response, endpoint) {
1178
1250
  const body = await readErrorText(response);
1179
1251
  if (body.kind === "text") {
@@ -2225,7 +2297,23 @@ function deployBundleError(envelope, body) {
2225
2297
  ...typeof body.head_sha === "string" ? { head_sha: body.head_sha } : {},
2226
2298
  ...paths === undefined ? {} : { paths },
2227
2299
  ...typeof body.reason === "string" ? { reason: body.reason } : {},
2228
- ...readDeployGuidance(body)
2300
+ ...readDeployGuidance(body),
2301
+ ...readAuditRefusal(body)
2302
+ };
2303
+ }
2304
+ function readAuditRefusal(body) {
2305
+ const holds = Array.isArray(body.holds) ? body.holds.flatMap((h) => isRecord2(h) && typeof h.flag === "string" ? [{
2306
+ flag: h.flag,
2307
+ ...typeof h.path === "string" ? { path: h.path } : {},
2308
+ ...typeof h.line === "number" ? { line: h.line } : {},
2309
+ ...typeof h.host === "string" ? { host: h.host } : {}
2310
+ }] : []) : undefined;
2311
+ const served = Array.isArray(body.served_data_findings) ? body.served_data_findings.flatMap((f) => isRecord2(f) && typeof f.path === "string" && typeof f.rule === "string" ? [{ path: f.path, rule: f.rule, columns: readStringArray(f.columns) ?? [] }] : []) : undefined;
2312
+ return {
2313
+ ...holds === undefined ? {} : { holds },
2314
+ ...served === undefined ? {} : { served_data_findings: served },
2315
+ ...typeof body.next_step === "string" ? { next_step: body.next_step } : {},
2316
+ ...typeof body.review_url === "string" ? { review_url: body.review_url } : {}
2229
2317
  };
2230
2318
  }
2231
2319
  function readDeployGuidance(body) {
@@ -2602,7 +2690,7 @@ import { join as join6 } from "node:path";
2602
2690
  import { parse as parseYaml2 } from "yaml";
2603
2691
 
2604
2692
  // ../launchpad-engine/dist/schema.js
2605
- import { z as z3 } from "zod";
2693
+ import { z as z4 } from "zod";
2606
2694
 
2607
2695
  // ../launchpad-engine/dist/audience.js
2608
2696
  import { z } from "zod";
@@ -2692,11 +2780,137 @@ ${entry.name}`;
2692
2780
  }
2693
2781
  });
2694
2782
 
2783
+ // ../launchpad-engine/dist/boundary.js
2784
+ import { z as z3 } from "zod";
2785
+ var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
2786
+ function isIsoDate(s) {
2787
+ const m = ISO_DATE.exec(s);
2788
+ if (m === null)
2789
+ return false;
2790
+ const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
2791
+ const t = new Date(Date.UTC(y, mo - 1, d));
2792
+ return t.getUTCFullYear() === y && t.getUTCMonth() === mo - 1 && t.getUTCDate() === d;
2793
+ }
2794
+ var IsoDateSchema = z3.string().refine(isIsoDate, "must be a real date in YYYY-MM-DD form (quote it in YAML)");
2795
+ var BOUNDARY_TESTS = [
2796
+ "customer",
2797
+ "sales_agent",
2798
+ "financial_accounting",
2799
+ "sensitive_data",
2800
+ "system_of_record",
2801
+ "regulatory"
2802
+ ];
2803
+ var DATA_CLASSIFICATIONS = [
2804
+ "general",
2805
+ "restricted",
2806
+ "confidential",
2807
+ "aggregated-from-restricted"
2808
+ ];
2809
+ var PERSONAL_DATA_KINDS = [
2810
+ "none",
2811
+ "staff_work_contact",
2812
+ "staff_hr",
2813
+ "customer",
2814
+ "agent",
2815
+ "third_party"
2816
+ ];
2817
+ var RESTRICTED_KINDS = [
2818
+ "compensation",
2819
+ "performance",
2820
+ "customer_personal",
2821
+ "customer_repayment",
2822
+ "device_identifier",
2823
+ "credit_or_bureau",
2824
+ "unreleased_financials",
2825
+ "security_findings",
2826
+ "credentials",
2827
+ "legal_matters",
2828
+ "other_designated"
2829
+ ];
2830
+ var AUDIENCE_SCOPES = ["team", "function", "company"];
2831
+ var BOUNDARY_VERSION = 1;
2832
+ var ReasonSchema = z3.string().trim().min(10, "reason must be at least 10 characters").max(280);
2833
+ var TestAnswerSchema = z3.object({
2834
+ answer: z3.enum(["yes", "no"]),
2835
+ reason: ReasonSchema
2836
+ }).strict();
2837
+ var TestsSchema = z3.object(Object.fromEntries(BOUNDARY_TESTS.map((t) => [t, TestAnswerSchema]))).strict();
2838
+ var BOUNDARY_HOSTNAME_REGEX = /^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
2839
+ var HostnameSchema = z3.string().max(253).regex(BOUNDARY_HOSTNAME_REGEX, "host must be a lowercase DNS name (no scheme, port, path or wildcard)");
2840
+ function uniq(a) {
2841
+ return new Set(a).size === a.length;
2842
+ }
2843
+ var BoundaryDataSchema = z3.object({
2844
+ classification: z3.enum(DATA_CLASSIFICATIONS),
2845
+ personal_data: z3.array(z3.enum(PERSONAL_DATA_KINDS)).min(1, "personal_data must list at least one kind (use [none])").refine(uniq, "personal_data must not repeat"),
2846
+ record_level: z3.boolean(),
2847
+ restricted_kinds: z3.array(z3.enum(RESTRICTED_KINDS)).refine(uniq, "restricted_kinds must not repeat").optional(),
2848
+ aggregated_at: z3.enum(["source", "in_app"]).optional(),
2849
+ retention_days: z3.number().int().min(1).max(3650).optional()
2850
+ }).strict().superRefine((d, ctx) => {
2851
+ const kinds = d.restricted_kinds ?? [];
2852
+ if (d.classification === "general") {
2853
+ if (kinds.length > 0) {
2854
+ ctx.addIssue({ code: "custom", path: ["restricted_kinds"], message: "restricted_kinds must be empty when classification is general" });
2855
+ }
2856
+ } else if (kinds.length === 0) {
2857
+ ctx.addIssue({ code: "custom", path: ["restricted_kinds"], message: `restricted_kinds must list at least one kind when classification is ${d.classification}` });
2858
+ }
2859
+ if (d.classification === "aggregated-from-restricted") {
2860
+ if (d.aggregated_at === undefined) {
2861
+ ctx.addIssue({ code: "custom", path: ["aggregated_at"], message: "aggregated_at is required when classification is aggregated-from-restricted" });
2862
+ }
2863
+ } else if (d.aggregated_at !== undefined) {
2864
+ ctx.addIssue({ code: "custom", path: ["aggregated_at"], message: "aggregated_at is only allowed when classification is aggregated-from-restricted" });
2865
+ }
2866
+ if (d.personal_data.includes("none") && d.personal_data.length > 1) {
2867
+ ctx.addIssue({ code: "custom", path: ["personal_data"], message: "personal_data: none cannot be combined with other kinds" });
2868
+ }
2869
+ });
2870
+ var OutboundSchema = z3.object({
2871
+ host: HostnameSchema,
2872
+ access: z3.enum(["read", "write"]),
2873
+ purpose: z3.string().trim().min(5).max(140),
2874
+ production: z3.boolean()
2875
+ }).strict();
2876
+ var ProductionWriteSchema = z3.object({
2877
+ system: z3.string().trim().min(2).max(60),
2878
+ host: HostnameSchema
2879
+ }).strict();
2880
+ var BoundarySchema = z3.object({
2881
+ version: z3.literal(BOUNDARY_VERSION),
2882
+ declared_on: IsoDateSchema.optional(),
2883
+ review_by: IsoDateSchema.optional(),
2884
+ tests: TestsSchema.optional(),
2885
+ audience: z3.object({
2886
+ statement: z3.string().trim().min(10).max(280),
2887
+ scope: z3.enum(AUDIENCE_SCOPES)
2888
+ }).strict().optional(),
2889
+ data: BoundaryDataSchema,
2890
+ outbound: z3.array(OutboundSchema).max(50).optional(),
2891
+ production_writes: z3.array(ProductionWriteSchema).max(20).optional(),
2892
+ owners: z3.array(z3.string().email().max(254)).min(1).max(5).refine(uniq, "owners must not repeat").optional(),
2893
+ prototype: z3.boolean().optional(),
2894
+ retire_by: IsoDateSchema.optional()
2895
+ }).strict().superRefine((b, ctx) => {
2896
+ const hosts = (b.outbound ?? []).map((o) => `${o.host}
2897
+ ${o.access}`);
2898
+ if (!uniq(hosts)) {
2899
+ ctx.addIssue({ code: "custom", path: ["outbound"], message: "outbound must not repeat the same host and access" });
2900
+ }
2901
+ });
2902
+ var UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
2903
+ var BroadAudienceAckSchema = z3.object({
2904
+ by: z3.string().trim().max(254).refine((s) => UUID_REGEX.test(s) || z3.string().email().safeParse(s).success, "by must be an Entra object id or a work email"),
2905
+ reason: ReasonSchema,
2906
+ expires: IsoDateSchema
2907
+ }).strict();
2908
+
2695
2909
  // ../launchpad-engine/dist/schema.js
2696
2910
  var APP_TYPES2 = ["static", "react", "react+api", "container"];
2697
2911
  var AUTH_MODES = ["access", "gateway"];
2698
2912
  var IDENTITY_TYPES = ["employee", "dsr"];
2699
- var IdentityTypesSchema = z3.array(z3.enum(IDENTITY_TYPES)).min(1).refine((values) => new Set(values).size === values.length, {
2913
+ var IdentityTypesSchema = z4.array(z4.enum(IDENTITY_TYPES)).min(1).refine((values) => new Set(values).size === values.length, {
2700
2914
  message: "identity_types must not contain duplicates"
2701
2915
  }).refine((values) => values.includes("employee"), {
2702
2916
  message: "identity_types must include employee"
@@ -2708,36 +2922,37 @@ var PRIMARY_TARGET = "primary";
2708
2922
  var SLUG_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
2709
2923
  var ENV_NAME_REGEX = /^[A-Z][A-Z0-9_]*$/;
2710
2924
  var SESSION_DURATION_REGEX = /^[0-9]+(s|m|h)$/;
2711
- var MetadataSchema = z3.object({
2712
- name: z3.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
2713
- team: z3.string().min(1),
2714
- owner: z3.string().email(),
2715
- description: z3.string().max(280).optional()
2925
+ var MetadataSchema = z4.object({
2926
+ name: z4.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
2927
+ team: z4.string().min(1),
2928
+ owner: z4.string().email(),
2929
+ description: z4.string().max(280).optional()
2716
2930
  }).strict();
2717
- var DeploymentSchema = z3.object({
2718
- type: z3.enum(APP_TYPES2),
2719
- runtime: z3.enum(RUNTIMES).optional()
2931
+ var DeploymentSchema = z4.object({
2932
+ type: z4.enum(APP_TYPES2),
2933
+ runtime: z4.enum(RUNTIMES).optional()
2720
2934
  }).strict();
2721
- var AccessSchema = z3.object({
2722
- audience: z3.literal("private").optional(),
2935
+ var AccessSchema = z4.object({
2936
+ audience: z4.literal("private").optional(),
2723
2937
  private_owner: PrivateOwnerSchema.optional(),
2724
- allowed_entra_group: z3.string().min(1).optional(),
2725
- allowed_entra_groups: z3.array(z3.string().min(1)).refine((arr) => new Set(arr).size === arr.length, { message: "allowed_entra_groups must not contain duplicates" }).optional(),
2726
- session_duration: z3.string().regex(SESSION_DURATION_REGEX, "must match Go duration format, e.g. 24h / 30m / 60s").optional(),
2727
- identity_types: IdentityTypesSchema.optional()
2938
+ allowed_entra_group: z4.string().min(1).optional(),
2939
+ allowed_entra_groups: z4.array(z4.string().min(1)).refine((arr) => new Set(arr).size === arr.length, { message: "allowed_entra_groups must not contain duplicates" }).optional(),
2940
+ session_duration: z4.string().regex(SESSION_DURATION_REGEX, "must match Go duration format, e.g. 24h / 30m / 60s").optional(),
2941
+ identity_types: IdentityTypesSchema.optional(),
2942
+ broad_audience_ack: BroadAudienceAckSchema.optional()
2728
2943
  }).strict().superRefine((access, ctx) => {
2729
2944
  const hasSingular = access.allowed_entra_group !== undefined;
2730
2945
  const hasPlural = access.allowed_entra_groups !== undefined;
2731
2946
  if (!hasSingular && !hasPlural && access.audience !== "private") {
2732
2947
  ctx.addIssue({
2733
- code: z3.ZodIssueCode.custom,
2948
+ code: z4.ZodIssueCode.custom,
2734
2949
  message: "either `allowed_entra_group` (singular, legacy) or `allowed_entra_groups` (plural, preferred) must be set",
2735
2950
  path: ["allowed_entra_groups"]
2736
2951
  });
2737
2952
  }
2738
2953
  if (hasSingular && hasPlural) {
2739
2954
  ctx.addIssue({
2740
- code: z3.ZodIssueCode.custom,
2955
+ code: z4.ZodIssueCode.custom,
2741
2956
  message: "`allowed_entra_group` (singular) and `allowed_entra_groups` (plural) are mutually exclusive; use the plural form",
2742
2957
  path: ["allowed_entra_groups"]
2743
2958
  });
@@ -2751,73 +2966,74 @@ function allowedEntraGroups(access) {
2751
2966
  }
2752
2967
  return [access.allowed_entra_group];
2753
2968
  }
2754
- var ContainerSchema = z3.object({
2755
- name: z3.string().min(2).max(32).regex(SLUG_REGEX, "container name must be lowercase letters, digits, and hyphens"),
2756
- image: z3.string().min(1),
2757
- port: z3.number().int().min(1).max(65535),
2758
- ingress: z3.boolean().optional(),
2759
- healthcheck: z3.string().default("/health"),
2760
- env: z3.array(z3.string().regex(ENV_NAME_REGEX, "env entries must be UPPER_SNAKE_CASE")).optional(),
2761
- max_instances: z3.number().int().min(1).max(100).optional()
2969
+ var ContainerSchema = z4.object({
2970
+ name: z4.string().min(2).max(32).regex(SLUG_REGEX, "container name must be lowercase letters, digits, and hyphens"),
2971
+ image: z4.string().min(1),
2972
+ port: z4.number().int().min(1).max(65535),
2973
+ ingress: z4.boolean().optional(),
2974
+ healthcheck: z4.string().default("/health"),
2975
+ env: z4.array(z4.string().regex(ENV_NAME_REGEX, "env entries must be UPPER_SNAKE_CASE")).optional(),
2976
+ max_instances: z4.number().int().min(1).max(100).optional()
2762
2977
  }).strict();
2763
- var TargetSchema = z3.object({
2764
- kind: z3.enum(TARGET_KINDS),
2765
- script: z3.string().min(2).max(63).regex(SLUG_REGEX, "target script must be lowercase letters, digits, and hyphens").optional(),
2766
- schedule: z3.array(z3.string().min(1).max(120)).min(1).max(20).optional(),
2767
- d1_binding: z3.string().min(1).max(64).regex(ENV_NAME_REGEX, "d1_binding must be an UPPER_SNAKE_CASE binding name").optional()
2978
+ var TargetSchema = z4.object({
2979
+ kind: z4.enum(TARGET_KINDS),
2980
+ script: z4.string().min(2).max(63).regex(SLUG_REGEX, "target script must be lowercase letters, digits, and hyphens").optional(),
2981
+ schedule: z4.array(z4.string().min(1).max(120)).min(1).max(20).optional(),
2982
+ d1_binding: z4.string().min(1).max(64).regex(ENV_NAME_REGEX, "d1_binding must be an UPPER_SNAKE_CASE binding name").optional()
2768
2983
  }).strict();
2769
- var SecretBindingSchema = z3.object({
2770
- name: z3.string().min(1).max(64).regex(ENV_NAME_REGEX, "secret binding name must be UPPER_SNAKE_CASE"),
2771
- source: z3.enum(SECRET_SOURCES),
2772
- description: z3.string().max(200).optional(),
2773
- targets: z3.union([z3.literal("all"), z3.array(z3.string().min(1)).min(1)]).optional()
2984
+ var SecretBindingSchema = z4.object({
2985
+ name: z4.string().min(1).max(64).regex(ENV_NAME_REGEX, "secret binding name must be UPPER_SNAKE_CASE"),
2986
+ source: z4.enum(SECRET_SOURCES),
2987
+ description: z4.string().max(200).optional(),
2988
+ targets: z4.union([z4.literal("all"), z4.array(z4.string().min(1)).min(1)]).optional()
2774
2989
  }).strict();
2775
- var SecretsSchema = z3.object({
2776
- bindings: z3.array(SecretBindingSchema).optional()
2990
+ var SecretsSchema = z4.object({
2991
+ bindings: z4.array(SecretBindingSchema).optional()
2777
2992
  }).strict();
2778
- var BuildSchema = z3.object({
2779
- command: z3.string().min(1).optional(),
2780
- destination_dir: z3.string().min(1),
2781
- root_dir: z3.string()
2993
+ var BuildSchema = z4.object({
2994
+ command: z4.string().min(1).optional(),
2995
+ destination_dir: z4.string().min(1),
2996
+ root_dir: z4.string()
2782
2997
  }).strict();
2783
2998
  var STATIC_SERVE_DIR = "static";
2784
2999
  function staticNoBuild() {
2785
3000
  return { destination_dir: STATIC_SERVE_DIR, root_dir: "" };
2786
3001
  }
2787
- var AppBoundarySchema = z3.object({
2788
- root: z3.string().min(1).optional(),
2789
- include: z3.array(z3.string().min(1)).min(1).optional(),
2790
- exclude: z3.array(z3.string().min(1)).optional()
3002
+ var AppBoundarySchema = z4.object({
3003
+ root: z4.string().min(1).optional(),
3004
+ include: z4.array(z4.string().min(1)).min(1).optional(),
3005
+ exclude: z4.array(z4.string().min(1)).optional()
2791
3006
  }).strict();
2792
- var ProductionEnvSchema = z3.record(z3.string().regex(ENV_NAME_REGEX, "production_env keys must be UPPER_SNAKE_CASE"), z3.string());
2793
- var VerifySchema = z3.object({
2794
- protected_path: z3.string().min(1).regex(/^\//, "verify.protected_path must be a root-relative path beginning with '/'")
3007
+ var ProductionEnvSchema = z4.record(z4.string().regex(ENV_NAME_REGEX, "production_env keys must be UPPER_SNAKE_CASE"), z4.string());
3008
+ var VerifySchema = z4.object({
3009
+ protected_path: z4.string().min(1).regex(/^\//, "verify.protected_path must be a root-relative path beginning with '/'")
2795
3010
  }).strict();
2796
- var ManifestSchema = z3.object({
2797
- apiVersion: z3.literal("launchpad.m-kopa.us/v1alpha1"),
2798
- kind: z3.literal("App"),
3011
+ var ManifestSchema = z4.object({
3012
+ apiVersion: z4.literal("launchpad.m-kopa.us/v1alpha1"),
3013
+ kind: z4.literal("App"),
2799
3014
  metadata: MetadataSchema,
2800
3015
  deployment: DeploymentSchema,
2801
3016
  access: AccessSchema,
2802
- auth: z3.enum(AUTH_MODES).optional(),
2803
- hostnames: z3.array(z3.string().min(1)).optional(),
2804
- containers: z3.array(ContainerSchema).min(1).optional(),
3017
+ auth: z4.enum(AUTH_MODES).optional(),
3018
+ hostnames: z4.array(z4.string().min(1)).optional(),
3019
+ containers: z4.array(ContainerSchema).min(1).optional(),
2805
3020
  secrets: SecretsSchema.optional(),
2806
- targets: z3.array(TargetSchema).optional(),
3021
+ targets: z4.array(TargetSchema).optional(),
2807
3022
  build: BuildSchema.optional(),
2808
3023
  production_env: ProductionEnvSchema.optional(),
2809
3024
  app: AppBoundarySchema.optional(),
2810
3025
  verify: VerifySchema.optional(),
2811
- confine_origin: z3.boolean().optional(),
2812
- origin: z3.enum(["pages", "dispatch"]).optional(),
2813
- catalogue: z3.object({ listed: z3.boolean().default(true) }).strict().optional(),
2814
- sensitive: z3.boolean().optional(),
2815
- integrations: IntegrationsSchema.optional()
3026
+ confine_origin: z4.boolean().optional(),
3027
+ origin: z4.enum(["pages", "dispatch"]).optional(),
3028
+ catalogue: z4.object({ listed: z4.boolean().default(true) }).strict().optional(),
3029
+ sensitive: z4.boolean().optional(),
3030
+ integrations: IntegrationsSchema.optional(),
3031
+ boundary: BoundarySchema.optional()
2816
3032
  }).strict().superRefine((m, ctx) => {
2817
3033
  const isContainer = m.deployment.type === "container";
2818
3034
  if (m.access.identity_types !== undefined && (m.auth ?? "access") !== "gateway") {
2819
3035
  ctx.addIssue({
2820
- code: z3.ZodIssueCode.custom,
3036
+ code: z4.ZodIssueCode.custom,
2821
3037
  path: ["access", "identity_types"],
2822
3038
  message: "access.identity_types is only valid with auth: gateway"
2823
3039
  });
@@ -2825,19 +3041,19 @@ var ManifestSchema = z3.object({
2825
3041
  if (m.confine_origin !== undefined) {
2826
3042
  if (isContainer) {
2827
3043
  ctx.addIssue({
2828
- code: z3.ZodIssueCode.custom,
3044
+ code: z4.ZodIssueCode.custom,
2829
3045
  path: ["confine_origin"],
2830
3046
  message: "confine_origin is only valid for gateway pages apps (static/react/react+api); container apps have no pages.dev surface."
2831
3047
  });
2832
3048
  } else if (m.auth === "access") {
2833
3049
  ctx.addIssue({
2834
- code: z3.ZodIssueCode.custom,
3050
+ code: z4.ZodIssueCode.custom,
2835
3051
  path: ["confine_origin"],
2836
3052
  message: "confine_origin applies to gateway-fronted apps (auth: gateway); it has no meaning under Cloudflare Access."
2837
3053
  });
2838
3054
  } else if (m.deployment.type === "static" && m.confine_origin === false) {
2839
3055
  ctx.addIssue({
2840
- code: z3.ZodIssueCode.custom,
3056
+ code: z4.ZodIssueCode.custom,
2841
3057
  path: ["confine_origin"],
2842
3058
  message: "confine_origin: false is not allowed for static apps — they have no verifier, so an unconfined apex would be world-readable (ADR 0031)."
2843
3059
  });
@@ -2845,35 +3061,35 @@ var ManifestSchema = z3.object({
2845
3061
  }
2846
3062
  if (isContainer && m.containers === undefined) {
2847
3063
  ctx.addIssue({
2848
- code: z3.ZodIssueCode.custom,
3064
+ code: z4.ZodIssueCode.custom,
2849
3065
  path: ["containers"],
2850
3066
  message: "containers[] is required when deployment.type is 'container'"
2851
3067
  });
2852
3068
  }
2853
3069
  if (!isContainer && m.containers !== undefined) {
2854
3070
  ctx.addIssue({
2855
- code: z3.ZodIssueCode.custom,
3071
+ code: z4.ZodIssueCode.custom,
2856
3072
  path: ["containers"],
2857
3073
  message: `containers[] is only allowed when deployment.type is 'container' (current type: '${m.deployment.type}')`
2858
3074
  });
2859
3075
  }
2860
3076
  if (!isContainer && m.deployment.runtime !== undefined) {
2861
3077
  ctx.addIssue({
2862
- code: z3.ZodIssueCode.custom,
3078
+ code: z4.ZodIssueCode.custom,
2863
3079
  path: ["deployment", "runtime"],
2864
3080
  message: "deployment.runtime is only meaningful when deployment.type is 'container'"
2865
3081
  });
2866
3082
  }
2867
3083
  if (isContainer && m.build !== undefined) {
2868
3084
  ctx.addIssue({
2869
- code: z3.ZodIssueCode.custom,
3085
+ code: z4.ZodIssueCode.custom,
2870
3086
  path: ["build"],
2871
3087
  message: "build is only allowed for pages-app deployments (static/react/react+api). Container builds live in the Dockerfile."
2872
3088
  });
2873
3089
  }
2874
3090
  if (isContainer && m.production_env !== undefined) {
2875
3091
  ctx.addIssue({
2876
- code: z3.ZodIssueCode.custom,
3092
+ code: z4.ZodIssueCode.custom,
2877
3093
  path: ["production_env"],
2878
3094
  message: "production_env is only allowed for pages-app deployments. Container env vars use containers[].env (names only) + the bot's secrets pipeline for values."
2879
3095
  });
@@ -2882,7 +3098,7 @@ var ManifestSchema = z3.object({
2882
3098
  const ingressContainers = m.containers.filter((c) => c.ingress === true);
2883
3099
  if (ingressContainers.length !== 1) {
2884
3100
  ctx.addIssue({
2885
- code: z3.ZodIssueCode.custom,
3101
+ code: z4.ZodIssueCode.custom,
2886
3102
  path: ["containers"],
2887
3103
  message: `multi-container apps must mark exactly one container ingress: true (found ${ingressContainers.length})`
2888
3104
  });
@@ -2895,7 +3111,7 @@ var ManifestSchema = z3.object({
2895
3111
  for (const envName of c.env ?? []) {
2896
3112
  if (!declaredBindings.has(envName)) {
2897
3113
  ctx.addIssue({
2898
- code: z3.ZodIssueCode.custom,
3114
+ code: z4.ZodIssueCode.custom,
2899
3115
  path: ["containers", i, "env"],
2900
3116
  message: `env reference '${envName}' has no matching entry in secrets.bindings[]`
2901
3117
  });
@@ -2911,7 +3127,7 @@ var ManifestSchema = z3.object({
2911
3127
  continue;
2912
3128
  if (seen.has(name)) {
2913
3129
  ctx.addIssue({
2914
- code: z3.ZodIssueCode.custom,
3130
+ code: z4.ZodIssueCode.custom,
2915
3131
  path: ["containers", i, "name"],
2916
3132
  message: `duplicate container name '${name}' — names become DO class identifiers and must be unique`
2917
3133
  });
@@ -2928,7 +3144,7 @@ var ManifestSchema = z3.object({
2928
3144
  continue;
2929
3145
  if (seen.has(name)) {
2930
3146
  ctx.addIssue({
2931
- code: z3.ZodIssueCode.custom,
3147
+ code: z4.ZodIssueCode.custom,
2932
3148
  path: ["secrets", "bindings", i, "name"],
2933
3149
  message: `duplicate secret binding name '${name}' — names become env-var keys and must be unique`
2934
3150
  });
@@ -2941,21 +3157,21 @@ var ManifestSchema = z3.object({
2941
3157
  const t = targets[i];
2942
3158
  if (t.kind === "worker" && t.script === undefined) {
2943
3159
  ctx.addIssue({
2944
- code: z3.ZodIssueCode.custom,
3160
+ code: z4.ZodIssueCode.custom,
2945
3161
  path: ["targets", i, "script"],
2946
3162
  message: "a worker target must declare a script (the sibling Workers script name)"
2947
3163
  });
2948
3164
  }
2949
3165
  if (t.kind === "pages" && t.script !== undefined) {
2950
3166
  ctx.addIssue({
2951
- code: z3.ZodIssueCode.custom,
3167
+ code: z4.ZodIssueCode.custom,
2952
3168
  path: ["targets", i, "script"],
2953
3169
  message: "a pages target must not declare a script — the primary Pages project is the app slug"
2954
3170
  });
2955
3171
  }
2956
3172
  if (t.kind === "pages" && t.schedule !== undefined) {
2957
3173
  ctx.addIssue({
2958
- code: z3.ZodIssueCode.custom,
3174
+ code: z4.ZodIssueCode.custom,
2959
3175
  path: ["targets", i, "schedule"],
2960
3176
  message: "schedule is only valid on a worker target (the cron deploy contract — ADR 0022)"
2961
3177
  });
@@ -2969,7 +3185,7 @@ var ManifestSchema = z3.object({
2969
3185
  pagesTargets++;
2970
3186
  if (pagesTargets > 1) {
2971
3187
  ctx.addIssue({
2972
- code: z3.ZodIssueCode.custom,
3188
+ code: z4.ZodIssueCode.custom,
2973
3189
  path: ["targets", i, "kind"],
2974
3190
  message: "at most one pages target may be declared (the primary Pages project is singular)"
2975
3191
  });
@@ -2980,7 +3196,7 @@ var ManifestSchema = z3.object({
2980
3196
  continue;
2981
3197
  if (t.script === PRIMARY_TARGET || t.script === "pages") {
2982
3198
  ctx.addIssue({
2983
- code: z3.ZodIssueCode.custom,
3199
+ code: z4.ZodIssueCode.custom,
2984
3200
  path: ["targets", i, "script"],
2985
3201
  message: `worker target script '${t.script}' is a reserved selector token — use a different script name`
2986
3202
  });
@@ -2988,7 +3204,7 @@ var ManifestSchema = z3.object({
2988
3204
  }
2989
3205
  if (seenScripts.has(t.script)) {
2990
3206
  ctx.addIssue({
2991
- code: z3.ZodIssueCode.custom,
3207
+ code: z4.ZodIssueCode.custom,
2992
3208
  path: ["targets", i, "script"],
2993
3209
  message: `duplicate worker target script '${t.script}' — target scripts must be unique`
2994
3210
  });
@@ -3006,7 +3222,7 @@ var ManifestSchema = z3.object({
3006
3222
  for (const ref of sel) {
3007
3223
  if (!validRefs.has(ref)) {
3008
3224
  ctx.addIssue({
3009
- code: z3.ZodIssueCode.custom,
3225
+ code: z4.ZodIssueCode.custom,
3010
3226
  path: ["secrets", "bindings", bi, "targets"],
3011
3227
  message: `secret binding '${b?.name}' references unknown target '${ref}' — declare it in targets[] or use "primary"`
3012
3228
  });
@@ -3422,51 +3638,57 @@ var STATUS_STATUS_KEYS = new Set([
3422
3638
  "status.generated_at"
3423
3639
  ]);
3424
3640
  // ../launchpad-engine/dist/schema-v2.js
3425
- import { z as z4 } from "zod";
3426
- var EnvVarSchema = z4.discriminatedUnion("type", [
3427
- z4.object({ type: z4.literal("secret_text"), secret_ref: z4.string().min(1) }).strict(),
3428
- z4.object({ type: z4.literal("plain_text"), value: z4.string() }).strict()
3641
+ import { z as z5 } from "zod";
3642
+ var EnvVarSchema = z5.discriminatedUnion("type", [
3643
+ z5.object({ type: z5.literal("secret_text"), secret_ref: z5.string().min(1) }).strict(),
3644
+ z5.object({ type: z5.literal("plain_text"), value: z5.string() }).strict()
3429
3645
  ]);
3430
3646
  var MIGRATION_STAGES = ["staged", "flipped"];
3431
- var SpecSchema = z4.object({
3432
- appType: z4.enum(APP_TYPES2),
3433
- display: z4.object({
3434
- name: z4.string().min(1),
3435
- description: z4.string().max(280).optional(),
3436
- team: z4.string().min(1)
3647
+ var SpecSchema = z5.object({
3648
+ appType: z5.enum(APP_TYPES2),
3649
+ display: z5.object({
3650
+ name: z5.string().min(1),
3651
+ description: z5.string().max(280).optional(),
3652
+ team: z5.string().min(1)
3437
3653
  }).strict(),
3438
- owner: z4.object({ email: z4.string().email() }).strict(),
3439
- access: z4.object({
3440
- audience: z4.literal("private").optional(),
3654
+ owner: z5.object({ email: z5.string().email() }).strict(),
3655
+ access: z5.object({
3656
+ audience: z5.literal("private").optional(),
3441
3657
  private_owner: PrivateOwnerSchema.optional(),
3442
- allowed_entra_groups: z4.array(z4.string().min(1)).refine((a) => new Set(a).size === a.length, {
3658
+ allowed_entra_groups: z5.array(z5.string().min(1)).refine((a) => new Set(a).size === a.length, {
3443
3659
  message: "allowed_entra_groups must not contain duplicates"
3444
3660
  }),
3445
- require_email_domain: z4.string().min(1).optional(),
3446
- identity_types: IdentityTypesSchema.optional()
3661
+ require_email_domain: z5.string().min(1).optional(),
3662
+ identity_types: IdentityTypesSchema.optional(),
3663
+ broad_audience_ack: BroadAudienceAckSchema.optional()
3447
3664
  }).strict().superRefine(validateAudience),
3448
- auth: z4.enum(AUTH_MODES).optional(),
3665
+ auth: z5.enum(AUTH_MODES).optional(),
3449
3666
  build: BuildSchema.optional(),
3450
3667
  app: AppBoundarySchema.optional(),
3451
3668
  verify: VerifySchema.optional(),
3452
- confine_origin: z4.boolean().optional(),
3453
- origin: z4.enum(["pages", "dispatch"]).optional(),
3454
- sensitive: z4.boolean().optional(),
3669
+ confine_origin: z5.boolean().optional(),
3670
+ origin: z5.enum(["pages", "dispatch"]).optional(),
3671
+ sensitive: z5.boolean().optional(),
3672
+ lifecycle: z5.object({
3673
+ disabled: z5.boolean(),
3674
+ reason: z5.string().regex(/^[A-Za-z0-9 ._:#/-]{1,120}$/, "lifecycle.reason must be a ticket reference").optional()
3675
+ }).strict().optional(),
3455
3676
  integrations: IntegrationsSchema.optional(),
3456
- catalogue: z4.object({ listed: z4.boolean().default(true) }).strict().optional(),
3457
- env_vars: z4.record(z4.string().regex(ENV_NAME_REGEX, "env_vars keys must be UPPER_SNAKE_CASE"), EnvVarSchema).optional(),
3458
- containers: z4.array(ContainerSchema).min(1).optional(),
3677
+ catalogue: z5.object({ listed: z5.boolean().default(true) }).strict().optional(),
3678
+ env_vars: z5.record(z5.string().regex(ENV_NAME_REGEX, "env_vars keys must be UPPER_SNAKE_CASE"), EnvVarSchema).optional(),
3679
+ containers: z5.array(ContainerSchema).min(1).optional(),
3459
3680
  secrets: SecretsSchema.optional(),
3460
- fronted_by_concierge: z4.boolean().optional(),
3461
- migration: z4.object({ stage: z4.enum(MIGRATION_STAGES) }).strict().optional(),
3462
- bindings: z4.object({
3463
- d1: z4.string().min(1).max(64).regex(ENV_NAME_REGEX, "bindings.d1 must be an UPPER_SNAKE_CASE binding name").optional()
3681
+ fronted_by_concierge: z5.boolean().optional(),
3682
+ migration: z5.object({ stage: z5.enum(MIGRATION_STAGES) }).strict().optional(),
3683
+ bindings: z5.object({
3684
+ d1: z5.string().min(1).max(64).regex(ENV_NAME_REGEX, "bindings.d1 must be an UPPER_SNAKE_CASE binding name").optional()
3464
3685
  }).strict().optional(),
3465
- targets: z4.array(TargetSchema).min(1).max(1).optional()
3686
+ targets: z5.array(TargetSchema).min(1).max(1).optional(),
3687
+ boundary: BoundarySchema.optional()
3466
3688
  }).strict().superRefine((s, ctx) => {
3467
3689
  if (s.access.identity_types !== undefined && (s.auth ?? "access") !== "gateway") {
3468
3690
  ctx.addIssue({
3469
- code: z4.ZodIssueCode.custom,
3691
+ code: z5.ZodIssueCode.custom,
3470
3692
  path: ["access", "identity_types"],
3471
3693
  message: "access.identity_types is only valid with auth: gateway"
3472
3694
  });
@@ -3474,7 +3696,7 @@ var SpecSchema = z4.object({
3474
3696
  for (const [k, v] of Object.entries(s.env_vars ?? {})) {
3475
3697
  if (/_(TOKEN|SECRET)$/.test(k) && v.type !== "secret_text") {
3476
3698
  ctx.addIssue({
3477
- code: z4.ZodIssueCode.custom,
3699
+ code: z5.ZodIssueCode.custom,
3478
3700
  path: ["env_vars", k],
3479
3701
  message: `env var '${k}' is secret-bearing (*_TOKEN/*_SECRET) and must be type secret_text, not '${v.type}'`
3480
3702
  });
@@ -3483,7 +3705,7 @@ var SpecSchema = z4.object({
3483
3705
  const isContainer = s.appType === "container";
3484
3706
  if (isContainer && s.containers === undefined) {
3485
3707
  ctx.addIssue({
3486
- code: z4.ZodIssueCode.custom,
3708
+ code: z5.ZodIssueCode.custom,
3487
3709
  path: ["containers"],
3488
3710
  message: "containers[] is required when appType is 'container'"
3489
3711
  });
@@ -3491,19 +3713,19 @@ var SpecSchema = z4.object({
3491
3713
  if (s.confine_origin !== undefined) {
3492
3714
  if (isContainer) {
3493
3715
  ctx.addIssue({
3494
- code: z4.ZodIssueCode.custom,
3716
+ code: z5.ZodIssueCode.custom,
3495
3717
  path: ["confine_origin"],
3496
3718
  message: "confine_origin is only valid for gateway pages apps; container apps have no pages.dev surface."
3497
3719
  });
3498
3720
  } else if (s.auth === "access") {
3499
3721
  ctx.addIssue({
3500
- code: z4.ZodIssueCode.custom,
3722
+ code: z5.ZodIssueCode.custom,
3501
3723
  path: ["confine_origin"],
3502
3724
  message: "confine_origin applies to gateway-fronted apps (auth: gateway); it has no meaning under Cloudflare Access."
3503
3725
  });
3504
3726
  } else if (s.appType === "static" && s.confine_origin === false) {
3505
3727
  ctx.addIssue({
3506
- code: z4.ZodIssueCode.custom,
3728
+ code: z5.ZodIssueCode.custom,
3507
3729
  path: ["confine_origin"],
3508
3730
  message: "confine_origin: false is not allowed for static apps — an unconfined apex with no verifier is world-readable (ADR 0031)."
3509
3731
  });
@@ -3512,21 +3734,21 @@ var SpecSchema = z4.object({
3512
3734
  if (s.origin === "dispatch") {
3513
3735
  if (isContainer) {
3514
3736
  ctx.addIssue({
3515
- code: z4.ZodIssueCode.custom,
3737
+ code: z5.ZodIssueCode.custom,
3516
3738
  path: ["origin"],
3517
3739
  message: "origin: dispatch is not available for container apps — they run on the container runtime (ADR 0015/0016), not in a Workers dispatch namespace."
3518
3740
  });
3519
3741
  }
3520
3742
  if ((s.auth ?? "access") !== "gateway") {
3521
3743
  ctx.addIssue({
3522
- code: z4.ZodIssueCode.custom,
3744
+ code: z5.ZodIssueCode.custom,
3523
3745
  path: ["origin"],
3524
3746
  message: "origin: dispatch requires an explicit auth: gateway (auth defaults to 'access' when omitted). A dispatch-namespace Worker has no public hostname for Cloudflare Access to gate, so the gateway must be the sole gate."
3525
3747
  });
3526
3748
  }
3527
3749
  if (s.confine_origin !== undefined && s.migration === undefined) {
3528
3750
  ctx.addIssue({
3529
- code: z4.ZodIssueCode.custom,
3751
+ code: z5.ZodIssueCode.custom,
3530
3752
  path: ["confine_origin"],
3531
3753
  message: "confine_origin has no meaning with origin: dispatch — there is no public pages.dev apex to confine. Remove it."
3532
3754
  });
@@ -3535,14 +3757,14 @@ var SpecSchema = z4.object({
3535
3757
  if (s.migration !== undefined) {
3536
3758
  if (s.origin !== "dispatch") {
3537
3759
  ctx.addIssue({
3538
- code: z4.ZodIssueCode.custom,
3760
+ code: z5.ZodIssueCode.custom,
3539
3761
  path: ["migration"],
3540
3762
  message: "migration is only valid with origin: dispatch; the portal-bot writes it while moving a live app."
3541
3763
  });
3542
3764
  }
3543
3765
  if (s.appType !== "static" && s.appType !== "react" && s.appType !== "react+api") {
3544
3766
  ctx.addIssue({
3545
- code: z4.ZodIssueCode.custom,
3767
+ code: z5.ZodIssueCode.custom,
3546
3768
  path: ["migration"],
3547
3769
  message: `migration is only valid for static, react and react+api apps (current appType: '${s.appType}')`
3548
3770
  });
@@ -3551,20 +3773,20 @@ var SpecSchema = z4.object({
3551
3773
  if (s.bindings?.d1 !== undefined) {
3552
3774
  if (s.origin !== "dispatch") {
3553
3775
  ctx.addIssue({
3554
- code: z4.ZodIssueCode.custom,
3776
+ code: z5.ZodIssueCode.custom,
3555
3777
  path: ["bindings", "d1"],
3556
3778
  message: "bindings.d1 requires origin: dispatch. A pages-origin app declares its database with a v1 pages target d1_binding."
3557
3779
  });
3558
3780
  } else if (s.appType !== "react+api") {
3559
3781
  ctx.addIssue({
3560
- code: z4.ZodIssueCode.custom,
3782
+ code: z5.ZodIssueCode.custom,
3561
3783
  path: ["bindings", "d1"],
3562
3784
  message: `bindings.d1 requires appType 'react+api' (current appType: '${s.appType}'); only a react+api app ships the Worker code that can read a database.`
3563
3785
  });
3564
3786
  }
3565
3787
  if (s.env_vars?.[s.bindings.d1] !== undefined) {
3566
3788
  ctx.addIssue({
3567
- code: z4.ZodIssueCode.custom,
3789
+ code: z5.ZodIssueCode.custom,
3568
3790
  path: ["env_vars", s.bindings.d1],
3569
3791
  message: `env var '${s.bindings.d1}' has the same name as bindings.d1. Rename one of them.`
3570
3792
  });
@@ -3573,7 +3795,7 @@ var SpecSchema = z4.object({
3573
3795
  if (s.targets !== undefined) {
3574
3796
  if (s.origin !== "dispatch") {
3575
3797
  ctx.addIssue({
3576
- code: z4.ZodIssueCode.custom,
3798
+ code: z5.ZodIssueCode.custom,
3577
3799
  path: ["targets"],
3578
3800
  message: "targets requires origin: dispatch. A pages-origin app declares its cron Worker in a v1 manifest."
3579
3801
  });
@@ -3582,7 +3804,7 @@ var SpecSchema = z4.object({
3582
3804
  const t = s.targets[i];
3583
3805
  if (t.kind !== "worker") {
3584
3806
  ctx.addIssue({
3585
- code: z4.ZodIssueCode.custom,
3807
+ code: z5.ZodIssueCode.custom,
3586
3808
  path: ["targets", i, "kind"],
3587
3809
  message: "a dispatch app has no Pages project, so the only valid target kind is 'worker' (the cron sibling Worker)"
3588
3810
  });
@@ -3590,27 +3812,27 @@ var SpecSchema = z4.object({
3590
3812
  }
3591
3813
  if (t.script === undefined) {
3592
3814
  ctx.addIssue({
3593
- code: z4.ZodIssueCode.custom,
3815
+ code: z5.ZodIssueCode.custom,
3594
3816
  path: ["targets", i, "script"],
3595
3817
  message: "a worker target must declare a script (the sibling Workers script name)"
3596
3818
  });
3597
3819
  } else if (t.script === PRIMARY_TARGET || t.script === "pages") {
3598
3820
  ctx.addIssue({
3599
- code: z4.ZodIssueCode.custom,
3821
+ code: z5.ZodIssueCode.custom,
3600
3822
  path: ["targets", i, "script"],
3601
3823
  message: `worker target script '${t.script}' is a reserved selector token — use a different script name`
3602
3824
  });
3603
3825
  }
3604
3826
  if (t.schedule === undefined) {
3605
3827
  ctx.addIssue({
3606
- code: z4.ZodIssueCode.custom,
3828
+ code: z5.ZodIssueCode.custom,
3607
3829
  path: ["targets", i, "schedule"],
3608
3830
  message: "a dispatch worker target must declare a non-empty schedule; the cron sibling is the only thing spec.targets carries on dispatch"
3609
3831
  });
3610
3832
  }
3611
3833
  if (t.d1_binding !== undefined) {
3612
3834
  ctx.addIssue({
3613
- code: z4.ZodIssueCode.custom,
3835
+ code: z5.ZodIssueCode.custom,
3614
3836
  path: ["targets", i, "d1_binding"],
3615
3837
  message: "d1_binding is not supported on a dispatch worker target. Declare the app's database with bindings.d1."
3616
3838
  });
@@ -3619,86 +3841,86 @@ var SpecSchema = z4.object({
3619
3841
  }
3620
3842
  if (!isContainer && s.containers !== undefined) {
3621
3843
  ctx.addIssue({
3622
- code: z4.ZodIssueCode.custom,
3844
+ code: z5.ZodIssueCode.custom,
3623
3845
  path: ["containers"],
3624
3846
  message: `containers[] is only allowed when appType is 'container' (current appType: '${s.appType}')`
3625
3847
  });
3626
3848
  }
3627
3849
  if (isContainer && s.build !== undefined) {
3628
3850
  ctx.addIssue({
3629
- code: z4.ZodIssueCode.custom,
3851
+ code: z5.ZodIssueCode.custom,
3630
3852
  path: ["build"],
3631
3853
  message: "build is not allowed when appType is 'container' (container build lives in the Dockerfile)"
3632
3854
  });
3633
3855
  }
3634
3856
  if (!isContainer && s.fronted_by_concierge === true) {
3635
3857
  ctx.addIssue({
3636
- code: z4.ZodIssueCode.custom,
3858
+ code: z5.ZodIssueCode.custom,
3637
3859
  path: ["fronted_by_concierge"],
3638
3860
  message: `fronted_by_concierge is only allowed when appType is 'container' (current appType: '${s.appType}')`
3639
3861
  });
3640
3862
  }
3641
3863
  });
3642
- var nonEmpty = z4.string().min(1);
3643
- var StatusSchema = z4.object({
3644
- schemaVersion: z4.literal(2),
3864
+ var nonEmpty = z5.string().min(1);
3865
+ var StatusSchema = z5.object({
3866
+ schemaVersion: z5.literal(2),
3645
3867
  manifest_spec_sha: nonEmpty,
3646
- cloudflare: z4.object({
3647
- access: z4.object({
3868
+ cloudflare: z5.object({
3869
+ access: z5.object({
3648
3870
  app_id: nonEmpty,
3649
3871
  app_aud: nonEmpty,
3650
3872
  team_domain: nonEmpty,
3651
3873
  policy_id: nonEmpty
3652
3874
  }).strict(),
3653
- pages: z4.object({
3875
+ pages: z5.object({
3654
3876
  project_name: nonEmpty,
3655
3877
  subdomain: nonEmpty,
3656
3878
  latest_deployment_id: nonEmpty
3657
3879
  }).strict().optional(),
3658
- worker: z4.object({
3880
+ worker: z5.object({
3659
3881
  dev_url: nonEmpty,
3660
3882
  script_name: nonEmpty
3661
3883
  }).strict().optional()
3662
3884
  }).strict(),
3663
- dns: z4.object({ custom_hostname: nonEmpty, cname_target: nonEmpty }).strict().optional(),
3664
- terraform: z4.object({
3885
+ dns: z5.object({ custom_hostname: nonEmpty, cname_target: nonEmpty }).strict().optional(),
3886
+ terraform: z5.object({
3665
3887
  workspace_state_key: nonEmpty,
3666
3888
  last_applied_at: nonEmpty,
3667
3889
  last_applied_sha: nonEmpty
3668
3890
  }).strict(),
3669
- registry: z4.object({ record_present: z4.boolean(), lifecycle: nonEmpty }).strict(),
3891
+ registry: z5.object({ record_present: z5.boolean(), lifecycle: nonEmpty }).strict(),
3670
3892
  generated_at: nonEmpty
3671
3893
  }).strict().superRefine((s, ctx) => {
3672
3894
  const hasPages = s.cloudflare.pages !== undefined;
3673
3895
  const hasWorker = s.cloudflare.worker !== undefined;
3674
3896
  if (hasPages === hasWorker) {
3675
3897
  ctx.addIssue({
3676
- code: z4.ZodIssueCode.custom,
3898
+ code: z5.ZodIssueCode.custom,
3677
3899
  path: ["cloudflare"],
3678
3900
  message: "status.cloudflare must carry exactly one of `pages` (pages apps) or `worker` (container apps)"
3679
3901
  });
3680
3902
  }
3681
3903
  if (hasPages && s.dns === undefined) {
3682
3904
  ctx.addIssue({
3683
- code: z4.ZodIssueCode.custom,
3905
+ code: z5.ZodIssueCode.custom,
3684
3906
  path: ["dns"],
3685
3907
  message: "status.dns is required for a pages-shape status (cloudflare.pages present)"
3686
3908
  });
3687
3909
  }
3688
3910
  if (hasWorker && s.dns !== undefined) {
3689
3911
  ctx.addIssue({
3690
- code: z4.ZodIssueCode.custom,
3912
+ code: z5.ZodIssueCode.custom,
3691
3913
  path: ["dns"],
3692
3914
  message: "status.dns must be absent for a workers_dev_only container status (no custom hostname)"
3693
3915
  });
3694
3916
  }
3695
3917
  });
3696
- var ManifestV2Schema = z4.object({
3697
- apiVersion: z4.literal("launchpad.m-kopa.us/v2"),
3698
- kind: z4.literal("App"),
3699
- metadata: z4.object({
3700
- slug: z4.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
3701
- schemaVersion: z4.literal(2)
3918
+ var ManifestV2Schema = z5.object({
3919
+ apiVersion: z5.literal("launchpad.m-kopa.us/v2"),
3920
+ kind: z5.literal("App"),
3921
+ metadata: z5.object({
3922
+ slug: z5.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
3923
+ schemaVersion: z5.literal(2)
3702
3924
  }).strict(),
3703
3925
  spec: SpecSchema,
3704
3926
  status: StatusSchema.optional()
@@ -3707,7 +3929,7 @@ var ManifestV2Schema = z4.object({
3707
3929
  (m.spec.targets ?? []).forEach((t, i) => {
3708
3930
  if (t.kind === "worker" && t.script !== undefined && !t.script.startsWith(prefix)) {
3709
3931
  ctx.addIssue({
3710
- code: z4.ZodIssueCode.custom,
3932
+ code: z5.ZodIssueCode.custom,
3711
3933
  path: ["spec", "targets", i, "script"],
3712
3934
  message: `worker target script '${t.script}' must start with '${prefix}' (the app slug plus a dash)`
3713
3935
  });
@@ -4885,8 +5107,9 @@ function assertBroadGroupsWellFormed(list = BROAD_GROUPS) {
4885
5107
  }
4886
5108
  assertBroadGroupsWellFormed();
4887
5109
  var BROAD_UUIDS = new Set(BROAD_GROUPS.map((g) => canonicalUuid(g.uuid)).filter((u) => u !== null));
5110
+ var BROAD_NAMES = new Set(BROAD_GROUPS.map((g) => g.name.trim().toLowerCase()));
4888
5111
  // ../launchpad-engine/dist/fleet-manifest.js
4889
- import { z as z5 } from "zod";
5112
+ import { z as z6 } from "zod";
4890
5113
  var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
4891
5114
  var TF_RESIDENCIES = ["per-app-workspace", "main-tf"];
4892
5115
  var APP_SHAPES = [
@@ -4914,22 +5137,22 @@ var FLEET_TIERS = [
4914
5137
  "out-of-scope"
4915
5138
  ];
4916
5139
  var DEVICE_POSTURE = ["gateway-eligible", "retained-access"];
4917
- var GroupId = z5.string().regex(UUID_RE, "Entra group ids are emitted as canonical UUIDs in the JWT groups claim — display names will not match policies.");
4918
- var FleetAppSchema = z5.object({
4919
- slug: z5.string().regex(SLUG_REGEX),
4920
- residency: z5.enum(TF_RESIDENCIES),
4921
- shape: z5.enum(APP_SHAPES),
4922
- declaredAuth: z5.enum(DECLARED_AUTH),
4923
- actualAuth: z5.enum(ACTUAL_AUTH),
4924
- groups: z5.array(GroupId).default([]),
4925
- tier: z5.enum(FLEET_TIERS),
4926
- devicePosture: z5.enum(DEVICE_POSTURE),
4927
- devicePostureReason: z5.string().trim().min(1, "devicePosture is only valid with a non-empty reason — the two-tier determination must be a surveyed output, not a default (AC-T0-3)."),
4928
- notes: z5.string().optional()
5140
+ var GroupId = z6.string().regex(UUID_RE, "Entra group ids are emitted as canonical UUIDs in the JWT groups claim — display names will not match policies.");
5141
+ var FleetAppSchema = z6.object({
5142
+ slug: z6.string().regex(SLUG_REGEX),
5143
+ residency: z6.enum(TF_RESIDENCIES),
5144
+ shape: z6.enum(APP_SHAPES),
5145
+ declaredAuth: z6.enum(DECLARED_AUTH),
5146
+ actualAuth: z6.enum(ACTUAL_AUTH),
5147
+ groups: z6.array(GroupId).default([]),
5148
+ tier: z6.enum(FLEET_TIERS),
5149
+ devicePosture: z6.enum(DEVICE_POSTURE),
5150
+ devicePostureReason: z6.string().trim().min(1, "devicePosture is only valid with a non-empty reason — the two-tier determination must be a surveyed output, not a default (AC-T0-3)."),
5151
+ notes: z6.string().optional()
4929
5152
  }).strict();
4930
- var FleetManifestSchema = z5.object({
4931
- schemaVersion: z5.literal(1),
4932
- apps: z5.array(FleetAppSchema).min(1)
5153
+ var FleetManifestSchema = z6.object({
5154
+ schemaVersion: z6.literal(1),
5155
+ apps: z6.array(FleetAppSchema).min(1)
4933
5156
  }).strict().superRefine((m, ctx) => {
4934
5157
  const seen = new Set;
4935
5158
  for (const app of m.apps) {
@@ -4951,23 +5174,23 @@ var FleetManifestSchema = z5.object({
4951
5174
  }
4952
5175
  });
4953
5176
  // ../launchpad-engine/dist/fleet-secret-sets.js
4954
- import { z as z6 } from "zod";
5177
+ import { z as z7 } from "zod";
4955
5178
  var SET_NAME_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
4956
- var Slug = z6.string().regex(SLUG_REGEX, "member must be a lowercase-kebab app slug");
4957
- var SecretName = z6.string().regex(ENV_NAME_REGEX, "secret name must be UPPER_SNAKE_CASE");
4958
- var SecretSetExcludeSchema = z6.object({
5179
+ var Slug = z7.string().regex(SLUG_REGEX, "member must be a lowercase-kebab app slug");
5180
+ var SecretName = z7.string().regex(ENV_NAME_REGEX, "secret name must be UPPER_SNAKE_CASE");
5181
+ var SecretSetExcludeSchema = z7.object({
4959
5182
  member: Slug,
4960
5183
  secret: SecretName
4961
5184
  }).strict();
4962
- var SecretSetSchema = z6.object({
4963
- name: z6.string().min(1).max(64).regex(SET_NAME_REGEX, "set name must be lowercase-kebab"),
4964
- secrets: z6.array(SecretName).min(1),
4965
- members: z6.array(Slug).min(1),
4966
- exclude: z6.array(SecretSetExcludeSchema).optional()
5185
+ var SecretSetSchema = z7.object({
5186
+ name: z7.string().min(1).max(64).regex(SET_NAME_REGEX, "set name must be lowercase-kebab"),
5187
+ secrets: z7.array(SecretName).min(1),
5188
+ members: z7.array(Slug).min(1),
5189
+ exclude: z7.array(SecretSetExcludeSchema).optional()
4967
5190
  }).strict();
4968
- var FleetSecretSetsSchema = z6.object({
4969
- schemaVersion: z6.literal(1),
4970
- secretSets: z6.array(SecretSetSchema).min(1)
5191
+ var FleetSecretSetsSchema = z7.object({
5192
+ schemaVersion: z7.literal(1),
5193
+ secretSets: z7.array(SecretSetSchema).min(1)
4971
5194
  }).strict().superRefine((m, ctx) => {
4972
5195
  const seenSets = new Set;
4973
5196
  for (let i = 0;i < m.secretSets.length; i++) {
@@ -5100,14 +5323,16 @@ function dispatchManifest(manifest, wrangler = {}) {
5100
5323
  audience: manifest.access.audience,
5101
5324
  private_owner: manifest.access.private_owner,
5102
5325
  allowed_entra_groups: [...allowedEntraGroups(manifest.access)],
5103
- identity_types: manifest.access.identity_types
5326
+ identity_types: manifest.access.identity_types,
5327
+ broad_audience_ack: manifest.access.broad_audience_ack
5104
5328
  },
5105
5329
  build: manifest.build,
5106
5330
  app: manifest.app,
5107
5331
  verify: manifest.verify,
5108
5332
  sensitive: manifest.sensitive,
5109
5333
  catalogue: manifest.catalogue,
5110
- integrations: manifest.integrations
5334
+ integrations: manifest.integrations,
5335
+ boundary: manifest.boundary
5111
5336
  };
5112
5337
  const candidate = {
5113
5338
  apiVersion: "launchpad.m-kopa.us/v2",
@@ -5205,6 +5430,293 @@ function pagesTargetD1(manifest) {
5205
5430
  return;
5206
5431
  return target.d1_binding;
5207
5432
  }
5433
+ // ../launchpad-engine/dist/boundary-proposal.js
5434
+ var REVIEW_TEST_CODES = Object.fromEntries(BOUNDARY_TESTS.map((t, i) => [`T${i + 1}`, t]));
5435
+ // ../launchpad-engine/dist/app-server-code.js
5436
+ var MAX_FILE_CHARS = 512000;
5437
+ var SERVER_PATH_RX = new RegExp("^(functions|server|worker|workers|backend|api|app/api|pages/api|netlify/functions|" + "src/(worker|server|api|functions)|apps/[^/]+/(src/)?(api|worker|server)|react-api/(src|functions|worker))/" + "|^(static/|public/|dist/)?_worker\\.js$|^(worker|server|main|app)\\.(js|ts|mjs|py)$");
5438
+ var CODE_EXT_RX = /\.(?:m?js|cjs|jsx|tsx?|mts|py)$/;
5439
+ var TEST_PATH_RX = /(?:^|\/)(?:tests?|__tests__|__mocks__|fixtures?|node_modules|dist|coverage)\/|\.(?:test|spec)\.[a-z]+$/;
5440
+ var CLIENT_RECV = new Set([
5441
+ "axios",
5442
+ "http",
5443
+ "https",
5444
+ "got",
5445
+ "ky",
5446
+ "superagent",
5447
+ "request",
5448
+ "requests",
5449
+ "httpx",
5450
+ "session",
5451
+ "client",
5452
+ "$",
5453
+ "kv",
5454
+ "db",
5455
+ "cache",
5456
+ "cy",
5457
+ "page",
5458
+ "agent",
5459
+ "fetcher",
5460
+ "jquery",
5461
+ "ajax",
5462
+ "supabase",
5463
+ "stub",
5464
+ "mock"
5465
+ ]);
5466
+ var JS_ROUTE_RX = /\b([A-Za-z_$][\w$]*)\s*\.\s*(post|put|patch|delete)\s*\(\s*(['"`])(\/[^'"`]*|\*)\3/g;
5467
+ var PAGES_EXPORT_RX = /export\s+(?:async\s+)?(?:function|const)\s+onRequest(Post|Put|Patch|Delete)\b/g;
5468
+ var METHOD_BRANCH_RX = /\bmethod\s*(?:===|==)\s*['"](POST|PUT|PATCH|DELETE)['"]|\bcase\s+['"](POST|PUT|PATCH|DELETE)['"]\s*:/g;
5469
+ var PY_ROUTE_RX = /@\s*\w+\.(post|put|patch|delete)\s*\(\s*['"](\/[^'"]*)|methods\s*=\s*\[[^\]]{0,500}['"](POST|PUT|PATCH|DELETE)['"]/gi;
5470
+ var REL_IMPORT_RX = /(?:from\s+|import\s*\(\s*|require\s*\(\s*)['"](\.{1,2}\/[^'"]+)['"]/g;
5471
+ var AUTH_REF_RX = new RegExp("platform-auth|@m-kopa/platform|assertion|requireStaff|requireAuth|requireUser|requireRole|" + "requireCaller|requireIdentity|requireSession|requireAdmin|authMiddleware|jwtVerify|jwks|\\bverify[A-Za-z]*\\s*\\(|x-launchpad", "i");
5472
+ var JS_LINE_COMMENT_RX = /^[ \t]*(?:\/\/|\/\*|\*).*$/gm;
5473
+ var PY_LINE_COMMENT_RX = /^[ \t]*#.*$/gm;
5474
+ function stripLineComments(text, rel) {
5475
+ return text.replace(rel.endsWith(".py") ? PY_LINE_COMMENT_RX : JS_LINE_COMMENT_RX, "");
5476
+ }
5477
+ var VENDORED_VERIFIER_RX = /(?:^|\/)platform-auth\.(?:m?js|ts)$/;
5478
+ function isVendoredVerifierPath(rel) {
5479
+ return VENDORED_VERIFIER_RX.test(rel);
5480
+ }
5481
+ function relativeToRoot(path7, rootDir) {
5482
+ const root = normalisePath(rootDir ?? "");
5483
+ const p = normalisePath(path7);
5484
+ if (root === "" || root === ".")
5485
+ return p;
5486
+ return p.startsWith(`${root}/`) ? p.slice(root.length + 1) : null;
5487
+ }
5488
+ function normalisePath(path7) {
5489
+ const out = [];
5490
+ for (const part of path7.replace(/\\/g, "/").split("/")) {
5491
+ if (part === "" || part === ".")
5492
+ continue;
5493
+ if (part === "..")
5494
+ out.pop();
5495
+ else
5496
+ out.push(part);
5497
+ }
5498
+ return out.join("/");
5499
+ }
5500
+ function dirOf(path7) {
5501
+ const i = path7.lastIndexOf("/");
5502
+ return i < 0 ? "" : path7.slice(0, i);
5503
+ }
5504
+ function baseOf(path7) {
5505
+ return path7.slice(path7.lastIndexOf("/") + 1);
5506
+ }
5507
+ function isServerCodePath(rel) {
5508
+ return SERVER_PATH_RX.test(rel) && CODE_EXT_RX.test(rel) && !TEST_PATH_RX.test(rel);
5509
+ }
5510
+ function findWriteRoutes(text, rel) {
5511
+ const out = [];
5512
+ if (rel.endsWith(".py")) {
5513
+ for (const m of text.matchAll(PY_ROUTE_RX)) {
5514
+ out.push({ at: m.index, method: (m[1] ?? m[3] ?? "POST").toUpperCase() });
5515
+ }
5516
+ return out.map((r) => r.method);
5517
+ }
5518
+ for (const m of text.matchAll(JS_ROUTE_RX)) {
5519
+ if (CLIENT_RECV.has((m[1] ?? "").toLowerCase()))
5520
+ continue;
5521
+ out.push({ at: m.index, method: (m[2] ?? "post").toUpperCase() });
5522
+ }
5523
+ for (const m of text.matchAll(PAGES_EXPORT_RX)) {
5524
+ out.push({ at: m.index, method: (m[1] ?? "Post").toUpperCase() });
5525
+ }
5526
+ if (rel.startsWith("functions/") || rel.startsWith("pages/api/") || /(?:^|\/)_?worker\.(?:js|ts)$/.test(rel)) {
5527
+ for (const m of text.matchAll(METHOD_BRANCH_RX)) {
5528
+ out.push({ at: m.index, method: m[1] ?? m[2] ?? "POST" });
5529
+ }
5530
+ }
5531
+ return out.sort((a, b) => a.at - b.at).map((r) => r.method);
5532
+ }
5533
+ function resolveImport(rel, spec, known) {
5534
+ const base = normalisePath(`${dirOf(rel)}/${spec}`);
5535
+ const stem = base.replace(/\.(?:m?js|jsx|tsx?)$/, "");
5536
+ for (const b of [base, stem]) {
5537
+ for (const cand of [b, `${b}.ts`, `${b}.js`, `${b}.mjs`, `${b}.tsx`, `${b}.jsx`, `${b}.py`, `${b}/index.ts`, `${b}/index.js`]) {
5538
+ if (known.has(cand))
5539
+ return cand;
5540
+ }
5541
+ }
5542
+ return null;
5543
+ }
5544
+ function relativeImports(text) {
5545
+ return [...text.matchAll(REL_IMPORT_RX)].map((m) => m[1] ?? "").filter((s) => s !== "");
5546
+ }
5547
+ function collectServerFiles(files, options = {}) {
5548
+ const raw = new Map;
5549
+ for (const [path7, content] of Object.entries(files)) {
5550
+ const rel = relativeToRoot(path7, options.rootDir);
5551
+ if (rel === null || !isServerCodePath(rel) || content.length > MAX_FILE_CHARS)
5552
+ continue;
5553
+ raw.set(rel, content);
5554
+ }
5555
+ const known = new Set(raw.keys());
5556
+ const out = new Map;
5557
+ for (const [rel, content] of raw) {
5558
+ const imports = relativeImports(content).map((s) => resolveImport(rel, s, known)).filter((x) => x !== null);
5559
+ const code = stripLineComments(content, rel);
5560
+ out.set(rel, {
5561
+ path: rel,
5562
+ content,
5563
+ code,
5564
+ writeRoutes: findWriteRoutes(content, rel),
5565
+ authRef: AUTH_REF_RX.test(code),
5566
+ imports
5567
+ });
5568
+ }
5569
+ return out;
5570
+ }
5571
+ function reach(start, graph, depth) {
5572
+ const seen = new Set([start]);
5573
+ let frontier = new Set([start]);
5574
+ for (let i = 0;i < depth; i++) {
5575
+ const next = new Set;
5576
+ for (const x of frontier) {
5577
+ for (const y of graph.get(x) ?? []) {
5578
+ if (!seen.has(y)) {
5579
+ seen.add(y);
5580
+ next.add(y);
5581
+ }
5582
+ }
5583
+ }
5584
+ frontier = next;
5585
+ }
5586
+ seen.delete(start);
5587
+ return seen;
5588
+ }
5589
+ function importGraphs(files) {
5590
+ const imports = new Map;
5591
+ const importedBy = new Map;
5592
+ for (const [rel, f] of files) {
5593
+ imports.set(rel, f.imports);
5594
+ for (const x of f.imports) {
5595
+ const list = importedBy.get(x) ?? [];
5596
+ list.push(rel);
5597
+ importedBy.set(x, list);
5598
+ }
5599
+ }
5600
+ return { imports, importedBy };
5601
+ }
5602
+ function coveredByMiddleware(rel, files, pred) {
5603
+ let d = dirOf(rel);
5604
+ for (;; ) {
5605
+ for (const f of files.values()) {
5606
+ if (dirOf(f.path) === d && baseOf(f.path).startsWith("_middleware") && pred(f))
5607
+ return true;
5608
+ }
5609
+ if (d === "")
5610
+ return false;
5611
+ d = dirOf(d);
5612
+ }
5613
+ }
5614
+
5615
+ // ../launchpad-engine/dist/route-auth-lint.js
5616
+ function lintRouteAuth(files, options = {}) {
5617
+ const server = collectServerFiles(files, options);
5618
+ const { imports, importedBy } = importGraphs(server);
5619
+ const appHasAuthRef = [...server.values()].some((f) => f.authRef);
5620
+ const hasWrites = (p) => (server.get(p)?.writeRoutes.length ?? 0) > 0;
5621
+ const guardsWrites = (f) => {
5622
+ if (!f.authRef || isVendoredVerifierPath(f.path))
5623
+ return false;
5624
+ if (f.writeRoutes.length > 0)
5625
+ return true;
5626
+ if (f.path.slice(f.path.lastIndexOf("/") + 1).startsWith("_middleware"))
5627
+ return true;
5628
+ return [...reach(f.path, importedBy, 3)].some(hasWrites);
5629
+ };
5630
+ const appGuardsWrites = [...server.values()].some(guardsWrites);
5631
+ const authed = (p) => server.get(p)?.authRef === true;
5632
+ const findings = [];
5633
+ let writeRoutes = 0;
5634
+ for (const f of [...server.values()].sort((a, b) => a.path.localeCompare(b.path))) {
5635
+ if (f.writeRoutes.length === 0)
5636
+ continue;
5637
+ writeRoutes += f.writeRoutes.length;
5638
+ const covered = f.authRef || [...reach(f.path, imports, 3)].some(authed) || [...reach(f.path, importedBy, 2)].some(authed) || coveredByMiddleware(f.path, server, (m) => m.authRef);
5639
+ if (covered)
5640
+ continue;
5641
+ findings.push({
5642
+ path: f.path,
5643
+ rule: "route-without-auth",
5644
+ severity: appGuardsWrites ? "medium" : "high",
5645
+ methods: [...new Set(f.writeRoutes)].sort(),
5646
+ routes: f.writeRoutes.length
5647
+ });
5648
+ }
5649
+ return { serverFiles: server.size, writeRoutes, appHasAuthRef, appGuardsWrites, findings };
5650
+ }
5651
+ // ../launchpad-engine/dist/assertion-verify-lint.js
5652
+ var APP_SESSION_MAX_SECONDS = 3600;
5653
+ var ASSERTION_READ_RX = /x-launchpad-user-assertion|cf-access-jwt-assertion|GATEWAY_ASSERTION_HEADER_NAME|CF_ACCESS_HEADER_NAME|parseGatewayAssertionFromHeaders|parseAccessJwtFromHeaders/i;
5654
+ var PLATFORM_AUTH_IMPORT_RX = /['"](?:@m-kopa\/platform-auth(?:\/hono)?|\.{1,2}\/(?:[^'"\n]*\/)?platform-auth(?:\.m?js|\.ts)?)['"]/;
5655
+ var PLATFORM_AUTH_CALL_RX = /\b(?:verifyAccessJwt|verifyJwt|verifyIntegrationAssertion|createPlatformAuthMiddleware)\s*\(/;
5656
+ var DECODE_RX = /\batob\s*\(|Buffer\.from\s*\([^)]{0,200}['"]base64(?:url)?['"]|\bdecodeJwt\s*\(|\bjwt\.decode\s*\(|\bjwtDecode\s*\(|\.split\s*\(\s*['"]\.['"]\s*\)/;
5657
+ var OTHER_VERIFY_RX = /\bjwtVerify\s*\(|createRemoteJWKSet\s*\(|subtle\.verify\s*\(/;
5658
+ var COOKIE_RX = /set-cookie|setCookie|\bcookie\b/i;
5659
+ var MAX_AGE_RX = /(?:max-age|maxAge)\s*[=:]\s*(\d{1,9})\b/gi;
5660
+ function usesPlatformAuth(f) {
5661
+ return PLATFORM_AUTH_IMPORT_RX.test(f.code) && PLATFORM_AUTH_CALL_RX.test(f.code);
5662
+ }
5663
+ function maxCookieAge(f) {
5664
+ if (!COOKIE_RX.test(f.code))
5665
+ return null;
5666
+ let max = null;
5667
+ for (const m of f.code.matchAll(MAX_AGE_RX)) {
5668
+ const n = Number(m[1]);
5669
+ if (max === null || n > max)
5670
+ max = n;
5671
+ }
5672
+ return max;
5673
+ }
5674
+ function lintAssertionVerification(files, options = {}) {
5675
+ const server = collectServerFiles(files, options);
5676
+ if (server.size === 0) {
5677
+ return { status: "no-server-code", readers: 0, usesPlatformAuth: false, findings: [] };
5678
+ }
5679
+ const { imports } = importGraphs(server);
5680
+ const inReach = (f, pred) => pred(f) || [...reach(f.path, imports, 3)].some((p) => {
5681
+ const x = server.get(p);
5682
+ return x !== undefined && pred(x);
5683
+ });
5684
+ const findings = [];
5685
+ let readers = 0;
5686
+ let uncovered = 0;
5687
+ const sorted = [...server.values()].sort((a, b) => a.path.localeCompare(b.path));
5688
+ for (const f of sorted) {
5689
+ if (isVendoredVerifierPath(f.path))
5690
+ continue;
5691
+ if (usesPlatformAuth(f)) {
5692
+ readers++;
5693
+ } else if (ASSERTION_READ_RX.test(f.code)) {
5694
+ readers++;
5695
+ if (!inReach(f, usesPlatformAuth)) {
5696
+ uncovered++;
5697
+ const otherVerifier = inReach(f, (x) => OTHER_VERIFY_RX.test(x.code));
5698
+ if (otherVerifier) {
5699
+ findings.push({ path: f.path, rule: "assertion-verified-without-platform-auth", severity: "low" });
5700
+ } else if (inReach(f, (x) => !isVendoredVerifierPath(x.path) && DECODE_RX.test(x.code))) {
5701
+ findings.push({ path: f.path, rule: "assertion-decoded-without-verify", severity: "high" });
5702
+ } else {
5703
+ findings.push({ path: f.path, rule: "assertion-read-without-platform-auth", severity: "medium" });
5704
+ }
5705
+ }
5706
+ }
5707
+ const age = maxCookieAge(f);
5708
+ if (age !== null && age > APP_SESSION_MAX_SECONDS) {
5709
+ findings.push({ path: f.path, rule: "app-session-over-1h", severity: "low", maxAgeSeconds: age });
5710
+ }
5711
+ }
5712
+ const status = readers === 0 ? "no-assertion-use" : uncovered === 0 ? "verified" : "not-verified";
5713
+ return {
5714
+ status,
5715
+ readers,
5716
+ usesPlatformAuth: sorted.some(usesPlatformAuth),
5717
+ findings
5718
+ };
5719
+ }
5208
5720
  // src/bundle/boundary.ts
5209
5721
  var MAX_CONTENT_PROBE_BYTES = 1024 * 1024;
5210
5722
  function applyBoundaryToFiles(args) {
@@ -5371,7 +5883,7 @@ import { readFileSync as readFileSync10, existsSync as existsSync4 } from "node:
5371
5883
  import { join as join9 } from "node:path";
5372
5884
 
5373
5885
  // src/deploy/deployment-status.ts
5374
- import { z as z8 } from "zod";
5886
+ import { z as z9 } from "zod";
5375
5887
 
5376
5888
  // src/deploy/redact-diagnostic.ts
5377
5889
  var MAX_DIAGNOSTIC_LEN = 600;
@@ -5389,19 +5901,19 @@ function redactDiagnostic(text, maxLen = MAX_DIAGNOSTIC_LEN) {
5389
5901
  }
5390
5902
 
5391
5903
  // src/notices.ts
5392
- import { z as z7 } from "zod";
5904
+ import { z as z8 } from "zod";
5393
5905
  var NOTICE_COMMAND_ALLOWLIST = new Set([
5394
5906
  "launchpad migrate --origin dispatch --dry-run",
5395
5907
  "launchpad migrate --status",
5396
5908
  "launchpad migrate --finalize"
5397
5909
  ]);
5398
5910
  var MAX_TEXT = 300;
5399
- var NoticeSchema = z7.object({
5400
- id: z7.string().regex(/^[a-z][a-z0-9_]{0,63}$/),
5401
- schema: z7.literal(1),
5402
- level: z7.enum(["info", "warning"]),
5403
- text: z7.string().transform(clean).pipe(z7.string().min(1)),
5404
- command: z7.string().optional().catch(undefined)
5911
+ var NoticeSchema = z8.object({
5912
+ id: z8.string().regex(/^[a-z][a-z0-9_]{0,63}$/),
5913
+ schema: z8.literal(1),
5914
+ level: z8.enum(["info", "warning"]),
5915
+ text: z8.string().transform(clean).pipe(z8.string().min(1)),
5916
+ command: z8.string().optional().catch(undefined)
5405
5917
  });
5406
5918
  function parseNotices(raw) {
5407
5919
  if (!Array.isArray(raw))
@@ -5509,16 +6021,16 @@ function projectV2(value) {
5509
6021
  };
5510
6022
  return { v2 };
5511
6023
  }
5512
- var Sha40 = z8.string().regex(/^[0-9a-f]{40}$/);
5513
- var VerifiedCommitSchema = z8.object({
6024
+ var Sha40 = z9.string().regex(/^[0-9a-f]{40}$/);
6025
+ var VerifiedCommitSchema = z9.object({
5514
6026
  commitSha: Sha40,
5515
- runId: z8.number().int().positive(),
5516
- artifactSha256: z8.string().regex(/^[0-9a-f]{64}$/),
5517
- verifiedAt: z8.string().transform((value) => redactDiagnostic(value)),
5518
- runUrl: z8.unknown().optional()
6027
+ runId: z9.number().int().positive(),
6028
+ artifactSha256: z9.string().regex(/^[0-9a-f]{64}$/),
6029
+ verifiedAt: z9.string().transform((value) => redactDiagnostic(value)),
6030
+ runUrl: z9.unknown().optional()
5519
6031
  });
5520
- var ScriptBindingSchema = z8.object({
5521
- state: z8.enum(["match", "mismatch", "unbound", "unreadable"]),
6032
+ var ScriptBindingSchema = z9.object({
6033
+ state: z9.enum(["match", "mismatch", "unbound", "unreadable"]),
5522
6034
  commitSha: Sha40.optional().catch(undefined)
5523
6035
  });
5524
6036
  function projectVerifiedCommit(value) {
@@ -11078,10 +11590,10 @@ function saveMigration(file, original, converted) {
11078
11590
  }
11079
11591
 
11080
11592
  // src/integration-status.ts
11081
- import { z as z9 } from "zod";
11082
- var EntrySchema = z9.object({
11083
- name: z9.string().regex(INTEGRATION_NAME_REGEX),
11084
- status: z9.enum(["approved", "pending", "unavailable"])
11593
+ import { z as z10 } from "zod";
11594
+ var EntrySchema = z10.object({
11595
+ name: z10.string().regex(INTEGRATION_NAME_REGEX),
11596
+ status: z10.enum(["approved", "pending", "unavailable"])
11085
11597
  });
11086
11598
  function integrationStatusLines(raw) {
11087
11599
  if (!Array.isArray(raw))
@@ -11783,6 +12295,25 @@ ${w}`, ""), message);
11783
12295
  io.err(` - ${String(f.path)} [${String(f.rule)}]`);
11784
12296
  }
11785
12297
  }
12298
+ if (body.holds !== undefined && body.holds.length > 0) {
12299
+ io.err(" Boundary hold (paused for review, the live app keeps running):");
12300
+ for (const h of body.holds) {
12301
+ const where = [h.path, h.line === undefined ? undefined : `line ${h.line}`, h.host].filter((x) => x !== undefined).join(", ");
12302
+ io.err(` - ${h.flag}${where === "" ? "" : ` (${where})`}`);
12303
+ }
12304
+ }
12305
+ if (body.served_data_findings !== undefined && body.served_data_findings.length > 0) {
12306
+ io.err(" Record-level data in served files (paths and column names only):");
12307
+ for (const f of body.served_data_findings) {
12308
+ const cols = f.columns.length > 0 ? ` columns: ${f.columns.join(", ")}` : "";
12309
+ io.err(` - ${f.path} [${f.rule}]${cols}`);
12310
+ }
12311
+ }
12312
+ if (body.next_step !== undefined)
12313
+ io.err(` Next step: ${body.next_step}`);
12314
+ if (body.review_url !== undefined && body.review_url !== "") {
12315
+ io.err(` Review PR: ${body.review_url}`);
12316
+ }
11786
12317
  if (errorCode === "bundle_policy_violation" || errorCode === "app_boundary_violation" || errorCode === "bad_build_command") {
11787
12318
  io.err("");
11788
12319
  io.err(" Nothing was committed or claimed by this attempt — fix the");
@@ -13114,9 +13645,9 @@ function describe22(e) {
13114
13645
 
13115
13646
  // src/commands/init.ts
13116
13647
  import { createInterface as createInterface2 } from "node:readline/promises";
13117
- import { existsSync as existsSync12, mkdirSync as mkdirSync4, readFileSync as readFileSync17, writeFileSync as writeFileSync4 } from "node:fs";
13118
- import { dirname as dirname8, resolve as resolve11 } from "node:path";
13119
- import { stringify as yamlStringify } from "yaml";
13648
+ import { existsSync as existsSync13, mkdirSync as mkdirSync5, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "node:fs";
13649
+ import { dirname as dirname9, resolve as resolve12 } from "node:path";
13650
+ import { parse as yamlParse, stringify as yamlStringify } from "yaml";
13120
13651
 
13121
13652
  // src/detect/index.ts
13122
13653
  import { existsSync as existsSync11, readFileSync as readFileSync16, statSync } from "node:fs";
@@ -13273,50 +13804,421 @@ function detectDestinationDir(cwd, vite) {
13273
13804
  return { kind: "ok", value: "dist" };
13274
13805
  }
13275
13806
 
13276
- // src/commands/init.ts
13277
- var SLUG_REGEX3 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
13278
- var initCommand = {
13279
- name: "init",
13280
- summary: "scaffold a new launchpad.yaml in the current directory",
13281
- run: (args, io) => runInit(args, io, defaultPrompt3)
13282
- };
13283
- async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(), { path: "/me/identity" })) {
13284
- const parsed = parseArgs6(args);
13285
- if (parsed.kind === "usage-error") {
13286
- io.err(`launchpad init: ${parsed.message}`);
13287
- io.err("Usage: launchpad init [--non-interactive] [flags]");
13288
- return 64;
13289
- }
13290
- const { inputs, options } = parsed;
13291
- const outPath = resolve11(process.cwd(), options.out);
13292
- if (existsSync12(outPath) && !options.force) {
13293
- io.err(`launchpad init: ${outPath} already exists`);
13294
- io.err("Pass --force to overwrite.");
13295
- return 64;
13296
- }
13297
- let detected;
13298
- if (!options.skipDetect && inputs.type !== "container") {
13299
- const detectResult = detectAppShape(process.cwd());
13300
- if (detectResult.kind === "ok") {
13301
- detected = detectResult.detected;
13302
- if (inputs.type === undefined) {
13303
- inputs.type = detected.appType;
13304
- }
13305
- } else if (detectResult.kind === "ambiguous" && inputs.type === undefined) {
13306
- io.err(`launchpad init: cannot detect app shape from current directory`);
13307
- io.err(` ${detectResult.reason}`);
13308
- io.err(``);
13309
- io.err(`If you know the app type, pass --type (one of: ${APP_TYPES2.join(", ")}) to bypass detection,`);
13310
- io.err(`or pass --no-detect to skip detection entirely.`);
13311
- return 64;
13312
- }
13313
- }
13314
- const fillResult = await fillRequired(inputs, options, io, prompt);
13315
- if (fillResult.kind === "usage-error") {
13316
- io.err(`launchpad init: ${fillResult.message}`);
13317
- return 64;
13807
+ // src/scaffold/secure-api-template.ts
13808
+ import { existsSync as existsSync12, lstatSync as lstatSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "node:fs";
13809
+ import { dirname as dirname8, join as join14, resolve as resolve11 } from "node:path";
13810
+ var SECURE_API_LIB_PATH = "functions/_lib/secure-api.ts";
13811
+ var SECURE_API_ROUTER_PATH = "functions/api/[[path]].ts";
13812
+ var SECURE_API_TEST_PATH = "tests/secure-api.test.ts";
13813
+ var AUTHZ_ATTESTATION_PATH = "authz-attestation.json";
13814
+ var SECURE_TEMPLATE_INCLUDE = ["tests/**", AUTHZ_ATTESTATION_PATH];
13815
+ var AUTHZ_STATEMENT_ID = "launchpad-app-authz-v1";
13816
+ var AUTHZ_STATEMENT = "Every API route verifies the signed-in user with @m-kopa/platform-auth before it runs, " + "every route that changes data checks the caller's role, and new routes are added through " + "createSecureApi with tests/secure-api.test.ts kept in place.";
13817
+ var SECURE_API_LIB = `// Secure-by-default API helpers (scaffolded by \`launchpad init --secure-template\`).
13818
+ //
13819
+ // createSecureApi() registers the identity check FIRST, so every route added
13820
+ // to the returned app runs behind it. requireRole() is the role check for
13821
+ // routes that change data. tests/secure-api.test.ts fails if either is
13822
+ // bypassed. Do not create another Hono app under functions/.
13823
+
13824
+ import { Hono, type MiddlewareHandler } from "hono";
13825
+ import { createJwksCache, parseGatewayAssertionFromHeaders } from "@m-kopa/platform-auth";
13826
+ import { createPlatformAuthMiddleware, type PlatformAuthVariables } from "@m-kopa/platform-auth/hono";
13827
+
13828
+ /**
13829
+ * Bindings the platform sets on a gateway-fronted app. Older Pages apps may
13830
+ * carry only the legacy names (CF_ACCESS_TEAM_DOMAIN, CF_ACCESS_AUD,
13831
+ * JWKS_URL), which hold the same gateway values; both sets are read.
13832
+ */
13833
+ export interface SecureEnv {
13834
+ GATEWAY_ISSUER?: string;
13835
+ GATEWAY_AUD?: string;
13836
+ GATEWAY_JWKS_URL?: string;
13837
+ CF_ACCESS_TEAM_DOMAIN?: string;
13838
+ CF_ACCESS_AUD?: string;
13839
+ JWKS_URL?: string;
13840
+ [key: string]: unknown;
13841
+ }
13842
+
13843
+ type SecureVars<E extends SecureEnv> = { Bindings: E; Variables: PlatformAuthVariables };
13844
+ export type SecureApp<E extends SecureEnv> = Hono<SecureVars<E>>;
13845
+
13846
+ const authGuards = new WeakSet<object>();
13847
+ const roleGuards = new WeakSet<object>();
13848
+ const passThroughs = new WeakSet<object>();
13849
+
13850
+ /** True for the identity middleware created by createSecureApi (used by the tests). */
13851
+ export function isAuthGuard(handler: unknown): boolean {
13852
+ return typeof handler === "function" && authGuards.has(handler);
13853
+ }
13854
+
13855
+ /** True for a middleware created by requireRole (used by the tests). */
13856
+ export function isRoleGuard(handler: unknown): boolean {
13857
+ return typeof handler === "function" && roleGuards.has(handler);
13858
+ }
13859
+
13860
+ /** True for a middleware marked with passThrough (used by the tests). */
13861
+ export function isPassThrough(handler: unknown): boolean {
13862
+ return typeof handler === "function" && passThroughs.has(handler);
13863
+ }
13864
+
13865
+ /**
13866
+ * Mark a middleware that only observes the request and always calls next()
13867
+ * (logging, headers, timing) so app.use(...) does not need a role check. Never
13868
+ * wrap a handler that answers a request or changes data.
13869
+ */
13870
+ export function passThrough<H extends MiddlewareHandler<any>>(handler: H): H {
13871
+ passThroughs.add(handler);
13872
+ return handler;
13873
+ }
13874
+
13875
+ let cachedJwks: ReturnType<typeof createJwksCache> | undefined;
13876
+ let cachedJwksUrl: string | undefined;
13877
+ function jwksFor(url: string): ReturnType<typeof createJwksCache> {
13878
+ if (cachedJwks === undefined || cachedJwksUrl !== url) {
13879
+ cachedJwks = createJwksCache(url);
13880
+ cachedJwksUrl = url;
13318
13881
  }
13319
- const authIssue = deploymentAuthIssue(fillResult.inputs.type, fillResult.inputs.auth ?? "gateway");
13882
+ return cachedJwks;
13883
+ }
13884
+
13885
+ function verifyIdentity<E extends SecureEnv>(): MiddlewareHandler<SecureVars<E>> {
13886
+ const guard: MiddlewareHandler<SecureVars<E>> = async (c, next) => {
13887
+ // No assertion: refuse before anything else runs.
13888
+ if (parseGatewayAssertionFromHeaders(c.req.raw.headers) === null) {
13889
+ return c.json({ error: "unauthorized" }, 401);
13890
+ }
13891
+ const issuer = c.env?.GATEWAY_ISSUER || c.env?.CF_ACCESS_TEAM_DOMAIN;
13892
+ const audience = c.env?.GATEWAY_AUD || c.env?.CF_ACCESS_AUD;
13893
+ if (!issuer || !audience) {
13894
+ // Fail closed: never serve a route when the verifier is not configured.
13895
+ return c.json({ error: "identity_not_configured" }, 503);
13896
+ }
13897
+ const jwksUrl =
13898
+ c.env?.GATEWAY_JWKS_URL || c.env?.JWKS_URL || \`\${issuer.replace(/\\/$/, "")}/.well-known/jwks.json\`;
13899
+ // platform-auth types its middleware for its own Variables only; this app
13900
+ // also has Bindings, so the cast widens it to the app's context type.
13901
+ const middleware = createPlatformAuthMiddleware({
13902
+ header: "gateway",
13903
+ teamDomain: issuer,
13904
+ audience,
13905
+ jwks: jwksFor(jwksUrl),
13906
+ }) as unknown as MiddlewareHandler<SecureVars<E>>;
13907
+ return middleware(c, next);
13908
+ };
13909
+ authGuards.add(guard);
13910
+ return guard;
13911
+ }
13912
+
13913
+ /** A Hono app under /api whose first handler verifies the caller's identity. */
13914
+ export function createSecureApi<E extends SecureEnv>(): SecureApp<E> {
13915
+ const app = new Hono<SecureVars<E>>().basePath("/api");
13916
+ app.use("*", verifyIdentity<E>());
13917
+ return app;
13918
+ }
13919
+
13920
+ /**
13921
+ * Allow the request only when the caller is in one of the Entra groups listed
13922
+ * (comma separated group object IDs) in ROLE_<ROLE>_GROUP_IDS. An unset or
13923
+ * empty list denies everyone: set it before the route can be used.
13924
+ *
13925
+ * The groups come from the verified gateway assertion, which is a login-time
13926
+ * snapshot: removing someone from a role group takes effect at their next
13927
+ * gateway sign-in, not at once. Use this for coarse roles (writer, admin).
13928
+ * When revocation must be immediate, look the role up server-side (your own
13929
+ * table or Microsoft Graph) instead.
13930
+ */
13931
+ export function requireRole<E extends SecureEnv>(role: string): MiddlewareHandler<SecureVars<E>> {
13932
+ const key = \`ROLE_\${role.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_GROUP_IDS\`;
13933
+ const guard: MiddlewareHandler<SecureVars<E>> = async (c, next) => {
13934
+ const allowed = String(c.env?.[key] ?? "")
13935
+ .split(",")
13936
+ .map((g) => g.trim().toLowerCase())
13937
+ .filter((g) => g !== "");
13938
+ const user = c.get("user");
13939
+ const groups = (user?.groups ?? []).map((g) => g.toLowerCase());
13940
+ if (allowed.length === 0 || !groups.some((g) => allowed.includes(g))) {
13941
+ return c.json({ error: "forbidden", role }, 403);
13942
+ }
13943
+ await next();
13944
+ return;
13945
+ };
13946
+ roleGuards.add(guard);
13947
+ return guard;
13948
+ }
13949
+ `;
13950
+ var SECURE_API_ROUTER = `// API router (scaffolded by \`launchpad init --secure-template\`).
13951
+ //
13952
+ // Add every route to the app that buildApp() returns. Routes that change data
13953
+ // need requireRole(...) BEFORE the handler. tests/secure-api.test.ts checks
13954
+ // both. Keep the last line as it is: the guard test checks it.
13955
+
13956
+ import { handle } from "hono/cloudflare-pages";
13957
+ import { createSecureApi, requireRole, type SecureEnv } from "../_lib/secure-api";
13958
+
13959
+ export interface Env extends SecureEnv {
13960
+ /** Comma separated Entra group object IDs allowed to write. */
13961
+ ROLE_WRITER_GROUP_IDS?: string;
13962
+ }
13963
+
13964
+ export function buildApp() {
13965
+ const app = createSecureApi<Env>();
13966
+
13967
+ // Read route: any verified user of this app.
13968
+ app.get("/me", (c) => {
13969
+ const user = c.get("user");
13970
+ return c.json({ sub: user.sub, name: user.name ?? null });
13971
+ });
13972
+
13973
+ // Write route: verified user AND in the writer role.
13974
+ app.post("/items", requireRole<Env>("writer"), async (c) => {
13975
+ return c.json({ ok: true }, 201);
13976
+ });
13977
+
13978
+ return app;
13979
+ }
13980
+
13981
+ export const onRequest = handle(buildApp());
13982
+ `;
13983
+ var SECURE_API_TEST = `// Guard test for the secure API template (audit A2-09). Do not delete.
13984
+ //
13985
+ // Fails when a route escapes the identity middleware, a route that can change
13986
+ // data has no role check in front of it, the router stops exporting the
13987
+ // secure app, or a route file appears outside the secure router.
13988
+
13989
+ import { lstatSync, readdirSync, readFileSync } from "node:fs";
13990
+ import { join, relative } from "node:path";
13991
+ import { describe, expect, test } from "vitest";
13992
+ import { buildApp } from "../functions/api/[[path]]";
13993
+ import { isAuthGuard, isPassThrough, isRoleGuard } from "../functions/_lib/secure-api";
13994
+
13995
+ /** Methods that cannot change data. Everything else, ALL included, is a write. */
13996
+ const READ_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
13997
+ const ROUTER = "functions/api/[[path]].ts";
13998
+ const LIB = "functions/_lib/secure-api.ts";
13999
+
14000
+ const ROUTE_EXPORT_RX = /export\\s+(?:async\\s+)?(?:function|const|let|var)\\s+onRequest|export\\s*\\{[^}]*\\bonRequest/;
14001
+ const NEW_HONO_RX = /new\\s+Hono\\b/g;
14002
+
14003
+ function honoApps(text: string): number {
14004
+ return (text.match(NEW_HONO_RX) ?? []).length;
14005
+ }
14006
+
14007
+ function samplePath(path: string): string {
14008
+ return path.replace(/:[^/]+/g, "x").replace(/\\*$/, "x");
14009
+ }
14010
+
14011
+ /** True when a guard registered on \`guardPath\` runs for \`path\`. */
14012
+ function covers(guardPath: string, path: string): boolean {
14013
+ if (guardPath === path) return true;
14014
+ if (!guardPath.endsWith("/*")) return false;
14015
+ const prefix = guardPath.slice(0, -1); // keeps the trailing "/"
14016
+ return path.startsWith(prefix) || path === prefix.slice(0, -1);
14017
+ }
14018
+
14019
+ /** Files under dir. A symlink fails the test: it cannot be checked and can loop. */
14020
+ function walk(dir: string, root: string): string[] {
14021
+ let names: string[];
14022
+ try {
14023
+ names = readdirSync(dir);
14024
+ } catch {
14025
+ return [];
14026
+ }
14027
+ return names.flatMap((n) => {
14028
+ const p = join(dir, n);
14029
+ const st = lstatSync(p);
14030
+ expect(st.isSymbolicLink(), \`\${relative(root, p)} is a symlink; the guard test cannot check it\`).toBe(false);
14031
+ return st.isDirectory() ? walk(p, root) : [p];
14032
+ });
14033
+ }
14034
+
14035
+ describe("secure API template", () => {
14036
+ const app = buildApp();
14037
+ const routes = app.routes;
14038
+
14039
+ test("the identity middleware is the first handler and covers every route", () => {
14040
+ expect(isAuthGuard(routes[0]?.handler)).toBe(true);
14041
+ expect(routes[0]?.path).toBe("/api/*");
14042
+ expect(routes.filter((r) => isAuthGuard(r.handler))).toHaveLength(1);
14043
+ });
14044
+
14045
+ test("every route refuses a request without an identity assertion", async () => {
14046
+ for (const r of routes) {
14047
+ if (isAuthGuard(r.handler)) continue;
14048
+ const method = r.method === "ALL" ? "GET" : r.method;
14049
+ const res = await app.request(samplePath(r.path), { method });
14050
+ expect(res.status, \`\${method} \${r.path}\`).toBe(401);
14051
+ }
14052
+ });
14053
+
14054
+ test("every route that can change data has requireRole(...) in front of it", () => {
14055
+ routes.forEach((w, i) => {
14056
+ if (READ_METHODS.has(w.method)) return;
14057
+ if (isAuthGuard(w.handler) || isRoleGuard(w.handler) || isPassThrough(w.handler)) return;
14058
+ // A role guard must run first: registered earlier, for the same method
14059
+ // (or every method), on a path that covers this one. An ALL route needs
14060
+ // an ALL guard, since a POST-only guard leaves DELETE open.
14061
+ const guarded = routes.slice(0, i).some(
14062
+ (g) =>
14063
+ isRoleGuard(g.handler) &&
14064
+ (g.method === "ALL" || (w.method !== "ALL" && g.method === w.method)) &&
14065
+ covers(g.path, w.path),
14066
+ );
14067
+ expect(guarded, \`\${w.method} \${w.path} has no requireRole(...) before its handler (wrap an observe-only middleware in passThrough(...))\`).toBe(true);
14068
+ });
14069
+ });
14070
+
14071
+ test("the router exports the secure app and nothing else", () => {
14072
+ const text = readFileSync(join(process.cwd(), ROUTER), "utf8");
14073
+ expect(text, \`\${ROUTER} must end with: export const onRequest = handle(buildApp());\`).toMatch(
14074
+ /^export const onRequest = handle\\(buildApp\\(\\)\\);$/m,
14075
+ );
14076
+ expect(text.match(/export\\s+(?:async\\s+)?(?:function|const|let|var)\\s+onRequest\\w*/g), ROUTER).toHaveLength(1);
14077
+ expect(/export\\s*\\{[^}]*\\bonRequest|export\\s+default\\b/.test(text), \`\${ROUTER} has another export\`).toBe(false);
14078
+ expect(honoApps(text), \`\${ROUTER} creates its own Hono app\`).toBe(0);
14079
+ const lib = readFileSync(join(process.cwd(), LIB), "utf8");
14080
+ expect(honoApps(lib), \`\${LIB} creates one Hono app (createSecureApi)\`).toBe(1);
14081
+ expect(ROUTE_EXPORT_RX.test(lib), \`\${LIB} exports a route handler\`).toBe(false);
14082
+ });
14083
+
14084
+ test("no route handlers outside the secure router", () => {
14085
+ const root = process.cwd(); // vitest runs from the app root
14086
+ for (const abs of walk(join(root, "functions"), root)) {
14087
+ const rel = relative(root, abs).split("\\\\").join("/");
14088
+ if (rel === ROUTER || rel === LIB || !/\\.(m?[jt]sx?)$/.test(rel)) continue;
14089
+ const text = readFileSync(abs, "utf8");
14090
+ expect(ROUTE_EXPORT_RX.test(text), \`\${rel} exports a route handler\`).toBe(false);
14091
+ expect(honoApps(text), \`\${rel} creates its own Hono app\`).toBe(0);
14092
+ }
14093
+ });
14094
+ });
14095
+ `;
14096
+ function sameEmail(a, b) {
14097
+ return a.trim().toLowerCase() === b.trim().toLowerCase();
14098
+ }
14099
+ function attestationStatus(input2) {
14100
+ if (input2.attester === undefined)
14101
+ return "pending";
14102
+ return sameEmail(input2.attester.email, input2.owner) ? "attested" : "attested_by_other";
14103
+ }
14104
+ function attestationJson(input2) {
14105
+ const status = attestationStatus(input2);
14106
+ const record = {
14107
+ version: 2,
14108
+ audit_item: "A2-09",
14109
+ statement_id: AUTHZ_STATEMENT_ID,
14110
+ statement: AUTHZ_STATEMENT,
14111
+ status,
14112
+ owner: input2.owner,
14113
+ ...input2.attester === undefined ? {} : {
14114
+ attested_by: { oid: input2.attester.oid, email: input2.attester.email },
14115
+ attested_at: input2.date,
14116
+ identity_source: "launchpad session (/me/identity)"
14117
+ },
14118
+ server_recorded: false
14119
+ };
14120
+ return `${JSON.stringify(record, null, 2)}
14121
+ `;
14122
+ }
14123
+ function symlinkOnPath(baseDir, rel) {
14124
+ let cur = resolve11(baseDir);
14125
+ for (const part of rel.split("/")) {
14126
+ cur = join14(cur, part);
14127
+ let st;
14128
+ try {
14129
+ st = lstatSync5(cur);
14130
+ } catch {
14131
+ return false;
14132
+ }
14133
+ if (st.isSymbolicLink())
14134
+ return true;
14135
+ }
14136
+ return false;
14137
+ }
14138
+ function writeSecureApiScaffold(baseDir, attestation) {
14139
+ const files = [
14140
+ [SECURE_API_LIB_PATH, SECURE_API_LIB],
14141
+ [SECURE_API_ROUTER_PATH, SECURE_API_ROUTER],
14142
+ [SECURE_API_TEST_PATH, SECURE_API_TEST],
14143
+ [AUTHZ_ATTESTATION_PATH, attestationJson(attestation)]
14144
+ ];
14145
+ const written = [];
14146
+ const kept = [];
14147
+ const skippedSymlink = [];
14148
+ for (const [rel, text2] of files) {
14149
+ if (symlinkOnPath(baseDir, rel)) {
14150
+ skippedSymlink.push(rel);
14151
+ continue;
14152
+ }
14153
+ const abs = resolve11(baseDir, rel);
14154
+ if (existsSync12(abs)) {
14155
+ kept.push(rel);
14156
+ continue;
14157
+ }
14158
+ mkdirSync4(dirname8(abs), { recursive: true });
14159
+ writeFileSync4(abs, text2, { encoding: "utf8", flag: "wx" });
14160
+ written.push(rel);
14161
+ }
14162
+ return { written, kept, skippedSymlink };
14163
+ }
14164
+ function writeAttestation(baseDir, attestation) {
14165
+ if (symlinkOnPath(baseDir, AUTHZ_ATTESTATION_PATH))
14166
+ return false;
14167
+ writeFileSync4(resolve11(baseDir, AUTHZ_ATTESTATION_PATH), attestationJson(attestation), { encoding: "utf8" });
14168
+ return true;
14169
+ }
14170
+
14171
+ // src/commands/init.ts
14172
+ var SLUG_REGEX3 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
14173
+ var initCommand = {
14174
+ name: "init",
14175
+ summary: "scaffold a new launchpad.yaml in the current directory",
14176
+ run: (args, io) => runInit(args, io, defaultPrompt3)
14177
+ };
14178
+ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(), { path: "/me/identity" })) {
14179
+ const parsed = parseArgs6(args);
14180
+ if (parsed.kind === "usage-error") {
14181
+ io.err(`launchpad init: ${parsed.message}`);
14182
+ io.err("Usage: launchpad init [--non-interactive] [flags]");
14183
+ return 64;
14184
+ }
14185
+ const { inputs, options } = parsed;
14186
+ const outPath = resolve12(process.cwd(), options.out);
14187
+ if (options.attestAuthz && !options.secureTemplate) {
14188
+ return attestExistingScaffold(outPath, io, identity);
14189
+ }
14190
+ if (existsSync13(outPath) && !options.force) {
14191
+ io.err(`launchpad init: ${outPath} already exists`);
14192
+ io.err("Pass --force to overwrite.");
14193
+ return 64;
14194
+ }
14195
+ let detected;
14196
+ if (!options.skipDetect && inputs.type !== "container") {
14197
+ const detectResult = detectAppShape(process.cwd());
14198
+ if (detectResult.kind === "ok") {
14199
+ detected = detectResult.detected;
14200
+ if (inputs.type === undefined) {
14201
+ inputs.type = detected.appType;
14202
+ }
14203
+ } else if (detectResult.kind === "ambiguous" && inputs.type === undefined) {
14204
+ io.err(`launchpad init: cannot detect app shape from current directory`);
14205
+ io.err(` ${detectResult.reason}`);
14206
+ io.err(``);
14207
+ io.err(`If you know the app type, pass --type (one of: ${APP_TYPES2.join(", ")}) to bypass detection,`);
14208
+ io.err(`or pass --no-detect to skip detection entirely.`);
14209
+ return 64;
14210
+ }
14211
+ }
14212
+ const fillResult = await fillRequired(inputs, options, io, prompt);
14213
+ if (fillResult.kind === "usage-error") {
14214
+ io.err(`launchpad init: ${fillResult.message}`);
14215
+ return 64;
14216
+ }
14217
+ if (options.secureTemplate && fillResult.inputs.type !== "react+api") {
14218
+ io.err(`launchpad init: --secure-template scaffolds an API and needs --type react+api (got ${fillResult.inputs.type})`);
14219
+ return 64;
14220
+ }
14221
+ const authIssue = deploymentAuthIssue(fillResult.inputs.type, fillResult.inputs.auth ?? "gateway");
13320
14222
  if (authIssue !== null) {
13321
14223
  io.err(`launchpad init: ${authIssue.message}`);
13322
14224
  return 64;
@@ -13343,7 +14245,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
13343
14245
  io.out(`Audience: selected Entra groups (${fillResult.inputs.groups.join(", ")}), plus platform administrators.`);
13344
14246
  io.out("The deploy skill confirms company-wide grants with you. Sensitive apps also require browser confirmation and platform-admin approval.");
13345
14247
  }
13346
- const manifest = buildManifest({ ...fillResult.inputs, ...privateOwner === undefined ? {} : { privateOwner } }, detected);
14248
+ const manifest = buildManifest({ ...fillResult.inputs, ...privateOwner === undefined ? {} : { privateOwner } }, detected, options.secureTemplate ? SECURE_TEMPLATE_INCLUDE : []);
13347
14249
  const validation = manifest.apiVersion === "launchpad.m-kopa.us/v2" ? ManifestV2Schema.safeParse(manifest) : ManifestSchema.safeParse(manifest);
13348
14250
  if (!validation.success) {
13349
14251
  io.err("launchpad init: invalid manifest input");
@@ -13354,7 +14256,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
13354
14256
  }
13355
14257
  const yamlText = renderYaml(manifest);
13356
14258
  try {
13357
- writeFileSync4(outPath, yamlText, { encoding: "utf8" });
14259
+ writeFileSync5(outPath, yamlText, { encoding: "utf8" });
13358
14260
  } catch (err) {
13359
14261
  const e = err;
13360
14262
  io.err(`launchpad init: failed to write ${outPath}`);
@@ -13363,7 +14265,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
13363
14265
  }
13364
14266
  io.out(`✓ wrote ${outPath}`);
13365
14267
  if (options.gitignore) {
13366
- const gitignorePath = resolve11(process.cwd(), ".gitignore");
14268
+ const gitignorePath = resolve12(process.cwd(), ".gitignore");
13367
14269
  try {
13368
14270
  const changed = ensureGitignoreEntries(gitignorePath, [".env", ".env.local"]);
13369
14271
  if (changed.length > 0) {
@@ -13378,12 +14280,12 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
13378
14280
  }
13379
14281
  }
13380
14282
  if (fillResult.inputs.type === "static") {
13381
- const serveDir = resolve11(dirname8(outPath), STATIC_SERVE_DIR);
13382
- const indexPath = resolve11(serveDir, "index.html");
13383
- if (!existsSync12(indexPath)) {
14283
+ const serveDir = resolve12(dirname9(outPath), STATIC_SERVE_DIR);
14284
+ const indexPath = resolve12(serveDir, "index.html");
14285
+ if (!existsSync13(indexPath)) {
13384
14286
  try {
13385
- mkdirSync4(serveDir, { recursive: true });
13386
- writeFileSync4(indexPath, starterIndexHtml(fillResult.inputs.name), {
14287
+ mkdirSync5(serveDir, { recursive: true });
14288
+ writeFileSync5(indexPath, starterIndexHtml(fillResult.inputs.name), {
13387
14289
  encoding: "utf8"
13388
14290
  });
13389
14291
  io.out(`✓ scaffolded ${indexPath}`);
@@ -13394,6 +14296,11 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
13394
14296
  }
13395
14297
  }
13396
14298
  }
14299
+ if (options.secureTemplate) {
14300
+ const code = await scaffoldSecureTemplate(dirname9(outPath), fillResult.inputs.owner, options, io, prompt, identity);
14301
+ if (code !== 0)
14302
+ return code;
14303
+ }
13397
14304
  io.out("");
13398
14305
  io.out("Next steps:");
13399
14306
  io.out(" launchpad validate # confirm the manifest");
@@ -13423,6 +14330,8 @@ function parseArgs6(args) {
13423
14330
  let out = "launchpad.yaml";
13424
14331
  let gitignore = true;
13425
14332
  let skipDetect = false;
14333
+ let secureTemplate = false;
14334
+ let attestAuthz = false;
13426
14335
  for (let i = 0;i < args.length; i++) {
13427
14336
  const a = args[i];
13428
14337
  switch (a) {
@@ -13441,6 +14350,12 @@ function parseArgs6(args) {
13441
14350
  case "--no-detect":
13442
14351
  skipDetect = true;
13443
14352
  continue;
14353
+ case "--secure-template":
14354
+ secureTemplate = true;
14355
+ continue;
14356
+ case "--attest-authz":
14357
+ attestAuthz = true;
14358
+ continue;
13444
14359
  default:
13445
14360
  break;
13446
14361
  }
@@ -13574,7 +14489,7 @@ function parseArgs6(args) {
13574
14489
  return {
13575
14490
  kind: "ok",
13576
14491
  inputs,
13577
- options: { force, nonInteractive, out, gitignore, skipDetect }
14492
+ options: { force, nonInteractive, out, gitignore, skipDetect, secureTemplate, attestAuthz }
13578
14493
  };
13579
14494
  }
13580
14495
  async function fillRequired(inputs, options, io, prompt) {
@@ -13698,7 +14613,7 @@ async function fillRequired(inputs, options, io, prompt) {
13698
14613
  }
13699
14614
  };
13700
14615
  }
13701
- function buildManifest(inputs, detected) {
14616
+ function buildManifest(inputs, detected, extraInclude = []) {
13702
14617
  const metadata = {
13703
14618
  name: inputs.name,
13704
14619
  team: inputs.team,
@@ -13748,7 +14663,7 @@ function buildManifest(inputs, detected) {
13748
14663
  }
13749
14664
  manifest.app = {
13750
14665
  root: ".",
13751
- include: [...defaultIncludeForAppType(inputs.type)]
14666
+ include: [...defaultIncludeForAppType(inputs.type), ...extraInclude]
13752
14667
  };
13753
14668
  if (newAppOrigin(inputs.type, inputs.origin) === "dispatch") {
13754
14669
  return {
@@ -13801,9 +14716,120 @@ function starterIndexHtml(slug) {
13801
14716
  function renderYaml(manifest) {
13802
14717
  return yamlStringify(manifest, { lineWidth: 0 });
13803
14718
  }
14719
+ async function verifiedAttester(io, identity) {
14720
+ try {
14721
+ const who = await identity();
14722
+ if (typeof who?.email !== "string" || who.email.trim() === "" || typeof who.oid !== "string") {
14723
+ throw new Error("the session has no verified email");
14724
+ }
14725
+ return { oid: who.oid, email: who.email };
14726
+ } catch (error) {
14727
+ io.err(` cannot verify who is attesting (${error instanceof Error ? error.message : String(error)}); run \`launchpad login\` first`);
14728
+ return;
14729
+ }
14730
+ }
14731
+ function reportAttestation(input2, io) {
14732
+ const status = attestationStatus(input2);
14733
+ if (status === "attested") {
14734
+ io.out(`✓ authorisation statement attested by the owner ${input2.owner} (${AUTHZ_ATTESTATION_PATH})`);
14735
+ return;
14736
+ }
14737
+ if (status === "attested_by_other") {
14738
+ io.err(`⚠ you are signed in as ${input2.attester?.email ?? "(unknown)"}, not the owner ${input2.owner}: recorded as attested_by_other, not attested`);
14739
+ } else {
14740
+ io.out("⚠ authorisation statement pending");
14741
+ }
14742
+ io.out(` The owner (${input2.owner}) attests by running \`launchpad init --attest-authz\` here while signed in as themselves.`);
14743
+ io.out(` Do not edit ${AUTHZ_ATTESTATION_PATH} by hand: only a record written from the owner's session counts.`);
14744
+ }
14745
+ async function scaffoldSecureTemplate(baseDir, owner, options, io, prompt, identity) {
14746
+ let attests = options.attestAuthz;
14747
+ if (!attests && !options.nonInteractive) {
14748
+ io.out("");
14749
+ io.out("Owner attestation (audit A2-09):");
14750
+ io.out(` ${AUTHZ_STATEMENT}`);
14751
+ const answer = await prompt("Do you, as the app owner, attest this statement? (yes/no): ", "no");
14752
+ attests = /^y(es)?$/i.test(answer.trim());
14753
+ }
14754
+ const attester = attests ? await verifiedAttester(io, identity) : undefined;
14755
+ const attestation = {
14756
+ owner,
14757
+ date: new Date().toISOString().slice(0, 10),
14758
+ ...attester === undefined ? {} : { attester }
14759
+ };
14760
+ let result;
14761
+ try {
14762
+ result = writeSecureApiScaffold(baseDir, attestation);
14763
+ } catch (err) {
14764
+ const e = err;
14765
+ io.err(`launchpad init: failed to write the secure API template: ${e.message ?? String(err)}`);
14766
+ return 2;
14767
+ }
14768
+ for (const p of result.written)
14769
+ io.out(`✓ scaffolded ${p}`);
14770
+ for (const p of result.kept)
14771
+ io.out(` kept existing ${p} (not overwritten)`);
14772
+ for (const p of result.skippedSymlink)
14773
+ io.err(` skipped ${p}: a symlink is on its path`);
14774
+ if (result.written.includes(AUTHZ_ATTESTATION_PATH))
14775
+ reportAttestation(attestation, io);
14776
+ io.out(" Install: npm install hono @m-kopa/platform-auth && npm install -D vitest");
14777
+ io.out(" Set ROLE_WRITER_GROUP_IDS (Entra group object IDs) before the write route accepts anyone.");
14778
+ io.out(" Run the guard test: npx vitest run tests/secure-api.test.ts");
14779
+ return 0;
14780
+ }
14781
+ function existingStatus(path11) {
14782
+ try {
14783
+ const record = JSON.parse(readFileSync17(path11, "utf8"));
14784
+ return typeof record?.status === "string" ? record.status : undefined;
14785
+ } catch {
14786
+ return;
14787
+ }
14788
+ }
14789
+ async function attestExistingScaffold(outPath, io, identity) {
14790
+ const baseDir = dirname9(outPath);
14791
+ if (!existsSync13(resolve12(baseDir, AUTHZ_ATTESTATION_PATH))) {
14792
+ io.err(`launchpad init: --attest-authz needs --secure-template, or an existing ${AUTHZ_ATTESTATION_PATH} beside the manifest`);
14793
+ return 64;
14794
+ }
14795
+ let owner;
14796
+ try {
14797
+ const manifest = yamlParse(readFileSync17(outPath, "utf8"));
14798
+ owner = manifest?.spec?.owner?.email ?? manifest?.metadata?.owner;
14799
+ } catch (err) {
14800
+ io.err(`launchpad init: cannot read ${outPath}: ${err instanceof Error ? err.message : String(err)}`);
14801
+ return 64;
14802
+ }
14803
+ if (typeof owner !== "string" || owner.trim() === "") {
14804
+ io.err(`launchpad init: ${outPath} has no owner (spec.owner.email or metadata.owner) to attest for`);
14805
+ return 64;
14806
+ }
14807
+ const attester = await verifiedAttester(io, identity);
14808
+ if (attester === undefined) {
14809
+ io.err("launchpad init: attestation not recorded");
14810
+ return 1;
14811
+ }
14812
+ const attestation = { owner, date: new Date().toISOString().slice(0, 10), attester };
14813
+ if (attestationStatus(attestation) !== "attested" && existingStatus(resolve12(baseDir, AUTHZ_ATTESTATION_PATH)) === "attested") {
14814
+ reportAttestation(attestation, io);
14815
+ io.err("launchpad init: the owner has already attested; not replaced");
14816
+ return 1;
14817
+ }
14818
+ try {
14819
+ if (!writeAttestation(baseDir, attestation)) {
14820
+ io.err(`launchpad init: ${AUTHZ_ATTESTATION_PATH} is a symlink; not written`);
14821
+ return 2;
14822
+ }
14823
+ } catch (err) {
14824
+ io.err(`launchpad init: failed to write ${AUTHZ_ATTESTATION_PATH}: ${err instanceof Error ? err.message : String(err)}`);
14825
+ return 2;
14826
+ }
14827
+ reportAttestation(attestation, io);
14828
+ return attestationStatus(attestation) === "attested" ? 0 : 1;
14829
+ }
13804
14830
  function ensureGitignoreEntries(path11, entries) {
13805
14831
  let current = "";
13806
- if (existsSync12(path11)) {
14832
+ if (existsSync13(path11)) {
13807
14833
  current = readFileSync17(path11, "utf8");
13808
14834
  }
13809
14835
  const lines = current.split(/\r?\n/);
@@ -13822,7 +14848,7 @@ function ensureGitignoreEntries(path11, entries) {
13822
14848
  }
13823
14849
  }
13824
14850
  if (added.length > 0) {
13825
- writeFileSync4(path11, out, { encoding: "utf8" });
14851
+ writeFileSync5(path11, out, { encoding: "utf8" });
13826
14852
  }
13827
14853
  return added;
13828
14854
  }
@@ -13839,10 +14865,217 @@ async function defaultPrompt3(question, fallback) {
13839
14865
  }
13840
14866
  }
13841
14867
 
14868
+ // src/commands/agreement.ts
14869
+ import { createHash as createHash3 } from "node:crypto";
14870
+
14871
+ // src/io/prompt.ts
14872
+ function isInteractive() {
14873
+ return Boolean(process.stdin.isTTY);
14874
+ }
14875
+ async function defaultPrompt4(question) {
14876
+ const { createInterface: createInterface3 } = await import("node:readline/promises");
14877
+ const rl = createInterface3({ input: process.stdin, output: process.stdout });
14878
+ try {
14879
+ return await rl.question(question);
14880
+ } finally {
14881
+ rl.close();
14882
+ }
14883
+ }
14884
+
14885
+ // src/commands/agreement.ts
14886
+ var REAL_DEPS = {
14887
+ fetcher: (input2, init) => fetch(input2, init),
14888
+ isInteractive,
14889
+ prompt: defaultPrompt4,
14890
+ loadConfig
14891
+ };
14892
+ var agreementCommand = makeAgreementCommand();
14893
+ function makeAgreementCommand(deps = REAL_DEPS) {
14894
+ return {
14895
+ name: "agreement",
14896
+ summary: "read, accept or check the Launchpad access agreement",
14897
+ run: (args, io) => runAgreement(args, io, deps)
14898
+ };
14899
+ }
14900
+ function acceptancePhrase(version) {
14901
+ return `I accept version ${version}`;
14902
+ }
14903
+ async function runAgreement(args, io, deps) {
14904
+ const sub = args[0];
14905
+ if (sub === undefined || sub === "--help" || sub === "-h" || args.includes("--help")) {
14906
+ printHelp3(io);
14907
+ return sub === undefined ? 64 : 0;
14908
+ }
14909
+ try {
14910
+ const cfg = deps.loadConfig();
14911
+ switch (sub) {
14912
+ case "status":
14913
+ return await runStatus2(cfg, io, deps, args.includes("--json"));
14914
+ case "show":
14915
+ return await runShow2(cfg, io, deps);
14916
+ case "accept":
14917
+ return await runAccept(cfg, io, deps);
14918
+ default:
14919
+ io.err(`launchpad agreement: unknown subcommand "${sub}"`);
14920
+ printHelp3(io);
14921
+ return 64;
14922
+ }
14923
+ } catch (error) {
14924
+ io.err(`launchpad agreement ${sub}: ${describe23(error)}`);
14925
+ return 1;
14926
+ }
14927
+ }
14928
+ async function runStatus2(cfg, io, deps, json) {
14929
+ const status = await apiJson(cfg, { path: "/agreement/status" }, deps.fetcher);
14930
+ if (json) {
14931
+ io.out(JSON.stringify(status, null, 2));
14932
+ return 0;
14933
+ }
14934
+ io.out(`Agreement version: ${status.version}${status.approved ? "" : " (not approved yet)"}`);
14935
+ io.out(`State: ${status.state}`);
14936
+ if (status.acceptedVersion !== null) {
14937
+ io.out(`Accepted version: ${status.acceptedVersion}`);
14938
+ }
14939
+ if (status.acceptedAt !== null)
14940
+ io.out(`Accepted on: ${status.acceptedAt.slice(0, 10)}`);
14941
+ if (status.expiresAt !== null)
14942
+ io.out(`Expires on: ${status.expiresAt.slice(0, 10)}`);
14943
+ if (status.graceUntil !== null)
14944
+ io.out(`Re-accept by: ${status.graceUntil.slice(0, 10)}`);
14945
+ const next = nextStepLine(status);
14946
+ if (next !== null)
14947
+ io.out(next);
14948
+ return 0;
14949
+ }
14950
+ async function runShow2(cfg, io, deps) {
14951
+ const agreement = await apiJson(cfg, { path: "/agreement" }, deps.fetcher);
14952
+ io.out(agreement.text);
14953
+ io.out("");
14954
+ io.out(`Version ${agreement.version}${agreement.approved ? "" : " (not approved yet)"}`);
14955
+ io.out(`SHA-256 ${agreement.sha256}`);
14956
+ return 0;
14957
+ }
14958
+ async function runAccept(cfg, io, deps) {
14959
+ if (!deps.isInteractive()) {
14960
+ io.err("launchpad agreement accept: a person must accept in an interactive terminal. " + "If you are an AI agent, stop and ask the human to run `launchpad agreement accept` themselves.");
14961
+ return 1;
14962
+ }
14963
+ const agreement = await apiJson(cfg, { path: "/agreement" }, deps.fetcher);
14964
+ if (!agreement.approved) {
14965
+ io.err(`Agreement ${agreement.version} is not approved yet, so there is nothing to accept. ` + "You can read the draft with `launchpad agreement show`.");
14966
+ return 1;
14967
+ }
14968
+ const shownSha256 = agreementTextSha256(agreement.text);
14969
+ if (shownSha256 !== agreement.sha256) {
14970
+ io.err("Not accepted: the agreement text does not match the hash the bot reported. " + "Nothing was recorded. Try again, and run `launchpad bug` if it keeps happening.");
14971
+ return 1;
14972
+ }
14973
+ io.out(agreement.text);
14974
+ io.out("");
14975
+ io.out(`Version ${agreement.version}, SHA-256 ${shownSha256}`);
14976
+ io.out("");
14977
+ const phrase = acceptancePhrase(agreement.version);
14978
+ const typed = await deps.prompt(`To accept, type exactly "${phrase}": `);
14979
+ if (typed.trim() !== phrase) {
14980
+ io.err("Not accepted: the phrase did not match. Nothing was recorded.");
14981
+ return 1;
14982
+ }
14983
+ const res = await apiRaw(cfg, {
14984
+ method: "POST",
14985
+ path: "/agreement/accept",
14986
+ jsonBody: { version: agreement.version, sha256: shownSha256, phrase: typed.trim() },
14987
+ nonThrowingStatuses: [400, 409, 503]
14988
+ }, deps.fetcher);
14989
+ const body = await res.json().catch(() => ({}));
14990
+ if (!res.ok) {
14991
+ const message = typeof body.message === "string" ? body.message : `HTTP ${res.status}`;
14992
+ io.err(`Not accepted: ${message}`);
14993
+ return 1;
14994
+ }
14995
+ const expires = typeof body.expiresAt === "string" ? body.expiresAt.slice(0, 10) : "(unknown)";
14996
+ io.out(`Agreement ${agreement.version} accepted. Valid until ${expires}.`);
14997
+ return 0;
14998
+ }
14999
+ function agreementTextSha256(text2) {
15000
+ return createHash3("sha256").update(text2, "utf8").digest("hex");
15001
+ }
15002
+ function nextStepLine(status) {
15003
+ if (!status.approved)
15004
+ return null;
15005
+ switch (status.state) {
15006
+ case "current":
15007
+ return null;
15008
+ case "expiring":
15009
+ return `Your Launchpad agreement expires on ${status.expiresAt?.slice(0, 10) ?? "(soon)"}. Run \`launchpad agreement accept\`.`;
15010
+ case "grace":
15011
+ return `Agreement ${status.version} has changed. Accept it by ${status.graceUntil?.slice(0, 10) ?? "(soon)"}: run \`launchpad agreement accept\`.`;
15012
+ case "expired":
15013
+ return "Your Launchpad agreement has expired. Run `launchpad agreement accept`.";
15014
+ default:
15015
+ return `Before you can deploy, read and accept the Launchpad access agreement (version ${status.version}): run \`launchpad agreement accept\`.`;
15016
+ }
15017
+ }
15018
+ async function printAgreementLoginNotice(io, deps = REAL_DEPS, timeoutMs = 5000) {
15019
+ const faultBefore = peekFault();
15020
+ const restoreFault = () => {
15021
+ if (faultBefore === null)
15022
+ clearFault();
15023
+ else
15024
+ recordFault(faultBefore);
15025
+ };
15026
+ try {
15027
+ const cfg = deps.loadConfig();
15028
+ const request = apiJson(cfg, { path: "/agreement/status", signal: AbortSignal.timeout(timeoutMs) }, deps.fetcher).then((status2) => {
15029
+ restoreFault();
15030
+ return status2;
15031
+ }, () => {
15032
+ restoreFault();
15033
+ return null;
15034
+ });
15035
+ const status = await Promise.race([
15036
+ request,
15037
+ new Promise((resolve13) => setTimeout(() => resolve13(null), timeoutMs).unref?.())
15038
+ ]);
15039
+ if (status === null)
15040
+ return;
15041
+ const line = nextStepLine(status);
15042
+ if (line === null)
15043
+ return;
15044
+ io.out("");
15045
+ io.out(line);
15046
+ io.out("An AI agent must not accept for you: open a terminal and run it yourself.");
15047
+ } catch {
15048
+ restoreFault();
15049
+ }
15050
+ }
15051
+ function printHelp3(io) {
15052
+ io.out("launchpad agreement — the Launchpad access agreement.");
15053
+ io.out("");
15054
+ io.out("Usage:");
15055
+ io.out(" launchpad agreement status [--json] Your state against the current version");
15056
+ io.out(" launchpad agreement show Print the current text and its SHA-256");
15057
+ io.out(" launchpad agreement accept Read the text and accept it (interactive terminal only)");
15058
+ io.out("");
15059
+ io.out("You accept once a year, and again when the text changes in a material way.");
15060
+ io.out("An AI agent may not accept for you.");
15061
+ io.out("");
15062
+ io.out("Exit codes:");
15063
+ io.out(" 0 success");
15064
+ io.out(" 1 refused or failed");
15065
+ io.out(" 64 usage error");
15066
+ }
15067
+ function describe23(error) {
15068
+ return error instanceof Error ? error.message : String(error);
15069
+ }
15070
+
13842
15071
  // src/commands/login.ts
13843
- var REAL_DEPS = { gatewayLogin, legacyLogin: login };
15072
+ var REAL_DEPS2 = {
15073
+ gatewayLogin,
15074
+ legacyLogin: login,
15075
+ agreementNotice: (io) => printAgreementLoginNotice(io)
15076
+ };
13844
15077
  var loginCommand = makeLoginCommand();
13845
- function makeLoginCommand(deps = REAL_DEPS) {
15078
+ function makeLoginCommand(deps = REAL_DEPS2) {
13846
15079
  return {
13847
15080
  name: "login",
13848
15081
  summary: "authenticate (browser-based PKCE) and store a session",
@@ -13875,15 +15108,16 @@ async function runLogin(args, io, deps) {
13875
15108
  const expiresIn = Math.max(0, Math.round((session.accessTokenExpiresAt - Date.now()) / 1000));
13876
15109
  io.out(`Logged in. Session stored at ${cfg.sessionPath}`);
13877
15110
  io.out(`Access token expires in ~${expiresIn}s; refreshes silently.`);
15111
+ await agreementNoticeSafely(deps, io);
13878
15112
  return 0;
13879
15113
  } catch (e) {
13880
- io.err(`Gateway login failed: ${describe23(e)}`);
15114
+ io.err(`Gateway login failed: ${describe24(e)}`);
13881
15115
  io.err("Falling back to the legacy Cloudflare Access flow (DEPRECATED — this fallback will be removed when the dual-auth window closes).");
13882
15116
  io.err("");
13883
15117
  return await runLegacyLogin(io, cfg.botUrl, cfg.sessionPath, deps);
13884
15118
  }
13885
15119
  } catch (e) {
13886
- io.err(`launchpad login failed: ${describe23(e)}`);
15120
+ io.err(`launchpad login failed: ${describe24(e)}`);
13887
15121
  return 1;
13888
15122
  }
13889
15123
  }
@@ -13902,6 +15136,7 @@ async function runLegacyLogin(io, botUrl, sessionPath, deps) {
13902
15136
  const expiresIn = Math.max(0, Math.round((session.accessTokenExpiresAt - Date.now()) / 1000));
13903
15137
  io.out(`Logged in. Session stored at ${sessionPath}`);
13904
15138
  io.out(`Access token expires in ~${expiresIn}s; refreshes silently.`);
15139
+ await agreementNoticeSafely(deps, io);
13905
15140
  return 0;
13906
15141
  }
13907
15142
  function printLoginHelp(io) {
@@ -13925,14 +15160,19 @@ function printLoginHelp(io) {
13925
15160
  io.out(" 0 signed in / session stored");
13926
15161
  io.out(" 1 login failed (network, browser, or gateway error)");
13927
15162
  }
13928
- function describe23(e) {
15163
+ async function agreementNoticeSafely(deps, io) {
15164
+ try {
15165
+ await deps.agreementNotice?.(io);
15166
+ } catch {}
15167
+ }
15168
+ function describe24(e) {
13929
15169
  return e instanceof Error ? e.message : String(e);
13930
15170
  }
13931
15171
 
13932
15172
  // src/commands/logout.ts
13933
- var REAL_DEPS2 = { revoke: revokeGatewaySession };
15173
+ var REAL_DEPS3 = { revoke: revokeGatewaySession };
13934
15174
  var logoutCommand = makeLogoutCommand();
13935
- function makeLogoutCommand(deps = REAL_DEPS2) {
15175
+ function makeLogoutCommand(deps = REAL_DEPS3) {
13936
15176
  return {
13937
15177
  name: "logout",
13938
15178
  summary: "revoke the session server-side and clear it locally",
@@ -13962,14 +15202,14 @@ async function runLogout(args, io, deps) {
13962
15202
  });
13963
15203
  io.out("Server-side session revoked.");
13964
15204
  } catch (e) {
13965
- io.err(`warning: could not revoke the session server-side (${describe24(e)}) — clearing the local session anyway. Any in-flight access token expires within 15 minutes.`);
15205
+ io.err(`warning: could not revoke the session server-side (${describe25(e)}) — clearing the local session anyway. Any in-flight access token expires within 15 minutes.`);
13966
15206
  }
13967
15207
  }
13968
15208
  const had = await clearSession(cfg.sessionPath);
13969
15209
  io.out(had ? `Logged out. Session cleared at ${cfg.sessionPath}` : "Already logged out.");
13970
15210
  return 0;
13971
15211
  } catch (e) {
13972
- io.err(`launchpad logout failed: ${describe24(e)}`);
15212
+ io.err(`launchpad logout failed: ${describe25(e)}`);
13973
15213
  return 1;
13974
15214
  }
13975
15215
  }
@@ -13989,7 +15229,7 @@ function printLogoutHelp(io) {
13989
15229
  io.out(" 0 logged out (or already logged out)");
13990
15230
  io.out(" 1 could not clear the local session (file IO / config error)");
13991
15231
  }
13992
- function describe24(e) {
15232
+ function describe25(e) {
13993
15233
  return e instanceof Error ? e.message : String(e);
13994
15234
  }
13995
15235
 
@@ -14064,7 +15304,7 @@ async function runLogs(args, io) {
14064
15304
  io.err(`launchpad logs: ${e.message}`);
14065
15305
  return 1;
14066
15306
  }
14067
- io.err(`launchpad logs failed: ${describe25(e)}`);
15307
+ io.err(`launchpad logs failed: ${describe26(e)}`);
14068
15308
  return 1;
14069
15309
  }
14070
15310
  }
@@ -14153,7 +15393,7 @@ function formatRelative2(iso) {
14153
15393
  return `${hr}h ago`;
14154
15394
  return `${Math.floor(hr / 24)}d ago`;
14155
15395
  }
14156
- function describe25(e) {
15396
+ function describe26(e) {
14157
15397
  return e instanceof Error ? e.message : String(e);
14158
15398
  }
14159
15399
 
@@ -14202,7 +15442,7 @@ async function runMerge(args, io) {
14202
15442
  try {
14203
15443
  body = await res.json();
14204
15444
  } catch (e) {
14205
- io.err(`launchpad merge: bot returned 2xx with malformed body: ${describe26(e)}`);
15445
+ io.err(`launchpad merge: bot returned 2xx with malformed body: ${describe27(e)}`);
14206
15446
  return 1;
14207
15447
  }
14208
15448
  io.out("");
@@ -14242,7 +15482,7 @@ async function runMerge(args, io) {
14242
15482
  io.err(`launchpad merge: ${e.message}`);
14243
15483
  return 1;
14244
15484
  }
14245
- io.err(`launchpad merge failed: ${describe26(e)}`);
15485
+ io.err(`launchpad merge failed: ${describe27(e)}`);
14246
15486
  return 1;
14247
15487
  }
14248
15488
  }
@@ -14341,12 +15581,12 @@ function renderBotError(status, env, io, prNumber = null) {
14341
15581
  io.err(`launchpad merge: bot returned ${status} ${code}${detail !== undefined ? `: ${detail}` : ""}`);
14342
15582
  }
14343
15583
  }
14344
- function describe26(e) {
15584
+ function describe27(e) {
14345
15585
  return e instanceof Error ? e.message : String(e);
14346
15586
  }
14347
15587
 
14348
15588
  // src/commands/plan.ts
14349
- import { resolve as resolve12 } from "node:path";
15589
+ import { resolve as resolve13 } from "node:path";
14350
15590
 
14351
15591
  // src/manifest/container-runtime-warnings.ts
14352
15592
  var CONTAINER_RUNTIME_GATE_WARNING = "Container apps are gated by the platform runtime switch; `launchpad deploy` may return " + "503 container_runtime_off until the platform team enables your app. See docs/concepts/containers.md.";
@@ -14373,7 +15613,7 @@ async function runPlan(args, io) {
14373
15613
  io.err("Usage: launchpad plan [--file <path>] [--json]");
14374
15614
  return 64;
14375
15615
  }
14376
- const manifestPath = resolve12(process.cwd(), flags.file ?? "launchpad.yaml");
15616
+ const manifestPath = resolve13(process.cwd(), flags.file ?? "launchpad.yaml");
14377
15617
  const result = loadManifest(manifestPath);
14378
15618
  if (result.kind === "ok") {
14379
15619
  const unsupported2 = rejectUnsupportedCliRuntime({
@@ -14575,7 +15815,7 @@ import { stdin as input2, stdout as output2 } from "node:process";
14575
15815
  var destroyCommand = {
14576
15816
  name: "destroy",
14577
15817
  summary: "tear down a Launchpad app (owner-only, destructive)",
14578
- run: (args, io) => runDestroy(args, io, defaultPrompt4, defaultIsTty)
15818
+ run: (args, io) => runDestroy(args, io, defaultPrompt5, defaultIsTty)
14579
15819
  };
14580
15820
  var SLUG_RE11 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
14581
15821
  var SLUG_MIN_LENGTH = 3;
@@ -14632,7 +15872,7 @@ async function runDestroy(args, io, prompt, isTty) {
14632
15872
  io.err(`launchpad destroy: ${e.message}`);
14633
15873
  return 1;
14634
15874
  }
14635
- io.err(`launchpad destroy failed: ${describe27(e)}`);
15875
+ io.err(`launchpad destroy failed: ${describe28(e)}`);
14636
15876
  return 1;
14637
15877
  }
14638
15878
  }
@@ -14806,7 +16046,7 @@ function renderBotError2(status, env, slug, io) {
14806
16046
  io.err(`launchpad destroy: bot returned HTTP ${status} (error=${errorCode}): ${message}`);
14807
16047
  }
14808
16048
  }
14809
- async function defaultPrompt4(question) {
16049
+ async function defaultPrompt5(question) {
14810
16050
  const rl = createInterface3({ input: input2, output: output2 });
14811
16051
  try {
14812
16052
  return await rl.question(question);
@@ -14832,12 +16072,12 @@ function printUsage5(io) {
14832
16072
  ].join(`
14833
16073
  `));
14834
16074
  }
14835
- function describe27(e) {
16075
+ function describe28(e) {
14836
16076
  return e instanceof Error ? e.message : String(e);
14837
16077
  }
14838
16078
 
14839
16079
  // src/commands/pull.ts
14840
- import { writeFileSync as writeFileSync5 } from "node:fs";
16080
+ import { writeFileSync as writeFileSync6 } from "node:fs";
14841
16081
  import { stringify as stringifyYaml } from "yaml";
14842
16082
 
14843
16083
  // src/deploy/manifest-status.ts
@@ -14850,7 +16090,7 @@ async function fetchManifestStatus(cfg, slug, fetcher = fetch) {
14850
16090
  import * as fs6 from "node:fs/promises";
14851
16091
  import * as path13 from "node:path";
14852
16092
  import { constants as fsConstants } from "node:fs";
14853
- import { createHash as createHash3 } from "node:crypto";
16093
+ import { createHash as createHash4 } from "node:crypto";
14854
16094
  import { execFile } from "node:child_process";
14855
16095
  var CONFLICT_REPORT = `${MARKER_DIR}/pull-conflicts.json`;
14856
16096
  var CONFLICT_DIR = `${MARKER_DIR}/pull-conflicts`;
@@ -14988,12 +16228,12 @@ async function listFiles(root, relative6 = "") {
14988
16228
  return files.sort();
14989
16229
  }
14990
16230
  function gitOutput(cwd, args) {
14991
- return new Promise((resolve14, reject) => {
16231
+ return new Promise((resolve15, reject) => {
14992
16232
  execFile("git", [...args], { cwd, encoding: "utf8" }, (error, stdout) => {
14993
16233
  if (error !== null)
14994
16234
  reject(error);
14995
16235
  else
14996
- resolve14(stdout);
16236
+ resolve15(stdout);
14997
16237
  });
14998
16238
  });
14999
16239
  }
@@ -15085,7 +16325,7 @@ async function planPath(args, relative6, removals) {
15085
16325
  }
15086
16326
  function conflictPlan(relative6, target, local, head, upstreamDeleted, reason) {
15087
16327
  const suffix = upstreamDeleted ? ".upstream-deleted" : ".upstream";
15088
- const digest = createHash3("sha256").update(relative6).digest("hex");
16328
+ const digest = createHash4("sha256").update(relative6).digest("hex");
15089
16329
  return {
15090
16330
  relative: relative6,
15091
16331
  target,
@@ -15353,7 +16593,7 @@ async function runPull(args, io) {
15353
16593
  }
15354
16594
  const yaml = stringifyYaml(res.status);
15355
16595
  if (parsed.out !== null) {
15356
- writeFileSync5(parsed.out, yaml);
16596
+ writeFileSync6(parsed.out, yaml);
15357
16597
  io.err(`launchpad pull: wrote status (${res.role} view) to ${parsed.out}`);
15358
16598
  } else {
15359
16599
  io.out(yaml.replace(/\n$/, ""));
@@ -15374,7 +16614,7 @@ async function runPull(args, io) {
15374
16614
  return 1;
15375
16615
  }
15376
16616
  if (parsed.out !== null) {
15377
- writeFileSync5(parsed.out, state.manifestYaml);
16617
+ writeFileSync6(parsed.out, state.manifestYaml);
15378
16618
  io.err(`launchpad pull: wrote ${state.manifestYaml.length} bytes to ${parsed.out}`);
15379
16619
  } else {
15380
16620
  io.out(state.manifestYaml.replace(/\n$/, ""));
@@ -15402,7 +16642,7 @@ async function runPull(args, io) {
15402
16642
  io.err(`launchpad pull: ${e.message}`);
15403
16643
  return 1;
15404
16644
  }
15405
- io.err(`launchpad pull failed: ${describe28(e)}`);
16645
+ io.err(`launchpad pull failed: ${describe29(e)}`);
15406
16646
  return 1;
15407
16647
  }
15408
16648
  }
@@ -15503,12 +16743,212 @@ function printUsage6(io) {
15503
16743
  ].join(`
15504
16744
  `));
15505
16745
  }
15506
- function describe28(e) {
16746
+ function describe29(e) {
15507
16747
  return e instanceof Error ? e.message : String(e);
15508
16748
  }
15509
16749
 
15510
- // src/commands/watch.ts
16750
+ // src/commands/disable.ts
15511
16751
  var SLUG_RE13 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
16752
+ var REASON_RE = /^[A-Za-z0-9 ._:#/-]{1,120}$/;
16753
+ var disableCommand = {
16754
+ name: "disable",
16755
+ summary: "switch an app off (serves a 503) without destroying it",
16756
+ run: (args, io) => runVerb("disable", args, io)
16757
+ };
16758
+ var enableCommand = {
16759
+ name: "enable",
16760
+ summary: "switch a disabled app back on",
16761
+ run: (args, io) => runVerb("enable", args, io)
16762
+ };
16763
+ function usage(verb) {
16764
+ return verb === "disable" ? "usage: launchpad disable <slug> --reason <ticket> | launchpad disable <slug> --status" : "usage: launchpad enable <slug> --reason <ticket>";
16765
+ }
16766
+ async function runVerb(verb, args, io) {
16767
+ const parsed = parseAppDisableArgs(verb, args);
16768
+ if (parsed === "help") {
16769
+ printHelp4(verb, io);
16770
+ return 0;
16771
+ }
16772
+ if (typeof parsed === "string") {
16773
+ io.err(`launchpad ${verb}: ${parsed}`);
16774
+ io.err("");
16775
+ io.err(usage(verb));
16776
+ return 64;
16777
+ }
16778
+ return runAppDisable(parsed, io);
16779
+ }
16780
+ function parseAppDisableArgs(verb, args) {
16781
+ let slug = null;
16782
+ let reason = null;
16783
+ let status = false;
16784
+ for (let i = 0;i < args.length; i++) {
16785
+ const a = args[i] ?? "";
16786
+ if (a === "--help" || a === "-h")
16787
+ return "help";
16788
+ if (a === "--status" && verb === "disable") {
16789
+ status = true;
16790
+ continue;
16791
+ }
16792
+ if (a === "--reason") {
16793
+ const v = args[i + 1];
16794
+ if (v === undefined)
16795
+ return "--reason needs a value";
16796
+ reason = v;
16797
+ i++;
16798
+ continue;
16799
+ }
16800
+ if (a.startsWith("--reason=")) {
16801
+ reason = a.slice("--reason=".length);
16802
+ continue;
16803
+ }
16804
+ if (a.startsWith("-"))
16805
+ return `unknown flag ${a}`;
16806
+ if (slug !== null)
16807
+ return `unexpected argument ${a}`;
16808
+ slug = a;
16809
+ }
16810
+ if (slug === null)
16811
+ return "an app slug is required";
16812
+ if (!SLUG_RE13.test(slug))
16813
+ return `invalid slug "${slug}"`;
16814
+ if (status) {
16815
+ if (reason !== null)
16816
+ return "--status takes no --reason";
16817
+ return { verb, slug, reason: null, status: true };
16818
+ }
16819
+ if (reason === null)
16820
+ return "--reason <ticket> is required (for example --reason INC-123)";
16821
+ reason = reason.trim();
16822
+ if (!REASON_RE.test(reason)) {
16823
+ return "--reason must be a ticket reference: letters, digits, space and . _ : # / - (up to 120)";
16824
+ }
16825
+ return { verb, slug, reason, status: false };
16826
+ }
16827
+ async function runAppDisable(opts, io, deps = {}) {
16828
+ const cfg = deps.config ?? loadConfig();
16829
+ const fetcher = deps.fetcher ?? fetch;
16830
+ const { verb, slug } = opts;
16831
+ let resp;
16832
+ try {
16833
+ resp = opts.status ? await apiJson(cfg, { method: "GET", path: `/apps/${slug}/disable` }, fetcher) : await apiJson(cfg, { method: "POST", path: `/apps/${slug}/${verb}`, jsonBody: { reason: opts.reason } }, fetcher);
16834
+ } catch (e) {
16835
+ return mapError2(e, verb, slug, io);
16836
+ }
16837
+ if (opts.status) {
16838
+ if (!resp.disabled) {
16839
+ io.out(`${slug} is not disabled by the runtime switch.`);
16840
+ io.out(" (A disable set in launchpad.yaml spec.lifecycle.disabled is not shown here.)");
16841
+ return 0;
16842
+ }
16843
+ io.out(`${slug} is DISABLED${describeHold(resp)}.`);
16844
+ warnIfNotEnforced(resp, slug, io);
16845
+ return 0;
16846
+ }
16847
+ if (verb === "disable") {
16848
+ if (resp.alreadyDisabled) {
16849
+ io.out(`${slug} was already disabled${describeHold(resp)}. Nothing changed.`);
16850
+ warnIfNotEnforced(resp, slug, io);
16851
+ return 0;
16852
+ }
16853
+ if (resp.upgradedToHold) {
16854
+ io.out(` ${slug} was disabled by an owner; it is now a platform hold that only the platform team can lift.`);
16855
+ }
16856
+ if (resp.enforced === true) {
16857
+ io.out(`✓ ${slug} is disabled. Visitors now get a 503 "This app is disabled" page.`);
16858
+ io.out(" It can take about a minute to reach every edge location. Data and DNS are kept.");
16859
+ } else {
16860
+ io.out(`✓ ${slug} is recorded as disabled.`);
16861
+ warnIfNotEnforced(resp, slug, io);
16862
+ }
16863
+ io.out(` To switch it back on: launchpad enable ${slug} --reason <ticket>`);
16864
+ return 0;
16865
+ }
16866
+ if (resp.alreadyEnabled) {
16867
+ io.out(`${slug} was not disabled by the runtime switch. Nothing changed.`);
16868
+ io.out(" If it still shows the disabled page, check spec.lifecycle.disabled in launchpad.yaml.");
16869
+ return 0;
16870
+ }
16871
+ io.out(`✓ ${slug} is enabled again. It can take about a minute to reach every edge location.`);
16872
+ return 0;
16873
+ }
16874
+ function warnIfNotEnforced(resp, slug, io) {
16875
+ if (resp.enforced === true)
16876
+ return;
16877
+ if (resp.fronted === "access") {
16878
+ io.err(`! ${slug} is not fronted by the gateway (for example auth: access). This switch does NOT stop it.`);
16879
+ return;
16880
+ }
16881
+ if (resp.gatewayMode === "off" || resp.gatewayMode === "report") {
16882
+ io.err(`! The gateway is not enforcing disables yet (mode: ${resp.gatewayMode}). ${slug} is STILL SERVING visitors.`);
16883
+ io.err(" Ask the Launchpad platform team to switch the gateway to enforce, or use another control.");
16884
+ return;
16885
+ }
16886
+ io.err(`! The bot did not confirm that the gateway enforces this. Check that ${slug} returns a 503.`);
16887
+ }
16888
+ function describeHold(resp) {
16889
+ if (resp.malformed)
16890
+ return " (record unreadable; only the platform team can enable it)";
16891
+ const parts = [];
16892
+ if (resp.actorRole === "break_glass" || resp.platformHold === true && resp.actorRole === undefined) {
16893
+ parts.push("by the platform team");
16894
+ }
16895
+ if (resp.actorRole === "owner")
16896
+ parts.push("by an owner");
16897
+ if (typeof resp.disabledAt === "number")
16898
+ parts.push(`at ${new Date(resp.disabledAt * 1000).toISOString()}`);
16899
+ if (typeof resp.reason === "string")
16900
+ parts.push(`reason ${resp.reason}`);
16901
+ return parts.length === 0 ? "" : ` (${parts.join(", ")})`;
16902
+ }
16903
+ function mapError2(e, verb, slug, io) {
16904
+ if (e instanceof UnauthenticatedError) {
16905
+ io.err(`✗ ${verb} ${slug}: ${e.message}`);
16906
+ return 3;
16907
+ }
16908
+ if (e instanceof ForbiddenError) {
16909
+ io.err(`✗ ${verb} ${slug}: forbidden. ${e.message}`);
16910
+ if (verb === "enable") {
16911
+ io.err(" If the platform team disabled this app, only the platform team can enable it.");
16912
+ } else {
16913
+ io.err(" Only an owner, a co-owner or the platform team can disable an app.");
16914
+ }
16915
+ return 1;
16916
+ }
16917
+ if (e instanceof NotFoundError) {
16918
+ io.err(`✗ ${verb} ${slug}: not found. Either there is no app '${slug}', or the`);
16919
+ io.err(" disable feature is not switched on yet (ask the Launchpad platform team).");
16920
+ return 1;
16921
+ }
16922
+ if (e instanceof TransportError) {
16923
+ io.err(`✗ ${verb} ${slug}: ${e.message}`);
16924
+ return 2;
16925
+ }
16926
+ if (e instanceof ApiError) {
16927
+ io.err(`✗ ${verb} ${slug}: ${e.message}`);
16928
+ return 1;
16929
+ }
16930
+ io.err(`✗ ${verb} ${slug} failed: ${e instanceof Error ? e.message : String(e)}`);
16931
+ return 2;
16932
+ }
16933
+ function printHelp4(verb, io) {
16934
+ io.out(usage(verb));
16935
+ io.out("");
16936
+ if (verb === "disable") {
16937
+ io.out("Switch an app off without destroying it. Visitors get a 503 page; data, DNS and");
16938
+ io.out("the deployment are kept. Owner, co-owner or platform team only.");
16939
+ io.out("");
16940
+ io.out(" --reason <ticket> required: a ticket reference, e.g. INC-123");
16941
+ io.out(" --status show whether the app is disabled (any role on the app)");
16942
+ } else {
16943
+ io.out("Switch a disabled app back on. An owner can lift a disable an owner set; a");
16944
+ io.out("disable set by the platform team needs the platform team.");
16945
+ io.out("");
16946
+ io.out(" --reason <ticket> required: a ticket reference, e.g. INC-123");
16947
+ }
16948
+ }
16949
+
16950
+ // src/commands/watch.ts
16951
+ var SLUG_RE14 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
15512
16952
  function printUsage7(io) {
15513
16953
  io.err("usage: launchpad watch [<slug>] [--slug <slug>] [--file <path>]");
15514
16954
  io.err(" Watch an app provision to live in real time.");
@@ -15534,7 +16974,7 @@ function resolveWatchSlug(args, cwd, warn) {
15534
16974
  if (slug === undefined) {
15535
16975
  return { error: "no slug given and none could be inferred from the current directory" };
15536
16976
  }
15537
- if (!SLUG_RE13.test(slug)) {
16977
+ if (!SLUG_RE14.test(slug)) {
15538
16978
  return { error: `invalid slug: "${slug}"` };
15539
16979
  }
15540
16980
  return { slug };
@@ -15561,7 +17001,7 @@ var reviewCommand = {
15561
17001
  summary: "show the review state for a PR (slug-scoped)",
15562
17002
  run: runReview
15563
17003
  };
15564
- var SLUG_RE14 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
17004
+ var SLUG_RE15 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
15565
17005
  async function runReview(args, io) {
15566
17006
  const parsed = parseArgs11(args);
15567
17007
  if (parsed === null) {
@@ -15581,8 +17021,8 @@ async function runReview(args, io) {
15581
17021
  }
15582
17022
  slug = inferred;
15583
17023
  }
15584
- if (!SLUG_RE14.test(slug)) {
15585
- io.err(`launchpad review: invalid slug "${slug}" — expected ${SLUG_RE14.source}`);
17024
+ if (!SLUG_RE15.test(slug)) {
17025
+ io.err(`launchpad review: invalid slug "${slug}" — expected ${SLUG_RE15.source}`);
15586
17026
  return 64;
15587
17027
  }
15588
17028
  try {
@@ -15625,7 +17065,7 @@ async function runReview(args, io) {
15625
17065
  io.err(`launchpad review: ${e.message}`);
15626
17066
  return 1;
15627
17067
  }
15628
- io.err(`launchpad review failed: ${describe29(e)}`);
17068
+ io.err(`launchpad review failed: ${describe30(e)}`);
15629
17069
  return 1;
15630
17070
  }
15631
17071
  }
@@ -15703,12 +17143,12 @@ function severityRank(s) {
15703
17143
  return 3;
15704
17144
  }
15705
17145
  }
15706
- function describe29(e) {
17146
+ function describe30(e) {
15707
17147
  return e instanceof Error ? e.message : String(e);
15708
17148
  }
15709
17149
 
15710
17150
  // src/deploy/rollback.ts
15711
- import { existsSync as existsSync13, readFileSync as readFileSync18, writeFileSync as writeFileSync6 } from "node:fs";
17151
+ import { existsSync as existsSync14, readFileSync as readFileSync18, writeFileSync as writeFileSync7 } from "node:fs";
15712
17152
  import { resolve as resolvePath4 } from "node:path";
15713
17153
  import { createInterface as createInterface4 } from "node:readline/promises";
15714
17154
 
@@ -15763,7 +17203,7 @@ async function runRollback(opts, io, deps = {}) {
15763
17203
  cwd: process.cwd()
15764
17204
  });
15765
17205
  } catch (e) {
15766
- io.err(`launchpad rollback: git rev-parse failed to start: ${describe30(e)}`);
17206
+ io.err(`launchpad rollback: git rev-parse failed to start: ${describe31(e)}`);
15767
17207
  return 2;
15768
17208
  }
15769
17209
  if (revParse.exitCode !== 0) {
@@ -15778,7 +17218,7 @@ async function runRollback(opts, io, deps = {}) {
15778
17218
  try {
15779
17219
  show = await runner.run("git", ["show", `${verifiedSha}:${manifestRelpath}`], { cwd: process.cwd() });
15780
17220
  } catch (e) {
15781
- io.err(`launchpad rollback: git show failed to start: ${describe30(e)}`);
17221
+ io.err(`launchpad rollback: git show failed to start: ${describe31(e)}`);
15782
17222
  return 2;
15783
17223
  }
15784
17224
  if (show.exitCode !== 0) {
@@ -15798,7 +17238,7 @@ async function runRollback(opts, io, deps = {}) {
15798
17238
  io.out(`Rollback target: ${verifiedSha.slice(0, 12)} (${manifestRelpath})`);
15799
17239
  renderDiff(current, parsed.manifest, io);
15800
17240
  if (!opts.yes) {
15801
- const prompt = deps.prompt ?? defaultPrompt5;
17241
+ const prompt = deps.prompt ?? defaultPrompt6;
15802
17242
  if (!process.stdin.isTTY && deps.prompt === undefined) {
15803
17243
  io.err("launchpad rollback: refusing to rollback non-interactively without --yes.");
15804
17244
  return 64;
@@ -15810,9 +17250,9 @@ async function runRollback(opts, io, deps = {}) {
15810
17250
  }
15811
17251
  }
15812
17252
  try {
15813
- writeFileSync6(manifestPath, historicalYaml, "utf8");
17253
+ writeFileSync7(manifestPath, historicalYaml, "utf8");
15814
17254
  } catch (e) {
15815
- io.err(`launchpad rollback: failed to write ${manifestPath}: ${describe30(e)}`);
17255
+ io.err(`launchpad rollback: failed to write ${manifestPath}: ${describe31(e)}`);
15816
17256
  return 2;
15817
17257
  }
15818
17258
  io.out(`Restored ${manifestPath} from ${verifiedSha.slice(0, 12)}.`);
@@ -15833,7 +17273,7 @@ async function runRollback(opts, io, deps = {}) {
15833
17273
  }, io, applyDeps);
15834
17274
  }
15835
17275
  function readCurrentManifest(path15) {
15836
- if (!existsSync13(path15))
17276
+ if (!existsSync14(path15))
15837
17277
  return null;
15838
17278
  let raw;
15839
17279
  try {
@@ -15886,7 +17326,7 @@ function formatHostnames(hs) {
15886
17326
  return hs[0];
15887
17327
  return `[${hs.join(", ")}]`;
15888
17328
  }
15889
- async function defaultPrompt5(question) {
17329
+ async function defaultPrompt6(question) {
15890
17330
  const rl = createInterface4({ input: process.stdin, output: process.stderr });
15891
17331
  try {
15892
17332
  return await rl.question(question);
@@ -15894,7 +17334,7 @@ async function defaultPrompt5(question) {
15894
17334
  rl.close();
15895
17335
  }
15896
17336
  }
15897
- function describe30(e) {
17337
+ function describe31(e) {
15898
17338
  return e instanceof Error ? e.message : String(e);
15899
17339
  }
15900
17340
  function renderManifestError4(result, io) {
@@ -16106,7 +17546,7 @@ function renderManifestError5(result, io) {
16106
17546
  }
16107
17547
 
16108
17548
  // src/secrets/set.ts
16109
- import { existsSync as existsSync14, readFileSync as readFileSync19 } from "node:fs";
17549
+ import { existsSync as existsSync15, readFileSync as readFileSync19 } from "node:fs";
16110
17550
  import { resolve as resolvePath6 } from "node:path";
16111
17551
  import { parse as parseYaml9 } from "yaml";
16112
17552
  var CELL_LABEL2 = {
@@ -16116,7 +17556,7 @@ var CELL_LABEL2 = {
16116
17556
  };
16117
17557
  function loadSet(fleetFile, setName, io) {
16118
17558
  const path15 = resolvePath6(process.cwd(), fleetFile ?? "fleet-secret-sets.yaml");
16119
- if (!existsSync14(path15)) {
17559
+ if (!existsSync15(path15)) {
16120
17560
  io.err(`✗ ${path15}`);
16121
17561
  io.err(" fleet-secret-sets.yaml not found. Run from the platform repo root or pass --fleet-file.");
16122
17562
  return 2;
@@ -16212,7 +17652,7 @@ async function runSecretsPushSet(opts, io, deps = {}) {
16212
17652
  if (typeof set === "number")
16213
17653
  return set;
16214
17654
  const envPath = resolvePath6(process.cwd(), opts.env ?? ".env");
16215
- if (!existsSync14(envPath)) {
17655
+ if (!existsSync15(envPath)) {
16216
17656
  io.err(`launchpad secrets push --set: ${envPath} not found.`);
16217
17657
  io.err(` Create a .env carrying the set's secrets: ${set.secrets.join(", ")}`);
16218
17658
  return 2;
@@ -16363,8 +17803,8 @@ function setPushExit(e) {
16363
17803
  }
16364
17804
 
16365
17805
  // src/commands/secrets-template.ts
16366
- import { existsSync as existsSync15, writeFileSync as writeFileSync7 } from "node:fs";
16367
- import { resolve as resolve14 } from "node:path";
17806
+ import { existsSync as existsSync16, writeFileSync as writeFileSync8 } from "node:fs";
17807
+ import { resolve as resolve15 } from "node:path";
16368
17808
  async function runSecretsTemplate(args, io) {
16369
17809
  const flags = parseFlags4(args);
16370
17810
  if (flags.kind === "usage-error") {
@@ -16372,7 +17812,7 @@ async function runSecretsTemplate(args, io) {
16372
17812
  io.err("Usage: launchpad secrets template [--file <path>] [--out <path>] " + "[--stdout] [--force] [--include-platform-managed]");
16373
17813
  return 64;
16374
17814
  }
16375
- const manifestPath = resolve14(process.cwd(), flags.file ?? "launchpad.yaml");
17815
+ const manifestPath = resolve15(process.cwd(), flags.file ?? "launchpad.yaml");
16376
17816
  const renderResult = renderManifest(loadManifestAnyVersion(manifestPath), io);
16377
17817
  if (renderResult.kind !== "ok") {
16378
17818
  return renderResult.code;
@@ -16386,14 +17826,14 @@ async function runSecretsTemplate(args, io) {
16386
17826
  }
16387
17827
  return 0;
16388
17828
  }
16389
- const outPath = resolve14(process.cwd(), flags.out);
16390
- if (existsSync15(outPath) && !flags.force) {
17829
+ const outPath = resolve15(process.cwd(), flags.out);
17830
+ if (existsSync16(outPath) && !flags.force) {
16391
17831
  io.err(`launchpad secrets template: ${outPath} already exists`);
16392
17832
  io.err("Pass --force to overwrite, or --stdout to print without writing.");
16393
17833
  return 64;
16394
17834
  }
16395
17835
  try {
16396
- writeFileSync7(outPath, body, { encoding: "utf8" });
17836
+ writeFileSync8(outPath, body, { encoding: "utf8" });
16397
17837
  } catch (err) {
16398
17838
  const e = err;
16399
17839
  io.err(`launchpad secrets template: failed to write ${outPath}`);
@@ -16527,7 +17967,7 @@ var secretsCommand = {
16527
17967
  async function runSecrets(args, io) {
16528
17968
  const sub = args[0];
16529
17969
  if (sub === undefined || sub === "--help" || sub === "-h") {
16530
- printHelp3(io);
17970
+ printHelp5(io);
16531
17971
  return 0;
16532
17972
  }
16533
17973
  if (sub === "template") {
@@ -16670,7 +18110,7 @@ function parseStatusArgs(args) {
16670
18110
  }
16671
18111
  return { file, slug };
16672
18112
  }
16673
- function printHelp3(io) {
18113
+ function printHelp5(io) {
16674
18114
  io.out("Usage: launchpad secrets <subcommand> [options]");
16675
18115
  io.out("");
16676
18116
  io.out("Subcommands:");
@@ -16688,16 +18128,16 @@ function printHelp3(io) {
16688
18128
 
16689
18129
  // src/commands/skills.ts
16690
18130
  import { fileURLToPath } from "node:url";
16691
- import { dirname as dirname10, join as join16, resolve as resolve15 } from "node:path";
16692
- import { promises as fs7, existsSync as existsSync16 } from "node:fs";
18131
+ import { dirname as dirname11, join as join17, resolve as resolve16 } from "node:path";
18132
+ import { promises as fs7, existsSync as existsSync17 } from "node:fs";
16693
18133
 
16694
18134
  // src/skills-bundle.ts
16695
18135
  import { homedir as homedir2 } from "node:os";
16696
- import { join as join15 } from "node:path";
18136
+ import { join as join16 } from "node:path";
16697
18137
  import { readFileSync as readFileSync20, readdirSync as readdirSync3 } from "node:fs";
16698
18138
  var SKILL_PREFIX = "launchpad-";
16699
18139
  function skillsTargetDir() {
16700
- return process.env.LAUNCHPAD_SKILLS_TARGET_DIR ?? join15(homedir2(), ".claude", "skills");
18140
+ return process.env.LAUNCHPAD_SKILLS_TARGET_DIR ?? join16(homedir2(), ".claude", "skills");
16701
18141
  }
16702
18142
  function readInstalledSkills() {
16703
18143
  try {
@@ -16707,7 +18147,7 @@ function readInstalledSkills() {
16707
18147
  return { present: false, version: null };
16708
18148
  return {
16709
18149
  present: true,
16710
- version: readSkillVersion(join15(dir, bundle.name, "SKILL.md"))
18150
+ version: readSkillVersion(join16(dir, bundle.name, "SKILL.md"))
16711
18151
  };
16712
18152
  } catch {
16713
18153
  return { present: false, version: null };
@@ -16737,6 +18177,7 @@ var BUNDLED_SKILLS = [
16737
18177
  "launchpad-destroy",
16738
18178
  "launchpad-identity",
16739
18179
  "launchpad-ingest",
18180
+ "launchpad-integration-contract",
16740
18181
  "launchpad-report",
16741
18182
  "marquee-share"
16742
18183
  ];
@@ -16751,7 +18192,7 @@ var skillsCommand = {
16751
18192
  async function runSkills(args, io) {
16752
18193
  const action = args[0];
16753
18194
  if (action === undefined || action === "--help" || action === "-h") {
16754
- printHelp4(io);
18195
+ printHelp6(io);
16755
18196
  return action === undefined ? 64 : 0;
16756
18197
  }
16757
18198
  try {
@@ -16766,15 +18207,15 @@ async function runSkills(args, io) {
16766
18207
  default:
16767
18208
  io.err(`launchpad skills: unknown action "${action}"`);
16768
18209
  io.err("");
16769
- printHelp4(io);
18210
+ printHelp6(io);
16770
18211
  return 64;
16771
18212
  }
16772
18213
  } catch (e) {
16773
- io.err(`launchpad skills ${action}: ${describe31(e)}`);
18214
+ io.err(`launchpad skills ${action}: ${describe32(e)}`);
16774
18215
  return 1;
16775
18216
  }
16776
18217
  }
16777
- function printHelp4(io) {
18218
+ function printHelp6(io) {
16778
18219
  io.out("launchpad skills — manage the Launchpad Claude Code slash-command bundle");
16779
18220
  io.out("");
16780
18221
  io.out("Usage:");
@@ -16793,13 +18234,13 @@ function resolveInstallEnv() {
16793
18234
  return { bundleDir, userSkillsDir };
16794
18235
  }
16795
18236
  function defaultBundleDir() {
16796
- const here = dirname10(fileURLToPath(import.meta.url));
18237
+ const here = dirname11(fileURLToPath(import.meta.url));
16797
18238
  const candidates = [
16798
- resolve15(here, "..", "skills"),
16799
- resolve15(here, "..", "..", "skills")
18239
+ resolve16(here, "..", "skills"),
18240
+ resolve16(here, "..", "..", "skills")
16800
18241
  ];
16801
18242
  for (const c of candidates) {
16802
- if (existsSync16(join16(c, "launchpad-onboard", "SKILL.md"))) {
18243
+ if (existsSync17(join17(c, "launchpad-onboard", "SKILL.md"))) {
16803
18244
  return c;
16804
18245
  }
16805
18246
  }
@@ -16820,12 +18261,12 @@ async function doInstall(io) {
16820
18261
  }
16821
18262
  let installed = 0;
16822
18263
  for (const skill of BUNDLED_SKILLS) {
16823
- const src = join16(env.bundleDir, skill);
18264
+ const src = join17(env.bundleDir, skill);
16824
18265
  if (!await isDir(src)) {
16825
18266
  io.err(`launchpad skills install: bundled skill "${skill}" missing from ${env.bundleDir} — package is incomplete.`);
16826
18267
  return 1;
16827
18268
  }
16828
- const dest = join16(env.userSkillsDir, skill);
18269
+ const dest = join17(env.userSkillsDir, skill);
16829
18270
  await fs7.rm(dest, { recursive: true, force: true });
16830
18271
  await fs7.cp(src, dest, { recursive: true });
16831
18272
  installed++;
@@ -16850,7 +18291,7 @@ async function doUninstall(io) {
16850
18291
  continue;
16851
18292
  if (!isBundleManaged(entry.name))
16852
18293
  continue;
16853
- const target = join16(env.userSkillsDir, entry.name);
18294
+ const target = join17(env.userSkillsDir, entry.name);
16854
18295
  await fs7.rm(target, { recursive: true, force: true });
16855
18296
  removed++;
16856
18297
  io.out(`✗ removed ${target}`);
@@ -16873,7 +18314,7 @@ async function doList(io) {
16873
18314
  }
16874
18315
  const width = managedDirs.reduce((n, s) => Math.max(n, s.length), 0);
16875
18316
  for (const name of managedDirs) {
16876
- const skillFile = join16(env.userSkillsDir, name, "SKILL.md");
18317
+ const skillFile = join17(env.userSkillsDir, name, "SKILL.md");
16877
18318
  const version = await readVersion(skillFile);
16878
18319
  io.out(` ${name.padEnd(width + 2)}${version ?? "(no version)"}`);
16879
18320
  }
@@ -16900,7 +18341,7 @@ async function isDir(path15) {
16900
18341
  return false;
16901
18342
  }
16902
18343
  }
16903
- function describe31(e) {
18344
+ function describe32(e) {
16904
18345
  return e instanceof Error ? e.message : String(e);
16905
18346
  }
16906
18347
 
@@ -16908,13 +18349,13 @@ function describe31(e) {
16908
18349
  import { execFile as execFile2, spawn as spawn5 } from "node:child_process";
16909
18350
  import { promisify } from "node:util";
16910
18351
  import { fileURLToPath as fileURLToPath2 } from "node:url";
16911
- import { dirname as dirname11, resolve as resolve16, relative as relative6, isAbsolute as isAbsolute3, join as join17 } from "node:path";
18352
+ import { dirname as dirname12, resolve as resolve17, relative as relative6, isAbsolute as isAbsolute3, join as join18 } from "node:path";
16912
18353
  import { homedir as homedir3, tmpdir } from "node:os";
16913
- import { readFileSync as readFileSync21, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync8, rmSync as rmSync3 } from "node:fs";
18354
+ import { readFileSync as readFileSync21, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync9, rmSync as rmSync3 } from "node:fs";
16914
18355
 
16915
18356
  // src/commands/channel-auth.ts
16916
18357
  import { createServer as createServer2 } from "node:http";
16917
- import { createHash as createHash4, randomBytes as randomBytes5 } from "node:crypto";
18358
+ import { createHash as createHash5, randomBytes as randomBytes5 } from "node:crypto";
16918
18359
  var CHANNEL_BASE = "https://get.launchpad.m-kopa.us";
16919
18360
  var CLI_AUTH_URL = `${CHANNEL_BASE}/__cli_auth`;
16920
18361
  var CLI_TOKEN_URL = `${CHANNEL_BASE}/__cli_token`;
@@ -16925,7 +18366,7 @@ function base64url(b) {
16925
18366
  }
16926
18367
  function pkcePair() {
16927
18368
  const verifier = base64url(randomBytes5(32));
16928
- const challenge = base64url(createHash4("sha256").update(verifier).digest());
18369
+ const challenge = base64url(createHash5("sha256").update(verifier).digest());
16929
18370
  return { verifier, challenge };
16930
18371
  }
16931
18372
  async function startLoopback(state, timeoutMs) {
@@ -16953,9 +18394,9 @@ async function startLoopback(state, timeoutMs) {
16953
18394
  resolveCode(code);
16954
18395
  }
16955
18396
  });
16956
- const bound = await new Promise((resolve16) => {
16957
- server.once("error", () => resolve16(false));
16958
- server.listen(0, "127.0.0.1", () => resolve16(true));
18397
+ const bound = await new Promise((resolve17) => {
18398
+ server.once("error", () => resolve17(false));
18399
+ server.listen(0, "127.0.0.1", () => resolve17(true));
16959
18400
  });
16960
18401
  if (!bound)
16961
18402
  return null;
@@ -17031,7 +18472,7 @@ var PKG = "@m-kopa/launchpad-cli";
17031
18472
  var REGISTRY = "https://registry.npmjs.org";
17032
18473
  var CHANNEL_VERSION_URL = "https://get.launchpad.m-kopa.us/version.json";
17033
18474
  var CHANNEL_INSTALL_URL = "https://get.launchpad.m-kopa.us";
17034
- var CHANNEL_MARKER = join17(homedir3(), ".launchpad", "channel");
18475
+ var CHANNEL_MARKER = join18(homedir3(), ".launchpad", "channel");
17035
18476
  var EXIT_UPDATE_AVAILABLE = 10;
17036
18477
  var UPGRADE_ARGS = {
17037
18478
  npm: ["install", "-g", `${PKG}@latest`],
@@ -17160,10 +18601,10 @@ async function openSystemBrowser(url) {
17160
18601
  await execFileAsync(opener, [url]);
17161
18602
  }
17162
18603
  async function runInstallerScript(script) {
17163
- const dir = mkdtempSync2(join17(tmpdir(), "launchpad-update-"));
17164
- const file = join17(dir, "install.sh");
18604
+ const dir = mkdtempSync2(join18(tmpdir(), "launchpad-update-"));
18605
+ const file = join18(dir, "install.sh");
17165
18606
  try {
17166
- writeFileSync8(file, script, { mode: 448 });
18607
+ writeFileSync9(file, script, { mode: 448 });
17167
18608
  return await new Promise((resolvePromise) => {
17168
18609
  const child = spawn5("bash", [file], { stdio: "inherit" });
17169
18610
  child.on("error", () => resolvePromise(127));
@@ -17248,7 +18689,7 @@ function errStderr(e) {
17248
18689
  return "";
17249
18690
  }
17250
18691
  async function detectPackageManager2() {
17251
- const pkgRoot = resolve16(dirname11(fileURLToPath2(import.meta.url)), "..", "..");
18692
+ const pkgRoot = resolve17(dirname12(fileURLToPath2(import.meta.url)), "..", "..");
17252
18693
  const candidates = [];
17253
18694
  const npmRoot = await pmRoot("npm");
17254
18695
  if (npmRoot !== null)
@@ -17256,7 +18697,7 @@ async function detectPackageManager2() {
17256
18697
  const pnpmRoot = await pmRoot("pnpm");
17257
18698
  if (pnpmRoot !== null)
17258
18699
  candidates.push(["pnpm", pnpmRoot]);
17259
- candidates.push(["bun", resolve16(homedir3(), ".bun/install/global/node_modules")]);
18700
+ candidates.push(["bun", resolve17(homedir3(), ".bun/install/global/node_modules")]);
17260
18701
  const matches = candidates.filter(([, root]) => pathContains(root, pkgRoot));
17261
18702
  return matches.length === 1 ? matches[0][0] : null;
17262
18703
  }
@@ -17288,11 +18729,11 @@ async function runUpdate(args, io, deps) {
17288
18729
  if (parsed.error !== null) {
17289
18730
  io.err(`launchpad update: ${parsed.error}`);
17290
18731
  io.err("");
17291
- printHelp5(io);
18732
+ printHelp7(io);
17292
18733
  return 64;
17293
18734
  }
17294
18735
  if (parsed.help) {
17295
- printHelp5(io);
18736
+ printHelp7(io);
17296
18737
  return 0;
17297
18738
  }
17298
18739
  const latest = await deps.fetchLatestVersion();
@@ -17369,7 +18810,7 @@ async function runUpdate(args, io, deps) {
17369
18810
  await syncSkillsAfterUpgrade(io, deps);
17370
18811
  return 0;
17371
18812
  }
17372
- function printHelp5(io) {
18813
+ function printHelp7(io) {
17373
18814
  io.out("launchpad update — self-update the launchpad CLI.");
17374
18815
  io.out("");
17375
18816
  io.out("Usage:");
@@ -17393,8 +18834,83 @@ function printHelp5(io) {
17393
18834
  }
17394
18835
 
17395
18836
  // src/commands/validate.ts
17396
- import { existsSync as existsSync17, readFileSync as readFileSync22, readdirSync as readdirSync4, statSync as statSync2 } from "node:fs";
17397
- import { dirname as dirname12, resolve as resolve17 } from "node:path";
18837
+ import { existsSync as existsSync18, readFileSync as readFileSync23, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
18838
+ import { dirname as dirname13, resolve as resolve18 } from "node:path";
18839
+
18840
+ // src/commands/app-lints.ts
18841
+ import { readFileSync as readFileSync22, statSync as statSync2 } from "node:fs";
18842
+ import { join as join19 } from "node:path";
18843
+ var MAX_READ_BYTES = 512000;
18844
+ function cleanRoot(rootDir) {
18845
+ if (rootDir === undefined)
18846
+ return;
18847
+ const r = rootDir.replace(/^\.\/?/, "").replace(/\/+$/, "");
18848
+ return r === "" ? undefined : r;
18849
+ }
18850
+ function runAppLints(dir, rootDir) {
18851
+ const root = cleanRoot(rootDir);
18852
+ const files = {};
18853
+ let skipped;
18854
+ try {
18855
+ for (const rel of walkCwd(dir).files) {
18856
+ const inRoot = root === undefined ? rel : rel.startsWith(`${root}/`) ? rel.slice(root.length + 1) : null;
18857
+ if (inRoot === null || !isServerCodePath(inRoot))
18858
+ continue;
18859
+ const abs = join19(dir, rel);
18860
+ if (statSync2(abs).size > MAX_READ_BYTES)
18861
+ continue;
18862
+ files[rel] = readFileSync22(abs, "utf8");
18863
+ }
18864
+ } catch (e) {
18865
+ skipped = e instanceof Error ? e.message : String(e);
18866
+ }
18867
+ const opts = root === undefined ? {} : { rootDir: root };
18868
+ return {
18869
+ routeAuth: lintRouteAuth(files, opts),
18870
+ assertion: lintAssertionVerification(files, opts),
18871
+ ...skipped === undefined ? {} : { skipped }
18872
+ };
18873
+ }
18874
+ function renderAppLintsHuman(r) {
18875
+ const out = [];
18876
+ if (r.skipped !== undefined) {
18877
+ out.push(`⚠ app lints: skipped (${r.skipped})`);
18878
+ return out;
18879
+ }
18880
+ out.push(` app lints: ${r.routeAuth.serverFiles} server file(s), ${r.routeAuth.writeRoutes} write route(s), identity assertion: ${r.assertion.status}`);
18881
+ for (const f of r.routeAuth.findings) {
18882
+ out.push(`⚠ app lint [${f.severity}] route-without-auth: ${f.path} (${f.methods.join(", ")}; ${f.routes} route(s)) has no identity check in reach`);
18883
+ }
18884
+ for (const f of r.assertion.findings) {
18885
+ const extra = f.maxAgeSeconds === undefined ? "" : ` (max-age ${f.maxAgeSeconds}s)`;
18886
+ out.push(`⚠ app lint [${f.severity}] ${f.rule}: ${f.path}${extra}`);
18887
+ }
18888
+ if (r.routeAuth.findings.length + r.assertion.findings.length > 0) {
18889
+ out.push(" Report only: these do not fail validate or deploy today.");
18890
+ out.push(" Fix: verify X-Launchpad-User-Assertion with @m-kopa/platform-auth in a middleware around every route,");
18891
+ out.push(" and check the caller's role on every write route. See the launchpad-identity skill.");
18892
+ }
18893
+ return out;
18894
+ }
18895
+ function appLintsJson(r) {
18896
+ return {
18897
+ reportOnly: true,
18898
+ ...r.skipped === undefined ? {} : { skipped: r.skipped },
18899
+ routeAuth: {
18900
+ serverFiles: r.routeAuth.serverFiles,
18901
+ writeRoutes: r.routeAuth.writeRoutes,
18902
+ findings: r.routeAuth.findings
18903
+ },
18904
+ assertion: {
18905
+ status: r.assertion.status,
18906
+ readers: r.assertion.readers,
18907
+ usesPlatformAuth: r.assertion.usesPlatformAuth,
18908
+ findings: r.assertion.findings
18909
+ }
18910
+ };
18911
+ }
18912
+
18913
+ // src/commands/validate.ts
17398
18914
  var validateCommand = {
17399
18915
  name: "validate",
17400
18916
  summary: "validate launchpad.yaml against its v1alpha1 or v2 schema",
@@ -17404,11 +18920,11 @@ async function runValidate(args, io) {
17404
18920
  const parseResult = parseArgs13(args);
17405
18921
  if (parseResult.kind === "usage-error") {
17406
18922
  io.err(`launchpad validate: ${parseResult.message}`);
17407
- io.err("Usage: launchpad validate [--file <path>] [--strict-groups] [--json]");
18923
+ io.err("Usage: launchpad validate [--file <path>] [--strict-groups] [--app-lints] [--json]");
17408
18924
  return 64;
17409
18925
  }
17410
- const { file, json, strictGroups } = parseResult;
17411
- const path15 = resolve17(process.cwd(), file ?? "launchpad.yaml");
18926
+ const { file, json, strictGroups, appLints } = parseResult;
18927
+ const path15 = resolve18(process.cwd(), file ?? "launchpad.yaml");
17412
18928
  const result = loadManifestAnyVersion(path15);
17413
18929
  if (result.kind !== "ok") {
17414
18930
  return json ? renderJsonError(result, io) : renderHumanError(result, io);
@@ -17429,11 +18945,15 @@ async function runValidate(args, io) {
17429
18945
  if (serveErrors.length > 0) {
17430
18946
  boundary.errors = [...boundary.errors, ...serveErrors];
17431
18947
  }
18948
+ const lints = appLints ? runAppLints(dirname13(path15), manifestRootDir(result.manifest)) : undefined;
17432
18949
  const groupCheck = strictGroups ? await checkGroups(allowedEntraGroups(view.access)) : { kind: "skipped" };
17433
- return json ? renderJsonOk(result, groupCheck, boundary, io) : renderHumanOk(result, groupCheck, boundary, io);
18950
+ return json ? renderJsonOk(result, groupCheck, boundary, io, lints) : renderHumanOk(result, groupCheck, boundary, io, lints);
18951
+ }
18952
+ function manifestRootDir(manifest) {
18953
+ return manifest.apiVersion === "launchpad.m-kopa.us/v2" ? manifest.spec.build?.root_dir : manifest.build?.root_dir;
17434
18954
  }
17435
18955
  function checkBoundary(manifestPath, declared) {
17436
- const dir = dirname12(manifestPath);
18956
+ const dir = dirname13(manifestPath);
17437
18957
  let files;
17438
18958
  try {
17439
18959
  files = walkCwd(dir).files;
@@ -17442,7 +18962,7 @@ function checkBoundary(manifestPath, declared) {
17442
18962
  }
17443
18963
  let manifestYaml;
17444
18964
  try {
17445
- manifestYaml = readFileSync22(manifestPath, "utf8");
18965
+ manifestYaml = readFileSync23(manifestPath, "utf8");
17446
18966
  } catch {
17447
18967
  manifestYaml = null;
17448
18968
  }
@@ -17466,18 +18986,18 @@ function checkStaticServeDir(manifestPath, manifest) {
17466
18986
  `static app destination_dir '${serveDir}' is unsafe — use a confined relative subdirectory (e.g. '${STATIC_SERVE_DIR}'). ` + `Serving '.' or an absolute/parent path would publish files outside your app's content.`
17467
18987
  ];
17468
18988
  }
17469
- const dir = dirname12(manifestPath);
17470
- const abs = resolve17(dir, serveDir);
17471
- if (!existsSync17(abs)) {
18989
+ const dir = dirname13(manifestPath);
18990
+ const abs = resolve18(dir, serveDir);
18991
+ if (!existsSync18(abs)) {
17472
18992
  return [
17473
18993
  `static app serves '${serveDir}/' but that directory does not exist — nothing would be served. ` + `Create ${serveDir}/index.html (or run \`launchpad init\` to scaffold it).`
17474
18994
  ];
17475
18995
  }
17476
18996
  let isDir2 = false;
17477
18997
  try {
17478
- isDir2 = statSync2(abs).isDirectory();
18998
+ isDir2 = statSync3(abs).isDirectory();
17479
18999
  } catch (e) {
17480
- return [`failed to inspect static served directory '${serveDir}/': ${describe32(e)}`];
19000
+ return [`failed to inspect static served directory '${serveDir}/': ${describe33(e)}`];
17481
19001
  }
17482
19002
  if (!isDir2) {
17483
19003
  return [`static app serves '${serveDir}/' but that path is not a directory.`];
@@ -17486,14 +19006,14 @@ function checkStaticServeDir(manifestPath, manifest) {
17486
19006
  try {
17487
19007
  entries = readdirSync4(abs);
17488
19008
  } catch (e) {
17489
- return [`failed to read static served directory '${serveDir}/': ${describe32(e)}`];
19009
+ return [`failed to read static served directory '${serveDir}/': ${describe33(e)}`];
17490
19010
  }
17491
19011
  if (entries.length === 0) {
17492
19012
  return [
17493
19013
  `static app's served directory '${serveDir}/' is empty — the deploy would serve an empty site.`
17494
19014
  ];
17495
19015
  }
17496
- if (!existsSync17(resolve17(abs, "index.html"))) {
19016
+ if (!existsSync18(resolve18(abs, "index.html"))) {
17497
19017
  return [
17498
19018
  `static app's served directory '${serveDir}/' has no index.html — the deploy would serve a directory with no entrypoint.`
17499
19019
  ];
@@ -17541,7 +19061,7 @@ async function checkGroup(allowedGroup, cfg) {
17541
19061
  if (e instanceof ForbiddenError) {
17542
19062
  return { kind: "forbidden", message: e.message };
17543
19063
  }
17544
- return { kind: "network", message: describe32(e) };
19064
+ return { kind: "network", message: describe33(e) };
17545
19065
  }
17546
19066
  }
17547
19067
  async function checkGroups(groups) {
@@ -17557,7 +19077,7 @@ async function checkGroups(groups) {
17557
19077
  const ok = perGroup.every((r) => r.kind === "ok");
17558
19078
  return ok ? { kind: "all-ok", perGroup } : { kind: "some-failed", perGroup };
17559
19079
  }
17560
- function renderHumanOk(result, group, boundary, io) {
19080
+ function renderHumanOk(result, group, boundary, io, lints) {
17561
19081
  const view = manifestView(result.manifest);
17562
19082
  io.out(`✓ ${view.name} — manifest is valid`);
17563
19083
  io.out(` apiVersion: ${result.schema}`);
@@ -17577,6 +19097,10 @@ function renderHumanOk(result, group, boundary, io) {
17577
19097
  for (const w of containerRuntimeWarnings(view)) {
17578
19098
  io.out(`⚠ ${w}`);
17579
19099
  }
19100
+ if (lints !== undefined) {
19101
+ for (const line of renderAppLintsHuman(lints))
19102
+ io.out(line);
19103
+ }
17580
19104
  switch (group.kind) {
17581
19105
  case "skipped":
17582
19106
  return 0;
@@ -17641,7 +19165,7 @@ function renderHumanError(result, io) {
17641
19165
  return 1;
17642
19166
  }
17643
19167
  }
17644
- function renderJsonOk(result, group, boundary, io) {
19168
+ function renderJsonOk(result, group, boundary, io, lints) {
17645
19169
  const view = manifestView(result.manifest);
17646
19170
  const runtimeWarnings = containerRuntimeWarnings(view);
17647
19171
  const base = {
@@ -17654,7 +19178,8 @@ function renderJsonOk(result, group, boundary, io) {
17654
19178
  errors: boundary.errors,
17655
19179
  warnings: boundary.warnings
17656
19180
  },
17657
- ...runtimeWarnings.length > 0 ? { warnings: runtimeWarnings } : {}
19181
+ ...runtimeWarnings.length > 0 ? { warnings: runtimeWarnings } : {},
19182
+ ...lints === undefined ? {} : { appLints: appLintsJson(lints) }
17658
19183
  };
17659
19184
  if (boundary.errors.length > 0) {
17660
19185
  io.out(JSON.stringify({ ok: false, ...base }));
@@ -17761,6 +19286,7 @@ function parseArgs13(args) {
17761
19286
  let file;
17762
19287
  let json = false;
17763
19288
  let strictGroups = false;
19289
+ let appLints = false;
17764
19290
  for (let i = 0;i < args.length; i++) {
17765
19291
  const a = args[i];
17766
19292
  if (a === "--json") {
@@ -17771,6 +19297,10 @@ function parseArgs13(args) {
17771
19297
  strictGroups = true;
17772
19298
  continue;
17773
19299
  }
19300
+ if (a === "--app-lints") {
19301
+ appLints = true;
19302
+ continue;
19303
+ }
17774
19304
  if (a === "--file") {
17775
19305
  const next = args[i + 1];
17776
19306
  if (next === undefined || next.startsWith("--")) {
@@ -17785,9 +19315,9 @@ function parseArgs13(args) {
17785
19315
  }
17786
19316
  return { kind: "usage-error", message: `unknown argument "${a}"` };
17787
19317
  }
17788
- return { kind: "ok", file, json, strictGroups };
19318
+ return { kind: "ok", file, json, strictGroups, appLints };
17789
19319
  }
17790
- function describe32(e) {
19320
+ function describe33(e) {
17791
19321
  return e instanceof Error ? e.message : String(e);
17792
19322
  }
17793
19323
 
@@ -17840,7 +19370,7 @@ async function runWhoami(args, io) {
17840
19370
  io.err(e.message);
17841
19371
  return 1;
17842
19372
  }
17843
- io.err(`launchpad whoami failed: ${describe33(e)}`);
19373
+ io.err(`launchpad whoami failed: ${describe34(e)}`);
17844
19374
  return 1;
17845
19375
  }
17846
19376
  }
@@ -17870,11 +19400,11 @@ async function runShare(args, io) {
17870
19400
  io.err(e.message);
17871
19401
  return 1;
17872
19402
  }
17873
- io.err(`launchpad whoami --share failed: ${describe33(e)}`);
19403
+ io.err(`launchpad whoami --share failed: ${describe34(e)}`);
17874
19404
  return 1;
17875
19405
  }
17876
19406
  }
17877
- function describe33(e) {
19407
+ function describe34(e) {
17878
19408
  return e instanceof Error ? e.message : String(e);
17879
19409
  }
17880
19410
 
@@ -18040,7 +19570,7 @@ async function runEditor(action, args, io, deps) {
18040
19570
  io.err(`launchpad ${verb}: no app "${slug}" — check the slug with \`launchpad apps\`.`);
18041
19571
  return 1;
18042
19572
  }
18043
- io.err(`launchpad ${verb} failed: ${describe34(e)}`);
19573
+ io.err(`launchpad ${verb} failed: ${describe35(e)}`);
18044
19574
  return 1;
18045
19575
  }
18046
19576
  }
@@ -18074,7 +19604,7 @@ async function sendMutation(action, slug, target, version, cfg, deps) {
18074
19604
  nonThrowingStatuses: [409]
18075
19605
  });
18076
19606
  }
18077
- function describe34(e) {
19607
+ function describe35(e) {
18078
19608
  return e instanceof Error ? e.message : String(e);
18079
19609
  }
18080
19610
  var grantEditorCommand = makeEditorCommand("grant");
@@ -18280,7 +19810,7 @@ async function runOwner(action, args, io, deps) {
18280
19810
  io.err(`launchpad ${verb}: no app "${slug}" — check the slug with \`launchpad apps\`.`);
18281
19811
  return 1;
18282
19812
  }
18283
- io.err(`launchpad ${verb} failed: ${describe35(e)}`);
19813
+ io.err(`launchpad ${verb} failed: ${describe36(e)}`);
18284
19814
  return 1;
18285
19815
  }
18286
19816
  }
@@ -18314,21 +19844,21 @@ async function sendMutation2(action, slug, target, version, cfg, deps) {
18314
19844
  nonThrowingStatuses: [409]
18315
19845
  });
18316
19846
  }
18317
- function describe35(e) {
19847
+ function describe36(e) {
18318
19848
  return e instanceof Error ? e.message : String(e);
18319
19849
  }
18320
19850
  var addOwnerCommand = makeOwnerCommand("add");
18321
19851
  var removeOwnerCommand = makeOwnerCommand("remove");
18322
19852
 
18323
19853
  // src/commands/admin-integrations.ts
18324
- import { createHash as createHash5, randomBytes as randomBytes6 } from "node:crypto";
19854
+ import { createHash as createHash6, randomBytes as randomBytes6 } from "node:crypto";
18325
19855
  import { unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
18326
19856
  var APPROVAL_PATH = "/admin/integrations/approval-request";
18327
19857
  function generateIntegrationKey() {
18328
19858
  return `lpi_${randomBytes6(32).toString("base64url")}`;
18329
19859
  }
18330
19860
  function integrationKeyHash(key) {
18331
- return createHash5("sha256").update(key).digest("hex");
19861
+ return createHash6("sha256").update(key).digest("hex");
18332
19862
  }
18333
19863
  async function runAdminIntegrations(args, io, config, deps) {
18334
19864
  const parsed = parseArgs17(args);
@@ -18391,37 +19921,37 @@ async function request(body, config, io, deps) {
18391
19921
  function parseArgs17(args) {
18392
19922
  const [sub, slug, name, ...rest] = args;
18393
19923
  if (sub !== "mint" && sub !== "revoke")
18394
- return usage("expected `mint` or `revoke`");
19924
+ return usage2("expected `mint` or `revoke`");
18395
19925
  if (slug === undefined || !SLUG_REGEX.test(slug))
18396
- return usage("expected a valid app slug");
19926
+ return usage2("expected a valid app slug");
18397
19927
  if (name === undefined || !INTEGRATION_NAME_REGEX.test(name)) {
18398
- return usage("expected an integration name matching ^[a-z0-9][a-z0-9-]{0,62}$");
19928
+ return usage2("expected an integration name matching ^[a-z0-9][a-z0-9-]{0,62}$");
18399
19929
  }
18400
19930
  const flags = parseFlags5(rest);
18401
19931
  if (typeof flags === "string")
18402
- return usage(flags);
19932
+ return usage2(flags);
18403
19933
  return sub === "revoke" ? parseRevoke(slug, name, flags) : parseMint(slug, name, flags);
18404
19934
  }
18405
- function usage(message) {
19935
+ function usage2(message) {
18406
19936
  return { kind: "usage", message };
18407
19937
  }
18408
19938
  function parseRevoke(slug, name, flags) {
18409
19939
  if (flags.out !== undefined || flags.rotate || flags.ips.length > 0)
18410
- return usage("revoke takes only --key-sha256");
19940
+ return usage2("revoke takes only --key-sha256");
18411
19941
  if (flags.keyHash === undefined)
18412
19942
  return { kind: "revoke", body: { slug, name, mode: "revoke" } };
18413
19943
  if (!INTEGRATION_KEY_SHA256_REGEX.test(flags.keyHash))
18414
- return usage("--key-sha256 must be 64 lowercase hex characters");
19944
+ return usage2("--key-sha256 must be 64 lowercase hex characters");
18415
19945
  return { kind: "revoke", body: { slug, name, mode: "drop-key", key_sha256: flags.keyHash } };
18416
19946
  }
18417
19947
  function parseMint(slug, name, flags) {
18418
19948
  if (flags.out === undefined)
18419
- return usage("mint requires --out <file>");
19949
+ return usage2("mint requires --out <file>");
18420
19950
  if (flags.keyHash !== undefined)
18421
- return usage("mint does not take --key-sha256");
19951
+ return usage2("mint does not take --key-sha256");
18422
19952
  const badIp = flags.ips.find((ip) => !IntegrationIpSchema.safeParse(ip).success);
18423
19953
  if (badIp !== undefined)
18424
- return usage(`--allow-ip '${badIp}' is not an exact IPv4 or IPv6 address`);
19954
+ return usage2(`--allow-ip '${badIp}' is not an exact IPv4 or IPv6 address`);
18425
19955
  const ips = flags.ips.length > 0 ? { allowed_ips: flags.ips } : {};
18426
19956
  return { kind: "mint", out: flags.out, body: { slug, name, mode: flags.rotate ? "add-key" : "approve", ...ips } };
18427
19957
  }
@@ -18453,10 +19983,97 @@ function printIntegrationsUsage(print) {
18453
19983
  print(" launchpad admin integrations revoke <slug> <name> [--key-sha256 <hex>]");
18454
19984
  }
18455
19985
 
19986
+ // src/commands/admin-cli-sessions.ts
19987
+ var REVOKE_PATH = "/admin/cli-sessions/revoke";
19988
+ var RECORD_PATH = "/admin/cli-sessions/revocations/";
19989
+ var ENTRA_OID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
19990
+ var REASON_RE2 = /^[A-Za-z0-9 ._:#/-]{1,120}$/;
19991
+ async function runAdminCliSessions(args, io, config, deps) {
19992
+ const parsed = parseArgs18(args);
19993
+ if (parsed.kind === "usage") {
19994
+ io.err(`launchpad admin cli-sessions: ${parsed.message}`);
19995
+ printCliSessionsUsage(io.err);
19996
+ return 64;
19997
+ }
19998
+ try {
19999
+ if (parsed.kind === "revoke") {
20000
+ const res2 = await deps.apiJson(config, {
20001
+ method: "POST",
20002
+ path: REVOKE_PATH,
20003
+ jsonBody: { sub: parsed.oid, reason: parsed.reason }
20004
+ });
20005
+ io.out(`CLI sessions revoked for ${parsed.oid} at ${isoTime(res2.revokedAt)}.`);
20006
+ io.out(`The record expires on its own at ${isoTime(res2.expiresAt)}.`);
20007
+ io.out(enforcementLine(res2.enforcement));
20008
+ return 0;
20009
+ }
20010
+ const path15 = `${RECORD_PATH}${parsed.oid}`;
20011
+ if (parsed.kind === "restore") {
20012
+ const res2 = await deps.apiJson(config, { method: "DELETE", path: path15 });
20013
+ io.out(`CLI session revocation lifted for ${parsed.oid}.`);
20014
+ io.out(enforcementLine(res2.enforcement));
20015
+ return 0;
20016
+ }
20017
+ const res = await deps.apiJson(config, { method: "GET", path: path15 });
20018
+ if (res.revoked === true) {
20019
+ const reason = typeof res.reason === "string" ? ` (${res.reason})` : "";
20020
+ io.out(`${parsed.oid}: revoked at ${isoTime(res.revokedAt)}${reason}.`);
20021
+ } else {
20022
+ io.out(`${parsed.oid}: not revoked.`);
20023
+ }
20024
+ io.out(enforcementLine(res.enforcement));
20025
+ return 0;
20026
+ } catch (error) {
20027
+ io.err(`launchpad admin cli-sessions ${parsed.kind}: ${error instanceof Error ? error.message : String(error)}`);
20028
+ return 1;
20029
+ }
20030
+ }
20031
+ function parseArgs18(args) {
20032
+ const [sub, rawOid, ...rest] = args;
20033
+ if (sub !== "revoke" && sub !== "status" && sub !== "restore") {
20034
+ return { kind: "usage", message: "expected `revoke`, `status` or `restore`" };
20035
+ }
20036
+ const oid = rawOid?.trim().toLowerCase();
20037
+ if (oid === undefined || !ENTRA_OID_RE.test(oid)) {
20038
+ return { kind: "usage", message: "expected the user's Entra object id (a GUID), not a UPN" };
20039
+ }
20040
+ if (sub !== "revoke") {
20041
+ return rest.length === 0 ? { kind: sub, oid } : { kind: "usage", message: `${sub} takes no options` };
20042
+ }
20043
+ if (rest.length !== 2 || rest[0] !== "--reason") {
20044
+ return { kind: "usage", message: "revoke requires --reason <ticket reference>" };
20045
+ }
20046
+ const reason = rest[1];
20047
+ if (!REASON_RE2.test(reason)) {
20048
+ return {
20049
+ kind: "usage",
20050
+ message: "--reason must be 1-120 characters of letters, digits, space and . _ : # / -"
20051
+ };
20052
+ }
20053
+ return { kind: "revoke", oid, reason };
20054
+ }
20055
+ function isoTime(value) {
20056
+ return typeof value === "number" && Number.isFinite(value) ? new Date(value * 1000).toISOString() : "an unknown time";
20057
+ }
20058
+ function enforcementLine(mode) {
20059
+ if (mode === "enforce") {
20060
+ return "Enforcement: on. The bot refuses this user's CLI sessions within about a minute.";
20061
+ }
20062
+ if (mode === "observe") {
20063
+ return "Enforcement: observe only. The bot logs this user's CLI requests but does NOT refuse them yet.";
20064
+ }
20065
+ return "Enforcement: off. The record is stored but the bot does NOT refuse this user's CLI sessions yet.";
20066
+ }
20067
+ function printCliSessionsUsage(print) {
20068
+ print(" launchpad admin cli-sessions revoke <entra-object-id> --reason <ticket>");
20069
+ print(" launchpad admin cli-sessions status <entra-object-id>");
20070
+ print(" launchpad admin cli-sessions restore <entra-object-id>");
20071
+ }
20072
+
18456
20073
  // src/commands/admin.ts
18457
- var REAL_DEPS3 = { loadConfig, apiJson };
20074
+ var REAL_DEPS4 = { loadConfig, apiJson };
18458
20075
  var adminCommand = makeAdminCommand();
18459
- function makeAdminCommand(deps = REAL_DEPS3) {
20076
+ function makeAdminCommand(deps = REAL_DEPS4) {
18460
20077
  return {
18461
20078
  name: "admin",
18462
20079
  summary: "run authenticated platform-operator actions",
@@ -18483,22 +20100,25 @@ function statusPageUrl(value, allowedHost) {
18483
20100
  }
18484
20101
  async function runAdmin(args, io, deps) {
18485
20102
  if (args.includes("--help") || args.includes("-h")) {
18486
- printHelp6(io);
20103
+ printHelp8(io);
18487
20104
  return 0;
18488
20105
  }
18489
20106
  const config = deps.loadConfig();
18490
20107
  if (args[0] === "integrations") {
18491
20108
  return runAdminIntegrations(args.slice(1), io, config, deps);
18492
20109
  }
20110
+ if (args[0] === "cli-sessions") {
20111
+ return runAdminCliSessions(args.slice(1), io, config, deps);
20112
+ }
18493
20113
  const parsed = parseStatusRevokeArgs(args, config.statusPageHost ?? DEFAULT_STATUS_PAGE_HOST);
18494
20114
  if (parsed.kind === "unknown") {
18495
20115
  io.err(`launchpad admin: unknown subcommand '${parsed.subcommand}'`);
18496
- printHelp6(io);
20116
+ printHelp8(io);
18497
20117
  return 64;
18498
20118
  }
18499
20119
  if (parsed.kind === "invalid") {
18500
20120
  io.err("launchpad admin: expected `status-revoke <status-url>`");
18501
- printHelp6(io);
20121
+ printHelp8(io);
18502
20122
  return 64;
18503
20123
  }
18504
20124
  return revokeStatusPage(parsed.url, config, io, deps);
@@ -18529,19 +20149,20 @@ async function revokeStatusPage(url, config, io, deps) {
18529
20149
  function statusRevokeMessage(response) {
18530
20150
  return response.revoked ? "Status page revoked." : "Status page was already absent.";
18531
20151
  }
18532
- function printHelp6(io) {
20152
+ function printHelp8(io) {
18533
20153
  io.out("launchpad admin - authenticated platform-operator actions.");
18534
20154
  io.out("");
18535
20155
  io.out("Usage:");
18536
20156
  io.out(" launchpad admin status-revoke <status-url>");
18537
20157
  printIntegrationsUsage(io.out);
20158
+ printCliSessionsUsage(io.out);
18538
20159
  }
18539
20160
 
18540
20161
  // src/commands/list-owners.ts
18541
20162
  function realDeps4() {
18542
20163
  return { loadConfig, apiJson };
18543
20164
  }
18544
- function parseArgs18(args) {
20165
+ function parseArgs19(args) {
18545
20166
  let slug;
18546
20167
  let json = false;
18547
20168
  for (const a of args) {
@@ -18555,7 +20176,7 @@ function parseArgs18(args) {
18555
20176
  return { slug, json };
18556
20177
  }
18557
20178
  async function runListOwners(args, io, deps) {
18558
- const parsed = parseArgs18(args);
20179
+ const parsed = parseArgs19(args);
18559
20180
  if (parsed === null) {
18560
20181
  io.err("usage: launchpad list-owners <slug> [--json]");
18561
20182
  return 64;
@@ -18612,20 +20233,20 @@ var listOwnersCommand = makeListOwnersCommand();
18612
20233
  // src/update-notifier.ts
18613
20234
  import { spawn as spawn6 } from "node:child_process";
18614
20235
  import { homedir as homedir4 } from "node:os";
18615
- import { join as join18 } from "node:path";
20236
+ import { join as join20 } from "node:path";
18616
20237
  import {
18617
- existsSync as existsSync18,
18618
- mkdirSync as mkdirSync5,
18619
- readFileSync as readFileSync23,
18620
- writeFileSync as writeFileSync9
20238
+ existsSync as existsSync19,
20239
+ mkdirSync as mkdirSync6,
20240
+ readFileSync as readFileSync24,
20241
+ writeFileSync as writeFileSync10
18621
20242
  } from "node:fs";
18622
20243
  var INTERNAL_REFRESH_VERB = "__refresh-update-cache";
18623
20244
  var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
18624
20245
  var OPT_OUT_ENV = "LAUNCHPAD_NO_UPDATE_NOTIFIER";
18625
- var CACHE_FILE = join18(homedir4(), ".launchpad", "update-check.json");
20246
+ var CACHE_FILE = join20(homedir4(), ".launchpad", "update-check.json");
18626
20247
  function readCache2() {
18627
20248
  try {
18628
- const raw = JSON.parse(readFileSync23(CACHE_FILE, "utf8"));
20249
+ const raw = JSON.parse(readFileSync24(CACHE_FILE, "utf8"));
18629
20250
  if (typeof raw === "object" && raw !== null && typeof raw.checkedAt === "number") {
18630
20251
  const latest = raw.latest;
18631
20252
  return {
@@ -18638,23 +20259,23 @@ function readCache2() {
18638
20259
  }
18639
20260
  function writeCache2(state) {
18640
20261
  try {
18641
- mkdirSync5(join18(homedir4(), ".launchpad"), { recursive: true });
18642
- writeFileSync9(CACHE_FILE, `${JSON.stringify(state)}
20262
+ mkdirSync6(join20(homedir4(), ".launchpad"), { recursive: true });
20263
+ writeFileSync10(CACHE_FILE, `${JSON.stringify(state)}
18643
20264
  `, { mode: 384 });
18644
20265
  } catch {}
18645
20266
  }
18646
- var SKILLS_HINT_MARKER = join18(homedir4(), ".launchpad", "skills-hint-shown");
20267
+ var SKILLS_HINT_MARKER = join20(homedir4(), ".launchpad", "skills-hint-shown");
18647
20268
  function absentHintShown() {
18648
20269
  try {
18649
- return existsSync18(SKILLS_HINT_MARKER);
20270
+ return existsSync19(SKILLS_HINT_MARKER);
18650
20271
  } catch {
18651
20272
  return false;
18652
20273
  }
18653
20274
  }
18654
20275
  function markAbsentHintShown() {
18655
20276
  try {
18656
- mkdirSync5(join18(homedir4(), ".launchpad"), { recursive: true });
18657
- writeFileSync9(SKILLS_HINT_MARKER, `${Date.now()}
20277
+ mkdirSync6(join20(homedir4(), ".launchpad"), { recursive: true });
20278
+ writeFileSync10(SKILLS_HINT_MARKER, `${Date.now()}
18658
20279
  `, { mode: 384 });
18659
20280
  } catch {}
18660
20281
  }
@@ -18756,8 +20377,8 @@ var refreshUpdateCacheCommand = {
18756
20377
  // src/telemetry.ts
18757
20378
  import { spawn as spawn7 } from "node:child_process";
18758
20379
  import { homedir as homedir5 } from "node:os";
18759
- import { join as join19 } from "node:path";
18760
- import { existsSync as existsSync19, mkdirSync as mkdirSync6, readFileSync as readFileSync24, writeFileSync as writeFileSync10 } from "node:fs";
20380
+ import { join as join21 } from "node:path";
20381
+ import { existsSync as existsSync20, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync11 } from "node:fs";
18761
20382
  import { randomUUID } from "node:crypto";
18762
20383
  var INTERNAL_EMIT_VERB = "__emit-telemetry";
18763
20384
  var POSTHOG_HOST = "https://us.i.posthog.com";
@@ -18765,8 +20386,8 @@ var POSTHOG_PROJECT_KEY = "phc_CYaCuETanWc36TMTiB7cdkdnmPPhFZCkDGmWGLaNkXnb";
18765
20386
  var CAPTURE_PATH = "/i/v0/e/";
18766
20387
  var SEND_TIMEOUT_MS = 3000;
18767
20388
  var APP = "launchpad-cli";
18768
- var DEVICE_ID_FILE = join19(homedir5(), ".launchpad", "telemetry-id.json");
18769
- var FIRST_RUN_MARKER = join19(homedir5(), ".launchpad", "telemetry-notice-shown");
20389
+ var DEVICE_ID_FILE = join21(homedir5(), ".launchpad", "telemetry-id.json");
20390
+ var FIRST_RUN_MARKER = join21(homedir5(), ".launchpad", "telemetry-notice-shown");
18770
20391
  function buildEvent(ctx, identity, nowMs) {
18771
20392
  const properties = {
18772
20393
  app: APP,
@@ -18833,15 +20454,15 @@ async function resolveIdentityReal() {
18833
20454
  }
18834
20455
  function getOrCreateDeviceId() {
18835
20456
  try {
18836
- const raw = JSON.parse(readFileSync24(DEVICE_ID_FILE, "utf8"));
20457
+ const raw = JSON.parse(readFileSync25(DEVICE_ID_FILE, "utf8"));
18837
20458
  const id2 = raw?.deviceId;
18838
20459
  if (typeof id2 === "string" && id2)
18839
20460
  return id2;
18840
20461
  } catch {}
18841
20462
  const id = randomUUID();
18842
20463
  try {
18843
- mkdirSync6(join19(homedir5(), ".launchpad"), { recursive: true });
18844
- writeFileSync10(DEVICE_ID_FILE, `${JSON.stringify({ deviceId: id })}
20464
+ mkdirSync7(join21(homedir5(), ".launchpad"), { recursive: true });
20465
+ writeFileSync11(DEVICE_ID_FILE, `${JSON.stringify({ deviceId: id })}
18845
20466
  `, {
18846
20467
  mode: 384
18847
20468
  });
@@ -18911,15 +20532,15 @@ function telemetryNoticeLine() {
18911
20532
  }
18912
20533
  function firstRunNoticeShown() {
18913
20534
  try {
18914
- return existsSync19(FIRST_RUN_MARKER);
20535
+ return existsSync20(FIRST_RUN_MARKER);
18915
20536
  } catch {
18916
20537
  return false;
18917
20538
  }
18918
20539
  }
18919
20540
  function markFirstRunNotice() {
18920
20541
  try {
18921
- mkdirSync6(join19(homedir5(), ".launchpad"), { recursive: true });
18922
- writeFileSync10(FIRST_RUN_MARKER, `${Date.now()}
20542
+ mkdirSync7(join21(homedir5(), ".launchpad"), { recursive: true });
20543
+ writeFileSync11(FIRST_RUN_MARKER, `${Date.now()}
18923
20544
  `, { mode: 384 });
18924
20545
  } catch {}
18925
20546
  }
@@ -18984,22 +20605,22 @@ import { createInterface as createInterface7 } from "node:readline/promises";
18984
20605
  import { platform } from "node:os";
18985
20606
 
18986
20607
  // src/report/breadcrumb.ts
18987
- import { writeFileSync as writeFileSync11, readFileSync as readFileSync25, mkdirSync as mkdirSync7 } from "node:fs";
20608
+ import { writeFileSync as writeFileSync12, readFileSync as readFileSync26, mkdirSync as mkdirSync8 } from "node:fs";
18988
20609
  import { homedir as homedir6 } from "node:os";
18989
- import { join as join20, dirname as dirname13 } from "node:path";
20610
+ import { join as join22, dirname as dirname14 } from "node:path";
18990
20611
  function breadcrumbPath() {
18991
- return join20(homedir6(), ".launchpad", "last-run.json");
20612
+ return join22(homedir6(), ".launchpad", "last-run.json");
18992
20613
  }
18993
20614
  function writeBreadcrumb(verb, exit) {
18994
20615
  try {
18995
20616
  const p = breadcrumbPath();
18996
- mkdirSync7(dirname13(p), { recursive: true });
18997
- writeFileSync11(p, JSON.stringify({ verb, exit, ts: Date.now() }), "utf8");
20617
+ mkdirSync8(dirname14(p), { recursive: true });
20618
+ writeFileSync12(p, JSON.stringify({ verb, exit, ts: Date.now() }), "utf8");
18998
20619
  } catch {}
18999
20620
  }
19000
20621
  function readBreadcrumb() {
19001
20622
  try {
19002
- const raw = JSON.parse(readFileSync25(breadcrumbPath(), "utf8"));
20623
+ const raw = JSON.parse(readFileSync26(breadcrumbPath(), "utf8"));
19003
20624
  if (typeof raw !== "object" || raw === null)
19004
20625
  return null;
19005
20626
  const r = raw;
@@ -19032,7 +20653,7 @@ function realDeps5() {
19032
20653
  readBreadcrumb
19033
20654
  };
19034
20655
  }
19035
- function parseArgs19(args) {
20656
+ function parseArgs20(args) {
19036
20657
  let title;
19037
20658
  let message;
19038
20659
  const positionalParts = [];
@@ -19063,7 +20684,7 @@ function parseArgs19(args) {
19063
20684
  var NOUN = { bug: "bug report", feature: "feature request" };
19064
20685
  async function runReport(kind, args, io, deps) {
19065
20686
  const verb = kind;
19066
- const parsed = parseArgs19(args);
20687
+ const parsed = parseArgs20(args);
19067
20688
  let message = parsed.message ?? parsed.positional ?? "";
19068
20689
  let title = parsed.title ?? "";
19069
20690
  if (message === "" && deps.isTty()) {
@@ -19165,6 +20786,7 @@ var COMMANDS = [
19165
20786
  logoutCommand,
19166
20787
  appsCommand,
19167
20788
  whoamiCommand,
20789
+ agreementCommand,
19168
20790
  createCommand,
19169
20791
  cloneCommand,
19170
20792
  deployCommand,
@@ -19185,6 +20807,8 @@ var COMMANDS = [
19185
20807
  watchCommand,
19186
20808
  recoverCommand,
19187
20809
  destroyCommand,
20810
+ disableCommand,
20811
+ enableCommand,
19188
20812
  rollbackCommand,
19189
20813
  groupsCommand,
19190
20814
  secretsCommand,
@@ -19202,7 +20826,7 @@ var COMMANDS = [
19202
20826
  ];
19203
20827
  async function dispatch(argv, io, commands = COMMANDS, deps = {}) {
19204
20828
  if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
19205
- printHelp7(io, commands);
20829
+ printHelp9(io, commands);
19206
20830
  return 0;
19207
20831
  }
19208
20832
  if (argv[0] === "--version" || argv[0] === "-v") {
@@ -19239,6 +20863,12 @@ async function runCliFloorPreflight(verb, args, io, deps) {
19239
20863
  io.err(error.message);
19240
20864
  return EXIT_CLI_UPGRADE_REQUIRED;
19241
20865
  }
20866
+ if (error instanceof AgreementRequiredError) {
20867
+ if (verb === "destroy")
20868
+ return null;
20869
+ io.err(error.message);
20870
+ return EXIT_AGREEMENT_REQUIRED;
20871
+ }
19242
20872
  io.err(`launchpad ${verb}: version preflight failed: ${error instanceof Error ? error.message : String(error)}`);
19243
20873
  return 1;
19244
20874
  }
@@ -19269,7 +20899,7 @@ function requiresCliFloorPreflight(verb, args) {
19269
20899
  return args[0] === "status-revoke" || args[0] === "integrations";
19270
20900
  return false;
19271
20901
  }
19272
- function printHelp7(io, commands) {
20902
+ function printHelp9(io, commands) {
19273
20903
  io.out("launchpad — manage Launchpad-deployed apps from the command line.");
19274
20904
  io.out("");
19275
20905
  io.out("Usage:");