hacklab 26.922.7 → 26.926.1

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 +9 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // src/index.ts
4
4
  import { parseArgs } from "node:util";
5
5
  // package.json
6
- var version = "26.922.7";
6
+ var version = "26.926.1";
7
7
 
8
8
  // src/auth.ts
9
9
  import { spawn } from "node:child_process";
@@ -141,7 +141,7 @@ import { text } from "node:stream/consumers";
141
141
 
142
142
  // src/origin.ts
143
143
  function cliOrigin() {
144
- return "https://beta.hacklab.so";
144
+ return "https://hacklab.so";
145
145
  }
146
146
 
147
147
  // src/state.ts
@@ -182,6 +182,7 @@ function sinceDate(from) {
182
182
  const local = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
183
183
  return local.toISOString().slice(0, 10);
184
184
  }
185
+ var describeType = (value) => value === undefined ? "missing" : value === null ? "null" : Array.isArray(value) ? "an array" : typeof value === "object" ? "an object" : `a ${typeof value}`;
185
186
  async function collectUsage(since) {
186
187
  const require2 = createRequire(import.meta.url);
187
188
  const args = [require2.resolve("ccusage/src/cli.js"), "session", "--json"];
@@ -197,8 +198,12 @@ async function collectUsage(since) {
197
198
  } catch {
198
199
  throw new Error("ccusage returned invalid JSON. Nothing synced.");
199
200
  }
200
- if (!Array.isArray(report?.session) || !report.totals) {
201
- throw new Error("Unexpected ccusage report. Nothing synced.");
201
+ const totals = report?.totals;
202
+ if (!Array.isArray(report?.session)) {
203
+ throw new Error(`Unexpected ccusage report: session is ${describeType(report?.session)}, expected an array. Nothing synced.`);
204
+ }
205
+ if (typeof totals !== "object" || totals === null || Array.isArray(totals)) {
206
+ throw new Error(`Unexpected ccusage report: totals is ${describeType(totals)}, expected an object. Nothing synced.`);
202
207
  }
203
208
  if (Buffer.byteLength(body) > 20 * 1024 * 1024)
204
209
  throw new Error("Usage report exceeds 20 MB. Nothing synced.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hacklab",
3
- "version": "26.922.7",
3
+ "version": "26.926.1",
4
4
  "description": "CLI for syncing coding agent usage to Hacklab",
5
5
  "bin": {
6
6
  "hacklab": "dist/index.js"