tori.host 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.
Files changed (2) hide show
  1. package/dist/cli.js +28 -6
  2. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -14532,7 +14532,7 @@ var AppSchema = external_exports.object({
14532
14532
  slug: external_exports.string(),
14533
14533
  name: external_exports.string(),
14534
14534
  region: RegionSchema,
14535
- /** Ops zone the app is scheduled into, e.g. 'eu-central-1'. */
14535
+ /** Ops zone the app is scheduled into, e.g. 'cz-prg-1'. */
14536
14536
  zone: external_exports.string(),
14537
14537
  status: AppStatusSchema,
14538
14538
  framework: FrameworkSchema,
@@ -14646,14 +14646,18 @@ var CliTokenSchema = external_exports.object({
14646
14646
  /** The row as it now appears in the console's token list. */
14647
14647
  apiToken: ApiTokenSchema
14648
14648
  });
14649
+ var CLI_AUTH_PENDING = "authorization_pending";
14650
+ var CLI_AUTH_SLOW_DOWN = "slow_down";
14649
14651
 
14650
14652
  // ../api/src/client.ts
14651
14653
  var ApiError = class extends Error {
14652
- constructor(status, message) {
14654
+ constructor(status, message, code) {
14653
14655
  super(message);
14654
14656
  this.status = status;
14657
+ this.code = code;
14655
14658
  }
14656
14659
  status;
14660
+ code;
14657
14661
  };
14658
14662
  function createApiCall({ baseUrl = "", getToken, onUnauthorized }) {
14659
14663
  return async function call(schema, path, init) {
@@ -14672,7 +14676,12 @@ function createApiCall({ baseUrl = "", getToken, onUnauthorized }) {
14672
14676
  }
14673
14677
  if (!res.ok) {
14674
14678
  const detail = await res.json().catch(() => null);
14675
- throw new ApiError(res.status, detail?.error ?? res.statusText);
14679
+ const payload = detail;
14680
+ throw new ApiError(
14681
+ res.status,
14682
+ typeof payload?.error === "string" ? payload.error : res.statusText,
14683
+ typeof payload?.code === "string" ? payload.code : void 0
14684
+ );
14676
14685
  }
14677
14686
  return schema.parse(await res.json());
14678
14687
  };
@@ -14761,7 +14770,7 @@ var EnrollableNodeRoleSchema = external_exports.literal("worker");
14761
14770
  var NodeSandboxSchema = external_exports.enum(["gvisor", "none"]);
14762
14771
  var ZoneSchema = external_exports.object({
14763
14772
  id: external_exports.string(),
14764
- /** Ops zone name, e.g. 'eu-central-1' — what apps reference as `zone`. */
14773
+ /** Ops zone name, e.g. 'cz-prg-1' — what apps reference as `zone`. */
14765
14774
  name: external_exports.string(),
14766
14775
  region: RegionSchema,
14767
14776
  provider: external_exports.string(),
@@ -14817,6 +14826,14 @@ var ZoneAgentSchema = external_exports.object({
14817
14826
  zoneId: external_exports.string(),
14818
14827
  state: external_exports.enum(["active", "revoked"]),
14819
14828
  agentVersion: external_exports.string().nullable(),
14829
+ /**
14830
+ * What the control plane last told this agent to run, as recorded when it
14831
+ * answered a sync (#80). Information only — the agent never upgrades itself
14832
+ * (design-cell-agent.md §7). Null means the control plane claims no desired
14833
+ * version, which is not drift; drift is a non-null value that differs from
14834
+ * `agentVersion`.
14835
+ */
14836
+ desiredAgentVersion: external_exports.string().nullable(),
14820
14837
  /** Per pod; changes on every restart of the agent. */
14821
14838
  instanceId: external_exports.string().nullable(),
14822
14839
  keyFingerprint: external_exports.string(),
@@ -15210,7 +15227,7 @@ async function deviceSignIn(apiUrl, timeoutMs, reason) {
15210
15227
  info(`\u2192 no browser here (${reason}) \u2014 sign in from any other device`);
15211
15228
  info(` Open: ${device.verificationUri}`);
15212
15229
  info(` Code: ${device.userCode}`);
15213
- const intervalMs = Math.max(1, device.interval || DEFAULT_POLL_INTERVAL_S) * 1e3;
15230
+ let intervalMs = Math.max(1, device.interval || DEFAULT_POLL_INTERVAL_S) * 1e3;
15214
15231
  const stopAt = Date.now() + Math.min(timeoutMs, Math.max(1, device.expiresIn) * 1e3);
15215
15232
  const spin = spinner("waiting for approval\u2026");
15216
15233
  try {
@@ -15218,7 +15235,12 @@ async function deviceSignIn(apiUrl, timeoutMs, reason) {
15218
15235
  try {
15219
15236
  return await exchange(apiUrl, device.deviceCode, verifier);
15220
15237
  } catch (cause) {
15221
- if (!(cause instanceof ApiError) || cause.message !== "authorization_pending") throw cause;
15238
+ if (!(cause instanceof ApiError)) throw cause;
15239
+ if (cause.message === CLI_AUTH_SLOW_DOWN) {
15240
+ intervalMs += DEFAULT_POLL_INTERVAL_S * 1e3;
15241
+ } else if (cause.message !== CLI_AUTH_PENDING) {
15242
+ throw cause;
15243
+ }
15222
15244
  }
15223
15245
  if (Date.now() >= stopAt) {
15224
15246
  throw new CliError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tori.host",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Deploy AI-generated apps to tori.host: npx tori.host",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -47,8 +47,8 @@
47
47
  "tsx": "^4.19.2",
48
48
  "vitest": "^3.0.0"
49
49
  },
50
- "gitHead": "6d806abe5347b7704d029a6a0a1af2c1395b8c79",
50
+ "gitHead": "b8bf939883d32e75c0049d22abef97f8e742f525",
51
51
  "tori": {
52
- "commit": "6d806abe5347b7704d029a6a0a1af2c1395b8c79"
52
+ "commit": "b8bf939883d32e75c0049d22abef97f8e742f525"
53
53
  }
54
54
  }