tencil 0.3.1 → 0.4.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/index.d.mts CHANGED
@@ -46,6 +46,7 @@ type ImageAttachment = z.infer<typeof ImageAttachment>;
46
46
  //#region ../protocol/src/thread.d.ts
47
47
  /**
48
48
  * Provider-agnostic run state.
49
+ * - `draft`: a comment queued in a batch, not sent to the agent yet
49
50
  * - `starting`: thread is being created on the provider
50
51
  * - `working`: the agent is producing a turn
51
52
  * - `waiting`: the agent needs approval/input inside the provider UI
@@ -53,6 +54,7 @@ type ImageAttachment = z.infer<typeof ImageAttachment>;
53
54
  * - `error`: last turn or the thread itself failed
54
55
  */
55
56
  declare const ThreadStatus: z.ZodEnum<{
57
+ draft: "draft";
56
58
  starting: "starting";
57
59
  working: "working";
58
60
  waiting: "waiting";
@@ -109,6 +111,7 @@ declare const Thread: z.ZodObject<{
109
111
  selection: z.ZodOptional<z.ZodString>;
110
112
  }, z.core.$strip>>;
111
113
  status: z.ZodEnum<{
114
+ draft: "draft";
112
115
  starting: "starting";
113
116
  working: "working";
114
117
  waiting: "waiting";
@@ -161,6 +164,14 @@ declare const ProviderThreadSummary: z.ZodObject<{
161
164
  agent: z.ZodOptional<z.ZodString>;
162
165
  }, z.core.$strip>;
163
166
  type ProviderThreadSummary = z.infer<typeof ProviderThreadSummary>;
167
+ /** A model a provider can start threads on, e.g. T3 Code's Claude Opus. */
168
+ declare const ProviderModel: z.ZodObject<{
169
+ id: z.ZodString;
170
+ label: z.ZodString;
171
+ group: z.ZodString;
172
+ agent: z.ZodOptional<z.ZodString>;
173
+ }, z.core.$strip>;
174
+ type ProviderModel = z.infer<typeof ProviderModel>;
164
175
  /** How the provider presents the project the threads belong to. */
165
176
  declare const ProviderProject: z.ZodObject<{
166
177
  name: z.ZodString;
@@ -198,6 +209,8 @@ declare const ProjectSettings: z.ZodObject<{
198
209
  id: z.ZodString;
199
210
  label: z.ZodString;
200
211
  }, z.core.$strip>>;
212
+ model: z.ZodOptional<z.ZodString>;
213
+ batch: z.ZodBoolean;
201
214
  }, z.core.$strip>;
202
215
  type ProjectSettings = z.infer<typeof ProjectSettings>;
203
216
  type ServerMessage = {
@@ -239,6 +252,12 @@ type ServerMessage = {
239
252
  type: 'provider.threads';
240
253
  project: ProviderProject;
241
254
  threads: ProviderThreadSummary[];
255
+ } | {
256
+ type: 'provider.models';
257
+ provider: string;
258
+ models: ProviderModel[];
259
+ /** What new threads run on when no model is picked. */
260
+ defaultModel?: string;
242
261
  } | {
243
262
  type: 'error';
244
263
  message: string;
@@ -268,6 +287,8 @@ interface Provider {
268
287
  project: ProviderProject;
269
288
  threads: ProviderThreadSummary[];
270
289
  }>;
290
+ /** Models new threads can run on, and the one they use by default. Optional. */
291
+ listModels?(): Promise<ProviderModels>;
271
292
  /** Deep link into the provider UI for a thread, when it has one. */
272
293
  threadUrl(providerThreadId: string): string | undefined;
273
294
  createThread(input: CreateThreadInput): Promise<CreatedThread>;
@@ -285,6 +306,13 @@ interface CreateThreadInput {
285
306
  title: string;
286
307
  text: string;
287
308
  attachments: ImageAttachment[];
309
+ /** A `ProviderModel.id` the user picked; the provider's default when absent or unknown. */
310
+ model?: string;
311
+ }
312
+ interface ProviderModels {
313
+ models: ProviderModel[];
314
+ /** `ProviderModel.id` new threads use when none is picked. */
315
+ defaultModel?: string;
288
316
  }
289
317
  interface CreatedThread {
290
318
  providerThreadId: string;
@@ -305,20 +333,39 @@ interface ProviderMessage {
305
333
  interface ThreadSink {
306
334
  /** Upsert by `id`; `text` is cumulative. */
307
335
  message(message: ProviderMessage): void;
308
- status(status: Exclude<ThreadStatus, 'starting'>, detail?: string): void;
336
+ status(status: Exclude<ThreadStatus, 'starting' | 'draft'>, detail?: string): void;
309
337
  /** Provider no longer has this thread (deleted/archived on its side). */
310
338
  gone(): void;
311
339
  }
312
340
  //#endregion
313
- //#region src/daemon/project-providers.d.ts
341
+ //#region ../bridge/src/project-providers.d.ts
342
+ /** What a project picked in the overlay's settings. */
343
+ interface SavedProjectSettings {
344
+ /** The provider new pins go to; unset means the host's fallback. */
345
+ provider?: string;
346
+ /** Model picked per provider for new threads; unset means the provider's default. */
347
+ models?: Record<string, string>;
348
+ /** Queue new comments and send them together; on when unset. */
349
+ batch?: boolean;
350
+ }
351
+ /**
352
+ * Where a project's settings live: a file next to its pins for the daemon,
353
+ * a database row for a hosted runner.
354
+ */
355
+ interface ProjectSettingsStore {
356
+ /** The saved settings, or undefined when the project has none yet. */
357
+ load(): Promise<SavedProjectSettings | undefined>;
358
+ save(settings: SavedProjectSettings): Promise<void>;
359
+ }
314
360
  interface ProjectProvidersOptions {
315
361
  /** Providers the project can pick from. */
316
362
  choices: ProviderOption[];
317
- /** Used until the project picks one: the daemon's `--provider`. */
363
+ /** Used until the project picks one, e.g. the daemon's `--provider`. */
318
364
  fallback: string;
365
+ /** Builds a choice's provider; called once per id, on first use. */
319
366
  create: (id: string) => Provider;
320
- /** Where the project's choice is saved; in memory only when absent. */
321
- settingsPath?: string;
367
+ /** Where the project's choices are saved; in memory only when absent. */
368
+ settings?: ProjectSettingsStore;
322
369
  }
323
370
  /**
324
371
  * The providers of one project. New pins go to the project's default, which
@@ -329,8 +376,11 @@ declare class ProjectProviders {
329
376
  #private;
330
377
  readonly choices: ProviderOption[];
331
378
  constructor(options: ProjectProvidersOptions);
332
- /** One fixed provider and no settings file (tests). */
333
- static of(provider: Provider): ProjectProviders;
379
+ /**
380
+ * Ready-made providers, the first being the default. Each is started
381
+ * here; `settings` keeps the project's picks (in memory when absent).
382
+ */
383
+ static of(providers: Provider | Provider[], settings?: ProjectSettingsStore): ProjectProviders;
334
384
  load(): Promise<void>;
335
385
  get defaultId(): string;
336
386
  default(): Provider;
@@ -338,37 +388,35 @@ declare class ProjectProviders {
338
388
  has(id: string): boolean;
339
389
  get(id: string): Provider;
340
390
  setDefault(id: string): Promise<void>;
391
+ /** The model picked for a provider's new threads, if any. */
392
+ modelFor(id: string): string | undefined;
393
+ setModel(id: string, model: string | null): Promise<void>;
394
+ get batch(): boolean;
395
+ setBatch(on: boolean): Promise<void>;
396
+ /** Fires when a picked model or batching changes. */
397
+ onSettingsChange(listener: () => void): () => void;
341
398
  onDefaultChange(listener: () => void): () => void;
342
399
  dispose(): Promise<void>;
343
400
  }
344
401
  //#endregion
345
- //#region src/daemon/thread-store.d.ts
346
- /** Where Tencil keeps per-machine state, shared by every project. */
347
- export declare function defaultDataDir(): string;
348
- /**
349
- * One file per project under the global data dir, named after the folder plus
350
- * a hash of its path: readable when browsing, unique per checkout, and never
351
- * shared between two bridges.
352
- */
353
- export declare function projectStorePath(projectRoot: string, dataDir?: string): string;
402
+ //#region ../bridge/src/thread-store.d.ts
354
403
  /**
355
- * Pins for one project, persisted outside the repo so they survive bridge
356
- * restarts without leaving files in the project. Writes are debounced and atomic.
404
+ * The pins of one project. The bridge reads and writes synchronously, so a
405
+ * store keeps the project's pins in memory (load them before handing the
406
+ * store to a bridge) and persists changes behind the scenes; `flush` waits
407
+ * until every change so far is saved.
357
408
  */
358
- export declare class ThreadStore {
359
- #private;
360
- readonly path: string;
361
- constructor(projectRoot: string, dataDir?: string);
362
- load(): Promise<void>;
409
+ interface ThreadStore {
410
+ /** Every pin, oldest first. */
363
411
  list(): Thread[];
364
412
  get(id: string): Thread | undefined;
365
- findByProviderThread(providerId: string, providerThreadId: string): Thread | undefined;
366
413
  upsert(thread: Thread): void;
414
+ /** False when there was no such pin. */
367
415
  delete(id: string): boolean;
368
416
  flush(): Promise<void>;
369
417
  }
370
418
  //#endregion
371
- //#region src/daemon/bridge.d.ts
419
+ //#region ../bridge/src/bridge.d.ts
372
420
  interface BridgeClient {
373
421
  send(message: ServerMessage): void;
374
422
  }
@@ -394,6 +442,20 @@ export declare class Bridge {
394
442
  dispose(): Promise<void>;
395
443
  }
396
444
  //#endregion
445
+ //#region ../bridge/src/prompt.d.ts
446
+ /**
447
+ * Renders the text sent to the agent: the user's words first, then a fenced
448
+ * block of element context. The block is stripped again before messages are
449
+ * shown in the overlay (`stripContext`).
450
+ */
451
+ export declare function renderPrompt(input: {
452
+ prompt: string;
453
+ pageUrl: string;
454
+ context: ElementContext;
455
+ hasScreenshot: boolean;
456
+ }): string;
457
+ export declare function stripContext(text: string): string;
458
+ //#endregion
397
459
  //#region src/daemon/project-resolver.d.ts
398
460
  /** Runs a command and returns stdout; injectable so tests don't depend on the OS. */
399
461
  type Exec = (command: string, args: string[]) => Promise<string>;
@@ -419,20 +481,6 @@ export declare class ProjectResolver {
419
481
  /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
420
482
  export declare function projectRoot(folder: string): string;
421
483
  //#endregion
422
- //#region src/daemon/prompt.d.ts
423
- /**
424
- * Renders the text sent to the agent: the user's words first, then a fenced
425
- * block of element context. The block is stripped again before messages are
426
- * shown in the overlay (`stripContext`).
427
- */
428
- export declare function renderPrompt(input: {
429
- prompt: string;
430
- pageUrl: string;
431
- context: ElementContext;
432
- hasScreenshot: boolean;
433
- }): string;
434
- export declare function stripContext(text: string): string;
435
- //#endregion
436
484
  //#region ../provider-claude-code/src/claude-code-provider.d.ts
437
485
  /** The permission modes that work without anyone at a terminal to answer prompts. */
438
486
  type PermissionMode = 'default' | 'acceptEdits' | 'auto' | 'bypassPermissions';
@@ -458,6 +506,8 @@ type RuntimeMode = 'approval-required' | 'auto-accept-edits' | 'auto' | 'full-ac
458
506
  interface ModelSelection {
459
507
  instanceId: string;
460
508
  model: string;
509
+ /** Per-model options such as reasoning effort, passed through as T3 Code stored them. */
510
+ options?: unknown;
461
511
  }
462
512
  //#endregion
463
513
  //#region ../provider-t3code/src/t3code-provider.d.ts
@@ -558,4 +608,30 @@ export declare function probeDaemon(port?: number, host?: string): Promise<{
558
608
  projects: ProjectStatus[];
559
609
  } | undefined>;
560
610
  //#endregion
561
- export type { Daemon, DaemonOptions, ProjectStatus };
611
+ //#region src/daemon/thread-store.d.ts
612
+ /** Where Tencil keeps per-machine state, shared by every project. */
613
+ export declare function defaultDataDir(): string;
614
+ /**
615
+ * One file per project under the global data dir, named after the folder plus
616
+ * a hash of its path: readable when browsing, unique per checkout, and never
617
+ * shared between two bridges.
618
+ */
619
+ export declare function projectStorePath(projectRoot: string, dataDir?: string): string;
620
+ /**
621
+ * Pins for one project, persisted outside the repo so they survive bridge
622
+ * restarts without leaving files in the project. Writes are debounced and atomic.
623
+ */
624
+ declare class FileThreadStore implements ThreadStore {
625
+ #private;
626
+ readonly path: string;
627
+ constructor(projectRoot: string, dataDir?: string);
628
+ load(): Promise<void>;
629
+ list(): Thread[];
630
+ get(id: string): Thread | undefined;
631
+ findByProviderThread(providerId: string, providerThreadId: string): Thread | undefined;
632
+ upsert(thread: Thread): void;
633
+ delete(id: string): boolean;
634
+ flush(): Promise<void>;
635
+ }
636
+ //#endregion
637
+ export { type Daemon, type DaemonOptions, type ProjectStatus, FileThreadStore as ThreadStore };
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 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
- export { Bridge, DEFAULT_PORT, ProjectResolver, ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };
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-9m0nvaLs.mjs";
2
+ export { Bridge, DEFAULT_PORT, ProjectResolver, FileThreadStore as ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };