@agentrix/agentrix-run 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -20,6 +20,9 @@ function usage() {
20
20
  " --sha <sha>",
21
21
  " --base-ref <ref>",
22
22
  " --head-ref <ref>",
23
+ " --head-sha <sha>",
24
+ " --checkout-ref <ref>",
25
+ " --checkout-sha <sha>",
23
26
  " --branch-name <name>",
24
27
  " --pr-number <number>",
25
28
  " --issue-number <number>",
@@ -218,6 +221,18 @@ function parseArgs(argv) {
218
221
  options.headRef = requireValue(argv, index, arg);
219
222
  index += 1;
220
223
  break;
224
+ case "--head-sha":
225
+ options.headSha = requireValue(argv, index, arg);
226
+ index += 1;
227
+ break;
228
+ case "--checkout-ref":
229
+ options.checkoutRef = requireValue(argv, index, arg);
230
+ index += 1;
231
+ break;
232
+ case "--checkout-sha":
233
+ options.checkoutSha = requireValue(argv, index, arg);
234
+ index += 1;
235
+ break;
221
236
  case "--branch-name":
222
237
  options.branchName = requireValue(argv, index, arg);
223
238
  index += 1;
@@ -325,6 +340,15 @@ function optionalPositiveInt(value) {
325
340
  const parsed = Number.parseInt(value, 10);
326
341
  return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
327
342
  }
343
+ function firstEnv(...names) {
344
+ for (const name of names) {
345
+ const value = process.env[name];
346
+ if (value) {
347
+ return value;
348
+ }
349
+ }
350
+ return void 0;
351
+ }
328
352
  function readBooleanEnv(name) {
329
353
  const value = process.env[name]?.trim().toLowerCase();
330
354
  return value === "1" || value === "true" || value === "yes" || value === "on";
@@ -367,6 +391,7 @@ function detectGithub() {
367
391
  sha: process.env.GITHUB_SHA,
368
392
  baseRef: process.env.GITHUB_BASE_REF || getNestedString(payload, "pull_request", "base", "ref"),
369
393
  headRef: process.env.GITHUB_HEAD_REF || getNestedString(payload, "pull_request", "head", "ref"),
394
+ headSha: getNestedString(payload, "pull_request", "head", "sha"),
370
395
  prNumber: getNestedNumber(payload, "pull_request", "number"),
371
396
  issueNumber: getNestedNumber(payload, "issue", "number")
372
397
  },
@@ -391,19 +416,24 @@ function detectGitlab() {
391
416
  name: repository.name
392
417
  },
393
418
  git: {
394
- ref: process.env.CI_COMMIT_REF_NAME,
395
- sha: process.env.CI_COMMIT_SHA,
396
- baseRef: process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME,
397
- headRef: process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME,
398
- prNumber: optionalPositiveInt(process.env.CI_MERGE_REQUEST_IID),
399
- issueNumber: optionalPositiveInt(process.env.AGENTRIX_ISSUE_NUMBER)
419
+ ref: firstEnv("GITLAB_BRIDGE_REF_NAME", "CI_COMMIT_REF_NAME"),
420
+ sha: firstEnv(
421
+ "GITLAB_BRIDGE_HEAD_SHA",
422
+ "GITLAB_BRIDGE_WORKFLOW_RUN_SHA",
423
+ "CI_COMMIT_SHA"
424
+ ),
425
+ baseRef: firstEnv("GITLAB_BRIDGE_BASE_REF", "CI_MERGE_REQUEST_TARGET_BRANCH_NAME"),
426
+ headRef: firstEnv("GITLAB_BRIDGE_HEAD_REF", "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"),
427
+ headSha: firstEnv("GITLAB_BRIDGE_HEAD_SHA", "CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"),
428
+ prNumber: optionalPositiveInt(firstEnv("GITLAB_BRIDGE_PR_NUMBER", "CI_MERGE_REQUEST_IID")),
429
+ issueNumber: optionalPositiveInt(firstEnv("GITLAB_BRIDGE_ISSUE_NUMBER", "AGENTRIX_ISSUE_NUMBER"))
400
430
  },
401
431
  context: {
402
432
  ciProvider: "gitlab_ci",
403
- eventName: process.env.AGENTRIX_EVENT_NAME || process.env.CI_PIPELINE_SOURCE,
404
- eventAction: process.env.AGENTRIX_EVENT_ACTION,
433
+ eventName: firstEnv("GITLAB_BRIDGE_EVENT_NAME", "CI_PIPELINE_SOURCE"),
434
+ eventAction: process.env.GITLAB_BRIDGE_EVENT_ACTION,
405
435
  jobUrl: process.env.CI_JOB_URL,
406
- runUrl: process.env.CI_PIPELINE_URL
436
+ runUrl: firstEnv("GITLAB_BRIDGE_WORKFLOW_RUN_URL", "CI_PIPELINE_URL")
407
437
  }
408
438
  };
409
439
  }
@@ -439,6 +469,9 @@ function buildRequest(options, detected) {
439
469
  sha: options.sha ?? detected.git?.sha,
440
470
  baseRef: options.baseRef ?? detected.git?.baseRef,
441
471
  headRef: options.headRef ?? detected.git?.headRef,
472
+ headSha: options.headSha ?? detected.git?.headSha,
473
+ checkoutRef: options.checkoutRef ?? detected.git?.checkoutRef,
474
+ checkoutSha: options.checkoutSha ?? detected.git?.checkoutSha,
442
475
  branchName: options.branchName || process.env.AGENTRIX_BRANCH_NAME,
443
476
  prNumber: options.prNumber ?? detected.git?.prNumber,
444
477
  issueNumber: options.issueNumber ?? detected.git?.issueNumber
@@ -449,10 +482,10 @@ function buildRequest(options, detected) {
449
482
  },
450
483
  context: detected.context?.ciProvider ? {
451
484
  ciProvider: detected.context.ciProvider,
452
- eventName: process.env.AGENTRIX_EVENT_NAME || detected.context.eventName,
453
- eventAction: process.env.AGENTRIX_EVENT_ACTION || detected.context.eventAction,
485
+ eventName: detected.context.eventName,
486
+ eventAction: detected.context.eventAction,
454
487
  jobUrl: process.env.AGENTRIX_JOB_URL || detected.context.jobUrl,
455
- runUrl: process.env.AGENTRIX_RUN_URL || detected.context.runUrl,
488
+ runUrl: detected.context.runUrl,
456
489
  payload: detected.context.payload
457
490
  } : void 0,
458
491
  metadata: Object.keys(options.metadata).length > 0 ? options.metadata : void 0
package/dist/index.mjs CHANGED
@@ -18,6 +18,9 @@ function usage() {
18
18
  " --sha <sha>",
19
19
  " --base-ref <ref>",
20
20
  " --head-ref <ref>",
21
+ " --head-sha <sha>",
22
+ " --checkout-ref <ref>",
23
+ " --checkout-sha <sha>",
21
24
  " --branch-name <name>",
22
25
  " --pr-number <number>",
23
26
  " --issue-number <number>",
@@ -216,6 +219,18 @@ function parseArgs(argv) {
216
219
  options.headRef = requireValue(argv, index, arg);
217
220
  index += 1;
218
221
  break;
222
+ case "--head-sha":
223
+ options.headSha = requireValue(argv, index, arg);
224
+ index += 1;
225
+ break;
226
+ case "--checkout-ref":
227
+ options.checkoutRef = requireValue(argv, index, arg);
228
+ index += 1;
229
+ break;
230
+ case "--checkout-sha":
231
+ options.checkoutSha = requireValue(argv, index, arg);
232
+ index += 1;
233
+ break;
219
234
  case "--branch-name":
220
235
  options.branchName = requireValue(argv, index, arg);
221
236
  index += 1;
@@ -323,6 +338,15 @@ function optionalPositiveInt(value) {
323
338
  const parsed = Number.parseInt(value, 10);
324
339
  return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
325
340
  }
341
+ function firstEnv(...names) {
342
+ for (const name of names) {
343
+ const value = process.env[name];
344
+ if (value) {
345
+ return value;
346
+ }
347
+ }
348
+ return void 0;
349
+ }
326
350
  function readBooleanEnv(name) {
327
351
  const value = process.env[name]?.trim().toLowerCase();
328
352
  return value === "1" || value === "true" || value === "yes" || value === "on";
@@ -365,6 +389,7 @@ function detectGithub() {
365
389
  sha: process.env.GITHUB_SHA,
366
390
  baseRef: process.env.GITHUB_BASE_REF || getNestedString(payload, "pull_request", "base", "ref"),
367
391
  headRef: process.env.GITHUB_HEAD_REF || getNestedString(payload, "pull_request", "head", "ref"),
392
+ headSha: getNestedString(payload, "pull_request", "head", "sha"),
368
393
  prNumber: getNestedNumber(payload, "pull_request", "number"),
369
394
  issueNumber: getNestedNumber(payload, "issue", "number")
370
395
  },
@@ -389,19 +414,24 @@ function detectGitlab() {
389
414
  name: repository.name
390
415
  },
391
416
  git: {
392
- ref: process.env.CI_COMMIT_REF_NAME,
393
- sha: process.env.CI_COMMIT_SHA,
394
- baseRef: process.env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME,
395
- headRef: process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME,
396
- prNumber: optionalPositiveInt(process.env.CI_MERGE_REQUEST_IID),
397
- issueNumber: optionalPositiveInt(process.env.AGENTRIX_ISSUE_NUMBER)
417
+ ref: firstEnv("GITLAB_BRIDGE_REF_NAME", "CI_COMMIT_REF_NAME"),
418
+ sha: firstEnv(
419
+ "GITLAB_BRIDGE_HEAD_SHA",
420
+ "GITLAB_BRIDGE_WORKFLOW_RUN_SHA",
421
+ "CI_COMMIT_SHA"
422
+ ),
423
+ baseRef: firstEnv("GITLAB_BRIDGE_BASE_REF", "CI_MERGE_REQUEST_TARGET_BRANCH_NAME"),
424
+ headRef: firstEnv("GITLAB_BRIDGE_HEAD_REF", "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"),
425
+ headSha: firstEnv("GITLAB_BRIDGE_HEAD_SHA", "CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"),
426
+ prNumber: optionalPositiveInt(firstEnv("GITLAB_BRIDGE_PR_NUMBER", "CI_MERGE_REQUEST_IID")),
427
+ issueNumber: optionalPositiveInt(firstEnv("GITLAB_BRIDGE_ISSUE_NUMBER", "AGENTRIX_ISSUE_NUMBER"))
398
428
  },
399
429
  context: {
400
430
  ciProvider: "gitlab_ci",
401
- eventName: process.env.AGENTRIX_EVENT_NAME || process.env.CI_PIPELINE_SOURCE,
402
- eventAction: process.env.AGENTRIX_EVENT_ACTION,
431
+ eventName: firstEnv("GITLAB_BRIDGE_EVENT_NAME", "CI_PIPELINE_SOURCE"),
432
+ eventAction: process.env.GITLAB_BRIDGE_EVENT_ACTION,
403
433
  jobUrl: process.env.CI_JOB_URL,
404
- runUrl: process.env.CI_PIPELINE_URL
434
+ runUrl: firstEnv("GITLAB_BRIDGE_WORKFLOW_RUN_URL", "CI_PIPELINE_URL")
405
435
  }
406
436
  };
407
437
  }
@@ -437,6 +467,9 @@ function buildRequest(options, detected) {
437
467
  sha: options.sha ?? detected.git?.sha,
438
468
  baseRef: options.baseRef ?? detected.git?.baseRef,
439
469
  headRef: options.headRef ?? detected.git?.headRef,
470
+ headSha: options.headSha ?? detected.git?.headSha,
471
+ checkoutRef: options.checkoutRef ?? detected.git?.checkoutRef,
472
+ checkoutSha: options.checkoutSha ?? detected.git?.checkoutSha,
440
473
  branchName: options.branchName || process.env.AGENTRIX_BRANCH_NAME,
441
474
  prNumber: options.prNumber ?? detected.git?.prNumber,
442
475
  issueNumber: options.issueNumber ?? detected.git?.issueNumber
@@ -447,10 +480,10 @@ function buildRequest(options, detected) {
447
480
  },
448
481
  context: detected.context?.ciProvider ? {
449
482
  ciProvider: detected.context.ciProvider,
450
- eventName: process.env.AGENTRIX_EVENT_NAME || detected.context.eventName,
451
- eventAction: process.env.AGENTRIX_EVENT_ACTION || detected.context.eventAction,
483
+ eventName: detected.context.eventName,
484
+ eventAction: detected.context.eventAction,
452
485
  jobUrl: process.env.AGENTRIX_JOB_URL || detected.context.jobUrl,
453
- runUrl: process.env.AGENTRIX_RUN_URL || detected.context.runUrl,
486
+ runUrl: detected.context.runUrl,
454
487
  payload: detected.context.payload
455
488
  } : void 0,
456
489
  metadata: Object.keys(options.metadata).length > 0 ? options.metadata : void 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrix/agentrix-run",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Native CI submit-and-observe wrapper for Agentrix",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "prepublishOnly": "yarn build"
33
33
  },
34
34
  "dependencies": {
35
- "@agentrix/shared": "^2.40.0"
35
+ "@agentrix/shared": "^2.41.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": ">=20",