@tenux/cli 0.0.10 → 0.0.12

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.
@@ -43,6 +43,7 @@ function updateConfig(partial) {
43
43
  // src/lib/supabase.ts
44
44
  import { createClient } from "@supabase/supabase-js";
45
45
  var client = null;
46
+ var initialized = false;
46
47
  function getSupabase() {
47
48
  if (client) return client;
48
49
  const config = loadConfig();
@@ -52,16 +53,34 @@ function getSupabase() {
52
53
  autoRefreshToken: true
53
54
  }
54
55
  });
56
+ client.auth.onAuthStateChange((_event, session) => {
57
+ if (session?.access_token && session?.refresh_token) {
58
+ updateConfig({
59
+ accessToken: session.access_token,
60
+ refreshToken: session.refresh_token
61
+ });
62
+ }
63
+ });
64
+ return client;
65
+ }
66
+ async function initSupabaseSession() {
67
+ if (initialized) return;
68
+ const config = loadConfig();
69
+ const sb = getSupabase();
55
70
  if (config.accessToken && config.refreshToken) {
56
- client.auth.setSession({
71
+ const { error } = await sb.auth.setSession({
57
72
  access_token: config.accessToken,
58
73
  refresh_token: config.refreshToken
59
74
  });
75
+ if (error) {
76
+ throw new Error(`Failed to restore session: ${error.message}`);
77
+ }
60
78
  }
61
- return client;
79
+ initialized = true;
62
80
  }
63
81
  function resetSupabase() {
64
82
  client = null;
83
+ initialized = false;
65
84
  }
66
85
 
67
86
  // src/lib/relay.ts
@@ -190,7 +209,11 @@ async function handleClaudeQuery(command, supabase) {
190
209
  prompt,
191
210
  project_path,
192
211
  model,
193
- session_id
212
+ session_id,
213
+ effort,
214
+ permission_mode,
215
+ max_budget,
216
+ system_prompt
194
217
  } = command.payload;
195
218
  if (!prompt) throw new Error("prompt is required");
196
219
  const config = loadConfig();
@@ -214,6 +237,10 @@ async function handleClaudeQuery(command, supabase) {
214
237
  // structured streaming output
215
238
  ];
216
239
  if (model) args.push("--model", model);
240
+ if (effort) args.push("--effort", effort);
241
+ if (permission_mode) args.push("--permission-mode", permission_mode);
242
+ if (max_budget) args.push("--max-budget-usd", max_budget);
243
+ if (system_prompt) args.push("--append-system-prompt", system_prompt);
217
244
  if (session_id) args.push("--resume", session_id);
218
245
  const isWindows = process.platform === "win32";
219
246
  const claudeBin = isWindows ? "claude.cmd" : "claude";
@@ -321,6 +348,7 @@ export {
321
348
  saveConfig,
322
349
  updateConfig,
323
350
  getSupabase,
351
+ initSupabaseSession,
324
352
  resetSupabase,
325
353
  Relay,
326
354
  handleClaudeQuery
package/dist/cli.js CHANGED
@@ -5,10 +5,11 @@ import {
5
5
  getConfigPath,
6
6
  getSupabase,
7
7
  handleClaudeQuery,
8
+ initSupabaseSession,
8
9
  loadConfig,
9
10
  saveConfig,
10
11
  updateConfig
11
- } from "./chunk-V2C4ESKK.js";
12
+ } from "./chunk-JN3TO63A.js";
12
13
 
13
14
  // src/cli.ts
14
15
  import { Command } from "commander";
@@ -230,13 +231,23 @@ program.command("start").description("Start the agent and listen for commands").
230
231
  console.log(chalk.dim(" Projects:"), config.projectsDir);
231
232
  console.log();
232
233
  const supabase = getSupabase();
234
+ try {
235
+ await initSupabaseSession();
236
+ } catch (err) {
237
+ console.log(chalk.red("\u2717"), `Session expired: ${err.message}`);
238
+ console.log(chalk.dim(" Run `tenux login` to re-authenticate."));
239
+ process.exit(1);
240
+ }
233
241
  await supabase.from("devices").update({
234
242
  name: config.deviceName,
235
243
  is_online: true,
236
244
  last_seen_at: (/* @__PURE__ */ new Date()).toISOString()
237
245
  }).eq("id", config.deviceId);
238
246
  const heartbeat = setInterval(async () => {
239
- await supabase.from("devices").update({ last_seen_at: (/* @__PURE__ */ new Date()).toISOString(), is_online: true }).eq("id", config.deviceId);
247
+ const { error } = await supabase.from("devices").update({ last_seen_at: (/* @__PURE__ */ new Date()).toISOString(), is_online: true }).eq("id", config.deviceId);
248
+ if (error) {
249
+ console.log(chalk.red("\u2717"), chalk.dim(`Heartbeat failed: ${error.message}`));
250
+ }
240
251
  }, 3e4);
241
252
  const relay = new Relay(supabase);
242
253
  const shutdown = async () => {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  resetSupabase,
8
8
  saveConfig,
9
9
  updateConfig
10
- } from "./chunk-V2C4ESKK.js";
10
+ } from "./chunk-JN3TO63A.js";
11
11
  export {
12
12
  Relay,
13
13
  configExists,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenux/cli",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Tenux — mobile-first IDE for 10x engineering",
5
5
  "author": "Antelogic LLC",
6
6
  "license": "MIT",