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.js CHANGED
@@ -122,10 +122,18 @@ function planningN(ci, moe) {
122
122
  const z = zForCi(ci);
123
123
  return Math.ceil(z * z * 0.25 / (moe * moe));
124
124
  }
125
- function realizedN(ci, moe) {
126
- const z = zForCi(ci);
127
- const z95 = zForCi(0.95);
128
- return Math.max(1, Math.round(612 * (0.03 / moe) ** 2 * (z / z95) ** 2));
125
+ var SEQUENTIAL_LOOK_PENALTY = 1.1;
126
+ var SEQUENTIAL_MIN_N = 50;
127
+ function realizedN(ci, moe, rate = 535 / 612) {
128
+ if (Math.abs(ci - 0.95) < 1e-9 && Math.abs(moe - 0.03) < 1e-9) return 612;
129
+ const z = zForCi(ci) * SEQUENTIAL_LOOK_PENALTY;
130
+ const z2 = z * z;
131
+ const p = Math.min(Math.max(rate, 1e-6), 1 - 1e-6);
132
+ for (let n = SEQUENTIAL_MIN_N; ; n += 1) {
133
+ const denom = 1 + z2 / n;
134
+ const half = z * Math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / denom;
135
+ if (half <= moe) return n;
136
+ }
129
137
  }
130
138
 
131
139
  // src/mock.ts
@@ -301,12 +309,12 @@ var MockBackend = class {
301
309
  const run = this.getRun(runId);
302
310
  const n = this.realizedEpisodes(run);
303
311
  const cell = "cell-g1-04";
304
- for (const i of [1, 2, 3]) {
312
+ for (const i of [0, 1, 2]) {
305
313
  yield { episode: i, of: n, outcome: "success", duration_s: 121, status: "running" };
306
314
  }
307
315
  yield {
308
316
  status: "completed",
309
- episode: n,
317
+ episode: n - 1,
310
318
  of: n,
311
319
  cell,
312
320
  webrtc: `wss://streams.roborama.com/cells/${cell}/webrtc`
@@ -332,28 +340,32 @@ var MockBackend = class {
332
340
  const priority = body.priority ?? "standard";
333
341
  const episodes = body.episodes ?? 600;
334
342
  const n = this.episodeCount(episodes, false);
335
- const hours = round1(n * MINUTES_PER_EPISODE / 60);
343
+ const exactHours = n * MINUTES_PER_EPISODE / 60;
336
344
  const rr = this.robotRate(robot);
337
345
  const er = this.envRate(environment);
338
- const robotUsd = Math.round(hours * rr);
339
- const envUsd = Math.round(hours * er);
340
346
  const mult = PRIORITY_MULT[priority] ?? 1;
347
+ const cents = (x) => Math.round((x + 1e-9) * 100) / 100;
348
+ const robotUsd = cents(exactHours * rr * mult);
349
+ const envUsd = cents(exactHours * er * mult);
341
350
  return {
342
351
  object: "quote",
343
352
  robot,
344
353
  environment,
345
354
  episodes,
346
355
  priority,
347
- robot_hours: hours,
348
- env_hours: hours,
349
- usd: Math.round((robotUsd + envUsd) * mult),
356
+ robot_hours: round1(exactHours),
357
+ env_hours: round1(exactHours),
358
+ usd: cents(robotUsd + envUsd),
350
359
  queue_eta: QUEUE_ETA[priority] ?? "6h",
351
360
  breakdown: {
352
361
  minutes_per_episode_est: MINUTES_PER_EPISODE,
362
+ billable_minutes_est: cents(n * MINUTES_PER_EPISODE),
353
363
  robot_usd_per_hour: rr,
354
364
  env_usd_per_hour: er,
365
+ priority_multiplier: mult,
355
366
  robot_usd: robotUsd,
356
- env_usd: envUsd
367
+ env_usd: envUsd,
368
+ note: "displayed hours are rounded to 0.1 h; billing uses exact minutes \u2014 robot_usd + env_usd = usd to the cent."
357
369
  },
358
370
  expires: MOCK_NOW
359
371
  };
@@ -774,7 +786,7 @@ var MockBackend = class {
774
786
 
775
787
  // src/client.ts
776
788
  var DEFAULT_BASE_URL = "https://api.roborama.com";
777
- var USER_AGENT = "roborama-typescript/0.1.0";
789
+ var USER_AGENT = "roborama-typescript/0.1.2";
778
790
  function env(name) {
779
791
  const proc = globalThis.process;
780
792
  return proc?.env?.[name];