@plotday/twister 0.36.0 → 0.38.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 +4 -2
- package/bin/commands/create.js +37 -3
- package/bin/commands/create.js.map +1 -1
- package/bin/commands/deploy.js +4 -0
- package/bin/commands/deploy.js.map +1 -1
- package/bin/index.js +1 -0
- package/bin/index.js.map +1 -1
- package/bin/templates/AGENTS.template.md +101 -189
- package/bin/templates/README.template.md +2 -23
- package/cli/templates/AGENTS.template.md +101 -189
- package/cli/templates/README.template.md +2 -23
- 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.Options.html +1 -1
- package/dist/docs/classes/index.Source.html +200 -0
- package/dist/docs/classes/tool.ITool.html +1 -1
- package/dist/docs/classes/tool.Tool.html +21 -21
- package/dist/docs/classes/tools_ai.AI.html +1 -1
- package/dist/docs/classes/tools_callbacks.Callbacks.html +2 -2
- package/dist/docs/classes/tools_integrations.Integrations.html +45 -16
- package/dist/docs/classes/tools_network.Network.html +1 -1
- package/dist/docs/classes/tools_plot.Plot.html +93 -60
- package/dist/docs/classes/tools_store.Store.html +1 -1
- package/dist/docs/classes/tools_tasks.Tasks.html +1 -1
- package/dist/docs/classes/tools_twists.Twists.html +1 -1
- package/dist/docs/classes/twist.Twist.html +42 -10
- package/dist/docs/documents/Building_Sources.html +137 -0
- package/dist/docs/documents/Built-in_Tools.html +11 -2
- package/dist/docs/documents/Core_Concepts.html +5 -10
- package/dist/docs/documents/Getting_Started.html +1 -1
- package/dist/docs/enums/{plot.ActivityLinkType.html → plot.ActionType.html} +10 -8
- package/dist/docs/enums/plot.ActorType.html +7 -7
- 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 -10
- package/dist/docs/enums/tools_integrations.AuthProvider.html +11 -11
- package/dist/docs/enums/tools_plot.ContactAccess.html +3 -3
- package/dist/docs/enums/tools_plot.PriorityAccess.html +3 -3
- package/dist/docs/enums/{tools_plot.ActivityAccess.html → tools_plot.ThreadAccess.html} +6 -6
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/index.html +5 -6
- package/dist/docs/media/AGENTS.md +910 -0
- package/dist/docs/media/MULTI_USER_AUTH.md +111 -0
- package/dist/docs/media/SYNC_STRATEGIES.md +7 -7
- package/dist/docs/modules/index.html +1 -1
- package/dist/docs/modules/plot.html +1 -1
- package/dist/docs/modules/tool.html +1 -1
- package/dist/docs/modules/tools_integrations.html +1 -1
- package/dist/docs/modules/tools_plot.html +1 -1
- package/dist/docs/modules.html +1 -1
- package/dist/docs/types/index.NewSchedule.html +33 -0
- package/dist/docs/types/index.NewScheduleContact.html +5 -0
- package/dist/docs/types/index.NewScheduleOccurrence.html +6 -0
- package/dist/docs/types/index.Schedule.html +37 -0
- package/dist/docs/types/index.ScheduleContact.html +5 -0
- package/dist/docs/types/index.ScheduleContactRole.html +1 -0
- package/dist/docs/types/index.ScheduleContactStatus.html +1 -0
- package/dist/docs/types/index.ScheduleOccurrence.html +17 -0
- package/dist/docs/types/index.ScheduleOccurrenceUpdate.html +2 -0
- package/dist/docs/types/plot.Action.html +28 -0
- package/dist/docs/types/plot.Actor.html +6 -6
- package/dist/docs/types/plot.ActorId.html +1 -1
- package/dist/docs/types/plot.ContentType.html +1 -1
- package/dist/docs/types/plot.Link.html +36 -0
- package/dist/docs/types/plot.NewActor.html +1 -1
- package/dist/docs/types/plot.NewContact.html +5 -5
- package/dist/docs/types/plot.NewLink.html +26 -0
- package/dist/docs/types/plot.NewLinkWithNotes.html +7 -0
- package/dist/docs/types/plot.NewNote.html +10 -10
- package/dist/docs/types/plot.NewPriority.html +1 -1
- package/dist/docs/types/plot.NewTags.html +1 -1
- package/dist/docs/types/plot.NewThread.html +27 -0
- package/dist/docs/types/plot.NewThreadWithNotes.html +1 -0
- package/dist/docs/types/plot.Note.html +9 -8
- package/dist/docs/types/plot.NoteUpdate.html +2 -2
- package/dist/docs/types/plot.PickPriorityConfig.html +8 -10
- package/dist/docs/types/plot.Priority.html +6 -6
- package/dist/docs/types/plot.PriorityUpdate.html +1 -1
- package/dist/docs/types/plot.Tags.html +1 -1
- package/dist/docs/types/plot.Thread.html +1 -0
- package/dist/docs/types/plot.ThreadCommon.html +17 -0
- package/dist/docs/types/plot.ThreadFilter.html +2 -0
- package/dist/docs/types/plot.ThreadMeta.html +11 -0
- package/dist/docs/types/plot.ThreadUpdate.html +3 -0
- package/dist/docs/types/plot.ThreadWithNotes.html +1 -0
- package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +11 -0
- 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.Channel.html +11 -0
- package/dist/docs/types/tools_integrations.LinkTypeConfig.html +17 -0
- package/dist/docs/types/tools_plot.LinkFilter.html +10 -0
- package/dist/docs/types/tools_plot.LinkSearchResult.html +1 -0
- package/dist/docs/types/tools_plot.NoteIntentHandler.html +6 -6
- package/dist/docs/types/tools_plot.NoteSearchResult.html +1 -0
- package/dist/docs/types/tools_plot.SearchOptions.html +7 -0
- package/dist/docs/types/tools_plot.SearchResult.html +1 -0
- package/dist/docs/types/tools_twists.TwistPermissions.html +1 -1
- package/dist/docs/variables/tools_plot.SEARCH_DEFAULT_LIMIT.html +2 -0
- package/dist/docs/variables/tools_plot.SEARCH_MAX_LIMIT.html +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/llm-docs/index.d.ts.map +1 -1
- package/dist/llm-docs/index.js +4 -8
- 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/schedule.d.ts +9 -0
- package/dist/llm-docs/schedule.d.ts.map +1 -0
- package/dist/llm-docs/schedule.js +8 -0
- package/dist/llm-docs/schedule.js.map +1 -0
- package/dist/llm-docs/source.d.ts +9 -0
- package/dist/llm-docs/source.d.ts.map +1 -0
- package/dist/llm-docs/source.js +8 -0
- package/dist/llm-docs/source.js.map +1 -0
- 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/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/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/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/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 +264 -589
- package/dist/plot.d.ts.map +1 -1
- package/dist/plot.js +18 -49
- package/dist/plot.js.map +1 -1
- package/dist/schedule.d.ts +172 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/schedule.js +2 -0
- package/dist/schedule.js.map +1 -0
- package/dist/source.d.ts +158 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +144 -0
- package/dist/source.js.map +1 -0
- package/dist/tag.d.ts +3 -10
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +2 -11
- package/dist/tag.js.map +1 -1
- package/dist/tool.d.ts +1 -15
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js.map +1 -1
- package/dist/tools/callbacks.d.ts +1 -1
- package/dist/tools/callbacks.js +1 -1
- package/dist/tools/integrations.d.ts +119 -52
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js +23 -22
- package/dist/tools/integrations.js.map +1 -1
- package/dist/tools/plot.d.ts +182 -117
- package/dist/tools/plot.d.ts.map +1 -1
- package/dist/tools/plot.js +23 -21
- package/dist/tools/plot.js.map +1 -1
- package/dist/tools/twists.d.ts +1 -1
- package/dist/twist-guide.d.ts +1 -1
- package/dist/twist-guide.d.ts.map +1 -1
- package/dist/twist.d.ts +66 -11
- package/dist/twist.d.ts.map +1 -1
- package/dist/twist.js +79 -10
- package/dist/twist.js.map +1 -1
- package/package.json +11 -41
- package/dist/common/calendar.d.ts +0 -135
- package/dist/common/calendar.d.ts.map +0 -1
- package/dist/common/calendar.js +0 -2
- package/dist/common/calendar.js.map +0 -1
- package/dist/common/documents.d.ts +0 -122
- package/dist/common/documents.d.ts.map +0 -1
- package/dist/common/documents.js +0 -2
- package/dist/common/documents.js.map +0 -1
- package/dist/common/messaging.d.ts +0 -84
- package/dist/common/messaging.d.ts.map +0 -1
- package/dist/common/messaging.js +0 -2
- package/dist/common/messaging.js.map +0 -1
- package/dist/common/projects.d.ts +0 -112
- package/dist/common/projects.d.ts.map +0 -1
- package/dist/common/projects.js +0 -2
- package/dist/common/projects.js.map +0 -1
- package/dist/docs/documents/Building_Custom_Tools.html +0 -215
- package/dist/docs/enums/plot.ActivityKind.html +0 -14
- package/dist/docs/enums/plot.ActivityType.html +0 -10
- package/dist/docs/modules/common_calendar.html +0 -1
- package/dist/docs/types/common_calendar.Calendar.html +0 -13
- package/dist/docs/types/common_calendar.CalendarTool.html +0 -81
- package/dist/docs/types/common_calendar.SyncOptions.html +0 -24
- package/dist/docs/types/plot.Activity.html +0 -2
- package/dist/docs/types/plot.ActivityCommon.html +0 -20
- package/dist/docs/types/plot.ActivityFilter.html +0 -3
- package/dist/docs/types/plot.ActivityLink.html +0 -26
- package/dist/docs/types/plot.ActivityMeta.html +0 -11
- package/dist/docs/types/plot.ActivityOccurrence.html +0 -22
- package/dist/docs/types/plot.ActivityOccurrenceUpdate.html +0 -3
- package/dist/docs/types/plot.ActivityUpdate.html +0 -3
- package/dist/docs/types/plot.ActivityWithNotes.html +0 -1
- package/dist/docs/types/plot.NewActivity.html +0 -81
- package/dist/docs/types/plot.NewActivityOccurrence.html +0 -24
- package/dist/docs/types/plot.NewActivityWithNotes.html +0 -1
- package/dist/docs/types/tool.SyncToolOptions.html +0 -9
- package/dist/docs/types/tools_integrations.IntegrationOptions.html +0 -4
- package/dist/docs/types/tools_integrations.IntegrationProviderConfig.html +0 -13
- package/dist/docs/types/tools_integrations.Syncable.html +0 -9
- package/dist/llm-docs/common/calendar.d.ts +0 -9
- package/dist/llm-docs/common/calendar.d.ts.map +0 -1
- package/dist/llm-docs/common/calendar.js +0 -8
- package/dist/llm-docs/common/calendar.js.map +0 -1
- package/dist/llm-docs/common/documents.d.ts +0 -9
- package/dist/llm-docs/common/documents.d.ts.map +0 -1
- package/dist/llm-docs/common/documents.js +0 -8
- package/dist/llm-docs/common/documents.js.map +0 -1
- package/dist/llm-docs/common/messaging.d.ts +0 -9
- package/dist/llm-docs/common/messaging.d.ts.map +0 -1
- package/dist/llm-docs/common/messaging.js +0 -8
- package/dist/llm-docs/common/messaging.js.map +0 -1
- package/dist/llm-docs/common/projects.d.ts +0 -9
- package/dist/llm-docs/common/projects.d.ts.map +0 -1
- package/dist/llm-docs/common/projects.js +0 -8
- package/dist/llm-docs/common/projects.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Multi-User Priority Auth
|
|
2
|
+
|
|
3
|
+
Twists and sources 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
|
+
- `private: true` — only the author and mentioned users can see the activity
|
|
36
|
+
- `context?.actor` — the user who installed the twist (available from the SDK)
|
|
37
|
+
- Always guard with `?.` since `context` is optional for backward compatibility
|
|
38
|
+
|
|
39
|
+
## Per-User Auth for Write-Backs
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
### Pattern: Try Actor First, Fall Back to Installer
|
|
44
|
+
|
|
45
|
+
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)`:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
private async onNoteCreated(note: Note): Promise<void> {
|
|
49
|
+
const provider = activity.meta?.provider;
|
|
50
|
+
const tool = this.getProviderTool(provider);
|
|
51
|
+
|
|
52
|
+
// Try actor's credentials first, then installer's
|
|
53
|
+
const actorId = note.author.id as string;
|
|
54
|
+
const installerAuthToken = await this.getAuthToken(provider);
|
|
55
|
+
|
|
56
|
+
const authTokensToTry = [
|
|
57
|
+
actorId,
|
|
58
|
+
...(installerAuthToken && installerAuthToken !== actorId
|
|
59
|
+
? [installerAuthToken]
|
|
60
|
+
: []),
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
for (const authToken of authTokensToTry) {
|
|
64
|
+
try {
|
|
65
|
+
await tool.addIssueComment(authToken, activity.meta, note.content, note.id);
|
|
66
|
+
return; // Success
|
|
67
|
+
} catch {
|
|
68
|
+
continue; // Try next token
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### When Actor ID Is Not Available
|
|
75
|
+
|
|
76
|
+
For callbacks like `onActivityUpdated` 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:
|
|
77
|
+
|
|
78
|
+
- Activity field updates (title, assignee, done) are less user-specific
|
|
79
|
+
- The change itself is the same regardless of who made it
|
|
80
|
+
- Per-user auth is most valuable for user-attributed actions like comments
|
|
81
|
+
|
|
82
|
+
### How Tools Resolve Auth Tokens
|
|
83
|
+
|
|
84
|
+
Tools with per-user auth support resolve tokens in their `getClient()` method:
|
|
85
|
+
|
|
86
|
+
1. Try `integrations.get(provider, authToken as ActorId)` — looks up per-actor credentials
|
|
87
|
+
2. Fall back to legacy token lookup if the actor has no credentials
|
|
88
|
+
3. Throw if neither works (caller catches and tries the next token)
|
|
89
|
+
|
|
90
|
+
## On-Demand Auth Requests
|
|
91
|
+
|
|
92
|
+
When a user without credentials performs a write-back action, you can optionally create a private auth-request activity prompting them to connect:
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// Create auth request for a specific actor
|
|
96
|
+
const authLink = await tool.requestAuth(this.onActorAuth, actorId);
|
|
97
|
+
|
|
98
|
+
await this.tools.plot.createActivity({
|
|
99
|
+
type: ActivityType.Action,
|
|
100
|
+
title: "Connect to sync your changes",
|
|
101
|
+
private: true,
|
|
102
|
+
source: `auth:${actorId}`, // Dedup: one auth request per user
|
|
103
|
+
notes: [{
|
|
104
|
+
content: "Connect your account so your changes appear under your name.",
|
|
105
|
+
links: [authLink],
|
|
106
|
+
mentions: [{ id: actorId as ActorId }],
|
|
107
|
+
}],
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This is optional — the simpler approach is to silently fall back to the installer's credentials.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sync Strategies
|
|
2
2
|
|
|
3
|
-
This guide explains good ways to build
|
|
3
|
+
This guide explains good ways to build sources that sync other services with Plot. Choosing the right strategy depends on whether you need to update items, deduplicate them, or simply create them once.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -115,7 +115,7 @@ interface Activity {
|
|
|
115
115
|
### Example: Calendar Event Sync
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
|
-
export default class
|
|
118
|
+
export default class GoogleCalendarSource extends Source<GoogleCalendarSource> {
|
|
119
119
|
async syncEvent(event: calendar_v3.Schema$Event): Promise<void> {
|
|
120
120
|
const activity: NewActivityWithNotes = {
|
|
121
121
|
// Use the event's canonical URL as the source
|
|
@@ -168,7 +168,7 @@ export default class GoogleCalendarTool extends Tool<GoogleCalendarTool> {
|
|
|
168
168
|
### Example: Task/Issue Sync
|
|
169
169
|
|
|
170
170
|
```typescript
|
|
171
|
-
export default class
|
|
171
|
+
export default class LinearSource extends Source<LinearSource> {
|
|
172
172
|
async syncIssue(issue: LinearIssue): Promise<void> {
|
|
173
173
|
const activity: NewActivityWithNotes = {
|
|
174
174
|
source: issue.url, // Linear provides stable URLs
|
|
@@ -274,7 +274,7 @@ Use this strategy when:
|
|
|
274
274
|
### Example: Multiple Activities from Single Source
|
|
275
275
|
|
|
276
276
|
```typescript
|
|
277
|
-
export default class
|
|
277
|
+
export default class GmailSource extends Source<GmailSource> {
|
|
278
278
|
/**
|
|
279
279
|
* Creates separate activities for email threads and individual messages.
|
|
280
280
|
* One email thread can have multiple Plot activities.
|
|
@@ -694,9 +694,9 @@ if (existingId) {
|
|
|
694
694
|
|
|
695
695
|
## Best Practices
|
|
696
696
|
|
|
697
|
-
### 1. Be Consistent Within a
|
|
697
|
+
### 1. Be Consistent Within a Source
|
|
698
698
|
|
|
699
|
-
Choose one strategy per
|
|
699
|
+
Choose one strategy per source and stick with it. Mixing strategies in the same source can lead to confusion and bugs.
|
|
700
700
|
|
|
701
701
|
### 2. Use Descriptive Keys
|
|
702
702
|
|
|
@@ -805,4 +805,4 @@ For more information:
|
|
|
805
805
|
|
|
806
806
|
- [Core Concepts](CORE_CONCEPTS.md) - Understanding activities, notes, and priorities
|
|
807
807
|
- [Tools Guide](TOOLS_GUIDE.md) - Complete reference for the Plot tool
|
|
808
|
-
- [Building
|
|
808
|
+
- [Building Sources](BUILDING_SOURCES.md) - Creating external service integrations
|