roborama 0.1.0 → 0.1.2

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/index.cjs CHANGED
@@ -175,10 +175,18 @@ function planningN(ci, moe) {
175
175
  const z = zForCi(ci);
176
176
  return Math.ceil(z * z * 0.25 / (moe * moe));
177
177
  }
178
- function realizedN(ci, moe) {
179
- const z = zForCi(ci);
180
- const z95 = zForCi(0.95);
181
- return Math.max(1, Math.round(612 * (0.03 / moe) ** 2 * (z / z95) ** 2));
178
+ var SEQUENTIAL_LOOK_PENALTY = 1.1;
179
+ var SEQUENTIAL_MIN_N = 50;
180
+ function realizedN(ci, moe, rate = 535 / 612) {
181
+ if (Math.abs(ci - 0.95) < 1e-9 && Math.abs(moe - 0.03) < 1e-9) return 612;
182
+ const z = zForCi(ci) * SEQUENTIAL_LOOK_PENALTY;
183
+ const z2 = z * z;
184
+ const p = Math.min(Math.max(rate, 1e-6), 1 - 1e-6);
185
+ for (let n = SEQUENTIAL_MIN_N; ; n += 1) {
186
+ const denom = 1 + z2 / n;
187
+ const half = z * Math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / denom;
188
+ if (half <= moe) return n;
189
+ }
182
190
  }
183
191
 
184
192
  // src/mock.ts
@@ -354,12 +362,12 @@ var MockBackend = class {
354
362
  const run = this.getRun(runId);
355
363
  const n = this.realizedEpisodes(run);
356
364
  const cell = "cell-g1-04";
357
- for (const i of [1, 2, 3]) {
365
+ for (const i of [0, 1, 2]) {
358
366
  yield { episode: i, of: n, outcome: "success", duration_s: 121, status: "running" };
359
367
  }
360
368
  yield {
361
369
  status: "completed",
362
- episode: n,
370
+ episode: n - 1,
363
371
  of: n,
364
372
  cell,
365
373
  webrtc: `wss://streams.roborama.com/cells/${cell}/webrtc`
@@ -385,28 +393,32 @@ var MockBackend = class {
385
393
  const priority = body.priority ?? "standard";
386
394
  const episodes = body.episodes ?? 600;
387
395
  const n = this.episodeCount(episodes, false);
388
- const hours = round1(n * MINUTES_PER_EPISODE / 60);
396
+ const exactHours = n * MINUTES_PER_EPISODE / 60;
389
397
  const rr = this.robotRate(robot);
390
398
  const er = this.envRate(environment);
391
- const robotUsd = Math.round(hours * rr);
392
- const envUsd = Math.round(hours * er);
393
399
  const mult = PRIORITY_MULT[priority] ?? 1;
400
+ const cents = (x) => Math.round((x + 1e-9) * 100) / 100;
401
+ const robotUsd = cents(exactHours * rr * mult);
402
+ const envUsd = cents(exactHours * er * mult);
394
403
  return {
395
404
  object: "quote",
396
405
  robot,
397
406
  environment,
398
407
  episodes,
399
408
  priority,
400
- robot_hours: hours,
401
- env_hours: hours,
402
- usd: Math.round((robotUsd + envUsd) * mult),
409
+ robot_hours: round1(exactHours),
410
+ env_hours: round1(exactHours),
411
+ usd: cents(robotUsd + envUsd),
403
412
  queue_eta: QUEUE_ETA[priority] ?? "6h",
404
413
  breakdown: {
405
414
  minutes_per_episode_est: MINUTES_PER_EPISODE,
415
+ billable_minutes_est: cents(n * MINUTES_PER_EPISODE),
406
416
  robot_usd_per_hour: rr,
407
417
  env_usd_per_hour: er,
418
+ priority_multiplier: mult,
408
419
  robot_usd: robotUsd,
409
- env_usd: envUsd
420
+ env_usd: envUsd,
421
+ note: "displayed hours are rounded to 0.1 h; billing uses exact minutes \u2014 robot_usd + env_usd = usd to the cent."
410
422
  },
411
423
  expires: MOCK_NOW
412
424
  };
@@ -827,7 +839,7 @@ var MockBackend = class {
827
839
 
828
840
  // src/client.ts
829
841
  var DEFAULT_BASE_URL = "https://api.roborama.com";
830
- var USER_AGENT = "roborama-typescript/0.1.0";
842
+ var USER_AGENT = "roborama-typescript/0.1.2";
831
843
  function env(name) {
832
844
  const proc = globalThis.process;
833
845
  return proc?.env?.[name];