@kitsi/action 0.0.14 → 0.0.16

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 +720 -491
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -101119,7 +101119,7 @@ var require_picomatch2 = __commonJS((exports, module2) => {
101119
101119
  });
101120
101120
 
101121
101121
  // src/index.ts
101122
- var core6 = __toESM(require_core(), 1);
101122
+ var core7 = __toESM(require_core(), 1);
101123
101123
 
101124
101124
  // src/capabilities/annotations.ts
101125
101125
  var core = __toESM(require_core(), 1);
@@ -101566,9 +101566,9 @@ class GroupManager {
101566
101566
  import { resolve as resolvePath2 } from "node:path";
101567
101567
  import { pathToFileURL } from "node:url";
101568
101568
 
101569
- // ../cli/dist/version.js
101569
+ // ../core/dist/version.js
101570
101570
  var VERSION = "0.0.1";
101571
- // ../cli/dist/dsl/plan.js
101571
+ // ../core/dist/dsl/plan.js
101572
101572
  var clonePlan = (plan, patch) => new PlanBuilder((() => {
101573
101573
  const next = {
101574
101574
  name: patch.name ?? plan.config.name,
@@ -101662,7 +101662,7 @@ var plan = (name) => new PlanBuilder({
101662
101662
  concurrency: {},
101663
101663
  tasks: []
101664
101664
  });
101665
- // ../cli/dist/dsl/task.js
101665
+ // ../core/dist/dsl/task.js
101666
101666
  var cloneTask = (task, patch) => new TaskBuilder({
101667
101667
  ...task.config,
101668
101668
  ...patch,
@@ -101729,7 +101729,7 @@ var task = (name) => new TaskBuilder({
101729
101729
  inputs: [],
101730
101730
  cacheEnv: []
101731
101731
  });
101732
- // ../cli/dist/dsl/step.js
101732
+ // ../core/dist/dsl/step.js
101733
101733
  class StepBuilder {
101734
101734
  name;
101735
101735
  run;
@@ -101746,7 +101746,7 @@ class StepBuilder {
101746
101746
  }
101747
101747
  }
101748
101748
  var step = (name, run) => new StepBuilder(name, run);
101749
- // ../cli/dist/dsl/kit.js
101749
+ // ../core/dist/dsl/kit.js
101750
101750
  var cloneKit = (kit, patch) => new KitBuilder({
101751
101751
  ...kit.config,
101752
101752
  ...patch,
@@ -101780,7 +101780,7 @@ class KitBuilder {
101780
101780
  }
101781
101781
  }
101782
101782
  var kit = (name) => new KitBuilder({ name, env: {}, setupSteps: [] });
101783
- // ../cli/dist/dsl/image.js
101783
+ // ../core/dist/dsl/image.js
101784
101784
  class ImageBuilder {
101785
101785
  config;
101786
101786
  constructor(config) {
@@ -101794,7 +101794,7 @@ class ImageBuilder {
101794
101794
  }
101795
101795
  }
101796
101796
  var image = (ref) => new ImageBuilder({ ref, env: {} });
101797
- // ../cli/dist/dsl/service.js
101797
+ // ../core/dist/dsl/service.js
101798
101798
  class ServiceBuilder {
101799
101799
  config;
101800
101800
  constructor(config) {
@@ -101814,101 +101814,26 @@ class ServiceBuilder {
101814
101814
  }
101815
101815
  }
101816
101816
  var service = (imageRef) => new ServiceBuilder({ image: imageRef, env: {}, ports: [] });
101817
- // ../cli/dist/dsl/registry.js
101817
+ // ../core/dist/dsl/registry.js
101818
101818
  var registry = (...plansList) => ({
101819
101819
  plans: plansList
101820
101820
  });
101821
- // ../cli/dist/ops/shell.js
101822
- var toTemplatePart = (value) => {
101823
- if (typeof value === "string" || typeof value === "number") {
101824
- return { type: "interpolated", value: String(value) };
101825
- }
101826
- if (value.kind === "secret") {
101827
- return { type: "secret", name: value.name };
101828
- }
101829
- if (value.kind === "param") {
101830
- return { type: "param", ref: value };
101831
- }
101832
- return { type: "value", ref: value };
101833
- };
101834
-
101835
- class CommandBuilder {
101836
- op;
101837
- constructor(op) {
101838
- this.op = op;
101839
- }
101840
- stdout() {
101841
- return { ...this.op, capture: "stdout" };
101842
- }
101843
- code() {
101844
- return { ...this.op, capture: "code" };
101845
- }
101846
- ok() {
101847
- return { ...this.op, capture: "ok" };
101848
- }
101849
- must() {
101850
- return { ...this.op, capture: "must" };
101851
- }
101852
- cached(options) {
101853
- return new CommandBuilder({ ...this.op, cache: { enabled: true, ...options } });
101854
- }
101855
- uncached() {
101856
- return new CommandBuilder({ ...this.op, cache: { enabled: false } });
101857
- }
101858
- }
101859
- var sh = (strings, ...values) => {
101860
- const template = [];
101861
- for (let i = 0;i < strings.length; i += 1) {
101862
- const text = strings[i] ?? "";
101863
- if (text.length > 0) {
101864
- template.push({ type: "text", value: text });
101865
- }
101866
- const value = values[i];
101867
- if (i < values.length && value !== undefined) {
101868
- template.push(toTemplatePart(value));
101869
- }
101870
- }
101871
- return new CommandBuilder({
101872
- kind: "command",
101873
- capture: "result",
101874
- template
101875
- });
101821
+ // ../core/dist/ops/operation.js
101822
+ var isOperation = (value) => {
101823
+ if (!value || typeof value !== "object")
101824
+ return false;
101825
+ const op = value;
101826
+ return typeof op.kind === "string" && typeof op.toOp === "function" && typeof op.analysisPlaceholder === "function" && typeof op.extractDependencies === "function" && typeof op.extractSecrets === "function" && typeof op.extractRefs === "function" && typeof op.cacheNormalize === "function" && typeof op.cachePlaceholder === "function";
101876
101827
  };
101877
101828
 
101878
- // ../cli/dist/dsl/analysis.js
101829
+ // ../core/dist/dsl/analysis.js
101879
101830
  var stepIterator = (step2, task2) => {
101880
101831
  return step2.run({ task: task2, workspace: "" });
101881
101832
  };
101882
- var toOp = (value) => {
101883
- if (value instanceof CommandBuilder)
101884
- return value.op;
101885
- if (value && typeof value === "object" && "op" in value) {
101886
- const maybeOp = value.op;
101887
- if (maybeOp && typeof maybeOp === "object" && "kind" in maybeOp) {
101888
- return maybeOp;
101889
- }
101890
- }
101891
- return value;
101892
- };
101893
- var placeholderForOp = (value) => {
101894
- const op = toOp(value);
101895
- switch (op.kind) {
101896
- case "command":
101897
- return "";
101898
- case "http":
101899
- return { status: 200, ok: true, headers: {}, body: "" };
101900
- case "use":
101901
- return op.ref.parse("");
101902
- case "emit":
101903
- return op.value;
101904
- case "pack":
101905
- case "unpack":
101906
- return;
101907
- case "env":
101908
- return typeof op.value === "string" || typeof op.value === "number" ? op.value : "";
101909
- default:
101910
- return;
101911
- }
101833
+ var toOperation = (value) => {
101834
+ if (isOperation(value))
101835
+ return value;
101836
+ throw new Error("Step yielded a non-operation value");
101912
101837
  };
101913
101838
  var collectEnvSecrets = (task2, secrets) => {
101914
101839
  for (const value of Object.values(task2.config.env)) {
@@ -101917,49 +101842,17 @@ var collectEnvSecrets = (task2, secrets) => {
101917
101842
  }
101918
101843
  }
101919
101844
  };
101920
- var collectTemplateSecrets = (template, secrets) => {
101921
- for (const part of template) {
101922
- if (part.type === "secret" && part.name) {
101923
- secrets.add(part.name);
101924
- }
101925
- }
101926
- };
101927
- var collectHttpSecrets = (op, secrets) => {
101928
- collectTemplateSecrets(op.url, secrets);
101929
- for (const header of op.headers) {
101930
- collectTemplateSecrets(header.value, secrets);
101931
- }
101932
- if (op.body) {
101933
- collectTemplateSecrets(op.body, secrets);
101934
- }
101935
- };
101936
- var collectEnvOpSecrets = (op, secrets) => {
101937
- if (op.value.kind === "secret") {
101938
- secrets.add(op.value.name);
101939
- }
101940
- };
101941
- var collectOpSecrets = (op, secrets) => {
101942
- if (op.kind === "command") {
101943
- collectTemplateSecrets(op.template, secrets);
101944
- return;
101945
- }
101946
- if (op.kind === "http") {
101947
- collectHttpSecrets(op, secrets);
101948
- return;
101949
- }
101950
- if (op.kind === "env") {
101951
- collectEnvOpSecrets(op, secrets);
101952
- }
101953
- };
101954
101845
  var collectStepSecrets = (task2, secrets) => {
101955
101846
  const steps = [...task2.config.setupSteps, ...task2.config.steps];
101956
101847
  for (const step2 of steps) {
101957
101848
  const iterator = stepIterator(step2, task2);
101958
101849
  let cursor = iterator.next();
101959
101850
  while (!cursor.done) {
101960
- const op = toOp(cursor.value);
101961
- collectOpSecrets(op, secrets);
101962
- cursor = iterator.next(placeholderForOp(op));
101851
+ const operation = toOperation(cursor.value);
101852
+ for (const name of operation.extractSecrets()) {
101853
+ secrets.add(name);
101854
+ }
101855
+ cursor = iterator.next(operation.analysisPlaceholder());
101963
101856
  }
101964
101857
  }
101965
101858
  };
@@ -101971,14 +101864,14 @@ var collectSecrets = (tasks) => {
101971
101864
  }
101972
101865
  return secrets;
101973
101866
  };
101974
- // ../cli/dist/dsl/utils.js
101867
+ // ../core/dist/dsl/utils.js
101975
101868
  import { resolve as resolvePath } from "node:path";
101976
101869
  var resolveWorkspace = (workspace) => {
101977
101870
  if (!workspace)
101978
101871
  return process.cwd();
101979
101872
  return workspace.startsWith(".") ? resolvePath(process.cwd(), workspace) : workspace;
101980
101873
  };
101981
- // ../cli/dist/ops/errors.js
101874
+ // ../core/dist/ops/errors.js
101982
101875
  class OpErrorBuilder {
101983
101876
  type;
101984
101877
  message;
@@ -102019,10 +101912,10 @@ var OpErrors = {
102019
101912
  service: (message) => new OpErrorBuilder("service", message),
102020
101913
  timeout: (message) => new OpErrorBuilder("timeout", message)
102021
101914
  };
102022
- // ../cli/dist/ops/http.js
101915
+ // ../core/dist/ops/template.js
102023
101916
  var isTemplateStringsArray = (value) => Array.isArray(value) && Object.prototype.hasOwnProperty.call(value, "raw");
102024
101917
  var isTemplatePartArray = (value) => Array.isArray(value) && (value.length === 0 || typeof value[0] === "object" && value[0] !== null && ("type" in value[0]));
102025
- var toTemplatePart2 = (value) => {
101918
+ var toTemplatePart = (value) => {
102026
101919
  if (typeof value === "string" || typeof value === "number") {
102027
101920
  return { type: "interpolated", value: String(value) };
102028
101921
  }
@@ -102043,7 +101936,7 @@ var buildTemplateParts = (strings, values) => {
102043
101936
  }
102044
101937
  const value = values[i];
102045
101938
  if (i < values.length && value !== undefined) {
102046
- template.push(toTemplatePart2(value));
101939
+ template.push(toTemplatePart(value));
102047
101940
  }
102048
101941
  }
102049
101942
  return template;
@@ -102056,10 +101949,123 @@ var templateFromInput = (input, values) => {
102056
101949
  return input;
102057
101950
  }
102058
101951
  if (Array.isArray(input)) {
102059
- return input.map((part) => toTemplatePart2(part));
101952
+ return input.map((part) => toTemplatePart(part));
101953
+ }
101954
+ return [toTemplatePart(input)];
101955
+ };
101956
+ var collectTemplateMetadata = (template, addSecret, addParam) => {
101957
+ for (const part of template) {
101958
+ if (part.type === "secret")
101959
+ addSecret(part.name);
101960
+ if (part.type === "param")
101961
+ addParam(part.ref.name);
102060
101962
  }
102061
- return [toTemplatePart2(input)];
102062
101963
  };
101964
+ var collectTemplateSecrets = (template) => {
101965
+ const names = new Set;
101966
+ for (const part of template) {
101967
+ if (part.type === "secret")
101968
+ names.add(part.name);
101969
+ }
101970
+ return Array.from(names);
101971
+ };
101972
+ var normalizeTemplatePart = (part) => {
101973
+ if (part.type === "text" || part.type === "interpolated") {
101974
+ return { type: part.type, value: part.value };
101975
+ }
101976
+ if (part.type === "secret") {
101977
+ return { type: part.type, name: part.name };
101978
+ }
101979
+ return { type: part.type, name: part.ref.name };
101980
+ };
101981
+ var commandSignature = (template) => {
101982
+ const raw = template.map((part) => {
101983
+ if (part.type === "text")
101984
+ return part.value;
101985
+ if (part.type === "interpolated")
101986
+ return String(part.value);
101987
+ if (part.type === "secret")
101988
+ return `<secret:${part.name}>`;
101989
+ if (part.type === "param")
101990
+ return `<param:${part.ref.name}>`;
101991
+ return `<value:${part.ref.name}>`;
101992
+ }).join("");
101993
+ return raw.replace(/\s+/g, " ").trim();
101994
+ };
101995
+
101996
+ // ../core/dist/ops/shell.js
101997
+ class CommandBuilder {
101998
+ op;
101999
+ constructor(op) {
102000
+ this.op = op;
102001
+ }
102002
+ get kind() {
102003
+ return this.op.kind;
102004
+ }
102005
+ toOp() {
102006
+ return this.op;
102007
+ }
102008
+ analysisPlaceholder() {
102009
+ return "";
102010
+ }
102011
+ extractDependencies(_taskName) {
102012
+ return [];
102013
+ }
102014
+ extractSecrets() {
102015
+ const names = new Set;
102016
+ collectTemplateMetadata(this.op.template, (name) => names.add(name), () => {});
102017
+ return Array.from(names);
102018
+ }
102019
+ extractRefs() {
102020
+ return [];
102021
+ }
102022
+ cacheNormalize(context) {
102023
+ context.addCommandSignature(commandSignature(this.op.template));
102024
+ collectTemplateMetadata(this.op.template, context.addSecret, context.addParam);
102025
+ return {
102026
+ kind: this.op.kind,
102027
+ capture: this.op.capture,
102028
+ cache: this.op.cache ?? null,
102029
+ template: this.op.template.map(normalizeTemplatePart)
102030
+ };
102031
+ }
102032
+ cachePlaceholder(context) {
102033
+ if (!context.isPrimary)
102034
+ return;
102035
+ if (this.op.capture === "ok")
102036
+ return true;
102037
+ if (this.op.capture === "code")
102038
+ return 0;
102039
+ return "";
102040
+ }
102041
+ stdout() {
102042
+ return new CommandBuilder({ ...this.op, capture: "stdout" });
102043
+ }
102044
+ code() {
102045
+ return new CommandBuilder({ ...this.op, capture: "code" });
102046
+ }
102047
+ ok() {
102048
+ return new CommandBuilder({ ...this.op, capture: "ok" });
102049
+ }
102050
+ must() {
102051
+ return new CommandBuilder({ ...this.op, capture: "must" });
102052
+ }
102053
+ cached(options) {
102054
+ return new CommandBuilder({ ...this.op, cache: { enabled: true, ...options } });
102055
+ }
102056
+ uncached() {
102057
+ return new CommandBuilder({ ...this.op, cache: { enabled: false } });
102058
+ }
102059
+ }
102060
+ var sh = (strings, ...values) => {
102061
+ const template = buildTemplateParts(strings, values);
102062
+ return new CommandBuilder({
102063
+ kind: "command",
102064
+ capture: "result",
102065
+ template
102066
+ });
102067
+ };
102068
+ // ../core/dist/ops/http.js
102063
102069
  var hasHeader = (headers, name) => headers.some((header) => header.name.toLowerCase() === name.toLowerCase());
102064
102070
 
102065
102071
  class HttpBuilder {
@@ -102067,6 +102073,60 @@ class HttpBuilder {
102067
102073
  constructor(op) {
102068
102074
  this.op = op;
102069
102075
  }
102076
+ get kind() {
102077
+ return this.op.kind;
102078
+ }
102079
+ toOp() {
102080
+ return this.op;
102081
+ }
102082
+ analysisPlaceholder() {
102083
+ return { status: 200, ok: true, headers: {}, body: "" };
102084
+ }
102085
+ extractDependencies(_taskName) {
102086
+ return [];
102087
+ }
102088
+ extractSecrets() {
102089
+ const names = new Set;
102090
+ for (const name of collectTemplateSecrets(this.op.url))
102091
+ names.add(name);
102092
+ for (const header of this.op.headers) {
102093
+ for (const name of collectTemplateSecrets(header.value))
102094
+ names.add(name);
102095
+ }
102096
+ if (this.op.body) {
102097
+ for (const name of collectTemplateSecrets(this.op.body))
102098
+ names.add(name);
102099
+ }
102100
+ return Array.from(names);
102101
+ }
102102
+ extractRefs() {
102103
+ return [];
102104
+ }
102105
+ cacheNormalize(context) {
102106
+ collectTemplateMetadata(this.op.url, context.addSecret, context.addParam);
102107
+ for (const header of this.op.headers) {
102108
+ collectTemplateMetadata(header.value, context.addSecret, context.addParam);
102109
+ }
102110
+ if (this.op.body) {
102111
+ collectTemplateMetadata(this.op.body, context.addSecret, context.addParam);
102112
+ }
102113
+ return {
102114
+ kind: this.op.kind,
102115
+ method: this.op.method,
102116
+ url: this.op.url.map(normalizeTemplatePart),
102117
+ headers: this.op.headers.map((header) => ({
102118
+ name: header.name,
102119
+ value: header.value.map(normalizeTemplatePart)
102120
+ })),
102121
+ body: this.op.body ? this.op.body.map(normalizeTemplatePart) : null,
102122
+ bodyPath: this.op.bodyPath ?? null
102123
+ };
102124
+ }
102125
+ cachePlaceholder(context) {
102126
+ if (!context.isPrimary)
102127
+ return;
102128
+ return { status: 200, ok: true, headers: {}, body: "" };
102129
+ }
102070
102130
  header(name, value, ...values) {
102071
102131
  const next = { name, value: templateFromInput(value, values) };
102072
102132
  return new HttpBuilder({ ...this.op, headers: [...this.op.headers, next] });
@@ -102113,15 +102173,76 @@ var http = {
102113
102173
  head: (url, ...values) => buildRequest("HEAD", url, values),
102114
102174
  options: (url, ...values) => buildRequest("OPTIONS", url, values)
102115
102175
  };
102116
- // ../cli/dist/ops/env.js
102117
- var env = (name, value) => ({
102118
- kind: "env",
102119
- name,
102120
- value
102121
- });
102122
- // ../cli/dist/ops/secret.js
102176
+ // ../core/dist/ops/types.js
102177
+ var isSecretRef = (value) => value.kind === "secret";
102178
+ var isParamRef = (value) => value.kind === "param";
102179
+ var isValueRef = (value) => value.kind === "value";
102180
+
102181
+ // ../core/dist/ops/env.js
102182
+ class EnvOperation {
102183
+ name;
102184
+ value;
102185
+ constructor(name, value) {
102186
+ this.name = name;
102187
+ this.value = value;
102188
+ }
102189
+ get kind() {
102190
+ return "env";
102191
+ }
102192
+ toOp() {
102193
+ return { kind: "env", name: this.name, value: this.value };
102194
+ }
102195
+ analysisPlaceholder() {
102196
+ if (typeof this.value === "string" || typeof this.value === "number") {
102197
+ return this.value;
102198
+ }
102199
+ return "";
102200
+ }
102201
+ extractDependencies(_taskName) {
102202
+ return [];
102203
+ }
102204
+ extractSecrets() {
102205
+ const value = this.value;
102206
+ if (typeof value === "object" && value !== null && isSecretRef(value)) {
102207
+ return [value.name];
102208
+ }
102209
+ return [];
102210
+ }
102211
+ extractRefs() {
102212
+ return [];
102213
+ }
102214
+ cacheNormalize(context) {
102215
+ const value = this.value;
102216
+ if (typeof value !== "string" && typeof value !== "number") {
102217
+ if (isSecretRef(value))
102218
+ context.addSecret(value.name);
102219
+ if (isParamRef(value))
102220
+ context.addParam(value.name);
102221
+ }
102222
+ const normalized = (() => {
102223
+ if (typeof value === "string" || typeof value === "number")
102224
+ return value;
102225
+ if (isSecretRef(value))
102226
+ return { kind: "secret", name: value.name };
102227
+ if (isParamRef(value))
102228
+ return { kind: "param", name: value.name };
102229
+ if (isValueRef(value))
102230
+ return { kind: "value", name: value.name };
102231
+ return String(value);
102232
+ })();
102233
+ return { kind: this.kind, name: this.name, value: normalized };
102234
+ }
102235
+ cachePlaceholder(context) {
102236
+ if (typeof this.value === "string" || typeof this.value === "number") {
102237
+ return this.value;
102238
+ }
102239
+ return context.isPrimary ? "" : undefined;
102240
+ }
102241
+ }
102242
+ var env = (name, value) => new EnvOperation(name, value);
102243
+ // ../core/dist/ops/secret.js
102123
102244
  var secret = (name) => ({ kind: "secret", name });
102124
- // ../cli/dist/ops/ref.js
102245
+ // ../core/dist/ops/ref.js
102125
102246
  var coerce = {
102126
102247
  string: (value) => String(value),
102127
102248
  number: (value) => Number(value),
@@ -102143,7 +102264,111 @@ var createRefFactory = (kind) => {
102143
102264
  };
102144
102265
  var param = createRefFactory("param");
102145
102266
  var out = createRefFactory("value");
102146
- // ../cli/dist/ops/cache.js
102267
+ // ../core/dist/ops/operation-base.js
102268
+ class OperationBase {
102269
+ analysisPlaceholder() {
102270
+ return;
102271
+ }
102272
+ extractDependencies(_taskName) {
102273
+ return [];
102274
+ }
102275
+ extractSecrets() {
102276
+ return [];
102277
+ }
102278
+ extractRefs() {
102279
+ return [];
102280
+ }
102281
+ cachePlaceholder(context) {
102282
+ return context.value;
102283
+ }
102284
+ }
102285
+
102286
+ // ../core/dist/ops/cache.js
102287
+ class CacheOperation extends OperationBase {
102288
+ name;
102289
+ paths;
102290
+ key;
102291
+ constructor(name, paths, key) {
102292
+ super();
102293
+ this.name = name;
102294
+ this.paths = paths;
102295
+ if (key)
102296
+ this.key = key;
102297
+ }
102298
+ get kind() {
102299
+ return "cache";
102300
+ }
102301
+ toOp() {
102302
+ return {
102303
+ kind: "cache",
102304
+ name: this.name,
102305
+ paths: this.paths,
102306
+ ...this.key ? { key: this.key } : {}
102307
+ };
102308
+ }
102309
+ cacheNormalize(_context) {
102310
+ return {
102311
+ kind: this.kind,
102312
+ name: this.name,
102313
+ paths: this.paths,
102314
+ key: this.key ?? null
102315
+ };
102316
+ }
102317
+ }
102318
+
102319
+ class CacheOrOperation extends OperationBase {
102320
+ name;
102321
+ paths;
102322
+ key;
102323
+ compute;
102324
+ constructor(name, paths, compute, key) {
102325
+ super();
102326
+ this.name = name;
102327
+ this.paths = paths;
102328
+ this.compute = compute;
102329
+ if (key)
102330
+ this.key = key;
102331
+ }
102332
+ get kind() {
102333
+ return "cache-or";
102334
+ }
102335
+ toOp() {
102336
+ return {
102337
+ kind: "cache-or",
102338
+ name: this.name,
102339
+ paths: this.paths,
102340
+ ...this.key ? { key: this.key } : {},
102341
+ compute: this.compute
102342
+ };
102343
+ }
102344
+ cacheNormalize(context) {
102345
+ const computeOps = context.analyzeNested(this.compute, context.resultValue);
102346
+ return {
102347
+ kind: this.kind,
102348
+ name: this.name,
102349
+ paths: this.paths,
102350
+ key: this.key ?? null,
102351
+ compute: computeOps
102352
+ };
102353
+ }
102354
+ }
102355
+
102356
+ class CacheMountOperation extends OperationBase {
102357
+ cache;
102358
+ constructor(cache2) {
102359
+ super();
102360
+ this.cache = cache2;
102361
+ }
102362
+ get kind() {
102363
+ return "cache-mount";
102364
+ }
102365
+ toOp() {
102366
+ return { kind: "cache-mount", cache: this.cache };
102367
+ }
102368
+ cacheNormalize(_context) {
102369
+ return { kind: this.kind };
102370
+ }
102371
+ }
102147
102372
  var createCacheRef = (name, mountPath, key) => {
102148
102373
  const ref = {
102149
102374
  kind: "cache",
@@ -102157,26 +102382,57 @@ var createCacheRef = (name, mountPath, key) => {
102157
102382
  ref.key = key;
102158
102383
  return ref;
102159
102384
  };
102160
- var cacheOr = (name, options) => ({
102161
- kind: "cache-or",
102162
- name,
102163
- paths: options.paths,
102164
- ...options.key !== undefined ? { key: options.key } : {},
102165
- compute: options.compute
102166
- });
102167
- var cacheFn = (name, options) => ({
102168
- kind: "cache",
102169
- name,
102170
- paths: options.paths,
102171
- ...options.key !== undefined ? { key: options.key } : {}
102172
- });
102385
+ var cacheOr = (name, options) => new CacheOrOperation(name, options.paths, options.compute, options.key);
102386
+ var cacheFn = (name, options) => new CacheOperation(name, options.paths, options.key);
102173
102387
  cacheFn.dir = (name) => createCacheRef(name);
102174
- cacheFn.mount = (ref) => ({
102175
- kind: "cache-mount",
102176
- cache: ref
102177
- });
102388
+ cacheFn.mount = (ref) => new CacheMountOperation(ref);
102178
102389
  var cache2 = cacheFn;
102179
- // ../cli/dist/ops/artifact.js
102390
+ // ../core/dist/ops/artifact.js
102391
+ class ArtifactUploadOperation extends OperationBase {
102392
+ name;
102393
+ patterns;
102394
+ when;
102395
+ constructor(name, patterns, when) {
102396
+ super();
102397
+ this.name = name;
102398
+ this.patterns = patterns;
102399
+ this.when = when;
102400
+ }
102401
+ get kind() {
102402
+ return "artifact-upload";
102403
+ }
102404
+ toOp() {
102405
+ return { kind: "artifact-upload", name: this.name, patterns: this.patterns, when: this.when };
102406
+ }
102407
+ cacheNormalize(_context) {
102408
+ return {
102409
+ kind: this.kind,
102410
+ name: this.name,
102411
+ patterns: this.patterns,
102412
+ when: this.when
102413
+ };
102414
+ }
102415
+ }
102416
+
102417
+ class ArtifactDownloadOperation extends OperationBase {
102418
+ name;
102419
+ destination;
102420
+ constructor(name, destination) {
102421
+ super();
102422
+ this.name = name;
102423
+ this.destination = destination;
102424
+ }
102425
+ get kind() {
102426
+ return "artifact-download";
102427
+ }
102428
+ toOp() {
102429
+ return { kind: "artifact-download", name: this.name, destination: this.destination };
102430
+ }
102431
+ cacheNormalize(_context) {
102432
+ return { kind: this.kind, name: this.name, destination: this.destination };
102433
+ }
102434
+ }
102435
+
102180
102436
  class ArtifactUploadBuilder {
102181
102437
  name;
102182
102438
  patterns;
@@ -102190,10 +102446,10 @@ class ArtifactUploadBuilder {
102190
102446
  return new ArtifactUploadBuilder(this.name, patterns, this.when);
102191
102447
  }
102192
102448
  whenSuccess() {
102193
- return { kind: "artifact-upload", name: this.name, patterns: this.patterns, when: "success" };
102449
+ return new ArtifactUploadOperation(this.name, this.patterns, "success");
102194
102450
  }
102195
102451
  whenAlways() {
102196
- return { kind: "artifact-upload", name: this.name, patterns: this.patterns, when: "always" };
102452
+ return new ArtifactUploadOperation(this.name, this.patterns, "always");
102197
102453
  }
102198
102454
  }
102199
102455
 
@@ -102203,14 +102459,14 @@ class ArtifactDownloadBuilder {
102203
102459
  this.name = name;
102204
102460
  }
102205
102461
  to(destination) {
102206
- return { kind: "artifact-download", name: this.name, destination };
102462
+ return new ArtifactDownloadOperation(this.name, destination);
102207
102463
  }
102208
102464
  }
102209
102465
  var artifact2 = {
102210
102466
  upload: (name) => new ArtifactUploadBuilder(name),
102211
102467
  download: (name) => new ArtifactDownloadBuilder(name)
102212
102468
  };
102213
- // ../cli/dist/ops/bundle.js
102469
+ // ../core/dist/ops/bundle.js
102214
102470
  var cloneBundle = (ref, patterns) => ({
102215
102471
  ...ref,
102216
102472
  patterns,
@@ -102225,79 +102481,243 @@ var createBundleRef = (name) => {
102225
102481
  };
102226
102482
  return ref;
102227
102483
  };
102228
- var pack = (ref) => ({
102229
- kind: "pack",
102230
- ref
102231
- });
102232
- var unpack = (from, ref) => ({
102233
- kind: "unpack",
102234
- from,
102235
- ref
102236
- });
102237
102484
 
102238
- // ../cli/dist/ops/output.js
102485
+ class PackOperation extends OperationBase {
102486
+ ref;
102487
+ constructor(ref) {
102488
+ super();
102489
+ this.ref = ref;
102490
+ }
102491
+ get kind() {
102492
+ return "pack";
102493
+ }
102494
+ toOp() {
102495
+ return { kind: "pack", ref: this.ref };
102496
+ }
102497
+ cacheNormalize(_context) {
102498
+ return { kind: this.kind, name: this.ref.name, patterns: this.ref.patterns };
102499
+ }
102500
+ cachePlaceholder(_context) {
102501
+ return;
102502
+ }
102503
+ }
102504
+
102505
+ class UnpackOperation extends OperationBase {
102506
+ from;
102507
+ ref;
102508
+ constructor(from, ref) {
102509
+ super();
102510
+ this.from = from;
102511
+ this.ref = ref;
102512
+ }
102513
+ get kind() {
102514
+ return "unpack";
102515
+ }
102516
+ toOp() {
102517
+ return { kind: "unpack", from: this.from, ref: this.ref };
102518
+ }
102519
+ extractDependencies(taskName) {
102520
+ return [{ from: this.from.config.name, to: taskName, type: "unpack" }];
102521
+ }
102522
+ extractRefs() {
102523
+ return [{ type: "bundle", ref: this.ref }];
102524
+ }
102525
+ cacheNormalize(context) {
102526
+ context.addDependency(this.from.config.name);
102527
+ return {
102528
+ kind: this.kind,
102529
+ from: this.from.config.name,
102530
+ name: this.ref.name,
102531
+ patterns: this.ref.patterns
102532
+ };
102533
+ }
102534
+ cachePlaceholder(_context) {
102535
+ return;
102536
+ }
102537
+ }
102538
+ var pack = (ref) => new PackOperation(ref);
102539
+ var unpack = (from, ref) => new UnpackOperation(from, ref);
102540
+
102541
+ // ../core/dist/ops/output.js
102239
102542
  var out2 = {
102240
102543
  ...out,
102241
102544
  bundle: (name) => createBundleRef(name)
102242
102545
  };
102243
- var emit = (ref, value) => ({
102244
- kind: "emit",
102245
- ref,
102246
- value
102247
- });
102248
- var use = (from, ref) => ({
102249
- kind: "use",
102250
- from,
102251
- ref
102252
- });
102253
- // ../cli/dist/ops/summary.js
102546
+ var emit = (ref, value) => new EmitOperation(ref, value);
102547
+ var use = (from, ref) => new UseOperation(from, ref);
102548
+
102549
+ class EmitOperation {
102550
+ ref;
102551
+ value;
102552
+ constructor(ref, value) {
102553
+ this.ref = ref;
102554
+ this.value = value;
102555
+ }
102556
+ get kind() {
102557
+ return "emit";
102558
+ }
102559
+ toOp() {
102560
+ return { kind: "emit", ref: this.ref, value: this.value };
102561
+ }
102562
+ analysisPlaceholder() {
102563
+ return this.value;
102564
+ }
102565
+ extractDependencies(_taskName) {
102566
+ return [];
102567
+ }
102568
+ extractSecrets() {
102569
+ return [];
102570
+ }
102571
+ extractRefs() {
102572
+ return [];
102573
+ }
102574
+ cacheNormalize(_context) {
102575
+ return { kind: this.kind, ref: this.ref.name, value: this.value };
102576
+ }
102577
+ cachePlaceholder(_context) {
102578
+ return this.value;
102579
+ }
102580
+ }
102581
+
102582
+ class UseOperation {
102583
+ from;
102584
+ ref;
102585
+ constructor(from, ref) {
102586
+ this.from = from;
102587
+ this.ref = ref;
102588
+ }
102589
+ get kind() {
102590
+ return "use";
102591
+ }
102592
+ toOp() {
102593
+ return { kind: "use", from: this.from, ref: this.ref };
102594
+ }
102595
+ analysisPlaceholder() {
102596
+ return this.ref.parse("");
102597
+ }
102598
+ extractDependencies(taskName) {
102599
+ return [{ from: this.from.config.name, to: taskName, type: "use" }];
102600
+ }
102601
+ extractSecrets() {
102602
+ return [];
102603
+ }
102604
+ extractRefs() {
102605
+ return [{ type: "value", ref: this.ref }];
102606
+ }
102607
+ cacheNormalize(context) {
102608
+ context.addDependency(this.from.config.name);
102609
+ return { kind: this.kind, from: this.from.config.name, ref: this.ref.name };
102610
+ }
102611
+ cachePlaceholder(context) {
102612
+ return context.isPrimary ? this.ref.parse("") : undefined;
102613
+ }
102614
+ }
102615
+ // ../core/dist/ops/summary.js
102616
+ class SummaryOperation extends OperationBase {
102617
+ format;
102618
+ content;
102619
+ constructor(format, content) {
102620
+ super();
102621
+ this.format = format;
102622
+ this.content = content;
102623
+ }
102624
+ get kind() {
102625
+ return "summary";
102626
+ }
102627
+ toOp() {
102628
+ return { kind: "summary", format: this.format, content: this.content };
102629
+ }
102630
+ cacheNormalize(_context) {
102631
+ return { kind: this.kind, format: this.format, content: this.content };
102632
+ }
102633
+ }
102254
102634
  var summary2 = {
102255
- md: (content) => ({
102256
- kind: "summary",
102257
- format: "md",
102258
- content
102259
- })
102635
+ md: (content) => new SummaryOperation("md", content)
102260
102636
  };
102261
- // ../cli/dist/ops/annotate.js
102262
- var createAnnotation = (level) => (message, location) => ({
102263
- kind: "annotate",
102264
- level,
102265
- message,
102266
- ...location ? { location } : {}
102267
- });
102637
+ // ../core/dist/ops/annotate.js
102638
+ class AnnotateOperation extends OperationBase {
102639
+ level;
102640
+ message;
102641
+ location;
102642
+ constructor(level, message, location) {
102643
+ super();
102644
+ this.level = level;
102645
+ this.message = message;
102646
+ if (location)
102647
+ this.location = location;
102648
+ }
102649
+ get kind() {
102650
+ return "annotate";
102651
+ }
102652
+ toOp() {
102653
+ return {
102654
+ kind: "annotate",
102655
+ level: this.level,
102656
+ message: this.message,
102657
+ ...this.location ? { location: this.location } : {}
102658
+ };
102659
+ }
102660
+ cacheNormalize(_context) {
102661
+ return { kind: this.kind, level: this.level, message: this.message };
102662
+ }
102663
+ }
102664
+ var createAnnotation = (level) => (message, location) => new AnnotateOperation(level, message, location);
102268
102665
  var annotate = {
102269
102666
  error: createAnnotation("error"),
102270
102667
  warning: createAnnotation("warning"),
102271
102668
  info: createAnnotation("info")
102272
102669
  };
102273
- // ../cli/dist/ops/report.js
102670
+ // ../core/dist/ops/report.js
102671
+ class ReportOperation extends OperationBase {
102672
+ reportType;
102673
+ path;
102674
+ constructor(reportType, path) {
102675
+ super();
102676
+ this.reportType = reportType;
102677
+ this.path = path;
102678
+ }
102679
+ get kind() {
102680
+ return "report";
102681
+ }
102682
+ toOp() {
102683
+ return { kind: "report", reportType: this.reportType, path: this.path };
102684
+ }
102685
+ cacheNormalize(_context) {
102686
+ return { kind: this.kind, reportType: this.reportType, path: this.path };
102687
+ }
102688
+ }
102274
102689
  var report = {
102275
- junit: (path) => ({
102276
- kind: "report",
102277
- reportType: "junit",
102278
- path
102279
- }),
102280
- coverage: (path) => ({
102281
- kind: "report",
102282
- reportType: "coverage",
102283
- path
102284
- })
102690
+ junit: (path) => new ReportOperation("junit", path),
102691
+ coverage: (path) => new ReportOperation("coverage", path)
102285
102692
  };
102286
- // ../cli/dist/ops/bind.js
102287
- var bind = (serviceInstance, alias) => {
102288
- const op = { kind: "bind-service", service: serviceInstance };
102289
- if (alias)
102290
- op.alias = alias;
102291
- return op;
102292
- };
102293
- // ../cli/dist/ops/types.js
102294
- var isSecretRef = (value) => value.kind === "secret";
102295
- var isParamRef = (value) => value.kind === "param";
102296
- var isValueRef = (value) => value.kind === "value";
102297
- // ../cli/dist/engine/cache/coordinator.js
102693
+ // ../core/dist/ops/bind.js
102694
+ class BindServiceOperation extends OperationBase {
102695
+ service;
102696
+ alias;
102697
+ constructor(service2, alias) {
102698
+ super();
102699
+ this.service = service2;
102700
+ if (alias)
102701
+ this.alias = alias;
102702
+ }
102703
+ get kind() {
102704
+ return "bind-service";
102705
+ }
102706
+ toOp() {
102707
+ const op = { kind: "bind-service", service: this.service };
102708
+ if (this.alias)
102709
+ op.alias = this.alias;
102710
+ return op;
102711
+ }
102712
+ cacheNormalize(_context) {
102713
+ return { kind: this.kind, service: this.service, alias: this.alias ?? null };
102714
+ }
102715
+ }
102716
+ var bind = (serviceInstance, alias) => new BindServiceOperation(serviceInstance, alias);
102717
+ // ../core/dist/engine/cache/coordinator.js
102298
102718
  import { join as join4 } from "node:path";
102299
102719
 
102300
- // ../cli/dist/engine/executor/file-system.js
102720
+ // ../core/dist/engine/executor/file-system.js
102301
102721
  var import_picomatch = __toESM(require_picomatch2(), 1);
102302
102722
  import { mkdir, readFile as readFile3, readdir, stat, writeFile } from "node:fs/promises";
102303
102723
  import { dirname, join, relative } from "node:path";
@@ -102345,7 +102765,7 @@ var writeFiles = async (basePath, files) => {
102345
102765
  }));
102346
102766
  };
102347
102767
 
102348
- // ../cli/dist/engine/cache/serialize.js
102768
+ // ../core/dist/engine/cache/serialize.js
102349
102769
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
102350
102770
  var stableStringify = (value) => {
102351
102771
  if (value === null || value === undefined)
@@ -102365,7 +102785,7 @@ var stableStringify = (value) => {
102365
102785
  return JSON.stringify(String(value));
102366
102786
  };
102367
102787
 
102368
- // ../cli/dist/engine/cache/analyze.js
102788
+ // ../core/dist/engine/cache/analyze.js
102369
102789
  var createPlaceholderTracker = () => {
102370
102790
  let touched = false;
102371
102791
  const placeholder = new Proxy(() => {
@@ -102390,219 +102810,40 @@ var createPlaceholderTracker = () => {
102390
102810
  used: () => touched
102391
102811
  };
102392
102812
  };
102393
- var toOp2 = (value) => {
102394
- if (value instanceof Object && "op" in value) {
102395
- const maybeOp = value.op;
102396
- if (maybeOp && typeof maybeOp === "object" && "kind" in maybeOp) {
102397
- return maybeOp;
102398
- }
102813
+ var toOperation2 = (value) => {
102814
+ if (!isOperation(value)) {
102815
+ throw new Error("Step yielded a non-operation value");
102399
102816
  }
102400
102817
  return value;
102401
102818
  };
102402
- var normalizeTemplatePart = (part) => {
102403
- if (part.type === "text" || part.type === "interpolated") {
102404
- return { type: part.type, value: part.value };
102819
+ var createCacheContext = (ctx, analysis, tracker, resultValue) => ({
102820
+ addCommandSignature: (signature) => {
102821
+ analysis.commandSignatures.push(signature);
102822
+ },
102823
+ addDependency: (name) => {
102824
+ analysis.dependencies.add(name);
102825
+ },
102826
+ addSecret: (name) => {
102827
+ analysis.secrets.add(name);
102828
+ },
102829
+ addParam: (name) => {
102830
+ analysis.params.add(name);
102831
+ },
102832
+ analyzeNested: (compute, nestedResultValue) => analyzeGenerator(compute(ctx), ctx, analysis, tracker, nestedResultValue),
102833
+ resultValue,
102834
+ placeholder: {
102835
+ value: tracker.value,
102836
+ isPrimary: tracker.value !== undefined
102405
102837
  }
102406
- if (part.type === "secret") {
102407
- return { type: part.type, name: part.name };
102408
- }
102409
- return { type: part.type, name: part.ref.name };
102410
- };
102411
- var commandSignature = (template) => {
102412
- const raw = template.map((part) => {
102413
- if (part.type === "text")
102414
- return part.value;
102415
- if (part.type === "interpolated")
102416
- return String(part.value);
102417
- if (part.type === "secret")
102418
- return `<secret:${part.name}>`;
102419
- if (part.type === "param")
102420
- return `<param:${part.ref.name}>`;
102421
- return `<value:${part.ref.name}>`;
102422
- }).join("");
102423
- return raw.replace(/\s+/g, " ").trim();
102424
- };
102425
- var collectFromTemplate = (template, secrets, params) => {
102426
- for (const part of template) {
102427
- if (part.type === "secret")
102428
- secrets.add(part.name);
102429
- if (part.type === "param")
102430
- params.add(part.ref.name);
102431
- }
102432
- };
102433
- var collectEnvValue = (value, secrets, params) => {
102434
- if (typeof value === "string" || typeof value === "number")
102435
- return;
102436
- if (isSecretRef(value))
102437
- secrets.add(value.name);
102438
- if (isParamRef(value))
102439
- params.add(value.name);
102440
- };
102441
- var normalizeEnvValue = (value) => {
102442
- if (typeof value === "string" || typeof value === "number")
102443
- return value;
102444
- if (isSecretRef(value))
102445
- return { kind: "secret", name: value.name };
102446
- if (isParamRef(value))
102447
- return { kind: "param", name: value.name };
102448
- if (isValueRef(value))
102449
- return { kind: "value", name: value.name };
102450
- return String(value);
102451
- };
102452
- var normalizeOp = (op, ctx, analysis, tracker, resultValue) => {
102453
- switch (op.kind) {
102454
- case "command": {
102455
- const commandOp = op;
102456
- analysis.commandSignatures.push(commandSignature(commandOp.template));
102457
- collectFromTemplate(commandOp.template, analysis.secrets, analysis.params);
102458
- return {
102459
- kind: op.kind,
102460
- capture: commandOp.capture,
102461
- cache: commandOp.cache ?? null,
102462
- template: commandOp.template.map(normalizeTemplatePart)
102463
- };
102464
- }
102465
- case "http": {
102466
- const httpOp = op;
102467
- collectFromTemplate(httpOp.url, analysis.secrets, analysis.params);
102468
- for (const header of httpOp.headers) {
102469
- collectFromTemplate(header.value, analysis.secrets, analysis.params);
102470
- }
102471
- if (httpOp.body) {
102472
- collectFromTemplate(httpOp.body, analysis.secrets, analysis.params);
102473
- }
102474
- return {
102475
- kind: op.kind,
102476
- method: httpOp.method,
102477
- url: httpOp.url.map(normalizeTemplatePart),
102478
- headers: httpOp.headers.map((header) => ({
102479
- name: header.name,
102480
- value: header.value.map(normalizeTemplatePart)
102481
- })),
102482
- body: httpOp.body ? httpOp.body.map(normalizeTemplatePart) : null,
102483
- bodyPath: httpOp.bodyPath ?? null
102484
- };
102485
- }
102486
- case "emit": {
102487
- const emitOp = op;
102488
- return { kind: op.kind, ref: emitOp.ref.name, value: emitOp.value };
102489
- }
102490
- case "use": {
102491
- const useOp = op;
102492
- analysis.dependencies.add(useOp.from.config.name);
102493
- return { kind: op.kind, from: useOp.from.config.name, ref: useOp.ref.name };
102494
- }
102495
- case "pack": {
102496
- const packOp = op;
102497
- return { kind: op.kind, name: packOp.ref.name, patterns: packOp.ref.patterns };
102498
- }
102499
- case "unpack": {
102500
- const unpackOp = op;
102501
- analysis.dependencies.add(unpackOp.from.config.name);
102502
- return {
102503
- kind: op.kind,
102504
- from: unpackOp.from.config.name,
102505
- name: unpackOp.ref.name,
102506
- patterns: unpackOp.ref.patterns
102507
- };
102508
- }
102509
- case "env": {
102510
- const envOp = op;
102511
- collectEnvValue(envOp.value, analysis.secrets, analysis.params);
102512
- return { kind: op.kind, name: envOp.name, value: normalizeEnvValue(envOp.value) };
102513
- }
102514
- case "summary": {
102515
- const summaryOp = op;
102516
- return { kind: op.kind, format: summaryOp.format, content: summaryOp.content };
102517
- }
102518
- case "artifact-upload": {
102519
- const uploadOp = op;
102520
- return {
102521
- kind: op.kind,
102522
- name: uploadOp.name,
102523
- patterns: uploadOp.patterns,
102524
- when: uploadOp.when
102525
- };
102526
- }
102527
- case "artifact-download": {
102528
- const downloadOp = op;
102529
- return { kind: op.kind, name: downloadOp.name, destination: downloadOp.destination };
102530
- }
102531
- case "annotate": {
102532
- const annotateOp = op;
102533
- return { kind: op.kind, level: annotateOp.level, message: annotateOp.message };
102534
- }
102535
- case "report": {
102536
- const reportOp = op;
102537
- return { kind: op.kind, reportType: reportOp.reportType, path: reportOp.path };
102538
- }
102539
- case "bind-service": {
102540
- const bindOp = op;
102541
- return { kind: op.kind, service: bindOp.service, alias: bindOp.alias ?? null };
102542
- }
102543
- case "cache": {
102544
- const cacheOp = op;
102545
- return { kind: op.kind, name: cacheOp.name, paths: cacheOp.paths, key: cacheOp.key ?? null };
102546
- }
102547
- case "cache-or": {
102548
- const cacheOrOp = op;
102549
- const computeOps = analyzeGenerator(cacheOrOp.compute(ctx), ctx, analysis, tracker, resultValue);
102550
- return {
102551
- kind: op.kind,
102552
- name: cacheOrOp.name,
102553
- paths: cacheOrOp.paths,
102554
- key: cacheOrOp.key ?? null,
102555
- compute: computeOps
102556
- };
102557
- }
102558
- default:
102559
- return { kind: op.kind };
102560
- }
102561
- };
102562
- var placeholderForCommand = (op, isPrimary) => {
102563
- if (!isPrimary)
102564
- return;
102565
- if (op.capture === "ok")
102566
- return true;
102567
- if (op.capture === "code")
102568
- return 0;
102569
- return "";
102570
- };
102571
- var placeholderForHttp = (isPrimary) => isPrimary ? { status: 200, ok: true, headers: {}, body: "" } : undefined;
102572
- var placeholderForUse = (op, isPrimary) => isPrimary ? op.ref.parse("") : undefined;
102573
- var placeholderForEnv = (op, isPrimary) => {
102574
- if (typeof op.value === "string" || typeof op.value === "number") {
102575
- return op.value;
102576
- }
102577
- return isPrimary ? "" : undefined;
102578
- };
102579
- var placeholderForOp2 = (op, tracker) => {
102580
- const isPrimary = tracker.value !== undefined;
102581
- switch (op.kind) {
102582
- case "command":
102583
- return placeholderForCommand(op, isPrimary);
102584
- case "http":
102585
- return placeholderForHttp(isPrimary);
102586
- case "use":
102587
- return placeholderForUse(op, isPrimary);
102588
- case "emit":
102589
- return op.value;
102590
- case "env":
102591
- return placeholderForEnv(op, isPrimary);
102592
- case "pack":
102593
- case "unpack":
102594
- return;
102595
- default:
102596
- return tracker.value;
102597
- }
102598
- };
102838
+ });
102599
102839
  var analyzeGenerator = (iterator, ctx, analysis, tracker, resultValue) => {
102600
102840
  const ops = [];
102601
102841
  let cursor = iterator.next();
102602
102842
  while (!cursor.done) {
102603
- const op = toOp2(cursor.value);
102604
- ops.push(normalizeOp(op, ctx, analysis, tracker, resultValue));
102605
- const placeholder = placeholderForOp2(op, tracker);
102843
+ const operation = toOperation2(cursor.value);
102844
+ const cacheContext = createCacheContext(ctx, analysis, tracker, resultValue);
102845
+ ops.push(operation.cacheNormalize(cacheContext));
102846
+ const placeholder = operation.cachePlaceholder(cacheContext.placeholder);
102606
102847
  cursor = iterator.next(placeholder);
102607
102848
  }
102608
102849
  return ops;
@@ -102646,7 +102887,7 @@ var analyzeTaskSteps = (task2, workspace) => {
102646
102887
  return primary.analysis;
102647
102888
  };
102648
102889
 
102649
- // ../cli/dist/engine/cache/hasher.js
102890
+ // ../core/dist/engine/cache/hasher.js
102650
102891
  import { createHash as createHash2 } from "node:crypto";
102651
102892
  import { readFile as readFile4 } from "node:fs/promises";
102652
102893
  import { join as join2, relative as relative2 } from "node:path";
@@ -102695,7 +102936,7 @@ var hashNamedValues = (values) => {
102695
102936
  return toHex(overall);
102696
102937
  };
102697
102938
 
102698
- // ../cli/dist/engine/cache/inference.js
102939
+ // ../core/dist/engine/cache/inference.js
102699
102940
  var trimCommand = (command) => command.replace(/\s+/g, " ").trim();
102700
102941
  var inferInputsFromCommand = (command) => {
102701
102942
  const normalized = trimCommand(command.toLowerCase());
@@ -102739,7 +102980,7 @@ var inferOutputsFromCommand = (command) => {
102739
102980
  return [];
102740
102981
  };
102741
102982
 
102742
- // ../cli/dist/engine/cache/store.js
102983
+ // ../core/dist/engine/cache/store.js
102743
102984
  import { existsSync } from "node:fs";
102744
102985
  import { mkdir as mkdir2, readFile as readFile5, readdir as readdir2, rm, stat as stat2, writeFile as writeFile2 } from "node:fs/promises";
102745
102986
  import { join as join3 } from "node:path";
@@ -102945,7 +103186,7 @@ class CacheStore {
102945
103186
  }
102946
103187
  }
102947
103188
 
102948
- // ../cli/dist/engine/cache/coordinator.js
103189
+ // ../core/dist/engine/cache/coordinator.js
102949
103190
  class CacheCoordinator {
102950
103191
  workspace;
102951
103192
  settings;
@@ -103506,16 +103747,10 @@ class CacheCoordinator {
103506
103747
  }
103507
103748
  }
103508
103749
  toOp(value) {
103509
- if (value instanceof CommandBuilder) {
103510
- return value.op;
103750
+ if (!isOperation(value)) {
103751
+ throw new Error("Step yielded a non-operation value");
103511
103752
  }
103512
- if (value && typeof value === "object" && "op" in value) {
103513
- const maybeOp = value.op;
103514
- if (maybeOp && typeof maybeOp === "object" && "kind" in maybeOp) {
103515
- return maybeOp;
103516
- }
103517
- }
103518
- return value;
103753
+ return value.toOp();
103519
103754
  }
103520
103755
  async computeCacheOpDecision(op, context, task2) {
103521
103756
  if (op.paths.length === 0) {
@@ -103690,7 +103925,7 @@ class CacheCoordinator {
103690
103925
  }
103691
103926
  }
103692
103927
 
103693
- // ../cli/dist/engine/handlers/annotate-handler.js
103928
+ // ../core/dist/engine/handlers/annotate-handler.js
103694
103929
  class AnnotateHandler {
103695
103930
  kind = "annotate";
103696
103931
  async execute(op, context, _state) {
@@ -103699,7 +103934,7 @@ class AnnotateHandler {
103699
103934
  }
103700
103935
  }
103701
103936
 
103702
- // ../cli/dist/engine/handlers/artifact-download-handler.js
103937
+ // ../core/dist/engine/handlers/artifact-download-handler.js
103703
103938
  import { existsSync as existsSync2 } from "node:fs";
103704
103939
  import { mkdir as mkdir3, readFile as readFile6 } from "node:fs/promises";
103705
103940
  import { join as join5, relative as relative3 } from "node:path";
@@ -103735,7 +103970,7 @@ class ArtifactDownloadHandler {
103735
103970
  }
103736
103971
  }
103737
103972
 
103738
- // ../cli/dist/engine/handlers/artifact-upload-handler.js
103973
+ // ../core/dist/engine/handlers/artifact-upload-handler.js
103739
103974
  import { join as join6 } from "node:path";
103740
103975
  class ArtifactUploadHandler {
103741
103976
  kind = "artifact-upload";
@@ -103760,7 +103995,7 @@ class ArtifactUploadHandler {
103760
103995
  }
103761
103996
  }
103762
103997
 
103763
- // ../cli/dist/engine/handlers/bind-service-handler.js
103998
+ // ../core/dist/engine/handlers/bind-service-handler.js
103764
103999
  class BindServiceHandler {
103765
104000
  kind = "bind-service";
103766
104001
  async execute(op, context, _state) {
@@ -103769,7 +104004,7 @@ class BindServiceHandler {
103769
104004
  }
103770
104005
  }
103771
104006
 
103772
- // ../cli/dist/engine/handlers/cache-mount-handler.js
104007
+ // ../core/dist/engine/handlers/cache-mount-handler.js
103773
104008
  import { existsSync as existsSync3 } from "node:fs";
103774
104009
  import { mkdir as mkdir4 } from "node:fs/promises";
103775
104010
  import { join as join7 } from "node:path";
@@ -103787,7 +104022,7 @@ class CacheMountHandler {
103787
104022
  }
103788
104023
  }
103789
104024
 
103790
- // ../cli/dist/engine/handlers/command-handler.js
104025
+ // ../core/dist/engine/handlers/command-handler.js
103791
104026
  class CommandHandler {
103792
104027
  runner;
103793
104028
  kind = "command";
@@ -103799,7 +104034,7 @@ class CommandHandler {
103799
104034
  }
103800
104035
  }
103801
104036
 
103802
- // ../cli/dist/engine/handlers/emit-handler.js
104037
+ // ../core/dist/engine/handlers/emit-handler.js
103803
104038
  class EmitHandler {
103804
104039
  kind = "emit";
103805
104040
  async execute(op, _context, state) {
@@ -103808,7 +104043,7 @@ class EmitHandler {
103808
104043
  }
103809
104044
  }
103810
104045
 
103811
- // ../cli/dist/engine/handlers/env-handler.js
104046
+ // ../core/dist/engine/handlers/env-handler.js
103812
104047
  class EnvHandler {
103813
104048
  kind = "env";
103814
104049
  async execute(op, context, _state) {
@@ -103818,7 +104053,7 @@ class EnvHandler {
103818
104053
  }
103819
104054
  }
103820
104055
 
103821
- // ../cli/dist/engine/handlers/http-handler.js
104056
+ // ../core/dist/engine/handlers/http-handler.js
103822
104057
  import { readFile as readFile7 } from "node:fs/promises";
103823
104058
  import { isAbsolute, resolve } from "node:path";
103824
104059
  class HttpHandler {
@@ -103885,7 +104120,7 @@ class HttpHandler {
103885
104120
  }
103886
104121
  }
103887
104122
 
103888
- // ../cli/dist/engine/handlers/pack-handler.js
104123
+ // ../core/dist/engine/handlers/pack-handler.js
103889
104124
  class PackHandler {
103890
104125
  kind = "pack";
103891
104126
  async execute(op, context, state) {
@@ -103898,7 +104133,7 @@ class PackHandler {
103898
104133
  }
103899
104134
  }
103900
104135
 
103901
- // ../cli/dist/engine/handlers/registry.js
104136
+ // ../core/dist/engine/handlers/registry.js
103902
104137
  class OpHandlerRegistry {
103903
104138
  handlers = new Map;
103904
104139
  register(handler) {
@@ -103913,7 +104148,7 @@ class OpHandlerRegistry {
103913
104148
  }
103914
104149
  }
103915
104150
 
103916
- // ../cli/dist/engine/handlers/report-handler.js
104151
+ // ../core/dist/engine/handlers/report-handler.js
103917
104152
  class ReportHandler {
103918
104153
  kind = "report";
103919
104154
  async execute(op, context, _state) {
@@ -103927,7 +104162,7 @@ class ReportHandler {
103927
104162
  }
103928
104163
  }
103929
104164
 
103930
- // ../cli/dist/engine/handlers/summary-handler.js
104165
+ // ../core/dist/engine/handlers/summary-handler.js
103931
104166
  class SummaryHandler {
103932
104167
  kind = "summary";
103933
104168
  async execute(op, _context, state) {
@@ -103936,7 +104171,7 @@ class SummaryHandler {
103936
104171
  }
103937
104172
  }
103938
104173
 
103939
- // ../cli/dist/engine/handlers/unpack-handler.js
104174
+ // ../core/dist/engine/handlers/unpack-handler.js
103940
104175
  class UnpackHandler {
103941
104176
  executeTask;
103942
104177
  states;
@@ -103959,7 +104194,7 @@ class UnpackHandler {
103959
104194
  }
103960
104195
  }
103961
104196
 
103962
- // ../cli/dist/engine/handlers/use-handler.js
104197
+ // ../core/dist/engine/handlers/use-handler.js
103963
104198
  class UseHandler {
103964
104199
  executeTask;
103965
104200
  states;
@@ -103981,7 +104216,7 @@ class UseHandler {
103981
104216
  }
103982
104217
  }
103983
104218
 
103984
- // ../cli/dist/engine/executor/command-runner.js
104219
+ // ../core/dist/engine/executor/command-runner.js
103985
104220
  import { spawn } from "node:child_process";
103986
104221
  class CommandRunner {
103987
104222
  workspace;
@@ -104115,7 +104350,7 @@ class CommandRunner {
104115
104350
  }
104116
104351
  }
104117
104352
 
104118
- // ../cli/dist/engine/executor/value-resolver.js
104353
+ // ../core/dist/engine/executor/value-resolver.js
104119
104354
  class ValueResolver {
104120
104355
  states;
104121
104356
  params;
@@ -104178,7 +104413,7 @@ class ValueResolver {
104178
104413
  }
104179
104414
  }
104180
104415
 
104181
- // ../cli/dist/engine/executor/plan-runner.js
104416
+ // ../core/dist/engine/executor/plan-runner.js
104182
104417
  var mergeEnv = (...sources) => {
104183
104418
  const merged = {};
104184
104419
  for (const source of sources) {
@@ -104440,16 +104675,10 @@ class PlanRunner {
104440
104675
  return String(error2);
104441
104676
  }
104442
104677
  toOp(value) {
104443
- if (value instanceof CommandBuilder) {
104444
- return value.op;
104678
+ if (!isOperation(value)) {
104679
+ throw new Error("Step yielded a non-operation value");
104445
104680
  }
104446
- if (value && typeof value === "object" && "op" in value) {
104447
- const maybeOp = value.op;
104448
- if (maybeOp && typeof maybeOp === "object" && "kind" in maybeOp) {
104449
- return maybeOp;
104450
- }
104451
- }
104452
- return value;
104681
+ return value.toOp();
104453
104682
  }
104454
104683
  async executeOp(op, task2, step2, env2, state) {
104455
104684
  if (op.kind === "artifact-upload") {
@@ -104582,7 +104811,7 @@ class PlanRunner {
104582
104811
  }
104583
104812
  }
104584
104813
 
104585
- // ../cli/dist/engine/executor/executor.js
104814
+ // ../core/dist/engine/executor/executor.js
104586
104815
  var defaultLogger = {
104587
104816
  info: (message) => console.log(message),
104588
104817
  error: (message) => console.error(message),
@@ -104800,15 +105029,15 @@ Available plans: ${available}`);
104800
105029
  async function run() {
104801
105030
  const startTime = Date.now();
104802
105031
  try {
104803
- const plan2 = core6.getInput("plan", { required: true });
104804
- const file = core6.getInput("file") || ".kitsi/pipeline.ts";
104805
- const task2 = core6.getInput("task") || undefined;
104806
- const timeout = core6.getInput("timeout") || "30m";
104807
- const failFast = core6.getBooleanInput("fail-fast");
104808
- const workdirInput = core6.getInput("working-directory");
105032
+ const plan2 = core7.getInput("plan", { required: true });
105033
+ const file = core7.getInput("file") || ".kitsi/pipeline.ts";
105034
+ const task2 = core7.getInput("task") || undefined;
105035
+ const timeout = core7.getInput("timeout") || "30m";
105036
+ const failFast = core7.getBooleanInput("fail-fast");
105037
+ const workdirInput = core7.getInput("working-directory");
104809
105038
  const defaultWorkdir = process.env.GITHUB_WORKSPACE || ".";
104810
105039
  const workdir = !workdirInput || workdirInput === "." ? defaultWorkdir : workdirInput;
104811
- core6.info(`Running Kitsi plan: ${plan2}`);
105040
+ core7.info(`Running Kitsi plan: ${plan2}`);
104812
105041
  const capabilities = new GitHubCapabilities;
104813
105042
  const groups = new GroupManager;
104814
105043
  const result = await runPipeline({
@@ -104827,16 +105056,16 @@ async function run() {
104827
105056
  });
104828
105057
  const duration = (Date.now() - startTime) / 1000;
104829
105058
  const status = Object.values(result.tasks).some((t) => t.status === "failed") ? "failed" : "success";
104830
- core6.setOutput("status", status);
104831
- core6.setOutput("duration", duration.toFixed(1));
104832
- core6.setOutput("tasks", JSON.stringify(result.tasks));
105059
+ core7.setOutput("status", status);
105060
+ core7.setOutput("duration", duration.toFixed(1));
105061
+ core7.setOutput("tasks", JSON.stringify(result.tasks));
104833
105062
  await capabilities.summary.writePlanSummary(plan2, result, duration);
104834
105063
  if (status === "failed") {
104835
105064
  for (const [name, taskResult] of Object.entries(result.tasks)) {
104836
105065
  if (taskResult.status !== "failed")
104837
105066
  continue;
104838
105067
  if (taskResult.error) {
104839
- core6.error(`Task "${name}" failed: ${taskResult.error.message}`);
105068
+ core7.error(`Task "${name}" failed: ${taskResult.error.message}`);
104840
105069
  const cause = taskResult.error.cause;
104841
105070
  if (cause) {
104842
105071
  const formatted = typeof cause === "string" ? cause : cause instanceof Error ? cause.message : (() => {
@@ -104849,23 +105078,23 @@ async function run() {
104849
105078
  for (const line of formatted.split(`
104850
105079
  `)) {
104851
105080
  if (line.trim().length > 0) {
104852
- core6.error(line);
105081
+ core7.error(line);
104853
105082
  }
104854
105083
  }
104855
105084
  }
104856
105085
  } else {
104857
- core6.error(`Task "${name}" failed`);
105086
+ core7.error(`Task "${name}" failed`);
104858
105087
  }
104859
105088
  }
104860
105089
  }
104861
105090
  if (status === "success") {
104862
- core6.info(`Plan "${plan2}" completed successfully in ${duration.toFixed(1)}s`);
105091
+ core7.info(`Plan "${plan2}" completed successfully in ${duration.toFixed(1)}s`);
104863
105092
  } else {
104864
- core6.setFailed(`Plan "${plan2}" failed`);
105093
+ core7.setFailed(`Plan "${plan2}" failed`);
104865
105094
  }
104866
105095
  } catch (error3) {
104867
105096
  const message = error3 instanceof Error ? error3.message : String(error3);
104868
- core6.setFailed(message);
105097
+ core7.setFailed(message);
104869
105098
  }
104870
105099
  }
104871
105100
  run();