tencil 0.3.2 → 0.5.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
@@ -1,324 +1,32 @@
1
- import { z } from "zod";
2
- //#region ../protocol/src/context.d.ts
3
- /**
4
- * Everything the overlay knows about the picked element. Captured once when
5
- * the pin is placed and forwarded to the agent as context.
6
- */
7
- declare const ElementContext: z.ZodObject<{
8
- tagName: z.ZodString;
9
- selector: z.ZodString;
10
- html: z.ZodString;
11
- text: z.ZodOptional<z.ZodString>;
12
- components: z.ZodDefault<z.ZodArray<z.ZodObject<{
13
- name: z.ZodString;
14
- source: z.ZodOptional<z.ZodObject<{
15
- file: z.ZodString;
16
- line: z.ZodOptional<z.ZodNumber>;
17
- column: z.ZodOptional<z.ZodNumber>;
18
- }, z.core.$strip>>;
19
- library: z.ZodOptional<z.ZodString>;
20
- }, z.core.$strip>>>;
21
- rect: z.ZodObject<{
22
- x: z.ZodNumber;
23
- y: z.ZodNumber;
24
- width: z.ZodNumber;
25
- height: z.ZodNumber;
26
- }, z.core.$strip>;
27
- viewport: z.ZodObject<{
28
- width: z.ZodNumber;
29
- height: z.ZodNumber;
30
- dpr: z.ZodNumber;
31
- }, z.core.$strip>;
32
- selection: z.ZodOptional<z.ZodString>;
33
- }, z.core.$strip>;
34
- type ElementContext = z.infer<typeof ElementContext>;
35
- declare const ImageAttachment: z.ZodObject<{
36
- name: z.ZodString;
37
- mimeType: z.ZodEnum<{
38
- "image/png": "image/png";
39
- "image/jpeg": "image/jpeg";
40
- "image/webp": "image/webp";
41
- }>;
42
- dataUrl: z.ZodString;
43
- }, z.core.$strip>;
44
- type ImageAttachment = z.infer<typeof ImageAttachment>;
45
- //#endregion
46
- //#region ../protocol/src/thread.d.ts
47
- /**
48
- * Provider-agnostic run state.
49
- * - `starting`: thread is being created on the provider
50
- * - `working`: the agent is producing a turn
51
- * - `waiting`: the agent needs approval/input inside the provider UI
52
- * - `idle`: last turn finished, ready for a follow-up
53
- * - `error`: last turn or the thread itself failed
54
- */
55
- declare const ThreadStatus: z.ZodEnum<{
56
- starting: "starting";
57
- working: "working";
58
- waiting: "waiting";
59
- idle: "idle";
60
- error: "error";
61
- }>;
62
- type ThreadStatus = z.infer<typeof ThreadStatus>;
63
- declare const MessageRole: z.ZodEnum<{
64
- user: "user";
65
- assistant: "assistant";
66
- system: "system";
67
- }>;
68
- type MessageRole = z.infer<typeof MessageRole>;
69
- /**
70
- * A conversation Tencil tracks, backed by one provider thread. Owned and
71
- * persisted by the bridge. Pinned threads sit on an element of a page;
72
- * threads opened from the provider's list have no anchor and live in the dock.
73
- * Several pins may continue the same provider thread.
74
- */
75
- declare const Thread: z.ZodObject<{
76
- id: z.ZodString;
77
- title: z.ZodString;
78
- pageUrl: z.ZodOptional<z.ZodString>;
79
- anchor: z.ZodOptional<z.ZodObject<{
80
- selector: z.ZodString;
81
- offsetX: z.ZodNumber;
82
- offsetY: z.ZodNumber;
83
- }, z.core.$strip>>;
84
- context: z.ZodOptional<z.ZodObject<{
85
- tagName: z.ZodString;
86
- selector: z.ZodString;
87
- html: z.ZodString;
88
- text: z.ZodOptional<z.ZodString>;
89
- components: z.ZodDefault<z.ZodArray<z.ZodObject<{
90
- name: z.ZodString;
91
- source: z.ZodOptional<z.ZodObject<{
92
- file: z.ZodString;
93
- line: z.ZodOptional<z.ZodNumber>;
94
- column: z.ZodOptional<z.ZodNumber>;
95
- }, z.core.$strip>>;
96
- library: z.ZodOptional<z.ZodString>;
97
- }, z.core.$strip>>>;
98
- rect: z.ZodObject<{
99
- x: z.ZodNumber;
100
- y: z.ZodNumber;
101
- width: z.ZodNumber;
102
- height: z.ZodNumber;
103
- }, z.core.$strip>;
104
- viewport: z.ZodObject<{
105
- width: z.ZodNumber;
106
- height: z.ZodNumber;
107
- dpr: z.ZodNumber;
108
- }, z.core.$strip>;
109
- selection: z.ZodOptional<z.ZodString>;
110
- }, z.core.$strip>>;
111
- status: z.ZodEnum<{
112
- starting: "starting";
113
- working: "working";
114
- waiting: "waiting";
115
- idle: "idle";
116
- error: "error";
117
- }>;
118
- statusDetail: z.ZodOptional<z.ZodString>;
119
- resolved: z.ZodDefault<z.ZodBoolean>;
120
- messages: z.ZodArray<z.ZodObject<{
121
- id: z.ZodString;
122
- role: z.ZodEnum<{
123
- user: "user";
124
- assistant: "assistant";
125
- system: "system";
126
- }>;
127
- text: z.ZodString;
128
- streaming: z.ZodDefault<z.ZodBoolean>;
129
- createdAt: z.ZodString;
130
- }, z.core.$strip>>;
131
- provider: z.ZodObject<{
132
- id: z.ZodString;
133
- threadId: z.ZodOptional<z.ZodString>;
134
- url: z.ZodOptional<z.ZodString>;
135
- }, z.core.$strip>;
136
- createdAt: z.ZodString;
137
- updatedAt: z.ZodString;
138
- }, z.core.$strip>;
139
- type Thread = z.infer<typeof Thread>;
140
- /** A thread as listed by the provider (e.g. every T3 Code thread in the project). */
141
- declare const ProviderThreadSummary: z.ZodObject<{
142
- id: z.ZodString;
143
- title: z.ZodString;
144
- status: z.ZodEnum<{
145
- working: "working";
146
- waiting: "waiting";
147
- idle: "idle";
148
- error: "error";
149
- }>;
150
- updatedAt: z.ZodString;
151
- url: z.ZodOptional<z.ZodString>;
152
- branch: z.ZodOptional<z.ZodString>;
153
- pullRequest: z.ZodOptional<z.ZodObject<{
154
- number: z.ZodNumber;
155
- url: z.ZodString;
156
- }, z.core.$strip>>;
157
- background: z.ZodOptional<z.ZodEnum<{
158
- working: "working";
159
- monitoring: "monitoring";
160
- }>>;
161
- agent: z.ZodOptional<z.ZodString>;
162
- }, z.core.$strip>;
163
- type ProviderThreadSummary = z.infer<typeof ProviderThreadSummary>;
164
- /** How the provider presents the project the threads belong to. */
165
- declare const ProviderProject: z.ZodObject<{
166
- name: z.ZodString;
167
- iconUrl: z.ZodOptional<z.ZodString>;
168
- emoji: z.ZodOptional<z.ZodString>;
169
- }, z.core.$strip>;
170
- type ProviderProject = z.infer<typeof ProviderProject>;
171
- //#endregion
172
- //#region ../protocol/src/messages.d.ts
173
- declare const PROTOCOL_VERSION = 1;
174
- declare const ProviderInfo: z.ZodObject<{
175
- id: z.ZodString;
176
- label: z.ZodString;
177
- state: z.ZodEnum<{
178
- connecting: "connecting";
179
- ready: "ready";
180
- unauthorized: "unauthorized";
181
- unavailable: "unavailable";
182
- }>;
183
- detail: z.ZodOptional<z.ZodString>;
184
- target: z.ZodOptional<z.ZodString>;
185
- canPair: z.ZodOptional<z.ZodBoolean>;
186
- }, z.core.$strip>;
187
- type ProviderInfo = z.infer<typeof ProviderInfo>;
188
- /** A provider the project can send pins to. */
189
- declare const ProviderOption: z.ZodObject<{
190
- id: z.ZodString;
191
- label: z.ZodString;
192
- }, z.core.$strip>;
193
- type ProviderOption = z.infer<typeof ProviderOption>;
194
- /** Per-project settings, as the overlay shows them. */
195
- declare const ProjectSettings: z.ZodObject<{
196
- provider: z.ZodString;
197
- providers: z.ZodArray<z.ZodObject<{
198
- id: z.ZodString;
199
- label: z.ZodString;
200
- }, z.core.$strip>>;
201
- }, z.core.$strip>;
202
- type ProjectSettings = z.infer<typeof ProjectSettings>;
203
- type ServerMessage = {
204
- type: 'ready';
205
- protocol: typeof PROTOCOL_VERSION;
206
- version: string;
207
- project: {
208
- name: string;
209
- root: string;
210
- };
211
- /** The provider new pins go to. */
212
- provider: ProviderInfo;
213
- settings: ProjectSettings;
214
- threads: Thread[];
215
- } | {
216
- type: 'provider.status';
217
- provider: ProviderInfo;
218
- } | {
219
- type: 'settings';
220
- settings: ProjectSettings;
221
- } |
222
- /** The daemon couldn't tell which project this page belongs to; the overlay asks. */
223
- {
224
- type: 'project.unknown';
225
- pageUrl: string;
226
- choices: Array<{
227
- root: string;
228
- title: string;
229
- }>;
230
- /** What to do when there are no choices. */
231
- emptyHint?: string;
232
- } | {
233
- type: 'thread.upsert';
234
- thread: Thread;
235
- } | {
236
- type: 'thread.removed';
237
- threadId: string;
238
- } | {
239
- type: 'provider.threads';
240
- project: ProviderProject;
241
- threads: ProviderThreadSummary[];
242
- } | {
243
- type: 'error';
244
- message: string;
245
- threadId?: string;
246
- };
247
- //#endregion
248
- //#region ../protocol/src/provider.d.ts
1
+ import { a as ElementContext, i as Thread, n as ProviderOption, r as ServerMessage, t as Provider } from "./index-DzR4m_IL.mjs";
2
+ //#region ../bridge/src/project-providers.d.ts
3
+ /** What a project picked in the overlay's settings. */
4
+ interface SavedProjectSettings {
5
+ /** The provider new pins go to; unset means the host's fallback. */
6
+ provider?: string;
7
+ /** Model picked per provider for new threads; unset means the provider's default. */
8
+ models?: Record<string, string>;
9
+ /** Queue new comments and send them together; on when unset. */
10
+ batch?: boolean;
11
+ }
249
12
  /**
250
- * A provider is the agent backend a pin is delegated to (T3 Code, Claude Code,
251
- * …). The bridge owns pins and talks to exactly one provider per process; the
252
- * provider owns the conversation.
253
- *
254
- * Providers only ever see plain text + images: the bridge renders element
255
- * context into the prompt so every provider gets identical input.
13
+ * Where a project's settings live: a file next to its pins for the daemon,
14
+ * a database row for a hosted runner.
256
15
  */
