@todoforai/tfa-surface 0.1.1 → 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 +11 -5
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -37,9 +37,13 @@ function writeSecure(data) {
37
37
  }
38
38
  function readStoredAuth(apiUrl) {
39
39
  const c = read();
40
- const apiToken = c[apiUrl] || c.apiToken || c.apiKey || "";
41
40
  const host = c.backendHost || "";
42
41
  const storedApiUrl = typeof c.apiUrl === "string" && c.apiUrl ? c.apiUrl : host ? `${host === "localhost" || host === "127.0.0.1" ? "http" : "https"}://${host}` : undefined;
42
+ const dstIsForThisUrl = !storedApiUrl || normalizeApiUrl(storedApiUrl) === normalizeApiUrl(apiUrl);
43
+ const isDst = typeof c.apiToken === "string" && c.apiToken.startsWith("dst_");
44
+ const dst = dstIsForThisUrl && isDst ? c.apiToken : "";
45
+ const fallbackApiToken = isDst && !dstIsForThisUrl ? "" : c.apiToken;
46
+ const apiToken = dst || c[apiUrl] || fallbackApiToken || c.apiKey || "";
43
47
  return {
44
48
  apiToken: typeof apiToken === "string" ? apiToken : "",
45
49
  apiUrl: storedApiUrl,
@@ -63,6 +67,8 @@ async function refreshDeviceToken(opts = {}) {
63
67
  const apiUrl = normalizeApiUrl(opts.apiUrl || envUrl || stored.apiUrl || DEFAULT_API_URL);
64
68
  if (!stored.deviceId || !stored.deviceSecret)
65
69
  return "";
70
+ if (stored.apiUrl && normalizeApiUrl(stored.apiUrl) !== apiUrl)
71
+ return "";
66
72
  try {
67
73
  const res = await fetch(`${apiUrl}/api/v1/cli/device/token`, {
68
74
  method: "POST",
@@ -89,7 +95,7 @@ async function fetchWithRenew(url, init, opts) {
89
95
  return fetch(url, { ...init, headers });
90
96
  };
91
97
  const res = await send(opts.token);
92
- if (renewOn.includes(res.status) && opts.token.startsWith("dst_")) {
98
+ if (renewOn.includes(res.status)) {
93
99
  const fresh = await refreshDeviceToken({ apiUrl: opts.apiUrl });
94
100
  if (fresh && fresh !== opts.token)
95
101
  return { res: await send(fresh), token: fresh };
@@ -110,7 +116,7 @@ function resolveToken(opts = {}) {
110
116
  // package.json
111
117
  var package_default = {
112
118
  name: "@todoforai/tfa-surface",
113
- version: "0.1.1",
119
+ version: "0.1.2",
114
120
  description: "TODOforAI surface CLI — see and drive what is shown in the user's live UI (describe, todo/panel views, renderer cards, surface render, controls). Replaces tfa-frontend. Reuses bridge credentials.",
115
121
  type: "module",
116
122
  bin: {
@@ -164,7 +170,7 @@ Todos (views):
164
170
 
165
171
  Panels (surfaces inside a todo; --todo defaults to $TODOFORAI_TODO_ID):
166
172
  panel open <surface> [--todo <id>] [--url <url>]
167
- surface: changes|preview|browser|terminal
173
+ surface: changes|agents|preview|browser|terminal
168
174
  panel close [--todo <id>]
169
175
 
170
176
  Renderer cards (data plane — works headless, no frontend needed;
@@ -367,7 +373,7 @@ async function main() {
367
373
  const [verb, surface] = args;
368
374
  if (verb === "open") {
369
375
  if (!surface)
370
- die("usage: tfa-surface panel open changes|preview|browser|terminal [--todo <id>] [--url <url>]");
376
+ die("usage: tfa-surface panel open changes|agents|preview|browser|terminal [--todo <id>] [--url <url>]");
371
377
  const result = await uiCall(ctx, "panel.open", { todoId: todoArg(), surface, ...values.url ? { url: values.url } : {} });
372
378
  const pending = result?.browserReady === false;
373
379
  console.log(ctx.json ? JSON.stringify(result ?? { ok: true }) : pending ? "ok (browser opening — its CDP url appears in `device_list` shortly)" : "ok");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@todoforai/tfa-surface",
3
- "version": "0.1.1",
4
- "description": "TODOforAI surface CLI \u2014 see and drive what is shown in the user's live UI (describe, todo/panel views, renderer cards, surface render, controls). Replaces tfa-frontend. Reuses bridge credentials.",
3
+ "version": "0.1.2",
4
+ "description": "TODOforAI surface CLI — see and drive what is shown in the user's live UI (describe, todo/panel views, renderer cards, surface render, controls). Replaces tfa-frontend. Reuses bridge credentials.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "tfa-surface": "dist/cli.js"