@plotday/twister 0.57.0 → 0.59.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/README.md +53 -44
- package/bin/commands/create.js +9 -14
- package/bin/commands/create.js.map +1 -1
- package/bin/commands/deploy.js +2 -0
- package/bin/commands/deploy.js.map +1 -1
- package/bin/commands/generate.js +8 -5
- package/bin/commands/generate.js.map +1 -1
- package/bin/index.js +2 -2
- package/bin/index.js.map +1 -1
- package/bin/templates/AGENTS.template.md +110 -94
- package/bin/templates/README.template.md +36 -33
- package/cli/templates/AGENTS.template.md +110 -94
- package/cli/templates/README.template.md +36 -33
- package/dist/connector.d.ts +58 -17
- package/dist/connector.d.ts.map +1 -1
- package/dist/connector.js +51 -13
- 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 +90 -60
- package/dist/docs/classes/index.FileNotFoundError.html +2 -2
- package/dist/docs/classes/index.Files.html +4 -4
- package/dist/docs/classes/index.Imap.html +10 -10
- package/dist/docs/classes/index.Options.html +2 -2
- package/dist/docs/classes/index.Smtp.html +6 -6
- package/dist/docs/classes/tool.ITool.html +2 -2
- package/dist/docs/classes/tool.Tool.html +23 -23
- package/dist/docs/classes/tools_ai.AI.html +5 -5
- package/dist/docs/classes/tools_callbacks.Callbacks.html +8 -8
- package/dist/docs/classes/tools_integrations.Integrations.html +15 -15
- package/dist/docs/classes/tools_network.Network.html +9 -9
- package/dist/docs/classes/tools_plot.Plot.html +34 -33
- package/dist/docs/classes/tools_store.Store.html +8 -8
- package/dist/docs/classes/tools_tasks.Tasks.html +6 -6
- package/dist/docs/classes/tools_twists.Twists.html +12 -11
- package/dist/docs/classes/twist.Twist.html +28 -28
- package/dist/docs/documents/Building_Connectors.html +42 -28
- package/dist/docs/documents/Built-in_Tools.html +170 -67
- package/dist/docs/documents/CLI_Reference.html +68 -47
- package/dist/docs/documents/Core_Concepts.html +52 -81
- package/dist/docs/documents/Getting_Started.html +28 -31
- package/dist/docs/documents/MULTI_USER_AUTH.html +45 -0
- package/dist/docs/documents/Runtime_Environment.html +13 -12
- package/dist/docs/documents/SYNC_STRATEGIES.html +373 -0
- package/dist/docs/enums/plot.ActionType.html +9 -9
- package/dist/docs/enums/plot.ActorType.html +4 -4
- package/dist/docs/enums/plot.ConferencingProvider.html +6 -6
- package/dist/docs/enums/plot.ThemeColor.html +9 -9
- package/dist/docs/enums/tag.Tag.html +3 -3
- package/dist/docs/enums/tools_ai.AIModel.html +3 -3
- package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
- package/dist/docs/enums/tools_plot.ContactAccess.html +2 -2
- package/dist/docs/enums/tools_plot.FocusAccess.html +3 -3
- package/dist/docs/enums/tools_plot.LinkAccess.html +3 -3
- package/dist/docs/enums/tools_plot.ThreadAccess.html +4 -4
- package/dist/docs/functions/index.Uuid.Generate.html +1 -1
- package/dist/docs/functions/utils_hash.quickHash.html +1 -1
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/index.html +7 -8
- package/dist/docs/interfaces/tools_ai.AIRequest.html +13 -13
- package/dist/docs/interfaces/tools_ai.AIResponse.html +9 -9
- package/dist/docs/interfaces/tools_ai.FilePart.html +5 -5
- package/dist/docs/interfaces/tools_ai.ImagePart.html +4 -4
- package/dist/docs/interfaces/tools_ai.ReasoningPart.html +4 -4
- package/dist/docs/interfaces/tools_ai.RedactedReasoningPart.html +3 -3
- package/dist/docs/interfaces/tools_ai.TextPart.html +3 -3
- package/dist/docs/interfaces/tools_ai.ToolCallPart.html +5 -5
- package/dist/docs/interfaces/tools_ai.ToolExecutionOptions.html +4 -4
- package/dist/docs/interfaces/tools_ai.ToolResultPart.html +5 -5
- package/dist/docs/interfaces/tools_twists.TwistSource.html +3 -3
- package/dist/docs/interfaces/utils_types.ToolShed.html +5 -5
- package/dist/docs/media/AGENTS.md +101 -74
- package/dist/docs/modules.html +1 -1
- package/dist/docs/types/index.BooleanDef.html +2 -2
- package/dist/docs/types/index.CreateLinkDraft.html +9 -9
- package/dist/docs/types/index.ImapAddress.html +3 -3
- package/dist/docs/types/index.ImapConnectOptions.html +6 -6
- package/dist/docs/types/index.ImapFetchOptions.html +4 -4
- package/dist/docs/types/index.ImapFlagOperation.html +1 -1
- package/dist/docs/types/index.ImapMailbox.html +5 -5
- package/dist/docs/types/index.ImapMailboxStatus.html +7 -7
- package/dist/docs/types/index.ImapMessage.html +14 -14
- package/dist/docs/types/index.ImapSearchCriteria.html +9 -9
- package/dist/docs/types/index.ImapSession.html +1 -1
- package/dist/docs/types/index.NewSchedule.html +13 -13
- package/dist/docs/types/index.NewScheduleContact.html +2 -2
- package/dist/docs/types/index.NewScheduleOccurrence.html +1 -1
- package/dist/docs/types/index.NoteWriteBackResult.html +3 -3
- package/dist/docs/types/index.NumberDef.html +2 -2
- package/dist/docs/types/index.OptionDef.html +1 -1
- package/dist/docs/types/index.OptionalScopeGroup.html +6 -6
- package/dist/docs/types/index.OptionsSchema.html +1 -1
- package/dist/docs/types/index.ReactionCapabilities.html +1 -1
- package/dist/docs/types/index.ResolvedOptions.html +1 -1
- package/dist/docs/types/index.ResolvedRecipient.html +5 -5
- package/dist/docs/types/index.Schedule.html +12 -12
- package/dist/docs/types/index.ScheduleContact.html +2 -2
- package/dist/docs/types/index.ScheduleContactRole.html +1 -1
- package/dist/docs/types/index.ScheduleContactStatus.html +1 -1
- package/dist/docs/types/index.ScheduleOccurrence.html +6 -6
- package/dist/docs/types/index.ScheduleOccurrenceUpdate.html +1 -1
- package/dist/docs/types/index.ScopeConfig.html +3 -3
- package/dist/docs/types/index.SelectDef.html +2 -2
- package/dist/docs/types/index.Serializable.html +1 -1
- package/dist/docs/types/index.SmtpAddress.html +3 -3
- package/dist/docs/types/index.SmtpConnectOptions.html +7 -7
- package/dist/docs/types/index.SmtpMessage.html +12 -12
- package/dist/docs/types/index.SmtpSendResult.html +4 -4
- package/dist/docs/types/index.SmtpSession.html +1 -1
- package/dist/docs/types/index.TextDef.html +2 -2
- package/dist/docs/types/index.Uuid.html +1 -1
- package/dist/docs/types/plot.Action.html +1 -1
- package/dist/docs/types/plot.Actor.html +5 -5
- package/dist/docs/types/plot.ActorId.html +4 -4
- package/dist/docs/types/plot.Contact.html +4 -4
- package/dist/docs/types/plot.ContentType.html +1 -1
- package/dist/docs/types/plot.Focus.html +8 -8
- package/dist/docs/types/plot.FocusUpdate.html +1 -1
- package/dist/docs/types/plot.Link.html +17 -17
- 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.NewFocus.html +1 -1
- package/dist/docs/types/plot.NewLink.html +5 -2
- package/dist/docs/types/plot.NewLinkWithNotes.html +1 -1
- package/dist/docs/types/plot.NewNote.html +1 -1
- package/dist/docs/types/plot.NewReactions.html +1 -1
- package/dist/docs/types/plot.NewTags.html +1 -1
- package/dist/docs/types/plot.NewThread.html +1 -1
- package/dist/docs/types/plot.NewThreadWithNotes.html +1 -1
- package/dist/docs/types/plot.Note.html +1 -1
- package/dist/docs/types/plot.NoteUpdate.html +1 -1
- package/dist/docs/types/plot.PlanOperation.html +1 -1
- package/dist/docs/types/plot.Reaction.html +3 -3
- package/dist/docs/types/plot.Reactions.html +1 -1
- package/dist/docs/types/plot.Tags.html +1 -1
- package/dist/docs/types/plot.Thread.html +1 -1
- package/dist/docs/types/plot.ThreadAccessLevel.html +1 -1
- package/dist/docs/types/plot.ThreadCommon.html +6 -6
- package/dist/docs/types/plot.ThreadFilter.html +2 -2
- package/dist/docs/types/plot.ThreadMeta.html +1 -1
- package/dist/docs/types/plot.ThreadType.html +1 -1
- package/dist/docs/types/plot.ThreadUpdate.html +1 -1
- package/dist/docs/types/plot.ThreadWithNotes.html +1 -1
- package/dist/docs/types/tools_ai.AIAssistantMessage.html +2 -2
- package/dist/docs/types/tools_ai.AICapabilities.html +4 -4
- package/dist/docs/types/tools_ai.AIMessage.html +1 -1
- package/dist/docs/types/tools_ai.AIOptions.html +2 -2
- package/dist/docs/types/tools_ai.AISource.html +1 -1
- package/dist/docs/types/tools_ai.AISystemMessage.html +2 -2
- package/dist/docs/types/tools_ai.AITool.html +1 -1
- package/dist/docs/types/tools_ai.AIToolMessage.html +2 -2
- package/dist/docs/types/tools_ai.AIToolSet.html +1 -1
- package/dist/docs/types/tools_ai.AIUsage.html +5 -5
- package/dist/docs/types/tools_ai.AIUserMessage.html +2 -2
- package/dist/docs/types/tools_ai.DataContent.html +1 -1
- package/dist/docs/types/tools_ai.ModelPreferences.html +5 -5
- package/dist/docs/types/tools_callbacks.Callback.html +2 -2
- package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
- package/dist/docs/types/tools_integrations.ArchiveNotesFilter.html +2 -2
- package/dist/docs/types/tools_integrations.AuthToken.html +6 -5
- package/dist/docs/types/tools_integrations.Authorization.html +4 -4
- package/dist/docs/types/tools_integrations.Channel.html +6 -6
- package/dist/docs/types/tools_integrations.ComposeConfig.html +4 -4
- package/dist/docs/types/tools_integrations.ContactRoleConfig.html +5 -5
- package/dist/docs/types/tools_integrations.LinkTypeConfig.html +21 -21
- package/dist/docs/types/tools_integrations.NewCustomEmoji.html +8 -8
- package/dist/docs/types/tools_integrations.StatusIcon.html +1 -1
- package/dist/docs/types/tools_integrations.SyncContext.html +4 -4
- package/dist/docs/types/tools_network.WebhookRequest.html +6 -6
- package/dist/docs/types/tools_plot.LinkFilter.html +5 -5
- package/dist/docs/types/tools_plot.LinkSearchResult.html +1 -1
- package/dist/docs/types/tools_plot.NoteIntentHandler.html +4 -4
- package/dist/docs/types/tools_plot.NoteSearchResult.html +1 -1
- package/dist/docs/types/tools_plot.SearchOptions.html +4 -4
- package/dist/docs/types/tools_plot.SearchResult.html +1 -1
- package/dist/docs/types/tools_twists.Log.html +2 -2
- package/dist/docs/types/tools_twists.TwistPermissions.html +1 -1
- package/dist/docs/types/utils_types.BuiltInTools.html +2 -2
- package/dist/docs/types/utils_types.ExtractBuildReturn.html +1 -1
- package/dist/docs/types/utils_types.InferOptions.html +1 -1
- package/dist/docs/types/utils_types.InferTools.html +1 -1
- package/dist/docs/types/utils_types.JSONValue.html +1 -1
- package/dist/docs/types/utils_types.PromiseValues.html +1 -1
- package/dist/docs/types/utils_types.ToolBuilder.html +1 -1
- package/dist/docs/variables/tools_plot.SEARCH_DEFAULT_LIMIT.html +1 -1
- package/dist/docs/variables/tools_plot.SEARCH_MAX_LIMIT.html +1 -1
- package/dist/facets.d.ts +30 -0
- package/dist/facets.d.ts.map +1 -0
- package/dist/facets.js +16 -0
- package/dist/facets.js.map +1 -0
- 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/facets.d.ts +9 -0
- package/dist/llm-docs/facets.d.ts.map +1 -0
- package/dist/llm-docs/facets.js +8 -0
- package/dist/llm-docs/facets.js.map +1 -0
- package/dist/llm-docs/index.d.ts.map +1 -1
- package/dist/llm-docs/index.js +2 -0
- package/dist/llm-docs/index.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/tool.d.ts +1 -1
- package/dist/llm-docs/tool.d.ts.map +1 -1
- package/dist/llm-docs/tool.js +1 -1
- package/dist/llm-docs/tool.js.map +1 -1
- package/dist/llm-docs/tools/ai.d.ts +1 -1
- package/dist/llm-docs/tools/ai.d.ts.map +1 -1
- package/dist/llm-docs/tools/ai.js +1 -1
- package/dist/llm-docs/tools/ai.js.map +1 -1
- package/dist/llm-docs/tools/callbacks.d.ts +1 -1
- package/dist/llm-docs/tools/callbacks.d.ts.map +1 -1
- package/dist/llm-docs/tools/callbacks.js +1 -1
- package/dist/llm-docs/tools/callbacks.js.map +1 -1
- package/dist/llm-docs/tools/files.d.ts +1 -1
- package/dist/llm-docs/tools/files.d.ts.map +1 -1
- package/dist/llm-docs/tools/files.js +1 -1
- package/dist/llm-docs/tools/files.js.map +1 -1
- package/dist/llm-docs/tools/imap.d.ts +1 -1
- package/dist/llm-docs/tools/imap.d.ts.map +1 -1
- package/dist/llm-docs/tools/imap.js +1 -1
- package/dist/llm-docs/tools/imap.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/network.d.ts +1 -1
- package/dist/llm-docs/tools/network.d.ts.map +1 -1
- package/dist/llm-docs/tools/network.js +1 -1
- package/dist/llm-docs/tools/network.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/smtp.d.ts +1 -1
- package/dist/llm-docs/tools/smtp.d.ts.map +1 -1
- package/dist/llm-docs/tools/smtp.js +1 -1
- package/dist/llm-docs/tools/smtp.js.map +1 -1
- package/dist/llm-docs/tools/tasks.d.ts +1 -1
- package/dist/llm-docs/tools/tasks.d.ts.map +1 -1
- package/dist/llm-docs/tools/tasks.js +1 -1
- package/dist/llm-docs/tools/tasks.js.map +1 -1
- package/dist/llm-docs/tools/twists.d.ts +1 -1
- package/dist/llm-docs/tools/twists.d.ts.map +1 -1
- package/dist/llm-docs/tools/twists.js +1 -1
- package/dist/llm-docs/tools/twists.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 +15 -8
- package/dist/plot.d.ts.map +1 -1
- package/dist/plot.js.map +1 -1
- package/dist/tool.d.ts +4 -4
- package/dist/tool.js +4 -4
- package/dist/tools/ai.d.ts +12 -13
- package/dist/tools/ai.d.ts.map +1 -1
- package/dist/tools/ai.js +8 -9
- package/dist/tools/ai.js.map +1 -1
- package/dist/tools/callbacks.d.ts +1 -1
- package/dist/tools/files.d.ts +2 -2
- package/dist/tools/imap.d.ts +1 -1
- package/dist/tools/imap.js +1 -1
- package/dist/tools/integrations.d.ts +2 -1
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/network.d.ts +5 -5
- package/dist/tools/plot.d.ts +42 -37
- package/dist/tools/plot.d.ts.map +1 -1
- package/dist/tools/plot.js +16 -12
- package/dist/tools/plot.js.map +1 -1
- package/dist/tools/smtp.d.ts +1 -1
- package/dist/tools/smtp.js +1 -1
- package/dist/tools/tasks.d.ts +6 -8
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +5 -7
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/twists.d.ts +15 -14
- package/dist/tools/twists.d.ts.map +1 -1
- package/dist/tools/twists.js +2 -2
- package/dist/tools/twists.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 -2
- package/dist/twist.js +2 -2
- package/package.json +6 -1
- package/src/connector.ts +56 -16
- package/src/facets.ts +40 -0
- package/src/llm-docs/connector.ts +1 -1
- package/src/llm-docs/facets.ts +8 -0
- package/src/llm-docs/index.ts +2 -0
- package/src/llm-docs/plot.ts +1 -1
- package/src/llm-docs/tool.ts +1 -1
- package/src/llm-docs/tools/ai.ts +1 -1
- package/src/llm-docs/tools/callbacks.ts +1 -1
- package/src/llm-docs/tools/files.ts +1 -1
- package/src/llm-docs/tools/imap.ts +1 -1
- package/src/llm-docs/tools/integrations.ts +1 -1
- package/src/llm-docs/tools/network.ts +1 -1
- package/src/llm-docs/tools/plot.ts +1 -1
- package/src/llm-docs/tools/smtp.ts +1 -1
- package/src/llm-docs/tools/tasks.ts +1 -1
- package/src/llm-docs/tools/twists.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 +15 -8
- package/src/tool.ts +4 -4
- package/src/tools/ai.ts +12 -13
- package/src/tools/callbacks.ts +1 -1
- package/src/tools/files.ts +2 -2
- package/src/tools/imap.ts +1 -1
- package/src/tools/integrations.ts +2 -1
- package/src/tools/network.ts +5 -5
- package/src/tools/plot.ts +42 -37
- package/src/tools/smtp.ts +1 -1
- package/src/tools/tasks.ts +6 -8
- package/src/tools/twists.ts +15 -14
- package/src/twist.ts +2 -2
- package/dist/docs/media/MULTI_USER_AUTH.md +0 -116
- 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
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
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
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
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
|
|
334
|
-
*
|
|
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
|
-
* //
|
|
347
|
-
* await this.plot.updateThread({
|
|
348
|
-
* id:
|
|
349
|
-
*
|
|
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:
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
433
|
+
* content: "First message in thread"
|
|
429
434
|
* },
|
|
430
435
|
* {
|
|
431
436
|
* thread: { id: "thread-123" },
|
|
432
|
-
*
|
|
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
|
-
*
|
|
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.
|
|
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:
|
|
79
|
+
* build(build: ToolBuilder) {
|
|
80
80
|
* return {
|
|
81
81
|
* options: build(Options, {
|
|
82
82
|
* email: { type: "text", label: "Apple ID Email", default: "" },
|
package/src/tools/tasks.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
104
|
+
* const callback = await this.callback(this.syncBatch, 1);
|
|
107
105
|
* await this.runTask(callback); // Fresh execution with ~1000 requests
|
|
108
106
|
* ```
|
|
109
107
|
*/
|
package/src/tools/twists.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
107
|
+
* const source = await this.tools.twists.generate(`
|
|
107
108
|
* # Calendar Sync Twist
|
|
108
109
|
*
|
|
109
|
-
* This twist syncs Google Calendar events to Plot
|
|
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
|
|
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
|
|
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
|
|
157
|
-
* const result = await
|
|
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
|
|
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.
|
|
213
|
-
* const callback = await this.callback.
|
|
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.
|
|
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<
|
|
229
|
-
* await this.run(token
|
|
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.
|