@plotday/twister 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/templates/AGENTS.template.md +8 -2
- package/cli/templates/AGENTS.template.md +8 -2
- package/dist/connector.d.ts +67 -7
- package/dist/connector.d.ts.map +1 -1
- package/dist/connector.js +15 -5
- package/dist/connector.js.map +1 -1
- package/dist/docs/assets/hierarchy.js +1 -1
- package/dist/docs/assets/navigation.js +1 -1
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/index.Connector.html +58 -49
- package/dist/docs/classes/index.Imap.html +1 -1
- package/dist/docs/classes/index.Options.html +1 -1
- package/dist/docs/classes/index.Smtp.html +1 -1
- package/dist/docs/classes/tools_ai.AI.html +1 -1
- package/dist/docs/classes/tools_callbacks.Callbacks.html +1 -1
- package/dist/docs/classes/tools_integrations.Integrations.html +21 -5
- package/dist/docs/classes/tools_network.Network.html +1 -1
- package/dist/docs/classes/tools_plot.Plot.html +1 -1
- 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 +28 -28
- package/dist/docs/documents/Building_Connectors.html +8 -1
- package/dist/docs/enums/tag.Tag.html +11 -1
- package/dist/docs/enums/tools_integrations.AuthProvider.html +13 -13
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/media/AGENTS.md +298 -775
- package/dist/docs/media/MULTI_USER_AUTH.md +6 -4
- package/dist/docs/media/SYNC_STRATEGIES.md +20 -14
- package/dist/docs/modules/index.html +1 -1
- package/dist/docs/types/index.CreateLinkDraft.html +7 -12
- package/dist/docs/types/index.NoteWriteBackResult.html +38 -0
- package/dist/docs/types/tools_integrations.ArchiveLinkFilter.html +5 -5
- package/dist/docs/types/tools_integrations.AuthToken.html +4 -4
- package/dist/docs/types/tools_integrations.Authorization.html +4 -4
- package/dist/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/tag.d.ts +1 -1
- package/dist/llm-docs/tag.d.ts.map +1 -1
- package/dist/llm-docs/tag.js +1 -1
- package/dist/llm-docs/tag.js.map +1 -1
- package/dist/llm-docs/tools/integrations.d.ts +1 -1
- package/dist/llm-docs/tools/integrations.d.ts.map +1 -1
- package/dist/llm-docs/tools/integrations.js +1 -1
- package/dist/llm-docs/tools/integrations.js.map +1 -1
- package/dist/llm-docs/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/tag.d.ts +11 -1
- package/dist/tag.d.ts.map +1 -1
- package/dist/tag.js +10 -0
- package/dist/tag.js.map +1 -1
- package/dist/tools/integrations.d.ts +22 -0
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js.map +1 -1
- package/dist/twist-guide.d.ts +1 -1
- package/dist/twist-guide.d.ts.map +1 -1
- package/dist/twist.d.ts +2 -1
- package/dist/twist.d.ts.map +1 -1
- package/dist/twist.js.map +1 -1
- package/dist/utils/markdown.d.ts +27 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +82 -0
- package/dist/utils/markdown.js.map +1 -0
- package/package.json +6 -1
- package/src/connector.ts +68 -7
- package/src/llm-docs/connector.ts +1 -1
- package/src/llm-docs/tag.ts +1 -1
- package/src/llm-docs/tools/integrations.ts +1 -1
- package/src/llm-docs/twist-guide-template.ts +1 -1
- package/src/llm-docs/twist.ts +1 -1
- package/src/tag.ts +10 -0
- package/src/tools/integrations.ts +24 -0
- package/src/twist.ts +2 -1
- package/src/utils/markdown.ts +94 -0
|
@@ -46,8 +46,8 @@ When a twist needs to write back to an external system (e.g., posting a comment
|
|
|
46
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
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
private async onNoteCreated(note: Note): Promise<void> {
|
|
50
|
-
const provider =
|
|
49
|
+
private async onNoteCreated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {
|
|
50
|
+
const provider = thread.meta?.provider;
|
|
51
51
|
const tool = this.getProviderTool(provider);
|
|
52
52
|
|
|
53
53
|
// Try actor's credentials first, then installer's
|
|
@@ -63,8 +63,10 @@ private async onNoteCreated(note: Note): Promise<void> {
|
|
|
63
63
|
|
|
64
64
|
for (const authToken of authTokensToTry) {
|
|
65
65
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
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);
|
|
68
70
|
} catch {
|
|
69
71
|
continue; // Try next token
|
|
70
72
|
}
|
|
@@ -764,29 +764,31 @@ When implementing two-way sync where items can be created in Plot and pushed to
|
|
|
764
764
|
|
|
765
765
|
This eliminates a race condition where a webhook for an item you're creating arrives before you've updated the Activity/Note with the external key. Without this pattern, the webhook handler won't find the item by external key and may create a duplicate.
|
|
766
766
|
|
|
767
|
+
In a connector, return a `NoteWriteBackResult` from `onNoteCreated` — the runtime sets the key atomically and also records the external content as the sync baseline:
|
|
768
|
+
|
|
767
769
|
```typescript
|
|
768
|
-
async
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
body: note.content,
|
|
770
|
+
async onNoteCreated(note: Note, thread: Thread): Promise<NoteWriteBackResult | void> {
|
|
771
|
+
const externalComment = await externalApi.createComment(thread.meta.externalItemId, {
|
|
772
|
+
body: note.content ?? "",
|
|
772
773
|
metadata: { plotNoteId: note.id }, // Embed Plot ID for webhook correlation
|
|
773
774
|
});
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
// A webhook may arrive between these two steps — that's OK because
|
|
777
|
-
// the webhook handler checks metadata first (see below)
|
|
778
|
-
await this.tools.plot.updateNote({
|
|
779
|
-
id: note.id,
|
|
775
|
+
if (!externalComment?.id) return;
|
|
776
|
+
return {
|
|
780
777
|
key: `comment-${externalComment.id}`,
|
|
781
|
-
|
|
778
|
+
// What the external system NOW STORES — must match what your sync-in
|
|
779
|
+
// path emits as NewNote.content on re-ingest. The runtime hashes this
|
|
780
|
+
// so the next sync re-listing unchanged content preserves Plot's
|
|
781
|
+
// (possibly richer-markdown) version instead of clobbering it.
|
|
782
|
+
externalContent: externalComment.body,
|
|
783
|
+
};
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
async onWebhook(payload: WebhookPayload): Promise<void> {
|
|
785
787
|
const comment = payload.comment;
|
|
786
788
|
|
|
787
|
-
// Use the Plot ID from metadata if present (handles the race
|
|
788
|
-
//
|
|
789
|
-
// otherwise fall back to upserting by activity source and key
|
|
789
|
+
// Use the Plot ID from metadata if present (handles the race where the
|
|
790
|
+
// webhook arrives before onNoteCreated's return has been applied),
|
|
791
|
+
// otherwise fall back to upserting by activity source and key.
|
|
790
792
|
await this.tools.plot.createNote({
|
|
791
793
|
...(comment.metadata?.plotNoteId
|
|
792
794
|
? { id: comment.metadata.plotNoteId }
|
|
@@ -797,6 +799,10 @@ async onWebhook(payload: WebhookPayload): Promise<void> {
|
|
|
797
799
|
}
|
|
798
800
|
```
|
|
799
801
|
|
|
802
|
+
For twists that write notes outside the `onNoteCreated` dispatch path (explicit `pushNoteAsComment`-style methods), set `key` via `updateNote` after the external write — see the legacy pattern below. In that path the sync baseline is **not** established, so the next sync-in will overwrite Plot's content with the external version. Prefer the connector `onNoteCreated` flow when round-trip preservation matters.
|
|
803
|
+
|
|
804
|
+
See `connectors/AGENTS.md` → "Sync baseline preservation" for the full contract on what `externalContent` must equal.
|
|
805
|
+
|
|
800
806
|
## Summary
|
|
801
807
|
|
|
802
808
|
- **Strategy 1** (Create Once): Simplest, no deduplication, use for one-time items
|