257
- interface Provider {
258
- readonly id: string;
259
- readonly label: string;
260
- /** Connect/authenticate. Must not throw; report problems through `info()`. */
261
- start(): Promise<void>;
262
- info(): ProviderInfo;
263
- onInfoChange(listener: (info: ProviderInfo) => void): () => void;
264
- /** Authorize against the provider (e.g. pair with T3 Code). Optional. */
265
- pair?(): Promise<void>;
266
- /** Threads that already exist for this project, newest first. */
267
- listThreads(): Promise<{
268
- project: ProviderProject;
269
- threads: ProviderThreadSummary[];
270
- }>;
271
- /** Deep link into the provider UI for a thread, when it has one. */
272
- threadUrl(providerThreadId: string): string | undefined;
273
- createThread(input: CreateThreadInput): Promise<CreatedThread>;
274
- sendMessage(input: SendMessageInput): Promise<void>;
275
- interrupt(providerThreadId: string): Promise<void>;
276
- /**
277
- * Stream updates for a thread. Called right after `createThread` and again
278
- * for every persisted thread when the bridge restarts. The provider should
279
- * replay current state first, then live updates.
280
- */
281
- watch(providerThreadId: string, sink: ThreadSink): () => void;
282
- dispose(): Promise<void>;
283
- }
284
- interface CreateThreadInput {
285
- title: string;
286
- text: string;
287
- attachments: ImageAttachment[];
288
- }
289
- interface CreatedThread {
290
- providerThreadId: string;
291
- url?: string;
292
- }
293
- interface SendMessageInput {
294
- providerThreadId: string;
295
- text: string;
296
- attachments: ImageAttachment[];
297
- }
298
- interface ProviderMessage {
299
- id: string;
300
- role: MessageRole;
301
- text: string;
302
- streaming: boolean;
303
- createdAt: string;
16
+ interface ProjectSettingsStore {
17
+ /** The saved settings, or undefined when the project has none yet. */
18
+ load(): Promise<SavedProjectSettings | undefined>;
19
+ save(settings: SavedProjectSettings): Promise<void>;
304
20
  }
305
- interface ThreadSink {
306
- /** Upsert by `id`; `text` is cumulative. */
307
- message(message: ProviderMessage): void;
308
- status(status: Exclude<ThreadStatus, 'starting'>, detail?: string): void;
309
- /** Provider no longer has this thread (deleted/archived on its side). */
310
- gone(): void;
311
- }
312
- //#endregion
313
- //#region src/daemon/project-providers.d.ts
314
21
  interface ProjectProvidersOptions {
315
22
  /** Providers the project can pick from. */
316
23
  choices: ProviderOption[];
317
- /** Used until the project picks one: the daemon's `--provider`. */
24
+ /** Used until the project picks one, e.g. the daemon's `--provider`. */
318
25
  fallback: string;
26
+ /** Builds a choice's provider; called once per id, on first use. */
319
27
  create: (id: string) => Provider;
320
- /** Where the project's choice is saved; in memory only when absent. */
321
- settingsPath?: string;
28
+ /** Where the project's choices are saved; in memory only when absent. */
29
+ settings?: ProjectSettingsStore;
322
30
  }
323
31
  /**
324
32
  * The providers of one project. New pins go to the project's default, which
@@ -329,8 +37,11 @@ declare class ProjectProviders {
329
37
  #private;
330
38
  readonly choices: ProviderOption[];
331
39
  constructor(options: ProjectProvidersOptions);
332
- /** One fixed provider and no settings file (tests). */
333
- static of(provider: Provider): ProjectProviders;
40
+ /**
41
+ * Ready-made providers, the first being the default. Each is started
42
+ * here; `settings` keeps the project's picks (in memory when absent).
43
+ */
44
+ static of(providers: Provider | Provider[], settings?: ProjectSettingsStore): ProjectProviders;
334
45
  load(): Promise<void>;
335
46
  get defaultId(): string;
336
47
  default(): Provider;
@@ -338,37 +49,35 @@ declare class ProjectProviders {
338
49
  has(id: string): boolean;
339
50
  get(id: string): Provider;
340
51
  setDefault(id: string): Promise<void>;
52
+ /** The model picked for a provider's new threads, if any. */
53
+ modelFor(id: string): string | undefined;
54
+ setModel(id: string, model: string | null): Promise<void>;
55
+ get batch(): boolean;
56
+ setBatch(on: boolean): Promise<void>;
57
+ /** Fires when a picked model or batching changes. */
58
+ onSettingsChange(listener: () => void): () => void;
341
59
  onDefaultChange(listener: () => void): () => void;
342
60
  dispose(): Promise<void>;
343
61
  }
344
62
  //#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;
63
+ //#region ../bridge/src/thread-store.d.ts
354
64
  /**
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.
65
+ * The pins of one project. The bridge reads and writes synchronously, so a
66
+ * store keeps the project's pins in memory (load them before handing the
67
+ * store to a bridge) and persists changes behind the scenes; `flush` waits
68
+ * until every change so far is saved.
357
69
  */
358
- export declare class ThreadStore {
359
- #private;
360
- readonly path: string;
361
- constructor(projectRoot: string, dataDir?: string);
362
- load(): Promise<void>;
70
+ interface ThreadStore {
71
+ /** Every pin, oldest first. */
363
72
  list(): Thread[];
364
73
  get(id: string): Thread | undefined;
365
- findByProviderThread(providerId: string, providerThreadId: string): Thread | undefined;
366
74
  upsert(thread: Thread): void;
75
+ /** False when there was no such pin. */
367
76
  delete(id: string): boolean;
368
77
  flush(): Promise<void>;
369
78
  }
370
79
  //#endregion
371
- //#region src/daemon/bridge.d.ts
80
+ //#region ../bridge/src/bridge.d.ts
372
81
  interface BridgeClient {
373
82
  send(message: ServerMessage): void;
374
83
  }
@@ -394,6 +103,20 @@ export declare class Bridge {
394
103
  dispose(): Promise<void>;
395
104
  }
396
105
  //#endregion
106
+ //#region ../bridge/src/prompt.d.ts
107
+ /**
108
+ * Renders the text sent to the agent: the user's words first, then a fenced
109
+ * block of element context. The block is stripped again before messages are
110
+ * shown in the overlay (`stripContext`).
111
+ */
112
+ export declare function renderPrompt(input: {
113
+ prompt: string;
114
+ pageUrl: string;
115
+ context: ElementContext;
116
+ hasScreenshot: boolean;
117
+ }): string;
118
+ export declare function stripContext(text: string): string;
119
+ //#endregion
397
120
  //#region src/daemon/project-resolver.d.ts
398
121
  /** Runs a command and returns stdout; injectable so tests don't depend on the OS. */
399
122
  type Exec = (command: string, args: string[]) => Promise<string>;
@@ -419,20 +142,6 @@ export declare class ProjectResolver {
419
142
  /** Closest folder with a package.json at or above `folder`, or `folder` itself. */
420
143
  export declare function projectRoot(folder: string): string;
421
144
  //#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
145
  //#region ../provider-claude-code/src/claude-code-provider.d.ts
437
146
  /** The permission modes that work without anyone at a terminal to answer prompts. */
438
147
  type PermissionMode = 'default' | 'acceptEdits' | 'auto' | 'bypassPermissions';
@@ -458,6 +167,8 @@ type RuntimeMode = 'approval-required' | 'auto-accept-edits' | 'auto' | 'full-ac
458
167
  interface ModelSelection {
459
168
  instanceId: string;
460
169
  model: string;
170
+ /** Per-model options such as reasoning effort, passed through as T3 Code stored them. */
171
+ options?: unknown;
461
172
  }
462
173
  //#endregion
463
174
  //#region ../provider-t3code/src/t3code-provider.d.ts
@@ -558,4 +269,30 @@ export declare function probeDaemon(port?: number, host?: string): Promise<{
558
269
  projects: ProjectStatus[];
559
270
  } | undefined>;
560
271
  //#endregion
561
- export type { Daemon, DaemonOptions, ProjectStatus };
272
+ //#region src/daemon/thread-store.d.ts
273
+ /** Where Tencil keeps per-machine state, shared by every project. */
274
+ export declare function defaultDataDir(): string;
275
+ /**
276
+ * One file per project under the global data dir, named after the folder plus
277
+ * a hash of its path: readable when browsing, unique per checkout, and never
278
+ * shared between two bridges.
279
+ */
280
+ export declare function projectStorePath(projectRoot: string, dataDir?: string): string;
281
+ /**
282
+ * Pins for one project, persisted outside the repo so they survive bridge
283
+ * restarts without leaving files in the project. Writes are debounced and atomic.
284
+ */
285
+ declare class FileThreadStore implements ThreadStore {
286
+ #private;
287
+ readonly path: string;
288
+ constructor(projectRoot: string, dataDir?: string);
289
+ load(): Promise<void>;
290
+ list(): Thread[];
291
+ get(id: string): Thread | undefined;
292
+ findByProviderThread(providerId: string, providerThreadId: string): Thread | undefined;
293
+ upsert(thread: Thread): void;
294
+ delete(id: string): boolean;
295
+ flush(): Promise<void>;
296
+ }
297
+ //#endregion
298
+ 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-Bxj8yTb3.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-DZUEgjla.mjs";
2
+ export { Bridge, DEFAULT_PORT, ProjectResolver, FileThreadStore as ThreadStore, defaultDataDir, probeDaemon, projectRoot, projectStorePath, renderPrompt, startDaemon, stripContext };