@leostera/evalkit 0.3.0 → 0.5.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +8 -7
  3. package/dist/cli.mjs +525 -72
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/dashboard/assets/index-D9NtA46z.css +2 -0
  6. package/dist/dashboard/assets/{index-CVd_Np_w.js → index-DrBwLKJD.js} +1 -1
  7. package/dist/dashboard/index.html +2 -2
  8. package/dist/files-C-U0-PWW.mjs +26 -0
  9. package/dist/files-C-U0-PWW.mjs.map +1 -0
  10. package/dist/index-db-HdZXelOS.d.mts +142 -0
  11. package/dist/index-db-HdZXelOS.d.mts.map +1 -0
  12. package/dist/index-db-vbqEGFaU.mjs +548 -0
  13. package/dist/index-db-vbqEGFaU.mjs.map +1 -0
  14. package/dist/{index-M5eRlMfd.d.mts → index-lOw0fmak.d.mts} +96 -9
  15. package/dist/index-lOw0fmak.d.mts.map +1 -0
  16. package/dist/index.d.mts +2 -2
  17. package/dist/index.mjs +2 -2
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/runner.d.mts +21 -3
  20. package/dist/runner.d.mts.map +1 -1
  21. package/dist/runner.mjs +1 -1
  22. package/dist/share-worker.d.mts +51 -0
  23. package/dist/share-worker.d.mts.map +1 -0
  24. package/dist/share-worker.mjs +73 -0
  25. package/dist/share-worker.mjs.map +1 -0
  26. package/dist/share.d.mts +116 -0
  27. package/dist/share.d.mts.map +1 -0
  28. package/dist/share.mjs +4 -0
  29. package/dist/{src-DrwwgaPn.mjs → src-ButXPY8P.mjs} +20 -5
  30. package/dist/src-ButXPY8P.mjs.map +1 -0
  31. package/dist/{src-DluldGKn.mjs → src-DoPs9Yug.mjs} +11 -7
  32. package/dist/src-DoPs9Yug.mjs.map +1 -0
  33. package/dist/src-DzZueFn3.mjs +98 -0
  34. package/dist/src-DzZueFn3.mjs.map +1 -0
  35. package/package.json +10 -1
  36. package/dist/dashboard/assets/index-CMr4aulR.css +0 -2
  37. package/dist/index-M5eRlMfd.d.mts.map +0 -1
  38. package/dist/src-DluldGKn.mjs.map +0 -1
  39. package/dist/src-DrwwgaPn.mjs.map +0 -1
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>EvalKit</title>
7
- <script type="module" crossorigin src="/assets/index-CVd_Np_w.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-CMr4aulR.css">
7
+ <script type="module" crossorigin src="/assets/index-DrBwLKJD.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-D9NtA46z.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
@@ -0,0 +1,26 @@
1
+ //#region ../share/src/files.ts
2
+ function r2Files(bucket) {
3
+ return {
4
+ async get(key) {
5
+ return (await bucket.get(key))?.body ?? null;
6
+ },
7
+ async put(key, data) {
8
+ await bucket.put(key, data);
9
+ },
10
+ async *list(prefix) {
11
+ let cursor;
12
+ do {
13
+ const page = await bucket.list({
14
+ prefix,
15
+ cursor
16
+ });
17
+ for (const object of page.objects) yield object.key;
18
+ cursor = page.truncated ? page.cursor : void 0;
19
+ } while (cursor);
20
+ }
21
+ };
22
+ }
23
+ //#endregion
24
+ export { r2Files as t };
25
+
26
+ //# sourceMappingURL=files-C-U0-PWW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files-C-U0-PWW.mjs","names":[],"sources":["../../share/src/files.ts"],"sourcesContent":["/** Where uploaded result files live: R2 in a Worker, a directory elsewhere. */\nexport type ShareFiles = {\n get(key: string): Promise<ReadableStream<Uint8Array> | Uint8Array | null>;\n put(key: string, data: Uint8Array | string): Promise<void>;\n /** Every key below `prefix`, in no particular order. */\n list(prefix: string): AsyncIterable<string>;\n};\n\n/** The subset of the Workers R2 binding used here. */\nexport type R2BucketLike = {\n get(key: string): Promise<{ body: ReadableStream<Uint8Array> } | null>;\n put(key: string, value: Uint8Array | string): Promise<unknown>;\n list(options: { prefix: string; cursor?: string }): Promise<{\n objects: { key: string }[];\n truncated: boolean;\n cursor?: string;\n }>;\n};\n\nexport function r2Files(bucket: R2BucketLike): ShareFiles {\n return {\n async get(key) {\n return (await bucket.get(key))?.body ?? null;\n },\n async put(key, data) {\n await bucket.put(key, data);\n },\n async *list(prefix) {\n let cursor: string | undefined;\n do {\n const page = await bucket.list({ prefix, cursor });\n for (const object of page.objects) yield object.key;\n cursor = page.truncated ? page.cursor : undefined;\n } while (cursor);\n },\n };\n}\n"],"mappings":";AAmBA,SAAgB,QAAQ,QAAkC;CACxD,OAAO;EACL,MAAM,IAAI,KAAK;GACb,QAAQ,MAAM,OAAO,IAAI,GAAG,EAAA,EAAI,QAAQ;EAC1C;EACA,MAAM,IAAI,KAAK,MAAM;GACnB,MAAM,OAAO,IAAI,KAAK,IAAI;EAC5B;EACA,OAAO,KAAK,QAAQ;GAClB,IAAI;GACJ,GAAG;IACD,MAAM,OAAO,MAAM,OAAO,KAAK;KAAE;KAAQ;IAAO,CAAC;IACjD,KAAK,MAAM,UAAU,KAAK,SAAS,MAAM,OAAO;IAChD,SAAS,KAAK,YAAY,KAAK,SAAS,KAAA;GAC1C,SAAS;EACX;CACF;AACF"}
@@ -0,0 +1,142 @@
1
+ //#region ../share/src/files.d.ts
2
+ /** Where uploaded result files live: R2 in a Worker, a directory elsewhere. */
3
+ type ShareFiles = {
4
+ get(key: string): Promise<ReadableStream<Uint8Array> | Uint8Array | null>;
5
+ put(key: string, data: Uint8Array | string): Promise<void>;
6
+ /** Every key below `prefix`, in no particular order. */
7
+ list(prefix: string): AsyncIterable<string>;
8
+ };
9
+ /** The subset of the Workers R2 binding used here. */
10
+ type R2BucketLike = {
11
+ get(key: string): Promise<{
12
+ body: ReadableStream<Uint8Array>;
13
+ } | null>;
14
+ put(key: string, value: Uint8Array | string): Promise<unknown>;
15
+ list(options: {
16
+ prefix: string;
17
+ cursor?: string;
18
+ }): Promise<{
19
+ objects: {
20
+ key: string;
21
+ }[];
22
+ truncated: boolean;
23
+ cursor?: string;
24
+ }>;
25
+ };
26
+ declare function r2Files(bucket: R2BucketLike): ShareFiles;
27
+ //#endregion
28
+ //#region ../share/src/bundle.d.ts
29
+ /**
30
+ * A run bundle: the snapshot files for one run, as one gzip-compressed body.
31
+ *
32
+ * "EKBUNDLE" (8 bytes) · header length (u32 BE) · header JSON · file bytes…
33
+ * header = { format: 1, files: [{ path, size }, …] }, bytes in that order.
34
+ *
35
+ * Both ends are EvalKit, so this is simpler than tar and has no path-length limit.
36
+ */
37
+ declare const BUNDLE_FORMAT = 1;
38
+ type BundleFile = {
39
+ path: string;
40
+ data: Uint8Array;
41
+ };
42
+ declare function encodeBundle(files: BundleFile[]): Promise<Uint8Array>;
43
+ /** Decode and check the framing; path rules are enforced by the caller. */
44
+ declare function decodeBundle(body: Uint8Array, limits: {
45
+ maxBytes: number;
46
+ }): Promise<BundleFile[]>;
47
+ //#endregion
48
+ //#region ../share/src/upload.d.ts
49
+ /** Finished runs only: a shared run's files are immutable once stored. */
50
+ type SharedRunStatus = 'passed' | 'failed' | 'errored';
51
+ type SharedSource = {
52
+ repo: string;
53
+ project: string;
54
+ commit: string;
55
+ ref?: string;
56
+ committedAt?: string;
57
+ dirty: boolean;
58
+ };
59
+ /** The fields of an uploaded run.json the server relies on. */
60
+ type SharedRun = {
61
+ id: string;
62
+ evalId: string;
63
+ suiteId?: string;
64
+ status: SharedRunStatus;
65
+ score?: number;
66
+ startedAt: string;
67
+ source: SharedSource;
68
+ /** Repository key (`repo` plus `/~project`), checked to be URL- and path-safe. */
69
+ repoKey: string;
70
+ /** The whole run.json object, served as-is in runs.json. */
71
+ summary: unknown;
72
+ };
73
+ /** A run bundle that passed every check; storing it cannot fail on its contents. */
74
+ type RunUpload = {
75
+ run: SharedRun;
76
+ runJson: Uint8Array;
77
+ catalog?: Uint8Array;
78
+ /** trials.json and trials/** files. */
79
+ files: BundleFile[];
80
+ };
81
+ declare function parseUpload(bundle: readonly BundleFile[]): RunUpload;
82
+ //#endregion
83
+ //#region ../share/src/index-db.d.ts
84
+ /**
85
+ * The share server's metadata index: repositories, commits and runs.
86
+ * R2 (or a directory) holds the files; this index answers "what exists" and
87
+ * every listing query. It is derived from stored run.json files and can be
88
+ * rebuilt from them (`POST /api/v1/reindex`).
89
+ */
90
+ /** Synchronous SQLite access, provided by Durable Object storage or bun:sqlite. */
91
+ type Sql = {
92
+ all<T>(query: string, ...params: SqlValue[]): T[];
93
+ run(query: string, ...params: SqlValue[]): void;
94
+ transaction<T>(work: () => T): T;
95
+ };
96
+ type SqlValue = string | number | null;
97
+ type RepoRow = {
98
+ key: string;
99
+ url: string;
100
+ project: string;
101
+ firstSeenAt: string;
102
+ lastUploadAt: string;
103
+ commits: number;
104
+ };
105
+ type CommitRow = {
106
+ commit: string;
107
+ ref?: string;
108
+ committedAt?: string;
109
+ firstSeenAt: string;
110
+ runs: number;
111
+ passed: number;
112
+ failed: number;
113
+ };
114
+ /** The operations the app needs; async so a Durable Object can sit behind it. */
115
+ type ShareIndex = {
116
+ hasRun(runId: string): Promise<boolean>;
117
+ recordRun(run: SharedRun): Promise<void>;
118
+ repos(): Promise<RepoRow[]>;
119
+ commits(repo: string): Promise<CommitRow[]>;
120
+ runs(repo: string, sha: string): Promise<unknown[]>;
121
+ /** Full SHA for a full SHA, a unique prefix (≥ 7), or a ref's latest commit. */
122
+ resolve(repo: string, ref: string): Promise<string | undefined>;
123
+ latest(repo: string): Promise<string | undefined>;
124
+ };
125
+ declare class ShareIndexDb {
126
+ private readonly sql;
127
+ private readonly now;
128
+ constructor(sql: Sql, now?: () => Date);
129
+ hasRun(runId: string): boolean;
130
+ /** Idempotent: recording an indexed run again changes nothing. */
131
+ recordRun(run: SharedRun): void;
132
+ repos(): RepoRow[];
133
+ commits(repo: string): CommitRow[];
134
+ runs(repo: string, sha: string): unknown[];
135
+ resolve(repo: string, ref: string): string | undefined;
136
+ latest(repo: string): string | undefined;
137
+ }
138
+ /** Adapt the synchronous index (bun:sqlite) to the app's async interface. */
139
+ declare function asyncIndex(db: ShareIndexDb): ShareIndex;
140
+ //#endregion
141
+ export { r2Files as _, Sql as a, SharedRun as c, BUNDLE_FORMAT as d, BundleFile as f, ShareFiles as g, R2BucketLike as h, ShareIndexDb as i, SharedRunStatus as l, encodeBundle as m, RepoRow as n, SqlValue as o, decodeBundle as p, ShareIndex as r, asyncIndex as s, CommitRow as t, parseUpload as u };
142
+ //# sourceMappingURL=index-db-HdZXelOS.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-db-HdZXelOS.d.mts","names":[],"sources":["../../share/src/files.ts","../../share/src/bundle.ts","../../share/src/upload.ts","../../share/src/index-db.ts"],"mappings":";;KACY;EACV,IAAI,cAAc,QAAQ,eAAe,cAAc;EACvD,IAAI,aAAa,MAAM,sBAAsB;;EAE7C,KAAK,iBAAiB;;;KAIZ;EACV,IAAI,cAAc;IAAU,MAAM,eAAe;;EACjD,IAAI,aAAa,OAAO,sBAAsB;EAC9C,KAAK;IAAW;IAAgB;MAAoB;IAClD;MAAW;;IACX;IACA;;;iBAIY,QAAQ,QAAQ,eAAe;;;;;;;;;;;cCXlC;KAGD;EAAe;EAAc,MAAM;;iBAUzB,aAAa,OAAO,eAAe,QAAQ;;iBA2B3C,aACpB,MAAM,YACN;EAAU;IACT,QAAQ;;;;KCtCC;KAEA;EACV;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,QAAQ;;EAER;;EAEA;;;KAUU;EACV,KAAK;EACL,SAAS;EACT,UAAU;;EAEV,OAAO;;iBAGO,YAAY,iBAAiB,eAAe;;;;;;;;;;KC5ChD;EACV,IAAI,GAAG,kBAAkB,QAAQ,aAAa;EAC9C,IAAI,kBAAkB,QAAQ;EAC9B,YAAY,GAAG,YAAY,IAAI;;KAErB;KAEA;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV,OAAO,gBAAgB;EACvB,UAAU,KAAK,YAAY;EAC3B,SAAS,QAAQ;EACjB,QAAQ,eAAe,QAAQ;EAC/B,KAAK,cAAc,cAAc;;EAEjC,QAAQ,cAAc,cAAc;EACpC,OAAO,eAAe;;cA4CX;mBAEQ;mBACA;EAFnB,YACmB,KAAK,KACL,YAAW;EAK9B,OAAO;;EAKP,UAAU,KAAK;EAwDf,SAAS;EAST,QAAQ,eAAe;EAevB,KAAK,cAAc;EAUnB,QAAQ,cAAc;EAiBtB,OAAO;;;iBASO,WAAW,IAAI,eAAe"}