@tryarcanist/cli 0.1.303 → 0.1.305

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 +144 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22995,13 +22995,24 @@ function parseEgressAllowlistSourceFile(content, key = EGRESS_ALLOWLIST_SOURCE_P
22995
22995
  }
22996
22996
 
22997
22997
  // ../../shared/github/repo-url.ts
22998
+ var REPO_SEGMENT_PATTERN = /^[A-Za-z0-9_.][A-Za-z0-9_.-]*$/;
22999
+ var MAX_REPO_SEGMENT_LENGTH = 100;
23000
+ function isValidGithubRepoSegment(value) {
23001
+ if (typeof value !== "string") return false;
23002
+ if (!value || value.length > MAX_REPO_SEGMENT_LENGTH) return false;
23003
+ if (value === "." || value === "..") return false;
23004
+ return REPO_SEGMENT_PATTERN.test(value);
23005
+ }
23006
+ function parseGithubRepoCoordinate(owner, repo) {
23007
+ return isValidGithubRepoSegment(owner) && isValidGithubRepoSegment(repo) ? { owner, repo } : null;
23008
+ }
22998
23009
  function parseGithubRepoFullName(value) {
22999
23010
  const shorthand = value.match(/^([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+)$/);
23000
- if (shorthand) return { owner: shorthand[1], repo: shorthand[2] };
23011
+ if (shorthand) return parseGithubRepoCoordinate(shorthand[1], shorthand[2]);
23001
23012
  const ssh = value.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/);
23002
- if (ssh) return { owner: ssh[1], repo: ssh[2] };
23013
+ if (ssh) return parseGithubRepoCoordinate(ssh[1], ssh[2]);
23003
23014
  const https = value.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
23004
- if (https) return { owner: https[1], repo: https[2] };
23015
+ if (https) return parseGithubRepoCoordinate(https[1], https[2]);
23005
23016
  return null;
23006
23017
  }
23007
23018
 
@@ -24487,6 +24498,103 @@ async function parseSandboxLayerSource(input) {
24487
24498
  };
24488
24499
  }
24489
24500
 
