tencil 0.3.0 → 0.3.1
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/cli.mjs +36 -16
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/{server-B7qPM-xo.mjs → server-PYBcw-eR.mjs} +22 -8
- package/package.json +6 -6
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as loadAgentSdk } from "./server-
|
|
2
|
+
import { _ as parsePairingInput, a as detectAgents, c as savedProvider, f as VERSION, g as exchangePairingCredential, h as createLocalPairingCode, i as PROVIDERS, m as DEFAULT_T3_URL, n as probeDaemon, o as providerLabel, p as CredentialStore, r as startDaemon, s as saveProvider, t as DEFAULT_PORT, u as defaultDataDir, v as withoutNpmEnv, y as loadAgentSdk } from "./server-PYBcw-eR.mjs";
|
|
3
3
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
4
4
|
import { cpSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
@@ -92,8 +92,23 @@ function serviceNames(port = DEFAULT_PORT) {
|
|
|
92
92
|
task: own ? `Tencil ${port}` : "Tencil"
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
/**
|
|
96
|
+
* What the daemon needs from the shell that installed it. launchd and systemd
|
|
97
|
+
* start it with a bare PATH (`/usr/bin:/bin`), where nvm's npm and npx, which
|
|
98
|
+
* it runs to pair and to install the Claude Agent SDK, can't be found; and a
|
|
99
|
+
* custom XDG_CONFIG_HOME must reach it, or it reads another data folder than
|
|
100
|
+
* the CLI. npx's and npm's own folders (anything in node_modules) are left out of PATH.
|
|
101
|
+
*/
|
|
102
|
+
function serviceEnvironment(command, env = process.env) {
|
|
103
|
+
const separator = process.platform === "win32" ? ";" : ":";
|
|
104
|
+
const entries = [dirname(command.node), ...(env.PATH ?? "").split(separator)].filter((entry) => entry && !/[\\/](?:_npx|node_modules)[\\/]/.test(entry));
|
|
105
|
+
const environment = { PATH: [...new Set(entries)].join(separator) };
|
|
106
|
+
if (env.XDG_CONFIG_HOME) environment.XDG_CONFIG_HOME = env.XDG_CONFIG_HOME;
|
|
107
|
+
return environment;
|
|
108
|
+
}
|
|
109
|
+
function launchdPlist(command, logPath, environment = {}) {
|
|
96
110
|
const args = [command.node, ...daemonArgs(command)].map((arg) => ` <string>${escapeXml(arg)}</string>`).join("\n");
|
|
111
|
+
const variables = Object.entries(environment).map(([key, value]) => ` <key>${escapeXml(key)}</key>\n <string>${escapeXml(value)}</string>`).join("\n");
|
|
97
112
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
98
113
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
99
114
|
<plist version="1.0">
|
|
@@ -104,6 +119,10 @@ function launchdPlist(command, logPath) {
|
|
|
104
119
|
<array>
|
|
105
120
|
${args}
|
|
106
121
|
</array>
|
|
122
|
+
<key>EnvironmentVariables</key>
|
|
123
|
+
<dict>
|
|
124
|
+
${variables}
|
|
125
|
+
</dict>
|
|
107
126
|
<key>RunAtLoad</key>
|
|
108
127
|
<true/>
|
|
109
128
|
<key>KeepAlive</key>
|
|
@@ -116,12 +135,12 @@ ${args}
|
|
|
116
135
|
</plist>
|
|
117
136
|
`;
|
|
118
137
|
}
|
|
119
|
-
function systemdUnit(command) {
|
|
138
|
+
function systemdUnit(command, environment = {}) {
|
|
120
139
|
return `[Unit]
|
|
121
140
|
Description=Tencil daemon
|
|
122
141
|
|
|
123
142
|
[Service]
|
|
124
|
-
ExecStart=${[command.node, ...daemonArgs(command)].map((arg) => `"${arg}"`).join(" ")}
|
|
143
|
+
${Object.entries(environment).map(([key, value]) => `Environment="${key}=${value}"\n`).join("")}ExecStart=${[command.node, ...daemonArgs(command)].map((arg) => `"${arg}"`).join(" ")}
|
|
125
144
|
Restart=on-failure
|
|
126
145
|
|
|
127
146
|
[Install]
|
|
@@ -184,7 +203,7 @@ async function installService(command, dataDir) {
|
|
|
184
203
|
]);
|
|
185
204
|
await stopDaemon(command.port);
|
|
186
205
|
mkdirSync(join(homedir(), "Library", "LaunchAgents"), { recursive: true });
|
|
187
|
-
writeFileSync(plist, launchdPlist(command, logPath));
|
|
206
|
+
writeFileSync(plist, launchdPlist(command, logPath, serviceEnvironment(command)));
|
|
188
207
|
execFileSync("launchctl", [
|
|
189
208
|
"bootstrap",
|
|
190
209
|
launchdDomain(),
|
|
@@ -201,7 +220,7 @@ async function installService(command, dataDir) {
|
|
|
201
220
|
]);
|
|
202
221
|
await stopDaemon(command.port);
|
|
203
222
|
mkdirSync(join(homedir(), ".config", "systemd", "user"), { recursive: true });
|
|
204
|
-
writeFileSync(unit, systemdUnit(command));
|
|
223
|
+
writeFileSync(unit, systemdUnit(command, serviceEnvironment(command)));
|
|
205
224
|
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
206
225
|
execFileSync("systemctl", [
|
|
207
226
|
"--user",
|
|
@@ -362,7 +381,8 @@ async function enableAutostart(command, dataDir, from) {
|
|
|
362
381
|
"ignore",
|
|
363
382
|
"pipe"
|
|
364
383
|
],
|
|
365
|
-
shell: process.platform === "win32"
|
|
384
|
+
shell: process.platform === "win32",
|
|
385
|
+
env: withoutNpmEnv()
|
|
366
386
|
});
|
|
367
387
|
if (result.status !== 0) throw new Error(`Couldn't install Tencil for the login service (npm ${result.status ?? "failed"}): ${result.stderr?.trim() ?? ""}`);
|
|
368
388
|
cli = runtimeCli(dataDir, command.port);
|
|
@@ -455,7 +475,7 @@ async function pairWithLocalT3(t3Url, log) {
|
|
|
455
475
|
if (await store.get(baseUrl)) return log(` ${pc.green("✓")} Paired with T3 Code.`);
|
|
456
476
|
const code = await createLocalPairingCode(baseUrl).catch(() => void 0);
|
|
457
477
|
if (!code) {
|
|
458
|
-
log(` ${pc.yellow("!")} T3 Code isn't running, so pairing is skipped. Tencil pairs on its own once it is.`);
|
|
478
|
+
log(await fetch(new URL("/.well-known/t3/environment", baseUrl), { signal: AbortSignal.timeout(3e3) }).then((response) => response.ok, () => false) ? ` ${pc.yellow("!")} Couldn't pair with T3 Code automatically. Press Pair in the overlay, or run ${pc.cyan("npx tencil connect")} with a pairing link from T3 Code.` : ` ${pc.yellow("!")} T3 Code isn't running, so pairing is skipped. Tencil pairs on its own once it is.`);
|
|
459
479
|
return;
|
|
460
480
|
}
|
|
461
481
|
try {
|
|
@@ -874,7 +894,8 @@ function uninstall(options, name, log) {
|
|
|
874
894
|
spawnSync(command, args, {
|
|
875
895
|
cwd: options.root,
|
|
876
896
|
stdio: "inherit",
|
|
877
|
-
shell: process.platform === "win32"
|
|
897
|
+
shell: process.platform === "win32",
|
|
898
|
+
env: withoutNpmEnv()
|
|
878
899
|
});
|
|
879
900
|
}
|
|
880
901
|
function install(options, log) {
|
|
@@ -883,7 +904,8 @@ function install(options, log) {
|
|
|
883
904
|
if (spawnSync(command, args, {
|
|
884
905
|
cwd: options.root,
|
|
885
906
|
stdio: "inherit",
|
|
886
|
-
shell: process.platform === "win32"
|
|
907
|
+
shell: process.platform === "win32",
|
|
908
|
+
env: withoutNpmEnv()
|
|
887
909
|
}).status !== 0) log(` ${pc.yellow("!")} Install failed; run it yourself: ${command} ${args.join(" ")}\n`);
|
|
888
910
|
}
|
|
889
911
|
function describe(framework) {
|
|
@@ -1073,12 +1095,11 @@ async function runDaemon(values, port, provider, t3Url, runtimeMode) {
|
|
|
1073
1095
|
async function setup(command, options = {}) {
|
|
1074
1096
|
const log = (message) => console.log(message);
|
|
1075
1097
|
log(`\n ${pc.bold("Tencil")} setup ${pc.dim(`v${VERSION}`)}\n`);
|
|
1076
|
-
|
|
1098
|
+
await prepareProvider(await chooseProvider({
|
|
1077
1099
|
...options,
|
|
1078
1100
|
log
|
|
1079
|
-
});
|
|
1101
|
+
}), options.t3Url, log);
|
|
1080
1102
|
await setUpMachine(command, options, log);
|
|
1081
|
-
await prepareProvider(provider, options.t3Url, log);
|
|
1082
1103
|
log(`
|
|
1083
1104
|
Next, in each project: ${pc.cyan("npx tencil")}
|
|
1084
1105
|
Then start its dev server and press ${pc.bold("C")} on the page.
|
|
@@ -1118,17 +1139,16 @@ async function confirm(question) {
|
|
|
1118
1139
|
async function quickstart(command, options) {
|
|
1119
1140
|
const log = (message) => console.log(message);
|
|
1120
1141
|
log(`\n ${pc.bold("Tencil")} ${pc.dim(`v${VERSION}`)}\n`);
|
|
1121
|
-
|
|
1142
|
+
await prepareProvider(await chooseProvider({
|
|
1122
1143
|
...options,
|
|
1123
1144
|
log
|
|
1124
|
-
});
|
|
1145
|
+
}), options.t3Url, log);
|
|
1125
1146
|
if (!await probeDaemon(command.port) && !isServiceInstalled(command.port)) await setUpMachine(command, options, log);
|
|
1126
1147
|
else {
|
|
1127
1148
|
const result = await ensureDaemon(command, defaultDataDir());
|
|
1128
1149
|
const verb = result.status === "running" ? "is running" : result.status;
|
|
1129
1150
|
log(` ${pc.green("✓")} Tencil ${verb} on port ${command.port}${result.autostart ? pc.dim(" (starts at login)") : ""}`);
|
|
1130
1151
|
}
|
|
1131
|
-
await prepareProvider(provider, options.t3Url, log);
|
|
1132
1152
|
const framework = await detectFramework(options.root);
|
|
1133
1153
|
if (framework.kind !== "unknown" || existsSync(join(options.root, "package.json"))) {
|
|
1134
1154
|
const apps = framework.kind === "unknown" ? await findApps(options.root) : [];
|
package/dist/index.d.mts
CHANGED
|
@@ -53,11 +53,11 @@ type ImageAttachment = z.infer<typeof ImageAttachment>;
|
|
|
53
53
|
* - `error`: last turn or the thread itself failed
|
|
54
54
|
*/
|
|
55
55
|
declare const ThreadStatus: z.ZodEnum<{
|
|
56
|
-
error: "error";
|
|
57
56
|
starting: "starting";
|
|
58
57
|
working: "working";
|
|
59
58
|
waiting: "waiting";
|
|
60
59
|
idle: "idle";
|
|
60
|
+
error: "error";
|
|
61
61
|
}>;
|
|
62
62
|
type ThreadStatus = z.infer<typeof ThreadStatus>;
|
|
63
63
|
declare const MessageRole: z.ZodEnum<{
|
|
@@ -109,11 +109,11 @@ declare const Thread: z.ZodObject<{
|
|
|
109
109
|
selection: z.ZodOptional<z.ZodString>;
|
|
110
110
|
}, z.core.$strip>>;
|
|
111
111
|
status: z.ZodEnum<{
|
|
112
|
-
error: "error";
|
|
113
112
|
starting: "starting";
|
|
114
113
|
working: "working";
|
|
115
114
|
waiting: "waiting";
|
|
116
115
|
idle: "idle";
|
|
116
|
+
error: "error";
|
|
117
117
|
}>;
|
|
118
118
|
statusDetail: z.ZodOptional<z.ZodString>;
|
|
119
119
|
resolved: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -142,10 +142,10 @@ declare const ProviderThreadSummary: z.ZodObject<{
|
|
|
142
142
|
id: z.ZodString;
|
|
143
143
|
title: z.ZodString;
|
|
144
144
|
status: z.ZodEnum<{
|
|
145
|
-
error: "error";
|
|
146
145
|
working: "working";
|
|
147
146
|
waiting: "waiting";
|
|
148
147
|
idle: "idle";
|
|
148
|
+
error: "error";
|
|
149
149
|
}>;
|
|
150
150
|
updatedAt: z.ZodString;
|
|
151
151
|
url: z.ZodOptional<z.ZodString>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as ThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-PYBcw-eR.mjs";
|
|
2
2
|
export { Bridge, DEFAULT_PORT, ProjectResolver, ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
|
|
@@ -903,7 +903,8 @@ async function installAgentSdk(installDir) {
|
|
|
903
903
|
], {
|
|
904
904
|
cwd: installDir,
|
|
905
905
|
shell: process.platform === "win32",
|
|
906
|
-
timeout: 6e5
|
|
906
|
+
timeout: 6e5,
|
|
907
|
+
env: Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith("npm_")))
|
|
907
908
|
});
|
|
908
909
|
} catch (error) {
|
|
909
910
|
const stderr = error.stderr?.trim();
|
|
@@ -1487,6 +1488,15 @@ async function exchangePairingCredential(target, clientLabel = "Tencil") {
|
|
|
1487
1488
|
* the server's own version (mismatched CLIs may migrate the database).
|
|
1488
1489
|
* Returns undefined when the server isn't local or the CLI fails.
|
|
1489
1490
|
*/
|
|
1491
|
+
/**
|
|
1492
|
+
* The environment minus the lowercase `npm_*` variables an outer npm or npx
|
|
1493
|
+
* passes down: under `npx --package <spec> tencil`, `npm_config_package` makes
|
|
1494
|
+
* a nested `npx t3` run that package instead. Variables the user set
|
|
1495
|
+
* (`NPM_CONFIG_REGISTRY`) are uppercase and stay.
|
|
1496
|
+
*/
|
|
1497
|
+
function withoutNpmEnv(env = process.env) {
|
|
1498
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => !key.startsWith("npm_")));
|
|
1499
|
+
}
|
|
1490
1500
|
async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME ?? join(homedir(), ".t3")) {
|
|
1491
1501
|
const { hostname } = new URL(baseUrl);
|
|
1492
1502
|
if (![
|
|
@@ -1509,7 +1519,8 @@ async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME
|
|
|
1509
1519
|
const installed = join(baseDir, "runtime", "versions", serverVersion, "t3");
|
|
1510
1520
|
const result = existsSync(installed) ? spawnSync(installed, args, {
|
|
1511
1521
|
encoding: "utf8",
|
|
1512
|
-
timeout: 3e4
|
|
1522
|
+
timeout: 3e4,
|
|
1523
|
+
env: withoutNpmEnv()
|
|
1513
1524
|
}) : spawnSync(process.platform === "win32" ? "npx.cmd" : "npx", [
|
|
1514
1525
|
"-y",
|
|
1515
1526
|
`t3@${serverVersion}`,
|
|
@@ -1517,7 +1528,8 @@ async function createLocalPairingCode(baseUrl, baseDir = process.env.T3CODE_HOME
|
|
|
1517
1528
|
], {
|
|
1518
1529
|
encoding: "utf8",
|
|
1519
1530
|
timeout: 12e4,
|
|
1520
|
-
shell: process.platform === "win32"
|
|
1531
|
+
shell: process.platform === "win32",
|
|
1532
|
+
env: withoutNpmEnv()
|
|
1521
1533
|
});
|
|
1522
1534
|
return `${result.stdout ?? ""}\n${result.stderr ?? ""}`.match(/^Token:\s*(\S+)/m)?.[1];
|
|
1523
1535
|
}
|
|
@@ -1533,8 +1545,8 @@ async function requestWebSocketTicket(baseUrl, token, timeoutMs = 8e3) {
|
|
|
1533
1545
|
return ticket;
|
|
1534
1546
|
}
|
|
1535
1547
|
var UnauthorizedError = class extends Error {
|
|
1536
|
-
constructor() {
|
|
1537
|
-
super(
|
|
1548
|
+
constructor(message = "T3 Code rejected the stored token. Run `tencil connect` to pair again.") {
|
|
1549
|
+
super(message);
|
|
1538
1550
|
this.name = "UnauthorizedError";
|
|
1539
1551
|
}
|
|
1540
1552
|
};
|
|
@@ -2236,6 +2248,7 @@ var T3CodeProvider = class {
|
|
|
2236
2248
|
state: "unauthorized",
|
|
2237
2249
|
detail: "Couldn't pair automatically. Run `npx tencil connect` with a pairing link from T3 Code."
|
|
2238
2250
|
});
|
|
2251
|
+
this.#scheduleReconnect();
|
|
2239
2252
|
return;
|
|
2240
2253
|
}
|
|
2241
2254
|
try {
|
|
@@ -2250,6 +2263,7 @@ var T3CodeProvider = class {
|
|
|
2250
2263
|
state: "unauthorized",
|
|
2251
2264
|
detail: errorMessage(error)
|
|
2252
2265
|
});
|
|
2266
|
+
this.#scheduleReconnect();
|
|
2253
2267
|
return;
|
|
2254
2268
|
}
|
|
2255
2269
|
clearTimeout(this.#retryTimer);
|
|
@@ -2429,7 +2443,7 @@ var T3CodeProvider = class {
|
|
|
2429
2443
|
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.`);
|
|
2430
2444
|
const protocol = environment.orchestrationProtocolVersion === 2 ? v2 : v1;
|
|
2431
2445
|
const token = this.#options.token ?? (await this.#credentials.get(this.#baseUrl))?.token;
|
|
2432
|
-
if (!token) throw new UnauthorizedError();
|
|
2446
|
+
if (!token) throw new UnauthorizedError("Not paired with T3 Code yet. Press Pair, or run `npx tencil connect`.");
|
|
2433
2447
|
const ticket = await requestWebSocketTicket(this.#baseUrl, token, this.#timeouts.httpMs);
|
|
2434
2448
|
const wsUrl = new URL("/ws", this.#baseUrl);
|
|
2435
2449
|
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
@@ -2594,7 +2608,7 @@ function errorMessage(error) {
|
|
|
2594
2608
|
}
|
|
2595
2609
|
//#endregion
|
|
2596
2610
|
//#region src/version.ts
|
|
2597
|
-
const VERSION = "0.3.
|
|
2611
|
+
const VERSION = "0.3.1";
|
|
2598
2612
|
//#endregion
|
|
2599
2613
|
//#region src/daemon/thread-store.ts
|
|
2600
2614
|
const StoreFile = z.object({
|
|
@@ -3188,4 +3202,4 @@ function resolveOverlayPath() {
|
|
|
3188
3202
|
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
|
|
3189
3203
|
}
|
|
3190
3204
|
//#endregion
|
|
3191
|
-
export {
|
|
3205
|
+
export { renderPrompt as C, Bridge as S, parsePairingInput as _, detectAgents as a, ProjectResolver as b, savedProvider as c, projectStorePath as d, VERSION as f, exchangePairingCredential as g, createLocalPairingCode as h, PROVIDERS as i, ThreadStore as l, DEFAULT_T3_URL as m, probeDaemon as n, providerLabel as o, CredentialStore as p, startDaemon as r, saveProvider as s, DEFAULT_PORT as t, defaultDataDir as u, withoutNpmEnv as v, stripContext as w, projectRoot as x, loadAgentSdk as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tencil",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Point at any element of your running app and tell your coding agent what to fix.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Pixel Perfect Agency",
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
"@types/ws": "^8.18.2",
|
|
86
86
|
"react": "^19.3.0",
|
|
87
87
|
"tsdown": "^0.23.0",
|
|
88
|
-
"@tencil/
|
|
89
|
-
"@tencil/testing": "0.0.0",
|
|
90
|
-
"@tencil/provider-t3code": "0.0.0",
|
|
91
|
-
"@tencil/tsconfig": "0.0.0",
|
|
88
|
+
"@tencil/protocol": "0.0.0",
|
|
92
89
|
"@tencil/provider-claude-code": "0.0.0",
|
|
93
|
-
"@tencil/
|
|
90
|
+
"@tencil/provider-t3code": "0.0.0",
|
|
91
|
+
"@tencil/testing": "0.0.0",
|
|
92
|
+
"@tencil/overlay": "0.0.0",
|
|
93
|
+
"@tencil/tsconfig": "0.0.0"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "tsdown && node scripts/copy-overlay.mjs",
|