@plotday/twister 0.56.0 → 0.58.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.
Files changed (331) hide show
  1. package/README.md +53 -44
  2. package/bin/commands/create.js +9 -14
  3. package/bin/commands/create.js.map +1 -1
  4. package/bin/commands/deploy.js +2 -0
  5. package/bin/commands/deploy.js.map +1 -1
  6. package/bin/commands/generate.js +8 -5
  7. package/bin/commands/generate.js.map +1 -1
  8. package/bin/index.js +2 -2
  9. package/bin/index.js.map +1 -1
  10. package/bin/templates/AGENTS.template.md +110 -94
  11. package/bin/templates/README.template.md +36 -33
  12. package/cli/templates/AGENTS.template.md +110 -94
  13. package/cli/templates/README.template.md +36 -33
  14. package/dist/connector.d.ts +24 -17
  15. package/dist/connector.d.ts.map +1 -1
  16. package/dist/connector.js +19 -12
  17. package/dist/connector.js.map +1 -1
  18. package/dist/docs/assets/hierarchy.js +1 -1
  19. package/dist/docs/assets/navigation.js +1 -1
  20. package/dist/docs/assets/search.js +1 -1
  21. package/dist/docs/classes/index.Connector.html +66 -60
  22. package/dist/docs/classes/index.FileNotFoundError.html +2 -2
  23. package/dist/docs/classes/index.Files.html +4 -4
  24. package/dist/docs/classes/index.Imap.html +10 -10
  25. package/dist/docs/classes/index.Options.html +2 -2
  26. package/dist/docs/classes/index.Smtp.html +6 -6
  27. package/dist/docs/classes/tool.ITool.html +2 -2
  28. package/dist/docs/classes/tool.Tool.html +23 -23
  29. package/dist/docs/classes/tools_ai.AI.html +5 -5
  30. package/dist/docs/classes/tools_callbacks.Callbacks.html +8 -8
  31. package/dist/docs/classes/tools_integrations.Integrations.html +26 -12
  32. package/dist/docs/classes/tools_network.Network.html +9 -9
  33. package/dist/docs/classes/tools_plot.Plot.html +34 -33
  34. package/dist/docs/classes/tools_store.Store.html +8 -8
  35. package/dist/docs/classes/tools_tasks.Tasks.html +6 -6
  36. package/dist/docs/classes/tools_twists.Twists.html +12 -11
  37. package/dist/docs/classes/twist.Twist.html +28 -28
  38. package/dist/docs/documents/Building_Connectors.html +42 -28
  39. package/dist/docs/documents/Built-in_Tools.html +170 -67
  40. package/dist/docs/documents/CLI_Reference.html +68 -47
  41. package/dist/docs/documents/Core_Concepts.html +52 -81
  42. package/dist/docs/documents/Getting_Started.html +28 -31
  43. package/dist/docs/documents/MULTI_USER_AUTH.html +45 -0
  44. package/dist/docs/documents/Runtime_Environment.html +13 -12
  45. package/dist/docs/documents/SYNC_STRATEGIES.html +373 -0
  46. package/dist/docs/enums/plot.ActionType.html +9 -9
  47. package/dist/docs/enums/plot.ActorType.html +4 -4
  48. package/dist/docs/enums/plot.ConferencingProvider.html +6 -6
  49. package/dist/docs/enums/plot.ThemeColor.html +9 -9
  50. package/dist/docs/enums/tag.Tag.html +3 -3
  51. package/dist/docs/enums/tools_ai.AIModel.html +3 -3
  52. package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
  53. package/dist/docs/enums/tools_plot.ContactAccess.html +2 -2
  54. package/dist/docs/enums/tools_plot.FocusAccess.html +3 -3
  55. package/dist/docs/enums/tools_plot.LinkAccess.html +3 -3
  56. package/dist/docs/enums/tools_plot.ThreadAccess.html +4 -4
  57. package/dist/docs/functions/index.Uuid.Generate.html +1 -1
  58. package/dist/docs/functions/utils_hash.quickHash.html +1 -1
  59. package/dist/docs/hierarchy.html +1 -1
  60. package/dist/docs/index.html +7 -8
  61. package/dist/docs/interfaces/tools_ai.AIRequest.html +13 -13
  62. package/dist/docs/interfaces/tools_ai.AIResponse.html +9 -9
  63. package/dist/docs/interfaces/tools_ai.FilePart.html +5 -5
  64. package/dist/docs/interfaces/tools_ai.ImagePart.html +4 -4
  65. package/dist/docs/interfaces/tools_ai.ReasoningPart.html +4 -4
  66. package/dist/docs/interfaces/tools_ai.RedactedReasoningPart.html +3 -3
  67. package/dist/docs/interfaces/tools_ai.TextPart.html +3 -3
  68. package/dist/docs/interfaces/tools_ai.ToolCallPart.html +5 -5
  69. package/dist/docs/interfaces/tools_ai.ToolExecutionOptions.html +4 -4
  70. package/dist/docs/interfaces/tools_ai.ToolResultPart.html +5 -5
  71. package/dist/docs/interfaces/tools_twists.TwistSource.html +3 -3
  72. package/dist/docs/interfaces/utils_types.ToolShed.html +5 -5
  73. package/dist/docs/media/AGENTS.md +101 -74
  74. package/dist/docs/modules/index.html +1 -1
  75. package/dist/docs/modules/tools_integrations.html +1 -1
  76. package/dist/docs/modules.html +1 -1
  77. package/dist/docs/types/index.BooleanDef.html +2 -2
  78. package/dist/docs/types/index.CreateLinkDraft.html +9 -9
  79. package/dist/docs/types/index.ImapAddress.html +3 -3
  80. package/dist/docs/types/index.ImapConnectOptions.html +6 -6
  81. package/dist/docs/types/index.ImapFetchOptions.html +4 -4
  82. package/dist/docs/types/index.ImapFlagOperation.html +1 -1
  83. package/dist/docs/types/index.ImapMailbox.html +5 -5
  84. package/dist/docs/types/index.ImapMailboxStatus.html +7 -7
  85. package/dist/docs/types/index.ImapMessage.html +14 -14
  86. package/dist/docs/types/index.ImapSearchCriteria.html +9 -9
  87. package/dist/docs/types/index.ImapSession.html +1 -1
  88. package/dist/docs/types/index.NewSchedule.html +13 -13
  89. package/dist/docs/types/index.NewScheduleContact.html +2 -2
  90. package/dist/docs/types/index.NewScheduleOccurrence.html +1 -1
  91. package/dist/docs/types/index.NoteWriteBackResult.html +3 -3
  92. package/dist/docs/types/index.NumberDef.html +2 -2
  93. package/dist/docs/types/index.OptionDef.html +1 -1
  94. package/dist/docs/types/index.OptionalScopeGroup.html +6 -6
  95. package/dist/docs/types/index.OptionsSchema.html +1 -1
  96. package/dist/docs/types/index.ReactionCapabilities.html +1 -1
  97. package/dist/docs/types/index.ResolvedOptions.html +1 -1
  98. package/dist/docs/types/index.ResolvedRecipient.html +5 -5
  99. package/dist/docs/types/index.Schedule.html +12 -12
  100. package/dist/docs/types/index.ScheduleContact.html +2 -2
  101. package/dist/docs/types/index.ScheduleContactRole.html +1 -1
  102. package/dist/docs/types/index.ScheduleContactStatus.html +1 -1
  103. package/dist/docs/types/index.ScheduleOccurrence.html +6 -6
  104. package/dist/docs/types/index.ScheduleOccurrenceUpdate.html +1 -1
  105. package/dist/docs/types/index.ScopeConfig.html +3 -3
  106. package/dist/docs/types/index.SelectDef.html +2 -2
  107. package/dist/docs/types/index.Serializable.html +1 -1
  108. package/dist/docs/types/index.SmtpAddress.html +3 -3
  109. package/dist/docs/types/index.SmtpConnectOptions.html +7 -7
  110. package/dist/docs/types/index.SmtpMessage.html +12 -12
  111. package/dist/docs/types/index.SmtpSendResult.html +4 -4
  112. package/dist/docs/types/index.SmtpSession.html +1 -1
  113. package/dist/docs/types/index.TextDef.html +2 -2
  114. package/dist/docs/types/index.Uuid.html +1 -1
  115. package/dist/docs/types/plot.Action.html +1 -1
  116. package/dist/docs/types/plot.Actor.html +5 -5
  117. package/dist/docs/types/plot.ActorId.html +4 -4
  118. package/dist/docs/types/plot.Contact.html +4 -4
  119. package/dist/docs/types/plot.ContentType.html +1 -1
  120. package/dist/docs/types/plot.Focus.html +8 -8
  121. package/dist/docs/types/plot.FocusUpdate.html +1 -1
  122. package/dist/docs/types/plot.Link.html +17 -17
  123. package/dist/docs/types/plot.LinkUpdate.html +1 -1
  124. package/dist/docs/types/plot.NewActor.html +1 -1
  125. package/dist/docs/types/plot.NewContact.html +1 -1
  126. package/dist/docs/types/plot.NewFocus.html +1 -1
  127. package/dist/docs/types/plot.NewLink.html +5 -2
  128. package/dist/docs/types/plot.NewLinkWithNotes.html +1 -1
  129. package/dist/docs/types/plot.NewNote.html +1 -1
  130. package/dist/docs/types/plot.NewReactions.html +1 -1
  131. package/dist/docs/types/plot.NewTags.html +1 -1
  132. package/dist/docs/types/plot.NewThread.html +1 -1
  133. package/dist/docs/types/plot.NewThreadWithNotes.html +1 -1
  134. package/dist/docs/types/plot.Note.html +1 -1
  135. package/dist/docs/types/plot.NoteUpdate.html +1 -1
  136. package/dist/docs/types/plot.PlanOperation.html +1 -1
  137. package/dist/docs/types/plot.Reaction.html +3 -3
  138. package/dist/docs/types/plot.Reactions.html +1 -1
  139. package/dist/docs/types/plot.Tags.html +1 -1
  140. package/dist/docs/types/plot.Thread.html +1 -1
  141. package/dist/docs/types/plot.ThreadAccessLevel.html +1 -1
  142. package/dist/docs/types/plot.ThreadCommon.html +6 -6
  143. package/dist/docs/types/plot.ThreadFilter.html +2 -2
  144. package/dist/docs/types/plot.ThreadMeta.html +1 -1
  145. package/dist/docs/types/plot.ThreadType.html +1 -1
  146. package/dist/docs/types/plot.ThreadUpdate.html +1 -1
  147. package/dist/docs/types/plot.ThreadWithNotes.html +1 -1
  148. package/dist/docs/types/tools_ai.AIAssistantMessage.html +2 -2
  149. package/dist/docs/types/tools_ai.AICapabilities.html +4 -4
  150. package/dist/docs/types/tools_ai.AIMessage.html +1 -1
  151. package/dist/docs/types/tools_ai.AIOptions.html +2 -2
  152. package/dist/docs/types/tools_ai.AISource.html +1 -1
  153. package/dist/docs/types/tools_ai.AISystemMessage.html +2 -2
  154. package/dist/docs/types/tools_ai.AITool.html +1 -1
  155. package/dist/docs/types/tools_ai.AIToolMessage.html +2 -2
  156. package/dist/docs/types/tools_ai.AIToolSet.html +1 -1
  157. package/dist/docs/types/tools_ai.AIUsage.html +5 -5
  158. package/dist/docs/types/tools_ai.AIUserMessage.html +2 -2
  159. package/dist/docs/types/tools_ai.DataContent.html +1 -1
  160. package/dist/docs/types/tools_ai.ModelPreferences.html +5 -5
  161. package/dist/docs/types/tools_callbacks.Callback.html +2 -2
  162. package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
  163. package/dist/docs/types/tools_integrations.ArchiveNotesFilter.html +5 -0
  164. package/dist/docs/types/tools_integrations.AuthToken.html +6 -5
  165. package/dist/docs/types/tools_integrations.Authorization.html +4 -4
  166. package/dist/docs/types/tools_integrations.Channel.html +6 -6
  167. package/dist/docs/types/tools_integrations.ComposeConfig.html +4 -4
  168. package/dist/docs/types/tools_integrations.ContactRoleConfig.html +5 -5
  169. package/dist/docs/types/tools_integrations.LinkTypeConfig.html +21 -21
  170. package/dist/docs/types/tools_integrations.NewCustomEmoji.html +8 -8
  171. package/dist/docs/types/tools_integrations.StatusIcon.html +1 -1
  172. package/dist/docs/types/tools_integrations.SyncContext.html +4 -4
  173. package/dist/docs/types/tools_network.WebhookRequest.html +6 -6
  174. package/dist/docs/types/tools_plot.LinkFilter.html +5 -5
  175. package/dist/docs/types/tools_plot.LinkSearchResult.html +1 -1
  176. package/dist/docs/types/tools_plot.NoteIntentHandler.html +4 -4
  177. package/dist/docs/types/tools_plot.NoteSearchResult.html +1 -1
  178. package/dist/docs/types/tools_plot.SearchOptions.html +4 -4
  179. package/dist/docs/types/tools_plot.SearchResult.html +1 -1
  180. package/dist/docs/types/tools_twists.Log.html +2 -2
  181. package/dist/docs/types/tools_twists.TwistPermissions.html +1 -1
  182. package/dist/docs/types/utils_types.BuiltInTools.html +2 -2
  183. package/dist/docs/types/utils_types.ExtractBuildReturn.html +1 -1
  184. package/dist/docs/types/utils_types.InferOptions.html +1 -1
  185. package/dist/docs/types/utils_types.InferTools.html +1 -1
  186. package/dist/docs/types/utils_types.JSONValue.html +1 -1
  187. package/dist/docs/types/utils_types.PromiseValues.html +1 -1
  188. package/dist/docs/types/utils_types.ToolBuilder.html +1 -1
  189. package/dist/docs/variables/tools_plot.SEARCH_DEFAULT_LIMIT.html +1 -1
  190. package/dist/docs/variables/tools_plot.SEARCH_MAX_LIMIT.html +1 -1
  191. package/dist/facets.d.ts +30 -0
  192. package/dist/facets.d.ts.map +1 -0
  193. package/dist/facets.js +16 -0
  194. package/dist/facets.js.map +1 -0
  195. package/dist/llm-docs/connector.d.ts +1 -1
  196. package/dist/llm-docs/connector.d.ts.map +1 -1
  197. package/dist/llm-docs/connector.js +1 -1
  198. package/dist/llm-docs/connector.js.map +1 -1
  199. package/dist/llm-docs/facets.d.ts +9 -0
  200. package/dist/llm-docs/facets.d.ts.map +1 -0
  201. package/dist/llm-docs/facets.js +8 -0
  202. package/dist/llm-docs/facets.js.map +1 -0
  203. package/dist/llm-docs/index.d.ts.map +1 -1
  204. package/dist/llm-docs/index.js +2 -0
  205. package/dist/llm-docs/index.js.map +1 -1
  206. package/dist/llm-docs/plot.d.ts +1 -1
  207. package/dist/llm-docs/plot.d.ts.map +1 -1
  208. package/dist/llm-docs/plot.js +1 -1
  209. package/dist/llm-docs/plot.js.map +1 -1
  210. package/dist/llm-docs/tool.d.ts +1 -1
  211. package/dist/llm-docs/tool.d.ts.map +1 -1
  212. package/dist/llm-docs/tool.js +1 -1
  213. package/dist/llm-docs/tool.js.map +1 -1
  214. package/dist/llm-docs/tools/ai.d.ts +1 -1
  215. package/dist/llm-docs/tools/ai.d.ts.map +1 -1
  216. package/dist/llm-docs/tools/ai.js +1 -1
  217. package/dist/llm-docs/tools/ai.js.map +1 -1
  218. package/dist/llm-docs/tools/callbacks.d.ts +1 -1
  219. package/dist/llm-docs/tools/callbacks.d.ts.map +1 -1
  220. package/dist/llm-docs/tools/callbacks.js +1 -1
  221. package/dist/llm-docs/tools/callbacks.js.map +1 -1
  222. package/dist/llm-docs/tools/files.d.ts +1 -1
  223. package/dist/llm-docs/tools/files.d.ts.map +1 -1
  224. package/dist/llm-docs/tools/files.js +1 -1
  225. package/dist/llm-docs/tools/files.js.map +1 -1
  226. package/dist/llm-docs/tools/imap.d.ts +1 -1
  227. package/dist/llm-docs/tools/imap.d.ts.map +1 -1
  228. package/dist/llm-docs/tools/imap.js +1 -1
  229. package/dist/llm-docs/tools/imap.js.map +1 -1
  230. package/dist/llm-docs/tools/integrations.d.ts +1 -1
  231. package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
  232. package/dist/llm-docs/tools/integrations.js +1 -1
  233. package/dist/llm-docs/tools/integrations.js.map +1 -1
  234. package/dist/llm-docs/tools/network.d.ts +1 -1
  235. package/dist/llm-docs/tools/network.d.ts.map +1 -1
  236. package/dist/llm-docs/tools/network.js +1 -1
  237. package/dist/llm-docs/tools/network.js.map +1 -1
  238. package/dist/llm-docs/tools/plot.d.ts +1 -1
  239. package/dist/llm-docs/tools/plot.d.ts.map +1 -1
  240. package/dist/llm-docs/tools/plot.js +1 -1
  241. package/dist/llm-docs/tools/plot.js.map +1 -1
  242. package/dist/llm-docs/tools/smtp.d.ts +1 -1
  243. package/dist/llm-docs/tools/smtp.d.ts.map +1 -1
  244. package/dist/llm-docs/tools/smtp.js +1 -1
  245. package/dist/llm-docs/tools/smtp.js.map +1 -1
  246. package/dist/llm-docs/tools/tasks.d.ts +1 -1
  247. package/dist/llm-docs/tools/tasks.d.ts.map +1 -1
  248. package/dist/llm-docs/tools/tasks.js +1 -1
  249. package/dist/llm-docs/tools/tasks.js.map +1 -1
  250. package/dist/llm-docs/tools/twists.d.ts +1 -1
  251. package/dist/llm-docs/tools/twists.d.ts.map +1 -1
  252. package/dist/llm-docs/tools/twists.js +1 -1
  253. package/dist/llm-docs/tools/twists.js.map +1 -1
  254. package/dist/llm-docs/twist-guide-template.d.ts +1 -1
  255. package/dist/llm-docs/twist-guide-template.d.ts.map +1 -1
  256. package/dist/llm-docs/twist-guide-template.js +1 -1
  257. package/dist/llm-docs/twist-guide-template.js.map +1 -1
  258. package/dist/llm-docs/twist.d.ts +1 -1
  259. package/dist/llm-docs/twist.d.ts.map +1 -1
  260. package/dist/llm-docs/twist.js +1 -1
  261. package/dist/llm-docs/twist.js.map +1 -1
  262. package/dist/plot.d.ts +15 -8
  263. package/dist/plot.d.ts.map +1 -1
  264. package/dist/plot.js.map +1 -1
  265. package/dist/tool.d.ts +4 -4
  266. package/dist/tool.js +4 -4
  267. package/dist/tools/ai.d.ts +12 -13
  268. package/dist/tools/ai.d.ts.map +1 -1
  269. package/dist/tools/ai.js +8 -9
  270. package/dist/tools/ai.js.map +1 -1
  271. package/dist/tools/callbacks.d.ts +1 -1
  272. package/dist/tools/files.d.ts +2 -2
  273. package/dist/tools/imap.d.ts +1 -1
  274. package/dist/tools/imap.js +1 -1
  275. package/dist/tools/integrations.d.ts +29 -2
  276. package/dist/tools/integrations.d.ts.map +1 -1
  277. package/dist/tools/integrations.js.map +1 -1
  278. package/dist/tools/network.d.ts +5 -5
  279. package/dist/tools/plot.d.ts +42 -37
  280. package/dist/tools/plot.d.ts.map +1 -1
  281. package/dist/tools/plot.js +16 -12
  282. package/dist/tools/plot.js.map +1 -1
  283. package/dist/tools/smtp.d.ts +1 -1
  284. package/dist/tools/smtp.js +1 -1
  285. package/dist/tools/tasks.d.ts +6 -8
  286. package/dist/tools/tasks.d.ts.map +1 -1
  287. package/dist/tools/tasks.js +5 -7
  288. package/dist/tools/tasks.js.map +1 -1
  289. package/dist/tools/twists.d.ts +15 -14
  290. package/dist/tools/twists.d.ts.map +1 -1
  291. package/dist/tools/twists.js +2 -2
  292. package/dist/tools/twists.js.map +1 -1
  293. package/dist/twist-guide.d.ts +1 -1
  294. package/dist/twist-guide.d.ts.map +1 -1
  295. package/dist/twist.d.ts +2 -2
  296. package/dist/twist.js +2 -2
  297. package/package.json +6 -1
  298. package/src/connector.ts +23 -16
  299. package/src/facets.ts +40 -0
  300. package/src/llm-docs/connector.ts +1 -1
  301. package/src/llm-docs/facets.ts +8 -0
  302. package/src/llm-docs/index.ts +2 -0
  303. package/src/llm-docs/plot.ts +1 -1
  304. package/src/llm-docs/tool.ts +1 -1
  305. package/src/llm-docs/tools/ai.ts +1 -1
  306. package/src/llm-docs/tools/callbacks.ts +1 -1
  307. package/src/llm-docs/tools/files.ts +1 -1
  308. package/src/llm-docs/tools/imap.ts +1 -1
  309. package/src/llm-docs/tools/integrations.ts +1 -1
  310. package/src/llm-docs/tools/network.ts +1 -1
  311. package/src/llm-docs/tools/plot.ts +1 -1
  312. package/src/llm-docs/tools/smtp.ts +1 -1
  313. package/src/llm-docs/tools/tasks.ts +1 -1
  314. package/src/llm-docs/tools/twists.ts +1 -1
  315. package/src/llm-docs/twist-guide-template.ts +1 -1
  316. package/src/llm-docs/twist.ts +1 -1
  317. package/src/plot.ts +15 -8
  318. package/src/tool.ts +4 -4
  319. package/src/tools/ai.ts +12 -13
  320. package/src/tools/callbacks.ts +1 -1
  321. package/src/tools/files.ts +2 -2
  322. package/src/tools/imap.ts +1 -1
  323. package/src/tools/integrations.ts +34 -1
  324. package/src/tools/network.ts +5 -5
  325. package/src/tools/plot.ts +42 -37
  326. package/src/tools/smtp.ts +1 -1
  327. package/src/tools/tasks.ts +6 -8
  328. package/src/tools/twists.ts +15 -14
  329. package/src/twist.ts +2 -2
  330. package/dist/docs/media/MULTI_USER_AUTH.md +0 -116
  331. package/dist/docs/media/SYNC_STRATEGIES.md +0 -818