24501
+ // ../../shared/types/sandbox-layer-api.ts
24502
+ var sandboxLayerBuildActorSchema = external_exports.object({
24503
+ userId: external_exports.number(),
24504
+ login: external_exports.string().nullable(),
24505
+ name: external_exports.string().nullable()
24506
+ });
24507
+ var sandboxLayerFailureSummarySchema = external_exports.object({
24508
+ phase: external_exports.enum(["validation", "provider_build", "smoke", "runtime", "unknown"]),
24509
+ reason: external_exports.string(),
24510
+ command: external_exports.string().optional(),
24511
+ commandIndex: external_exports.number().optional(),
24512
+ exitCode: external_exports.number().optional(),
24513
+ stdoutPreview: external_exports.string().optional(),
24514
+ stderrPreview: external_exports.string().optional(),
24515
+ activeTemplateUnchanged: external_exports.boolean()
24516
+ });
24517
+ var baseSourceSchema = external_exports.enum(["registry", "env_fallback"]);
24518
+ var baseVersionQualitySchema = external_exports.enum(["versioned", "unversioned"]);
24519
+ var sandboxLayerBuildRequestSchema = external_exports.object({
24520
+ id: external_exports.string(),
24521
+ status: external_exports.string(),
24522
+ repo: external_exports.string(),
24523
+ sourceRepo: external_exports.string(),
24524
+ targetRepo: external_exports.string(),
24525
+ requestedRef: external_exports.string(),
24526
+ commitSha: external_exports.string(),
24527
+ manifestPath: external_exports.string(),
24528
+ layerPath: external_exports.string(),
24529
+ sourceContentHash: external_exports.string(),
24530
+ baseTemplateRef: external_exports.string(),
24531
+ baseVersion: external_exports.string(),
24532
+ baseSource: baseSourceSchema,
24533
+ baseVersionQuality: baseVersionQualitySchema,
24534
+ resourceProfileKey: external_exports.string(),
24535
+ promotionEligibility: external_exports.enum(["default_branch_head", "non_default_ref", "unknown"]),
24536
+ willPromote: external_exports.number().optional(),
24537
+ providerArtifactRef: external_exports.string().nullable().optional(),
24538
+ activeTemplateRef: external_exports.string().nullable().optional(),
24539
+ createdBy: sandboxLayerBuildActorSchema,
24540
+ failureSummary: sandboxLayerFailureSummarySchema.nullable().optional()
24541
+ });
24542
+ var sandboxLayerBuildHistoryItemSchema = external_exports.object({
24543
+ id: external_exports.string(),
24544
+ status: external_exports.string(),
24545
+ sourceRepo: external_exports.string(),
24546
+ commitSha: external_exports.string(),
24547
+ resourceProfileKey: external_exports.string(),
24548
+ templateId: external_exports.string().nullable(),
24549
+ baseTemplateRef: external_exports.string(),
24550
+ baseVersion: external_exports.string(),
24551
+ baseSource: baseSourceSchema,
24552
+ baseVersionQuality: baseVersionQualitySchema,
24553
+ createdBy: sandboxLayerBuildActorSchema,
24554
+ createdAt: external_exports.number(),
24555
+ startedAt: external_exports.number().nullable(),
24556
+ completedAt: external_exports.number().nullable(),
24557
+ smokeStatus: external_exports.enum(["passed", "failed"]).nullable(),
24558
+ failureSummary: sandboxLayerFailureSummarySchema.nullable()
24559
+ });
24560
+ var sandboxLayerBuildLogSchema = external_exports.object({
24561
+ id: external_exports.string(),
24562
+ build_id: external_exports.string(),
24563
+ sequence: external_exports.number(),
24564
+ message: external_exports.string(),
24565
+ created_at: external_exports.number()
24566
+ });
24567
+ var sandboxLayerBuildRequestResponseSchema = external_exports.object({
24568
+ ok: external_exports.boolean(),
24569
+ buildRequest: sandboxLayerBuildRequestSchema
24570
+ });
24571
+ var sandboxLayerBuildHistoryResponseSchema = external_exports.object({
24572
+ ok: external_exports.boolean(),
24573
+ builds: external_exports.array(sandboxLayerBuildHistoryItemSchema)
24574
+ });
24575
+ var sandboxLayerBuildLogsResponseSchema = external_exports.object({
24576
+ ok: external_exports.boolean(),
24577
+ logs: external_exports.array(sandboxLayerBuildLogSchema)
24578
+ });
24579
+ var sandboxLayerCliBuildRequestSchema = sandboxLayerBuildRequestSchema.partial().required({ id: true, status: true }).extend({ createdBy: sandboxLayerBuildActorSchema.nullable().optional() });
24580
+ var sandboxLayerCliBuildHistoryItemSchema = sandboxLayerBuildHistoryItemSchema.extend({
24581
+ startedAt: external_exports.number().nullable().optional(),
24582
+ failureSummary: sandboxLayerFailureSummarySchema.nullable().optional()
24583
+ });
24584
+ var sandboxLayerCliBuildLogSchema = sandboxLayerBuildLogSchema.partial().required({ sequence: true, message: true }).extend({ created_at: external_exports.union([external_exports.string(), external_exports.number()]).optional() });
24585
+ var sandboxLayerCliBuildRequestResponseSchema = external_exports.object({
24586
+ ok: external_exports.boolean(),
24587
+ buildRequest: sandboxLayerCliBuildRequestSchema
24588
+ });
24589
+ var sandboxLayerCliBuildHistoryResponseSchema = external_exports.object({
24590
+ ok: external_exports.boolean(),
24591
+ builds: external_exports.array(sandboxLayerCliBuildHistoryItemSchema)
24592
+ });
24593
+ var sandboxLayerCliBuildLogsResponseSchema = external_exports.object({
24594
+ ok: external_exports.boolean(),
24595
+ logs: external_exports.array(sandboxLayerCliBuildLogSchema)
24596
+ });
24597
+
24490
24598
  // src/commands/sandbox.ts
24491
24599
  var DEFAULT_MANIFEST_PATH = SANDBOX_LAYER_MANIFEST_PATH;
24492
24600
  var DEFAULT_POLL_INTERVAL_MS = 2500;
