tencil 0.14.0 → 0.14.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/react.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as TencilCloudOptions } from "./cloud-CRDNwbe9.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-CblA1guP.mjs";
2
2
  //#region src/integrations/react.d.ts
3
3
  /**
4
4
  * Loads the Tencil overlay in development from the daemon on the machine
@@ -4134,6 +4134,51 @@ async function codexProblem(options = {}) {
4134
4134
  //#endregion
4135
4135
  //#region ../provider-t3code/src/auth.ts
4136
4136
  const DEFAULT_T3_URL = "http://127.0.0.1:3773";
4137
+ /** Where T3 Code keeps its data: `$T3CODE_HOME`, else `~/.t3`. */
4138
+ function t3Home() {
4139
+ return process.env.T3CODE_HOME ?? join(homedir(), ".t3");
4140
+ }
4141
+ /**
4142
+ * The T3 Code server this user runs, from the `userdata/server-runtime.json`
4143
+ * it writes on start (the `t3` CLI finds its server the same way). Undefined
4144
+ * when the file is missing or its process is gone (stale after a crash).
4145
+ * Checking the file matters on shared machines, where 3773 can be someone else's.
4146
+ */
4147
+ async function runningT3Url(baseDir = t3Home()) {
4148
+ try {
4149
+ const runtime = JSON.parse(await readFile(join(baseDir, "userdata", "server-runtime.json"), "utf8"));
4150
+ if (typeof runtime.origin !== "string" || !isAlive(runtime.pid)) return void 0;
4151
+ return normalizeBaseUrl(runtime.origin);
4152
+ } catch {
4153
+ return;
4154
+ }
4155
+ }
4156
+ function isAlive(pid) {
4157
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
4158
+ try {
4159
+ process.kill(pid, 0);
4160
+ return true;
4161
+ } catch (error) {
4162
+ return error.code === "EPERM";
4163
+ }
4164
+ }
4165
+ /**
4166
+ * The T3 Code to talk to: the configured URL, else the server paired with
4167
+ * last, else the one running for this user, else localhost:3773. A running
4168
+ * T3 Code beats a server paired on this machine: its port can change between
4169
+ * starts (another user may hold 3773), so a paired local port goes stale.
4170
+ */
4171
+ async function resolveT3Url(options = {}) {
4172
+ if (options.baseUrl) return normalizeBaseUrl(options.baseUrl);
4173
+ const paired = await (options.credentials ?? new CredentialStore()).lastBaseUrl();
4174
+ if (paired && !isLoopback(paired)) return normalizeBaseUrl(paired);
4175
+ return normalizeBaseUrl(await runningT3Url(options.baseDir) ?? paired ?? "http://127.0.0.1:3773");
4176
+ }
4177
+ /** `localhost`, `127.x` and `[::1]`: a server on this machine. */
4178
+ function isLoopback(baseUrl) {
4179
+ const { hostname } = new URL(normalizeBaseUrl(baseUrl));
4180
+ return hostname === "localhost" || hostname === "[::1]" || hostname.startsWith("127.");
4181
+ }
4137
4182
  /** Scopes Tencil needs: read thread state and launch/steer threads. */
4138
4183
  const SCOPES = "orchestration:read orchestration:operate";
4139
4184
  /**
@@ -4205,7 +4250,7 @@ async function exchangePairingCredential(target, clientLabel = "Tencil") {
4205
4250
  function withoutNpmEnv(env = process.env) {
4206
4251
  return Object.fromEntries(Object.entries(env).filter(([key]) => !key.startsWith("npm_")));
4207
4252
  }
4208
- async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME ?? join(homedir(), ".t3")) {
4253
+ async function createLocalPairingCode(baseUrl, baseDir = t3Home()) {
4209
4254
  const { hostname } = new URL(baseUrl);
4210
4255
  if (![
4211
4256
  "localhost",
@@ -4296,7 +4341,7 @@ var CredentialStore = class {
4296
4341
  /** `localhost`, `127.0.0.1` and `[::1]` reach the same server; share one credential. */
4297
4342
  function credentialKey(baseUrl) {
4298
4343
  const url = new URL(normalizeBaseUrl(baseUrl));
4299
- if (url.hostname === "localhost" || url.hostname === "[::1]" || url.hostname.startsWith("127.")) url.hostname = "127.0.0.1";
4344
+ if (isLoopback(url.origin)) url.hostname = "127.0.0.1";
4300
4345
  return url.origin;
4301
4346
  }
