@devpad/cli 2.5.2 → 2.5.3

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 (2) hide show
  1. package/dist/index.js +267 -23
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -1623,6 +1623,9 @@ var init_table2 = __esm(() => {
1623
1623
  function index(name) {
1624
1624
  return new IndexBuilderOn(name, false);
1625
1625
  }
1626
+ function uniqueIndex(name) {
1627
+ return new IndexBuilderOn(name, true);
1628
+ }
1626
1629
  var IndexBuilderOn, IndexBuilder, Index;
1627
1630
  var init_indexes = __esm(() => {
1628
1631
  init_entity();
@@ -11711,7 +11714,7 @@ __exportCjs(exports_commander, {
11711
11714
  InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
11712
11715
  });
11713
11716
 
11714
- // ../api/dist/chunk-HIDAIYV4.js
11717
+ // ../api/dist/chunk-WM2RV3FZ.js
11715
11718
  init_drizzle_orm();
11716
11719
  init_sqlite_core();
11717
11720
 
@@ -11968,7 +11971,7 @@ var createSelectSchema = (entity, refine) => {
11968
11971
  return handleColumns(columns, refine ?? {}, selectConditions);
11969
11972
  };
11970
11973
 
11971
- // ../api/dist/chunk-HIDAIYV4.js
11974
+ // ../api/dist/chunk-WM2RV3FZ.js
11972
11975
  init_zod();
11973
11976
  var timestamps = () => ({
11974
11977
  created_at: text("created_at").notNull().default(sql`(CURRENT_TIMESTAMP)`),
@@ -12335,10 +12338,12 @@ var ignore_path = sqliteTable("ignore_path", {
12335
12338
  });
12336
12339
  var ROLLOUT_SHAPES = ["gradual", "atomic"];
12337
12340
  var RUN_KINDS = ["deploy", "rollback"];
12338
- var RUN_STATUSES = ["queued", "deploying", "baking", "awaiting_approval", "rolling_back", "completed", "rolled_back", "failed", "cancelled"];
12341
+ var RUN_STATUSES = ["queued", "deploying", "unconfirmed", "baking", "awaiting_approval", "rolling_back", "completed", "rolled_back", "failed", "cancelled"];
12339
12342
  var FORCED_ATOMIC_REASONS = ["do_migrations", "asset_affinity_none"];
12340
- var STAGE_EVENT_KINDS = ["deploy_started", "deploy_completed", "bake_started", "bake_completed", "gate_verdict", "approval_requested", "rollback_started", "rollback_completed", "warning", "error"];
12343
+ var STAGE_EVENT_KINDS = ["deploy_started", "deploy_completed", "deploy_failed", "dispatch_requested", "dispatch_failed", "timed_out", "bake_started", "bake_completed", "gate_verdict", "approval_requested", "rollback_started", "rollback_completed", "warning", "error"];
12341
12344
  var APPROVAL_DECISIONS = ["approved", "denied"];
12345
+ var DEPLOY_MODES = ["orchestrated", "external"];
12346
+ var DISPATCH_STATUSES = ["claimed", "dispatched", "failed"];
12342
12347
  var pipeline_package = sqliteTable("pipeline_package", {
12343
12348
  ...entity2("pipeline-package"),
12344
12349
  owner_id: text("owner_id").notNull().references(() => user.id),
@@ -12346,12 +12351,15 @@ var pipeline_package = sqliteTable("pipeline_package", {
12346
12351
  repo_url: text("repo_url"),
12347
12352
  default_template_ref: text("default_template_ref"),
12348
12353
  script_name_overrides: text("script_name_overrides", { mode: "json" }),
12349
- project_id: text("project_id").references(() => project.id)
12354
+ project_id: text("project_id").references(() => project.id),
12355
+ deploy_mode: text("deploy_mode", { enum: DEPLOY_MODES }).notNull().default("orchestrated"),
12356
+ external_target: text("external_target", { mode: "json" })
12350
12357
  });
12351
12358
  var pipeline_run = sqliteTable("pipeline_run", {
12352
12359
  ...entity2("pipeline-run"),
12353
12360
  package_id: text("package_id").notNull().references(() => pipeline_package.id),
12354
- version_set_id: text("version_set_id").notNull(),
12361
+ version_set_id: text("version_set_id"),
12362
+ commit_sha: text("commit_sha"),
12355
12363
  shape: text("shape", { enum: ROLLOUT_SHAPES }).notNull(),
12356
12364
  kind: text("kind", { enum: RUN_KINDS }).notNull().default("deploy"),
12357
12365
  status: text("status", { enum: RUN_STATUSES }).notNull().default("queued"),
@@ -12370,7 +12378,19 @@ var pipeline_stage_event = sqliteTable("pipeline_stage_event", {
12370
12378
  payload: text("payload", { mode: "json" }),
12371
12379
  ts: text("ts").notNull().default(sql`(CURRENT_TIMESTAMP)`),
12372
12380
  idempotency_hash: text("idempotency_hash")
12373
- });
12381
+ }, (table) => [
12382
+ uniqueIndex("idx_pipeline_stage_event_idem_uniq").on(table.run_id, table.idempotency_hash).where(sql`idempotency_hash IS NOT NULL`)
12383
+ ]);
12384
+ var pipeline_dispatch = sqliteTable("pipeline_dispatch", {
12385
+ ...id("pipeline-dispatch"),
12386
+ run_id: text("run_id").notNull().references(() => pipeline_run.id),
12387
+ stage_name: text("stage_name").notNull(),
12388
+ commit_sha: text("commit_sha").notNull(),
12389
+ status: text("status", { enum: DISPATCH_STATUSES }).notNull().default("claimed"),
12390
+ error: text("error"),
12391
+ requested_by: text("requested_by"),
12392
+ ...timestamps()
12393
+ }, (table) => [unique("pipeline_dispatch_run_stage_unique").on(table.run_id, table.stage_name)]);
12374
12394
  var pipeline_grant = sqliteTable("pipeline_grant", {
12375
12395
  ...entity2("pipeline-grant"),
12376
12396
  package_id: text("package_id").notNull().references(() => pipeline_package.id),
@@ -12496,7 +12516,11 @@ var pipeline_package_relations = relations(pipeline_package, ({ one, many }) =>
12496
12516
  var pipeline_run_relations = relations(pipeline_run, ({ one, many }) => ({
12497
12517
  package: one(pipeline_package, { fields: [pipeline_run.package_id], references: [pipeline_package.id] }),
12498
12518
  events: many(pipeline_stage_event),
12499
- approvals: many(pipeline_approval)
12519
+ approvals: many(pipeline_approval),
12520
+ dispatches: many(pipeline_dispatch)
12521
+ }));
12522
+ var pipeline_dispatch_relations = relations(pipeline_dispatch, ({ one }) => ({
12523
+ run: one(pipeline_run, { fields: [pipeline_dispatch.run_id], references: [pipeline_run.id] })
12500
12524
  }));
12501
12525
  var pipeline_stage_event_relations = relations(pipeline_stage_event, ({ one }) => ({
12502
12526
  run: one(pipeline_run, { fields: [pipeline_stage_event.run_id], references: [pipeline_run.id] })
@@ -12666,6 +12690,7 @@ var run_kind = unionType([literalType("deploy"), literalType("rollback")]);
12666
12690
  var run_status = unionType([
12667
12691
  literalType("queued"),
12668
12692
  literalType("deploying"),
12693
+ literalType("unconfirmed"),
12669
12694
  literalType("baking"),
12670
12695
  literalType("awaiting_approval"),
12671
12696
  literalType("rolling_back"),
@@ -12678,6 +12703,10 @@ var forced_atomic_reason = unionType([literalType("do_migrations"), literalType(
12678
12703
  var stage_event_kind = unionType([
12679
12704
  literalType("deploy_started"),
12680
12705
  literalType("deploy_completed"),
12706
+ literalType("deploy_failed"),
12707
+ literalType("dispatch_requested"),
12708
+ literalType("dispatch_failed"),
12709
+ literalType("timed_out"),
12681
12710
  literalType("bake_started"),
12682
12711
  literalType("bake_completed"),
12683
12712
  literalType("gate_verdict"),
@@ -12688,6 +12717,16 @@ var stage_event_kind = unionType([
12688
12717
  literalType("error")
12689
12718
  ]);
12690
12719
  var approval_decision = unionType([literalType("approved"), literalType("denied")]);
12720
+ var deploy_mode = unionType([literalType("orchestrated"), literalType("external")]);
12721
+ var commit_sha = stringType().regex(/^[0-9a-f]{40}$/, "commit_sha must be a 40-hex SHA");
12722
+ var external_target = objectType({
12723
+ repo: stringType().regex(/^[^/\s]+\/[^/\s]+$/, "repo must be owner/name"),
12724
+ workflow: stringType().min(1).describe("workflow file name, e.g. deploy.yml"),
12725
+ ref: stringType().min(1).default("main"),
12726
+ timeout_ms: numberType().int().positive().default(2700000),
12727
+ gate: objectType({ type: literalType("manual") }).default({ type: "manual" })
12728
+ });
12729
+ var dispatch_status = unionType([literalType("claimed"), literalType("dispatched"), literalType("failed")]);
12691
12730
  var grant_scope = stringType().regex(/^[a-z0-9_-]+:[a-z0-9_-]+(:[^\s]+)?$/, "Invalid scope format");
12692
12731
  var rollout_stage = objectType({
12693
12732
  name: stringType(),
@@ -12716,12 +12755,15 @@ var upsert_pipeline_package = objectType({
12716
12755
  repo_url: stringType().nullable().optional(),
12717
12756
  default_template_ref: stringType().nullable().optional(),
12718
12757
  script_name_overrides: recordType(stringType(), stringType()).nullable().optional(),
12719
- project_id: stringType().nullable().optional()
12758
+ project_id: stringType().nullable().optional(),
12759
+ deploy_mode: deploy_mode.optional(),
12760
+ external_target: external_target.nullable().optional()
12720
12761
  });
12721
12762
  var upsert_pipeline_run = objectType({
12722
12763
  id: stringType().optional().nullable(),
12723
12764
  package_id: stringType(),
12724
- version_set_id: stringType(),
12765
+ version_set_id: stringType().nullable(),
12766
+ commit_sha: commit_sha.nullable().optional(),
12725
12767
  shape: rollout_shape,
12726
12768
  kind: run_kind.optional(),
12727
12769
  status: run_status.optional(),
@@ -12754,6 +12796,15 @@ var upsert_pipeline_approval = objectType({
12754
12796
  decided_by: stringType().nullable().optional(),
12755
12797
  decided_at: stringType().nullable().optional()
12756
12798
  });
12799
+ var upsert_pipeline_dispatch = objectType({
12800
+ id: stringType().optional().nullable(),
12801
+ run_id: stringType(),
12802
+ stage_name: stringType(),
12803
+ commit_sha,
12804
+ status: dispatch_status.optional(),
12805
+ error: stringType().nullable().optional(),
12806
+ requested_by: stringType().nullable().optional()
12807
+ });
12757
12808
  var upsert_pipeline_analysis_template = objectType({
12758
12809
  id: stringType().optional(),
12759
12810
  owner_id: stringType().min(1),
@@ -14163,6 +14214,8 @@ var ApiClient2 = class {
14163
14214
  })),
14164
14215
  cancel: (run_id) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/cancel`, { body: {} })),
14165
14216
  rollback: (run_id) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/rollback`, { body: {} })),
14217
+ redispatch: (run_id) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/redispatch`, { body: {} })),
14218
+ dispatches: (run_id) => wrap(() => this.clients.pipelines.get(`/runs/${run_id}/dispatches`)),
14166
14219
  events: {
14167
14220
  ingest: (run_id, input) => wrap(() => this.clients.pipelines.post(`/runs/${run_id}/events`, {
14168
14221
  body: input
@@ -14973,6 +15026,14 @@ var tools = {
14973
15026
  }),
14974
15027
  execute: async (client, input) => unwrap2(await client.pipelines.get(input.run_id))
14975
15028
  }),
15029
+ devpad_pipelines_dispatches: define_tool({
15030
+ name: "devpad_pipelines_dispatches",
15031
+ description: "List a pipeline run's dispatch ledger rows (external deploy mode #155): per-stage claim/dispatch status, error text, and requesting actor. Read-only.",
15032
+ inputSchema: objectType({
15033
+ run_id: stringType().describe("Pipeline run ID")
15034
+ }),
15035
+ execute: async (client, input) => unwrap2(await client.pipelines.dispatches(input.run_id))
15036
+ }),
14976
15037
  devpad_pipelines_create: define_tool({
14977
15038
  name: "devpad_pipelines_create",
14978
15039
  description: "Create a new pipeline run",
@@ -16827,6 +16888,8 @@ var ApiClient22 = class {
16827
16888
  })),
16828
16889
  cancel: (run_id) => wrap2(() => this.clients.pipelines.post(`/runs/${run_id}/cancel`, { body: {} })),
16829
16890
  rollback: (run_id) => wrap2(() => this.clients.pipelines.post(`/runs/${run_id}/rollback`, { body: {} })),
16891
+ redispatch: (run_id) => wrap2(() => this.clients.pipelines.post(`/runs/${run_id}/redispatch`, { body: {} })),
16892
+ dispatches: (run_id) => wrap2(() => this.clients.pipelines.get(`/runs/${run_id}/dispatches`)),
16830
16893
  events: {
16831
16894
  ingest: (run_id, input) => wrap2(() => this.clients.pipelines.post(`/runs/${run_id}/events`, {
16832
16895
  body: input
@@ -17637,6 +17700,14 @@ var tools2 = {
17637
17700
  }),
17638
17701
  execute: async (client, input) => unwrap3(await client.pipelines.get(input.run_id))
17639
17702
  }),
17703
+ devpad_pipelines_dispatches: define_tool2({
17704
+ name: "devpad_pipelines_dispatches",
17705
+ description: "List a pipeline run's dispatch ledger rows (external deploy mode #155): per-stage claim/dispatch status, error text, and requesting actor. Read-only.",
17706
+ inputSchema: objectType({
17707
+ run_id: stringType().describe("Pipeline run ID")
17708
+ }),
17709
+ execute: async (client, input) => unwrap3(await client.pipelines.dispatches(input.run_id))
17710
+ }),
17640
17711
  devpad_pipelines_create: define_tool2({
17641
17712
  name: "devpad_pipelines_create",
17642
17713
  description: "Create a new pipeline run",
@@ -19969,6 +20040,70 @@ var validate_template_shape = (candidate) => {
19969
20040
  return ok(parsed.data);
19970
20041
  };
19971
20042
 
20043
+ // src/pipelines-verify.ts
20044
+ var SHA_PATTERN = /^[0-9a-f]{40}$/;
20045
+ var is_sha_like = (s) => SHA_PATTERN.test(s);
20046
+ var resolve_runs_start_flags = (flags) => {
20047
+ if (flags.package === undefined || flags.package === "")
20048
+ return { ok: false, error: "--package is required" };
20049
+ if (flags.versionSetId !== undefined && flags.sha !== undefined)
20050
+ return { ok: false, error: "--version-set-id and --sha are mutually exclusive" };
20051
+ if (flags.versionSetId === undefined && flags.sha === undefined)
20052
+ return { ok: false, error: "provide exactly one of --version-set-id (orchestrated) or --sha (external)" };
20053
+ if (flags.versionSetId !== undefined)
20054
+ return { ok: true, value: { kind: "orchestrated", package_id: flags.package, version_set_id: flags.versionSetId } };
20055
+ if (flags.sha === undefined || !is_sha_like(flags.sha))
20056
+ return { ok: false, error: `--sha must be a 40-hex commit SHA; got "${String(flags.sha)}"` };
20057
+ return { ok: true, value: { kind: "external", package_id: flags.package, commit_sha: flags.sha } };
20058
+ };
20059
+ var IN_FLIGHT_RUN_STATUSES = ["deploying", "unconfirmed"];
20060
+ var evaluate_dispatch_verification = (envelope, expected) => {
20061
+ if (envelope.commit_sha !== expected.sha)
20062
+ return {
20063
+ ok: false,
20064
+ reason: `run ${envelope.run_id} targets commit_sha ${envelope.commit_sha ?? "(null)"}, expected ${expected.sha}`
20065
+ };
20066
+ const row = envelope.dispatches.find((d) => d.stage_name === expected.stage);
20067
+ if (row === undefined)
20068
+ return { ok: false, reason: `no pipeline_dispatch row for stage "${expected.stage}" on run ${envelope.run_id}` };
20069
+ if (row.status !== "dispatched")
20070
+ return { ok: false, reason: `dispatch row for stage "${expected.stage}" has status "${row.status}"` };
20071
+ if (!IN_FLIGHT_RUN_STATUSES.includes(envelope.run_status))
20072
+ return {
20073
+ ok: false,
20074
+ reason: `run status is "${envelope.run_status}", expected one of ${IN_FLIGHT_RUN_STATUSES.join("|")}`
20075
+ };
20076
+ return { ok: true };
20077
+ };
20078
+ var read_envelope = async (response) => {
20079
+ try {
20080
+ const parsed = await response.json();
20081
+ return parsed;
20082
+ } catch {
20083
+ return null;
20084
+ }
20085
+ };
20086
+ var fetch_dispatches_envelope = async (input, run_id) => {
20087
+ const url = `${input.pipelines_url.replace(/\/$/, "")}/runs/${run_id}/dispatches`;
20088
+ let response;
20089
+ try {
20090
+ response = await fetch(url, { headers: { authorization: `Bearer ${input.pipelines_token}` } });
20091
+ } catch (cause) {
20092
+ return { ok: false, error: `orchestrator unreachable: ${cause instanceof Error ? cause.message : String(cause)}` };
20093
+ }
20094
+ const body = await read_envelope(response);
20095
+ if (!response.ok) {
20096
+ const message = typeof body?.error === "object" && typeof body.error.message === "string" ? body.error.message : response.statusText;
20097
+ return { ok: false, error: `GET /runs/${run_id}/dispatches failed: ${String(response.status)} ${message}` };
20098
+ }
20099
+ if (body === null || body.ok !== true || body.value === undefined)
20100
+ return { ok: false, error: "unexpected response envelope from orchestrator" };
20101
+ const value = body.value;
20102
+ if (typeof value !== "object" || value === null || !("run_id" in value) || !("run_status" in value) || !("dispatches" in value))
20103
+ return { ok: false, error: "GET /runs/:id/dispatches returned an unexpected value shape" };
20104
+ return { ok: true, value };
20105
+ };
20106
+
19972
20107
  // src/scaffolder/scaffold.ts
19973
20108
  import { spawn } from "node:child_process";
19974
20109
  import { existsSync } from "node:fs";
@@ -20601,18 +20736,57 @@ var compile_and_upload_template = async (http_input, pipeline_path) => {
20601
20736
  return { ok: false, error: `pipeline-templates upload failed: ${format_http_error(upload.error)}` };
20602
20737
  return { ok: true, value: upload.value.ref };
20603
20738
  };
20739
+ var resolve_orchestrator_http = (options) => {
20740
+ const url = options.orchestratorUrl ?? process.env.DEVPAD_PIPELINES_URL;
20741
+ const token = options.token ?? process.env.DEVPAD_PIPELINES_TOKEN;
20742
+ if (url === undefined || url === "" || token === undefined || token === "") {
20743
+ return {
20744
+ ok: false,
20745
+ error: "requires DEVPAD_PIPELINES_URL + DEVPAD_PIPELINES_TOKEN (env or --orchestrator-url/--token)"
20746
+ };
20747
+ }
20748
+ return { ok: true, value: { pipelines_url: url, pipelines_token: token } };
20749
+ };
20750
+ var print_runs_start_result = (spinner, value, as_json) => {
20751
+ if (as_json)
20752
+ console.log(JSON.stringify({ run_id: value.run_id, status: value.status }));
20753
+ else {
20754
+ spinner.succeed(`run ${value.run_id} (${value.status})`);
20755
+ console.log(source_default2.green(`Run ID: ${value.run_id}`));
20756
+ }
20757
+ };
20604
20758
  var action_runs_start = (client_factory) => async (options) => {
20759
+ const targets = resolve_runs_start_flags(options);
20605
20760
  const spinner = make_spinner("Starting pipeline run...").start();
20761
+ if (!targets.ok)
20762
+ return fail_with(spinner, targets.error);
20763
+ if (targets.value.kind === "external") {
20764
+ const http = resolve_orchestrator_http(options);
20765
+ if (!http.ok)
20766
+ return fail_with(spinner, `external run start ${http.error}`);
20767
+ const posted = await post_envelope({
20768
+ url: `${http.value.pipelines_url.replace(/\/$/, "")}/runs`,
20769
+ headers: { authorization: `Bearer ${http.value.pipelines_token}`, "content-type": "application/json" },
20770
+ body: JSON.stringify({ package_id: targets.value.package_id, commit_sha: targets.value.commit_sha })
20771
+ });
20772
+ if (!posted.ok)
20773
+ return fail_with(spinner, `run start failed: ${format_http_error(posted.error)}`);
20774
+ print_runs_start_result(spinner, posted.value, options.json ?? false);
20775
+ return;
20776
+ }
20606
20777
  const client = client_factory();
20607
- const result = await client.pipelines.create({ package_id: options.package, version_set_id: options.versionSetId });
20778
+ const result = await client.pipelines.create({
20779
+ package_id: targets.value.package_id,
20780
+ version_set_id: targets.value.version_set_id
20781
+ });
20608
20782
  if (!result.ok)
20609
20783
  return fail_with(spinner, result.error.message);
20610
- spinner.succeed(`run ${result.value.run_id} (${result.value.status})`);
20611
- console.log(source_default2.green(`Run ID: ${result.value.run_id}`));
20784
+ print_runs_start_result(spinner, result.value, options.json ?? false);
20612
20785
  };
20613
20786
  var STAGE_EVENT_KINDS2 = [
20614
20787
  "deploy_started",
20615
20788
  "deploy_completed",
20789
+ "deploy_failed",
20616
20790
  "bake_started",
20617
20791
  "bake_completed",
20618
20792
  "gate_verdict",
@@ -20640,6 +20814,10 @@ var action_runs_events_ingest = (client_factory) => async (run_id, options) => {
20640
20814
  return fail_with(spinner, `--payload-file is not valid JSON: ${e instanceof Error ? e.message : String(e)}`);
20641
20815
  }
20642
20816
  }
20817
+ if (options.sha !== undefined && options.sha !== "") {
20818
+ const base = typeof payload === "object" && payload !== null ? payload : {};
20819
+ payload = { ...base, sha: options.sha };
20820
+ }
20643
20821
  let idempotency_key = options.idempotencyKey;
20644
20822
  if (idempotency_key === undefined || idempotency_key === "") {
20645
20823
  idempotency_key = crypto.randomUUID();
@@ -20668,6 +20846,23 @@ var action_runs_events_list = (client_factory) => async (run_id) => {
20668
20846
  console.log(` ${source_default2.dim(ev.ts)} ${source_default2.cyan(ev.kind)} ${ev.stage_name} ${source_default2.dim(ev.id)}`);
20669
20847
  }
20670
20848
  };
20849
+ var action_runs_verify_dispatch = async (options) => {
20850
+ const spinner = make_spinner(`Verifying dispatch for ${options.run}...`).start();
20851
+ if (!is_sha_like(options.sha))
20852
+ return fail_with(spinner, `--sha must be a 40-hex commit SHA; got "${options.sha}"`);
20853
+ const http = resolve_orchestrator_http(options);
20854
+ if (!http.ok)
20855
+ return fail_with(spinner, `verify-dispatch ${http.error}`);
20856
+ const fetched = await fetch_dispatches_envelope(http.value, options.run);
20857
+ if (!fetched.ok)
20858
+ return fail_with(spinner, fetched.error);
20859
+ if (options.json ?? false)
20860
+ console.log(JSON.stringify(fetched.value));
20861
+ const decision = evaluate_dispatch_verification(fetched.value, { sha: options.sha, stage: options.stage });
20862
+ if (!decision.ok)
20863
+ return fail_with(spinner, `dispatch verification failed: ${decision.reason}`);
20864
+ spinner.succeed(`dispatch verified: run ${options.run} @ ${options.sha.slice(0, 7)} (stage ${options.stage})`);
20865
+ };
20671
20866
  var action_packages_list = (client_factory) => async (options) => {
20672
20867
  const spinner = make_spinner("Listing pipeline packages...").start();
20673
20868
  const client = client_factory();
@@ -21090,11 +21285,12 @@ var register_pipelines_commands = (program, client_factory = default_client_fact
21090
21285
  const artifacts = pipelines.command("artifacts").description("Manage pipeline artifacts");
21091
21286
  artifacts.command("upload").description("Upload artifacts to corpus").requiredOption("--package <name>", "Package name").option("--bundle <path>", "Path to single-file worker bundle (dist/_worker.js). Mutually exclusive with --bundle-dir").option("--bundle-dir <path>", "Path to directory-bundle worker (e.g. dist/_worker.js/). Mutually exclusive with --bundle").option("--main-module <name>", "Entrypoint module name inside --bundle-dir (e.g. index.js). Required with --bundle-dir").option("--assets-dir <path>", "Path to static-assets directory (e.g. dist/). Files uploaded as CF assets").option("--asset-config <path-or-json>", "JSON file path OR inline JSON for asset config").option("--manifest <path>", "Optional path to env manifest (dist/manifest.json). Defaults to empty object").requiredOption("--infra-plan <path>", "Path to infra plan (infra.ts)").requiredOption("--pipeline <path>", "Path to pipeline definition (pipeline.ts)").requiredOption("--grants <path>", "Path to grants definition (grants.ts)").requiredOption("--output <path>", "Output path for version set JSON").option("--git-sha <sha>", "Git SHA (default: from environment or zeroed)").option("--compatibility-date <date>", "Compatibility date (default: 2025-05-01)").option("--compatibility-flag <flag>", "Compatibility flag (repeatable)", (value, prev) => [...prev ?? [], value]).option("--orchestrator-url <url>", "Orchestrator base URL (default: $DEVPAD_PIPELINES_URL)").option("--token <token>", "Bearer token (default: $DEVPAD_PIPELINES_TOKEN)").option("--mode <mode>", "Backend mode: memory | cloudflare-http (default: auto)").action(action_artifacts_upload);
21092
21287
  const runs = pipelines.command("runs").description("Manage pipeline runs");
21093
- runs.command("start").description("Start a pipeline run with an explicit version set").requiredOption("--package <name>", "Package name").requiredOption("--version-set-id <id>", "Version set ID from corpus").action(action_runs_start(client_factory));
21288
+ runs.command("start").description("Start a pipeline run. Orchestrated packages target --version-set-id; external packages (#155) target --sha (40-hex, POSTs /runs with commit_sha directly to the orchestrator).").requiredOption("--package <name>", "Package name").option("--version-set-id <id>", "Version set ID from corpus (orchestrated packages)").option("--sha <sha>", "40-hex commit SHA (external packages; mutually exclusive with --version-set-id)").option("--json", "Print the run id/status as JSON").option("--orchestrator-url <url>", "Orchestrator base URL (default: $DEVPAD_PIPELINES_URL) — external mode").option("--token <token>", "Bearer token (default: $DEVPAD_PIPELINES_TOKEN) — external mode").action(action_runs_start(client_factory));
21289
+ runs.command("verify-dispatch").description("Verify an external run's dispatch (run BEFORE a CI production deploy): the run targets --sha, a pipeline_dispatch row for --stage exists with status `dispatched`, and the run is in-flight. " + "Exits 0 only when ALL hold — a manual workflow_dispatch without a devpad approval fails here.").requiredOption("--run <id>", "Pipeline run id").requiredOption("--sha <sha>", "Expected 40-hex commit SHA").option("--stage <name>", "Stage to verify the dispatch for", "production").option("--json", "Print the raw dispatches envelope as JSON").option("--orchestrator-url <url>", "Orchestrator base URL (default: $DEVPAD_PIPELINES_URL)").option("--token <token>", "Bearer token (default: $DEVPAD_PIPELINES_TOKEN)").action(action_runs_verify_dispatch);
21094
21290
  const events = runs.command("events").description(`Manage stage events on a pipeline run (Phase 2.C webhook ingestion).
21095
21291
  CLI uses the admin bearer (PIPELINES_TOKEN via DEVPAD_API_KEY).
21096
21292
  External CI should call POST /runs/:id/events directly with an OIDC session JWT, not via this CLI.`);
21097
- events.command("ingest <run-id>").description('Ingest an external webhook event against a run. Server-side stamps payload.source = "external".').requiredOption("--stage <name>", "Stage the event is associated with").requiredOption(`--kind <kind>`, `Event kind — one of ${STAGE_EVENT_KINDS2.join(", ")}`).option("--payload-file <path>", "Path to a JSON file used as the event payload").option("--idempotency-key <uuid>", "UUID idempotency key (defaults to a fresh randomUUID — non-replayable)").action(action_runs_events_ingest(client_factory));
21293
+ events.command("ingest <run-id>").description('Ingest an external webhook event against a run. Server-side stamps payload.source = "external".').requiredOption("--stage <name>", "Stage the event is associated with").requiredOption(`--kind <kind>`, `Event kind — one of ${STAGE_EVENT_KINDS2.join(", ")}`).option("--payload-file <path>", "Path to a JSON file used as the event payload").option("--sha <sha>", "Commit SHA merged into the payload as payload.sha (deploy_started|deploy_completed|deploy_failed); wins over --payload-file's value").option("--idempotency-key <uuid>", "UUID idempotency key (defaults to a fresh randomUUID — non-replayable)").action(action_runs_events_ingest(client_factory));
21098
21294
  events.command("list <run-id>").description("List stored events for a run (newest-first)").action(action_runs_events_list(client_factory));
21099
21295
  const grants = pipelines.command("grants").description("Manage vault grants");
21100
21296
  grants.command("list").description("List vault grants for a package").requiredOption("--package <id>", "Package ID to list grants for").action(action_grants_list(client_factory));
@@ -21493,10 +21689,12 @@ var ignore_path2 = sqliteTable("ignore_path", {
21493
21689
  });
21494
21690
  var ROLLOUT_SHAPES2 = ["gradual", "atomic"];
21495
21691
  var RUN_KINDS2 = ["deploy", "rollback"];
21496
- var RUN_STATUSES2 = ["queued", "deploying", "baking", "awaiting_approval", "rolling_back", "completed", "rolled_back", "failed", "cancelled"];
21692
+ var RUN_STATUSES2 = ["queued", "deploying", "unconfirmed", "baking", "awaiting_approval", "rolling_back", "completed", "rolled_back", "failed", "cancelled"];
21497
21693
  var FORCED_ATOMIC_REASONS2 = ["do_migrations", "asset_affinity_none"];
21498
- var STAGE_EVENT_KINDS3 = ["deploy_started", "deploy_completed", "bake_started", "bake_completed", "gate_verdict", "approval_requested", "rollback_started", "rollback_completed", "warning", "error"];
21694
+ var STAGE_EVENT_KINDS3 = ["deploy_started", "deploy_completed", "deploy_failed", "dispatch_requested", "dispatch_failed", "timed_out", "bake_started", "bake_completed", "gate_verdict", "approval_requested", "rollback_started", "rollback_completed", "warning", "error"];
21499
21695
  var APPROVAL_DECISIONS2 = ["approved", "denied"];
21696
+ var DEPLOY_MODES2 = ["orchestrated", "external"];
21697
+ var DISPATCH_STATUSES2 = ["claimed", "dispatched", "failed"];
21500
21698
  var pipeline_package2 = sqliteTable("pipeline_package", {
21501
21699
  ...entity3("pipeline-package"),
21502
21700
  owner_id: text("owner_id").notNull().references(() => user2.id),
@@ -21504,12 +21702,15 @@ var pipeline_package2 = sqliteTable("pipeline_package", {
21504
21702
  repo_url: text("repo_url"),
21505
21703
  default_template_ref: text("default_template_ref"),
21506
21704
  script_name_overrides: text("script_name_overrides", { mode: "json" }),
21507
- project_id: text("project_id").references(() => project2.id)
21705
+ project_id: text("project_id").references(() => project2.id),
21706
+ deploy_mode: text("deploy_mode", { enum: DEPLOY_MODES2 }).notNull().default("orchestrated"),
21707
+ external_target: text("external_target", { mode: "json" })
21508
21708
  });
21509
21709
  var pipeline_run2 = sqliteTable("pipeline_run", {
21510
21710
  ...entity3("pipeline-run"),
21511
21711
  package_id: text("package_id").notNull().references(() => pipeline_package2.id),
21512
- version_set_id: text("version_set_id").notNull(),
21712
+ version_set_id: text("version_set_id"),
21713
+ commit_sha: text("commit_sha"),
21513
21714
  shape: text("shape", { enum: ROLLOUT_SHAPES2 }).notNull(),
21514
21715
  kind: text("kind", { enum: RUN_KINDS2 }).notNull().default("deploy"),
21515
21716
  status: text("status", { enum: RUN_STATUSES2 }).notNull().default("queued"),
@@ -21528,7 +21729,19 @@ var pipeline_stage_event2 = sqliteTable("pipeline_stage_event", {
21528
21729
  payload: text("payload", { mode: "json" }),
21529
21730
  ts: text("ts").notNull().default(sql`(CURRENT_TIMESTAMP)`),
21530
21731
  idempotency_hash: text("idempotency_hash")
21531
- });
21732
+ }, (table) => [
21733
+ uniqueIndex("idx_pipeline_stage_event_idem_uniq").on(table.run_id, table.idempotency_hash).where(sql`idempotency_hash IS NOT NULL`)
21734
+ ]);
21735
+ var pipeline_dispatch2 = sqliteTable("pipeline_dispatch", {
21736
+ ...id2("pipeline-dispatch"),
21737
+ run_id: text("run_id").notNull().references(() => pipeline_run2.id),
21738
+ stage_name: text("stage_name").notNull(),
21739
+ commit_sha: text("commit_sha").notNull(),
21740
+ status: text("status", { enum: DISPATCH_STATUSES2 }).notNull().default("claimed"),
21741
+ error: text("error"),
21742
+ requested_by: text("requested_by"),
21743
+ ...timestamps2()
21744
+ }, (table) => [unique("pipeline_dispatch_run_stage_unique").on(table.run_id, table.stage_name)]);
21532
21745
  var pipeline_grant2 = sqliteTable("pipeline_grant", {
21533
21746
  ...entity3("pipeline-grant"),
21534
21747
  package_id: text("package_id").notNull().references(() => pipeline_package2.id),
@@ -21654,7 +21867,11 @@ var pipeline_package_relations2 = relations(pipeline_package2, ({ one, many }) =
21654
21867
  var pipeline_run_relations2 = relations(pipeline_run2, ({ one, many }) => ({
21655
21868
  package: one(pipeline_package2, { fields: [pipeline_run2.package_id], references: [pipeline_package2.id] }),
21656
21869
  events: many(pipeline_stage_event2),
21657
- approvals: many(pipeline_approval2)
21870
+ approvals: many(pipeline_approval2),
21871
+ dispatches: many(pipeline_dispatch2)
21872
+ }));
21873
+ var pipeline_dispatch_relations2 = relations(pipeline_dispatch2, ({ one }) => ({
21874
+ run: one(pipeline_run2, { fields: [pipeline_dispatch2.run_id], references: [pipeline_run2.id] })
21658
21875
  }));
21659
21876
  var pipeline_stage_event_relations2 = relations(pipeline_stage_event2, ({ one }) => ({
21660
21877
  run: one(pipeline_run2, { fields: [pipeline_stage_event2.run_id], references: [pipeline_run2.id] })
@@ -21826,6 +22043,7 @@ var run_kind2 = unionType([literalType("deploy"), literalType("rollback")]);
21826
22043
  var run_status2 = unionType([
21827
22044
  literalType("queued"),
21828
22045
  literalType("deploying"),
22046
+ literalType("unconfirmed"),
21829
22047
  literalType("baking"),
21830
22048
  literalType("awaiting_approval"),
21831
22049
  literalType("rolling_back"),
@@ -21838,6 +22056,10 @@ var forced_atomic_reason2 = unionType([literalType("do_migrations"), literalType
21838
22056
  var stage_event_kind2 = unionType([
21839
22057
  literalType("deploy_started"),
21840
22058
  literalType("deploy_completed"),
22059
+ literalType("deploy_failed"),
22060
+ literalType("dispatch_requested"),
22061
+ literalType("dispatch_failed"),
22062
+ literalType("timed_out"),
21841
22063
  literalType("bake_started"),
21842
22064
  literalType("bake_completed"),
21843
22065
  literalType("gate_verdict"),
@@ -21848,6 +22070,16 @@ var stage_event_kind2 = unionType([
21848
22070
  literalType("error")
21849
22071
  ]);
21850
22072
  var approval_decision2 = unionType([literalType("approved"), literalType("denied")]);
22073
+ var deploy_mode2 = unionType([literalType("orchestrated"), literalType("external")]);
22074
+ var commit_sha2 = stringType().regex(/^[0-9a-f]{40}$/, "commit_sha must be a 40-hex SHA");
22075
+ var external_target2 = objectType({
22076
+ repo: stringType().regex(/^[^/\s]+\/[^/\s]+$/, "repo must be owner/name"),
22077
+ workflow: stringType().min(1).describe("workflow file name, e.g. deploy.yml"),
22078
+ ref: stringType().min(1).default("main"),
22079
+ timeout_ms: numberType().int().positive().default(2700000),
22080
+ gate: objectType({ type: literalType("manual") }).default({ type: "manual" })
22081
+ });
22082
+ var dispatch_status2 = unionType([literalType("claimed"), literalType("dispatched"), literalType("failed")]);
21851
22083
  var grant_scope2 = stringType().regex(/^[a-z0-9_-]+:[a-z0-9_-]+(:[^\s]+)?$/, "Invalid scope format");
21852
22084
  var rollout_stage2 = objectType({
21853
22085
  name: stringType(),
@@ -21876,12 +22108,15 @@ var upsert_pipeline_package2 = objectType({
21876
22108
  repo_url: stringType().nullable().optional(),
21877
22109
  default_template_ref: stringType().nullable().optional(),
21878
22110
  script_name_overrides: recordType(stringType(), stringType()).nullable().optional(),
21879
- project_id: stringType().nullable().optional()
22111
+ project_id: stringType().nullable().optional(),
22112
+ deploy_mode: deploy_mode2.optional(),
22113
+ external_target: external_target2.nullable().optional()
21880
22114
  });
21881
22115
  var upsert_pipeline_run2 = objectType({
21882
22116
  id: stringType().optional().nullable(),
21883
22117
  package_id: stringType(),
21884
- version_set_id: stringType(),
22118
+ version_set_id: stringType().nullable(),
22119
+ commit_sha: commit_sha2.nullable().optional(),
21885
22120
  shape: rollout_shape2,
21886
22121
  kind: run_kind2.optional(),
21887
22122
  status: run_status2.optional(),
@@ -21914,6 +22149,15 @@ var upsert_pipeline_approval2 = objectType({
21914
22149
  decided_by: stringType().nullable().optional(),
21915
22150
  decided_at: stringType().nullable().optional()
21916
22151
  });
22152
+ var upsert_pipeline_dispatch2 = objectType({
22153
+ id: stringType().optional().nullable(),
22154
+ run_id: stringType(),
22155
+ stage_name: stringType(),
22156
+ commit_sha: commit_sha2,
22157
+ status: dispatch_status2.optional(),
22158
+ error: stringType().nullable().optional(),
22159
+ requested_by: stringType().nullable().optional()
22160
+ });
21917
22161
  var upsert_pipeline_analysis_template2 = objectType({
21918
22162
  id: stringType().optional(),
21919
22163
  owner_id: stringType().min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devpad/cli",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Command line interface for devpad project management",
5
5
  "keywords": [
6
6
  "cli",
@@ -50,11 +50,11 @@
50
50
  "mime": "^3.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@devpad/api": "^2.5.2",
54
- "@devpad/core": "^2.5.2",
55
- "@devpad/pipeline-fakes": "^2.5.2",
56
- "@devpad/pipeline-templates": "^2.5.2",
57
- "@devpad/schema": "^2.5.2",
53
+ "@devpad/api": "^2.5.3",
54
+ "@devpad/core": "^2.5.3",
55
+ "@devpad/pipeline-fakes": "^2.5.3",
56
+ "@devpad/pipeline-templates": "^2.5.3",
57
+ "@devpad/schema": "^2.5.3",
58
58
  "@types/node": "^20.11.24",
59
59
  "bun-types": "latest",
60
60
  "chalk": "^5.3.0",