@@ -24636,9 +24744,11 @@ function buildLogsPath(businessId, buildId, options = {}) {
24636
24744
  )}/logs${suffix}`;
24637
24745
  }
24638
24746
  async function fetchAndEmitBuildLogs(config2, businessId, buildId, options) {
24639
- const logs = await apiFetch(
24640
- config2,
24641
- buildLogsPath(businessId, buildId, { afterSequence: options.afterSequence, limit: options.limit })
24747
+ const logs = sandboxLayerCliBuildLogsResponseSchema.parse(
24748
+ await apiFetch(
24749
+ config2,
24750
+ buildLogsPath(businessId, buildId, { afterSequence: options.afterSequence, limit: options.limit })
24751
+ )
24642
24752
  );
24643
24753
  if (logs.logs.length === 0) return { afterSequence: options.afterSequence, count: 0 };
24644
24754
  if (options.json) writeJson({ type: "logs", logs: logs.logs });
@@ -24664,9 +24774,11 @@ async function waitForBuild(config2, businessId, buildId, options) {
24664
24774
  const result = await fetchAndEmitBuildLogs(config2, businessId, buildId, { afterSequence, json: options.json });
24665
24775
  afterSequence = result.afterSequence;
24666
24776
  }
24667
- const status = await apiFetch(
24668
- config2,
24669
- `/api/businesses/${encodeURIComponent(businessId)}/sandbox-layer/build-requests/${encodeURIComponent(buildId)}`
24777
+ const status = sandboxLayerCliBuildRequestResponseSchema.parse(
24778
+ await apiFetch(
24779
+ config2,
24780
+ `/api/businesses/${encodeURIComponent(businessId)}/sandbox-layer/build-requests/${encodeURIComponent(buildId)}`
24781
+ )
24670
24782
  );
24671
24783
  if (TERMINAL_BUILD_STATUSES.has(status.buildRequest.status)) {
24672
24784
  if (options.follow) {
@@ -24786,20 +24898,22 @@ async function sandboxBuildCommand(sourceRepoArg, options = {}, command) {
24786
24898
  const ref = options.ref ?? currentRef();
24787
24899
  let payload;
24788
24900
  try {
24789
- payload = await apiFetch(
24790
- config2,
24791
- `/api/businesses/${encodeURIComponent(businessId)}/repos/${encodeURIComponent(sourceRepo.owner)}/${encodeURIComponent(
24792
- sourceRepo.repo
24793
- )}/sandbox-layer/build-requests`,
24794
- {
24795
- method: "POST",
24796
- headers: { "Idempotency-Key": options.idempotencyKey ?? randomIdempotencyKey() },
24797
- body: JSON.stringify({
24798
- ref,
24799
- manifestPath,
24800
- ...targetRepo ? { targetRepo: { owner: targetRepo.owner, name: targetRepo.repo } } : {}
24801
- })
24802
- }
24901
+ payload = sandboxLayerCliBuildRequestResponseSchema.parse(
24902
+ await apiFetch(
24903
+ config2,
24904
+ `/api/businesses/${encodeURIComponent(businessId)}/repos/${encodeURIComponent(sourceRepo.owner)}/${encodeURIComponent(
24905
+ sourceRepo.repo
24906
+ )}/sandbox-layer/build-requests`,
24907
+ {
24908
+ method: "POST",
24909
+ headers: { "Idempotency-Key": options.idempotencyKey ?? randomIdempotencyKey() },
24910
+ body: JSON.stringify({
24911
+ ref,
24912
+ manifestPath,
24913
+ ...targetRepo ? { targetRepo: { owner: targetRepo.owner, name: targetRepo.repo } } : {}
24914
+ })
24915
+ }
24916
+ )
24803
24917
  );
24804
24918
  } catch (err) {
24805
24919
  if (err instanceof ApiError && err.status === 409 && err.data?.serverCode === "duplicate_request") {
@@ -24859,9 +24973,11 @@ async function sandboxHistoryCommand(sourceRepoArg, options = {}, command) {
24859
24973
  }
24860
24974
  params.set("limit", String(limit));
24861
24975
  }
24862
- const payload = await apiFetch(
24863
- config2,
24864
- `/api/businesses/${encodeURIComponent(businessId)}/sandbox-layer/build-requests?${params.toString()}`
24976
+ const payload = sandboxLayerCliBuildHistoryResponseSchema.parse(
24977
+ await apiFetch(
24978
+ config2,
24979
+ `/api/businesses/${encodeURIComponent(businessId)}/sandbox-layer/build-requests?${params.toString()}`
24980
+ )
24865
24981
  );
24866
24982
  emit(command, options, payload, (historyPayload) => printBuildHistory(historyPayload.builds));
24867
24983
  }
@@ -24935,9 +25051,8 @@ async function sandboxLogsCommand(buildId, options = {}, command) {
24935
25051
  throw new CliError("user", "--limit must be a positive integer.");
24936
25052
  }
24937
25053
  for (; ; ) {
24938
- const payload = await apiFetch(
24939
- config2,
24940
- buildLogsPath(businessId, buildId, { afterSequence, limit })
25054
+ const payload = sandboxLayerCliBuildLogsResponseSchema.parse(
25055
+ await apiFetch(config2, buildLogsPath(businessId, buildId, { afterSequence, limit }))
24941
25056
  );
24942
25057
  if (payload.logs.length > 0 || !options.follow) {
24943
25058
  if (isJson(command, options)) writeJson(options.follow ? { type: "logs", logs: payload.logs } : payload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.303",
3
+ "version": "0.1.305",
4
4
  "description": "CLI for Arcanist - create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {