modelstat 0.0.13 → 0.0.15

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/cli.mjs CHANGED
@@ -4484,7 +4484,22 @@ var init_schemas = __esm({
4484
4484
  });
4485
4485
 
4486
4486
  // ../../packages/core/src/ids.ts
4487
- import { ulid } from "ulid";
4487
+ function ulid(seedTime) {
4488
+ const t = seedTime ?? Date.now();
4489
+ let timeStr = "";
4490
+ let ts = t;
4491
+ for (let i = 9; i >= 0; i--) {
4492
+ timeStr = ULID_ALPHABET[ts % 32] + timeStr;
4493
+ ts = Math.floor(ts / 32);
4494
+ }
4495
+ const bytes = new Uint8Array(16);
4496
+ globalThis.crypto.getRandomValues(bytes);
4497
+ let randStr = "";
4498
+ for (let i = 0; i < 16; i++) {
4499
+ randStr += ULID_ALPHABET[bytes[i] % 32];
4500
+ }
4501
+ return timeStr + randStr;
4502
+ }
4488
4503
  function sourceEventId(deviceId, sourceOrFilePath, byteOffsetMaybe) {
4489
4504
  let key;
4490
4505
  if (typeof sourceOrFilePath === "string") {
@@ -4513,10 +4528,11 @@ function segmentId(sessionId, startedAtMs, endedAtMs, sourceEventIds) {
4513
4528
  }
4514
4529
  return `seg_${h.toString(36)}`;
4515
4530
  }
4516
- var batchId;
4531
+ var ULID_ALPHABET, batchId;
4517
4532
  var init_ids = __esm({
4518
4533
  "../../packages/core/src/ids.ts"() {
4519
4534
  "use strict";
4535
+ ULID_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
4520
4536
  batchId = () => ulid();
4521
4537
  }
4522
4538
  });
@@ -7748,7 +7764,7 @@ async function reportDiscovery(report) {
7748
7764
  }
7749
7765
  }
7750
7766
  async function fetchDeviceViewByClaim(claimCode) {
7751
- const res = await request(`${state.apiUrl}/v1/d/${encodeURIComponent(claimCode)}`, {
7767
+ const res = await request(`${state.apiUrl}/v1/device/${encodeURIComponent(claimCode)}`, {
7752
7768
  method: "GET"
7753
7769
  });
7754
7770
  if (res.statusCode === 404) return null;
@@ -7759,7 +7775,7 @@ async function fetchDeviceViewByClaim(claimCode) {
7759
7775
  }
7760
7776
  async function fetchDeviceViewJobsByClaim(claimCode) {
7761
7777
  const res = await request(
7762
- `${state.apiUrl}/v1/d/${encodeURIComponent(claimCode)}/jobs`,
7778
+ `${state.apiUrl}/v1/device/${encodeURIComponent(claimCode)}/jobs`,
7763
7779
  { method: "GET" }
7764
7780
  );
7765
7781
  if (res.statusCode === 404) return null;
@@ -7770,7 +7786,7 @@ async function fetchDeviceViewJobsByClaim(claimCode) {
7770
7786
  }
7771
7787
  async function fetchDeviceViewLedgerByClaim(claimCode) {
7772
7788
  const res = await request(
7773
- `${state.apiUrl}/v1/d/${encodeURIComponent(claimCode)}/ledger`,
7789
+ `${state.apiUrl}/v1/device/${encodeURIComponent(claimCode)}/ledger`,
7774
7790
  { method: "GET" }
7775
7791
  );
7776
7792
  if (res.statusCode === 404) return null;
@@ -8991,17 +9007,6 @@ async function cmdConnect(opts) {
8991
9007
  process.stdout.write(` \x1B[33m\u26A0\x1B[0m ${msg}
8992
9008
  `);
8993
9009
  };
8994
- const hasLegacyBearer = !!state.bearer && !state.bearer.startsWith("ds_live_");
8995
- const hasLegacyClaim = !!state.claimUrl && state.claimUrl.includes("/c/");
8996
- if (hasLegacyBearer || hasLegacyClaim) {
8997
- step("Legacy state detected from an older version \u2014 wiping");
8998
- state.setBearer(null);
8999
- state.setDeviceId(null);
9000
- state.setDeviceUuid(null);
9001
- state.setClaimCode(null);
9002
- state.setClaimUrl(null);
9003
- ok("clean slate");
9004
- }
9005
9010
  if (!state.deviceUuid || !state.bearer || !state.deviceId) {
9006
9011
  step("Registering this device with modelstat.ai");
9007
9012
  await cmdSelfRegister();
@@ -9010,8 +9015,8 @@ async function cmdConnect(opts) {
9010
9015
  ok(`device ${state.deviceId}`);
9011
9016
  }
9012
9017
  const claimCode = state.claimCode ?? "(unknown)";
9013
- const claimUrl = state.claimUrl ?? `https://modelstat.ai/d/${claimCode}`;
9014
- const agentUrl = `https://modelstat.ai/da/${claimCode}`;
9018
+ const claimUrl = state.claimUrl ?? `https://modelstat.ai/device/${claimCode}`;
9019
+ const agentUrl = `https://modelstat.ai/device/${claimCode}/agent`;
9015
9020
  emitEvent(opts, "registered", {
9016
9021
  device_uuid: state.deviceUuid,
9017
9022
  device_id: state.deviceId,