@shipd-ai/cli 0.2.0 → 0.3.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/runs.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ export declare const RUN_ARTIFACT_FILES: {
2
+ readonly trajectory: "trajectory.json";
3
+ readonly workspaceDiff: "workspace-diff.patch";
4
+ readonly solutionPatch: "solution-patch.patch";
5
+ readonly testLog: "test-log.txt";
6
+ readonly junitBaselineXml: "junit-baseline.xml";
7
+ readonly junitNewXml: "junit-new.xml";
8
+ readonly evalResult: "eval-result.json";
9
+ };
10
+ export type RunArtifactKey = keyof typeof RUN_ARTIFACT_FILES;
11
+ export declare const RUN_ARTIFACT_KEYS: RunArtifactKey[];
12
+ export declare function parseArtifactKeys(artifact: string | undefined, all: boolean | undefined): RunArtifactKey[];
13
+ export type AgentRunRow = {
14
+ id: string;
15
+ jobId?: string;
16
+ taskAgentType?: string;
17
+ taskAgentCodename?: string;
18
+ status?: string;
19
+ verdict?: string;
20
+ fault?: string;
21
+ runPhase?: string;
22
+ label?: string;
23
+ batchName?: string;
24
+ hinted?: boolean;
25
+ legacy?: boolean;
26
+ stale?: boolean;
27
+ scratched?: boolean;
28
+ createdAt?: number;
29
+ completedAt?: number;
30
+ currentStep?: string;
31
+ error?: string;
32
+ };
33
+ export declare function runLabel(run: AgentRunRow): string;
34
+ export declare function selectRuns(runs: AgentRunRow[], runId: string | undefined, all: boolean | undefined): AgentRunRow[];
35
+ export declare function artifactPath(dir: string, runId: string, key: RunArtifactKey): string;
36
+ export declare function downloadArtifact(url: string, dest: string, fetchImpl?: typeof fetch): Promise<number>;
package/dist/runs.js ADDED
@@ -0,0 +1,59 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { assertTrustedConvexUrl, isDevelopment } from "./backend.js";
4
+ import { RefusedError, UsageError } from "./errors.js";
5
+ export const RUN_ARTIFACT_FILES = {
6
+ trajectory: "trajectory.json",
7
+ workspaceDiff: "workspace-diff.patch",
8
+ solutionPatch: "solution-patch.patch",
9
+ testLog: "test-log.txt",
10
+ junitBaselineXml: "junit-baseline.xml",
11
+ junitNewXml: "junit-new.xml",
12
+ evalResult: "eval-result.json",
13
+ };
14
+ export const RUN_ARTIFACT_KEYS = Object.keys(RUN_ARTIFACT_FILES);
15
+ export function parseArtifactKeys(artifact, all) {
16
+ if (all && artifact)
17
+ throw new UsageError("Pass --artifact or --all-artifacts, not both.");
18
+ if (!artifact)
19
+ return [...RUN_ARTIFACT_KEYS];
20
+ const keys = artifact
21
+ .split(",")
22
+ .map((k) => k.trim())
23
+ .filter((k) => k.length > 0);
24
+ for (const key of keys) {
25
+ if (!(key in RUN_ARTIFACT_FILES)) {
26
+ throw new UsageError(`Unknown artifact "${key}". One of: ${RUN_ARTIFACT_KEYS.join(", ")} (or --all-artifacts).`);
27
+ }
28
+ }
29
+ return [...new Set(keys)];
30
+ }
31
+ export function runLabel(run) {
32
+ return run.taskAgentCodename ?? "run";
33
+ }
34
+ export function selectRuns(runs, runId, all) {
35
+ if (all && runId)
36
+ throw new UsageError("Pass --run or --all, not both.");
37
+ if (all)
38
+ return runs;
39
+ if (!runId)
40
+ throw new UsageError("Name a run with --run <runId>, or pass --all.");
41
+ const run = runs.find((r) => r.id === runId || r.jobId === runId);
42
+ if (!run)
43
+ throw new UsageError(`Run not found on this challenge's latest version: ${runId}`);
44
+ return [run];
45
+ }
46
+ export function artifactPath(dir, runId, key) {
47
+ return join(dir, runId, RUN_ARTIFACT_FILES[key]);
48
+ }
49
+ export async function downloadArtifact(url, dest, fetchImpl = fetch) {
50
+ assertTrustedConvexUrl(url, isDevelopment());
51
+ const response = await fetchImpl(url, { signal: AbortSignal.timeout(120_000) });
52
+ if (!response.ok) {
53
+ throw new RefusedError(`Download failed (${response.status}) for ${dest}`);
54
+ }
55
+ const bytes = new Uint8Array(await response.arrayBuffer());
56
+ mkdirSync(join(dest, ".."), { recursive: true });
57
+ writeFileSync(dest, bytes);
58
+ return bytes.byteLength;
59
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipd-ai/cli",
3
- "version": "0.2.0",
4
- "description": "Shipd CLI \u2014 your quest challenges and their checks (authors), ad-hoc quest checks on Harbor tasks or existing tasks (admins)",
3
+ "version": "0.3.0",
4
+ "description": "Shipd CLI \u2014 your quest challenges, their content, checks and agent runs (authors), ad-hoc quest checks on Harbor tasks or existing tasks (admins)",
5
5
  "type": "module",
6
6
  "homepage": "https://shipd.ai",
7
7
  "keywords": [