@plotday/twister 0.47.0 → 0.49.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/bin/commands/generate.js +5 -5
- package/bin/commands/generate.js.map +1 -1
- package/bin/templates/AGENTS.template.md +8 -2
- package/bin/utils/bundle.js +14 -0
- package/bin/utils/bundle.js.map +1 -1
- package/cli/templates/AGENTS.template.md +8 -2
- package/dist/connector.d.ts +67 -7
- package/dist/connector.d.ts.map +1 -1
- package/dist/connector.js +15 -5
- package/dist/connector.js.map +1 -1
- package/dist/docs/assets/hierarchy.js +1 -1
- package/dist/docs/assets/navigation.js +1 -1
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/index.Connector.html +58 -49
- package/dist/docs/classes/index.Imap.html +1 -1
- package/dist/docs/classes/index.Options.html +1 -1
- package/dist/docs/classes/index.Smtp.html +1 -1
- package/dist/docs/classes/tools_ai.AI.html +1 -1
- package/dist/docs/classes/tools_callbacks.Callbacks.html +1 -1
- package/dist/docs/classes/tools_integrations.Integrations.html +21 -5
- package/dist/docs/classes/tools_network.Network.html +1 -1
- package/dist/docs/classes/tools_plot.Plot.html +1 -1
- package/dist/docs/classes/tools_store.Store.html +1 -1
- package/dist/docs/classes/tools_tasks.Tasks.html +1 -1
- package/dist/docs/classes/tools_twists.Twists.html +1 -1
- package/dist/docs/classes/twist.Twist.html +28 -28
- package/dist/docs/documents/Building_Connectors.html +8 -1
- package/dist/docs/documents/CLI_Reference.html +6 -4
- package/dist/docs/enums/tag.Tag.html +11 -1
- package/dist/docs/enums/tools_integrations.AuthProvider.html +14 -12
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/media/AGENTS.md +298 -775
- package/dist/docs/media/MULTI_USER_AUTH.md +6 -4
- package/dist/docs/media/SYNC_STRATEGIES.md +20 -14
- package/dist/docs/modules/index.html +1 -1
- package/dist/docs/types/index.CreateLinkDraft.html +7 -12
- package/dist/docs/types/index.NoteWriteBackResult.html +38 -0
- package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
- package/dist/docs/types/tools_integrations.AuthToken.html +4 -4
- package/dist/docs/types/tools_integrations.Authorization.html +4 -4
- package/dist/llm-docs/connector.d.ts +1 -1
- package/dist/llm-docs/connector.d.ts.map +1 -1
- package/dist/llm-docs/connector.js +1 -1
- package/dist/llm-docs/connector.js.map +1 -1
- package/dist/llm-docs/tag.d.ts +1 -1
- package/dist/llm-docs/tag.d.ts.map +1 -1
- package/dist/llm-docs/tag.js +1 -1
- package/dist/llm-docs/tag.js.map +1 -1
- package/dist/llm-docs/tools/integrations.d.ts +1 -1
- package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
- package/dist/llm-docs/tools/integrations.js +1 -1
- package/dist/llm-docs/tools/integrations.js.map +1 -1
- package/dist/llm-docs/twist-guide-template.d.ts +1 -1
- package/dist/llm-docs/twist-guide-template.d.ts.map +1 -1
- package/dist/llm-docs/twist-guide-template.js +1 -1
- package/dist/llm-docs/twist-guide-template.js.map +1 -1
- package/dist/llm-docs/twist.d.ts +1 -1
- package/dist/llm-docs/twist.d.ts.map +1 -1
- package/dist/llm-docs/twist.js +1 -1
- package/dist/llm-docs/twist.js.map +1 -1
- package/dist/tag.d.ts +11 -1
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +10 -0
- package/dist/tag.js.map +1 -1
- package/dist/tools/integrations.d.ts +25 -1
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js +2 -0
- package/dist/tools/integrations.js.map +1 -1
- package/dist/twist-guide.d.ts +1 -1
- package/dist/twist-guide.d.ts.map +1 -1
- package/dist/twist.d.ts +2 -1
- package/dist/twist.d.ts.map +1 -1
- package/dist/twist.js.map +1 -1
- package/dist/utils/markdown.d.ts +27 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +82 -0
- package/dist/utils/markdown.js.map +1 -0
- package/package.json +7 -1
- package/src/connector.ts +427 -0
- package/src/creator-docs.ts +29 -0
- package/src/index.ts +10 -0
- package/src/llm-docs/connector.ts +8 -0
- package/src/llm-docs/index.ts +48 -0
- package/src/llm-docs/options.ts +8 -0
- package/src/llm-docs/plot.ts +8 -0
- package/src/llm-docs/schedule.ts +8 -0
- package/src/llm-docs/tag.ts +8 -0
- package/src/llm-docs/tool.ts +8 -0
- package/src/llm-docs/tools/ai.ts +8 -0
- package/src/llm-docs/tools/callbacks.ts +8 -0
- package/src/llm-docs/tools/imap.ts +8 -0
- package/src/llm-docs/tools/integrations.ts +8 -0
- package/src/llm-docs/tools/network.ts +8 -0
- package/src/llm-docs/tools/plot.ts +8 -0
- package/src/llm-docs/tools/smtp.ts +8 -0
- package/src/llm-docs/tools/store.ts +8 -0
- package/src/llm-docs/tools/tasks.ts +8 -0
- package/src/llm-docs/tools/twists.ts +8 -0
- package/src/llm-docs/twist-guide-template.ts +8 -0
- package/src/llm-docs/twist.ts +8 -0
- package/src/options.ts +115 -0
- package/src/plot.ts +1068 -0
- package/src/schedule.ts +203 -0
- package/src/tag.ts +54 -0
- package/src/tool.ts +377 -0
- package/src/tools/ai.ts +845 -0
- package/src/tools/callbacks.ts +134 -0
- package/src/tools/imap.ts +266 -0
- package/src/tools/index.ts +10 -0
- package/src/tools/integrations.ts +352 -0
- package/src/tools/network.ts +240 -0
- package/src/tools/plot.ts +692 -0
- package/src/tools/smtp.ts +166 -0
- package/src/tools/store.ts +149 -0
- package/src/tools/tasks.ts +137 -0
- package/src/tools/twists.ts +228 -0
- package/src/twist-guide.ts +9 -0
- package/src/twist.ts +436 -0
- package/src/utils/hash.ts +8 -0
- package/src/utils/markdown.ts +94 -0
- package/src/utils/serializable.ts +54 -0
- package/src/utils/types.ts +130 -0
- package/src/utils/uuid.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plotday/twister",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Plot Twist Creator - Build intelligent extensions that integrate and automate",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -109,6 +109,11 @@
|
|
|
109
109
|
"types": "./dist/utils/hash.d.ts",
|
|
110
110
|
"default": "./dist/utils/hash.js"
|
|
111
111
|
},
|
|
112
|
+
"./utils/markdown": {
|
|
113
|
+
"@plotday/connector": "./src/utils/markdown.ts",
|
|
114
|
+
"types": "./dist/utils/markdown.d.ts",
|
|
115
|
+
"default": "./dist/utils/markdown.js"
|
|
116
|
+
},
|
|
112
117
|
"./utils/uuid": {
|
|
113
118
|
"@plotday/connector": "./src/utils/uuid.ts",
|
|
114
119
|
"types": "./dist/utils/uuid.d.ts",
|
|
@@ -203,6 +208,7 @@
|
|
|
203
208
|
},
|
|
204
209
|
"files": [
|
|
205
210
|
"dist",
|
|
211
|
+
"src",
|
|
206
212
|
"bin",
|
|
207
213
|
"cli/templates",
|
|
208
214
|
"tsconfig.base.json",
|
package/src/connector.ts
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import { type Actor, type ActorId, type Link, type NewLinkWithNotes, type Note, type Thread } from "./plot";
|
|
2
|
+
import type { ScheduleContactStatus } from "./schedule";
|
|
3
|
+
import {
|
|
4
|
+
type AuthProvider,
|
|
5
|
+
type AuthToken,
|
|
6
|
+
type Authorization,
|
|
7
|
+
type Channel,
|
|
8
|
+
type LinkTypeConfig,
|
|
9
|
+
type SyncContext,
|
|
10
|
+
} from "./tools/integrations";
|
|
11
|
+
import { Twist } from "./twist";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fields captured in Plot when a user initiates creation of a new external
|
|
15
|
+
* item via a connector's `onCreateLink` hook.
|
|
16
|
+
*
|
|
17
|
+
* Thread-agnostic on purpose — connectors do not receive the Plot thread.
|
|
18
|
+
* The platform attaches the returned `NewLinkWithNotes` to the originating
|
|
19
|
+
* thread once `onCreateLink` resolves.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Result returned from {@link Connector.onNoteCreated} and
|
|
23
|
+
* {@link Connector.onNoteUpdated} to report what the external system now
|
|
24
|
+
* has stored for the note.
|
|
25
|
+
*
|
|
26
|
+
* The runtime hashes `externalContent` and stores it as the note's sync
|
|
27
|
+
* baseline. On the next sync-in, if the incoming content hashes to the
|
|
28
|
+
* same value, the runtime knows the external side hasn't changed and
|
|
29
|
+
* preserves Plot's (possibly formatted) content. When the external side
|
|
30
|
+
* is edited, the hash diverges and the runtime overwrites Plot's content
|
|
31
|
+
* with the new external version.
|
|
32
|
+
*
|
|
33
|
+
* Omitting `externalContent` skips baseline tracking — the next sync-in
|
|
34
|
+
* will overwrite Plot's content (previous behavior). Always provide it
|
|
35
|
+
* when the write-back's return value reflects what the external system
|
|
36
|
+
* actually stored (often lossy plain-text), so the round-trip does not
|
|
37
|
+
* clobber the original Plot markdown.
|
|
38
|
+
*
|
|
39
|
+
* The hash covers only the content string — the runtime intentionally
|
|
40
|
+
* does not include a content-type in the hash, so write-back and sync-in
|
|
41
|
+
* do not have to agree on a content-type label for the same underlying
|
|
42
|
+
* bytes. Return exactly the string your connector's sync-in path will
|
|
43
|
+
* emit as `NewNote.content` for this note on the next re-ingest.
|
|
44
|
+
*
|
|
45
|
+
* For back-compat, `onNoteCreated` may also return a plain string, which
|
|
46
|
+
* is treated as `{ key }` with no baseline.
|
|
47
|
+
*/
|
|
48
|
+
export type NoteWriteBackResult = {
|
|
49
|
+
/**
|
|
50
|
+
* External system identifier assigned to this note. Set as the note's
|
|
51
|
+
* `key` for future upsert matching. Required when the runtime does not
|
|
52
|
+
* already know the key (i.e., from `onNoteCreated`); ignored from
|
|
53
|
+
* `onNoteUpdated` when the key was already established on create.
|
|
54
|
+
*/
|
|
55
|
+
key?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The content string as the external system now stores it, post-write.
|
|
58
|
+
* For systems whose write-back returns a representation of what was
|
|
59
|
+
* actually stored (e.g. Google Drive comment `content` after a create),
|
|
60
|
+
* pass that verbatim. For systems that only accept plain text, this
|
|
61
|
+
* will often be a lossy plain-text version of the Plot markdown — that
|
|
62
|
+
* is exactly the point: storing the lossy form as baseline lets the
|
|
63
|
+
* next sync-in recognize it and skip overwriting the richer Plot
|
|
64
|
+
* version.
|
|
65
|
+
*
|
|
66
|
+
* Must exactly match the string your connector's sync-in path emits as
|
|
67
|
+
* `NewNote.content` for this note on re-ingest.
|
|
68
|
+
*/
|
|
69
|
+
externalContent?: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type CreateLinkDraft = {
|
|
73
|
+
/** The channel (account + resource) the new item belongs to. */
|
|
74
|
+
channelId: string;
|
|
75
|
+
/** Link type identifier, matches a `LinkTypeConfig.type`. */
|
|
76
|
+
type: string;
|
|
77
|
+
/** Status the user selected. Matches a `statuses[].status` for `type`. */
|
|
78
|
+
status: string;
|
|
79
|
+
/** Title of the originating Plot thread (post AI title generation). */
|
|
80
|
+
title: string;
|
|
81
|
+
/** Markdown content of the thread's first note, or null if none. */
|
|
82
|
+
noteContent: string | null;
|
|
83
|
+
/**
|
|
84
|
+
* Contacts attached to the originating Plot thread, excluding the
|
|
85
|
+
* creating user. Use these as recipients (email, chat DM members, etc.)
|
|
86
|
+
* when the external item is a message or invite. An empty list means
|
|
87
|
+
* the user did not add anyone to the thread.
|
|
88
|
+
*/
|
|
89
|
+
contacts: Actor[];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Base class for connectors — twists that sync data from external services.
|
|
94
|
+
*
|
|
95
|
+
* Connectors declare a single OAuth provider and scopes, and implement channel
|
|
96
|
+
* lifecycle methods for discovering and syncing external resources. They save
|
|
97
|
+
* data directly via `integrations.saveLink()` instead of using the Plot tool.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* class LinearConnector extends Connector<LinearConnector> {
|
|
102
|
+
* readonly provider = AuthProvider.Linear;
|
|
103
|
+
* readonly scopes = ["read", "write"];
|
|
104
|
+
* readonly linkTypes = [{
|
|
105
|
+
* type: "issue",
|
|
106
|
+
* label: "Issue",
|
|
107
|
+
* statuses: [
|
|
108
|
+
* { status: "open", label: "Open" },
|
|
109
|
+
* { status: "done", label: "Done" },
|
|
110
|
+
* ],
|
|
111
|
+
* }];
|
|
112
|
+
*
|
|
113
|
+
* build(build: ToolBuilder) {
|
|
114
|
+
* return {
|
|
115
|
+
* integrations: build(Integrations),
|
|
116
|
+
* };
|
|
117
|
+
* }
|
|
118
|
+
*
|
|
119
|
+
* async getChannels(auth: Authorization, token: AuthToken): Promise<Channel[]> {
|
|
120
|
+
* const teams = await this.listTeams(token);
|
|
121
|
+
* return teams.map(t => ({ id: t.id, title: t.name }));
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* async onChannelEnabled(channel: Channel) {
|
|
125
|
+
* const issues = await this.fetchIssues(channel.id);
|
|
126
|
+
* for (const issue of issues) {
|
|
127
|
+
* await this.tools.integrations.saveLink(issue);
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* async onChannelDisabled(channel: Channel) {
|
|
132
|
+
* // Clean up webhooks, sync state, etc.
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export abstract class Connector<TSelf> extends Twist<TSelf> {
|
|
138
|
+
/**
|
|
139
|
+
* Static marker to identify Connector subclasses without instanceof checks
|
|
140
|
+
* across worker boundaries.
|
|
141
|
+
*/
|
|
142
|
+
static readonly isConnector = true;
|
|
143
|
+
|
|
144
|
+
// ---- Identity (abstract — every connector must declare) ----
|
|
145
|
+
|
|
146
|
+
/** The OAuth provider this connector authenticates with. */
|
|
147
|
+
readonly provider?: AuthProvider;
|
|
148
|
+
|
|
149
|
+
/** OAuth scopes to request for this connector. */
|
|
150
|
+
readonly scopes?: string[];
|
|
151
|
+
|
|
152
|
+
// ---- Auth model ----
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* When true, one credential is shared across all users in the workspace,
|
|
156
|
+
* entered once by the installer. When false (default), each user provides
|
|
157
|
+
* their own credential.
|
|
158
|
+
*
|
|
159
|
+
* Applies to both OAuth and key-based connectors:
|
|
160
|
+
* - Shared OAuth: e.g. Slack bot token (workspace-level)
|
|
161
|
+
* - Shared key: e.g. Attio workspace API key
|
|
162
|
+
* - Individual OAuth: e.g. Google Calendar (per-user)
|
|
163
|
+
* - Individual key: e.g. Fellow (per-user API key)
|
|
164
|
+
*/
|
|
165
|
+
readonly shared?: boolean;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The Options field name that contains the authentication key (e.g. "apiKey").
|
|
169
|
+
* Must reference a `secure: true` field in the Options schema.
|
|
170
|
+
*
|
|
171
|
+
* When set, this connector uses key-based auth instead of OAuth.
|
|
172
|
+
* For individual connectors (`shared` is false), this field is stored
|
|
173
|
+
* per-user rather than in shared config.
|
|
174
|
+
*/
|
|
175
|
+
readonly keyOption?: string;
|
|
176
|
+
|
|
177
|
+
// ---- Optional metadata ----
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* When true, this connector has a single implicit channel.
|
|
181
|
+
* `getChannels()` must return exactly one Channel.
|
|
182
|
+
* The UI will show channel config inline instead of a channel list.
|
|
183
|
+
*/
|
|
184
|
+
readonly singleChannel?: boolean;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Registry of link types this connector creates (e.g., issue, event, message).
|
|
188
|
+
* Used for display in the UI (icons, labels, statuses).
|
|
189
|
+
*/
|
|
190
|
+
readonly linkTypes?: LinkTypeConfig[];
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* When true, this connector is mentioned by default on replies to threads it created.
|
|
194
|
+
* When false (default), this connector cannot be mentioned at all.
|
|
195
|
+
*
|
|
196
|
+
* Set this to true for connectors with bidirectional sync (e.g., issue trackers,
|
|
197
|
+
* messaging) where user replies should be written back to the external service.
|
|
198
|
+
*/
|
|
199
|
+
static readonly handleReplies?: boolean;
|
|
200
|
+
|
|
201
|
+
// ---- Account identity (abstract — every connector must implement) ----
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Returns a human-readable name for the connected account.
|
|
205
|
+
* Shown in the connections list and edit modal to identify this connection.
|
|
206
|
+
*
|
|
207
|
+
* For OAuth connectors, this is typically the workspace or organization name
|
|
208
|
+
* (e.g., "Acme Corp" for a Linear workspace). For API key connectors, this
|
|
209
|
+
* could be the workspace name from the external service.
|
|
210
|
+
*
|
|
211
|
+
* Override this in your connector to return a meaningful account name.
|
|
212
|
+
*
|
|
213
|
+
* @param auth - The authorization (null for no-provider connectors)
|
|
214
|
+
* @param token - The access token (null for no-provider connectors)
|
|
215
|
+
* @returns Promise resolving to the account display name
|
|
216
|
+
*/
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
218
|
+
getAccountName(
|
|
219
|
+
auth: Authorization | null,
|
|
220
|
+
token: AuthToken | null
|
|
221
|
+
): Promise<string | null> {
|
|
222
|
+
return Promise.resolve(null);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ---- Channel lifecycle (abstract — every connector must implement) ----
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Returns available channels for the authorized actor.
|
|
229
|
+
* Called after OAuth is complete, during the setup/edit modal.
|
|
230
|
+
*
|
|
231
|
+
* @param auth - The completed authorization with provider and actor info
|
|
232
|
+
* @param token - The access token for making API calls
|
|
233
|
+
* @returns Promise resolving to available channels for the user to select
|
|
234
|
+
*/
|
|
235
|
+
abstract getChannels(
|
|
236
|
+
auth: Authorization | null,
|
|
237
|
+
token: AuthToken | null
|
|
238
|
+
): Promise<Channel[]>;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Called when a channel resource is enabled for syncing.
|
|
242
|
+
*
|
|
243
|
+
* **IMPORTANT: This method runs inline in the HTTP request handler.**
|
|
244
|
+
* Any long-running work (webhook setup, API calls, sync) MUST be queued
|
|
245
|
+
* as a separate task via `this.runTask()`, not executed inline. Blocking
|
|
246
|
+
* here causes the client to spin waiting for the response.
|
|
247
|
+
*
|
|
248
|
+
* Only lightweight operations should appear directly in this method:
|
|
249
|
+
* `this.set()`, `this.get()`, `this.callback()`, and `this.runTask()`.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* async onChannelEnabled(channel: Channel): Promise<void> {
|
|
254
|
+
* await this.set(`sync_enabled_${channel.id}`, true);
|
|
255
|
+
* await this.set(`sync_state_${channel.id}`, { channelId: channel.id });
|
|
256
|
+
*
|
|
257
|
+
* // Queue sync as a task — do NOT use this.run() or call sync methods inline
|
|
258
|
+
* const syncCallback = await this.callback(this.syncBatch, 1, "full", channel.id, true);
|
|
259
|
+
* await this.runTask(syncCallback);
|
|
260
|
+
*
|
|
261
|
+
* // Queue webhook setup as a task — do NOT call setupWebhook() inline
|
|
262
|
+
* const webhookCallback = await this.callback(this.setupWebhook, channel.id);
|
|
263
|
+
* await this.runTask(webhookCallback);
|
|
264
|
+
* }
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* @param channel - The channel that was enabled
|
|
268
|
+
* @param context - Optional sync context with plan-based hints (e.g. syncHistoryMin)
|
|
269
|
+
*/
|
|
270
|
+
abstract onChannelEnabled(channel: Channel, context?: SyncContext): Promise<void>;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Called when a channel resource is disabled.
|
|
274
|
+
* Should stop sync, clean up webhooks, and remove state.
|
|
275
|
+
*
|
|
276
|
+
* @param channel - The channel that was disabled
|
|
277
|
+
*/
|
|
278
|
+
abstract onChannelDisabled(channel: Channel): Promise<void>;
|
|
279
|
+
|
|
280
|
+
// ---- Write-back hooks (optional, default no-ops) ----
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Called when a link created by this connector is updated by the user.
|
|
284
|
+
* Override to write back changes to the external service
|
|
285
|
+
* (e.g., changing issue status in Linear when marked done in Plot).
|
|
286
|
+
*
|
|
287
|
+
* @param link - The updated link
|
|
288
|
+
*/
|
|
289
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
290
|
+
onLinkUpdated(link: Link): Promise<void> {
|
|
291
|
+
return Promise.resolve();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Called when a user creates a thread in Plot that should create a new
|
|
296
|
+
* item in this connector's external system.
|
|
297
|
+
*
|
|
298
|
+
* A connector opts in to Plot-initiated creation by declaring a status
|
|
299
|
+
* with `createDefault: true` on the relevant `LinkTypeConfig`. When a
|
|
300
|
+
* user picks "Create new <type>" from the Add link modal and the thread
|
|
301
|
+
* is synced, the runtime calls this method with the draft fields.
|
|
302
|
+
*
|
|
303
|
+
* Implementations should create the item in the external service and
|
|
304
|
+
* return a `NewLinkWithNotes` describing the created item. The platform
|
|
305
|
+
* attaches the returned link to the originating thread — do not call
|
|
306
|
+
* `integrations.saveLink` yourself.
|
|
307
|
+
*
|
|
308
|
+
* Returning `null` aborts creation silently (the thread is still saved
|
|
309
|
+
* without a link).
|
|
310
|
+
*
|
|
311
|
+
* @param draft - The fields captured in Plot for the new item.
|
|
312
|
+
* @returns The link to attach, or null to abort creation.
|
|
313
|
+
*/
|
|
314
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
315
|
+
onCreateLink(draft: CreateLinkDraft): Promise<NewLinkWithNotes | null> {
|
|
316
|
+
return Promise.resolve(null);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Called when a note is created on a thread owned by this connector.
|
|
321
|
+
* Override to write back comments to the external service
|
|
322
|
+
* (e.g., adding a comment to a Linear issue).
|
|
323
|
+
*
|
|
324
|
+
* Returning a string or {@link NoteWriteBackResult} links the Plot note
|
|
325
|
+
* to its external counterpart. A plain string sets the note's `key`.
|
|
326
|
+
* A `NoteWriteBackResult` additionally sets a sync baseline (via
|
|
327
|
+
* `externalContent`) so the next sync-in can recognize the round-tripped
|
|
328
|
+
* content and preserve Plot's formatted version. See
|
|
329
|
+
* {@link NoteWriteBackResult} for details.
|
|
330
|
+
*
|
|
331
|
+
* @param note - The created note
|
|
332
|
+
* @param thread - The thread the note belongs to (includes thread.meta with connector-specific data)
|
|
333
|
+
* @returns Optional note key or NoteWriteBackResult for external dedup + baseline tracking
|
|
334
|
+
*/
|
|
335
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
336
|
+
onNoteCreated(note: Note, thread: Thread): Promise<string | NoteWriteBackResult | void> {
|
|
337
|
+
return Promise.resolve();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Called when a note on a thread owned by this connector is updated.
|
|
342
|
+
* Override to write back changes to the external service
|
|
343
|
+
* (e.g., syncing reaction tags as emoji reactions, or editing a comment
|
|
344
|
+
* whose content changed in Plot).
|
|
345
|
+
*
|
|
346
|
+
* Return a {@link NoteWriteBackResult} with `externalContent` to update
|
|
347
|
+
* the sync baseline after a successful write-back, so the next sync-in
|
|
348
|
+
* recognizes the external version as already-seen and preserves Plot's
|
|
349
|
+
* content.
|
|
350
|
+
*
|
|
351
|
+
* @param note - The updated note (includes current tags)
|
|
352
|
+
* @param thread - The thread the note belongs to (includes thread.meta with connector-specific data)
|
|
353
|
+
* @returns Optional NoteWriteBackResult for baseline tracking
|
|
354
|
+
*/
|
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
356
|
+
onNoteUpdated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {
|
|
357
|
+
return Promise.resolve();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Called when a user reads or unreads a thread owned by this connector.
|
|
362
|
+
* Override to write back read status to the external service
|
|
363
|
+
* (e.g., marking an email as read in Gmail).
|
|
364
|
+
*
|
|
365
|
+
* @param thread - The thread that was read/unread (includes thread.meta with connector-specific data)
|
|
366
|
+
* @param actor - The user who performed the action
|
|
367
|
+
* @param unread - false when marked as read, true when marked as unread
|
|
368
|
+
*/
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
370
|
+
onThreadRead(thread: Thread, actor: Actor, unread: boolean): Promise<void> {
|
|
371
|
+
return Promise.resolve();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Called when a user marks or unmarks a thread as todo.
|
|
376
|
+
* Override to sync todo status to the external service
|
|
377
|
+
* (e.g., starring an email in Gmail when marked as todo).
|
|
378
|
+
*
|
|
379
|
+
* @param thread - The thread (includes thread.meta with connector-specific data)
|
|
380
|
+
* @param actor - The user who changed the todo status
|
|
381
|
+
* @param todo - true when marked as todo, false when done or removed
|
|
382
|
+
* @param options - Additional context
|
|
383
|
+
* @param options.date - The todo date (when todo=true)
|
|
384
|
+
*/
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
386
|
+
onThreadToDo(thread: Thread, actor: Actor, todo: boolean, options: { date?: Date }): Promise<void> {
|
|
387
|
+
return Promise.resolve();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Called when a schedule contact's RSVP status changes on a thread owned by this connector.
|
|
392
|
+
* Override to sync RSVP changes back to the external calendar.
|
|
393
|
+
*
|
|
394
|
+
* @param thread - The thread (includes thread.meta with connector-specific data)
|
|
395
|
+
* @param scheduleId - The schedule ID
|
|
396
|
+
* @param contactId - The contact whose status changed
|
|
397
|
+
* @param status - The new RSVP status ('attend', 'skip', or null)
|
|
398
|
+
* @param actor - The user who changed the status
|
|
399
|
+
*/
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
401
|
+
onScheduleContactUpdated(thread: Thread, scheduleId: string, contactId: ActorId, status: ScheduleContactStatus | null, actor: Actor): Promise<void> {
|
|
402
|
+
return Promise.resolve();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// ---- Activation ----
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Called when the connector is activated after OAuth is complete.
|
|
409
|
+
*
|
|
410
|
+
* Connectors receive the authorization in addition to the activating actor.
|
|
411
|
+
* When this runs, `this.userId` is already populated with the installing
|
|
412
|
+
* user's ID.
|
|
413
|
+
*
|
|
414
|
+
* Default implementation does nothing. Override for custom setup.
|
|
415
|
+
*
|
|
416
|
+
* @param context - The activation context
|
|
417
|
+
* @param context.auth - The completed OAuth authorization
|
|
418
|
+
* @param context.actor - The actor who activated the connector
|
|
419
|
+
*/
|
|
420
|
+
// @ts-ignore - Connector.activate() has a Connector-specific context type.
|
|
421
|
+
activate(context: { auth?: Authorization; actor?: Actor }): Promise<void> {
|
|
422
|
+
return Promise.resolve();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** @deprecated Use `Connector` instead. */
|
|
427
|
+
export { Connector as Source };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import llmDocs from "./llm-docs/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets complete Twist Creator type definitions with import paths for LLM context.
|
|
5
|
+
*
|
|
6
|
+
* This function returns pre-generated Builder documentation that was bundled
|
|
7
|
+
* at build time. Used by twist generators to provide complete type
|
|
8
|
+
* information to LLMs.
|
|
9
|
+
*
|
|
10
|
+
* @returns Formatted string containing all Twist Creator type definitions with import paths
|
|
11
|
+
*/
|
|
12
|
+
export function getBuilderDocumentation(): string {
|
|
13
|
+
let documentation = "# Plot Twist Creator Type Definitions\n\n";
|
|
14
|
+
documentation +=
|
|
15
|
+
"Complete type definitions with JSDoc documentation for all Plot Twist Creator types.\n";
|
|
16
|
+
documentation +=
|
|
17
|
+
"These are the source files - use the import paths shown to import types in your twist code.\n\n";
|
|
18
|
+
|
|
19
|
+
// Format each Builder file with headers and code fences
|
|
20
|
+
for (const [importPath, content] of Object.entries(llmDocs)) {
|
|
21
|
+
documentation += `## ${importPath}\n\n`;
|
|
22
|
+
documentation += "```typescript\n";
|
|
23
|
+
documentation += `// Import from: ${importPath}\n\n`;
|
|
24
|
+
documentation += content;
|
|
25
|
+
documentation += "\n```\n\n";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return documentation;
|
|
29
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./twist";
|
|
2
|
+
export * from "./connector";
|
|
3
|
+
export * from "./plot";
|
|
4
|
+
export * from "./schedule";
|
|
5
|
+
export * from "./tag";
|
|
6
|
+
export * from "./tool";
|
|
7
|
+
export * from "./tools";
|
|
8
|
+
export * from "./options";
|
|
9
|
+
export * from "./utils/types";
|
|
10
|
+
export { getBuilderDocumentation } from "./creator-docs";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated LLM documentation for @plotday/twister/connector
|
|
3
|
+
*
|
|
4
|
+
* This file is auto-generated during build. Do not edit manually.
|
|
5
|
+
* Generated from: prebuild.ts
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export default "import { type Actor, type ActorId, type Link, type NewLinkWithNotes, type Note, type Thread } from \"./plot\";\nimport type { ScheduleContactStatus } from \"./schedule\";\nimport {\n type AuthProvider,\n type AuthToken,\n type Authorization,\n type Channel,\n type LinkTypeConfig,\n type SyncContext,\n} from \"./tools/integrations\";\nimport { Twist } from \"./twist\";\n\n/**\n * Fields captured in Plot when a user initiates creation of a new external\n * item via a connector's `onCreateLink` hook.\n *\n * Thread-agnostic on purpose — connectors do not receive the Plot thread.\n * The platform attaches the returned `NewLinkWithNotes` to the originating\n * thread once `onCreateLink` resolves.\n */\n/**\n * Result returned from {@link Connector.onNoteCreated} and\n * {@link Connector.onNoteUpdated} to report what the external system now\n * has stored for the note.\n *\n * The runtime hashes `externalContent` and stores it as the note's sync\n * baseline. On the next sync-in, if the incoming content hashes to the\n * same value, the runtime knows the external side hasn't changed and\n * preserves Plot's (possibly formatted) content. When the external side\n * is edited, the hash diverges and the runtime overwrites Plot's content\n * with the new external version.\n *\n * Omitting `externalContent` skips baseline tracking — the next sync-in\n * will overwrite Plot's content (previous behavior). Always provide it\n * when the write-back's return value reflects what the external system\n * actually stored (often lossy plain-text), so the round-trip does not\n * clobber the original Plot markdown.\n *\n * The hash covers only the content string — the runtime intentionally\n * does not include a content-type in the hash, so write-back and sync-in\n * do not have to agree on a content-type label for the same underlying\n * bytes. Return exactly the string your connector's sync-in path will\n * emit as `NewNote.content` for this note on the next re-ingest.\n *\n * For back-compat, `onNoteCreated` may also return a plain string, which\n * is treated as `{ key }` with no baseline.\n */\nexport type NoteWriteBackResult = {\n /**\n * External system identifier assigned to this note. Set as the note's\n * `key` for future upsert matching. Required when the runtime does not\n * already know the key (i.e., from `onNoteCreated`); ignored from\n * `onNoteUpdated` when the key was already established on create.\n */\n key?: string;\n /**\n * The content string as the external system now stores it, post-write.\n * For systems whose write-back returns a representation of what was\n * actually stored (e.g. Google Drive comment `content` after a create),\n * pass that verbatim. For systems that only accept plain text, this\n * will often be a lossy plain-text version of the Plot markdown — that\n * is exactly the point: storing the lossy form as baseline lets the\n * next sync-in recognize it and skip overwriting the richer Plot\n * version.\n *\n * Must exactly match the string your connector's sync-in path emits as\n * `NewNote.content` for this note on re-ingest.\n */\n externalContent?: string;\n};\n\nexport type CreateLinkDraft = {\n /** The channel (account + resource) the new item belongs to. */\n channelId: string;\n /** Link type identifier, matches a `LinkTypeConfig.type`. */\n type: string;\n /** Status the user selected. Matches a `statuses[].status` for `type`. */\n status: string;\n /** Title of the originating Plot thread (post AI title generation). */\n title: string;\n /** Markdown content of the thread's first note, or null if none. */\n noteContent: string | null;\n /**\n * Contacts attached to the originating Plot thread, excluding the\n * creating user. Use these as recipients (email, chat DM members, etc.)\n * when the external item is a message or invite. An empty list means\n * the user did not add anyone to the thread.\n */\n contacts: Actor[];\n};\n\n/**\n * Base class for connectors — twists that sync data from external services.\n *\n * Connectors declare a single OAuth provider and scopes, and implement channel\n * lifecycle methods for discovering and syncing external resources. They save\n * data directly via `integrations.saveLink()` instead of using the Plot tool.\n *\n * @example\n * ```typescript\n * class LinearConnector extends Connector<LinearConnector> {\n * readonly provider = AuthProvider.Linear;\n * readonly scopes = [\"read\", \"write\"];\n * readonly linkTypes = [{\n * type: \"issue\",\n * label: \"Issue\",\n * statuses: [\n * { status: \"open\", label: \"Open\" },\n * { status: \"done\", label: \"Done\" },\n * ],\n * }];\n *\n * build(build: ToolBuilder) {\n * return {\n * integrations: build(Integrations),\n * };\n * }\n *\n * async getChannels(auth: Authorization, token: AuthToken): Promise<Channel[]> {\n * const teams = await this.listTeams(token);\n * return teams.map(t => ({ id: t.id, title: t.name }));\n * }\n *\n * async onChannelEnabled(channel: Channel) {\n * const issues = await this.fetchIssues(channel.id);\n * for (const issue of issues) {\n * await this.tools.integrations.saveLink(issue);\n * }\n * }\n *\n * async onChannelDisabled(channel: Channel) {\n * // Clean up webhooks, sync state, etc.\n * }\n * }\n * ```\n */\nexport abstract class Connector<TSelf> extends Twist<TSelf> {\n /**\n * Static marker to identify Connector subclasses without instanceof checks\n * across worker boundaries.\n */\n static readonly isConnector = true;\n\n // ---- Identity (abstract — every connector must declare) ----\n\n /** The OAuth provider this connector authenticates with. */\n readonly provider?: AuthProvider;\n\n /** OAuth scopes to request for this connector. */\n readonly scopes?: string[];\n\n // ---- Auth model ----\n\n /**\n * When true, one credential is shared across all users in the workspace,\n * entered once by the installer. When false (default), each user provides\n * their own credential.\n *\n * Applies to both OAuth and key-based connectors:\n * - Shared OAuth: e.g. Slack bot token (workspace-level)\n * - Shared key: e.g. Attio workspace API key\n * - Individual OAuth: e.g. Google Calendar (per-user)\n * - Individual key: e.g. Fellow (per-user API key)\n */\n readonly shared?: boolean;\n\n /**\n * The Options field name that contains the authentication key (e.g. \"apiKey\").\n * Must reference a `secure: true` field in the Options schema.\n *\n * When set, this connector uses key-based auth instead of OAuth.\n * For individual connectors (`shared` is false), this field is stored\n * per-user rather than in shared config.\n */\n readonly keyOption?: string;\n\n // ---- Optional metadata ----\n\n /**\n * When true, this connector has a single implicit channel.\n * `getChannels()` must return exactly one Channel.\n * The UI will show channel config inline instead of a channel list.\n */\n readonly singleChannel?: boolean;\n\n /**\n * Registry of link types this connector creates (e.g., issue, event, message).\n * Used for display in the UI (icons, labels, statuses).\n */\n readonly linkTypes?: LinkTypeConfig[];\n\n /**\n * When true, this connector is mentioned by default on replies to threads it created.\n * When false (default), this connector cannot be mentioned at all.\n *\n * Set this to true for connectors with bidirectional sync (e.g., issue trackers,\n * messaging) where user replies should be written back to the external service.\n */\n static readonly handleReplies?: boolean;\n\n // ---- Account identity (abstract — every connector must implement) ----\n\n /**\n * Returns a human-readable name for the connected account.\n * Shown in the connections list and edit modal to identify this connection.\n *\n * For OAuth connectors, this is typically the workspace or organization name\n * (e.g., \"Acme Corp\" for a Linear workspace). For API key connectors, this\n * could be the workspace name from the external service.\n *\n * Override this in your connector to return a meaningful account name.\n *\n * @param auth - The authorization (null for no-provider connectors)\n * @param token - The access token (null for no-provider connectors)\n * @returns Promise resolving to the account display name\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getAccountName(\n auth: Authorization | null,\n token: AuthToken | null\n ): Promise<string | null> {\n return Promise.resolve(null);\n }\n\n // ---- Channel lifecycle (abstract — every connector must implement) ----\n\n /**\n * Returns available channels for the authorized actor.\n * Called after OAuth is complete, during the setup/edit modal.\n *\n * @param auth - The completed authorization with provider and actor info\n * @param token - The access token for making API calls\n * @returns Promise resolving to available channels for the user to select\n */\n abstract getChannels(\n auth: Authorization | null,\n token: AuthToken | null\n ): Promise<Channel[]>;\n\n /**\n * Called when a channel resource is enabled for syncing.\n *\n * **IMPORTANT: This method runs inline in the HTTP request handler.**\n * Any long-running work (webhook setup, API calls, sync) MUST be queued\n * as a separate task via `this.runTask()`, not executed inline. Blocking\n * here causes the client to spin waiting for the response.\n *\n * Only lightweight operations should appear directly in this method:\n * `this.set()`, `this.get()`, `this.callback()`, and `this.runTask()`.\n *\n * @example\n * ```typescript\n * async onChannelEnabled(channel: Channel): Promise<void> {\n * await this.set(`sync_enabled_${channel.id}`, true);\n * await this.set(`sync_state_${channel.id}`, { channelId: channel.id });\n *\n * // Queue sync as a task — do NOT use this.run() or call sync methods inline\n * const syncCallback = await this.callback(this.syncBatch, 1, \"full\", channel.id, true);\n * await this.runTask(syncCallback);\n *\n * // Queue webhook setup as a task — do NOT call setupWebhook() inline\n * const webhookCallback = await this.callback(this.setupWebhook, channel.id);\n * await this.runTask(webhookCallback);\n * }\n * ```\n *\n * @param channel - The channel that was enabled\n * @param context - Optional sync context with plan-based hints (e.g. syncHistoryMin)\n */\n abstract onChannelEnabled(channel: Channel, context?: SyncContext): Promise<void>;\n\n /**\n * Called when a channel resource is disabled.\n * Should stop sync, clean up webhooks, and remove state.\n *\n * @param channel - The channel that was disabled\n */\n abstract onChannelDisabled(channel: Channel): Promise<void>;\n\n // ---- Write-back hooks (optional, default no-ops) ----\n\n /**\n * Called when a link created by this connector is updated by the user.\n * Override to write back changes to the external service\n * (e.g., changing issue status in Linear when marked done in Plot).\n *\n * @param link - The updated link\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLinkUpdated(link: Link): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when a user creates a thread in Plot that should create a new\n * item in this connector's external system.\n *\n * A connector opts in to Plot-initiated creation by declaring a status\n * with `createDefault: true` on the relevant `LinkTypeConfig`. When a\n * user picks \"Create new <type>\" from the Add link modal and the thread\n * is synced, the runtime calls this method with the draft fields.\n *\n * Implementations should create the item in the external service and\n * return a `NewLinkWithNotes` describing the created item. The platform\n * attaches the returned link to the originating thread — do not call\n * `integrations.saveLink` yourself.\n *\n * Returning `null` aborts creation silently (the thread is still saved\n * without a link).\n *\n * @param draft - The fields captured in Plot for the new item.\n * @returns The link to attach, or null to abort creation.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onCreateLink(draft: CreateLinkDraft): Promise<NewLinkWithNotes | null> {\n return Promise.resolve(null);\n }\n\n /**\n * Called when a note is created on a thread owned by this connector.\n * Override to write back comments to the external service\n * (e.g., adding a comment to a Linear issue).\n *\n * Returning a string or {@link NoteWriteBackResult} links the Plot note\n * to its external counterpart. A plain string sets the note's `key`.\n * A `NoteWriteBackResult` additionally sets a sync baseline (via\n * `externalContent`) so the next sync-in can recognize the round-tripped\n * content and preserve Plot's formatted version. See\n * {@link NoteWriteBackResult} for details.\n *\n * @param note - The created note\n * @param thread - The thread the note belongs to (includes thread.meta with connector-specific data)\n * @returns Optional note key or NoteWriteBackResult for external dedup + baseline tracking\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onNoteCreated(note: Note, thread: Thread): Promise<string | NoteWriteBackResult | void> {\n return Promise.resolve();\n }\n\n /**\n * Called when a note on a thread owned by this connector is updated.\n * Override to write back changes to the external service\n * (e.g., syncing reaction tags as emoji reactions, or editing a comment\n * whose content changed in Plot).\n *\n * Return a {@link NoteWriteBackResult} with `externalContent` to update\n * the sync baseline after a successful write-back, so the next sync-in\n * recognizes the external version as already-seen and preserves Plot's\n * content.\n *\n * @param note - The updated note (includes current tags)\n * @param thread - The thread the note belongs to (includes thread.meta with connector-specific data)\n * @returns Optional NoteWriteBackResult for baseline tracking\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onNoteUpdated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {\n return Promise.resolve();\n }\n\n /**\n * Called when a user reads or unreads a thread owned by this connector.\n * Override to write back read status to the external service\n * (e.g., marking an email as read in Gmail).\n *\n * @param thread - The thread that was read/unread (includes thread.meta with connector-specific data)\n * @param actor - The user who performed the action\n * @param unread - false when marked as read, true when marked as unread\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onThreadRead(thread: Thread, actor: Actor, unread: boolean): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when a user marks or unmarks a thread as todo.\n * Override to sync todo status to the external service\n * (e.g., starring an email in Gmail when marked as todo).\n *\n * @param thread - The thread (includes thread.meta with connector-specific data)\n * @param actor - The user who changed the todo status\n * @param todo - true when marked as todo, false when done or removed\n * @param options - Additional context\n * @param options.date - The todo date (when todo=true)\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onThreadToDo(thread: Thread, actor: Actor, todo: boolean, options: { date?: Date }): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called when a schedule contact's RSVP status changes on a thread owned by this connector.\n * Override to sync RSVP changes back to the external calendar.\n *\n * @param thread - The thread (includes thread.meta with connector-specific data)\n * @param scheduleId - The schedule ID\n * @param contactId - The contact whose status changed\n * @param status - The new RSVP status ('attend', 'skip', or null)\n * @param actor - The user who changed the status\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onScheduleContactUpdated(thread: Thread, scheduleId: string, contactId: ActorId, status: ScheduleContactStatus | null, actor: Actor): Promise<void> {\n return Promise.resolve();\n }\n\n // ---- Activation ----\n\n /**\n * Called when the connector is activated after OAuth is complete.\n *\n * Connectors receive the authorization in addition to the activating actor.\n * When this runs, `this.userId` is already populated with the installing\n * user's ID.\n *\n * Default implementation does nothing. Override for custom setup.\n *\n * @param context - The activation context\n * @param context.auth - The completed OAuth authorization\n * @param context.actor - The actor who activated the connector\n */\n // @ts-ignore - Connector.activate() has a Connector-specific context type.\n activate(context: { auth?: Authorization; actor?: Actor }): Promise<void> {\n return Promise.resolve();\n }\n}\n\n/** @deprecated Use `Connector` instead. */\nexport { Connector as Source };\n";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated LLM documentation index
|
|
3
|
+
*
|
|
4
|
+
* This file is auto-generated during build. Do not edit manually.
|
|
5
|
+
* Generated from: prebuild.ts
|
|
6
|
+
*
|
|
7
|
+
* Provides a mapping of Twister import paths to their source code documentation.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import connector from "./connector.js";
|
|
11
|
+
import options from "./options.js";
|
|
12
|
+
import plot from "./plot.js";
|
|
13
|
+
import schedule from "./schedule.js";
|
|
14
|
+
import tag from "./tag.js";
|
|
15
|
+
import tool from "./tool.js";
|
|
16
|
+
import twist from "./twist.js";
|
|
17
|
+
import tools_ai from "./tools/ai.js";
|
|
18
|
+
import tools_callbacks from "./tools/callbacks.js";
|
|
19
|
+
import tools_imap from "./tools/imap.js";
|
|
20
|
+
import tools_integrations from "./tools/integrations.js";
|
|
21
|
+
import tools_network from "./tools/network.js";
|
|
22
|
+
import tools_plot from "./tools/plot.js";
|
|
23
|
+
import tools_smtp from "./tools/smtp.js";
|
|
24
|
+
import tools_store from "./tools/store.js";
|
|
25
|
+
import tools_tasks from "./tools/tasks.js";
|
|
26
|
+
import tools_twists from "./tools/twists.js";
|
|
27
|
+
|
|
28
|
+
const llmDocs: Record<string, string> = {
|
|
29
|
+
"@plotday/twister/connector": connector,
|
|
30
|
+
"@plotday/twister/options": options,
|
|
31
|
+
"@plotday/twister/plot": plot,
|
|
32
|
+
"@plotday/twister/schedule": schedule,
|
|
33
|
+
"@plotday/twister/tag": tag,
|
|
34
|
+
"@plotday/twister/tool": tool,
|
|
35
|
+
"@plotday/twister/twist": twist,
|
|
36
|
+
"@plotday/twister/tools/ai": tools_ai,
|
|
37
|
+
"@plotday/twister/tools/callbacks": tools_callbacks,
|
|
38
|
+
"@plotday/twister/tools/imap": tools_imap,
|
|
39
|
+
"@plotday/twister/tools/integrations": tools_integrations,
|
|
40
|
+
"@plotday/twister/tools/network": tools_network,
|
|
41
|
+
"@plotday/twister/tools/plot": tools_plot,
|
|
42
|
+
"@plotday/twister/tools/smtp": tools_smtp,
|
|
43
|
+
"@plotday/twister/tools/store": tools_store,
|
|
44
|
+
"@plotday/twister/tools/tasks": tools_tasks,
|
|
45
|
+
"@plotday/twister/tools/twists": tools_twists
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default llmDocs;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated LLM documentation for @plotday/twister/options
|
|
3
|
+
*
|
|
4
|
+
* This file is auto-generated during build. Do not edit manually.
|
|
5
|
+
* Generated from: prebuild.ts
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export default "import { ITool } from \"./tool\";\n\n/**\n * A select option definition for twist configuration.\n * Renders as a dropdown in the Flutter UI.\n */\nexport type SelectDef = {\n type: \"select\";\n label: string;\n description?: string;\n choices: ReadonlyArray<{ value: string; label: string }>;\n default: string;\n};\n\n/**\n * A text input option definition for twist configuration.\n * Renders as a text field in the Flutter UI.\n */\nexport type TextDef = {\n type: \"text\";\n label: string;\n description?: string;\n default: string;\n placeholder?: string;\n secure?: boolean; // Encrypted at rest, masked in UI, never returned to clients\n helpText?: string; // Help text displayed below the input field\n helpUrl?: string; // URL for a \"Learn more\" link shown after helpText\n};\n\n/**\n * A number input option definition for twist configuration.\n * Renders as a number field in the Flutter UI.\n */\nexport type NumberDef = {\n type: \"number\";\n label: string;\n description?: string;\n default: number;\n min?: number;\n max?: number;\n};\n\n/**\n * A boolean toggle option definition for twist configuration.\n * Renders as a switch in the Flutter UI.\n */\nexport type BooleanDef = {\n type: \"boolean\";\n label: string;\n description?: string;\n default: boolean;\n};\n\n/**\n * Union of all option definition types.\n */\nexport type OptionDef = SelectDef | TextDef | NumberDef | BooleanDef;\n\n/**\n * Schema defining all configurable options for a twist.\n * Each key maps to an option definition that describes its type, label, and default value.\n */\nexport type OptionsSchema = Record<string, OptionDef>;\n\n/**\n * Infers the resolved value types from an options schema.\n * Boolean options resolve to `boolean`, number options to `number`,\n * and select/text options to `string`.\n */\nexport type ResolvedOptions<T extends OptionsSchema> = {\n [K in keyof T]: T[K] extends BooleanDef\n ? boolean\n : T[K] extends NumberDef\n ? number\n : string;\n};\n\n/**\n * Built-in marker class for twist configuration options.\n *\n * Declare options in your twist's `build()` method to expose configurable\n * settings to users. The schema is introspected at deploy time and stored\n * alongside permissions. At runtime, user values are merged with defaults.\n *\n * @example\n * ```typescript\n * import { Options, type OptionsSchema } from \"@plotday/twister/options\";\n *\n * export default class MyTwist extends Twist<MyTwist> {\n * build(build: ToolBuilder) {\n * return {\n * options: build(Options, {\n * model: {\n * type: 'select',\n * label: 'AI Model',\n * choices: [\n * { value: 'fast', label: 'Fast' },\n * { value: 'smart', label: 'Smart' },\n * ],\n * default: 'fast',\n * },\n * }),\n * // ... other tools\n * };\n * }\n *\n * async respond(note: Note) {\n * const model = this.tools.options.model; // typed as string\n * }\n * }\n * ```\n */\nexport abstract class Options extends ITool {\n static readonly toolId = \"Options\";\n}\n";
|