@plotday/twister 0.51.0 → 0.53.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 (145) hide show
  1. package/bin/commands/deploy.js +4 -0
  2. package/bin/commands/deploy.js.map +1 -1
  3. package/bin/templates/AGENTS.template.md +6 -10
  4. package/cli/templates/AGENTS.template.md +6 -10
  5. package/dist/connector.d.ts +164 -10
  6. package/dist/connector.d.ts.map +1 -1
  7. package/dist/connector.js +78 -4
  8. package/dist/connector.js.map +1 -1
  9. package/dist/docs/assets/hierarchy.js +1 -1
  10. package/dist/docs/assets/navigation.js +1 -1
  11. package/dist/docs/assets/search.js +1 -1
  12. package/dist/docs/classes/index.Connector.html +74 -26
  13. package/dist/docs/classes/index.FileNotFoundError.html +2 -0
  14. package/dist/docs/classes/index.Files.html +16 -0
  15. package/dist/docs/classes/index.Imap.html +1 -1
  16. package/dist/docs/classes/index.Options.html +1 -1
  17. package/dist/docs/classes/index.Smtp.html +1 -1
  18. package/dist/docs/classes/tool.ITool.html +1 -1
  19. package/dist/docs/classes/tools_ai.AI.html +1 -1
  20. package/dist/docs/classes/tools_callbacks.Callbacks.html +1 -1
  21. package/dist/docs/classes/tools_integrations.Integrations.html +17 -23
  22. package/dist/docs/classes/tools_network.Network.html +1 -1
  23. package/dist/docs/classes/tools_plot.Plot.html +1 -1
  24. package/dist/docs/classes/tools_store.Store.html +1 -1
  25. package/dist/docs/classes/tools_tasks.Tasks.html +1 -1
  26. package/dist/docs/classes/tools_twists.Twists.html +1 -1
  27. package/dist/docs/documents/Building_Connectors.html +1 -1
  28. package/dist/docs/enums/plot.ActionType.html +10 -8
  29. package/dist/docs/enums/plot.ActorType.html +4 -4
  30. package/dist/docs/enums/plot.ConferencingProvider.html +6 -6
  31. package/dist/docs/enums/plot.ThemeColor.html +9 -9
  32. package/dist/docs/enums/tag.Tag.html +16 -46
  33. package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
  34. package/dist/docs/hierarchy.html +1 -1
  35. package/dist/docs/media/AGENTS.md +22 -14
  36. package/dist/docs/modules/index.html +1 -1
  37. package/dist/docs/modules/plot.html +1 -1
  38. package/dist/docs/modules/tools_integrations.html +1 -1
  39. package/dist/docs/types/index.CreateLinkDraft.html +30 -7
  40. package/dist/docs/types/index.NoteWriteBackResult.html +3 -3
  41. package/dist/docs/types/index.ReactionCapabilities.html +17 -0
  42. package/dist/docs/types/index.ResolvedRecipient.html +13 -0
  43. package/dist/docs/types/plot.Action.html +9 -2
  44. package/dist/docs/types/plot.Actor.html +5 -5
  45. package/dist/docs/types/plot.ActorId.html +1 -1
  46. package/dist/docs/types/plot.Contact.html +4 -4
  47. package/dist/docs/types/plot.ContentType.html +1 -1
  48. package/dist/docs/types/plot.Link.html +16 -16
  49. package/dist/docs/types/plot.LinkUpdate.html +1 -1
  50. package/dist/docs/types/plot.NewActor.html +1 -1
  51. package/dist/docs/types/plot.NewContact.html +1 -1
  52. package/dist/docs/types/plot.NewLink.html +1 -1
  53. package/dist/docs/types/plot.NewLinkWithNotes.html +1 -1
  54. package/dist/docs/types/plot.NewNote.html +4 -2
  55. package/dist/docs/types/plot.NewPriority.html +1 -1
  56. package/dist/docs/types/plot.NewReactions.html +4 -0
  57. package/dist/docs/types/plot.NewTags.html +1 -1
  58. package/dist/docs/types/plot.NewThread.html +4 -2
  59. package/dist/docs/types/plot.NewThreadWithNotes.html +1 -1
  60. package/dist/docs/types/plot.Note.html +1 -1
  61. package/dist/docs/types/plot.NoteUpdate.html +4 -2
  62. package/dist/docs/types/plot.PlanOperation.html +1 -1
  63. package/dist/docs/types/plot.Priority.html +6 -6
  64. package/dist/docs/types/plot.PriorityUpdate.html +1 -1
  65. package/dist/docs/types/plot.Reaction.html +13 -0
  66. package/dist/docs/types/plot.Reactions.html +3 -0
  67. package/dist/docs/types/plot.Tags.html +1 -1
  68. package/dist/docs/types/plot.Thread.html +1 -1
  69. package/dist/docs/types/plot.ThreadAccessLevel.html +1 -1
  70. package/dist/docs/types/plot.ThreadCommon.html +9 -5
  71. package/dist/docs/types/plot.ThreadFilter.html +2 -2
  72. package/dist/docs/types/plot.ThreadMeta.html +1 -1
  73. package/dist/docs/types/plot.ThreadType.html +1 -1
  74. package/dist/docs/types/plot.ThreadUpdate.html +1 -1
  75. package/dist/docs/types/plot.ThreadWithNotes.html +1 -1
  76. package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
  77. package/dist/docs/types/tools_integrations.AuthToken.html +4 -4
  78. package/dist/docs/types/tools_integrations.Authorization.html +4 -4
  79. package/dist/docs/types/tools_integrations.Channel.html +5 -5
  80. package/dist/docs/types/tools_integrations.ComposeConfig.html +35 -0
  81. package/dist/docs/types/tools_integrations.ContactRoleConfig.html +14 -0
  82. package/dist/docs/types/tools_integrations.LinkTypeConfig.html +69 -19
  83. package/dist/docs/types/tools_integrations.SyncContext.html +3 -3
  84. package/dist/llm-docs/connector.d.ts +1 -1
  85. package/dist/llm-docs/connector.d.ts.map +1 -1
  86. package/dist/llm-docs/connector.js +1 -1
  87. package/dist/llm-docs/connector.js.map +1 -1
  88. package/dist/llm-docs/index.d.ts.map +1 -1
  89. package/dist/llm-docs/index.js +2 -0
  90. package/dist/llm-docs/index.js.map +1 -1
  91. package/dist/llm-docs/plot.d.ts +1 -1
  92. package/dist/llm-docs/plot.d.ts.map +1 -1
  93. package/dist/llm-docs/plot.js +1 -1
  94. package/dist/llm-docs/plot.js.map +1 -1
  95. package/dist/llm-docs/tag.d.ts +1 -1
  96. package/dist/llm-docs/tag.d.ts.map +1 -1
  97. package/dist/llm-docs/tag.js +1 -1
  98. package/dist/llm-docs/tag.js.map +1 -1
  99. package/dist/llm-docs/tools/files.d.ts +9 -0
  100. package/dist/llm-docs/tools/files.d.ts.map +1 -0
  101. package/dist/llm-docs/tools/files.js +8 -0
  102. package/dist/llm-docs/tools/files.js.map +1 -0
  103. package/dist/llm-docs/tools/integrations.d.ts +1 -1
  104. package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
  105. package/dist/llm-docs/tools/integrations.js +1 -1
  106. package/dist/llm-docs/tools/integrations.js.map +1 -1
  107. package/dist/llm-docs/twist-guide-template.d.ts +1 -1
  108. package/dist/llm-docs/twist-guide-template.d.ts.map +1 -1
  109. package/dist/llm-docs/twist-guide-template.js +1 -1
  110. package/dist/llm-docs/twist-guide-template.js.map +1 -1
  111. package/dist/plot.d.ts +85 -4
  112. package/dist/plot.d.ts.map +1 -1
  113. package/dist/plot.js +2 -0
  114. package/dist/plot.js.map +1 -1
  115. package/dist/tag.d.ts +17 -43
  116. package/dist/tag.d.ts.map +1 -1
  117. package/dist/tag.js +17 -46
  118. package/dist/tag.js.map +1 -1
  119. package/dist/tools/files.d.ts +33 -0
  120. package/dist/tools/files.d.ts.map +1 -0
  121. package/dist/tools/files.js +22 -0
  122. package/dist/tools/files.js.map +1 -0
  123. package/dist/tools/index.d.ts +1 -0
  124. package/dist/tools/index.d.ts.map +1 -1
  125. package/dist/tools/index.js +1 -0
  126. package/dist/tools/index.js.map +1 -1
  127. package/dist/tools/integrations.d.ts +152 -32
  128. package/dist/tools/integrations.d.ts.map +1 -1
  129. package/dist/tools/integrations.js.map +1 -1
  130. package/dist/twist-guide.d.ts +1 -1
  131. package/dist/twist-guide.d.ts.map +1 -1
  132. package/package.json +6 -1
  133. package/src/connector.ts +167 -10
  134. package/src/llm-docs/connector.ts +1 -1
  135. package/src/llm-docs/index.ts +2 -0
  136. package/src/llm-docs/plot.ts +1 -1
  137. package/src/llm-docs/tag.ts +1 -1
  138. package/src/llm-docs/tools/files.ts +8 -0
  139. package/src/llm-docs/tools/integrations.ts +1 -1
  140. package/src/llm-docs/twist-guide-template.ts +1 -1
  141. package/src/plot.ts +94 -4
  142. package/src/tag.ts +17 -48
  143. package/src/tools/files.ts +37 -0
  144. package/src/tools/index.ts +1 -0
  145. package/src/tools/integrations.ts +153 -43
