tencil 0.12.0 → 0.13.0
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 +1 -1
- package/dist/{cloud-DKtU6lcZ.d.mts → cloud-kfsssyEM.d.mts} +1 -1
- package/dist/{index-BSKV-nDI.d.mts → index-CCzEXssj.d.mts} +9 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/overlay.global.js +24 -24
- package/dist/react.d.mts +1 -1
- package/dist/{server-CjZNKv1m.mjs → server-D1QuPhoI.mjs} +313 -30
- package/dist/vite.d.mts +1 -1
- package/package.json +5 -5
package/dist/react.d.mts
CHANGED
|
@@ -464,6 +464,7 @@ const CONTEXT_CLOSE = "</tencil-context>";
|
|
|
464
464
|
function renderPrompt(input) {
|
|
465
465
|
const lines = [
|
|
466
466
|
"The user pinned this comment on an element of their running app (via Tencil). Use the context below to locate the code, then make the change in this workspace.",
|
|
467
|
+
...deployedNote([input.pageUrl]),
|
|
467
468
|
"",
|
|
468
469
|
...contextLines(input.pageUrl, input.context)
|
|
469
470
|
];
|
|
@@ -476,7 +477,7 @@ function renderPrompt(input) {
|
|
|
476
477
|
* the block leaves the numbered comments.
|
|
477
478
|
*/
|
|
478
479
|
function renderBatchPrompt(comments) {
|
|
479
|
-
const lines = [`The user pinned ${comments.length} comments on elements of their running app (via Tencil). Work through all of them in this workspace, using the context below to locate the code. They're numbered like the pins on the page: refer to them by number (#2) when you report back
|
|
480
|
+
const lines = [`The user pinned ${comments.length} comments on elements of their running app (via Tencil). Work through all of them in this workspace, using the context below to locate the code. They're numbered like the pins on the page: refer to them by number (#2) when you report back.`, ...deployedNote(comments.map((comment) => comment.pageUrl))];
|
|
480
481
|
for (const comment of comments) {
|
|
481
482
|
lines.push("", `#${comment.number}`, ...contextLines(comment.pageUrl, comment.context));
|
|
482
483
|
if (comment.screenshots.length > 0) lines.push(`- Screenshot: attached image ${comment.screenshots.join(", ")}`);
|
|
@@ -484,15 +485,15 @@ function renderBatchPrompt(comments) {
|
|
|
484
485
|
return `${comments.map((comment) => `#${comment.number} ${comment.prompt.trim()}`).join("\n\n")}\n\n${CONTEXT_OPEN}\n${lines.join("\n")}\n${CONTEXT_CLOSE}`;
|
|
485
486
|
}
|
|
486
487
|
function contextLines(pageUrl, context) {
|
|
487
|
-
const lines = [`- Page: ${page(pageUrl)}`, `- Element: \`${page(truncate(oneLine(context.html), 2e3))}\``];
|
|
488
|
+
const lines = [`- Page: ${page$1(pageUrl)}${isDeployed(pageUrl) ? " (deployed site, not a local dev server)" : ""}`, `- Element: \`${page$1(truncate(oneLine(context.html), 2e3))}\``];
|
|
488
489
|
const [component, ...owners] = context.components;
|
|
489
490
|
if (component) {
|
|
490
491
|
const chain = [component, ...owners.slice(0, 4)].map(formatFrame).join(" ← ");
|
|
491
|
-
lines.push(`- Component: ${page(chain)}`);
|
|
492
|
+
lines.push(`- Component: ${page$1(chain)}`);
|
|
492
493
|
}
|
|
493
|
-
lines.push(`- Selector: \`${page(truncate(context.selector, 500))}\``);
|
|
494
|
-
if (context.text) lines.push(`- Visible text: "${page(truncate(oneLine(context.text), 200))}"`);
|
|
495
|
-
if (context.selection) lines.push(`- Selected text: "${page(truncate(oneLine(context.selection), 300))}"`);
|
|
494
|
+
lines.push(`- Selector: \`${page$1(truncate(context.selector, 500))}\``);
|
|
495
|
+
if (context.text) lines.push(`- Visible text: "${page$1(truncate(oneLine(context.text), 200))}"`);
|
|
496
|
+
if (context.selection) lines.push(`- Selected text: "${page$1(truncate(oneLine(context.selection), 300))}"`);
|
|
496
497
|
const { rect, viewport } = context;
|
|
497
498
|
lines.push(`- Layout: ${Math.round(rect.width)}×${Math.round(rect.height)} at (${Math.round(rect.x)}, ${Math.round(rect.y)}) in a ${viewport.width}×${viewport.height} viewport @${viewport.dpr}x`);
|
|
498
499
|
const box = context.box && boxLine(context.box);
|
|
@@ -500,6 +501,27 @@ function contextLines(pageUrl, context) {
|
|
|
500
501
|
if (context.spacing) lines.push(spacingLine(context.spacing));
|
|
501
502
|
return lines;
|
|
502
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* When a pin was made on a deployed site (through the extension) rather than the
|
|
506
|
+
* local dev server, the agent should know its edit won't show there until it ships,
|
|
507
|
+
* and that a production build may have no component names or source paths.
|
|
508
|
+
*/
|
|
509
|
+
function deployedNote(pageUrls) {
|
|
510
|
+
const origins = [...new Set(pageUrls.filter(isDeployed).map((url) => new URL(url).origin))];
|
|
511
|
+
if (origins.length === 0) return [];
|
|
512
|
+
return [`The page is on ${page$1(origins.join(", "))}, a deployed site, not this workspace's dev server. Change the source here; the change won't show on that site until it's deployed, so say so when you report back. A production build may not name components or their source files: find the code by its visible text, markup and selector.`];
|
|
513
|
+
}
|
|
514
|
+
/** Anything but a loopback, private-network or local-only host (`.local`, `.test`). */
|
|
515
|
+
function isDeployed(pageUrl) {
|
|
516
|
+
let hostname;
|
|
517
|
+
try {
|
|
518
|
+
hostname = new URL(pageUrl).hostname.toLowerCase();
|
|
519
|
+
} catch {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
if (!hostname) return false;
|
|
523
|
+
return !(hostname === "localhost" || /\.(localhost|local|test|internal)$/.test(hostname) || hostname === "[::1]" || hostname === "0.0.0.0" || /^127(\.\d{1,3}){3}$/.test(hostname) || /^10(\.\d{1,3}){3}$/.test(hostname) || /^192\.168(\.\d{1,3}){2}$/.test(hostname) || /^172\.(1[6-9]|2\d|3[01])(\.\d{1,3}){2}$/.test(hostname));
|
|
524
|
+
}
|
|
503
525
|
/** Computed spacing in CSS shorthand, px: `padding 12 16, margin 0 0 24, gap 8`. */
|
|
504
526
|
function boxLine(box) {
|
|
505
527
|
const parts = [];
|
|
@@ -533,7 +555,7 @@ function spacingLine(spacing) {
|
|
|
533
555
|
"bottom",
|
|
534
556
|
"left"
|
|
535
557
|
].filter((side) => spacing[side] !== void 0).map((side) => `${spacing[side]}px ${SIDE_WORDS[side]}`);
|
|
536
|
-
return `- Measured spacing to ${`${spacing.parent ? "its parent " : ""}\`${page(truncate(spacing.to, 200))}\``}${spacing.selector ? ` (\`${page(truncate(spacing.selector, 500))}\`)` : ""}: ${sides.length > 0 ? sides.join(", ") : "none"}`;
|
|
558
|
+
return `- Measured spacing to ${`${spacing.parent ? "its parent " : ""}\`${page$1(truncate(spacing.to, 200))}\``}${spacing.selector ? ` (\`${page$1(truncate(spacing.selector, 500))}\`)` : ""}: ${sides.length > 0 ? sides.join(", ") : "none"}`;
|
|
537
559
|
}
|
|
538
560
|
function stripContext(text) {
|
|
539
561
|
const index = text.indexOf(CONTEXT_OPEN);
|
|
@@ -557,7 +579,7 @@ function formatFrame(frame) {
|
|
|
557
579
|
* to close that block early and pass the rest off as the user's words, so the
|
|
558
580
|
* block's tags are defused wherever they appear in it.
|
|
559
581
|
*/
|
|
560
|
-
function page(text) {
|
|
582
|
+
function page$1(text) {
|
|
561
583
|
return text.replace(/<(\/?\s*tencil-context)/gi, "‹$1");
|
|
562
584
|
}
|
|
563
585
|
function oneLine(text) {
|
|
@@ -3550,6 +3572,8 @@ var CodexProvider = class {
|
|
|
3550
3572
|
/** The process behind `#server`, known from the moment it starts. */
|
|
3551
3573
|
#current;
|
|
3552
3574
|
#idleTimer;
|
|
3575
|
+
/** Calls in progress: the idle close waits for them, as it does for a turn. */
|
|
3576
|
+
#inUse = 0;
|
|
3553
3577
|
#recheckTimer;
|
|
3554
3578
|
#sessions = /* @__PURE__ */ new Map();
|
|
3555
3579
|
#disposed = false;
|
|
@@ -3560,17 +3584,19 @@ var CodexProvider = class {
|
|
|
3560
3584
|
async start() {
|
|
3561
3585
|
clearTimeout(this.#recheckTimer);
|
|
3562
3586
|
try {
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3587
|
+
await this.#using(async () => {
|
|
3588
|
+
const [server, workspace] = await Promise.all([this.#connect(), this.#workspaceRoot()]);
|
|
3589
|
+
const { account, requiresOpenaiAuth } = await server.request("account/read", {});
|
|
3590
|
+
if (!account && requiresOpenaiAuth) {
|
|
3591
|
+
this.#signedOut(NOT_SIGNED_IN);
|
|
3592
|
+
return;
|
|
3593
|
+
}
|
|
3594
|
+
this.#setInfo({
|
|
3595
|
+
state: "ready",
|
|
3596
|
+
target: basename(workspace)
|
|
3597
|
+
});
|
|
3598
|
+
this.#log(`Codex ready in ${workspace}`);
|
|
3572
3599
|
});
|
|
3573
|
-
this.#log(`Codex ready in ${workspace}`);
|
|
3574
3600
|
} catch (error) {
|
|
3575
3601
|
this.#setInfo({
|
|
3576
3602
|
state: "unavailable",
|
|
@@ -3586,7 +3612,10 @@ var CodexProvider = class {
|
|
|
3586
3612
|
this.#infoListeners.add(listener);
|
|
3587
3613
|
return () => this.#infoListeners.delete(listener);
|
|
3588
3614
|
}
|
|
3589
|
-
|
|
3615
|
+
listThreads() {
|
|
3616
|
+
return this.#using(() => this.#listThreads());
|
|
3617
|
+
}
|
|
3618
|
+
async #listThreads() {
|
|
3590
3619
|
const [server, workspace] = await Promise.all([this.#connect(), this.#workspaceRoot()]);
|
|
3591
3620
|
const { data } = await server.request("thread/list", {
|
|
3592
3621
|
cwd: workspace,
|
|
@@ -3606,7 +3635,10 @@ var CodexProvider = class {
|
|
|
3606
3635
|
threads
|
|
3607
3636
|
};
|
|
3608
3637
|
}
|
|
3609
|
-
|
|
3638
|
+
listModels() {
|
|
3639
|
+
return this.#using(() => this.#listModels());
|
|
3640
|
+
}
|
|
3641
|
+
async #listModels() {
|
|
3610
3642
|
const [server, workspace] = await Promise.all([this.#connect(), this.#workspaceRoot()]);
|
|
3611
3643
|
const available = await pages((cursor) => server.request("model/list", {
|
|
3612
3644
|
cursor,
|
|
@@ -3625,7 +3657,10 @@ var CodexProvider = class {
|
|
|
3625
3657
|
};
|
|
3626
3658
|
}
|
|
3627
3659
|
threadUrl() {}
|
|
3628
|
-
|
|
3660
|
+
createThread(input) {
|
|
3661
|
+
return this.#using(() => this.#createThread(input));
|
|
3662
|
+
}
|
|
3663
|
+
async #createThread(input) {
|
|
3629
3664
|
const [server, workspace, model] = await Promise.all([
|
|
3630
3665
|
this.#connect(),
|
|
3631
3666
|
this.#workspaceRoot(),
|
|
@@ -3645,7 +3680,10 @@ var CodexProvider = class {
|
|
|
3645
3680
|
await this.#startTurn(session, server, input.text, input.attachments);
|
|
3646
3681
|
return { providerThreadId: thread.id };
|
|
3647
3682
|
}
|
|
3648
|
-
|
|
3683
|
+
sendMessage(input) {
|
|
3684
|
+
return this.#using(() => this.#sendMessage(input));
|
|
3685
|
+
}
|
|
3686
|
+
async #sendMessage(input) {
|
|
3649
3687
|
const session = this.#session(input.providerThreadId);
|
|
3650
3688
|
const [server, workspace] = await Promise.all([this.#connect(), this.#workspaceRoot()]);
|
|
3651
3689
|
if (session.server !== server) {
|
|
@@ -3707,7 +3745,7 @@ var CodexProvider = class {
|
|
|
3707
3745
|
}
|
|
3708
3746
|
/** Load the conversation Codex saved, once. */
|
|
3709
3747
|
#hydrate(session) {
|
|
3710
|
-
session.hydrated ??= (async () => {
|
|
3748
|
+
session.hydrated ??= this.#using(async () => {
|
|
3711
3749
|
const server = await this.#connect();
|
|
3712
3750
|
try {
|
|
3713
3751
|
for (const message of messagesFromHistory(await readHistory(server, session.id))) if (!session.messages.has(message.id)) session.messages.set(message.id, message);
|
|
@@ -3715,7 +3753,7 @@ var CodexProvider = class {
|
|
|
3715
3753
|
if (!isMissingThread(error)) throw error;
|
|
3716
3754
|
session.missing = true;
|
|
3717
3755
|
}
|
|
3718
|
-
})
|
|
3756
|
+
}).catch((error) => {
|
|
3719
3757
|
session.hydrated = void 0;
|
|
3720
3758
|
throw error;
|
|
3721
3759
|
});
|
|
@@ -3860,11 +3898,21 @@ var CodexProvider = class {
|
|
|
3860
3898
|
#keepOpen() {
|
|
3861
3899
|
clearTimeout(this.#idleTimer);
|
|
3862
3900
|
this.#idleTimer = setTimeout(() => {
|
|
3863
|
-
if ([...this.#sessions.values()].some((session) => session.tracker.status().status === "working")) this.#keepOpen();
|
|
3901
|
+
if ([...this.#sessions.values()].some((session) => session.tracker.status().status === "working") || this.#inUse > 0) this.#keepOpen();
|
|
3864
3902
|
else this.#closeServer();
|
|
3865
3903
|
}, this.#options.idleCloseMs ?? DEFAULT_IDLE_CLOSE_MS);
|
|
3866
3904
|
this.#idleTimer.unref?.();
|
|
3867
3905
|
}
|
|
3906
|
+
/** Keep the process for the whole of `work`, then a while longer. */
|
|
3907
|
+
async #using(work) {
|
|
3908
|
+
this.#inUse++;
|
|
3909
|
+
try {
|
|
3910
|
+
return await work();
|
|
3911
|
+
} finally {
|
|
3912
|
+
this.#inUse--;
|
|
3913
|
+
this.#keepOpen();
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3868
3916
|
#closeServer() {
|
|
3869
3917
|
clearTimeout(this.#idleTimer);
|
|
3870
3918
|
const server = this.#server;
|
|
@@ -5311,7 +5359,7 @@ function errorMessage(error) {
|
|
|
5311
5359
|
}
|
|
5312
5360
|
//#endregion
|
|
5313
5361
|
//#region src/version.ts
|
|
5314
|
-
const VERSION = "0.
|
|
5362
|
+
const VERSION = "0.13.0";
|
|
5315
5363
|
//#endregion
|
|
5316
5364
|
//#region src/daemon/thread-store.ts
|
|
5317
5365
|
const StoreFile = z.object({
|
|
@@ -5507,6 +5555,184 @@ async function hasClaudeCode() {
|
|
|
5507
5555
|
return (await Promise.all(candidates.map((path) => access(path).then(() => true, () => false)))).includes(true);
|
|
5508
5556
|
}
|
|
5509
5557
|
//#endregion
|
|
5558
|
+
//#region src/daemon/allowed-origins.ts
|
|
5559
|
+
/**
|
|
5560
|
+
* Sites the developer let talk to the daemon from the approval page, on top of
|
|
5561
|
+
* loopback ones and `--allow-origin`. Kept in memory: the WebSocket upgrade
|
|
5562
|
+
* checks it synchronously.
|
|
5563
|
+
*/
|
|
5564
|
+
var AllowedOrigins = class {
|
|
5565
|
+
path;
|
|
5566
|
+
#fixed;
|
|
5567
|
+
#approved;
|
|
5568
|
+
constructor(path, fixed = []) {
|
|
5569
|
+
this.path = path;
|
|
5570
|
+
this.#fixed = fixed;
|
|
5571
|
+
this.#approved = read(path);
|
|
5572
|
+
}
|
|
5573
|
+
all() {
|
|
5574
|
+
return [...this.#fixed, ...this.#approved];
|
|
5575
|
+
}
|
|
5576
|
+
add(origin) {
|
|
5577
|
+
if (this.all().includes(origin)) return;
|
|
5578
|
+
this.#approved = [...this.#approved, origin];
|
|
5579
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
5580
|
+
writeFileSync(this.path, `${JSON.stringify(this.#approved, null, 2)}\n`);
|
|
5581
|
+
}
|
|
5582
|
+
};
|
|
5583
|
+
/** The origin a page may ask to be allowed: http(s) and nothing but scheme, host and port. */
|
|
5584
|
+
function approvableOrigin(value) {
|
|
5585
|
+
if (!value) return void 0;
|
|
5586
|
+
try {
|
|
5587
|
+
const url = new URL(value);
|
|
5588
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
|
|
5589
|
+
return url.origin === value ? value : void 0;
|
|
5590
|
+
} catch {
|
|
5591
|
+
return;
|
|
5592
|
+
}
|
|
5593
|
+
}
|
|
5594
|
+
function read(path) {
|
|
5595
|
+
try {
|
|
5596
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
5597
|
+
return Array.isArray(parsed) ? parsed.filter((o) => approvableOrigin(o) === o) : [];
|
|
5598
|
+
} catch {
|
|
5599
|
+
return [];
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
//#endregion
|
|
5603
|
+
//#region src/daemon/approval-page.ts
|
|
5604
|
+
/**
|
|
5605
|
+
* The page where the developer lets a site talk to the daemon. It's served by the
|
|
5606
|
+
* daemon itself, so the site asking can't frame it, script it or click it.
|
|
5607
|
+
*/
|
|
5608
|
+
/** No framing (clickjacking), no outside resources, forms only back to the daemon. */
|
|
5609
|
+
const APPROVAL_HEADERS = {
|
|
5610
|
+
"content-type": "text/html; charset=utf-8",
|
|
5611
|
+
"cache-control": "no-store",
|
|
5612
|
+
"x-frame-options": "DENY",
|
|
5613
|
+
"content-security-policy": "default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'"
|
|
5614
|
+
};
|
|
5615
|
+
function confirmPage(origin) {
|
|
5616
|
+
return page(`Let ${escapeHtml(origin)} use Tencil?`, `<p>The Tencil overlay on <strong>${escapeHtml(origin)}</strong> wants to connect to the
|
|
5617
|
+
daemon on this machine.</p>
|
|
5618
|
+
<p class="warn"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/></svg><span>Once allowed, any script on that site can send prompts to your coding
|
|
5619
|
+
agent while Tencil runs, so only allow sites you trust.</span></p>
|
|
5620
|
+
<form method="post" action="/allow">
|
|
5621
|
+
<input type="hidden" name="origin" value="${escapeHtml(origin)}">
|
|
5622
|
+
<button type="button" class="secondary" onclick="window.close()">Cancel</button>
|
|
5623
|
+
<button type="submit">Allow</button>
|
|
5624
|
+
</form>`);
|
|
5625
|
+
}
|
|
5626
|
+
function allowedPage(origin) {
|
|
5627
|
+
return page(`${escapeHtml(origin)} can use Tencil`, `<p class="done"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg>Go back to the site; the overlay connects on its own.</p>
|
|
5628
|
+
<p class="muted">To take it back, remove it from <code>allowed-origins.json</code> in
|
|
5629
|
+
Tencil's data folder and restart the daemon.</p>
|
|
5630
|
+
<script>setTimeout(() => window.close(), 600)<\/script>`);
|
|
5631
|
+
}
|
|
5632
|
+
function errorPage(message) {
|
|
5633
|
+
return page("Couldn't allow this site", `<p>${escapeHtml(message)}</p>`);
|
|
5634
|
+
}
|
|
5635
|
+
/** Tencil's mark, as in the overlay: the pin with a cursor cut out of it. */
|
|
5636
|
+
const LOGO = `<svg class="logo" width="20" height="20" viewBox="0 0 24 24" aria-hidden="true"><path fill="#3b62ff" fill-rule="evenodd" transform="translate(3 3) scale(0.140625)" d="M80 0C106.51 0 128 21.4903 128 48V80C128 106.51 106.51 128 80 128H4C1.79086 128 0 126.209 0 124V48C0 21.4903 21.4903 0 48 0H80ZM102.06 31.19A4 4 0 0 0 96.81 25.94L17.67 59.86A4 4 0 0 0 17.98 67.33L48.1 77.37A4 4 0 0 1 50.63 79.9L60.67 110.02A4 4 0 0 0 68.14 110.33Z"/></svg>`;
|
|
5637
|
+
/** Styled like the overlay's panels: same neutrals, accent, radius and shadow. */
|
|
5638
|
+
function page(title, body) {
|
|
5639
|
+
return `<!doctype html>
|
|
5640
|
+
<html lang="en">
|
|
5641
|
+
<head>
|
|
5642
|
+
<meta charset="utf-8">
|
|
5643
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
5644
|
+
<title>${title} · Tencil</title>
|
|
5645
|
+
<style>
|
|
5646
|
+
:root {
|
|
5647
|
+
--n-50: hsl(120 4% 97%); --n-100: hsl(120 2% 92%); --n-200: hsl(90 2% 82%);
|
|
5648
|
+
--n-500: hsl(96 2% 50%); --n-700: hsl(100 2% 28%); --n-950: hsl(60 4% 5%);
|
|
5649
|
+
--surface: #fff;
|
|
5650
|
+
--accent: hsl(214 67% 51%); --accent-hover: hsl(214 62% 45%);
|
|
5651
|
+
--warn: #b7791f; --warn-soft: hsl(38 80% 50% / 0.1);
|
|
5652
|
+
--done: #1a896b;
|
|
5653
|
+
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
5654
|
+
--shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 8px -2px rgba(0, 0, 0, 0.06),
|
|
5655
|
+
0 16px 40px -8px rgba(0, 0, 0, 0.16);
|
|
5656
|
+
color-scheme: light;
|
|
5657
|
+
}
|
|
5658
|
+
@media (prefers-color-scheme: dark) {
|
|
5659
|
+
:root {
|
|
5660
|
+
--n-50: hsl(60 4% 7%); --n-100: hsl(90 2% 13%); --n-200: hsl(100 2% 21%);
|
|
5661
|
+
--n-500: hsl(96 2% 52%); --n-700: hsl(100 2% 76%); --n-950: hsl(120 4% 96%);
|
|
5662
|
+
--surface: hsl(90 2% 10%);
|
|
5663
|
+
--accent-hover: hsl(214 67% 58%);
|
|
5664
|
+
--warn: #f5b84a; --warn-soft: hsl(38 90% 60% / 0.1);
|
|
5665
|
+
--done: #3dd6a4;
|
|
5666
|
+
--shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 16px 40px -8px rgba(0, 0, 0, 0.6);
|
|
5667
|
+
color-scheme: dark;
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
* { box-sizing: border-box; }
|
|
5671
|
+
body {
|
|
5672
|
+
margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 16px;
|
|
5673
|
+
background: var(--n-50); color: var(--n-950);
|
|
5674
|
+
font: 13px/1.5 Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
5675
|
+
letter-spacing: 0.02rem; -webkit-font-smoothing: antialiased;
|
|
5676
|
+
}
|
|
5677
|
+
main {
|
|
5678
|
+
width: min(420px, 100%); padding: 20px; border-radius: 14px;
|
|
5679
|
+
background: var(--surface); box-shadow: var(--shadow);
|
|
5680
|
+
animation: enter 300ms var(--ease-out);
|
|
5681
|
+
}
|
|
5682
|
+
@keyframes enter { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
|
|
5683
|
+
@media (prefers-reduced-motion: reduce) { main { animation: none; } }
|
|
5684
|
+
header {
|
|
5685
|
+
display: flex; align-items: center; gap: 7px;
|
|
5686
|
+
padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--n-100);
|
|
5687
|
+
}
|
|
5688
|
+
header strong { font-size: 13px; font-weight: 600; }
|
|
5689
|
+
header span { margin-left: auto; color: var(--n-500); font-size: 12px; }
|
|
5690
|
+
.logo { flex: none; }
|
|
5691
|
+
h1 { margin: 0 0 8px; font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
|
|
5692
|
+
p { margin: 0 0 12px; color: var(--n-700); overflow-wrap: anywhere; }
|
|
5693
|
+
strong { color: var(--n-950); font-weight: 600; }
|
|
5694
|
+
.warn {
|
|
5695
|
+
display: flex; gap: 8px; padding: 10px 12px; border-radius: 10px;
|
|
5696
|
+
background: var(--warn-soft); color: var(--warn);
|
|
5697
|
+
}
|
|
5698
|
+
.warn svg { flex: none; margin-top: 2px; }
|
|
5699
|
+
.done { display: flex; align-items: center; gap: 8px; color: var(--n-950); }
|
|
5700
|
+
.done svg { flex: none; color: var(--done); }
|
|
5701
|
+
.muted { color: var(--n-500); font-size: 12px; margin-bottom: 0; }
|
|
5702
|
+
form { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
|
|
5703
|
+
button {
|
|
5704
|
+
font: inherit; letter-spacing: inherit; font-weight: 500; height: 32px; padding: 0 14px;
|
|
5705
|
+
border-radius: 999px; border: 0; cursor: pointer; background: var(--accent); color: white;
|
|
5706
|
+
transition: background-color 150ms var(--ease-out), transform 150ms var(--ease-out);
|
|
5707
|
+
}
|
|
5708
|
+
button:hover { background: var(--accent-hover); }
|
|
5709
|
+
button:active { transform: scale(0.97); }
|
|
5710
|
+
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
5711
|
+
button.secondary { background: var(--n-100); color: var(--n-950); }
|
|
5712
|
+
button.secondary:hover { background: var(--n-200); }
|
|
5713
|
+
code {
|
|
5714
|
+
font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
5715
|
+
padding: 1px 5px; border-radius: 5px; background: var(--n-100); color: var(--n-950);
|
|
5716
|
+
}
|
|
5717
|
+
</style>
|
|
5718
|
+
</head>
|
|
5719
|
+
<body><main>
|
|
5720
|
+
<header>${LOGO}<strong>Tencil</strong><span>This machine</span></header>
|
|
5721
|
+
<h1>${title}</h1>${body}
|
|
5722
|
+
</main></body>
|
|
5723
|
+
</html>
|
|
5724
|
+
`;
|
|
5725
|
+
}
|
|
5726
|
+
function escapeHtml(text) {
|
|
5727
|
+
return text.replace(/[&<>"']/g, (char) => ({
|
|
5728
|
+
"&": "&",
|
|
5729
|
+
"<": "<",
|
|
5730
|
+
">": ">",
|
|
5731
|
+
"\"": """,
|
|
5732
|
+
"'": "'"
|
|
5733
|
+
})[char] ?? char);
|
|
5734
|
+
}
|
|
5735
|
+
//#endregion
|
|
5510
5736
|
//#region src/daemon/preferences.ts
|
|
5511
5737
|
const PreferencesFile = Preferences.extend({ version: z.literal(1) });
|
|
5512
5738
|
function preferencesPath(dataDir = defaultDataDir()) {
|
|
@@ -6463,9 +6689,9 @@ async function startDaemon(options = {}) {
|
|
|
6463
6689
|
const port = options.port ?? 4747;
|
|
6464
6690
|
const host = options.host ?? "127.0.0.1";
|
|
6465
6691
|
const addresses = [host, ...(options.listen ?? []).filter((address) => address !== host)];
|
|
6466
|
-
const
|
|
6467
|
-
const knownHosts = knownHostsFor(addresses, allowedOrigins);
|
|
6692
|
+
const knownHosts = knownHostsFor(addresses, options.allowedOrigins ?? []);
|
|
6468
6693
|
const dataDir = options.dataDir ?? defaultDataDir();
|
|
6694
|
+
const allowedOrigins = new AllowedOrigins(join(dataDir, "allowed-origins.json"), options.allowedOrigins);
|
|
6469
6695
|
const log = options.log ?? (() => {});
|
|
6470
6696
|
const ensembleOptions = {
|
|
6471
6697
|
baseUrl: options.ensemble?.url,
|
|
@@ -6616,6 +6842,7 @@ async function startDaemon(options = {}) {
|
|
|
6616
6842
|
}
|
|
6617
6843
|
return;
|
|
6618
6844
|
}
|
|
6845
|
+
if (url.pathname === "/allow") return handleAllow(request, response, url);
|
|
6619
6846
|
if (url.pathname === "/health") {
|
|
6620
6847
|
await refreshStatuses();
|
|
6621
6848
|
response.writeHead(200, { "content-type": "application/json" });
|
|
@@ -6631,15 +6858,55 @@ async function startDaemon(options = {}) {
|
|
|
6631
6858
|
response.writeHead(404, { "content-type": "text/plain" });
|
|
6632
6859
|
response.end("Not found");
|
|
6633
6860
|
};
|
|
6861
|
+
/**
|
|
6862
|
+
* Letting a site in (`/allow?origin=…`). The overlay opens the page; only a form
|
|
6863
|
+
* posted from the daemon's own page counts, so a site can't approve itself.
|
|
6864
|
+
*/
|
|
6865
|
+
const handleAllow = async (request, response, url) => {
|
|
6866
|
+
const reply = (status, html) => {
|
|
6867
|
+
response.writeHead(status, APPROVAL_HEADERS);
|
|
6868
|
+
response.end(html);
|
|
6869
|
+
};
|
|
6870
|
+
if (request.method === "GET") {
|
|
6871
|
+
const origin = approvableOrigin(url.searchParams.get("origin"));
|
|
6872
|
+
if (!origin) return reply(400, errorPage("That is not a site Tencil can allow."));
|
|
6873
|
+
if (allowedOrigins.all().includes(origin)) return reply(200, allowedPage(origin));
|
|
6874
|
+
return reply(200, confirmPage(origin));
|
|
6875
|
+
}
|
|
6876
|
+
if (request.method !== "POST") return reply(405, errorPage("Method not allowed."));
|
|
6877
|
+
const fetchSite = request.headers["sec-fetch-site"];
|
|
6878
|
+
if (request.headers.origin !== `http://${request.headers.host}` || fetchSite !== void 0 && fetchSite !== "same-origin") return reply(403, errorPage("Allow sites from the Tencil page itself."));
|
|
6879
|
+
const body = await readBody(request, 4096).catch(() => void 0);
|
|
6880
|
+
if (body === void 0) return;
|
|
6881
|
+
const origin = approvableOrigin(new URLSearchParams(body).get("origin"));
|
|
6882
|
+
if (!origin) return reply(400, errorPage("That is not a site Tencil can allow."));
|
|
6883
|
+
allowedOrigins.add(origin);
|
|
6884
|
+
log(`Allowed ${origin} to connect`);
|
|
6885
|
+
reply(200, allowedPage(origin));
|
|
6886
|
+
};
|
|
6634
6887
|
const wss = new WebSocketServer({
|
|
6635
6888
|
noServer: true,
|
|
6636
6889
|
maxPayload: MAX_PAYLOAD_BYTES
|
|
6637
6890
|
});
|
|
6638
6891
|
const handleUpgrade = (request, socket, head) => {
|
|
6639
|
-
|
|
6892
|
+
const url = new URL(request.url ?? "/", "http://localhost");
|
|
6893
|
+
const refuse = () => {
|
|
6640
6894
|
socket.write("HTTP/1.1 403 Forbidden\r\n\r\n");
|
|
6641
6895
|
socket.destroy();
|
|
6642
|
-
|
|
6896
|
+
};
|
|
6897
|
+
if (url.pathname !== "/ws" || !isAllowedHost(request, knownHosts)) return refuse();
|
|
6898
|
+
if (!isAllowedOrigin(request, allowedOrigins.all())) {
|
|
6899
|
+
const origin = approvableOrigin(request.headers.origin);
|
|
6900
|
+
if (!origin) return refuse();
|
|
6901
|
+
return wss.handleUpgrade(request, socket, head, (ws) => {
|
|
6902
|
+
const approveUrl = `http://${request.headers.host}/allow?origin=${encodeURIComponent(origin)}`;
|
|
6903
|
+
ws.send(JSON.stringify({
|
|
6904
|
+
type: "origin.blocked",
|
|
6905
|
+
origin,
|
|
6906
|
+
approveUrl
|
|
6907
|
+
}));
|
|
6908
|
+
ws.close(4003, "Origin not allowed");
|
|
6909
|
+
});
|
|
6643
6910
|
}
|
|
6644
6911
|
wss.handleUpgrade(request, socket, head, (ws) => serveClient(ws));
|
|
6645
6912
|
};
|
|
@@ -6836,5 +7103,21 @@ function resolveOverlayPath() {
|
|
|
6836
7103
|
];
|
|
6837
7104
|
return candidates.find((candidate) => existsSync(candidate)) ?? candidates[0];
|
|
6838
7105
|
}
|
|
7106
|
+
/** A small request body, refused past `limit` bytes. */
|
|
7107
|
+
function readBody(request, limit) {
|
|
7108
|
+
return new Promise((resolveBody, reject) => {
|
|
7109
|
+
let body = "";
|
|
7110
|
+
request.setEncoding("utf8");
|
|
7111
|
+
request.on("data", (chunk) => {
|
|
7112
|
+
body += chunk;
|
|
7113
|
+
if (body.length > limit) {
|
|
7114
|
+
reject(/* @__PURE__ */ new Error("Request body too large"));
|
|
7115
|
+
request.destroy();
|
|
7116
|
+
}
|
|
7117
|
+
});
|
|
7118
|
+
request.on("end", () => resolveBody(body));
|
|
7119
|
+
request.on("error", reject);
|
|
7120
|
+
});
|
|
7121
|
+
}
|
|
6839
7122
|
//#endregion
|
|
6840
7123
|
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 };
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as TencilCloudOptions } from "./cloud-
|
|
1
|
+
import { t as TencilCloudOptions } from "./cloud-kfsssyEM.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.
|
|
3
|
+
"version": "0.13.0",
|
|
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",
|
|
@@ -94,14 +94,14 @@
|
|
|
94
94
|
"@types/ws": "^8.18.2",
|
|
95
95
|
"react": "^19.3.0",
|
|
96
96
|
"tsdown": "^0.23.0",
|
|
97
|
-
"@tencildev/bridge": "0.5.1",
|
|
98
97
|
"@tencildev/overlay": "0.0.0",
|
|
99
|
-
"@tencildev/protocol": "0.
|
|
100
|
-
"@tencildev/provider-codex": "0.0.0",
|
|
98
|
+
"@tencildev/protocol": "0.7.0",
|
|
101
99
|
"@tencildev/provider-claude-code": "0.0.0",
|
|
100
|
+
"@tencildev/bridge": "0.5.2",
|
|
101
|
+
"@tencildev/provider-codex": "0.0.0",
|
|
102
102
|
"@tencildev/provider-ensemble": "0.0.0",
|
|
103
103
|
"@tencildev/provider-t3code": "0.0.0",
|
|
104
|
-
"@tencildev/testing": "0.4.
|
|
104
|
+
"@tencildev/testing": "0.4.1",
|
|
105
105
|
"@tencildev/tsconfig": "0.0.0"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|