4302
4347
  /**
@@ -4305,7 +4350,10 @@ function credentialKey(baseUrl) {
4305
4350
  */
4306
4351
  async function listT3Projects(options = {}) {
4307
4352
  const credentials = options.credentials ?? new CredentialStore();
4308
- const baseUrl = normalizeBaseUrl(options.baseUrl ?? await credentials.lastBaseUrl() ?? "http://127.0.0.1:3773");
4353
+ const baseUrl = await resolveT3Url({
4354
+ baseUrl: options.baseUrl,
4355
+ credentials
4356
+ });
4309
4357
  const token = options.token ?? (await credentials.get(baseUrl))?.token;
4310
4358
  if (!token) return [];
4311
4359
  try {
@@ -5027,10 +5075,7 @@ var T3CodeProvider = class {
5027
5075
  * and reconnect. Used automatically on first run and by the overlay's Pair button.
5028
5076
  */
5029
5077
  async pair() {
5030
- if (!this.#options.baseUrl) {
5031
- const paired = await this.#credentials.lastBaseUrl();
5032
- if (paired) this.#baseUrl = normalizeBaseUrl(paired);
5033
- }
5078
+ await this.#resolveBaseUrl();
5034
5079
  this.#setInfo({
5035
5080
  state: "connecting",
5036
5081
  detail: "Pairing with T3 Code…"
@@ -5264,11 +5309,13 @@ var T3CodeProvider = class {
5264
5309
  }
5265
5310
  this.#scheduleReconnect();
5266
5311
  }
5312
+ /** Re-resolved on every attempt: T3 Code may start, or be paired, after Tencil. */
5313
+ async #resolveBaseUrl() {
5314
+ if (this.#options.baseUrl) return;
5315
+ this.#baseUrl = await resolveT3Url({ credentials: this.#credentials });
5316
+ }
5267
5317
  async #establish() {
5268
- if (!this.#options.baseUrl) {
5269
- const paired = await this.#credentials.lastBaseUrl();
5270
- if (paired) this.#baseUrl = normalizeBaseUrl(paired);
5271
- }
5318
+ await this.#resolveBaseUrl();
5272
5319
  const environment = await this.#fetchJson("/.well-known/t3/environment", void 0, `T3 Code isn't running at ${this.#baseUrl}. Open T3 Code and Tencil connects on its own.`);
5273
5320
  const protocol = environment.orchestrationProtocolVersion === 2 ? v2 : v1;
5274
5321
  const token = this.#options.token ?? (await this.#credentials.get(this.#baseUrl))?.token;
@@ -5425,7 +5472,7 @@ function errorMessage(error) {
5425
5472
  }
5426
5473
  //#endregion
5427
5474
  //#region src/version.ts
5428
- const VERSION = "0.14.0";
5475
+ const VERSION = "0.14.2";
5429
5476
  //#endregion
5430
5477
  //#region src/daemon/thread-store.ts
5431
5478
  const StoreFile = z.object({
@@ -5616,7 +5663,10 @@ async function machineProvider(options = {}) {
5616
5663
  }
5617
5664
  async function hasT3Code(t3Url) {
5618
5665
  const store = new CredentialStore();
5619
- const baseUrl = t3Url ?? await store.lastBaseUrl() ?? "http://127.0.0.1:3773";
5666
+ const baseUrl = await resolveT3Url({
5667
+ baseUrl: t3Url,
5668
+ credentials: store
5669
+ });
5620
5670
  if (await store.get(baseUrl)) return true;
5621
5671
  try {
5622
5672
  return (await fetch(new URL("/.well-known/t3/environment", baseUrl), { signal: AbortSignal.timeout(800) })).ok;
@@ -6140,14 +6190,15 @@ function serviceNames(port = DEFAULT_PORT) {
6140
6190
  * What the daemon needs from the shell that installed it. launchd and systemd
6141
6191
  * start it with a bare PATH (`/usr/bin:/bin`), where nvm's npm and npx, which
6142
6192
  * it runs to pair and to install the Claude Agent SDK, can't be found; and a
6143
- * custom XDG_CONFIG_HOME must reach it, or it reads another data folder than
6144
- * the CLI. npx's and npm's own folders (anything in node_modules) are left out of PATH.
6193
+ * custom XDG_CONFIG_HOME or T3CODE_HOME must reach it, or it reads another
6194
+ * data folder than the CLI. npx's and npm's own folders (anything in node_modules) are left out of PATH.
6145
6195
  */
6146
6196
  function serviceEnvironment(command, env = process.env) {
6147
6197
  const separator = process.platform === "win32" ? ";" : ":";
6148
6198
  const entries = [dirname(command.node), ...(env.PATH ?? "").split(separator)].filter((entry) => entry && !/[\\/](?:_npx|node_modules)[\\/]/.test(entry));
6149
6199
  const environment = { PATH: [...new Set(entries)].join(separator) };
6150
6200
  if (env.XDG_CONFIG_HOME) environment.XDG_CONFIG_HOME = env.XDG_CONFIG_HOME;
6201
+ if (env.T3CODE_HOME) environment.T3CODE_HOME = env.T3CODE_HOME;
6151
6202
  return environment;
6152
6203
  }
6153
6204
  function launchdPlist(command, logPath, environment = {}) {
@@ -7244,4 +7295,4 @@ function readBody(request, limit) {
7244
7295
  });
7245
7296
  }
7246
7297
  //#endregion
7247
- export { withoutNpmEnv as A, projectStorePath as C, createLocalPairingCode as D, DEFAULT_T3_URL as E, EnsembleCredentialStore as F, EnsembleClient as I, Bridge as L, loadAgentSdk as M, ProjectResolver as N, exchangePairingCredential as O, projectRoot as P, renderPrompt as R, defaultDataDir as S, CredentialStore as T, detectAgents as _, readPlan as a, savedProvider as b, runtimeDir as c, uninstallService as d, startInBackground as f, PROVIDERS as g, updateNotice as h, finishUpdate as i, codexProblem as j, parsePairingInput as k, isServiceInstalled as l, isNewerThanThis as m, probeDaemon as n, enableAutostart as o, stopDaemon as p, startDaemon as r, ensureDaemon as s, DEFAULT_PORT as t, stopService as u, providerLabel as v, VERSION as w, FileThreadStore as x, saveProvider as y, stripContext as z };
7298
+ export { resolveT3Url as A, stripContext as B, projectStorePath as C, createLocalPairingCode as D, DEFAULT_T3_URL as E, projectRoot as F, EnsembleCredentialStore as I, EnsembleClient as L, codexProblem as M, loadAgentSdk as N, exchangePairingCredential as O, ProjectResolver as P, Bridge as R, defaultDataDir as S, CredentialStore as T, detectAgents as _, readPlan as a, savedProvider as b, runtimeDir as c, uninstallService as d, startInBackground as f, PROVIDERS as g, updateNotice as h, finishUpdate as i, withoutNpmEnv as j, parsePairingInput as k, isServiceInstalled as l, isNewerThanThis as m, probeDaemon as n, enableAutostart as o, stopDaemon as p, startDaemon as r, ensureDaemon as s, DEFAULT_PORT as t, stopService as u, providerLabel as v, VERSION as w, FileThreadStore as x, saveProvider as y, renderPrompt as z };
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as TencilCloudOptions } from "./cloud-CRDNwbe9.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-CblA1guP.mjs";
2
2
  //#region src/integrations/vite.d.ts
3
3
  /** Structural subset of Vite's Plugin type, so `vite` stays an optional peer. */
4
4
  interface VitePlugin {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencil",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "Point at any element of your running app and tell your coding agent what to fix.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Pixel Perfect Agency",
@@ -95,9 +95,9 @@
95
95
  "react": "^19.3.0",
96
96
  "tsdown": "^0.23.0",
97
97
  "@tencildev/bridge": "0.6.0",
98
- "@tencildev/overlay": "0.0.0",
99
98
  "@tencildev/protocol": "0.8.0",
100
99
  "@tencildev/provider-claude-code": "0.0.0",
100
+ "@tencildev/overlay": "0.0.0",
101
101
  "@tencildev/provider-codex": "0.0.0",
102
102
  "@tencildev/provider-ensemble": "0.0.0",
103
103
  "@tencildev/provider-t3code": "0.0.0",