@@ -4,9 +4,7 @@ import {
4
4
  type NewContact,
5
5
  type NewLinkWithNotes,
6
6
  ITool,
7
- Serializable,
8
7
  } from "..";
9
- import { Tag } from "../tag";
10
8
  import type { JSONValue } from "../utils/types";
11
9
  import type { Uuid } from "../utils/uuid";
12
10
 
@@ -34,6 +32,13 @@ export type LinkTypeConfig = {
34
32
  type: string;
35
33
  /** Human-readable label (e.g., "Issue", "Pull Request") */
36
34
  label: string;
35
+ /**
36
+ * Connector's word for a note on a linked item of this type — used by the
37
+ * Flutter app to adapt note/composer copy ("Add a comment" on Linear,
38
+ * "Add a message" on Slack, "Add a reply" on Gmail). Defaults to "note"
39
+ * when omitted. Use the singular noun in title case (e.g. "Comment").
40
+ */
41
+ noteLabel?: string;
37
42
  /** URL to an icon for this link type (light mode). Prefer Iconify `logos/*` URLs. */
38
43
  logo?: string;
39
44
  /** URL to an icon for dark mode. Use when the default logo is invisible on dark backgrounds (e.g., Iconify `simple-icons/*` with `?color=`). */
@@ -46,30 +51,155 @@ export type LinkTypeConfig = {
46
51
  status: string;
47
52
  /** Human-readable label (e.g., "Open", "Done") */
48
53
  label: string;
49
- /** Tag to propagate to thread when this status is active (e.g., Tag.Done) */
50
- tag?: Tag;
51
54
  /** Whether this status represents completion (done, closed, merged, cancelled, etc.) */
52
55
  done?: boolean;
53
56
  /**
54
- * Whether this status represents the connector's "to-do" / active state.
55
- * When a user adds a thread to Plot's agenda, done-status links flip to
56
- * the status marked `todo: true` (e.g., Gmail's "starred", Linear's
57
- * "todo") so the link widget and thread tags reflect the active state.
58
- * At most one status per type should set this.
57
+ * Mark the thread `active=true` in Plot when a link enters this status.
58
+ * Use for messaging-style flags where the user has indicated they want
59
+ * to act on the thread now Gmail's "starred", Slack's "later", etc.
60
+ * The Plot user can later un-flag the thread without breaking the
61
+ * connector relationship.
59
62
  */
60
- todo?: boolean;
63
+ active?: boolean;
64
+ /**
65
+ * Mark the thread `task=true` in Plot when a link enters this status.
66
+ * Use for project-tracker assignments — Linear / Todoist / Jira / etc.
67
+ * `task` puts the thread on the user's task list without flooding their
68
+ * inbox under `active`: the user explicitly flips it to `active` when
69
+ * they decide to start.
70
+ */
71
+ task?: boolean;
72
+ /**
73
+ * Mark the thread `to_read=true` in Plot when a link enters this status.
74
+ * Use for connectors that explicitly track read-later state (Pocket
75
+ * archives, Slack "remind me", etc).
76
+ */
77
+ toRead?: boolean;
61
78
  /**
62
- * Default status applied when Plot asks the connector to create a new
63
- * item of this type via `Connector.onCreateLink`. Declaring at least one
64
- * status with `createDefault: true` is how a link type opts in to
65
- * Plot-initiated creation. At most one status per type should set this.
79
+ * @deprecated Use `active` (messaging) or `task` (project tracker) instead.
80
+ * Treated as `task: true` for backward compatibility.
81
+ *
82
+ * Original meaning: whether this status represents the connector's
83
+ * "to-do" / active state. When a user adds a thread to Plot's agenda,
84
+ * done-status links flip to the status marked `todo: true` (e.g.,
85
+ * Gmail's "starred", Linear's "todo").
66
86
  */
67
- createDefault?: boolean;
87
+ todo?: boolean;
68
88
  }>;
69
89
  /** Whether this link type supports displaying and changing the assignee */
70
90
  supportsAssignee?: boolean;
71
91
  /** Default thread creation mode for this link type: 'all' | 'actionable' | 'manual' */
72
92
  defaultCreateThreads?: string;
93
+ /**
94
+ * Opt-in: declares this link type is composable from Plot via
95
+ * `Connector.onCreateLink`. Omit to make the link type sync-only (no
96
+ * "Create new …" picker entry).
97
+ *
98
+ * Connectors that need multiple compose modes for what users perceive as
99
+ * the same kind of thing (e.g. Slack channel post vs DM) should declare
100
+ * **separate linkTypes**, one per user-facing thread type. That keeps
101
+ * each linkType isomorphic to one filter chip.
102
+ */
103
+ compose?: ComposeConfig;
104
+ /**
105
+ * Per-connector contact roles. Examples:
106
+ * email → [{id:"to",label:"To",default:true},{id:"cc",label:"CC"},{id:"bcc",label:"BCC",hidden:true}]
107
+ * calendar → [{id:"required",label:"Required",default:true},{id:"optional",label:"Optional"}]
108
+ *
109
+ * Plot uses this list to render a role picker on each contact chip in the
110
+ * composer and to label non-default roles on existing threads. Exactly one
111
+ * role should be marked `default: true`. Connectors that don't distinguish
112
+ * roles (Slack, Linear) omit this field entirely.
113
+ */
114
+ contactRoles?: ContactRoleConfig[];
115
+ /**
116
+ * Whether contacts on an existing thread can be added, removed, or have
117
+ * their role changed (email-style mid-thread recipient changes). When
118
+ * false, the thread's contact list is fixed after creation. Defaults to
119
+ * false when omitted.
120
+ */
121
+ supportsContactChanges?: boolean;
122
+ /**
123
+ * Declares how sharing on threads of this link type is scoped:
124
+ *
125
+ * - `"thread"` (default): one roster shared across all notes in the
126
+ * thread. Native Plot threads, Slack DMs, calendar events.
127
+ * - `"channel"`: visibility is the external channel's membership;
128
+ * the per-thread `contacts` array is ignored for sharing UI.
129
+ * Slack channels, Linear projects.
130
+ * - `"message"`: each note carries its own recipient set via
131
+ * `note.access_contacts`; the thread roster is the union across
132
+ * all messages. Email.
133
+ *
134
+ * Omit to default to `"thread"`. When set to `"message"`, every
135
+ * note this connector ingests must populate `access_contacts`
136
+ * explicitly (never NULL).
137
+ */
138
+ sharingModel?: "thread" | "channel" | "message";
139
+ };
140
+
141
+ /**
142
+ * Declares how a link type is composable from Plot via
143
+ * `Connector.onCreateLink`. Attached to {@link LinkTypeConfig.compose}.
144
+ */
145
+ export type ComposeConfig = {
146
+ /**
147
+ * Selects the destination model for the "Create new …" picker.
148
+ *
149
+ * - `"channels"` (default): one chip per enabled channel (e.g. a Linear
150
+ * team, a Slack channel). Existing behaviour for task-tracker / calendar
151
+ * connectors.
152
+ * - `"contacts"`: one chip per connection (account); the user picks
153
+ * recipients from their contacts. The runtime pre-resolves the chosen
154
+ * Plot contacts to platform account IDs via the per-connection
155
+ * `contact_external_account` rows and delivers them as
156
+ * `CreateLinkDraft.recipients`. Contacts without a row for this specific
157
+ * connection are filtered out of the picker — used by closed-roster
158
+ * messaging platforms (Slack DM, Teams DM, Google Chat DM, LinkedIn DM).
159
+ * - `"addresses"`: one chip per connection; the picker accepts any
160
+ * contact with an addressable identifier (e.g. an email) or a free-form
161
+ * typed address. The runtime fills `recipients` for contacts with a
162
+ * connection-scoped row and falls back to the contact's primary address
163
+ * (e.g. `contact.email`) when no row exists. Free-form addresses arrive
164
+ * via the thread's `inviteEmails`. Used by open address spaces like
165
+ * Gmail.
166
+ */
167
+ targets?: "channels" | "contacts" | "addresses";
168
+ /**
169
+ * Status to assign newly-created links. Should match an entry in the
170
+ * parent linkType's `statuses[]`, OR a symbolic id that the connector's
171
+ * `onCreateLink` resolves itself (e.g. Linear's `"unstarted"` category is
172
+ * resolved per-team to a state UUID inside the connector — see
173
+ * `connectors/linear/src/linear.ts`).
174
+ */
175
+ status: string;
176
+ /**
177
+ * Optional override for the picker chip / "Create new …" copy. Defaults
178
+ * to the parent linkType's `label`. Use to disambiguate compose entries
179
+ * when the parent label alone isn't specific enough (e.g. "Direct
180
+ * messages" for a DM-mode compose on a chat connector).
181
+ */
182
+ label?: string;
183
+ };
184
+
185
+ /**
186
+ * Declares one contact role for a connector's link type. See
187
+ * `LinkTypeConfig.contactRoles`.
188
+ */
189
+ export type ContactRoleConfig = {
190
+ /** Stable machine id, e.g. "to" / "cc" / "bcc" / "required" / "optional". */
191
+ id: string;
192
+ /** Display label shown next to a contact chip, e.g. "To", "CC", "Required". */
193
+ label: string;
194
+ /** Exactly one role per linkType should be marked default. */
195
+ default?: boolean;
196
+ /**
197
+ * Hidden roles are visible only to (a) the contact themselves and
198
+ * (b) the user who added them. The API filters them out of every other
199
+ * viewer's `thread.contacts` and `thread.contactMeta`. Use for BCC-style
200
+ * semantics where other recipients must not see the hidden contact.
201
+ */
202
+ hidden?: boolean;
73
203
  };
