@plotday/twister 0.28.0 → 0.30.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/commands/deploy.js +1 -1
- package/bin/commands/deploy.js.map +1 -1
- package/dist/common/calendar.d.ts +24 -15
- package/dist/common/calendar.d.ts.map +1 -1
- package/dist/common/messaging.d.ts +17 -13
- package/dist/common/messaging.d.ts.map +1 -1
- package/dist/common/projects.d.ts +23 -18
- package/dist/common/projects.d.ts.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/tool.ITool.html +1 -1
- package/dist/docs/classes/tool.Tool.html +34 -35
- package/dist/docs/classes/tools_ai.AI.html +1 -1
- package/dist/docs/classes/tools_callbacks.Callbacks.html +21 -12
- package/dist/docs/classes/tools_integrations.Integrations.html +6 -6
- package/dist/docs/classes/tools_network.Network.html +12 -12
- package/dist/docs/classes/tools_plot.Plot.html +40 -30
- package/dist/docs/classes/tools_store.Store.html +29 -18
- package/dist/docs/classes/tools_tasks.Tasks.html +5 -5
- package/dist/docs/classes/tools_twists.Twists.html +1 -1
- package/dist/docs/classes/twist.Twist.html +39 -27
- package/dist/docs/enums/plot.ActivityLinkType.html +5 -5
- package/dist/docs/enums/plot.ActivityType.html +4 -4
- package/dist/docs/enums/plot.ActorType.html +4 -4
- package/dist/docs/enums/plot.ConferencingProvider.html +6 -6
- package/dist/docs/enums/tools_integrations.AuthLevel.html +3 -3
- package/dist/docs/enums/tools_integrations.AuthProvider.html +11 -11
- package/dist/docs/enums/tools_plot.ActivityAccess.html +3 -3
- package/dist/docs/enums/tools_plot.ContactAccess.html +3 -3
- package/dist/docs/enums/tools_plot.PriorityAccess.html +3 -3
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/interfaces/tools_ai.AIResponse.html +2 -2
- package/dist/docs/interfaces/tools_ai.FilePart.html +2 -2
- package/dist/docs/interfaces/tools_ai.ImagePart.html +2 -2
- package/dist/docs/interfaces/utils_types.ToolShed.html +5 -5
- package/dist/docs/modules/common_calendar.html +1 -1
- package/dist/docs/modules/index.html +1 -1
- package/dist/docs/modules/plot.html +1 -1
- package/dist/docs/modules/tools_callbacks.html +1 -1
- package/dist/docs/modules/utils_types.html +1 -1
- package/dist/docs/{interfaces → types}/common_calendar.Calendar.html +2 -2
- package/dist/docs/types/common_calendar.CalendarTool.html +71 -0
- package/dist/docs/{interfaces → types}/common_calendar.SyncOptions.html +2 -2
- package/dist/docs/types/index.Serializable.html +17 -0
- package/dist/docs/types/plot.Activity.html +1 -1
- package/dist/docs/types/plot.ActivityCommon.html +8 -10
- package/dist/docs/types/plot.ActivityLink.html +1 -1
- package/dist/docs/types/plot.ActivityMeta.html +5 -3
- package/dist/docs/types/plot.ActivityUpdate.html +2 -2
- package/dist/docs/types/plot.ActivityWithNotes.html +1 -1
- package/dist/docs/types/plot.Actor.html +15 -5
- package/dist/docs/types/plot.ActorId.html +1 -1
- package/dist/docs/types/plot.ContentType.html +1 -1
- package/dist/docs/types/plot.NewActivity.html +1 -1
- package/dist/docs/types/plot.NewActivityWithNotes.html +1 -1
- package/dist/docs/types/plot.NewActor.html +1 -1
- package/dist/docs/types/plot.NewContact.html +4 -4
- package/dist/docs/types/plot.NewNote.html +1 -1
- package/dist/docs/types/plot.NewPriority.html +15 -5
- package/dist/docs/types/plot.NewTags.html +1 -1
- package/dist/docs/types/plot.Note.html +1 -1
- package/dist/docs/types/plot.NoteUpdate.html +2 -2
- package/dist/docs/types/plot.PickPriorityConfig.html +3 -3
- package/dist/docs/types/plot.Priority.html +9 -4
- package/dist/docs/types/plot.PriorityUpdate.html +3 -0
- package/dist/docs/types/plot.SyncUpdate.html +1 -1
- package/dist/docs/types/plot.Tags.html +1 -1
- package/dist/docs/types/tools_callbacks.Callback.html +3 -2
- 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_network.WebhookRequest.html +6 -6
- package/dist/docs/types/tools_plot.NoteIntentHandler.html +4 -4
- 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 +7 -0
- package/dist/docs/types/utils_types.PromiseValues.html +1 -1
- package/dist/docs/types/utils_types.ToolBuilder.html +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/llm-docs/common/calendar.d.ts +1 -1
- package/dist/llm-docs/common/calendar.d.ts.map +1 -1
- package/dist/llm-docs/common/calendar.js +1 -1
- package/dist/llm-docs/common/calendar.js.map +1 -1
- package/dist/llm-docs/common/messaging.d.ts +1 -1
- package/dist/llm-docs/common/messaging.d.ts.map +1 -1
- package/dist/llm-docs/common/messaging.js +1 -1
- package/dist/llm-docs/common/messaging.js.map +1 -1
- package/dist/llm-docs/common/projects.d.ts +1 -1
- package/dist/llm-docs/common/projects.d.ts.map +1 -1
- package/dist/llm-docs/common/projects.js +1 -1
- package/dist/llm-docs/common/projects.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/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/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/store.d.ts +1 -1
- package/dist/llm-docs/tools/store.d.ts.map +1 -1
- package/dist/llm-docs/tools/store.js +1 -1
- package/dist/llm-docs/tools/store.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/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 +125 -16
- package/dist/plot.d.ts.map +1 -1
- package/dist/plot.js.map +1 -1
- package/dist/tool.d.ts +28 -20
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +25 -17
- package/dist/tool.js.map +1 -1
- package/dist/tools/callbacks.d.ts +10 -8
- package/dist/tools/callbacks.d.ts.map +1 -1
- package/dist/tools/callbacks.js.map +1 -1
- package/dist/tools/integrations.d.ts +3 -4
- package/dist/tools/integrations.d.ts.map +1 -1
- package/dist/tools/integrations.js.map +1 -1
- package/dist/tools/network.d.ts +20 -17
- package/dist/tools/network.d.ts.map +1 -1
- package/dist/tools/network.js +6 -4
- package/dist/tools/network.js.map +1 -1
- package/dist/tools/plot.d.ts +91 -24
- package/dist/tools/plot.d.ts.map +1 -1
- package/dist/tools/plot.js +45 -0
- package/dist/tools/plot.js.map +1 -1
- package/dist/tools/store.d.ts +43 -18
- package/dist/tools/store.d.ts.map +1 -1
- package/dist/tools/store.js +12 -1
- package/dist/tools/store.js.map +1 -1
- package/dist/tools/tasks.d.ts +4 -4
- package/dist/tools/tasks.js +4 -4
- package/dist/twist.d.ts +45 -12
- package/dist/twist.d.ts.map +1 -1
- package/dist/twist.js +40 -6
- package/dist/twist.js.map +1 -1
- package/dist/utils/serializable.d.ts +40 -0
- package/dist/utils/serializable.d.ts.map +1 -0
- package/dist/utils/serializable.js +2 -0
- package/dist/utils/serializable.js.map +1 -0
- package/dist/utils/types.d.ts +18 -16
- package/dist/utils/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/docs/interfaces/common_calendar.CalendarTool.html +0 -65
- package/dist/docs/types/utils_types.CallbackMethods.html +0 -3
- package/dist/docs/types/utils_types.NoFunctions.html +0 -3
- package/dist/docs/types/utils_types.NonFunction.html +0 -2
package/dist/plot.d.ts
CHANGED
|
@@ -1,8 +1,69 @@
|
|
|
1
1
|
import { type Tag } from "./tag";
|
|
2
2
|
import { type Callback } from "./tools/callbacks";
|
|
3
|
+
import { type JSONValue } from "./utils/types";
|
|
3
4
|
import { Uuid } from "./utils/uuid";
|
|
4
5
|
export { Tag } from "./tag";
|
|
5
6
|
export { Uuid } from "./utils/uuid";
|
|
7
|
+
export { type JSONValue } from "./utils/types";
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview
|
|
10
|
+
* Core Plot entity types for working with activities, notes, priorities, and contacts.
|
|
11
|
+
*
|
|
12
|
+
* ## Type Pattern: Null vs Undefined Semantics
|
|
13
|
+
*
|
|
14
|
+
* Plot entity types use a consistent pattern to distinguish between missing, unset, and explicitly cleared values:
|
|
15
|
+
*
|
|
16
|
+
* ### Entity Types (Activity, Priority, Note, Actor)
|
|
17
|
+
* - **Required fields**: No `?`, cannot be `undefined`
|
|
18
|
+
* - Example: `id: Uuid`, `type: ActivityType`
|
|
19
|
+
* - **Nullable fields**: Use `| null` to allow explicit clearing
|
|
20
|
+
* - Example: `assignee: ActorId | null`, `done: Date | null`
|
|
21
|
+
* - `null` = field is explicitly unset/cleared
|
|
22
|
+
* - Non-null value = field has a value
|
|
23
|
+
* - **Optional nullable fields**: Use `?` with `| null` for permission-based access
|
|
24
|
+
* - Example: `email?: string | null`, `name?: string | null`
|
|
25
|
+
* - `undefined` = field not included (e.g., no permission to access)
|
|
26
|
+
* - `null` = field included but not set
|
|
27
|
+
* - Value = field has a value
|
|
28
|
+
*
|
|
29
|
+
* ### New* Types (NewActivity, NewNote, NewPriority)
|
|
30
|
+
* Used for creating or updating entities. Support partial updates by distinguishing omitted vs cleared fields:
|
|
31
|
+
* - **Required fields**: Must be provided (no `?`)
|
|
32
|
+
* - Example: `type: ActivityType` in NewActivity
|
|
33
|
+
* - **Optional fields**: Use `?` to make them optional
|
|
34
|
+
* - Example: `title?: string`, `author?: NewActor`
|
|
35
|
+
* - `undefined` (omitted) = don't set/update this field
|
|
36
|
+
* - Provided value = set/update this field
|
|
37
|
+
* - **Optional nullable fields**: Use `?` with `| null` to support clearing
|
|
38
|
+
* - Example: `assignee?: NewActor | null`
|
|
39
|
+
* - `undefined` (omitted) = don't change assignee
|
|
40
|
+
* - `null` = clear the assignee
|
|
41
|
+
* - NewActor = set/update the assignee
|
|
42
|
+
*
|
|
43
|
+
* This pattern allows API consumers to:
|
|
44
|
+
* 1. Omit fields they don't want to change (undefined)
|
|
45
|
+
* 2. Explicitly clear fields by setting to null
|
|
46
|
+
* 3. Set or update fields by providing values
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Creating a new activity
|
|
51
|
+
* const newActivity: NewActivity = {
|
|
52
|
+
* type: ActivityType.Action, // Required
|
|
53
|
+
* title: "Review PR", // Optional, provided
|
|
54
|
+
* assignee: null, // Optional nullable, explicitly clearing
|
|
55
|
+
* // priority is omitted (undefined), will auto-select or use default
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* // Updating an activity - only change what's specified
|
|
59
|
+
* const update: ActivityUpdate = {
|
|
60
|
+
* id: activityId,
|
|
61
|
+
* done: new Date(), // Mark as done
|
|
62
|
+
* assignee: null, // Clear assignee
|
|
63
|
+
* // title is omitted, won't be changed
|
|
64
|
+
* };
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
6
67
|
/**
|
|
7
68
|
* Represents a unique user, contact, or twist in Plot.
|
|
8
69
|
*
|
|
@@ -23,20 +84,57 @@ export type ActorId = string & {
|
|
|
23
84
|
*/
|
|
24
85
|
export type Priority = {
|
|
25
86
|
/** Unique identifier for the priority */
|
|
26
|
-
id:
|
|
87
|
+
id: Uuid;
|
|
27
88
|
/** Human-readable title for the priority */
|
|
28
89
|
title: string;
|
|
90
|
+
/** Whether this priority has been archived */
|
|
91
|
+
archived: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Optional key for referencing this priority.
|
|
94
|
+
* Keys are unique per priority tree (a user's personal priorities or the root of a shared priority).
|
|
95
|
+
*/
|
|
96
|
+
key: string | null;
|
|
29
97
|
};
|
|
30
98
|
/**
|
|
31
99
|
* Type for creating new priorities.
|
|
32
100
|
*
|
|
33
|
-
*
|
|
34
|
-
* for
|
|
101
|
+
* Supports multiple creation patterns:
|
|
102
|
+
* - Provide a specific UUID for the priority
|
|
103
|
+
* - Provide a key for upsert within the user's priorities
|
|
104
|
+
* - Omit both to auto-generate a new UUID
|
|
105
|
+
*
|
|
106
|
+
* Optionally specify a parent priority by ID or key for hierarchical structures.
|
|
35
107
|
*/
|
|
36
|
-
export type NewPriority = Omit<Priority, "id"
|
|
37
|
-
/**
|
|
38
|
-
|
|
108
|
+
export type NewPriority = Pick<Priority, "title"> & Partial<Omit<Priority, "id" | "title">> & ({
|
|
109
|
+
/**
|
|
110
|
+
* Unique identifier for the priority, generated by Uuid.Generate().
|
|
111
|
+
* Specifying an ID allows tools to track and upsert priorities.
|
|
112
|
+
*/
|
|
113
|
+
id: Uuid;
|
|
114
|
+
} | {
|
|
115
|
+
/**
|
|
116
|
+
* Unique key for the priority within the user's priorities.
|
|
117
|
+
* Can be used to upsert without knowing the UUID.
|
|
118
|
+
* For example, "@plot" identifies the Plot priority.
|
|
119
|
+
*/
|
|
120
|
+
key: string;
|
|
121
|
+
} | {}) & {
|
|
122
|
+
/** Add the new priority as the child of another priority */
|
|
123
|
+
parent?: {
|
|
124
|
+
id: Uuid;
|
|
125
|
+
} | {
|
|
126
|
+
key: string;
|
|
127
|
+
};
|
|
39
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Type for updating existing priorities.
|
|
131
|
+
* Must provide either id or key to identify the priority to update.
|
|
132
|
+
*/
|
|
133
|
+
export type PriorityUpdate = ({
|
|
134
|
+
id: Uuid;
|
|
135
|
+
} | {
|
|
136
|
+
key: string;
|
|
137
|
+
}) & Partial<Pick<Priority, "title" | "archived">>;
|
|
40
138
|
/**
|
|
41
139
|
* Enumeration of supported activity types in Plot.
|
|
42
140
|
*
|
|
@@ -167,6 +265,9 @@ export type ActivityLink = {
|
|
|
167
265
|
* which is useful for synchronization, linking back to external systems,
|
|
168
266
|
* and storing tool-specific data.
|
|
169
267
|
*
|
|
268
|
+
* Must be valid JSON data (strings, numbers, booleans, null, objects, arrays).
|
|
269
|
+
* Functions and other non-JSON values are not supported.
|
|
270
|
+
*
|
|
170
271
|
* @example
|
|
171
272
|
* ```typescript
|
|
172
273
|
* // Calendar event metadata
|
|
@@ -195,7 +296,7 @@ export type ActivityLink = {
|
|
|
195
296
|
*/
|
|
196
297
|
export type ActivityMeta = {
|
|
197
298
|
/** Source-specific properties and metadata */
|
|
198
|
-
[key: string]:
|
|
299
|
+
[key: string]: JSONValue;
|
|
199
300
|
};
|
|
200
301
|
/**
|
|
201
302
|
* Tags on an item, along with the actors who added each tag.
|
|
@@ -227,8 +328,6 @@ export type ActivityCommon = {
|
|
|
227
328
|
created: Date;
|
|
228
329
|
/** Information about who created the activity */
|
|
229
330
|
author: Actor;
|
|
230
|
-
/** Whether this activity is in draft state (not shown in do now view) */
|
|
231
|
-
draft: boolean;
|
|
232
331
|
/** Whether this activity is private (only visible to author) */
|
|
233
332
|
private: boolean;
|
|
234
333
|
/** Whether this activity has been archived */
|
|
@@ -400,8 +499,8 @@ export type NewActivityWithNotes = NewActivity & {
|
|
|
400
499
|
* // Score based on content (max 100 points) and require exact type match
|
|
401
500
|
* pickPriority: { content: 100, type: true }
|
|
402
501
|
*
|
|
403
|
-
* // Match on meta
|
|
404
|
-
* pickPriority: { "meta.
|
|
502
|
+
* // Match on meta and score content
|
|
503
|
+
* pickPriority: { "meta.projectId": true, content: 50 }
|
|
405
504
|
* ```
|
|
406
505
|
*/
|
|
407
506
|
export type PickPriorityConfig = {
|
|
@@ -532,7 +631,7 @@ export type ActivityUpdate = ({
|
|
|
532
631
|
* Canonical URL for the item in an external system.
|
|
533
632
|
*/
|
|
534
633
|
source: string;
|
|
535
|
-
}) & Partial<Pick<Activity, "type" | "start" | "end" | "done" | "title" | "assignee" | "
|
|
634
|
+
}) & Partial<Pick<Activity, "type" | "start" | "end" | "done" | "title" | "assignee" | "private" | "archived" | "meta" | "recurrenceRule" | "recurrenceDates" | "recurrenceExdates" | "recurrenceUntil" | "recurrenceCount" | "occurrence">> & {
|
|
536
635
|
/**
|
|
537
636
|
* Tags to change on the activity. Use an empty array of NewActor to remove a tag.
|
|
538
637
|
* Use twistTags to add/remove the twist from tags to avoid clearing other actors' tags.
|
|
@@ -656,7 +755,7 @@ export type NoteUpdate = ({
|
|
|
656
755
|
id: Uuid;
|
|
657
756
|
} | {
|
|
658
757
|
key: string;
|
|
659
|
-
}) & Partial<Pick<Note, "
|
|
758
|
+
}) & Partial<Pick<Note, "private" | "archived" | "content" | "links">> & {
|
|
660
759
|
/**
|
|
661
760
|
* Format of the note content. Determines how the note is processed:
|
|
662
761
|
* - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)
|
|
@@ -701,9 +800,19 @@ export type Actor = {
|
|
|
701
800
|
id: ActorId;
|
|
702
801
|
/** Type of actor (User, Contact, or Twist) */
|
|
703
802
|
type: ActorType;
|
|
704
|
-
/**
|
|
705
|
-
|
|
706
|
-
|
|
803
|
+
/**
|
|
804
|
+
* Email address (only included with ContactAccess.Read permission).
|
|
805
|
+
* - `undefined`: No permission to read email
|
|
806
|
+
* - `null`: Permission granted but email not set
|
|
807
|
+
* - `string`: Email address
|
|
808
|
+
*/
|
|
809
|
+
email?: string | null;
|
|
810
|
+
/**
|
|
811
|
+
* Display name.
|
|
812
|
+
* - `undefined`: Not included due to permissions
|
|
813
|
+
* - `null`: Not set
|
|
814
|
+
* - `string`: Display name
|
|
815
|
+
*/
|
|
707
816
|
name?: string | null;
|
|
708
817
|
};
|
|
709
818
|
/**
|
package/dist/plot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../src/plot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../src/plot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,I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AAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC"}
|
package/dist/plot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../src/plot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plot.js","sourceRoot":"","sources":["../src/plot.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAyIpC;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,qEAAqE;IACrE,+CAAI,CAAA;IACJ,+CAA+C;IAC/C,mDAAM,CAAA;IACN,8DAA8D;IAC9D,iDAAK,CAAA;AACP,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,8CAA8C;IAC9C,yCAAqB,CAAA;IACrB,mDAAmD;IACnD,iCAAa,CAAA;IACb,6DAA6D;IAC7D,yCAAqB,CAAA;IACrB,+DAA+D;IAC/D,iDAA6B,CAAA;AAC/B,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC9B,kBAAkB;IAClB,iDAAyB,CAAA;IACzB,WAAW;IACX,qCAAa,CAAA;IACb,sBAAsB;IACtB,yDAAiC,CAAA;IACjC,kBAAkB;IAClB,uCAAe,CAAA;IACf,6CAA6C;IAC7C,uCAAe,CAAA;AACjB,CAAC,EAXW,oBAAoB,KAApB,oBAAoB,QAW/B;AA+sBD;;;;;GAKG;AACH,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,wCAAwC;IACxC,yCAAI,CAAA;IACJ,8CAA8C;IAC9C,+CAAO,CAAA;IACP,6CAA6C;IAC7C,2CAAK,CAAA;AACP,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB"}
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Priority } from "./plot";
|
|
2
2
|
import type { Callback } from "./tools/callbacks";
|
|
3
|
-
import type { InferOptions, InferTools, ToolBuilder, ToolShed } from "./utils/types";
|
|
3
|
+
import type { InferOptions, InferTools, Serializable, ToolBuilder, ToolShed } from "./utils/types";
|
|
4
4
|
export type { ToolBuilder };
|
|
5
5
|
/**
|
|
6
6
|
* Abstrtact parent for both built-in tools and regular Tools.
|
|
@@ -78,7 +78,7 @@ export declare abstract class Tool<TSelf> implements ITool {
|
|
|
78
78
|
* const callback = await this.callback(this.onWebhook, "calendar", 123);
|
|
79
79
|
* ```
|
|
80
80
|
*/
|
|
81
|
-
protected callback<Fn extends (...args:
|
|
81
|
+
protected callback<TArgs extends Serializable[], Fn extends (...args: TArgs) => any>(fn: Fn, ...extraArgs: TArgs): Promise<Callback>;
|
|
82
82
|
/**
|
|
83
83
|
* Deletes a specific callback by its token.
|
|
84
84
|
*
|
|
@@ -99,38 +99,46 @@ export declare abstract class Tool<TSelf> implements ITool {
|
|
|
99
99
|
* @param args - Optional arguments to pass to the callback
|
|
100
100
|
* @returns Promise resolving to the callback result
|
|
101
101
|
*/
|
|
102
|
-
protected run(token: Callback, args
|
|
102
|
+
protected run(token: Callback, ...args: any[]): Promise<any>;
|
|
103
103
|
/**
|
|
104
104
|
* Retrieves a value from persistent storage by key.
|
|
105
105
|
*
|
|
106
|
-
*
|
|
106
|
+
* Values are automatically deserialized using SuperJSON, which
|
|
107
|
+
* properly restores Date objects, Maps, Sets, and other complex types.
|
|
108
|
+
*
|
|
109
|
+
* @template T - The expected type of the stored value (must be Serializable)
|
|
107
110
|
* @param key - The storage key to retrieve
|
|
108
111
|
* @returns Promise resolving to the stored value or null
|
|
109
112
|
*/
|
|
110
|
-
protected get<T>(key: string): Promise<T | null>;
|
|
113
|
+
protected get<T extends Serializable>(key: string): Promise<T | null>;
|
|
111
114
|
/**
|
|
112
115
|
* Stores a value in persistent storage.
|
|
113
116
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* - Object keys with undefined values are automatically removed
|
|
118
|
-
* - Arrays with undefined elements will throw a validation error
|
|
119
|
-
* - Use null instead of undefined for array elements
|
|
117
|
+
* The value will be serialized using SuperJSON and stored persistently.
|
|
118
|
+
* SuperJSON automatically handles Date objects, Maps, Sets, undefined values,
|
|
119
|
+
* and other complex types that standard JSON doesn't support.
|
|
120
120
|
*
|
|
121
|
+
* **Important**: Functions and Symbols cannot be stored.
|
|
121
122
|
* **For function references**: Use callbacks instead of storing functions directly.
|
|
122
123
|
*
|
|
123
124
|
* @example
|
|
124
125
|
* ```typescript
|
|
125
|
-
* // ✅
|
|
126
|
+
* // ✅ Date objects are preserved
|
|
127
|
+
* await this.set("sync_state", {
|
|
128
|
+
* lastSync: new Date(),
|
|
129
|
+
* minDate: new Date(2024, 0, 1)
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* // ✅ undefined is now supported
|
|
126
133
|
* await this.set("data", { name: "test", optional: undefined });
|
|
127
|
-
* // Stores: { name: "test" }
|
|
128
134
|
*
|
|
129
|
-
* // ✅ Arrays
|
|
130
|
-
* await this.set("items", [1,
|
|
135
|
+
* // ✅ Arrays with undefined are supported
|
|
136
|
+
* await this.set("items", [1, undefined, 3]);
|
|
137
|
+
* await this.set("items", [1, null, 3]); // Also works
|
|
131
138
|
*
|
|
132
|
-
* //
|
|
133
|
-
* await this.set("
|
|
139
|
+
* // ✅ Maps and Sets are supported
|
|
140
|
+
* await this.set("mapping", new Map([["key", "value"]]));
|
|
141
|
+
* await this.set("tags", new Set(["tag1", "tag2"]));
|
|
134
142
|
*
|
|
135
143
|
* // ❌ WRONG: Cannot store functions directly
|
|
136
144
|
* await this.set("handler", this.myHandler);
|
|
@@ -144,12 +152,12 @@ export declare abstract class Tool<TSelf> implements ITool {
|
|
|
144
152
|
* await this.run(token, args);
|
|
145
153
|
* ```
|
|
146
154
|
*
|
|
147
|
-
* @template T - The type of value being stored
|
|
155
|
+
* @template T - The type of value being stored (must be Serializable)
|
|
148
156
|
* @param key - The storage key to use
|
|
149
|
-
* @param value - The value to store (must be
|
|
157
|
+
* @param value - The value to store (must be SuperJSON-serializable)
|
|
150
158
|
* @returns Promise that resolves when the value is stored
|
|
151
159
|
*/
|
|
152
|
-
protected set<T>(key: string, value: T): Promise<void>;
|
|
160
|
+
protected set<T extends Serializable>(key: string, value: T): Promise<void>;
|
|
153
161
|
/**
|
|
154
162
|
* Removes a specific key from persistent storage.
|
|
155
163
|
*
|
package/dist/tool.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,WAAW,EACX,QAAQ,EACT,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B;;;GAGG;AACH,8BAAsB,KAAK;CAAG;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8BAAsB,IAAI,CAAC,KAAK,CAAE,YAAW,KAAK;IAE9C,SAAS,CAAC,EAAE,EAAE,MAAM;IACpB,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC;IACtC,OAAO,CAAC,QAAQ;gBAFN,EAAE,EAAE,MAAM,EACV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IAEH,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;;;;;OAQG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;;;;;OAOG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;;;;;OAQG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;;;;;OAOG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/tool.js
CHANGED
|
@@ -110,13 +110,16 @@ export class Tool {
|
|
|
110
110
|
* @param args - Optional arguments to pass to the callback
|
|
111
111
|
* @returns Promise resolving to the callback result
|
|
112
112
|
*/
|
|
113
|
-
async run(token, args) {
|
|
114
|
-
return this.tools.callbacks.run(token, args);
|
|
113
|
+
async run(token, ...args) {
|
|
114
|
+
return this.tools.callbacks.run(token, ...args);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* Retrieves a value from persistent storage by key.
|
|
118
118
|
*
|
|
119
|
-
*
|
|
119
|
+
* Values are automatically deserialized using SuperJSON, which
|
|
120
|
+
* properly restores Date objects, Maps, Sets, and other complex types.
|
|
121
|
+
*
|
|
122
|
+
* @template T - The expected type of the stored value (must be Serializable)
|
|
120
123
|
* @param key - The storage key to retrieve
|
|
121
124
|
* @returns Promise resolving to the stored value or null
|
|
122
125
|
*/
|
|
@@ -126,26 +129,31 @@ export class Tool {
|
|
|
126
129
|
/**
|
|
127
130
|
* Stores a value in persistent storage.
|
|
128
131
|
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* - Object keys with undefined values are automatically removed
|
|
133
|
-
* - Arrays with undefined elements will throw a validation error
|
|
134
|
-
* - Use null instead of undefined for array elements
|
|
132
|
+
* The value will be serialized using SuperJSON and stored persistently.
|
|
133
|
+
* SuperJSON automatically handles Date objects, Maps, Sets, undefined values,
|
|
134
|
+
* and other complex types that standard JSON doesn't support.
|
|
135
135
|
*
|
|
136
|
+
* **Important**: Functions and Symbols cannot be stored.
|
|
136
137
|
* **For function references**: Use callbacks instead of storing functions directly.
|
|
137
138
|
*
|
|
138
139
|
* @example
|
|
139
140
|
* ```typescript
|
|
140
|
-
* // ✅
|
|
141
|
+
* // ✅ Date objects are preserved
|
|
142
|
+
* await this.set("sync_state", {
|
|
143
|
+
* lastSync: new Date(),
|
|
144
|
+
* minDate: new Date(2024, 0, 1)
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // ✅ undefined is now supported
|
|
141
148
|
* await this.set("data", { name: "test", optional: undefined });
|
|
142
|
-
* // Stores: { name: "test" }
|
|
143
149
|
*
|
|
144
|
-
* // ✅ Arrays
|
|
145
|
-
* await this.set("items", [1,
|
|
150
|
+
* // ✅ Arrays with undefined are supported
|
|
151
|
+
* await this.set("items", [1, undefined, 3]);
|
|
152
|
+
* await this.set("items", [1, null, 3]); // Also works
|
|
146
153
|
*
|
|
147
|
-
* //
|
|
148
|
-
* await this.set("
|
|
154
|
+
* // ✅ Maps and Sets are supported
|
|
155
|
+
* await this.set("mapping", new Map([["key", "value"]]));
|
|
156
|
+
* await this.set("tags", new Set(["tag1", "tag2"]));
|
|
149
157
|
*
|
|
150
158
|
* // ❌ WRONG: Cannot store functions directly
|
|
151
159
|
* await this.set("handler", this.myHandler);
|
|
@@ -159,9 +167,9 @@ export class Tool {
|
|
|
159
167
|
* await this.run(token, args);
|
|
160
168
|
* ```
|
|
161
169
|
*
|
|
162
|
-
* @template T - The type of value being stored
|
|
170
|
+
* @template T - The type of value being stored (must be Serializable)
|
|
163
171
|
* @param key - The storage key to use
|
|
164
|
-
* @param value - The value to store (must be
|
|
172
|
+
* @param value - The value to store (must be SuperJSON-serializable)
|
|
165
173
|
* @returns Promise that resolves when the value is stored
|
|
166
174
|
*/
|
|
167
175
|
async set(key, value) {
|
package/dist/tool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,MAAM,OAAgB,KAAK;CAAG;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAgB,IAAI;IAEZ;IACA;IACF;IAHV,YACY,EAAU,EACV,OAA4B,EAC9B,QAAkB;QAFhB,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAqB;QAC9B,aAAQ,GAAR,QAAQ,CAAU;IACzB,CAAC;IAEJ;;;OAGG;IACH,IAAc,KAAK;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAqB,CAAC;IACrD,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,6DAA6D;IAC7D,KAAK,CAAC,KAAkB;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;;;;;;;;OAaG;IACO,KAAK,CAAC,QAAQ,CAGtB,EAAM,EAAE,GAAG,SAAgB;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,cAAc,CAAC,KAAe;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,kBAAkB;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,GAAG,CAAC,KAAe,EAAE,GAAG,IAAW;QACjD,OAAO,IAAI,CAAC,KAAK,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IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,6DAA6D;IAC7D,YAAY,CAAC,QAAkB;QAC7B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,UAAU;QACR,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,WAAW;QACT,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;;OAQG;IACH,aAAa;QACX,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;;;;OAOG;IACH,cAAc;QACZ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ITool } from "..";
|
|
2
|
-
import
|
|
3
|
-
export type { CallbackMethods, NoFunctions, NonFunction };
|
|
2
|
+
import { Serializable } from "../utils/types";
|
|
4
3
|
/**
|
|
5
4
|
* Represents a callback token for persistent function references.
|
|
6
5
|
*
|
|
7
6
|
* Callbacks enable tools and twists to create persistent references to functions
|
|
8
7
|
* that can survive worker restarts and be invoked across different execution contexts.
|
|
9
8
|
*
|
|
10
|
-
* This is a branded
|
|
9
|
+
* This is a branded strin
|
|
10
|
+
* type to prevent mixing callback tokens with regular strings.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```typescript
|
|
@@ -58,19 +58,21 @@ export declare abstract class Callbacks extends ITool {
|
|
|
58
58
|
* Creates a persistent callback to a method on the current class.
|
|
59
59
|
*
|
|
60
60
|
* @param fn - The function to callback
|
|
61
|
-
* @param extraArgs - Additional arguments to pass to the function
|
|
61
|
+
* @param extraArgs - Additional arguments to pass to the function after any passed by the caller
|
|
62
62
|
* @returns Promise resolving to a persistent callback token
|
|
63
63
|
*/
|
|
64
|
-
abstract create<
|
|
64
|
+
abstract create<TArgs extends Serializable[], F extends (...extraArgs: TArgs) => any>(fn: F, ...extraArgs: TArgs): Promise<Callback>;
|
|
65
|
+
abstract create<TArgs extends Serializable[], F extends (arg1: any, ...extraArgs: TArgs) => any>(fn: F, ...extraArgs: TArgs): Promise<Callback>;
|
|
65
66
|
/**
|
|
66
67
|
* Creates a persistent callback to a function from the parent twist/tool.
|
|
67
68
|
* Use this when the callback function is passed in from outside this class.
|
|
68
69
|
*
|
|
69
70
|
* @param fn - The function to callback
|
|
70
|
-
* @param extraArgs - Additional arguments to pass to the function
|
|
71
|
-
* @returns Promise resolving to a
|
|
71
|
+
* @param extraArgs - Additional arguments to pass to the function after any passed by the caller
|
|
72
|
+
* @returns Promise resolving to a callback token
|
|
72
73
|
*/
|
|
73
|
-
abstract createFromParent(fn:
|
|
74
|
+
abstract createFromParent<TArgs extends Serializable[], F extends (...extraArgs: TArgs) => any>(fn: F, ...extraArgs: TArgs): Promise<Callback>;
|
|
75
|
+
abstract createFromParent<TArgs extends Serializable[], F extends (arg1: any, ...extraArgs: TArgs) => any>(fn: F, ...extraArgs: TArgs): Promise<Callback>;
|
|
74
76
|
/**
|
|
75
77
|
* Deletes a specific callback by its token.
|
|
76
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../src/tools/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../src/tools/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,QAAQ,GAA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nC;;;;;;OAMG;IAEH,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;CAC1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../src/tools/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../src/tools/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAmB3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAgB,SAAU,SAAQ,KAAK;CA8E5C"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type ActivityLink, ITool } from "..";
|
|
2
|
-
import { type NoFunctions } from "./callbacks";
|
|
1
|
+
import { type ActivityLink, ITool, Serializable } from "..";
|
|
3
2
|
/**
|
|
4
3
|
* Built-in tool for managing OAuth authentication flows.
|
|
5
4
|
*
|
|
@@ -50,11 +49,11 @@ export declare abstract class Integrations extends ITool {
|
|
|
50
49
|
* @param extraArgs - Additional arguments to pass to the callback (type-checked, must be serializable)
|
|
51
50
|
* @returns Promise resolving to an ActivityLink for the auth flow
|
|
52
51
|
*/
|
|
53
|
-
abstract request<TCallback extends (auth: Authorization, ...args:
|
|
52
|
+
abstract request<TArgs extends Serializable[], TCallback extends (auth: Authorization, ...args: TArgs) => any>(auth: {
|
|
54
53
|
provider: AuthProvider;
|
|
55
54
|
level: AuthLevel;
|
|
56
55
|
scopes: string[];
|
|
57
|
-
}, callback: TCallback, ...extraArgs:
|
|
56
|
+
}, callback: TCallback, ...extraArgs: TArgs): Promise<ActivityLink>;
|
|
58
57
|
/**
|
|
59
58
|
* Retrieves an access token (refreshing it first if necessary).
|
|
60
59
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,8BAAsB,YAAa,SAAQ,KAAK;IAC9C;;;;;;;;;;;;;;OAcG;IAEH,QAAQ,CAAC,OAAO,CACd,KAAK,SAAS,YAAY,EAAE,EAC5B,SAAS,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,GAAG,EAE9D,IAAI,EAAE;QACJ,QAAQ,EAAE,YAAY,CAAC;QACvB,KAAK,EAAE,SAAS,CAAC;QACjB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,EACD,QAAQ,EAAE,SAAS,EACnB,GAAG,SAAS,EAAE,KAAK,GAClB,OAAO,CAAC,YAAY,CAAC;IAExB;;;;;;;OAOG;IAEH,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;CACtE;AAED;;;;;GAKG;AACH,oBAAY,YAAY;IACtB,0DAA0D;IAC1D,MAAM,WAAW;IACjB,0DAA0D;IAC1D,SAAS,cAAc;IACvB,kDAAkD;IAClD,MAAM,WAAW;IACjB,gDAAgD;IAChD,KAAK,UAAU;IACf,uDAAuD;IACvD,SAAS,cAAc;IACvB,kDAAkD;IAClD,MAAM,WAAW;IACjB,gCAAgC;IAChC,MAAM,WAAW;IACjB,sEAAsE;IACtE,MAAM,WAAW;IACjB,gDAAgD;IAChD,KAAK,UAAU;IACf,6CAA6C;IAC7C,OAAO,YAAY;CACpB;AAED;;;;GAIG;AACH,oBAAY,SAAS;IACnB,uEAAuE;IACvE,QAAQ,aAAa;IACrB,6DAA6D;IAC7D,IAAI,SAAS;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,QAAQ,EAAE,YAAY,CAAC;IACvB,sDAAsD;IACtD,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/tools/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAgB,MAAM,IAAI,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;CAwC/C;AAED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,YAqBX;AArBD,WAAY,YAAY;IACtB,0DAA0D;IAC1D,iCAAiB,CAAA;IACjB,0DAA0D;IAC1D,uCAAuB,CAAA;IACvB,kDAAkD;IAClD,iCAAiB,CAAA;IACjB,gDAAgD;IAChD,+BAAe,CAAA;IACf,uDAAuD;IACvD,uCAAuB,CAAA;IACvB,kDAAkD;IAClD,iCAAiB,CAAA;IACjB,gCAAgC;IAChC,iCAAiB,CAAA;IACjB,sEAAsE;IACtE,iCAAiB,CAAA;IACjB,gDAAgD;IAChD,+BAAe,CAAA;IACf,6CAA6C;IAC7C,mCAAmB,CAAA;AACrB,CAAC,EArBW,YAAY,KAAZ,YAAY,QAqBvB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,uEAAuE;IACvE,kCAAqB,CAAA;IACrB,6DAA6D;IAC7D,0BAAa,CAAA;AACf,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB"}
|
package/dist/tools/network.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ITool } from "..";
|
|
2
|
+
import { type JSONValue, Serializable } from "../utils/types";
|
|
2
3
|
import { type AuthProvider, type Authorization } from "./integrations";
|
|
3
4
|
/**
|
|
4
5
|
* Represents an incoming webhook request.
|
|
@@ -25,7 +26,7 @@ export type WebhookRequest = {
|
|
|
25
26
|
/** Query string parameters from the request URL */
|
|
26
27
|
params: Record<string, string>;
|
|
27
28
|
/** Request body (parsed as JSON if applicable) */
|
|
28
|
-
body:
|
|
29
|
+
body: JSONValue;
|
|
29
30
|
/** Raw request body (for signature verification) */
|
|
30
31
|
rawBody?: string;
|
|
31
32
|
};
|
|
@@ -82,10 +83,12 @@ export type WebhookRequest = {
|
|
|
82
83
|
*
|
|
83
84
|
* async setupCalendarWebhook(calendarId: string) {
|
|
84
85
|
* // Create webhook URL that will call onCalendarEvent
|
|
85
|
-
* const webhookUrl = await this.tools.network.createWebhook(
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
86
|
+
* const webhookUrl = await this.tools.network.createWebhook(
|
|
87
|
+
* {},
|
|
88
|
+
* this.onCalendarEvent,
|
|
89
|
+
* calendarId,
|
|
90
|
+
* "google"
|
|
91
|
+
* );
|
|
89
92
|
*
|
|
90
93
|
* // Register webhook with Google Calendar API
|
|
91
94
|
* await this.registerWithGoogleCalendar(calendarId, webhookUrl);
|
|
@@ -133,21 +136,23 @@ export declare abstract class Network extends ITool {
|
|
|
133
136
|
* - **Default**: Returns a standard webhook URL for all other cases.
|
|
134
137
|
*
|
|
135
138
|
* @param options - Webhook creation options
|
|
136
|
-
* @param options.callback - Function receiving (request, ...extraArgs)
|
|
137
|
-
* @param options.extraArgs - Additional arguments to pass to the callback (type-checked)
|
|
138
139
|
* @param options.provider - Optional provider for provider-specific webhook routing
|
|
139
140
|
* @param options.authorization - Optional authorization for provider-specific webhooks (required for Slack and Gmail)
|
|
141
|
+
* @param callback - Function receiving (request, ...extraArgs)
|
|
142
|
+
* @param extraArgs - Additional arguments to pass to the callback (type-checked, no functions allowed)
|
|
140
143
|
* @returns Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name
|
|
141
144
|
*
|
|
142
145
|
* @example
|
|
143
146
|
* ```typescript
|
|
144
147
|
* // Gmail webhook - returns Pub/Sub topic name
|
|
145
|
-
* const topicName = await this.tools.network.createWebhook(
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
148
|
+
* const topicName = await this.tools.network.createWebhook(
|
|
149
|
+
* {
|
|
150
|
+
* provider: AuthProvider.Google,
|
|
151
|
+
* authorization: gmailAuth
|
|
152
|
+
* },
|
|
153
|
+
* this.onGmailNotification,
|
|
154
|
+
* "inbox"
|
|
155
|
+
* );
|
|
151
156
|
* // topicName: "projects/plot-prod/topics/gmail-webhook-abc123"
|
|
152
157
|
*
|
|
153
158
|
* // Pass topic name to Gmail API
|
|
@@ -160,12 +165,10 @@ export declare abstract class Network extends ITool {
|
|
|
160
165
|
* });
|
|
161
166
|
* ```
|
|
162
167
|
*/
|
|
163
|
-
abstract createWebhook<TCallback extends (request: WebhookRequest, ...args:
|
|
164
|
-
callback: TCallback;
|
|
165
|
-
extraArgs?: TCallback extends (req: any, ...rest: infer R) => any ? R : [];
|
|
168
|
+
abstract createWebhook<TArgs extends Serializable[], TCallback extends (request: WebhookRequest, ...args: TArgs) => any>(options: {
|
|
166
169
|
provider?: AuthProvider;
|
|
167
170
|
authorization?: Authorization;
|
|
168
|
-
}): Promise<string>;
|
|
171
|
+
}, callback: TCallback, ...extraArgs: TArgs): Promise<string>;
|
|
169
172
|
/**
|
|
170
173
|
* Deletes an existing webhook endpoint.
|
|
171
174
|
*
|