tencil 0.7.0 → 0.9.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.
@@ -216,6 +216,7 @@ declare const Thread: z.ZodObject<{
216
216
  id: z.ZodString;
217
217
  threadId: z.ZodOptional<z.ZodString>;
218
218
  url: z.ZodOptional<z.ZodString>;
219
+ archivable: z.ZodOptional<z.ZodBoolean>;
219
220
  }, z.core.$strip>;
220
221
  delivery: z.ZodOptional<z.ZodObject<{
221
222
  status: z.ZodEnum<{
@@ -319,6 +320,20 @@ interface Viewer {
319
320
  /** `read`: can see pins, not make or answer them (no write access to the repository). */
320
321
  access: 'write' | 'read';
321
322
  }
323
+ /**
324
+ * The daemon's own updates (local only; Tencil Cloud leaves it out). `latest`
325
+ * is set when a newer Tencil is published. `state` walks through an update
326
+ * started from the overlay: installing it, waiting for running threads,
327
+ * restarting on it, or failed (the old version keeps running).
328
+ */
329
+ interface UpdateStatus {
330
+ latest?: string;
331
+ state: 'idle' | 'installing' | 'waiting' | 'restarting' | 'failed';
332
+ /** `waiting`: how many threads are still running. */
333
+ running?: number;
334
+ /** `failed`: what went wrong. */
335
+ error?: string;
336
+ }
322
337
  declare const ProviderInfo: z.ZodObject<{
323
338
  id: z.ZodString;
324
339
  label: z.ZodString;
@@ -365,6 +380,13 @@ type ServerMessage = {
365
380
  threads: Thread[];
366
381
  /** Tencil Cloud only: who is signed in. */
367
382
  viewer?: Viewer;
383
+ /** Local daemon only: the latest version and any update in progress. */
384
+ update?: UpdateStatus;
385
+ } |
386
+ /** The update status changed: a check found a newer version, or an update moved on. */
387
+ {
388
+ type: 'update';
389
+ update: UpdateStatus;
368
390
  } |
369
391
  /** Tencil Cloud: sign in first (no token, or one it no longer accepts). */
370
392
  {
@@ -440,6 +462,10 @@ interface Provider {
440
462
  createThread(input: CreateThreadInput): Promise<CreatedThread>;
441
463
  sendMessage(input: SendMessageInput): Promise<void>;
442
464
  interrupt(providerThreadId: string): Promise<void>;
465
+ /** Archive a thread `createThread` marked `archivable`, once its pins are resolved. Optional. */
466
+ archive?(providerThreadId: string): Promise<void>;
467
+ /** Bring an archived thread back, for a pin reopened or replied to. */
468
+ reopen?(providerThreadId: string): Promise<void>;
443
469
  /**
444
470
  * Stream updates for a thread. Called right after `createThread` and again
445
471
  * for every persisted thread when the bridge restarts. The provider should
@@ -463,6 +489,8 @@ interface ProviderModels {
463
489
  interface CreatedThread {
464
490
  providerThreadId: string;
465
491
  url?: string;
492
+ /** The provider started this thread for the pin alone, so resolving the pin may archive it. */
493
+ archivable?: boolean;
466
494
  }
467
495
  interface SendMessageInput {
468
496
  providerThreadId: string;
@@ -488,4 +516,4 @@ interface ThreadSink {
488
516
  step?(step: ThreadStep): void;
489
517
  }
490
518
  //#endregion
491
- export { Thread as a, Viewer as i, ProviderOption as n, ElementContext as o, ServerMessage as r, Provider as t };
519
+ export { Viewer as a, UpdateStatus as i, ProviderOption as n, Thread as o, ServerMessage as r, ElementContext as s, Provider as t };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Thread, i as Viewer, n as ProviderOption, o as ElementContext, r as ServerMessage, t as Provider } from "./index-BRcZL2Ov.mjs";
1
+ import { a as Viewer, i as UpdateStatus, n as ProviderOption, o as Thread, r as ServerMessage, s as ElementContext, t as Provider } from "./index-CexSk5_J.mjs";
2
2
  //#region ../bridge/src/project-providers.d.ts
3
3
  /** What a project picked in the overlay's settings. */
4
4
  interface SavedProjectSettings {
@@ -95,6 +95,11 @@ interface BridgeOptions {
95
95
  root: string;
96
96
  };
97
97
  version: string;
98
+ /**
99
+ * The host's own updates, sent in `ready`. The local daemon has them (and
100
+ * handles `update.start` itself); Tencil Cloud doesn't.
101
+ */
102
+ update?: () => UpdateStatus;
98
103
  log?: (message: string) => void;
99
104
  }
100
105
  /**
@@ -126,11 +131,17 @@ export declare function stripContext(text: string): string;
126
131
  //#region src/daemon/project-resolver.d.ts
127
132
  /** Runs a command and returns stdout; injectable so tests don't depend on the OS. */
128
133
  type Exec = (command: string, args: string[]) => Promise<string>;
134
+ /** The `ensemble://thread/<id>` root of the Ensemble thread whose dev server listens on `port`. */
135
+ type EnsembleForPort = (port: number) => Promise<string | undefined>;
129
136
  /**
130
137
  * Works out which project folder a page belongs to:
131
- * 1. what the user picked for this address before,
132
- * 2. the dev server's working directory, found from the port it listens on.
133
- * Returns undefined when neither works; the overlay then asks.
138
+ * 1. the Ensemble thread whose dev server listens on the port,
139
+ * 2. the repository root the Vite or Next loader sent, if it's a git checkout,
140
+ * 3. the dev server's working directory, found from the port it listens on,
141
+ * 4. what the user picked for this address before (a folder or an Ensemble thread).
142
+ * Picks come last: ports get reused (5173 is every Vite app's default), so a pick
143
+ * only stands in for what can't be detected. Returns undefined when nothing works;
144
+ * the overlay then asks.
134
145
  */
135
146
  export declare class ProjectResolver {
136
147
  #private;
@@ -138,11 +149,15 @@ export declare class ProjectResolver {
138
149
  dataDir: string;
139
150
  exec?: Exec;
140
151
  platform?: NodeJS.Platform;
152
+ ensembleForPort?: EnsembleForPort;
141
153
  });
142
- resolve(pageUrl: string): Promise<string | undefined>;
154
+ resolve(pageUrl: string, claimedRoot?: string): Promise<string | undefined>;
143
155
  /** Remember the user's choice for an address (from the overlay's project picker). */
144
156
  remember(pageUrl: string, root: string): Promise<void>;
145
- /** Folder of the process listening on `port`: its working directory, or its script's package. */
157
+ /**
158
+ * Folder of the process listening on `port`: its working directory, or its script's
159
+ * package. When Docker publishes the port, the compose project of the container.
160
+ */
146
161
  folderForPort(port: number): Promise<string | undefined>;
147
162
  }
148
163
  /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
@@ -152,6 +167,16 @@ export declare function projectRoot(folder: string): string;
152
167
  /** The permission modes that work without anyone at a terminal to answer prompts. */
153
168
  type PermissionMode = 'default' | 'acceptEdits' | 'auto' | 'bypassPermissions';
154
169
  //#endregion
170
+ //#region ../provider-ensemble/src/auth.d.ts
171
+ /** The tokens Ensemble gave Tencil, per Ensemble URL, readable only by this user. */
172
+ declare class EnsembleCredentialStore {
173
+ #private;
174
+ readonly path: string;
175
+ constructor(path?: string);
176
+ get(baseUrl: string): Promise<string | undefined>;
177
+ set(baseUrl: string, token: string): Promise<void>;
178
+ }
179
+ //#endregion
155
180
  //#region ../provider-t3code/src/auth.d.ts
156
181
  interface StoredCredential {
157
182
  token: string;
@@ -205,9 +230,42 @@ interface T3CodeProviderOptions {
205
230
  }
206
231
  //#endregion
207
232
  //#region src/daemon/agents.d.ts
208
- declare const PROVIDERS: readonly ["t3code", "claude-code"];
233
+ declare const PROVIDERS: readonly ["t3code", "claude-code", "ensemble"];
209
234
  type ProviderName = (typeof PROVIDERS)[number];
210
235
  //#endregion
236
+ //#region src/service/self-update.d.ts
237
+ /** Installs a package spec into a folder, like `npm install --prefix dir spec`. */
238
+ type Installer = (spec: string, dir: string) => Promise<void>;
239
+ /** What the helper needs to move the daemon on `port` to the staged `version`. */
240
+ interface UpdatePlan {
241
+ version: string;
242
+ port: number;
243
+ dataDir: string;
244
+ node: string;
245
+ /** The running daemon's flags, kept by the new one. */
246
+ flags: string[];
247
+ /** The CLI the running daemon was started from, to go back to on failure. */
248
+ previousCli: string;
249
+ }
250
+ //#endregion
251
+ //#region src/daemon/updates.d.ts
252
+ interface UpdateOptions {
253
+ /** Ask the registry at all. Defaults to on, unless opted out (`updateChecksDisabled`). */
254
+ check?: boolean;
255
+ /** Registry base URL; defaults to `registryUrl()`. */
256
+ registry?: string;
257
+ /** Between checks; a failed one is retried sooner. Defaults to a day. */
258
+ intervalMs?: number;
259
+ /** Installs the new version (tests fake it); defaults to npm. */
260
+ install?: Installer;
261
+ /** Starts the helper that restarts the daemon (tests fake it). */
262
+ handOff?: (plan: UpdatePlan) => void;
263
+ /** How often to look again while threads are running. */
264
+ idlePollMs?: number;
265
+ /** How long to wait for the helper to replace this daemon before giving up. */
266
+ restartTimeoutMs?: number;
267
+ }
268
+ //#endregion
211
269
  //#region src/daemon/server.d.ts
212
270
  export declare const DEFAULT_PORT = 4747;
213
271
  interface DaemonOptions {
@@ -229,6 +287,11 @@ interface DaemonOptions {
229
287
  model?: string;
230
288
  permissionMode?: PermissionMode;
231
289
  };
290
+ /** Ensemble's public local API. */
291
+ ensemble?: {
292
+ url?: string;
293
+ credentials?: EnsembleCredentialStore;
294
+ };
232
295
  t3?: Pick<T3CodeProviderOptions, 'autoPair' | 'createPairingCode' | 'timeouts'> & {
233
296
  url?: string;
234
297
  token?: string;
@@ -238,7 +301,7 @@ interface DaemonOptions {
238
301
  createProjectIfMissing?: boolean;
239
302
  };
240
303
  /** Overrides how pages map to projects (tests). */
241
- resolveProject?: (pageUrl: string) => Promise<string | undefined>;
304
+ resolveProject?: (pageUrl: string, root?: string) => Promise<string | undefined>;
242
305
  /** Overrides process lookups for the default resolver (tests). */
243
306
  exec?: Exec;
244
307
  /** Build a project's provider by id (tests). */
@@ -246,6 +309,10 @@ interface DaemonOptions {
246
309
  log?: (message: string) => void;
247
310
  /** The CLI flags this daemon runs with, reported on /health so a restart can keep them. */
248
311
  flags?: string[];
312
+ /** The CLI entry this daemon runs from; updating from the overlay needs it. */
313
+ cli?: string;
314
+ /** Update checks and the overlay's Update button (fakes in tests). */
315
+ updates?: UpdateOptions;
249
316
  }
250
317
  interface ProjectStatus {
251
318
  root: string;
@@ -258,6 +325,8 @@ interface Daemon {
258
325
  scriptUrl: string;
259
326
  port: number;
260
327
  projects(): ProjectStatus[];
328
+ /** Look for a new Tencil now instead of at the next daily check. */
329
+ checkForUpdates(): Promise<void>;
261
330
  close(): Promise<void>;
262
331
  }
263
332
  /**
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { C as renderPrompt, S as Bridge, b as ProjectResolver, d as projectStorePath, l as FileThreadStore, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, u as defaultDataDir, w as stripContext, x as projectRoot } from "./server-1L4Fi2wN.mjs";
1
+ import { C as projectStorePath, I as Bridge, L as renderPrompt, M as ProjectResolver, N as projectRoot, R as stripContext, S as defaultDataDir, n as probeDaemon, r as startDaemon, t as DEFAULT_PORT, x as FileThreadStore } from "./server-4YposP38.mjs";
2
2
  export { Bridge, DEFAULT_PORT, ProjectResolver, FileThreadStore as ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
@@ -5,11 +5,16 @@ const DEFAULT_DAEMON_PORT = 4747;
5
5
  * Browser code that loads the overlay from the daemon on the machine serving
6
6
  * the page: `localhost:4747` for a local dev server, `devbox:4747` for one
7
7
  * opened as http://devbox:3000. The daemon always speaks plain HTTP.
8
+ *
9
+ * `root` is the repository the dev server runs in; the daemon uses it to find
10
+ * the page's project when no Node process in that folder serves the page
11
+ * (Laravel on Sail or Herd, a backend behind a proxy).
8
12
  */
9
- function overlayLoader(port = DEFAULT_DAEMON_PORT) {
13
+ function overlayLoader(port = DEFAULT_DAEMON_PORT, root) {
14
+ const query = root ? `?root=${encodeURIComponent(root)}` : "";
10
15
  return `;(() => {
11
16
  if (typeof document === "undefined") return;
12
- const src = "http://" + location.hostname + ":${Number(port)}/tencil.js";
17
+ const src = "http://" + location.hostname + ":${Number(port)}/tencil.js${query}";
13
18
  if (document.querySelector('script[src="' + src + '"]')) return;
14
19
  const script = document.createElement("script");
15
20
  script.src = src;
package/dist/next.d.mts CHANGED
@@ -1,10 +1,13 @@
1
- import { t as TencilCloudOptions } from "./cloud-jOobzTY9.mjs";
1
+ import { t as TencilCloudOptions } from "./cloud-dXtv3DCr.mjs";
2
2
  //#region src/integrations/next.d.ts
3
3
  /**
4
4
  * Wrap `next.config` for Tencil Cloud preview builds: every element gets a
5
5
  * `data-tencil-src` attribute with its file and line, because production React
6
- * keeps no source info. Without TENCIL_CLOUD, in development and on production
7
- * deployments the config comes back untouched.
6
+ * keeps no source info. Without TENCIL_CLOUD, on production deployments the
7
+ * config comes back untouched.
8
+ *
9
+ * In development it hands `<Tencil />` the repository root (TENCIL_ROOT), so
10
+ * the daemon finds the project even when the page isn't served by Next itself.
8
11
  *
9
12
  * export default withTencil(nextConfig);
10
13
  */
package/dist/next.mjs CHANGED
@@ -1,16 +1,30 @@
1
1
  import { r as resolveCloudBuild } from "./cloud-CiwIrP1h.mjs";
2
+ import { n as repositoryRoot } from "./source-attributes-Cs2NvuxG.mjs";
2
3
  import { fileURLToPath } from "node:url";
3
4
  //#region src/integrations/next.ts
4
5
  /**
5
6
  * Wrap `next.config` for Tencil Cloud preview builds: every element gets a
6
7
  * `data-tencil-src` attribute with its file and line, because production React
7
- * keeps no source info. Without TENCIL_CLOUD, in development and on production
8
- * deployments the config comes back untouched.
8
+ * keeps no source info. Without TENCIL_CLOUD, on production deployments the
9
+ * config comes back untouched.
10
+ *
11
+ * In development it hands `<Tencil />` the repository root (TENCIL_ROOT), so
12
+ * the daemon finds the project even when the page isn't served by Next itself.
9
13
  *
10
14
  * export default withTencil(nextConfig);
11
15
  */
12
16
  function withTencil(config = {}, options = {}) {
13
- if (process.env.NODE_ENV === "development") return config;
17
+ if (process.env.NODE_ENV === "development") {
18
+ const parts = config;
19
+ const env = {
20
+ ...parts.env,
21
+ TENCIL_ROOT: repositoryRoot(process.cwd())
22
+ };
23
+ return {
24
+ ...parts,
25
+ env
26
+ };
27
+ }
14
28
  if (resolveCloudBuild(process.env, options.cloud).kind !== "on") return config;
15
29
  return addSourceLoader(config);
16
30
  }