package/src/tools/plot.ts CHANGED
@@ -146,22 +146,26 @@ export type SearchOptions = {
146
146
  *
147
147
  * @example
148
148
  * ```typescript
149
- * class MyTwist extends Twist {
150
- * private plot: Plot;
151
- *
152
- * constructor(id: string, tools: ToolBuilder) {
153
- * super();
154
- * this.plot = tools.get(Plot);
149
+ * class MyTwist extends Twist<MyTwist> {
150
+ * build(build: ToolBuilder) {
151
+ * return {
152
+ * plot: build(Plot, {
153
+ * thread: { access: ThreadAccess.Create },
154
+ * }),
155
+ * };
155
156
  * }
156
157
  *
157
158
  * async activate() {
158
- * // Create a welcome thread
159
- * await this.plot.createThread({
159
+ * // Create a welcome thread with an opening note
160
+ * await this.tools.plot.createThread({
160
161
  * title: "Welcome to Plot!",
161
- * actions: [{
162
- * title: "Get Started",
163
- * type: ActionType.external,
164
- * url: "https://plot.day/docs"
162
+ * notes: [{
163
+ * content: "Get started with Plot:",
164
+ * actions: [{
165
+ * type: ActionType.external,
166
+ * title: "Get Started",
167
+ * url: "https://plot.day/docs"
168
+ * }]
165
169
  * }]
166
170
  * });
167
171
  * }
@@ -330,8 +334,9 @@ export abstract class Plot extends ITool {
330
334
  * remain unchanged. This enables partial updates without needing to fetch and resend
331
335
  * the entire thread object.
332
336
  *
333
- * For tags, provide a Record<number, boolean> where true adds a tag and false removes it.
334
- * Tags not included in the update remain unchanged.
337
+ * For the twist's own tags, use `twistTags`: a record mapping tag ID to a
338
+ * boolean, where true adds the tag and false removes it. Tags not included
339
+ * in the update remain unchanged.
335
340
  *
336
341
  * Set `focus` to move the thread to a different focus.
337
342
  *
@@ -343,18 +348,18 @@ export abstract class Plot extends ITool {
343
348
  *
344
349
  * @example
345
350
  * ```typescript
346
- * // Mark a task as complete
347
- * await this.plot.updateThread({
348
- * id: "task-123",
349
- * done: new Date()
351
+ * // Archive a thread
352
+ * await this.tools.plot.updateThread({
353
+ * id: threadId,
354
+ * archived: true
350
355
  * });
351
356
  *
352
- * // Add and remove tags
353
- * await this.plot.updateThread({
354
- * id: "thread-789",
355
- * tags: {
356
- * 1: true, // Add tag with ID 1
357
- * 2: false // Remove tag with ID 2
357
+ * // Add and remove the twist's tags
358
+ * await this.tools.plot.updateThread({
359
+ * id: threadId,
360
+ * twistTags: {
361
+ * [Tag.Todo]: true, // Add the to-do tag
362
+ * [Tag.Done]: false // Remove the done tag
358
363
  * }
359
364
  * });
360
365
  * ```
@@ -388,16 +393,16 @@ export abstract class Plot extends ITool {
388
393
  * @example
389
394
  * ```typescript
390
395
  * // Create a note with content
391
- * await this.plot.createNote({
396
+ * await this.tools.plot.createNote({
392
397
  * thread: { id: "thread-123" },
393
- * note: "Discussion notes from the meeting...",
398
+ * content: "Discussion notes from the meeting...",
394
399
  * contentType: "markdown"
395
400
  * });
396
401
  *
397
402
  * // Create a note with actions
398
- * await this.plot.createNote({
403
+ * await this.tools.plot.createNote({
399
404
  * thread: { id: "thread-456" },
400
- * note: "Meeting recording available",
405
+ * content: "Meeting recording available",
401
406
  * actions: [{
402
407
  * type: ActionType.external,
403
408
  * title: "View Recording",
@@ -422,14 +427,14 @@ export abstract class Plot extends ITool {
422
427
  * @example
423
428
  * ```typescript
424
429
  * // Create multiple notes in one batch
425
- * await this.plot.createNotes([
430
+ * await this.tools.plot.createNotes([
426
431
  * {
427
432
  * thread: { id: "thread-123" },
428
- * note: "First message in thread"
433
+ * content: "First message in thread"
429
434
  * },
430
435
  * {
431
436
  * thread: { id: "thread-123" },
432
- * note: "Second message in thread"
437
+ * content: "Second message in thread"
433
438
  * }
434
439
  * ]);
435
440
  * ```
@@ -454,16 +459,16 @@ export abstract class Plot extends ITool {
454
459
  * @example
455
460
  * ```typescript
456
461
  * // Update note content
457
- * await this.plot.updateNote({
462
+ * await this.tools.plot.updateNote({
458
463
  * id: "note-123",
459
- * note: "Updated content with more details"
464
+ * content: "Updated content with more details"
460
465
  * });
461
466
  *
462
467
  * // Add tags to a note
463
- * await this.plot.updateNote({
468
+ * await this.tools.plot.updateNote({
464
469
  * id: "note-456",
465
470
  * twistTags: {
466
- * [Tag.Important]: true
471
+ * [Tag.Todo]: true
467
472
  * }
468
473
  * });
469
474
  * ```
@@ -573,10 +578,10 @@ export abstract class Plot extends ITool {
573
578
  * @example
574
579
  * ```typescript
575
580
  * // Schedule a timed event
576
- * const threadId = await this.plot.createThread({
581
+ * const threadId = await this.tools.plot.createThread({
577
582
  * title: "Team standup"
578
583
  * });
579
- * await this.plot.createSchedule({
584
+ * await this.tools.plot.createSchedule({
580
585
  * threadId,
581
586
  * start: new Date("2025-01-15T10:00:00Z"),
582
587
  * end: new Date("2025-01-15T10:30:00Z"),
package/src/tools/smtp.ts CHANGED
@@ -76,7 +76,7 @@ export type SmtpSendResult = {
76
76
  * @example
77
77
  * ```typescript
78
78
  * class AppleMailConnector extends Connector<AppleMailConnector> {
79
- * build(build: ConnectorBuilder) {
79
+ * build(build: ToolBuilder) {
80
80
  * return {
81
81
  * options: build(Options, {
82
82
  * email: { type: "text", label: "Apple ID Email", default: "" },
@@ -30,18 +30,18 @@ import type { Callback } from "./callbacks";
30
30
  *
31
31
  * @example
32
32
  * ```typescript
33
- * class SyncTool extends Tool {
33
+ * class SyncTool extends Tool<SyncTool> {
34
34
  * async startBatchSync(totalItems: number) {
35
35
  * // Store initial state using built-in set method
36
36
  * await this.set("sync_progress", { processed: 0, total: totalItems });
37
37
  *
38
38
  * // Create callback and queue first batch
39
- * const callback = await this.callback("processBatch", { batchNumber: 1 });
39
+ * const callback = await this.callback(this.processBatch, 1);
40
40
  * // runTask creates NEW execution with fresh ~1000 request limit
41
41
  * await this.runTask(callback);
42
42
  * }
43
43
  *
44
- * async processBatch(args: any, context: { batchNumber: number }) {
44
+ * async processBatch(batchNumber: number) {
45
45
  * // Process one batch of items (sized to stay under request limit)
46
46
  * const progress = await this.get("sync_progress");
47
47
  *
@@ -61,9 +61,7 @@ import type { Callback } from "./callbacks";
61
61
  *
62
62
  * if (progress.processed < progress.total) {
63
63
  * // Queue next batch - creates NEW execution with fresh request limit
64
- * const callback = await this.callback("processBatch", {
65
- * batchNumber: context.batchNumber + 1
66
- * });
64
+ * const callback = await this.callback(this.processBatch, batchNumber + 1);
67
65
  * await this.runTask(callback);
68
66
  * }
69
67
  * }
@@ -72,7 +70,7 @@ import type { Callback } from "./callbacks";
72
70
  * const tomorrow = new Date();
73
71
  * tomorrow.setDate(tomorrow.getDate() + 1);
74
72
  *
75
- * const callback = await this.callback("cleanupOldData");
73
+ * const callback = await this.callback(this.cleanupOldData);
76
74
  * // Schedule for future execution
77
75
  * return await this.runTask(callback, { runAt: tomorrow });
78
76
  * }
@@ -103,7 +101,7 @@ export abstract class Tasks extends ITool {
103
101
  * @example
104
102
  * ```typescript
105
103
  * // Break large loop into batches to stay under request limit
106
- * const callback = await this.callback("syncBatch", { page: 1 });
104
+ * const callback = await this.callback(this.syncBatch, 1);
107
105
  * await this.runTask(callback); // Fresh execution with ~1000 requests
108
106
  * ```
109
107
  */
@@ -61,10 +61,10 @@ export type TwistPermissions = Record<string, Record<string, string[]>>;
61
61
  *
62
62
  * @example
63
63
  * ```typescript
64
- * class TwistBuilderTwist extends Twist {
64
+ * class TwistBuilderTwist extends Twist<TwistBuilderTwist> {
65
65
  * build(build: ToolBuilder) {
66
66
  * return {
67
- * twists: build.get(Twists)
67
+ * twists: build(Twists)
68
68
  * }
69
69
  * }
70
70
  *
@@ -77,14 +77,15 @@ export type TwistPermissions = Record<string, Record<string, string[]>>;
77
77
  */
78
78
  export abstract class Twists extends ITool {
79
79
  /**
80
- * Creates a new twist ID and grants access to people in the current focus.
80
+ * Creates a new twist package ID. Ownership of the ID is claimed lazily
81
+ * on first deploy — no upfront registration happens beyond generating it.
81
82
  *
82
83
  * @returns Promise resolving to the generated twist ID
83
84
  * @throws When twist creation fails
84
85
  *
85
86
  * @example
86
87
  * ```typescript
87
- * const twistId = await twist.create();
88
+ * const twistId = await this.tools.twists.create();
88
89
  * console.log(`Your twist ID: ${twistId}`);
89
90
  * ```
90
91
  */
@@ -103,15 +104,15 @@ export abstract class Twists extends ITool {
103
104
  *
104
105
  * @example
105
106
  * ```typescript
106
- * const source = await twist.generate(`
107
+ * const source = await this.tools.twists.generate(`
107
108
  * # Calendar Sync Twist
108
109
  *
109
- * This twist syncs Google Calendar events to Plot activities.
110
+ * This twist syncs Google Calendar events to Plot threads.
110
111
  *
111
112
  * ## Features
112
113
  * - Authenticate with Google
113
114
  * - Sync calendar events
114
- * - Create activities from events
115
+ * - Create threads from events
115
116
  * `);
116
117
  *
117
118
  * // source.dependencies: { "@plotday/twister": "workspace:^", ... }
@@ -143,7 +144,7 @@ export abstract class Twists extends ITool {
143
144
  * @example
144
145
  * ```typescript
145
146
  * // Deploy with a module
146
- * const result = await twist.deploy({
147
+ * const result = await this.tools.twists.deploy({
147
148
  * twistId: 'abc-123-...',
148
149
  * module: 'export default class MyTwist extends Twist {...}',
149
150
  * environment: 'personal',
@@ -153,8 +154,8 @@ export abstract class Twists extends ITool {
153
154
  * console.log(`Deployed version ${result.version}`);
154
155
  *
155
156
  * // Deploy with source
156
- * const source = await twist.generate(spec);
157
- * const result = await twist.deploy({
157
+ * const source = await this.tools.twists.generate(spec);
158
+ * const result = await this.tools.twists.deploy({
158
159
  * twistId: 'abc-123-...',
159
160
  * source,
160
161
  * environment: 'personal',
@@ -162,7 +163,7 @@ export abstract class Twists extends ITool {
162
163
  * });
163
164
  *
164
165
  * // Validate with dryRun
165
- * const result = await twist.deploy({
166
+ * const result = await this.tools.twists.deploy({
166
167
  * twistId: 'abc-123-...',
167
168
  * source,
168
169
  * dryRun: true,
@@ -209,11 +210,11 @@ export abstract class Twists extends ITool {
209
210
  * @example
210
211
  * ```typescript
211
212
  * // Create twist and callback
212
- * const twistId = await this.twist.create();
213
- * const callback = await this.callback.create("onLogs");
213
+ * const twistId = await this.tools.twists.create();
214
+ * const callback = await this.callback(this.onLogs);
214
215
  *
215
216
  * // Subscribe to logs
216
- * await this.twist.watchLogs(twistId, callback);
217
+ * await this.tools.twists.watchLogs(twistId, callback);
217
218
  *
218
219
  * // Implement handler
219
220
  * async onLogs(logs: Log[]) {
package/src/twist.ts CHANGED
@@ -225,8 +225,8 @@ export abstract class Twist<TSelf> {
225
225
  * await this.set("handler_token", token);
226
226
  *
227
227
  * // Later, execute the callback
228
- * const token = await this.get<string>("handler_token");
229
- * await this.run(token, args);
228
+ * const token = await this.get<Callback>("handler_token");
229
+ * await this.run(token);
230
230
  * ```
231
231
  *
232
232
  * @template T - The type of value being stored (must be Serializable)
@@ -1,116 +0,0 @@
1
- # Multi-User Priority Auth
2
-
3
- Twists and connectors operating in shared priorities must handle authentication for multiple users. This guide covers the patterns for per-user auth and private auth activities.
4
-
5
- ## Auth Models
6
-
7
- | Model | Use case | Example |
8
- | --------------------- | ---------------------------------------------- | ------------------------ |
9
- | No auth | Twist doesn't need external credentials | Text-only twist |
10
- | Read-only single auth | Installer connects, synced data visible to all | Calendar sync (read) |
11
- | Two-way per-user auth | Write-backs use the acting user's credentials | Comments, RSVP responses |
12
-
13
- ## Private Auth Activities
14
-
15
- When a twist creates an auth activity in `activate()`, make it `private: true` and add `mentions` targeting `context.actor`. This ensures only the installing user sees the auth prompt — other priority members won't be spammed with irrelevant auth requests.
16
-
17
- ```typescript
18
- async activate(_priority: Pick<Priority, "id">, context?: { actor: Actor }) {
19
- const authLink = await this.tools.myTool.requestAuth(this.onAuthComplete, "provider");
20
-
21
- await this.tools.plot.createActivity({
22
- type: ActivityType.Action,
23
- title: "Connect your account",
24
- private: true,
25
- notes: [{
26
- content: "Connect to get started.",
27
- links: [authLink],
28
- ...(context?.actor ? { mentions: [{ id: context.actor.id }] } : {}),
29
- }],
30
- });
31
- }
32
- ```
33
-
34
- Key points:
35
-
36
- - `private: true` — only the author and mentioned users can see the activity
37
- - `context?.actor` — the user who installed the twist (available from the SDK)
38
- - Always guard with `?.` since `context` is optional for backward compatibility
39
-
40
- ## Per-User Auth for Write-Backs
41
-
42
- When a twist needs to write back to an external system (e.g., posting a comment on a Linear issue), it should use the acting user's credentials when available.
43
-
44
- ### Pattern: Try Actor First, Fall Back to Installer
45
-
46
- The simplest approach passes the actor's ID as the `authToken` parameter. The tool's `getClient()` method will look it up via `integrations.get(provider, actorId)`:
47
-
48
- ```typescript
49
- private async onNoteCreated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {
50
- const provider = thread.meta?.provider;
51
- const tool = this.getProviderTool(provider);
52
-
53
- // Try actor's credentials first, then installer's
54
- const actorId = note.author.id as string;
55
- const installerAuthToken = await this.getAuthToken(provider);
56
-
57
- const authTokensToTry = [
58
- actorId,
59
- ...(installerAuthToken && installerAuthToken !== actorId
60
- ? [installerAuthToken]
61
- : []),
62
- ];
63
-
64
- for (const authToken of authTokensToTry) {
65
- try {
66
- // addIssueComment returns { key, externalContent } — returning it
67
- // directly lets the runtime set note.key AND record the sync
68
- // baseline so future re-syncs preserve Plot's markdown.
69
- return await tool.addIssueComment(authToken, thread.meta, note.content, note.id);
70
- } catch {
71
- continue; // Try next token
72
- }
73
- }
74
- }
75
- ```
76
-
77
- ### When Actor ID Is Not Available
78
-
79
- For callbacks like `onThreadUpdated` where the acting user's ID is not included in the callback signature, continue using the installer's stored auth token. This is acceptable because:
80
-
81
- - Activity field updates (title, assignee, done) are less user-specific
82
- - The change itself is the same regardless of who made it
83
- - Per-user auth is most valuable for user-attributed actions like comments
84
-
85
- ### How Tools Resolve Auth Tokens
86
-
87
- Tools with per-user auth support resolve tokens in their `getClient()` method:
88
-
89
- 1. Try `integrations.get(provider, authToken as ActorId)` — looks up per-actor credentials
90
- 2. Fall back to legacy token lookup if the actor has no credentials
91
- 3. Throw if neither works (caller catches and tries the next token)
92
-
93
- ## On-Demand Auth Requests
94
-
95
- When a user without credentials performs a write-back action, you can optionally create a private auth-request activity prompting them to connect:
96
-
97
- ```typescript
98
- // Create auth request for a specific actor
99
- const authLink = await tool.requestAuth(this.onActorAuth, actorId);
100
-
101
- await this.tools.plot.createActivity({
102
- type: ActivityType.Action,
103
- title: "Connect to sync your changes",
104
- private: true,
105
- source: `auth:${actorId}`, // Dedup: one auth request per user
106
- notes: [
107
- {
108
- content: "Connect your account so your changes appear under your name.",
109
- links: [authLink],
110
- mentions: [{ id: actorId as ActorId }],
111
- },
112
- ],
113
- });
114
- ```
115
-
116
- This is optional — the simpler approach is to silently fall back to the installer's credentials.