74
204
 
75
205
  /**
@@ -185,31 +315,6 @@ export abstract class Integrations extends ITool {
185
315
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
186
316
  abstract get(provider: AuthProvider, channelId: string): Promise<AuthToken | null>;
187
317
 
188
- /**
189
- * Execute a callback as a specific actor, requesting auth if needed.
190
- *
191
- * If the actor has a valid token, calls the callback immediately with it.
192
- * If the actor has no token, creates a private auth note in the specified
193
- * activity prompting them to connect. Once they authorize, this callback fires.
194
- *
195
- * @param provider - The OAuth provider
196
- * @param actorId - The actor to act as
197
- * @param activityId - The activity to create an auth note in (if needed)
198
- * @param callback - Function to call with the token
199
- * @param extraArgs - Additional arguments to pass to the callback
200
- */
201
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
202
- abstract actAs<
203
- TArgs extends Serializable[],
204
- TCallback extends (token: AuthToken, ...args: TArgs) => any
205
- >(
206
- provider: AuthProvider,
207
- actorId: ActorId,
208
- activityId: Uuid,
209
- callback: TCallback,
210
- ...extraArgs: TArgs
211
- ): Promise<void>;
212
-
213
318
  /**
214
319
  * Saves a link with notes to the connector's priority.
215
320
  *
@@ -250,10 +355,15 @@ export abstract class Integrations extends ITool {
250
355
  abstract saveLinks(links: NewLinkWithNotes[]): Promise<(Uuid | null)[]>;
251
356
 
252
357
  /**
253
- * Saves contacts to the connector's priority.
358
+ * Upserts contacts into the connector's priority without requiring a Link.
359
+ *
360
+ * Use this for messaging connectors to bulk-sync workspace members so the
361
+ * recipient picker can filter contacts by reachable platform account. Populate
362
+ * `NewContact.source` to persist `contact_external_account` rows (the platform
363
+ * identity used to address the contact). Returns one `Actor` per input, in order.
254
364
  *
255
- * @param contacts - Array of contacts to save
256
- * @returns Promise resolving to the saved actors
365
+ * @param contacts - Contacts to upsert, keyed by `source`/`key`
366
+ * @returns Promise resolving to the saved actors, 1:1 with input order
257
367
  */
258
368
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
259
369
  abstract saveContacts(contacts: NewContact[]): Promise<Actor[]>;