@plotday/twister 0.48.0 → 0.50.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/templates/AGENTS.template.md +8 -2
- package/cli/templates/AGENTS.template.md +8 -2
- package/dist/connector.d.ts +97 -10
- 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 +84 -51
- 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 +55 -9
- package/dist/docs/classes/tools_network.Network.html +1 -1
- package/dist/docs/classes/tools_plot.Plot.html +11 -19
- package/dist/docs/classes/tools_store.Store.html +25 -2
- 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/Built-in_Tools.html +1 -1
- package/dist/docs/documents/Runtime_Environment.html +25 -1
- package/dist/docs/enums/plot.ActorType.html +4 -4
- package/dist/docs/enums/tag.Tag.html +11 -1
- package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
- 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.NewScheduleOccurrence.html +15 -2
- package/dist/docs/types/index.NoteWriteBackResult.html +38 -0
- package/dist/docs/types/index.ScheduleOccurrence.html +2 -4
- package/dist/docs/types/index.ScheduleOccurrenceUpdate.html +1 -1
- package/dist/docs/types/plot.Actor.html +5 -5
- package/dist/docs/types/plot.Contact.html +4 -4
- package/dist/docs/types/plot.ContentType.html +1 -1
- package/dist/docs/types/plot.Link.html +15 -15
- package/dist/docs/types/plot.LinkUpdate.html +1 -1
- package/dist/docs/types/plot.NewActor.html +1 -1
- package/dist/docs/types/plot.NewContact.html +1 -1
- package/dist/docs/types/plot.NewLink.html +1 -1
- package/dist/docs/types/plot.NewLinkWithNotes.html +1 -1
- package/dist/docs/types/plot.NewNote.html +1 -1
- package/dist/docs/types/plot.Note.html +7 -1
- package/dist/docs/types/plot.NoteUpdate.html +1 -1
- package/dist/docs/types/plot.PlanOperation.html +1 -1
- 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/docs/types/tools_integrations.SyncContext.html +21 -2
- 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/plot.d.ts +1 -1
- package/dist/llm-docs/plot.d.ts.map +1 -1
- package/dist/llm-docs/plot.js +1 -1
- package/dist/llm-docs/plot.js.map +1 -1
- package/dist/llm-docs/schedule.d.ts +1 -1
- package/dist/llm-docs/schedule.d.ts.map +1 -1
- package/dist/llm-docs/schedule.js +1 -1
- package/dist/llm-docs/schedule.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/tools/plot.d.ts +1 -1
- package/dist/llm-docs/tools/plot.d.ts.map +1 -1
- package/dist/llm-docs/tools/plot.js +1 -1
- package/dist/llm-docs/tools/plot.js.map +1 -1
- package/dist/llm-docs/tools/store.d.ts +1 -1
- package/dist/llm-docs/tools/store.d.ts.map +1 -1
- package/dist/llm-docs/tools/store.js +1 -1
- package/dist/llm-docs/tools/store.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/plot.d.ts +8 -1
- package/dist/plot.d.ts.map +1 -1
- package/dist/plot.js.map +1 -1
- package/dist/schedule.d.ts +18 -2
- package/dist/schedule.d.ts.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 +86 -0
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js.map +1 -1
- package/dist/tools/plot.d.ts +0 -11
- package/dist/tools/plot.d.ts.map +1 -1
- package/dist/tools/plot.js.map +1 -1
- package/dist/tools/store.d.ts +40 -0
- package/dist/tools/store.d.ts.map +1 -1
- package/dist/tools/store.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 +6 -1
- package/src/connector.ts +98 -10
- package/src/llm-docs/connector.ts +1 -1
- package/src/llm-docs/plot.ts +1 -1
- package/src/llm-docs/schedule.ts +1 -1
- package/src/llm-docs/tag.ts +1 -1
- package/src/llm-docs/tools/integrations.ts +1 -1
- package/src/llm-docs/tools/plot.ts +1 -1
- package/src/llm-docs/tools/store.ts +1 -1
- package/src/llm-docs/twist-guide-template.ts +1 -1
- package/src/llm-docs/twist.ts +1 -1
- package/src/plot.ts +8 -1
- package/src/schedule.ts +19 -3
- package/src/tag.ts +10 -0
- package/src/tools/integrations.ts +93 -0
- package/src/tools/plot.ts +0 -12
- package/src/tools/store.ts +44 -0
- package/src/twist.ts +2 -1
- package/src/utils/markdown.ts +94 -0
package/dist/tag.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../src/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,GAAG;IAEb,IAAI,IAAI;IACR,IAAI,IAAI;IAGR,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,IAAI,MAAM;IACV,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,KAAK,MAAM;IACX,IAAI,MAAM;IACV,IAAI,MAAM;IAGV,GAAG,OAAO;IACV,EAAE,OAAO;IACT,SAAS,OAAO;IAChB,IAAI,OAAO;IACX,IAAI,OAAO;IACX,OAAO,OAAO;IACd,OAAO,OAAO;IACd,IAAI,OAAO;IACX,MAAM,OAAO;IACb,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,KAAK,OAAO;IACZ,IAAI,OAAO;IACX,MAAM,OAAO;IACb,QAAQ,OAAO;IACf,IAAI,OAAO;IACX,GAAG,OAAO;IACV,KAAK,OAAO;
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../src/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,GAAG;IAEb,IAAI,IAAI;IACR,IAAI,IAAI;IAGR,MAAM,MAAM;IACZ,MAAM,MAAM;IACZ,IAAI,MAAM;IACV,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,KAAK,MAAM;IACX,IAAI,MAAM;IACV,IAAI,MAAM;IAGV,GAAG,OAAO;IACV,EAAE,OAAO;IACT,SAAS,OAAO;IAChB,IAAI,OAAO;IACX,IAAI,OAAO;IACX,OAAO,OAAO;IACd,OAAO,OAAO;IACd,IAAI,OAAO;IACX,MAAM,OAAO;IACb,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,KAAK,OAAO;IACZ,IAAI,OAAO;IACX,MAAM,OAAO;IACb,QAAQ,OAAO;IACf,IAAI,OAAO;IACX,GAAG,OAAO;IACV,KAAK,OAAO;IACZ,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,QAAQ,OAAO;IACf,IAAI,OAAO;IACX,KAAK,OAAO;IACZ,KAAK,OAAO;IACZ,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,QAAQ,OAAO;CAChB"}
|
package/dist/tag.js
CHANGED
|
@@ -40,5 +40,15 @@ export var Tag;
|
|
|
40
40
|
Tag[Tag["Cool"] = 1017] = "Cool";
|
|
41
41
|
Tag[Tag["Sad"] = 1018] = "Sad";
|
|
42
42
|
Tag[Tag["Reply"] = 1019] = "Reply";
|
|
43
|
+
Tag[Tag["Thinking"] = 1013] = "Thinking";
|
|
44
|
+
Tag[Tag["Remember"] = 1014] = "Remember";
|
|
45
|
+
Tag[Tag["Agreed"] = 1020] = "Agreed";
|
|
46
|
+
Tag[Tag["Relieved"] = 1021] = "Relieved";
|
|
47
|
+
Tag[Tag["Send"] = 1022] = "Send";
|
|
48
|
+
Tag[Tag["Noted"] = 1023] = "Noted";
|
|
49
|
+
Tag[Tag["Laugh"] = 1024] = "Laugh";
|
|
50
|
+
Tag[Tag["Surprised"] = 1025] = "Surprised";
|
|
51
|
+
Tag[Tag["Confused"] = 1026] = "Confused";
|
|
52
|
+
Tag[Tag["Dismayed"] = 1027] = "Dismayed";
|
|
43
53
|
})(Tag || (Tag = {}));
|
|
44
54
|
//# sourceMappingURL=tag.js.map
|
package/dist/tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../src/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../src/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,GA+CX;AA/CD,WAAY,GAAG;IACb,eAAe;IACf,6BAAQ,CAAA;IACR,6BAAQ,CAAA;IAER,cAAc;IACd,mCAAY,CAAA;IACZ,mCAAY,CAAA;IACZ,+BAAU,CAAA;IACV,uCAAc,CAAA;IACd,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,uCAAc,CAAA;IACd,iCAAW,CAAA;IACX,+BAAU,CAAA;IACV,+BAAU,CAAA;IAEV,aAAa;IACb,8BAAU,CAAA;IACV,4BAAS,CAAA;IACT,0CAAgB,CAAA;IAChB,gCAAW,CAAA;IACX,gCAAW,CAAA;IACX,sCAAc,CAAA;IACd,sCAAc,CAAA;IACd,gCAAW,CAAA;IACX,oCAAa,CAAA;IACb,wCAAe,CAAA;IACf,oCAAa,CAAA;IACb,kCAAY,CAAA;IACZ,gCAAW,CAAA;IACX,oCAAa,CAAA;IACb,wCAAe,CAAA;IACf,gCAAW,CAAA;IACX,8BAAU,CAAA;IACV,kCAAY,CAAA;IACZ,wCAAe,CAAA;IACf,wCAAe,CAAA;IACf,oCAAa,CAAA;IACb,wCAAe,CAAA;IACf,gCAAW,CAAA;IACX,kCAAY,CAAA;IACZ,kCAAY,CAAA;IACZ,0CAAgB,CAAA;IAChB,wCAAe,CAAA;IACf,wCAAe,CAAA;AACjB,CAAC,EA/CW,GAAG,KAAH,GAAG,QA+Cd"}
|
|
@@ -78,6 +78,28 @@ export type SyncContext = {
|
|
|
78
78
|
* Undefined when no limit applies.
|
|
79
79
|
*/
|
|
80
80
|
syncHistoryMin?: Date;
|
|
81
|
+
/**
|
|
82
|
+
* True when this is a recovery dispatch after the connection's auth was
|
|
83
|
+
* restored (the user re-authorized a previously-broken connection).
|
|
84
|
+
*
|
|
85
|
+
* The framework calls `onChannelEnabled` again for every channel that was
|
|
86
|
+
* already enabled at the time of re-auth so the connector can recover from
|
|
87
|
+
* the auth gap. Connectors should:
|
|
88
|
+
*
|
|
89
|
+
* 1. Drop any persisted incremental sync cursors / sync tokens so the
|
|
90
|
+
* next sync re-walks history (the cursor may be stale or invalid —
|
|
91
|
+
* Google Calendar invalidates syncTokens after ~7 days).
|
|
92
|
+
* 2. Re-register webhooks (any prior subscription may have been
|
|
93
|
+
* invalidated during the auth outage).
|
|
94
|
+
* 3. Treat this as a backfill that walks history but does NOT spam
|
|
95
|
+
* notifications — set `unread: false` and `archived: false` on
|
|
96
|
+
* items as you would during initial sync.
|
|
97
|
+
*
|
|
98
|
+
* Most connectors can take the same code path as a fresh
|
|
99
|
+
* `onChannelEnabled` for `recovering: true` as long as that path
|
|
100
|
+
* overwrites stored state rather than appending to it.
|
|
101
|
+
*/
|
|
102
|
+
recovering?: boolean;
|
|
81
103
|
};
|
|
82
104
|
/**
|
|
83
105
|
* Built-in tool for managing OAuth authentication and channel resources.
|
|
@@ -173,6 +195,28 @@ export declare abstract class Integrations extends ITool {
|
|
|
173
195
|
* link was filtered out (e.g. older than the plan's sync history limit)
|
|
174
196
|
*/
|
|
175
197
|
abstract saveLink(link: NewLinkWithNotes): Promise<Uuid | null>;
|
|
198
|
+
/**
|
|
199
|
+
* Batch version of {@link saveLink} — saves many links in one call.
|
|
200
|
+
*
|
|
201
|
+
* Connectors syncing many items per page (e.g. calendar events, issues,
|
|
202
|
+
* messages) should prefer this over looping `saveLink`. Each `saveLink`
|
|
203
|
+
* crosses the runtime boundary and counts against the per-execution
|
|
204
|
+
* request budget; `saveLinks` collapses N saves into a single crossing.
|
|
205
|
+
*
|
|
206
|
+
* Failures on individual links DO NOT abort the batch. A bad item lands
|
|
207
|
+
* as `null` in its slot and the rest still save. This prevents one
|
|
208
|
+
* malformed record from losing an entire page of sync progress.
|
|
209
|
+
*
|
|
210
|
+
* This method is available only to Connectors (not regular Twists).
|
|
211
|
+
*
|
|
212
|
+
* @param links - Array of links with notes to save
|
|
213
|
+
* @returns Array of the same length and order as `links`. Each entry is
|
|
214
|
+
* the saved thread's UUID, or `null` if the link was filtered out
|
|
215
|
+
* (e.g. older than the plan's sync history limit) OR failed to save.
|
|
216
|
+
* The two null causes are not distinguished; the save failure is
|
|
217
|
+
* logged server-side.
|
|
218
|
+
*/
|
|
219
|
+
abstract saveLinks(links: NewLinkWithNotes[]): Promise<(Uuid | null)[]>;
|
|
176
220
|
/**
|
|
177
221
|
* Saves contacts to the connector's priority.
|
|
178
222
|
*
|
|
@@ -202,6 +246,48 @@ export declare abstract class Integrations extends ITool {
|
|
|
202
246
|
abstract setThreadToDo(source: string, actorId: ActorId, todo: boolean, options?: {
|
|
203
247
|
date?: Date | string;
|
|
204
248
|
}): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Signal that initial bulk-sync (or recovery sync) for a channel is fully
|
|
251
|
+
* complete. The Flutter app uses this to clear the "syncing…" indicator
|
|
252
|
+
* on the connection.
|
|
253
|
+
*
|
|
254
|
+
* The framework automatically marks a channel as syncing when it dispatches
|
|
255
|
+
* `onChannelEnabled` (whether initial-enable, auto-enable from
|
|
256
|
+
* `setChannels`, or recovery after re-auth). Connectors do NOT need to
|
|
257
|
+
* call anything to start tracking — only to signal completion.
|
|
258
|
+
*
|
|
259
|
+
* Call this exactly once when the initial backfill has finished (no more
|
|
260
|
+
* pages, all phases exhausted). Do NOT call it on every incremental sync.
|
|
261
|
+
*
|
|
262
|
+
* If `onChannelEnabled` throws an unhandled exception, the framework
|
|
263
|
+
* automatically clears the syncing state — connectors don't need a
|
|
264
|
+
* `try/catch` to clear state on failure.
|
|
265
|
+
*
|
|
266
|
+
* No-op when no auth/user mapping exists for the channel (e.g. key-based
|
|
267
|
+
* connectors that don't have a per-user OAuth association).
|
|
268
|
+
*
|
|
269
|
+
* @param channelId - The channel resource ID whose initial sync just finished
|
|
270
|
+
*/
|
|
271
|
+
abstract channelSyncCompleted(channelId: string): Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Flag a connection as needing re-authentication so the Flutter app
|
|
274
|
+
* surfaces a re-auth prompt on the next sync.
|
|
275
|
+
*
|
|
276
|
+
* Call this when a connector's API call returns a permanent auth-style
|
|
277
|
+
* error that the runtime can't observe through token refresh — e.g.
|
|
278
|
+
* Slack `invalid_auth` / `token_revoked` / `not_authed`, or a 401 on a
|
|
279
|
+
* provider that doesn't refresh. The runtime already flags reauth
|
|
280
|
+
* automatically when an OAuth refresh permanently fails or when the
|
|
281
|
+
* stored token is missing on a get(); only call this for cases the
|
|
282
|
+
* runtime can't see.
|
|
283
|
+
*
|
|
284
|
+
* Idempotent: safe to call repeatedly; existing reauth flags are not
|
|
285
|
+
* overwritten. No-op when the channel has no `enabledBy` actor (e.g.
|
|
286
|
+
* key-based connectors).
|
|
287
|
+
*
|
|
288
|
+
* @param channelId - The channel resource ID whose token is bad
|
|
289
|
+
*/
|
|
290
|
+
abstract markNeedsReauth(channelId: string): Promise<void>;
|
|
205
291
|
}
|
|
206
292
|
/**
|
|
207
293
|
* Filter criteria for archiving links.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK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;;;GAKG;AACH,oBAAY,YAAY;IACtB,0DAA0D;IAC1D,MAAM,WAAW;IACjB,0DAA0D;IAC1D,SAAS,cAAc;IACvB,kDAAkD;IAClD,MAAM,WAAW;IACjB,gDAAgD;IAChD,KAAK,UAAU;IACf,uDAAuD;IACvD,SAAS,cAAc;IACvB,kDAAkD;IAClD,MAAM,WAAW;IACjB,gCAAgC;IAChC,MAAM,WAAW;IACjB,sEAAsE;IACtE,MAAM,WAAW;IACjB,gDAAgD;IAChD,KAAK,UAAU;IACf,6CAA6C;IAC7C,OAAO,YAAY;IACnB,yDAAyD;IACzD,OAAO,YAAY;IACnB,iDAAiD;IACjD,QAAQ,aAAa;CACtB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mDAAmD;IACnD,QAAQ,EAAE,YAAY,CAAC;IACvB,sDAAsD;IACtD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0EAA0E;IAC1E,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GAEN,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GAEN,MAAM,IAAI,CAAC;AA4GZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;IAC9C;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,WAAuB;QAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;CA2KF;AAiBD;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAyBX;AAzBD,WAAY,YAAY;IACtB,0DAA0D;IAC1D,iCAAiB,CAAA;IACjB,0DAA0D;IAC1D,uCAAuB,CAAA;IACvB,kDAAkD;IAClD,iCAAiB,CAAA;IACjB,gDAAgD;IAChD,+BAAe,CAAA;IACf,uDAAuD;IACvD,uCAAuB,CAAA;IACvB,kDAAkD;IAClD,iCAAiB,CAAA;IACjB,gCAAgC;IAChC,iCAAiB,CAAA;IACjB,sEAAsE;IACtE,iCAAiB,CAAA;IACjB,gDAAgD;IAChD,+BAAe,CAAA;IACf,6CAA6C;IAC7C,mCAAmB,CAAA;IACnB,yDAAyD;IACzD,mCAAmB,CAAA;IACnB,iDAAiD;IACjD,qCAAqB,CAAA;AACvB,CAAC,EAzBW,YAAY,KAAZ,YAAY,QAyBvB"}
|
package/dist/tools/plot.d.ts
CHANGED
|
@@ -490,17 +490,6 @@ export declare abstract class Plot extends ITool {
|
|
|
490
490
|
* twist. This is the same value exposed on Twist via `this.userId`.
|
|
491
491
|
*/
|
|
492
492
|
abstract getUserId(): Promise<string>;
|
|
493
|
-
/**
|
|
494
|
-
* Returns the owner user's root priority ID. Used as the implicit default
|
|
495
|
-
* when an operation needs a priority but the caller didn't supply one —
|
|
496
|
-
* for example, `plot.createPriority()` without a parent, or
|
|
497
|
-
* `plot.getThreads()` without an explicit `priorityId`.
|
|
498
|
-
*
|
|
499
|
-
* On the server, priority resolution for newly created threads/links
|
|
500
|
-
* happens automatically via `match_priority_for_user`; twists rarely need
|
|
501
|
-
* to call this directly.
|
|
502
|
-
*/
|
|
503
|
-
abstract getDefaultPriorityId(): Promise<string>;
|
|
504
493
|
/**
|
|
505
494
|
* Creates a new schedule for a thread.
|
|
506
495
|
*
|
package/dist/tools/plot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/tools/plot.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,EACL,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,IAAI,EACL,MAAM,IAAI,CAAC;AACZ,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,WAAW,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,oBAAY,YAAY;IACtB;;;OAGG;IACH,OAAO,IAAA;IACP;;;;OAIG;IACH,MAAM,IAAA;IACN;;;;;OAKG;IACH,IAAI,IAAA;CACL;AAED,oBAAY,cAAc;IACxB;;;OAGG;IACH,MAAM,IAAA;IACN;;;;OAIG;IACH,IAAI,IAAA;CACL;AAED,oBAAY,aAAa;IACvB,iFAAiF;IACjF,IAAI,IAAA;CACL;AAED,oBAAY,UAAU;IACpB,0DAA0D;IAC1D,IAAI,IAAA;IACJ,6FAA6F;IAC7F,IAAI,IAAA;CACL;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,uDAAuD;IACvD,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC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AAY,QAmBvB;AAED,MAAM,CAAN,IAAY,cAYX;AAZD,WAAY,cAAc;IACxB;;;OAGG;IACH,uDAAM,CAAA;IACN;;;;OAIG;IACH,mDAAI,CAAA;AACN,CAAC,EAZW,cAAc,KAAd,cAAc,QAYzB;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iFAAiF;IACjF,iDAAI,CAAA;AACN,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,MAAM,CAAN,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,0DAA0D;IAC1D,2CAAI,CAAA;IACJ,6FAA6F;IAC7F,2CAAI,CAAA;AACN,CAAC,EALW,UAAU,KAAV,UAAU,QAKrB;AAmDD,gDAAgD;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAenC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAgB,IAAK,SAAQ,KAAK;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,MAAM,CAAU,OAAO,CAqDrB;CA0ZH"}
|
package/dist/tools/store.d.ts
CHANGED
|
@@ -137,5 +137,45 @@ export declare abstract class Store extends ITool {
|
|
|
137
137
|
* @returns Promise that resolves when all keys are removed
|
|
138
138
|
*/
|
|
139
139
|
abstract clearAll(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Acquire a self-expiring lock. Returns true if the caller now holds the
|
|
142
|
+
* lock, false if another holder has a non-expired lease.
|
|
143
|
+
*
|
|
144
|
+
* Use this for any operation where you previously hand-rolled a boolean
|
|
145
|
+
* "in progress" flag with manual cleanup on every error path. The lock
|
|
146
|
+
* auto-releases after `ttlMs`, so a crashed/timed-out holder cannot wedge
|
|
147
|
+
* the system permanently — pick a `ttlMs` comfortably longer than the
|
|
148
|
+
* worst-case duration of the protected work.
|
|
149
|
+
*
|
|
150
|
+
* Acquisition is atomic across concurrent callers (the underlying
|
|
151
|
+
* Durable Object serializes operations). Lock keys live in a reserved
|
|
152
|
+
* namespace and never appear in `get` / `list` results.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* if (!(await this.tools.store.acquireLock(`sync_${id}`, 30 * 60_000))) {
|
|
157
|
+
* return; // another sync is already running
|
|
158
|
+
* }
|
|
159
|
+
* try {
|
|
160
|
+
* await this.runSync(id);
|
|
161
|
+
* } finally {
|
|
162
|
+
* await this.tools.store.releaseLock(`sync_${id}`);
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @param key Lock identifier (any string).
|
|
167
|
+
* @param ttlMs Lease duration in milliseconds. After this time the lock
|
|
168
|
+
* is considered expired and a new caller can acquire it even if
|
|
169
|
+
* `releaseLock` was never called.
|
|
170
|
+
* @returns Promise resolving to true if acquired, false if held.
|
|
171
|
+
*/
|
|
172
|
+
abstract acquireLock(key: string, ttlMs: number): Promise<boolean>;
|
|
173
|
+
/**
|
|
174
|
+
* Release a lock acquired via {@link acquireLock}. Safe to call even if
|
|
175
|
+
* the caller never acquired the lock or the lease has already expired.
|
|
176
|
+
*
|
|
177
|
+
* @param key The same key that was passed to `acquireLock`.
|
|
178
|
+
*/
|
|
179
|
+
abstract releaseLock(key: string): Promise<void>;
|
|
140
180
|
}
|
|
141
181
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/tools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,8BAAsB,KAAM,SAAQ,KAAK;IACvC;;;;;;;;;;;;OA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E,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhD;;;;;;;;OAQG;IAEH,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1C;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IAEH,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAElE;;;;;OAKG;IAEH,QAAQ,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CACjD"}
|
package/dist/tools/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/tools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,IAAI,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,OAAgB,KAAM,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/tools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,IAAI,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,OAAgB,KAAM,SAAQ,KAAK;CAuIxC"}
|
package/dist/twist-guide.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const TWIST_GUIDE = "# Twist Implementation Guide for LLMs\n\nThis document provides context for AI assistants generating or modifying twists.\n\n## Architecture Overview\n\nPlot Twists are TypeScript classes that extend the `Twist` base class. Twists interact with external services and Plot's core functionality through a tool-based architecture.\n\n### Runtime Environment\n\n**Critical**: All Twists and tool functions are executed in a sandboxed, ephemeral environment with limited resources:\n\n- **Memory is temporary**: Anything stored in memory (e.g. as a variable in the twist/tool object) is lost after the function completes. Use the Store tool instead. Only use memory for temporary caching.\n- **Limited requests per execution**: Each execution has ~1000 requests (HTTP requests, tool calls, database operations)\n- **Limited CPU time**: Each execution has limited CPU time (typically ~60 seconds) and memory (128MB)\n- **Use tasks to get fresh request limits**: `this.runTask()` creates a NEW execution with a fresh ~1000 request limit\n- **Calling callbacks continues same execution**: `this.run()` continues the same execution and shares the request count\n- **Break long loops**: Split large operations into batches that each stay under the ~1000 request limit\n- **Store intermediate state**: Use the Store tool to persist state between batches\n- **Examples**: Syncing large datasets, processing many API calls, or performing batch operations\n\n## Understanding Threads and Notes\n\n**CRITICAL CONCEPT**: A **Thread** represents something done or to be done (a task, event, or conversation), while **Notes** represent the updates and details on that thread.\n\n**Think of a Thread as a thread** on a messaging platform, and **Notes as the messages in that thread**.\n\n### Key Guidelines\n\n1. **Always create Threads with an initial Note** - The title is just a summary; detailed content goes in Notes\n2. **Add Notes to existing Threads for updates** - Don't create a new Thread for each related message\n3. **Use Thread.source and Note.key for automatic upserts (Recommended)** - Set Thread.source to the external item's URL for deduplication, and use Note.key for upsertable note content. No manual ID tracking needed.\n4. **For advanced cases, use generated UUIDs** - Only when you need multiple Plot threads per external item (see SYNC_STRATEGIES.md)\n5. **Most Threads should be `ThreadType.Note`** - Use `Action` only for tasks with `done`, use `Event` only for items with `start`/`end`\n\n### Recommended Decision Tree (Strategy 2: Upsert via Source/Key)\n\n```\nNew event/task/conversation from external system?\n \u251C\u2500 Has stable URL or ID?\n \u2502 \u2514\u2500 Yes \u2192 Set Thread.source to the canonical URL/ID\n \u2502 Create Thread (Plot handles deduplication automatically)\n \u2502 Use Note.key for different note types:\n \u2502 - \"description\" for main content\n \u2502 - \"metadata\" for status/priority/assignee\n \u2502 - \"comment-{id}\" for individual comments\n \u2502\n \u2514\u2500 No stable identifier OR need multiple Plot threads per external item?\n \u2514\u2500 Use Advanced Pattern (Strategy 3: Generate and Store IDs)\n See SYNC_STRATEGIES.md for details\n```\n\n### Advanced Decision Tree (Strategy 3: Generate and Store IDs)\n\nOnly use when source/key upserts aren't sufficient (e.g., creating multiple threads from one external item):\n\n```\nNew event/task/conversation?\n \u251C\u2500 Yes \u2192 Generate UUID with Uuid.Generate()\n \u2502 Create new Thread with that UUID\n \u2502 Store mapping: external_id \u2192 thread_uuid\n \u2502\n \u2514\u2500 No (update/reply/comment) \u2192 Look up mapping by external_id\n \u251C\u2500 Found \u2192 Add Note to existing Thread using stored UUID\n \u2514\u2500 Not found \u2192 Create new Thread with UUID + store mapping\n```\n\n## Twist Structure Pattern\n\n```typescript\nimport {\n type Thread,\n type NewThreadWithNotes,\n type ThreadFilter,\n type Priority,\n type ToolBuilder,\n Twist,\n ThreadType,\n} from \"@plotday/twister\";\nimport { ThreadAccess, Plot } from \"@plotday/twister/tools/plot\";\n// Import your sources or tools as needed\n\nexport default class MyTwist extends Twist<MyTwist> {\n build(build: ToolBuilder) {\n return {\n plot: build(Plot, {\n thread: { access: ThreadAccess.Create },\n }),\n };\n }\n\n async activate(_priority: Pick<Priority, \"id\">) {\n // Auth and resource selection handled in the twist edit modal.\n }\n}\n```\n\n## Tool System\n\n### Accessing Tools\n\nAll tools are declared in the `build` method:\n\n```typescript\nbuild(build: ToolBuilder) {\n return {\n toolName: build(ToolClass),\n };\n}\n```\n\nAll `build()` calls must occur in the `build` method as they are used for dependency analysis.\n\nIMPORTANT: HTTP access is restricted to URLs requested via `build(Network, { urls: [url1, url2, ...] })` in the `build` method. Wildcards are supported. Use `build(Network, { urls: ['*'] })` if full access is needed.\n\n### Built-in Tools (Always Available)\n\nFor complete API documentation of built-in tools including all methods, types, and detailed examples, see the TypeScript definitions in your installed package at `node_modules/@plotday/twister/src/tools/*.ts`. Each tool file contains comprehensive JSDoc documentation.\n\n**Quick reference - Available tools:**\n\n- `@plotday/twister/tools/plot` - Core data layer (create/update activities, priorities, contacts)\n- `@plotday/twister/tools/ai` - LLM integration (text generation, structured output, reasoning)\n - Use ModelPreferences to specify `speed` (fast/balanced/capable) and `cost` (low/medium/high)\n- `@plotday/twister/tools/store` - Persistent key-value storage (also via `this.set()`, `this.get()`)\n- `@plotday/twister/tools/tasks` - Queue batched work (also via `this.run()`)\n- `@plotday/twister/tools/callbacks` - Persistent function references (also via `this.callback()`)\n- `@plotday/twister/tools/integrations` - OAuth2 authentication flows\n- `@plotday/twister/tools/network` - HTTP access permissions and webhook management\n- `@plotday/twister/tools/twists` - Manage other Twists\n\n**Critical**: Never use instance variables for state. They are lost after function execution. Always use Store methods.\n\n## Lifecycle Methods\n\n### activate(priority: Pick<Priority, \"id\">)\n\nCalled when the twist is enabled for a priority. Auth and resource selection are handled automatically via the twist edit modal when using external tools with Integrations.\n\nMost twists have an empty or minimal `activate()`:\n\n```typescript\nasync activate(_priority: Pick<Priority, \"id\">) {\n // Auth and resource selection are handled in the twist edit modal.\n // Only add custom initialization here if needed.\n}\n```\n\n**Store Parent Thread for Later (optional):**\n\n```typescript\nasync activate(_priority: Pick<Priority, \"id\">) {\n const threadId = await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Setup complete\",\n notes: [{\n content: \"Your twist is ready. Threads will appear as they sync.\",\n }],\n });\n await this.set(\"setup_thread_id\", threadId);\n}\n```\n\n### Event Callbacks (via build options)\n\nTwists respond to events through callbacks declared in `build()`:\n\n**React to thread changes (for two-way sync):**\n\n```typescript\nplot: build(Plot, {\n thread: {\n access: ThreadAccess.Create,\n updated: this.onThreadUpdated,\n },\n note: {\n created: this.onNoteCreated,\n },\n}),\n\nasync onThreadUpdated(thread: Thread, changes: { tagsAdded, tagsRemoved }): Promise<void> {\n const tool = this.getToolForThread(thread);\n if (tool?.updateIssue) await tool.updateIssue(thread);\n}\n\nasync onNoteCreated(note: Note): Promise<void> {\n if (note.author.type === ActorType.Twist) return; // Prevent loops\n // Sync note to external service as a comment\n}\n```\n\n**Respond to mentions (AI twist pattern):**\n\n```typescript\nplot: build(Plot, {\n thread: { access: ThreadAccess.Respond },\n note: {\n intents: [{\n description: \"Respond to general questions\",\n examples: [\"What's the weather?\", \"Help me plan my week\"],\n handler: this.respond,\n }],\n },\n}),\n```\n\n**Default mention on replies:**\n\nWhen your twist processes replies (two-way comment sync or conversational AI), set `defaultMention: true` so the user doesn't have to manually re-mention your twist on every note:\n\n- `thread.defaultMention` \u2014 Auto-mention on replies to threads your twist created (e.g., synced issues, emails)\n- `note.defaultMention` \u2014 Auto-mention on follow-up notes in threads where your twist was @-mentioned (e.g., conversational agents)\n\n```typescript\n// Connector with two-way comment sync\nplot: build(Plot, {\n thread: {\n access: ThreadAccess.Create,\n defaultMention: true, // Users replying to synced threads will mention this twist by default\n updated: this.onThreadUpdated,\n },\n note: {\n created: this.onNoteCreated,\n },\n}),\n\n// Conversational AI twist\nplot: build(Plot, {\n thread: { access: ThreadAccess.Respond },\n note: {\n defaultMention: true, // Follow-up notes auto-mention this twist\n intents: [{ description: \"...\", examples: [...], handler: this.respond }],\n },\n}),\n```\n\nWithout `defaultMention`, the twist chip appears toggled OFF by default \u2014 the user can still enable it manually per-note.\n\n## Actions\n\nActions enable user interaction:\n\n```typescript\nimport { type Action, ActionType } from \"@plotday/twister\";\n\n// External URL action\nconst urlAction: Action = {\n title: \"Open website\",\n type: ActionType.external,\n url: \"https://example.com\",\n};\n\n// Callback action (uses Callbacks tool \u2014 use linkCallback, not callback)\nconst token = await this.linkCallback(this.onActionClicked, \"context\");\nconst callbackAction: Action = {\n title: \"Click me\",\n type: ActionType.callback,\n callback: token,\n};\n\n// Add to thread note\nawait this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Task with actions\",\n notes: [\n {\n content: \"Click the actions below to take action.\",\n actions: [urlAction, callbackAction],\n },\n ],\n});\n\n// Callback handler receives the Action as first argument\nasync onActionClicked(action: Action, context: string): Promise<void> {\n // Handle action click\n}\n```\n\n## Authentication Pattern\n\nAuth is handled automatically via the Integrations tool. Tools declare their OAuth provider in `build()`, and users connect in the twist edit modal. **You do not need to create auth activities manually.**\n\n```typescript\n// In your tool's build() method:\nbuild(build: ToolBuilder) {\n return {\n integrations: build(Integrations, {\n providers: [{\n provider: AuthProvider.Google,\n scopes: [\"https://www.googleapis.com/auth/calendar\"],\n getChannels: this.getChannels, // List available resources after auth\n onChannelEnabled: this.onChannelEnabled, // User enabled a resource\n onChannelDisabled: this.onChannelDisabled, // User disabled a resource\n }],\n }),\n // ...\n };\n}\n\n// Get a token for API calls:\nconst token = await this.tools.integrations.get(AuthProvider.Google, channelId);\nif (!token) throw new Error(\"No auth token available\");\nconst client = new ApiClient({ accessToken: token.token });\n```\n\nFor per-user write-backs (e.g., RSVP, comments attributed to the acting user):\n\n```typescript\nawait this.tools.integrations.actAs(\n AuthProvider.Google,\n actorId, // The user who performed the action\n threadId, // Thread to prompt for auth if needed\n this.performWriteBack,\n ...extraArgs\n);\n```\n\n## Sync Pattern\n\n### Upsert via Source/Key (Strategy 2)\n\nUse source/key for automatic upserts:\n\n```typescript\nasync handleEvent(event: ExternalEvent): Promise<void> {\n const thread: NewThreadWithNotes = {\n source: event.htmlLink, // Canonical URL for automatic deduplication\n type: ThreadType.Event,\n title: event.summary || \"(No title)\",\n notes: [],\n };\n\n if (event.description) {\n thread.notes.push({\n thread: { source: event.htmlLink },\n key: \"description\", // This key enables note-level upserts\n content: event.description,\n });\n }\n\n // Create or update \u2014 Plot handles deduplication automatically\n await this.tools.plot.createThread(thread);\n}\n```\n\n### Advanced: Generate and Store IDs (Strategy 3)\n\nOnly use this pattern when you need to create multiple Plot threads from a single external item, or when the external system doesn't provide stable identifiers. See SYNC_STRATEGIES.md for details.\n\n```typescript\nasync handleEventAdvanced(\n incomingThread: NewThreadWithNotes,\n calendarId: string\n): Promise<void> {\n // Extract external event ID from meta (adapt based on your tool's data)\n const externalId = incomingThread.meta?.eventId;\n\n if (!externalId) {\n console.error(\"Event missing external ID\");\n return;\n }\n\n // Check if we've already synced this event\n const mappingKey = `event_mapping:${calendarId}:${externalId}`;\n const existingThreadId = await this.get<Uuid>(mappingKey);\n\n if (existingThreadId) {\n // Event already exists - add update as a Note (add message to thread)\n if (incomingThread.notes?.[0]?.content) {\n await this.tools.plot.createNote({\n thread: { id: existingThreadId },\n content: incomingThread.notes[0].content,\n });\n }\n return;\n }\n\n // New event - generate UUID and store mapping\n const threadId = Uuid.Generate();\n await this.set(mappingKey, threadId);\n\n // Create new Thread with initial Note (new thread with first message)\n await this.tools.plot.createThread({\n ...incomingThread,\n id: threadId,\n });\n}\n```\n\n## Resource Selection\n\nResource selection (calendars, projects, channels) is handled automatically in the twist edit modal via the Integrations tool. Users see a list of available resources returned by your tool's `getChannels()` method and toggle them on/off. You do **not** need to build custom selection UI.\n\n```typescript\n// In your tool:\nasync getChannels(_auth: Authorization, token: AuthToken): Promise<Channel[]> {\n const client = new ApiClient({ accessToken: token.token });\n const calendars = await client.listCalendars();\n return calendars.map(c => ({\n id: c.id,\n title: c.name,\n children: c.subCalendars?.map(sc => ({ id: sc.id, title: sc.name })),\n }));\n}\n```\n\n## Batch Processing Pattern\n\n**Important**: Because Twists run in an ephemeral environment with limited requests per execution (~1000 requests), you must break long operations into batches. Each batch runs independently in a new execution context with its own fresh request limit.\n\n### Key Principles\n\n1. **Stay under request limits**: Each execution has ~1000 requests. Size batches accordingly.\n2. **Use runTask() for fresh limits**: Each call to `this.runTask()` creates a NEW execution with fresh ~1000 requests\n3. **Store state between batches**: Use the Store tool to persist progress\n4. **Calculate safe batch sizes**: Determine requests per item to size batches (e.g., ~10 requests per item = ~100 items per batch)\n5. **Clean up when done**: Delete stored state after completion\n6. **Handle failures**: Store enough state to resume if a batch fails\n\n### Example Implementation\n\n```typescript\nasync startSync(resourceId: string): Promise<void> {\n // Initialize state in Store (persists between executions)\n await this.set(`sync_state_${resourceId}`, {\n nextPageToken: null,\n batchNumber: 1,\n itemsProcessed: 0,\n initialSync: true, // Track whether this is the first sync\n });\n\n // Queue first batch using runTask method\n const callback = await this.callback(this.syncBatch, resourceId);\n // runTask creates NEW execution with fresh ~1000 request limit\n await this.runTask(callback);\n}\n\nasync syncBatch(resourceId: string): Promise<void> {\n // Load state from Store (set by previous execution)\n const state = await this.get(`sync_state_${resourceId}`);\n\n // Process one batch (size to stay under ~1000 request limit)\n const result = await this.fetchBatch(state.nextPageToken);\n\n // Process results using source/key pattern (automatic upserts, no manual tracking)\n // If each item makes ~10 requests, keep batch size \u2264 100 items to stay under limit\n for (const item of result.items) {\n // Each createThread may make ~5-10 requests depending on notes/links\n await this.tools.plot.createThread({\n source: item.url, // Use item's canonical URL for automatic deduplication\n type: ThreadType.Note,\n title: item.title,\n notes: [{\n activity: { source: item.url },\n key: \"description\", // Use key for upsertable notes\n content: item.description,\n }],\n ...(state.initialSync ? { unread: false } : {}), // false for initial, omit for incremental\n ...(state.initialSync ? { archived: false } : {}), // unarchive on initial only\n });\n }\n\n if (result.nextPageToken) {\n // Update state in Store for next batch\n await this.set(`sync_state_${resourceId}`, {\n nextPageToken: result.nextPageToken,\n batchNumber: state.batchNumber + 1,\n itemsProcessed: state.itemsProcessed + result.items.length,\n initialSync: state.initialSync, // Preserve initialSync flag across batches\n });\n\n // Queue next batch - creates NEW execution with fresh request limit\n const nextCallback = await this.callback(this.syncBatch, resourceId);\n await this.runTask(nextCallback);\n } else {\n // Cleanup when complete\n await this.clear(`sync_state_${resourceId}`);\n\n // Optionally notify user of completion\n await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Sync complete\",\n notes: [\n {\n content: `Successfully processed ${state.itemsProcessed + result.items.length} items.`,\n },\n ],\n });\n }\n}\n```\n\n## Thread Sync Best Practices\n\nWhen syncing threads from external systems, follow these patterns for optimal user experience:\n\n### The `initialSync` Flag\n\nAll sync-based tools should distinguish between initial sync (first import) and incremental sync (ongoing updates):\n\n| Field | Initial Sync | Incremental Sync | Reason |\n|-------|--------------|------------------|---------|\n| `unread` | `false` | *omit* | Initial: mark read for all. Incremental: auto-mark read for author only |\n| `archived` | `false` | *omit* | Unarchive on install, preserve user choice on updates |\n\n**Example:**\n```typescript\nconst thread: NewThread = {\n type: ThreadType.Event,\n source: event.url,\n title: event.title,\n ...(initialSync ? { unread: false } : {}), // false for initial, omit for incremental\n ...(initialSync ? { archived: false } : {}), // unarchive on initial only\n};\n```\n\n**Why this matters:**\n- **Initial sync**: Activities are unarchived and marked as read for all users, preventing spam from bulk historical imports\n- **Incremental sync**: Activities are auto-marked read for the author (twist owner), unread for everyone else. Archived state is preserved\n- **Reinstall**: Acts as initial sync, so previously archived activities are unarchived (fresh start)\n\n### Two-Way Sync: Avoiding Race Conditions\n\nWhen implementing two-way sync where items created in Plot are pushed to an external system (e.g. Notes becoming comments), a race condition can occur: the external system may send a webhook for the newly created item before you've updated the Thread/Note with the external key. The webhook handler won't find the item by external key and may create a duplicate.\n\n**Solution:** Embed the Plot `Thread.id` / `Note.id` in the external item's metadata when creating it, and update `Thread.source` / `Note.key` after creation. When processing webhooks, check for the Plot ID in metadata first.\n\n```typescript\nasync pushNoteAsComment(note: Note, externalItemId: string): Promise<void> {\n // Create external item with Plot ID in metadata for webhook correlation\n const externalComment = await externalApi.createComment(externalItemId, {\n body: note.content,\n metadata: { plotNoteId: note.id },\n });\n\n // Update Note with external key AFTER creation\n // A webhook may arrive before this completes \u2014 that's OK (see onWebhook below)\n await this.tools.plot.updateNote({\n id: note.id,\n key: `comment-${externalComment.id}`,\n });\n}\n\nasync onWebhook(payload: WebhookPayload): Promise<void> {\n const comment = payload.comment;\n\n // Use Plot ID from metadata if present (handles race condition),\n // otherwise fall back to upserting by activity source and key\n await this.tools.plot.createNote({\n ...(comment.metadata?.plotNoteId\n ? { id: comment.metadata.plotNoteId }\n : { activity: { source: payload.itemUrl } }),\n key: `comment-${comment.id}`,\n content: comment.body,\n });\n}\n```\n\n## Error Handling\n\nAlways handle errors gracefully and communicate them to users:\n\n```typescript\ntry {\n await this.externalOperation();\n} catch (error) {\n console.error(\"Operation failed:\", error);\n\n await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Operation failed\",\n notes: [\n {\n content: `Failed to complete operation: ${error.message}`,\n },\n ],\n });\n}\n```\n\n## Common Pitfalls\n\n- **Don't use instance variables for state** - Anything stored in memory is lost after function execution. Always use the Store tool for data that needs to persist.\n- **Processing self-created threads** - Other users may change a Thread created by the twist, resulting in a callback. Be sure to check the `changes === null` and/or `thread.author.id !== this.id` to avoid re-processing.\n- **Always create Threads with Notes** - See \"Understanding Threads and Notes\" section above for the thread/message pattern and decision tree.\n- **Use correct Thread types** - Most should be `ThreadType.Note`. Only use `Action` for tasks with `done`, and `Event` for items with `start`/`end`.\n- **Use Thread.source and Note.key for automatic upserts (Recommended)** - Set Thread.source to the external item's URL for automatic deduplication. Only use UUID generation and storage for advanced cases (see SYNC_STRATEGIES.md).\n- **Add Notes to existing Threads** - For source/key pattern, reference threads by source. For UUID pattern, look up stored mappings before creating new Threads. Think thread replies, not new threads.\n- Tools are declared in the `build` method and accessed via `this.tools.toolName` in twist methods.\n- **Don't forget request limits** - Each execution has ~1000 requests (HTTP requests, tool calls). Break long loops into batches with `this.runTask()` to get fresh request limits. Calculate requests per item to determine safe batch size (e.g., if each item needs ~10 requests, batch size = ~100 items).\n- **Always use Callbacks tool for persistent references** - Direct function references don't survive worker restarts.\n- **Store auth tokens** - Don't re-request authentication unnecessarily.\n- **Clean up callbacks and stored state** - Delete callbacks and Store entries when no longer needed.\n- **Handle missing auth gracefully** - Check for stored auth before operations.\n- **CRITICAL: Maintain callback backward compatibility** - All callbacks (webhooks, tasks, batch operations) automatically upgrade to new twist versions. You **must** maintain backward compatibility in callback method signatures. Only add optional parameters at the end, never remove or reorder parameters. For breaking changes, implement migration logic in the `upgrade()` lifecycle method to recreate affected callbacks.\n\n## Testing\n\nBefore deploying, verify:\n\n1. Linting passes: `{{packageManager}} lint`\n2. All dependencies are in package.json\n3. Authentication flow works end-to-end\n4. Batch operations handle pagination correctly\n5. Error cases are handled gracefully\n";
|
|
1
|
+
export declare const TWIST_GUIDE = "# Twist Implementation Guide for LLMs\n\nThis document provides context for AI assistants generating or modifying twists.\n\n## Architecture Overview\n\nPlot Twists are TypeScript classes that extend the `Twist` base class. Twists interact with external services and Plot's core functionality through a tool-based architecture.\n\n### Runtime Environment\n\n**Critical**: All Twists and tool functions are executed in a sandboxed, ephemeral environment with limited resources:\n\n- **Memory is temporary**: Anything stored in memory (e.g. as a variable in the twist/tool object) is lost after the function completes. Use the Store tool instead. Only use memory for temporary caching.\n- **Limited requests per execution**: Each execution has ~1000 requests (HTTP requests, tool calls, database operations)\n- **Limited CPU time**: Each execution has limited CPU time (typically ~60 seconds) and memory (128MB)\n- **Use tasks to get fresh request limits**: `this.runTask()` creates a NEW execution with a fresh ~1000 request limit\n- **Calling callbacks continues same execution**: `this.run()` continues the same execution and shares the request count\n- **Break long loops**: Split large operations into batches that each stay under the ~1000 request limit\n- **Store intermediate state**: Use the Store tool to persist state between batches\n- **Examples**: Syncing large datasets, processing many API calls, or performing batch operations\n\n## Understanding Threads and Notes\n\n**CRITICAL CONCEPT**: A **Thread** represents something done or to be done (a task, event, or conversation), while **Notes** represent the updates and details on that thread.\n\n**Think of a Thread as a thread** on a messaging platform, and **Notes as the messages in that thread**.\n\n### Key Guidelines\n\n1. **Always create Threads with an initial Note** - The title is just a summary; detailed content goes in Notes\n2. **Add Notes to existing Threads for updates** - Don't create a new Thread for each related message\n3. **Use Thread.source and Note.key for automatic upserts (Recommended)** - Set Thread.source to the external item's URL for deduplication, and use Note.key for upsertable note content. No manual ID tracking needed.\n4. **For advanced cases, use generated UUIDs** - Only when you need multiple Plot threads per external item (see SYNC_STRATEGIES.md)\n5. **Most Threads should be `ThreadType.Note`** - Use `Action` only for tasks with `done`, use `Event` only for items with `start`/`end`\n\n### Recommended Decision Tree (Strategy 2: Upsert via Source/Key)\n\n```\nNew event/task/conversation from external system?\n \u251C\u2500 Has stable URL or ID?\n \u2502 \u2514\u2500 Yes \u2192 Set Thread.source to the canonical URL/ID\n \u2502 Create Thread (Plot handles deduplication automatically)\n \u2502 Use Note.key for different note types:\n \u2502 - \"description\" for main content\n \u2502 - \"metadata\" for status/priority/assignee\n \u2502 - \"comment-{id}\" for individual comments\n \u2502\n \u2514\u2500 No stable identifier OR need multiple Plot threads per external item?\n \u2514\u2500 Use Advanced Pattern (Strategy 3: Generate and Store IDs)\n See SYNC_STRATEGIES.md for details\n```\n\n### Advanced Decision Tree (Strategy 3: Generate and Store IDs)\n\nOnly use when source/key upserts aren't sufficient (e.g., creating multiple threads from one external item):\n\n```\nNew event/task/conversation?\n \u251C\u2500 Yes \u2192 Generate UUID with Uuid.Generate()\n \u2502 Create new Thread with that UUID\n \u2502 Store mapping: external_id \u2192 thread_uuid\n \u2502\n \u2514\u2500 No (update/reply/comment) \u2192 Look up mapping by external_id\n \u251C\u2500 Found \u2192 Add Note to existing Thread using stored UUID\n \u2514\u2500 Not found \u2192 Create new Thread with UUID + store mapping\n```\n\n## Twist Structure Pattern\n\n```typescript\nimport {\n type Thread,\n type NewThreadWithNotes,\n type ThreadFilter,\n type Priority,\n type ToolBuilder,\n Twist,\n ThreadType,\n} from \"@plotday/twister\";\nimport { ThreadAccess, Plot } from \"@plotday/twister/tools/plot\";\n// Import your sources or tools as needed\n\nexport default class MyTwist extends Twist<MyTwist> {\n build(build: ToolBuilder) {\n return {\n plot: build(Plot, {\n thread: { access: ThreadAccess.Create },\n }),\n };\n }\n\n async activate(_priority: Pick<Priority, \"id\">) {\n // Auth and resource selection handled in the twist edit modal.\n }\n}\n```\n\n## Tool System\n\n### Accessing Tools\n\nAll tools are declared in the `build` method:\n\n```typescript\nbuild(build: ToolBuilder) {\n return {\n toolName: build(ToolClass),\n };\n}\n```\n\nAll `build()` calls must occur in the `build` method as they are used for dependency analysis.\n\nIMPORTANT: HTTP access is restricted to URLs requested via `build(Network, { urls: [url1, url2, ...] })` in the `build` method. Wildcards are supported. Use `build(Network, { urls: ['*'] })` if full access is needed.\n\n### Built-in Tools (Always Available)\n\nFor complete API documentation of built-in tools including all methods, types, and detailed examples, see the TypeScript definitions in your installed package at `node_modules/@plotday/twister/src/tools/*.ts`. Each tool file contains comprehensive JSDoc documentation.\n\n**Quick reference - Available tools:**\n\n- `@plotday/twister/tools/plot` - Core data layer (create/update activities, priorities, contacts)\n- `@plotday/twister/tools/ai` - LLM integration (text generation, structured output, reasoning)\n - Use ModelPreferences to specify `speed` (fast/balanced/capable) and `cost` (low/medium/high)\n- `@plotday/twister/tools/store` - Persistent key-value storage (also via `this.set()`, `this.get()`)\n- `@plotday/twister/tools/tasks` - Queue batched work (also via `this.run()`)\n- `@plotday/twister/tools/callbacks` - Persistent function references (also via `this.callback()`)\n- `@plotday/twister/tools/integrations` - OAuth2 authentication flows\n- `@plotday/twister/tools/network` - HTTP access permissions and webhook management\n- `@plotday/twister/tools/twists` - Manage other Twists\n\n**Critical**: Never use instance variables for state. They are lost after function execution. Always use Store methods.\n\n## Lifecycle Methods\n\n### activate(priority: Pick<Priority, \"id\">)\n\nCalled when the twist is enabled for a priority. Auth and resource selection are handled automatically via the twist edit modal when using external tools with Integrations.\n\nMost twists have an empty or minimal `activate()`:\n\n```typescript\nasync activate(_priority: Pick<Priority, \"id\">) {\n // Auth and resource selection are handled in the twist edit modal.\n // Only add custom initialization here if needed.\n}\n```\n\n**Store Parent Thread for Later (optional):**\n\n```typescript\nasync activate(_priority: Pick<Priority, \"id\">) {\n const threadId = await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Setup complete\",\n notes: [{\n content: \"Your twist is ready. Threads will appear as they sync.\",\n }],\n });\n await this.set(\"setup_thread_id\", threadId);\n}\n```\n\n### Event Callbacks (via build options)\n\nTwists respond to events through callbacks declared in `build()`:\n\n**React to thread changes (for two-way sync):**\n\n```typescript\nplot: build(Plot, {\n thread: {\n access: ThreadAccess.Create,\n updated: this.onThreadUpdated,\n },\n note: {\n created: this.onNoteCreated,\n },\n}),\n\nasync onThreadUpdated(thread: Thread, changes: { tagsAdded, tagsRemoved }): Promise<void> {\n const tool = this.getToolForThread(thread);\n if (tool?.updateIssue) await tool.updateIssue(thread);\n}\n\nasync onNoteCreated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {\n if (note.author.type === ActorType.Twist) return; // Prevent loops\n // Sync note to external service as a comment. Return the external\n // system's id + stored content so the runtime can set note.key AND\n // record a sync baseline that preserves Plot's content on round-trip.\n // See connectors/AGENTS.md \u2192 \"Sync baseline preservation\".\n const comment = await externalApi.createComment(thread.meta.externalId, { body: note.content ?? \"\" });\n if (!comment?.id) return;\n return { key: `comment-${comment.id}`, externalContent: comment.body };\n}\n```\n\n**Respond to mentions (AI twist pattern):**\n\n```typescript\nplot: build(Plot, {\n thread: { access: ThreadAccess.Respond },\n note: {\n intents: [{\n description: \"Respond to general questions\",\n examples: [\"What's the weather?\", \"Help me plan my week\"],\n handler: this.respond,\n }],\n },\n}),\n```\n\n**Default mention on replies:**\n\nWhen your twist processes replies (two-way comment sync or conversational AI), set `defaultMention: true` so the user doesn't have to manually re-mention your twist on every note:\n\n- `thread.defaultMention` \u2014 Auto-mention on replies to threads your twist created (e.g., synced issues, emails)\n- `note.defaultMention` \u2014 Auto-mention on follow-up notes in threads where your twist was @-mentioned (e.g., conversational agents)\n\n```typescript\n// Connector with two-way comment sync\nplot: build(Plot, {\n thread: {\n access: ThreadAccess.Create,\n defaultMention: true, // Users replying to synced threads will mention this twist by default\n updated: this.onThreadUpdated,\n },\n note: {\n created: this.onNoteCreated,\n },\n}),\n\n// Conversational AI twist\nplot: build(Plot, {\n thread: { access: ThreadAccess.Respond },\n note: {\n defaultMention: true, // Follow-up notes auto-mention this twist\n intents: [{ description: \"...\", examples: [...], handler: this.respond }],\n },\n}),\n```\n\nWithout `defaultMention`, the twist chip appears toggled OFF by default \u2014 the user can still enable it manually per-note.\n\n## Actions\n\nActions enable user interaction:\n\n```typescript\nimport { type Action, ActionType } from \"@plotday/twister\";\n\n// External URL action\nconst urlAction: Action = {\n title: \"Open website\",\n type: ActionType.external,\n url: \"https://example.com\",\n};\n\n// Callback action (uses Callbacks tool \u2014 use linkCallback, not callback)\nconst token = await this.linkCallback(this.onActionClicked, \"context\");\nconst callbackAction: Action = {\n title: \"Click me\",\n type: ActionType.callback,\n callback: token,\n};\n\n// Add to thread note\nawait this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Task with actions\",\n notes: [\n {\n content: \"Click the actions below to take action.\",\n actions: [urlAction, callbackAction],\n },\n ],\n});\n\n// Callback handler receives the Action as first argument\nasync onActionClicked(action: Action, context: string): Promise<void> {\n // Handle action click\n}\n```\n\n## Authentication Pattern\n\nAuth is handled automatically via the Integrations tool. Tools declare their OAuth provider in `build()`, and users connect in the twist edit modal. **You do not need to create auth activities manually.**\n\n```typescript\n// In your tool's build() method:\nbuild(build: ToolBuilder) {\n return {\n integrations: build(Integrations, {\n providers: [{\n provider: AuthProvider.Google,\n scopes: [\"https://www.googleapis.com/auth/calendar\"],\n getChannels: this.getChannels, // List available resources after auth\n onChannelEnabled: this.onChannelEnabled, // User enabled a resource\n onChannelDisabled: this.onChannelDisabled, // User disabled a resource\n }],\n }),\n // ...\n };\n}\n\n// Get a token for API calls:\nconst token = await this.tools.integrations.get(AuthProvider.Google, channelId);\nif (!token) throw new Error(\"No auth token available\");\nconst client = new ApiClient({ accessToken: token.token });\n```\n\nFor per-user write-backs (e.g., RSVP, comments attributed to the acting user):\n\n```typescript\nawait this.tools.integrations.actAs(\n AuthProvider.Google,\n actorId, // The user who performed the action\n threadId, // Thread to prompt for auth if needed\n this.performWriteBack,\n ...extraArgs\n);\n```\n\n## Sync Pattern\n\n### Upsert via Source/Key (Strategy 2)\n\nUse source/key for automatic upserts:\n\n```typescript\nasync handleEvent(event: ExternalEvent): Promise<void> {\n const thread: NewThreadWithNotes = {\n source: event.htmlLink, // Canonical URL for automatic deduplication\n type: ThreadType.Event,\n title: event.summary || \"(No title)\",\n notes: [],\n };\n\n if (event.description) {\n thread.notes.push({\n thread: { source: event.htmlLink },\n key: \"description\", // This key enables note-level upserts\n content: event.description,\n });\n }\n\n // Create or update \u2014 Plot handles deduplication automatically\n await this.tools.plot.createThread(thread);\n}\n```\n\n### Advanced: Generate and Store IDs (Strategy 3)\n\nOnly use this pattern when you need to create multiple Plot threads from a single external item, or when the external system doesn't provide stable identifiers. See SYNC_STRATEGIES.md for details.\n\n```typescript\nasync handleEventAdvanced(\n incomingThread: NewThreadWithNotes,\n calendarId: string\n): Promise<void> {\n // Extract external event ID from meta (adapt based on your tool's data)\n const externalId = incomingThread.meta?.eventId;\n\n if (!externalId) {\n console.error(\"Event missing external ID\");\n return;\n }\n\n // Check if we've already synced this event\n const mappingKey = `event_mapping:${calendarId}:${externalId}`;\n const existingThreadId = await this.get<Uuid>(mappingKey);\n\n if (existingThreadId) {\n // Event already exists - add update as a Note (add message to thread)\n if (incomingThread.notes?.[0]?.content) {\n await this.tools.plot.createNote({\n thread: { id: existingThreadId },\n content: incomingThread.notes[0].content,\n });\n }\n return;\n }\n\n // New event - generate UUID and store mapping\n const threadId = Uuid.Generate();\n await this.set(mappingKey, threadId);\n\n // Create new Thread with initial Note (new thread with first message)\n await this.tools.plot.createThread({\n ...incomingThread,\n id: threadId,\n });\n}\n```\n\n## Resource Selection\n\nResource selection (calendars, projects, channels) is handled automatically in the twist edit modal via the Integrations tool. Users see a list of available resources returned by your tool's `getChannels()` method and toggle them on/off. You do **not** need to build custom selection UI.\n\n```typescript\n// In your tool:\nasync getChannels(_auth: Authorization, token: AuthToken): Promise<Channel[]> {\n const client = new ApiClient({ accessToken: token.token });\n const calendars = await client.listCalendars();\n return calendars.map(c => ({\n id: c.id,\n title: c.name,\n children: c.subCalendars?.map(sc => ({ id: sc.id, title: sc.name })),\n }));\n}\n```\n\n## Batch Processing Pattern\n\n**Important**: Because Twists run in an ephemeral environment with limited requests per execution (~1000 requests), you must break long operations into batches. Each batch runs independently in a new execution context with its own fresh request limit.\n\n### Key Principles\n\n1. **Stay under request limits**: Each execution has ~1000 requests. Size batches accordingly.\n2. **Use runTask() for fresh limits**: Each call to `this.runTask()` creates a NEW execution with fresh ~1000 requests\n3. **Store state between batches**: Use the Store tool to persist progress\n4. **Calculate safe batch sizes**: Determine requests per item to size batches (e.g., ~10 requests per item = ~100 items per batch)\n5. **Clean up when done**: Delete stored state after completion\n6. **Handle failures**: Store enough state to resume if a batch fails\n\n### Example Implementation\n\n```typescript\nasync startSync(resourceId: string): Promise<void> {\n // Initialize state in Store (persists between executions)\n await this.set(`sync_state_${resourceId}`, {\n nextPageToken: null,\n batchNumber: 1,\n itemsProcessed: 0,\n initialSync: true, // Track whether this is the first sync\n });\n\n // Queue first batch using runTask method\n const callback = await this.callback(this.syncBatch, resourceId);\n // runTask creates NEW execution with fresh ~1000 request limit\n await this.runTask(callback);\n}\n\nasync syncBatch(resourceId: string): Promise<void> {\n // Load state from Store (set by previous execution)\n const state = await this.get(`sync_state_${resourceId}`);\n\n // Process one batch (size to stay under ~1000 request limit)\n const result = await this.fetchBatch(state.nextPageToken);\n\n // Process results using source/key pattern (automatic upserts, no manual tracking)\n // If each item makes ~10 requests, keep batch size \u2264 100 items to stay under limit\n for (const item of result.items) {\n // Each createThread may make ~5-10 requests depending on notes/links\n await this.tools.plot.createThread({\n source: item.url, // Use item's canonical URL for automatic deduplication\n type: ThreadType.Note,\n title: item.title,\n notes: [{\n activity: { source: item.url },\n key: \"description\", // Use key for upsertable notes\n content: item.description,\n }],\n ...(state.initialSync ? { unread: false } : {}), // false for initial, omit for incremental\n ...(state.initialSync ? { archived: false } : {}), // unarchive on initial only\n });\n }\n\n if (result.nextPageToken) {\n // Update state in Store for next batch\n await this.set(`sync_state_${resourceId}`, {\n nextPageToken: result.nextPageToken,\n batchNumber: state.batchNumber + 1,\n itemsProcessed: state.itemsProcessed + result.items.length,\n initialSync: state.initialSync, // Preserve initialSync flag across batches\n });\n\n // Queue next batch - creates NEW execution with fresh request limit\n const nextCallback = await this.callback(this.syncBatch, resourceId);\n await this.runTask(nextCallback);\n } else {\n // Cleanup when complete\n await this.clear(`sync_state_${resourceId}`);\n\n // Optionally notify user of completion\n await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Sync complete\",\n notes: [\n {\n content: `Successfully processed ${state.itemsProcessed + result.items.length} items.`,\n },\n ],\n });\n }\n}\n```\n\n## Thread Sync Best Practices\n\nWhen syncing threads from external systems, follow these patterns for optimal user experience:\n\n### The `initialSync` Flag\n\nAll sync-based tools should distinguish between initial sync (first import) and incremental sync (ongoing updates):\n\n| Field | Initial Sync | Incremental Sync | Reason |\n|-------|--------------|------------------|---------|\n| `unread` | `false` | *omit* | Initial: mark read for all. Incremental: auto-mark read for author only |\n| `archived` | `false` | *omit* | Unarchive on install, preserve user choice on updates |\n\n**Example:**\n```typescript\nconst thread: NewThread = {\n type: ThreadType.Event,\n source: event.url,\n title: event.title,\n ...(initialSync ? { unread: false } : {}), // false for initial, omit for incremental\n ...(initialSync ? { archived: false } : {}), // unarchive on initial only\n};\n```\n\n**Why this matters:**\n- **Initial sync**: Activities are unarchived and marked as read for all users, preventing spam from bulk historical imports\n- **Incremental sync**: Activities are auto-marked read for the author (twist owner), unread for everyone else. Archived state is preserved\n- **Reinstall**: Acts as initial sync, so previously archived activities are unarchived (fresh start)\n\n### Two-Way Sync: Avoiding Race Conditions\n\nWhen implementing two-way sync where items created in Plot are pushed to an external system (e.g. Notes becoming comments), a race condition can occur: the external system may send a webhook for the newly created item before you've updated the Thread/Note with the external key. The webhook handler won't find the item by external key and may create a duplicate.\n\n**Solution:** Embed the Plot `Thread.id` / `Note.id` in the external item's metadata when creating it, and update `Thread.source` / `Note.key` after creation. When processing webhooks, check for the Plot ID in metadata first.\n\n```typescript\nasync pushNoteAsComment(note: Note, externalItemId: string): Promise<void> {\n // Create external item with Plot ID in metadata for webhook correlation\n const externalComment = await externalApi.createComment(externalItemId, {\n body: note.content,\n metadata: { plotNoteId: note.id },\n });\n\n // Update Note with external key AFTER creation\n // A webhook may arrive before this completes \u2014 that's OK (see onWebhook below)\n await this.tools.plot.updateNote({\n id: note.id,\n key: `comment-${externalComment.id}`,\n });\n}\n\nasync onWebhook(payload: WebhookPayload): Promise<void> {\n const comment = payload.comment;\n\n // Use Plot ID from metadata if present (handles race condition),\n // otherwise fall back to upserting by activity source and key\n await this.tools.plot.createNote({\n ...(comment.metadata?.plotNoteId\n ? { id: comment.metadata.plotNoteId }\n : { activity: { source: payload.itemUrl } }),\n key: `comment-${comment.id}`,\n content: comment.body,\n });\n}\n```\n\n## Error Handling\n\nAlways handle errors gracefully and communicate them to users:\n\n```typescript\ntry {\n await this.externalOperation();\n} catch (error) {\n console.error(\"Operation failed:\", error);\n\n await this.tools.plot.createThread({\n type: ThreadType.Note,\n title: \"Operation failed\",\n notes: [\n {\n content: `Failed to complete operation: ${error.message}`,\n },\n ],\n });\n}\n```\n\n## Common Pitfalls\n\n- **Don't use instance variables for state** - Anything stored in memory is lost after function execution. Always use the Store tool for data that needs to persist.\n- **Processing self-created threads** - Other users may change a Thread created by the twist, resulting in a callback. Be sure to check the `changes === null` and/or `thread.author.id !== this.id` to avoid re-processing.\n- **Always create Threads with Notes** - See \"Understanding Threads and Notes\" section above for the thread/message pattern and decision tree.\n- **Use correct Thread types** - Most should be `ThreadType.Note`. Only use `Action` for tasks with `done`, and `Event` for items with `start`/`end`.\n- **Use Thread.source and Note.key for automatic upserts (Recommended)** - Set Thread.source to the external item's URL for automatic deduplication. Only use UUID generation and storage for advanced cases (see SYNC_STRATEGIES.md).\n- **Add Notes to existing Threads** - For source/key pattern, reference threads by source. For UUID pattern, look up stored mappings before creating new Threads. Think thread replies, not new threads.\n- Tools are declared in the `build` method and accessed via `this.tools.toolName` in twist methods.\n- **Don't forget request limits** - Each execution has ~1000 requests (HTTP requests, tool calls). Break long loops into batches with `this.runTask()` to get fresh request limits. Calculate requests per item to determine safe batch size (e.g., if each item needs ~10 requests, batch size = ~100 items).\n- **Always use Callbacks tool for persistent references** - Direct function references don't survive worker restarts.\n- **Store auth tokens** - Don't re-request authentication unnecessarily.\n- **Clean up callbacks and stored state** - Delete callbacks and Store entries when no longer needed.\n- **Handle missing auth gracefully** - Check for stored auth before operations.\n- **CRITICAL: Maintain callback backward compatibility** - All callbacks (webhooks, tasks, batch operations) automatically upgrade to new twist versions. You **must** maintain backward compatibility in callback method signatures. Only add optional parameters at the end, never remove or reorder parameters. For breaking changes, implement migration logic in the `upgrade()` lifecycle method to recreate affected callbacks.\n\n## Testing\n\nBefore deploying, verify:\n\n1. Linting passes: `{{packageManager}} lint`\n2. All dependencies are in package.json\n3. Authentication flow works end-to-end\n4. Batch operations handle pagination correctly\n5. Error cases are handled gracefully\n";
|
|
2
2
|
//# sourceMappingURL=twist-guide.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twist-guide.d.ts","sourceRoot":"","sources":["../src/twist-guide.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"twist-guide.d.ts","sourceRoot":"","sources":["../src/twist-guide.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,mxwBAAsB,CAAC"}
|
package/dist/twist.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NoteWriteBackResult } from "./connector";
|
|
1
2
|
import { type Action, type Actor, type ActorId, type Link, type Note, type Thread, Uuid } from "./plot";
|
|
2
3
|
import type { Tag } from "./tag";
|
|
3
4
|
import { type ITool } from "./tool";
|
|
@@ -299,7 +300,7 @@ export declare abstract class Twist<TSelf> {
|
|
|
299
300
|
* @param note - The newly created note
|
|
300
301
|
* @returns Optional note key for external deduplication
|
|
301
302
|
*/
|
|
302
|
-
onNoteCreated(note: Note, ...args: any[]): Promise<string | void>;
|
|
303
|
+
onNoteCreated(note: Note, ...args: any[]): Promise<string | NoteWriteBackResult | void>;
|
|
303
304
|
/**
|
|
304
305
|
* Called when a link is created in a connected source channel.
|
|
305
306
|
* Requires `link: true` in Plot options.
|
package/dist/twist.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AIvF;;;;;;OAMG;IAEH,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;;;;;OAMG;IAEH,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;;;;;OAMG;IAEH,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/twist.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twist.js","sourceRoot":"","sources":["../src/twist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"twist.js","sourceRoot":"","sources":["../src/twist.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAgB,KAAK;IAwBH;IAAkB;IAvBxC;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAU,iBAAiB,CAAW;IAE5C;;;OAGG;IACO,MAAM,CAAQ;IAExB,YAAsB,EAAQ,EAAU,QAAkB;QAApC,OAAE,GAAF,EAAE,CAAM;QAAU,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAE9D;;;OAGG;IACH,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAqB,CAAC;IACrD,CAAC;IA4CS,KAAK,CAAC,QAAQ,CAGtB,EAAM,EAAE,GAAG,SAAgB;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACO,KAAK,CAAC,cAAc,CAG5B,EAAM,EAAE,G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,EAAE,KAAc;QACtC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,6DAA6D;IAC7D,iBAAiB,CAAC,IAAU,EAAE,IAAU;QACtC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion helpers for connectors that bridge Plot markdown to external
|
|
3
|
+
* systems that store content as plain text (Google Drive comments, Todoist
|
|
4
|
+
* comments, Airtable cells, Attio notes, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Both functions are pure and run in-process inside the connector's twist
|
|
7
|
+
* runtime — no RPC boundary is crossed, so they are cheap to call on every
|
|
8
|
+
* `onNoteCreated` / `onNoteUpdated`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Render Markdown as plain text while preserving document structure.
|
|
12
|
+
*
|
|
13
|
+
* Numbered lists authored as `1. / 1. / 1.` in markdown are renumbered to
|
|
14
|
+
* `1. / 2. / 3.` so the plain-text reader sees real numbers. Bullet
|
|
15
|
+
* markers, headings content, blockquotes, and paragraph breaks survive;
|
|
16
|
+
* emphasis markers, code fences, and image syntax are dropped.
|
|
17
|
+
*
|
|
18
|
+
* Mentions `[Name](#@UUID)` render as `@Name`. Links `[text](url)`
|
|
19
|
+
* collapse to their label, falling back to the URL when the label is
|
|
20
|
+
* empty or identical to the URL.
|
|
21
|
+
*
|
|
22
|
+
* Use this when writing a Plot note to an external API that stores
|
|
23
|
+
* content verbatim as plain text. Pair the result with a matching
|
|
24
|
+
* `NoteWriteBackResult.externalContent` so the sync baseline round-trips.
|
|
25
|
+
*/
|
|
26
|
+
export declare function markdownToPlainText(markdown: string): string;
|
|
27
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAwC5D"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversion helpers for connectors that bridge Plot markdown to external
|
|
3
|
+
* systems that store content as plain text (Google Drive comments, Todoist
|
|
4
|
+
* comments, Airtable cells, Attio notes, etc.).
|
|
5
|
+
*
|
|
6
|
+
* Both functions are pure and run in-process inside the connector's twist
|
|
7
|
+
* runtime — no RPC boundary is crossed, so they are cheap to call on every
|
|
8
|
+
* `onNoteCreated` / `onNoteUpdated`.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Render Markdown as plain text while preserving document structure.
|
|
12
|
+
*
|
|
13
|
+
* Numbered lists authored as `1. / 1. / 1.` in markdown are renumbered to
|
|
14
|
+
* `1. / 2. / 3.` so the plain-text reader sees real numbers. Bullet
|
|
15
|
+
* markers, headings content, blockquotes, and paragraph breaks survive;
|
|
16
|
+
* emphasis markers, code fences, and image syntax are dropped.
|
|
17
|
+
*
|
|
18
|
+
* Mentions `[Name](#@UUID)` render as `@Name`. Links `[text](url)`
|
|
19
|
+
* collapse to their label, falling back to the URL when the label is
|
|
20
|
+
* empty or identical to the URL.
|
|
21
|
+
*
|
|
22
|
+
* Use this when writing a Plot note to an external API that stores
|
|
23
|
+
* content verbatim as plain text. Pair the result with a matching
|
|
24
|
+
* `NoteWriteBackResult.externalContent` so the sync baseline round-trips.
|
|
25
|
+
*/
|
|
26
|
+
export function markdownToPlainText(markdown) {
|
|
27
|
+
let text = markdown;
|
|
28
|
+
text = text.replace(/```[a-zA-Z0-9]*\n([\s\S]*?)```/g, "$1");
|
|
29
|
+
text = text.replace(/`([^`]+)`/g, "$1");
|
|
30
|
+
text = text.replace(/!\[[^\]]*\]\([^)]*\)/g, "");
|
|
31
|
+
text = text.replace(/\[([^\]]+)\]\(#@[^)]+\)/g, "@$1");
|
|
32
|
+
text = text.replace(/\[([^\]]*)\]\(<?([^>)]+)>?\)/g, (_, label, url) => {
|
|
33
|
+
if (!label)
|
|
34
|
+
return url;
|
|
35
|
+
if (label === url)
|
|
36
|
+
return url;
|
|
37
|
+
return label;
|
|
38
|
+
});
|
|
39
|
+
text = text.replace(/^\s{0,3}#{1,6}\s+/gm, "");
|
|
40
|
+
text = text.replace(/^\s{0,3}>\s?/gm, "");
|
|
41
|
+
text = text.replace(/(\*\*|__)(.+?)\1/g, "$2");
|
|
42
|
+
text = text.replace(/(?<![*_])([*_])([^*_\n]+)\1(?![*_])/g, "$2");
|
|
43
|
+
text = text.replace(/~~(.+?)~~/g, "$1");
|
|
44
|
+
text = text.replace(/^\s{0,3}(?:-\s?){3,}\s*$/gm, "");
|
|
45
|
+
text = text.replace(/^\s{0,3}(?:\*\s?){3,}\s*$/gm, "");
|
|
46
|
+
text = text.replace(/^\s{0,3}(?:_\s?){3,}\s*$/gm, "");
|
|
47
|
+
text = renumberNumberedLists(text);
|
|
48
|
+
text = text
|
|
49
|
+
.replace(/&/g, "&")
|
|
50
|
+
.replace(/</g, "<")
|
|
51
|
+
.replace(/>/g, ">")
|
|
52
|
+
.replace(/"/g, '"')
|
|
53
|
+
.replace(/'/g, "'")
|
|
54
|
+
.replace(/ /g, " ");
|
|
55
|
+
text = text.replace(/\n{3,}/g, "\n\n");
|
|
56
|
+
return text.trim();
|
|
57
|
+
}
|
|
58
|
+
function renumberNumberedLists(text) {
|
|
59
|
+
const lines = text.split("\n");
|
|
60
|
+
const numberedRe = /^(\s*)(\d+)\.(\s+)(.*)$/;
|
|
61
|
+
let currentIndent = null;
|
|
62
|
+
let counter = 0;
|
|
63
|
+
for (let i = 0; i < lines.length; i++) {
|
|
64
|
+
const match = numberedRe.exec(lines[i]);
|
|
65
|
+
if (!match) {
|
|
66
|
+
currentIndent = null;
|
|
67
|
+
counter = 0;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const [, indent, , space, content] = match;
|
|
71
|
+
if (indent !== currentIndent) {
|
|
72
|
+
currentIndent = indent;
|
|
73
|
+
counter = 1;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
counter += 1;
|
|
77
|
+
}
|
|
78
|
+
lines[i] = `${indent}${counter}.${space}${content}`;
|
|
79
|
+
}
|
|
80
|
+
return lines.join("\n");
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,IAAI,IAAI,GAAG,QAAQ,CAAC;IAEpB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,iCAAiC,EAAE,IAAI,CAAC,CAAC;IAC7D,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAExC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAEjD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IAEvD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrE,IAAI,CAAC,KAAK;YAAE,OAAO,GAAG,CAAC;QACvB,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,GAAG,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAA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K,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,aAAa,GAAG,IAAI,CAAC;YACrB,OAAO,GAAG,CAAC,CAAC;YACZ,SAAS;QACX,CAAC;QACD,MAAM,CAAC,EAAE,MAAM,EAAE,AAAD,EAAG,KAAK,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;QAC3C,IAAI,MAAM,KAAK,aAAa,EAAE,CAAC;YAC7B,aAAa,GAAG,MAAM,CAAC;YACvB,OAAO,GAAG,CAAC,CAAC;QACd,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,CAAC;QACf,CAAC;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,GAAG,OAAO,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;IACtD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plotday/twister",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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",
|