@plotday/twister 0.22.0 → 0.26.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 (169) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -6
  3. package/bin/commands/deploy.js +234 -2
  4. package/bin/commands/deploy.js.map +1 -1
  5. package/bin/commands/generate.js +11 -2
  6. package/bin/commands/generate.js.map +1 -1
  7. package/bin/commands/login.js +19 -3
  8. package/bin/commands/login.js.map +1 -1
  9. package/bin/commands/priority-create.js +7 -2
  10. package/bin/commands/priority-create.js.map +1 -1
  11. package/bin/commands/priority-list.js +6 -1
  12. package/bin/commands/priority-list.js.map +1 -1
  13. package/bin/commands/twist-logs.js +12 -3
  14. package/bin/commands/twist-logs.js.map +1 -1
  15. package/bin/templates/AGENTS.template.md +109 -20
  16. package/bin/utils/bundle.js +40 -0
  17. package/bin/utils/bundle.js.map +1 -1
  18. package/bin/utils/network-error.js +149 -0
  19. package/bin/utils/network-error.js.map +1 -0
  20. package/cli/templates/AGENTS.template.md +109 -20
  21. package/dist/common/calendar.d.ts +10 -2
  22. package/dist/common/calendar.d.ts.map +1 -1
  23. package/dist/common/projects.d.ts +123 -0
  24. package/dist/common/projects.d.ts.map +1 -0
  25. package/dist/common/projects.js +2 -0
  26. package/dist/common/projects.js.map +1 -0
  27. package/dist/docs/assets/hierarchy.js +1 -1
  28. package/dist/docs/assets/highlight.css +4 -4
  29. package/dist/docs/assets/navigation.js +1 -1
  30. package/dist/docs/assets/search.js +1 -1
  31. package/dist/docs/classes/tool.Tool.html +5 -5
  32. package/dist/docs/classes/tools_ai.AI.html +3 -3
  33. package/dist/docs/classes/tools_callbacks.Callbacks.html +4 -4
  34. package/dist/docs/classes/tools_integrations.Integrations.html +1 -1
  35. package/dist/docs/classes/tools_network.Network.html +4 -4
  36. package/dist/docs/classes/tools_plot.Plot.html +28 -14
  37. package/dist/docs/classes/tools_store.Store.html +1 -1
  38. package/dist/docs/classes/tools_tasks.Tasks.html +2 -2
  39. package/dist/docs/classes/tools_twists.Twists.html +4 -4
  40. package/dist/docs/classes/twist.Twist.html +1 -1
  41. package/dist/docs/documents/Building_Custom_Tools.html +6 -6
  42. package/dist/docs/documents/Built-in_Tools.html +24 -17
  43. package/dist/docs/documents/Core_Concepts.html +42 -9
  44. package/dist/docs/documents/Getting_Started.html +10 -3
  45. package/dist/docs/documents/Runtime_Environment.html +7 -7
  46. package/dist/docs/enums/plot.ActivityLinkType.html +5 -5
  47. package/dist/docs/enums/plot.ActivityType.html +4 -4
  48. package/dist/docs/enums/plot.ActorType.html +4 -4
  49. package/dist/docs/enums/plot.ConferencingProvider.html +6 -6
  50. package/dist/docs/enums/tag.Tag.html +3 -4
  51. package/dist/docs/enums/tools_plot.ActivityAccess.html +3 -3
  52. package/dist/docs/enums/tools_plot.ContactAccess.html +3 -3
  53. package/dist/docs/enums/tools_plot.PriorityAccess.html +3 -3
  54. package/dist/docs/hierarchy.html +1 -1
  55. package/dist/docs/interfaces/common_calendar.CalendarTool.html +13 -7
  56. package/dist/docs/interfaces/tools_ai.AIResponse.html +2 -2
  57. package/dist/docs/interfaces/tools_twists.TwistSource.html +1 -1
  58. package/dist/docs/modules/index.html +1 -1
  59. package/dist/docs/modules/plot.html +1 -1
  60. package/dist/docs/types/plot.Activity.html +28 -7
  61. package/dist/docs/types/plot.ActivityCommon.html +10 -8
  62. package/dist/docs/types/plot.ActivityLink.html +1 -1
  63. package/dist/docs/types/plot.ActivityMeta.html +24 -6
  64. package/dist/docs/types/plot.ActivityUpdate.html +2 -2
  65. package/dist/docs/types/plot.ActivityWithNotes.html +1 -1
  66. package/dist/docs/types/plot.Actor.html +5 -5
  67. package/dist/docs/types/plot.ActorId.html +8 -3
  68. package/dist/docs/types/plot.ContentType.html +1 -0
  69. package/dist/docs/types/plot.NewActivity.html +18 -3
  70. package/dist/docs/types/plot.NewActivityWithNotes.html +1 -1
  71. package/dist/docs/types/plot.NewContact.html +4 -4
  72. package/dist/docs/types/plot.NewNote.html +9 -3
  73. package/dist/docs/types/plot.NewPriority.html +1 -1
  74. package/dist/docs/types/plot.Note.html +3 -3
  75. package/dist/docs/types/plot.NoteUpdate.html +4 -4
  76. package/dist/docs/types/plot.PickPriorityConfig.html +3 -3
  77. package/dist/docs/types/plot.Priority.html +3 -3
  78. package/dist/docs/types/plot.Tags.html +1 -0
  79. package/dist/docs/types/tools_ai.DataContent.html +1 -1
  80. package/dist/docs/types/tools_network.WebhookRequest.html +5 -3
  81. package/dist/docs/types/tools_plot.NoteIntentHandler.html +4 -4
  82. package/dist/llm-docs/common/calendar.d.ts +2 -2
  83. package/dist/llm-docs/common/calendar.d.ts.map +1 -1
  84. package/dist/llm-docs/common/calendar.js +2 -2
  85. package/dist/llm-docs/common/calendar.js.map +1 -1
  86. package/dist/llm-docs/common/messaging.d.ts +1 -1
  87. package/dist/llm-docs/common/messaging.js +1 -1
  88. package/dist/llm-docs/common/projects.d.ts +9 -0
  89. package/dist/llm-docs/common/projects.d.ts.map +1 -0
  90. package/dist/llm-docs/common/projects.js +8 -0
  91. package/dist/llm-docs/common/projects.js.map +1 -0
  92. package/dist/llm-docs/index.d.ts +1 -1
  93. package/dist/llm-docs/index.js +17 -17
  94. package/dist/llm-docs/index.js.map +1 -1
  95. package/dist/llm-docs/plot.d.ts +2 -2
  96. package/dist/llm-docs/plot.d.ts.map +1 -1
  97. package/dist/llm-docs/plot.js +2 -2
  98. package/dist/llm-docs/plot.js.map +1 -1
  99. package/dist/llm-docs/tag.d.ts +2 -2
  100. package/dist/llm-docs/tag.d.ts.map +1 -1
  101. package/dist/llm-docs/tag.js +2 -2
  102. package/dist/llm-docs/tag.js.map +1 -1
  103. package/dist/llm-docs/tool.d.ts +2 -2
  104. package/dist/llm-docs/tool.d.ts.map +1 -1
  105. package/dist/llm-docs/tool.js +2 -2
  106. package/dist/llm-docs/tool.js.map +1 -1
  107. package/dist/llm-docs/tools/ai.d.ts +2 -2
  108. package/dist/llm-docs/tools/ai.d.ts.map +1 -1
  109. package/dist/llm-docs/tools/ai.js +2 -2
  110. package/dist/llm-docs/tools/ai.js.map +1 -1
  111. package/dist/llm-docs/tools/callbacks.d.ts +2 -2
  112. package/dist/llm-docs/tools/callbacks.d.ts.map +1 -1
  113. package/dist/llm-docs/tools/callbacks.js +2 -2
  114. package/dist/llm-docs/tools/callbacks.js.map +1 -1
  115. package/dist/llm-docs/tools/integrations.d.ts +1 -1
  116. package/dist/llm-docs/tools/integrations.js +1 -1
  117. package/dist/llm-docs/tools/network.d.ts +2 -2
  118. package/dist/llm-docs/tools/network.d.ts.map +1 -1
  119. package/dist/llm-docs/tools/network.js +2 -2
  120. package/dist/llm-docs/tools/network.js.map +1 -1
  121. package/dist/llm-docs/tools/plot.d.ts +2 -2
  122. package/dist/llm-docs/tools/plot.d.ts.map +1 -1
  123. package/dist/llm-docs/tools/plot.js +2 -2
  124. package/dist/llm-docs/tools/plot.js.map +1 -1
  125. package/dist/llm-docs/tools/store.d.ts +1 -1
  126. package/dist/llm-docs/tools/store.js +1 -1
  127. package/dist/llm-docs/tools/tasks.d.ts +1 -1
  128. package/dist/llm-docs/tools/tasks.js +1 -1
  129. package/dist/llm-docs/tools/twists.d.ts +2 -2
  130. package/dist/llm-docs/tools/twists.d.ts.map +1 -1
  131. package/dist/llm-docs/tools/twists.js +2 -2
  132. package/dist/llm-docs/tools/twists.js.map +1 -1
  133. package/dist/llm-docs/twist-guide-template.d.ts +1 -1
  134. package/dist/llm-docs/twist-guide-template.d.ts.map +1 -1
  135. package/dist/llm-docs/twist-guide-template.js +1 -1
  136. package/dist/llm-docs/twist-guide-template.js.map +1 -1
  137. package/dist/llm-docs/twist.d.ts +1 -1
  138. package/dist/llm-docs/twist.js +1 -1
  139. package/dist/plot.d.ts +203 -35
  140. package/dist/plot.d.ts.map +1 -1
  141. package/dist/plot.js.map +1 -1
  142. package/dist/tag.d.ts +2 -3
  143. package/dist/tag.d.ts.map +1 -1
  144. package/dist/tag.js +2 -3
  145. package/dist/tag.js.map +1 -1
  146. package/dist/tool.d.ts +2 -2
  147. package/dist/tool.d.ts.map +1 -1
  148. package/dist/tool.js +1 -1
  149. package/dist/tool.js.map +1 -1
  150. package/dist/tools/ai.d.ts +2 -2
  151. package/dist/tools/ai.d.ts.map +1 -1
  152. package/dist/tools/callbacks.d.ts +1 -1
  153. package/dist/tools/callbacks.d.ts.map +1 -1
  154. package/dist/tools/network.d.ts +2 -0
  155. package/dist/tools/network.d.ts.map +1 -1
  156. package/dist/tools/network.js.map +1 -1
  157. package/dist/tools/plot.d.ts +36 -4
  158. package/dist/tools/plot.d.ts.map +1 -1
  159. package/dist/tools/plot.js.map +1 -1
  160. package/dist/tools/twists.d.ts +2 -2
  161. package/dist/twist-guide.d.ts +1 -1
  162. package/dist/twist-guide.d.ts.map +1 -1
  163. package/package.json +52 -2
  164. package/tsconfig.base.json +1 -0
  165. package/dist/docs/types/plot.NoteType.html +0 -1
  166. package/dist/llm-docs/creator-docs.d.ts +0 -9
  167. package/dist/llm-docs/creator-docs.d.ts.map +0 -1
  168. package/dist/llm-docs/creator-docs.js +0 -8
  169. package/dist/llm-docs/creator-docs.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/plot
2
+ * Generated LLM documentation for @plotday/twister/plot
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- declare const _default: "import { type Tag } from \"./tag\";\nimport { type Callback } from \"./tools/callbacks\";\n\nexport { Tag } from \"./tag\";\n\n/**\n * Represents a unique user, contact, or twist in Plot.\n *\n * Note contacts (i.e. people not using Plot) are also represented by ActorIds. They may be\n * people interacting with other connected services (e.g. an email sender or event attendee).\n */\nexport type ActorId = string & { readonly __brand: \"ActorId\" };\n\n/**\n * Represents a priority context within Plot.\n *\n * Priorities are similar to projects in other apps. All Activity is in a Priority.\n * Priorities can be nested.\n */\nexport type Priority = {\n /** Unique identifier for the priority */\n id: string;\n /** Human-readable title for the priority */\n title: string;\n};\n\n/**\n * Type for creating new priorities.\n *\n * Excludes the auto-generated ID field and adds an optional parentId\n * for creating hierarchical priority structures.\n */\nexport type NewPriority = Omit<Priority, \"id\"> & {\n /** Optional ID of the parent priority for creating hierarchies */\n parentId?: string;\n};\n\n/**\n * Enumeration of supported activity types in Plot.\n *\n * Each activity type has different behaviors and rendering characteristics\n * within the Plot application.\n */\nexport enum ActivityType {\n /** A note or piece of information without actionable requirements */\n Note,\n /** An actionable item that can be completed */\n Action,\n /** A scheduled occurrence with start and optional end time */\n Event,\n}\n\n/**\n * Enumeration of supported activity link types.\n *\n * Different link types have different behaviors when clicked by users\n * and may require different rendering approaches.\n */\nexport enum ActivityLinkType {\n /** External web links that open in browser */\n external = \"external\",\n /** Authentication flows for connecting services */\n auth = \"auth\",\n /** Callback links that trigger twist methods when clicked */\n callback = \"callback\",\n /** Video conferencing links with provider-specific handling */\n conferencing = \"conferencing\",\n}\n\n/**\n * Video conferencing providers for conferencing links.\n *\n * Used to identify the conferencing platform and provide\n * provider-specific UI elements (titles, icons, etc.).\n */\nexport enum ConferencingProvider {\n /** Google Meet */\n googleMeet = \"googleMeet\",\n /** Zoom */\n zoom = \"zoom\",\n /** Microsoft Teams */\n microsoftTeams = \"microsoftTeams\",\n /** Cisco Webex */\n webex = \"webex\",\n /** Other or unknown conferencing provider */\n other = \"other\",\n}\n\n/**\n * Represents a clickable link attached to an activity.\n *\n * Activity links are rendered as buttons that enable user interaction with activities.\n * Different link types have specific behaviors and required fields for proper functionality.\n *\n * @example\n * ```typescript\n * // External link - opens URL in browser\n * const externalLink: ActivityLink = {\n * type: ActivityLinkType.external,\n * title: \"Open in Google Calendar\",\n * url: \"https://calendar.google.com/event/123\",\n * };\n *\n * // Conferencing link - opens video conference with provider info\n * const conferencingLink: ActivityLink = {\n * type: ActivityLinkType.conferencing,\n * url: \"https://meet.google.com/abc-defg-hij\",\n * provider: ConferencingProvider.googleMeet,\n * };\n *\n * // Integrations link - initiates OAuth flow\n * const authLink: ActivityLink = {\n * type: ActivityLinkType.auth,\n * title: \"Continue with Google\",\n * provider: AuthProvider.Google,\n * level: AuthLevel.User,\n * scopes: [\"https://www.googleapis.com/auth/calendar.readonly\"],\n * callback: \"callback-token-for-auth-completion\"\n * };\n *\n * // Callback link - triggers a twist method\n * const callbackLink: ActivityLink = {\n * type: ActivityLinkType.callback,\n * title: \"\uD83D\uDCC5 Primary Calendar\",\n * token: \"callback-token-here\"\n * };\n * ```\n */\nexport type ActivityLink =\n | {\n /** External web link that opens in browser */\n type: ActivityLinkType.external;\n /** Display text for the link button */\n title: string;\n /** URL to open when clicked */\n url: string;\n }\n | {\n /** Video conferencing link with provider-specific handling */\n type: ActivityLinkType.conferencing;\n /** URL to join the conference */\n url: string;\n /** Conferencing provider for UI customization */\n provider: ConferencingProvider;\n }\n | {\n /** Authentication link that initiates an OAuth flow */\n type: ActivityLinkType.auth;\n /** Display text for the auth button */\n title: string;\n /** OAuth provider (e.g., \"google\", \"microsoft\") */\n provider: string;\n /** Authorization level (\"user\" or \"priority\") */\n level: string;\n /** Array of OAuth scopes to request */\n scopes: string[];\n /** Callback token for auth completion notification */\n callback: Callback;\n }\n | {\n /** Callback link that triggers a twist method when clicked */\n type: ActivityLinkType.callback;\n /** Display text for the callback button */\n title: string;\n /** Token identifying the callback to execute */\n callback: Callback;\n };\n\n/**\n * Represents metadata about an activity, typically from an external system.\n *\n * Activity metadata enables tracking where activities originated from,\n * which is useful for synchronization, deduplication, and linking\n * back to external systems.\n *\n * @example\n * ```typescript\n * const googleCalendarMeta: ActivityMeta = {\n * type: \"google-calendar-event\",\n * id: \"event-123\",\n * calendarId: \"primary\",\n * htmlLink: \"https://calendar.google.com/event/123\"\n * };\n * ```\n */\nexport type ActivityMeta = {\n /** The type identifier for the source system */\n source: string;\n /** Additional source-specific properties */\n [key: string]: any;\n};\n\n/**\n * Represents a complete activity within the Plot system.\n *\n * Activities are the core entities in Plot, representing anything from simple notes\n * to complex recurring events. They support rich metadata including scheduling,\n * recurrence patterns, links, and external source tracking.\n *\n * @example\n * ```typescript\n * // Simple note\n * const task: Activity = {\n * type: ActivityType.Note,\n * title: \"New campaign brainstorming ideas\",\n * note: \"We could rent a bouncy castle...\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Simple action\n * const action: Activity = {\n * type: ActivityType.Action,\n * title: \"Review budget proposal\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Recurring event\n * const meeting: Activity = {\n * type: ActivityType.Event,\n * title: \"Weekly standup\",\n * recurrenceRule: \"FREQ=WEEKLY;BYDAY=MO\",\n * recurrenceCount: 12,\n * // ... other fields\n * };\n * ```\n */\nexport type ActivityCommon = {\n /** Unique identifier for the activity */\n id: string;\n /** Information about who created the activity */\n author: Actor;\n /** Whether this activity is in draft state (not shown in do now view) */\n draft: boolean;\n /** Whether this activity is private (only visible to author) */\n private: boolean;\n /** Tags attached to this activity. Maps tag ID to array of actor IDs who added that tag. */\n tags: Partial<Record<Tag, ActorId[]>> | null;\n /** Array of actor IDs (users, contacts, or twists) mentioned in this activity via @-mentions */\n mentions: ActorId[] | null;\n};\n\nexport type Activity = ActivityCommon & {\n /** The display title/summary of the activity */\n title: string | null;\n /** The type of activity (Note, Task, or Event) */\n type: ActivityType;\n /** Who this activity note is assigned to */\n assignee: Actor | null;\n /** Timestamp when the activity was marked as complete. Null if not completed. */\n doneAt: Date | null;\n /**\n * Start time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the start of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for activities without scheduled start times.\n */\n start: Date | string | null;\n /**\n * End time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the end of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for tasks or activities without defined end times.\n */\n end: Date | string | null;\n /**\n * For recurring activities, the last occurrence date (inclusive).\n * Can be a Date object, date string in \"YYYY-MM-DD\" format, or null if recurring indefinitely.\n * When both recurrenceCount and recurrenceUntil are provided, recurrenceCount takes precedence.\n */\n recurrenceUntil: Date | string | null;\n /**\n * For recurring activities, the number of occurrences to generate.\n * Takes precedence over recurrenceUntil if both are provided.\n * Null for non-recurring activities or indefinite recurrence.\n */\n recurrenceCount: number | null;\n /** The priority context this activity belongs to */\n priority: Priority;\n /** Recurrence rule in RFC 5545 RRULE format (e.g., \"FREQ=WEEKLY;BYDAY=MO,WE,FR\") */\n recurrenceRule: string | null;\n /** Array of dates to exclude from the recurrence pattern */\n recurrenceExdates: Date[] | null;\n /** Array of additional occurrence dates to include in the recurrence pattern */\n recurrenceDates: Date[] | null;\n /**\n * For recurring event exceptions, points to the root recurring activity.\n * Used when an individual occurrence of a recurring event is modified.\n */\n recurrence: Activity | null;\n /**\n * For recurring event exceptions, the original occurrence date being overridden.\n * Used to identify which occurrence of a recurring event this exception replaces.\n */\n occurrence: Date | null;\n /** Metadata about the activity, typically from an external system that created it */\n meta: ActivityMeta | null;\n};\n\nexport type ActivityWithNotes = Activity & {\n notes: Note[];\n};\n\nexport type NewActivityWithNotes = NewActivity & {\n notes: Omit<NewNote, \"activity\">[];\n};\n\n/**\n * Configuration for automatic priority selection based on activity similarity.\n *\n * Maps activity fields to scoring weights or required exact matches:\n * - Number value: Maximum score for similarity matching on this field\n * - `true` value: Required exact match - activities must match exactly or be excluded\n *\n * Scoring rules:\n * - content: Uses vector similarity on activity embedding (cosine similarity)\n * - type: Exact match on ActivityType\n * - mentions: Percentage of existing activity's mentions that appear in new activity\n * - meta.field: Exact match on top-level meta fields (e.g., \"meta.sourceId\")\n *\n * When content is `true`, applies a strong similarity threshold to ensure only close matches.\n * Default (when neither priority nor pickPriority specified): `{content: true}`\n *\n * @example\n * ```typescript\n * // Require exact content match with strong similarity\n * pickPriority: { content: true }\n *\n * // Score based on content (max 100 points) and require exact type match\n * pickPriority: { content: 100, type: true }\n *\n * // Match on meta source and score content\n * pickPriority: { \"meta.source\": true, content: 50 }\n * ```\n */\nexport type PickPriorityConfig = {\n content?: number | true;\n type?: number | true;\n mentions?: number | true;\n [key: `meta.${string}`]: number | true;\n};\n\n/**\n * Type for creating new activities.\n *\n * Requires only the activity type, with all other fields optional.\n * The ID and author will be automatically assigned by the Plot system\n * based on the current execution context.\n *\n * Priority can be specified in three ways:\n * 1. Explicit priority: `priority: { id: \"...\" }` - Use specific priority (disables pickPriority)\n * 2. Pick priority config: `pickPriority: { ... }` - Auto-select based on similarity\n * 3. Neither: Defaults to `pickPriority: { content: true }` for automatic matching\n *\n * @example\n * ```typescript\n * // Explicit priority (disables automatic matching)\n * const newTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review pull request\",\n * priority: { id: \"work-project-123\" }\n * };\n *\n * // Automatic priority matching (default behavior)\n * const newNote: NewActivity = {\n * type: ActivityType.Note,\n * title: \"Meeting notes\",\n * note: \"Discussed Q4 roadmap...\"\n * // Defaults to pickPriority: { content: true }\n * };\n *\n * // Custom priority matching\n * const newEvent: NewActivity = {\n * type: ActivityType.Event,\n * title: \"Team standup\",\n * pickPriority: { type: true, content: 50 }\n * };\n * ```\n */\nexport type NewActivity = Pick<Activity, \"type\"> &\n Partial<Omit<Activity, \"id\" | \"author\" | \"type\" | \"priority\" | \"mentions\">> &\n (\n | {\n /** Explicit priority (required when specified) - disables automatic priority matching */\n priority: Pick<Priority, \"id\">;\n }\n | {\n /** Configuration for automatic priority selection based on similarity */\n pickPriority?: PickPriorityConfig;\n }\n | {}\n );\n\nexport type ActivityUpdate = Pick<Activity, \"id\"> &\n Partial<\n Pick<\n Activity,\n | \"type\"\n | \"start\"\n | \"end\"\n | \"doneAt\"\n | \"title\"\n | \"draft\"\n | \"private\"\n | \"meta\"\n | \"recurrenceRule\"\n | \"recurrenceDates\"\n | \"recurrenceExdates\"\n | \"recurrenceUntil\"\n | \"recurrenceCount\"\n | \"occurrence\"\n >\n > & {\n /**\n * Full tags object from Activity. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for activities created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other activities.\n */\n tags?: Partial<Record<Tag, ActorId[]>>;\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all activities the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents a note within an activity.\n *\n * Notes contain the detailed content (note text, links) associated with an activity.\n * They are always ordered by creation time within their parent activity.\n */\nexport type Note = Omit<ActivityCommon, \"type\"> & {\n /** The parent activity this note belongs to */\n activity: Activity;\n /** Primary content for the note (markdown) */\n note: string | null;\n /** Array of interactive links attached to the note */\n links: Array<ActivityLink> | null;\n};\n\n/**\n * Type for creating new notes.\n *\n * Requires the activity reference, with all other fields optional.\n */\nexport type NewNote = Partial<Omit<Note, \"id\" | \"author\" | \"activity\">> & {\n /** Reference to the parent activity (required) */\n activity: Pick<Activity, \"id\">;\n\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n noteType?: NoteType;\n};\n\n/**\n * Type for updating existing notes.\n */\nexport type NoteUpdate = Pick<Note, \"id\"> &\n Partial<Pick<Note, \"draft\" | \"private\" | \"note\" | \"links\" | \"mentions\">> & {\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n noteType?: NoteType;\n\n /**\n * Full tags object from Note. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for notes created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other notes.\n */\n tags?: Partial<Record<Tag, ActorId[]>>;\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all notes the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents an actor in Plot - a user, contact, or twist.\n *\n * Actors can be associated with activities as authors, assignees, or mentions.\n * The email field is only included when ContactAccess.Read permission is granted.\n *\n * @example\n * ```typescript\n * const actor: Actor = {\n * id: \"f0ffd5f8-1635-4b13-9532-35f97446db90\" as ActorId,\n * type: ActorType.Contact,\n * email: \"john.doe@example.com\", // Only if ContactAccess.Read\n * name: \"John Doe\"\n * };\n * ```\n */\nexport type Actor = {\n /** Unique identifier for the actor */\n id: ActorId;\n /** Type of actor (User, Contact, or Twist) */\n type: ActorType;\n /** Email address (only included with ContactAccess.Read permission) */\n email?: string;\n /** Display name (undefined if not included due to permissions, null if not set) */\n name?: string | null;\n};\n\n/**\n * Enumeration of author types that can create activities.\n *\n * The author type affects how activities are displayed and processed\n * within the Plot system.\n */\nexport enum ActorType {\n /** Activities created by human users */\n User,\n /** Activities created by external contacts */\n Contact,\n /** Activities created by automated twists */\n Twist,\n}\n\n/**\n * Represents contact information for creating a new contact.\n *\n * Contacts are used throughout Plot for representing people associated\n * with activities, such as event attendees or task assignees.\n *\n * @example\n * ```typescript\n * const newContact: NewContact = {\n * email: \"john.doe@example.com\",\n * name: \"John Doe\",\n * avatar: \"https://avatar.example.com/john.jpg\"\n * };\n * ```\n */\nexport type NewContact = {\n /** Email address of the contact (required) */\n email: string;\n /** Optional display name for the contact */\n name?: string;\n /** Optional avatar image URL for the contact */\n avatar?: string;\n};\n\nexport type NoteType = \"text\" | \"markdown\" | \"html\";\n";
7
+ declare const _default: "import { type Tag } from \"./tag\";\nimport { type Callback } from \"./tools/callbacks\";\n\nexport { Tag } from \"./tag\";\n\n/**\n * Represents a unique user, contact, or twist in Plot.\n *\n * ActorIds are used throughout Plot for:\n * - Activity authors and assignees\n * - Tag creators (actor_id in activity_tag/note_tag)\n * - Mentions in activities and notes\n * - Any entity that can perform actions in Plot\n */\nexport type ActorId = string & { readonly __brand: \"ActorId\" };\n\n/**\n * Represents a priority context within Plot.\n *\n * Priorities are similar to projects in other apps. All Activity is in a Priority.\n * Priorities can be nested.\n */\nexport type Priority = {\n /** Unique identifier for the priority */\n id: string;\n /** Human-readable title for the priority */\n title: string;\n};\n\n/**\n * Type for creating new priorities.\n *\n * Excludes the auto-generated ID field and adds an optional parentId\n * for creating hierarchical priority structures.\n */\nexport type NewPriority = Omit<Priority, \"id\"> & {\n /** Optional ID of the parent priority for creating hierarchies */\n parentId?: string;\n};\n\n/**\n * Enumeration of supported activity types in Plot.\n *\n * Each activity type has different behaviors and rendering characteristics\n * within the Plot application.\n */\nexport enum ActivityType {\n /** A note or piece of information without actionable requirements */\n Note,\n /** An actionable item that can be completed */\n Action,\n /** A scheduled occurrence with start and optional end time */\n Event,\n}\n\n/**\n * Enumeration of supported activity link types.\n *\n * Different link types have different behaviors when clicked by users\n * and may require different rendering approaches.\n */\nexport enum ActivityLinkType {\n /** External web links that open in browser */\n external = \"external\",\n /** Authentication flows for connecting services */\n auth = \"auth\",\n /** Callback links that trigger twist methods when clicked */\n callback = \"callback\",\n /** Video conferencing links with provider-specific handling */\n conferencing = \"conferencing\",\n}\n\n/**\n * Video conferencing providers for conferencing links.\n *\n * Used to identify the conferencing platform and provide\n * provider-specific UI elements (titles, icons, etc.).\n */\nexport enum ConferencingProvider {\n /** Google Meet */\n googleMeet = \"googleMeet\",\n /** Zoom */\n zoom = \"zoom\",\n /** Microsoft Teams */\n microsoftTeams = \"microsoftTeams\",\n /** Cisco Webex */\n webex = \"webex\",\n /** Other or unknown conferencing provider */\n other = \"other\",\n}\n\n/**\n * Represents a clickable link attached to an activity.\n *\n * Activity links are rendered as buttons that enable user interaction with activities.\n * Different link types have specific behaviors and required fields for proper functionality.\n *\n * @example\n * ```typescript\n * // External link - opens URL in browser\n * const externalLink: ActivityLink = {\n * type: ActivityLinkType.external,\n * title: \"Open in Google Calendar\",\n * url: \"https://calendar.google.com/event/123\",\n * };\n *\n * // Conferencing link - opens video conference with provider info\n * const conferencingLink: ActivityLink = {\n * type: ActivityLinkType.conferencing,\n * url: \"https://meet.google.com/abc-defg-hij\",\n * provider: ConferencingProvider.googleMeet,\n * };\n *\n * // Integrations link - initiates OAuth flow\n * const authLink: ActivityLink = {\n * type: ActivityLinkType.auth,\n * title: \"Continue with Google\",\n * provider: AuthProvider.Google,\n * level: AuthLevel.User,\n * scopes: [\"https://www.googleapis.com/auth/calendar.readonly\"],\n * callback: \"callback-token-for-auth-completion\"\n * };\n *\n * // Callback link - triggers a twist method\n * const callbackLink: ActivityLink = {\n * type: ActivityLinkType.callback,\n * title: \"\uD83D\uDCC5 Primary Calendar\",\n * token: \"callback-token-here\"\n * };\n * ```\n */\nexport type ActivityLink =\n | {\n /** External web link that opens in browser */\n type: ActivityLinkType.external;\n /** Display text for the link button */\n title: string;\n /** URL to open when clicked */\n url: string;\n }\n | {\n /** Video conferencing link with provider-specific handling */\n type: ActivityLinkType.conferencing;\n /** URL to join the conference */\n url: string;\n /** Conferencing provider for UI customization */\n provider: ConferencingProvider;\n }\n | {\n /** Authentication link that initiates an OAuth flow */\n type: ActivityLinkType.auth;\n /** Display text for the auth button */\n title: string;\n /** OAuth provider (e.g., \"google\", \"microsoft\") */\n provider: string;\n /** Authorization level (\"user\" or \"priority\") */\n level: string;\n /** Array of OAuth scopes to request */\n scopes: string[];\n /** Callback token for auth completion notification */\n callback: Callback;\n }\n | {\n /** Callback link that triggers a twist method when clicked */\n type: ActivityLinkType.callback;\n /** Display text for the callback button */\n title: string;\n /** Token identifying the callback to execute */\n callback: Callback;\n };\n\n/**\n * Represents metadata about an activity, typically from an external system.\n *\n * Activity metadata enables tracking where activities originated from,\n * which is useful for synchronization, deduplication, and linking\n * back to external systems.\n *\n * ## Source-Based Upsert\n *\n * When creating an activity with a `source` field, Plot automatically implements\n * **upsert behavior**. If an activity with the same source already exists (created\n * by the same twist definition), it will be **updated** instead of creating a duplicate.\n * This enables safe, idempotent sync operations.\n *\n * ### How Source Uniqueness Works\n *\n * - **Scoped to twist definition**: Sources are unique per twist, not per twist instance.\n * Different instances of the same twist (installed in different priorities) share\n * the same source namespace.\n * - **Independent twists**: Different twists can have activities with the same source value.\n * - **Archived activities**: Archived activities don't conflict with active ones - you can\n * create a new activity with the same source after archiving.\n * - **Optional**: Activities without sources are always created fresh - no deduplication.\n *\n * ### Upsert Behavior Details\n *\n * When an activity is upserted (updated instead of created):\n * - **All provided fields** are updated with new values\n * - **Tags** are merged (existing tags + new tags)\n * - **Notes** are appended (existing notes kept, new ones added)\n * - **Priority** is NOT changed (stays in original priority)\n *\n * @example\n * ```typescript\n * // First call creates the activity\n * await plot.createActivity({\n * type: ActivityType.Event,\n * title: \"Team Meeting\",\n * start: new Date(\"2024-01-15T10:00:00Z\"),\n * source: \"google-calendar:event-abc123\",\n * meta: {\n * calendarId: \"primary\",\n * htmlLink: \"https://calendar.google.com/event/abc123\"\n * }\n * });\n *\n * // Second call with same source updates the existing activity\n * await plot.createActivity({\n * type: ActivityType.Event,\n * title: \"Team Meeting (Updated)\", // Title will be updated\n * start: new Date(\"2024-01-15T14:00:00Z\"), // Time will be updated\n * source: \"google-calendar:event-abc123\" // Same source = upsert\n * });\n *\n * // Different twist, same source = creates new activity (independent)\n * // Different source = creates new activity\n * // No source = creates new activity (no deduplication)\n * ```\n */\nexport type ActivityMeta = {\n /** Source-specific properties and metadata */\n [key: string]: any;\n};\n\nexport type Tags = { [K in Tag]?: ActorId[] };\n\n/**\n * Represents a complete activity within the Plot system.\n *\n * Activities are the core entities in Plot, representing anything from simple notes\n * to complex recurring events. They support rich metadata including scheduling,\n * recurrence patterns, links, and external source tracking.\n *\n * @example\n * ```typescript\n * // Simple note\n * const task: Activity = {\n * type: ActivityType.Note,\n * title: \"New campaign brainstorming ideas\",\n * content: \"We could rent a bouncy castle...\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Simple action\n * const action: Activity = {\n * type: ActivityType.Action,\n * title: \"Review budget proposal\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Recurring event\n * const meeting: Activity = {\n * type: ActivityType.Event,\n * title: \"Weekly standup\",\n * recurrenceRule: \"FREQ=WEEKLY;BYDAY=MO\",\n * recurrenceCount: 12,\n * // ... other fields\n * };\n * ```\n */\nexport type ActivityCommon = {\n /** Unique identifier for the activity */\n id: string;\n /** Information about who created the activity */\n author: Actor;\n /** Whether this activity is in draft state (not shown in do now view) */\n draft: boolean;\n /** Whether this activity is private (only visible to author) */\n private: boolean;\n /** Whether this activity has been archived */\n archived: boolean;\n /** Tags attached to this activity. Maps tag ID to array of actor IDs who added that tag. */\n tags: Tags | null;\n /** Array of actor IDs (users, contacts, or twists) mentioned in this activity via @-mentions */\n mentions: ActorId[] | null;\n};\n\nexport type Activity = ActivityCommon & {\n /** The display title/summary of the activity */\n title: string | null;\n /** The type of activity (Note, Task, or Event) */\n type: ActivityType;\n /**\n * The actor assigned to this activity.\n *\n * **For actions (tasks):** An assignee is required. If not explicitly provided when creating\n * an action, the assignee will default to the user who installed the twist (the twist owner).\n *\n * **For notes and events:** Assignee is optional and typically null.\n *\n * @example\n * ```typescript\n * // Create action with explicit assignee\n * const task: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review PR #123\",\n * assignee: {\n * id: userId as ActorId,\n * type: ActorType.User,\n * name: \"Alice\"\n * }\n * };\n *\n * // Create action with auto-assignment (defaults to twist owner)\n * const task: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Follow up on email\"\n * // assignee will be set automatically to twist owner\n * };\n *\n * // Update assignee\n * await plot.updateActivity({\n * id: activityId,\n * assignee: {\n * id: newUserId as ActorId,\n * type: ActorType.User,\n * name: \"Bob\"\n * }\n * });\n * ```\n */\n assignee: Actor | null;\n /** Timestamp when the activity was marked as complete. Null if not completed. */\n doneAt: Date | null;\n /**\n * Start time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the start of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n *\n * **Activity Scheduling States** (for Actions):\n * - **Do Now** (current/actionable): When creating a NewActivity of type Action, omitting `start` defaults to current time\n * - **Do Later** (future scheduled): Set `start` to a future Date or date string\n * - **Do Someday** (unscheduled backlog): Explicitly set `start: null`\n *\n * @example\n * ```typescript\n * // \"Do Now\" - defaults to current time when start is omitted\n * await this.tools.plot.createActivity({ type: ActivityType.Action, title: \"Urgent task\" });\n *\n * // \"Do Later\" - scheduled for a specific time\n * await this.tools.plot.createActivity({\n * type: ActivityType.Action,\n * title: \"Future task\",\n * start: new Date(\"2025-02-01\")\n * });\n *\n * // \"Do Someday\" - unscheduled backlog item\n * await this.tools.plot.createActivity({\n * type: ActivityType.Action,\n * title: \"Backlog task\",\n * start: null\n * });\n * ```\n */\n start: Date | string | null;\n /**\n * End time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the end of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for tasks or activities without defined end times.\n */\n end: Date | string | null;\n /**\n * For recurring activities, the last occurrence date (inclusive).\n * Can be a Date object, date string in \"YYYY-MM-DD\" format, or null if recurring indefinitely.\n * When both recurrenceCount and recurrenceUntil are provided, recurrenceCount takes precedence.\n */\n recurrenceUntil: Date | string | null;\n /**\n * For recurring activities, the number of occurrences to generate.\n * Takes precedence over recurrenceUntil if both are provided.\n * Null for non-recurring activities or indefinite recurrence.\n */\n recurrenceCount: number | null;\n /** The priority context this activity belongs to */\n priority: Priority;\n /** Recurrence rule in RFC 5545 RRULE format (e.g., \"FREQ=WEEKLY;BYDAY=MO,WE,FR\") */\n recurrenceRule: string | null;\n /** Array of dates to exclude from the recurrence pattern */\n recurrenceExdates: Date[] | null;\n /** Array of additional occurrence dates to include in the recurrence pattern */\n recurrenceDates: Date[] | null;\n /**\n * For recurring event exceptions, points to the root recurring activity.\n * Used when an individual occurrence of a recurring event is modified.\n */\n recurrence: Activity | null;\n /**\n * For recurring event exceptions, the original occurrence date being overridden.\n * Used to identify which occurrence of a recurring event this exception replaces.\n */\n occurrence: Date | null;\n /**\n * Unique identifier for this activity in the source system.\n *\n * Used for deduplication - activities with the same source are upserted instead\n * of creating duplicates. Format is typically \"source-name:external-id\"\n * (e.g., \"google-calendar:event-123\", \"outlook:message-456\").\n *\n * When provided, enables idempotent sync operations - calling createActivity()\n * multiple times with the same source will update the existing activity rather\n * than creating duplicates.\n */\n source: string | null;\n /** Metadata about the activity, typically from an external system that created it */\n meta: ActivityMeta | null;\n};\n\nexport type ActivityWithNotes = Activity & {\n notes: Note[];\n};\n\nexport type NewActivityWithNotes = NewActivity & {\n notes: Omit<NewNote, \"activity\">[];\n};\n\n/**\n * Configuration for automatic priority selection based on activity similarity.\n *\n * Maps activity fields to scoring weights or required exact matches:\n * - Number value: Maximum score for similarity matching on this field\n * - `true` value: Required exact match - activities must match exactly or be excluded\n *\n * Scoring rules:\n * - content: Uses vector similarity on activity embedding (cosine similarity)\n * - type: Exact match on ActivityType\n * - mentions: Percentage of existing activity's mentions that appear in new activity\n * - meta.field: Exact match on top-level meta fields (e.g., \"meta.sourceId\")\n *\n * When content is `true`, applies a strong similarity threshold to ensure only close matches.\n * Default (when neither priority nor pickPriority specified): `{content: true}`\n *\n * @example\n * ```typescript\n * // Require exact content match with strong similarity\n * pickPriority: { content: true }\n *\n * // Score based on content (max 100 points) and require exact type match\n * pickPriority: { content: 100, type: true }\n *\n * // Match on meta source and score content\n * pickPriority: { \"meta.source\": true, content: 50 }\n * ```\n */\nexport type PickPriorityConfig = {\n content?: number | true;\n type?: number | true;\n mentions?: number | true;\n [key: `meta.${string}`]: number | true;\n};\n\n/**\n * Type for creating new activities.\n *\n * Requires only the activity type, with all other fields optional.\n * The ID and author will be automatically assigned by the Plot system\n * based on the current execution context.\n *\n * **Important: Scheduling Defaults for Actions**\n *\n * When creating an Activity of type `Action`, the `start` field determines its scheduling state:\n * - **Omit `start`** \u2192 Defaults to current time \u2192 \"Do Now\" (appears in today's actionable list)\n * - **Set `start: null`** \u2192 Unscheduled \u2192 \"Do Someday\" (backlog item, no specific time)\n * - **Set `start` to future Date** \u2192 Scheduled \u2192 \"Do Later\" (appears on that date)\n *\n * For most external task integrations (project management, issue trackers), use `start: null`\n * to create backlog items unless the task is explicitly marked as current/active.\n *\n * Priority can be specified in three ways:\n * 1. Explicit priority: `priority: { id: \"...\" }` - Use specific priority (disables pickPriority)\n * 2. Pick priority config: `pickPriority: { ... }` - Auto-select based on similarity\n * 3. Neither: Defaults to `pickPriority: { content: true }` for automatic matching\n *\n * @example\n * ```typescript\n * // \"Do Now\" - Action defaults to current time (actionable today)\n * const urgentTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review pull request\"\n * // Omitting start defaults to new Date()\n * };\n *\n * // \"Do Someday\" - Backlog item (recommended for most synced tasks)\n * const backlogTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Refactor user service\",\n * start: null // Explicitly set to null for backlog\n * };\n *\n * // \"Do Later\" - Scheduled for specific date\n * const futureTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Prepare Q1 review\",\n * start: new Date(\"2025-03-15\")\n * };\n *\n * // Note (typically unscheduled)\n * const note: NewActivity = {\n * type: ActivityType.Note,\n * title: \"Meeting notes\",\n * content: \"Discussed Q4 roadmap...\",\n * start: null // Notes typically don't have scheduled times\n * };\n *\n * // Event (always has explicit start/end times)\n * const event: NewActivity = {\n * type: ActivityType.Event,\n * title: \"Team standup\",\n * start: new Date(\"2025-01-15T10:00:00\"),\n * end: new Date(\"2025-01-15T10:30:00\")\n * };\n * ```\n */\nexport type NewActivity = Pick<Activity, \"type\"> &\n Partial<Omit<Activity, \"id\" | \"author\" | \"type\" | \"priority\" | \"mentions\">> &\n (\n | {\n /** Explicit priority (required when specified) - disables automatic priority matching */\n priority: Pick<Priority, \"id\">;\n }\n | {\n /** Configuration for automatic priority selection based on similarity */\n pickPriority?: PickPriorityConfig;\n }\n | {}\n ) & {\n /**\n * Whether the activity should be marked as unread for users.\n * - true (default): Activity is unread for all users in the priority\n * - false: Activity is marked as read for all users in the priority at creation time\n *\n * Use false for historical imports to avoid marking old items as unread.\n */\n unread?: boolean;\n };\n\nexport type ActivityUpdate = Pick<Activity, \"id\"> &\n Partial<\n Pick<\n Activity,\n | \"type\"\n | \"start\"\n | \"end\"\n | \"doneAt\"\n | \"title\"\n | \"assignee\"\n | \"draft\"\n | \"private\"\n | \"source\"\n | \"meta\"\n | \"recurrenceRule\"\n | \"recurrenceDates\"\n | \"recurrenceExdates\"\n | \"recurrenceUntil\"\n | \"recurrenceCount\"\n | \"occurrence\"\n >\n > & {\n /**\n * Full tags object from Activity. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for activities created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other activities.\n */\n tags?: { [K in Tag]?: ActorId[] };\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all activities the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents a note within an activity.\n *\n * Notes contain the detailed content (note text, links) associated with an activity.\n * They are always ordered by creation time within their parent activity.\n */\nexport type Note = Omit<ActivityCommon, \"type\"> & {\n /** The parent activity this note belongs to */\n activity: Activity;\n /** Primary content for the note (markdown) */\n content: string | null;\n /** Array of interactive links attached to the note */\n links: Array<ActivityLink> | null;\n};\n\n/**\n * Type for creating new notes.\n *\n * Requires the activity reference, with all other fields optional.\n */\nexport type NewNote = Partial<Omit<Note, \"id\" | \"author\" | \"activity\">> & {\n /** Reference to the parent activity (required) */\n activity: Pick<Activity, \"id\">;\n\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n contentType?: ContentType;\n\n /**\n * Whether the note should mark the parent activity as unread for users.\n * - true (default): Activity becomes unread for users who haven't authored the note\n * - false: Activity is marked as read for all users in the priority at note creation time\n *\n * Use false for historical imports to avoid marking old items as unread.\n */\n unread?: boolean;\n};\n\n/**\n * Type for updating existing notes.\n */\nexport type NoteUpdate = Pick<Note, \"id\"> &\n Partial<\n Pick<Note, \"draft\" | \"private\" | \"content\" | \"links\" | \"mentions\">\n > & {\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n contentType?: ContentType;\n\n /**\n * Full tags object from Note. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for notes created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other notes.\n */\n tags?: { [K in Tag]?: ActorId[] };\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all notes the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents an actor in Plot - a user, contact, or twist.\n *\n * Actors can be associated with activities as authors, assignees, or mentions.\n * The email field is only included when ContactAccess.Read permission is granted.\n *\n * @example\n * ```typescript\n * const actor: Actor = {\n * id: \"f0ffd5f8-1635-4b13-9532-35f97446db90\" as ActorId,\n * type: ActorType.Contact,\n * email: \"john.doe@example.com\", // Only if ContactAccess.Read\n * name: \"John Doe\"\n * };\n * ```\n */\nexport type Actor = {\n /** Unique identifier for the actor */\n id: ActorId;\n /** Type of actor (User, Contact, or Twist) */\n type: ActorType;\n /** Email address (only included with ContactAccess.Read permission) */\n email?: string;\n /** Display name (undefined if not included due to permissions, null if not set) */\n name?: string | null;\n};\n\n/**\n * Enumeration of author types that can create activities.\n *\n * The author type affects how activities are displayed and processed\n * within the Plot system.\n */\nexport enum ActorType {\n /** Activities created by human users */\n User,\n /** Activities created by external contacts */\n Contact,\n /** Activities created by automated twists */\n Twist,\n}\n\n/**\n * Represents contact information for creating a new contact.\n *\n * Contacts are used throughout Plot for representing people associated\n * with activities, such as event attendees or task assignees.\n *\n * @example\n * ```typescript\n * const newContact: NewContact = {\n * email: \"john.doe@example.com\",\n * name: \"John Doe\",\n * avatar: \"https://avatar.example.com/john.jpg\"\n * };\n * ```\n */\nexport type NewContact = {\n /** Email address of the contact (required) */\n email: string;\n /** Optional display name for the contact */\n name?: string;\n /** Optional avatar image URL for the contact */\n avatar?: string;\n};\n\nexport type ContentType = \"text\" | \"markdown\" | \"html\";\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=plot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/llm-docs/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,snlBAA4mlB;AAA3nlB,wBAA4nlB"}
1
+ {"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../src/llm-docs/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,ukyBAA+hyB;AAA9iyB,wBAA+iyB"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/plot
2
+ * Generated LLM documentation for @plotday/twister/plot
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- export default "import { type Tag } from \"./tag\";\nimport { type Callback } from \"./tools/callbacks\";\n\nexport { Tag } from \"./tag\";\n\n/**\n * Represents a unique user, contact, or twist in Plot.\n *\n * Note contacts (i.e. people not using Plot) are also represented by ActorIds. They may be\n * people interacting with other connected services (e.g. an email sender or event attendee).\n */\nexport type ActorId = string & { readonly __brand: \"ActorId\" };\n\n/**\n * Represents a priority context within Plot.\n *\n * Priorities are similar to projects in other apps. All Activity is in a Priority.\n * Priorities can be nested.\n */\nexport type Priority = {\n /** Unique identifier for the priority */\n id: string;\n /** Human-readable title for the priority */\n title: string;\n};\n\n/**\n * Type for creating new priorities.\n *\n * Excludes the auto-generated ID field and adds an optional parentId\n * for creating hierarchical priority structures.\n */\nexport type NewPriority = Omit<Priority, \"id\"> & {\n /** Optional ID of the parent priority for creating hierarchies */\n parentId?: string;\n};\n\n/**\n * Enumeration of supported activity types in Plot.\n *\n * Each activity type has different behaviors and rendering characteristics\n * within the Plot application.\n */\nexport enum ActivityType {\n /** A note or piece of information without actionable requirements */\n Note,\n /** An actionable item that can be completed */\n Action,\n /** A scheduled occurrence with start and optional end time */\n Event,\n}\n\n/**\n * Enumeration of supported activity link types.\n *\n * Different link types have different behaviors when clicked by users\n * and may require different rendering approaches.\n */\nexport enum ActivityLinkType {\n /** External web links that open in browser */\n external = \"external\",\n /** Authentication flows for connecting services */\n auth = \"auth\",\n /** Callback links that trigger twist methods when clicked */\n callback = \"callback\",\n /** Video conferencing links with provider-specific handling */\n conferencing = \"conferencing\",\n}\n\n/**\n * Video conferencing providers for conferencing links.\n *\n * Used to identify the conferencing platform and provide\n * provider-specific UI elements (titles, icons, etc.).\n */\nexport enum ConferencingProvider {\n /** Google Meet */\n googleMeet = \"googleMeet\",\n /** Zoom */\n zoom = \"zoom\",\n /** Microsoft Teams */\n microsoftTeams = \"microsoftTeams\",\n /** Cisco Webex */\n webex = \"webex\",\n /** Other or unknown conferencing provider */\n other = \"other\",\n}\n\n/**\n * Represents a clickable link attached to an activity.\n *\n * Activity links are rendered as buttons that enable user interaction with activities.\n * Different link types have specific behaviors and required fields for proper functionality.\n *\n * @example\n * ```typescript\n * // External link - opens URL in browser\n * const externalLink: ActivityLink = {\n * type: ActivityLinkType.external,\n * title: \"Open in Google Calendar\",\n * url: \"https://calendar.google.com/event/123\",\n * };\n *\n * // Conferencing link - opens video conference with provider info\n * const conferencingLink: ActivityLink = {\n * type: ActivityLinkType.conferencing,\n * url: \"https://meet.google.com/abc-defg-hij\",\n * provider: ConferencingProvider.googleMeet,\n * };\n *\n * // Integrations link - initiates OAuth flow\n * const authLink: ActivityLink = {\n * type: ActivityLinkType.auth,\n * title: \"Continue with Google\",\n * provider: AuthProvider.Google,\n * level: AuthLevel.User,\n * scopes: [\"https://www.googleapis.com/auth/calendar.readonly\"],\n * callback: \"callback-token-for-auth-completion\"\n * };\n *\n * // Callback link - triggers a twist method\n * const callbackLink: ActivityLink = {\n * type: ActivityLinkType.callback,\n * title: \"📅 Primary Calendar\",\n * token: \"callback-token-here\"\n * };\n * ```\n */\nexport type ActivityLink =\n | {\n /** External web link that opens in browser */\n type: ActivityLinkType.external;\n /** Display text for the link button */\n title: string;\n /** URL to open when clicked */\n url: string;\n }\n | {\n /** Video conferencing link with provider-specific handling */\n type: ActivityLinkType.conferencing;\n /** URL to join the conference */\n url: string;\n /** Conferencing provider for UI customization */\n provider: ConferencingProvider;\n }\n | {\n /** Authentication link that initiates an OAuth flow */\n type: ActivityLinkType.auth;\n /** Display text for the auth button */\n title: string;\n /** OAuth provider (e.g., \"google\", \"microsoft\") */\n provider: string;\n /** Authorization level (\"user\" or \"priority\") */\n level: string;\n /** Array of OAuth scopes to request */\n scopes: string[];\n /** Callback token for auth completion notification */\n callback: Callback;\n }\n | {\n /** Callback link that triggers a twist method when clicked */\n type: ActivityLinkType.callback;\n /** Display text for the callback button */\n title: string;\n /** Token identifying the callback to execute */\n callback: Callback;\n };\n\n/**\n * Represents metadata about an activity, typically from an external system.\n *\n * Activity metadata enables tracking where activities originated from,\n * which is useful for synchronization, deduplication, and linking\n * back to external systems.\n *\n * @example\n * ```typescript\n * const googleCalendarMeta: ActivityMeta = {\n * type: \"google-calendar-event\",\n * id: \"event-123\",\n * calendarId: \"primary\",\n * htmlLink: \"https://calendar.google.com/event/123\"\n * };\n * ```\n */\nexport type ActivityMeta = {\n /** The type identifier for the source system */\n source: string;\n /** Additional source-specific properties */\n [key: string]: any;\n};\n\n/**\n * Represents a complete activity within the Plot system.\n *\n * Activities are the core entities in Plot, representing anything from simple notes\n * to complex recurring events. They support rich metadata including scheduling,\n * recurrence patterns, links, and external source tracking.\n *\n * @example\n * ```typescript\n * // Simple note\n * const task: Activity = {\n * type: ActivityType.Note,\n * title: \"New campaign brainstorming ideas\",\n * note: \"We could rent a bouncy castle...\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Simple action\n * const action: Activity = {\n * type: ActivityType.Action,\n * title: \"Review budget proposal\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Recurring event\n * const meeting: Activity = {\n * type: ActivityType.Event,\n * title: \"Weekly standup\",\n * recurrenceRule: \"FREQ=WEEKLY;BYDAY=MO\",\n * recurrenceCount: 12,\n * // ... other fields\n * };\n * ```\n */\nexport type ActivityCommon = {\n /** Unique identifier for the activity */\n id: string;\n /** Information about who created the activity */\n author: Actor;\n /** Whether this activity is in draft state (not shown in do now view) */\n draft: boolean;\n /** Whether this activity is private (only visible to author) */\n private: boolean;\n /** Tags attached to this activity. Maps tag ID to array of actor IDs who added that tag. */\n tags: Partial<Record<Tag, ActorId[]>> | null;\n /** Array of actor IDs (users, contacts, or twists) mentioned in this activity via @-mentions */\n mentions: ActorId[] | null;\n};\n\nexport type Activity = ActivityCommon & {\n /** The display title/summary of the activity */\n title: string | null;\n /** The type of activity (Note, Task, or Event) */\n type: ActivityType;\n /** Who this activity note is assigned to */\n assignee: Actor | null;\n /** Timestamp when the activity was marked as complete. Null if not completed. */\n doneAt: Date | null;\n /**\n * Start time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the start of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for activities without scheduled start times.\n */\n start: Date | string | null;\n /**\n * End time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the end of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for tasks or activities without defined end times.\n */\n end: Date | string | null;\n /**\n * For recurring activities, the last occurrence date (inclusive).\n * Can be a Date object, date string in \"YYYY-MM-DD\" format, or null if recurring indefinitely.\n * When both recurrenceCount and recurrenceUntil are provided, recurrenceCount takes precedence.\n */\n recurrenceUntil: Date | string | null;\n /**\n * For recurring activities, the number of occurrences to generate.\n * Takes precedence over recurrenceUntil if both are provided.\n * Null for non-recurring activities or indefinite recurrence.\n */\n recurrenceCount: number | null;\n /** The priority context this activity belongs to */\n priority: Priority;\n /** Recurrence rule in RFC 5545 RRULE format (e.g., \"FREQ=WEEKLY;BYDAY=MO,WE,FR\") */\n recurrenceRule: string | null;\n /** Array of dates to exclude from the recurrence pattern */\n recurrenceExdates: Date[] | null;\n /** Array of additional occurrence dates to include in the recurrence pattern */\n recurrenceDates: Date[] | null;\n /**\n * For recurring event exceptions, points to the root recurring activity.\n * Used when an individual occurrence of a recurring event is modified.\n */\n recurrence: Activity | null;\n /**\n * For recurring event exceptions, the original occurrence date being overridden.\n * Used to identify which occurrence of a recurring event this exception replaces.\n */\n occurrence: Date | null;\n /** Metadata about the activity, typically from an external system that created it */\n meta: ActivityMeta | null;\n};\n\nexport type ActivityWithNotes = Activity & {\n notes: Note[];\n};\n\nexport type NewActivityWithNotes = NewActivity & {\n notes: Omit<NewNote, \"activity\">[];\n};\n\n/**\n * Configuration for automatic priority selection based on activity similarity.\n *\n * Maps activity fields to scoring weights or required exact matches:\n * - Number value: Maximum score for similarity matching on this field\n * - `true` value: Required exact match - activities must match exactly or be excluded\n *\n * Scoring rules:\n * - content: Uses vector similarity on activity embedding (cosine similarity)\n * - type: Exact match on ActivityType\n * - mentions: Percentage of existing activity's mentions that appear in new activity\n * - meta.field: Exact match on top-level meta fields (e.g., \"meta.sourceId\")\n *\n * When content is `true`, applies a strong similarity threshold to ensure only close matches.\n * Default (when neither priority nor pickPriority specified): `{content: true}`\n *\n * @example\n * ```typescript\n * // Require exact content match with strong similarity\n * pickPriority: { content: true }\n *\n * // Score based on content (max 100 points) and require exact type match\n * pickPriority: { content: 100, type: true }\n *\n * // Match on meta source and score content\n * pickPriority: { \"meta.source\": true, content: 50 }\n * ```\n */\nexport type PickPriorityConfig = {\n content?: number | true;\n type?: number | true;\n mentions?: number | true;\n [key: `meta.${string}`]: number | true;\n};\n\n/**\n * Type for creating new activities.\n *\n * Requires only the activity type, with all other fields optional.\n * The ID and author will be automatically assigned by the Plot system\n * based on the current execution context.\n *\n * Priority can be specified in three ways:\n * 1. Explicit priority: `priority: { id: \"...\" }` - Use specific priority (disables pickPriority)\n * 2. Pick priority config: `pickPriority: { ... }` - Auto-select based on similarity\n * 3. Neither: Defaults to `pickPriority: { content: true }` for automatic matching\n *\n * @example\n * ```typescript\n * // Explicit priority (disables automatic matching)\n * const newTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review pull request\",\n * priority: { id: \"work-project-123\" }\n * };\n *\n * // Automatic priority matching (default behavior)\n * const newNote: NewActivity = {\n * type: ActivityType.Note,\n * title: \"Meeting notes\",\n * note: \"Discussed Q4 roadmap...\"\n * // Defaults to pickPriority: { content: true }\n * };\n *\n * // Custom priority matching\n * const newEvent: NewActivity = {\n * type: ActivityType.Event,\n * title: \"Team standup\",\n * pickPriority: { type: true, content: 50 }\n * };\n * ```\n */\nexport type NewActivity = Pick<Activity, \"type\"> &\n Partial<Omit<Activity, \"id\" | \"author\" | \"type\" | \"priority\" | \"mentions\">> &\n (\n | {\n /** Explicit priority (required when specified) - disables automatic priority matching */\n priority: Pick<Priority, \"id\">;\n }\n | {\n /** Configuration for automatic priority selection based on similarity */\n pickPriority?: PickPriorityConfig;\n }\n | {}\n );\n\nexport type ActivityUpdate = Pick<Activity, \"id\"> &\n Partial<\n Pick<\n Activity,\n | \"type\"\n | \"start\"\n | \"end\"\n | \"doneAt\"\n | \"title\"\n | \"draft\"\n | \"private\"\n | \"meta\"\n | \"recurrenceRule\"\n | \"recurrenceDates\"\n | \"recurrenceExdates\"\n | \"recurrenceUntil\"\n | \"recurrenceCount\"\n | \"occurrence\"\n >\n > & {\n /**\n * Full tags object from Activity. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for activities created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other activities.\n */\n tags?: Partial<Record<Tag, ActorId[]>>;\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all activities the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents a note within an activity.\n *\n * Notes contain the detailed content (note text, links) associated with an activity.\n * They are always ordered by creation time within their parent activity.\n */\nexport type Note = Omit<ActivityCommon, \"type\"> & {\n /** The parent activity this note belongs to */\n activity: Activity;\n /** Primary content for the note (markdown) */\n note: string | null;\n /** Array of interactive links attached to the note */\n links: Array<ActivityLink> | null;\n};\n\n/**\n * Type for creating new notes.\n *\n * Requires the activity reference, with all other fields optional.\n */\nexport type NewNote = Partial<Omit<Note, \"id\" | \"author\" | \"activity\">> & {\n /** Reference to the parent activity (required) */\n activity: Pick<Activity, \"id\">;\n\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n noteType?: NoteType;\n};\n\n/**\n * Type for updating existing notes.\n */\nexport type NoteUpdate = Pick<Note, \"id\"> &\n Partial<Pick<Note, \"draft\" | \"private\" | \"note\" | \"links\" | \"mentions\">> & {\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n noteType?: NoteType;\n\n /**\n * Full tags object from Note. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for notes created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other notes.\n */\n tags?: Partial<Record<Tag, ActorId[]>>;\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all notes the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents an actor in Plot - a user, contact, or twist.\n *\n * Actors can be associated with activities as authors, assignees, or mentions.\n * The email field is only included when ContactAccess.Read permission is granted.\n *\n * @example\n * ```typescript\n * const actor: Actor = {\n * id: \"f0ffd5f8-1635-4b13-9532-35f97446db90\" as ActorId,\n * type: ActorType.Contact,\n * email: \"john.doe@example.com\", // Only if ContactAccess.Read\n * name: \"John Doe\"\n * };\n * ```\n */\nexport type Actor = {\n /** Unique identifier for the actor */\n id: ActorId;\n /** Type of actor (User, Contact, or Twist) */\n type: ActorType;\n /** Email address (only included with ContactAccess.Read permission) */\n email?: string;\n /** Display name (undefined if not included due to permissions, null if not set) */\n name?: string | null;\n};\n\n/**\n * Enumeration of author types that can create activities.\n *\n * The author type affects how activities are displayed and processed\n * within the Plot system.\n */\nexport enum ActorType {\n /** Activities created by human users */\n User,\n /** Activities created by external contacts */\n Contact,\n /** Activities created by automated twists */\n Twist,\n}\n\n/**\n * Represents contact information for creating a new contact.\n *\n * Contacts are used throughout Plot for representing people associated\n * with activities, such as event attendees or task assignees.\n *\n * @example\n * ```typescript\n * const newContact: NewContact = {\n * email: \"john.doe@example.com\",\n * name: \"John Doe\",\n * avatar: \"https://avatar.example.com/john.jpg\"\n * };\n * ```\n */\nexport type NewContact = {\n /** Email address of the contact (required) */\n email: string;\n /** Optional display name for the contact */\n name?: string;\n /** Optional avatar image URL for the contact */\n avatar?: string;\n};\n\nexport type NoteType = \"text\" | \"markdown\" | \"html\";\n";
7
+ export default "import { type Tag } from \"./tag\";\nimport { type Callback } from \"./tools/callbacks\";\n\nexport { Tag } from \"./tag\";\n\n/**\n * Represents a unique user, contact, or twist in Plot.\n *\n * ActorIds are used throughout Plot for:\n * - Activity authors and assignees\n * - Tag creators (actor_id in activity_tag/note_tag)\n * - Mentions in activities and notes\n * - Any entity that can perform actions in Plot\n */\nexport type ActorId = string & { readonly __brand: \"ActorId\" };\n\n/**\n * Represents a priority context within Plot.\n *\n * Priorities are similar to projects in other apps. All Activity is in a Priority.\n * Priorities can be nested.\n */\nexport type Priority = {\n /** Unique identifier for the priority */\n id: string;\n /** Human-readable title for the priority */\n title: string;\n};\n\n/**\n * Type for creating new priorities.\n *\n * Excludes the auto-generated ID field and adds an optional parentId\n * for creating hierarchical priority structures.\n */\nexport type NewPriority = Omit<Priority, \"id\"> & {\n /** Optional ID of the parent priority for creating hierarchies */\n parentId?: string;\n};\n\n/**\n * Enumeration of supported activity types in Plot.\n *\n * Each activity type has different behaviors and rendering characteristics\n * within the Plot application.\n */\nexport enum ActivityType {\n /** A note or piece of information without actionable requirements */\n Note,\n /** An actionable item that can be completed */\n Action,\n /** A scheduled occurrence with start and optional end time */\n Event,\n}\n\n/**\n * Enumeration of supported activity link types.\n *\n * Different link types have different behaviors when clicked by users\n * and may require different rendering approaches.\n */\nexport enum ActivityLinkType {\n /** External web links that open in browser */\n external = \"external\",\n /** Authentication flows for connecting services */\n auth = \"auth\",\n /** Callback links that trigger twist methods when clicked */\n callback = \"callback\",\n /** Video conferencing links with provider-specific handling */\n conferencing = \"conferencing\",\n}\n\n/**\n * Video conferencing providers for conferencing links.\n *\n * Used to identify the conferencing platform and provide\n * provider-specific UI elements (titles, icons, etc.).\n */\nexport enum ConferencingProvider {\n /** Google Meet */\n googleMeet = \"googleMeet\",\n /** Zoom */\n zoom = \"zoom\",\n /** Microsoft Teams */\n microsoftTeams = \"microsoftTeams\",\n /** Cisco Webex */\n webex = \"webex\",\n /** Other or unknown conferencing provider */\n other = \"other\",\n}\n\n/**\n * Represents a clickable link attached to an activity.\n *\n * Activity links are rendered as buttons that enable user interaction with activities.\n * Different link types have specific behaviors and required fields for proper functionality.\n *\n * @example\n * ```typescript\n * // External link - opens URL in browser\n * const externalLink: ActivityLink = {\n * type: ActivityLinkType.external,\n * title: \"Open in Google Calendar\",\n * url: \"https://calendar.google.com/event/123\",\n * };\n *\n * // Conferencing link - opens video conference with provider info\n * const conferencingLink: ActivityLink = {\n * type: ActivityLinkType.conferencing,\n * url: \"https://meet.google.com/abc-defg-hij\",\n * provider: ConferencingProvider.googleMeet,\n * };\n *\n * // Integrations link - initiates OAuth flow\n * const authLink: ActivityLink = {\n * type: ActivityLinkType.auth,\n * title: \"Continue with Google\",\n * provider: AuthProvider.Google,\n * level: AuthLevel.User,\n * scopes: [\"https://www.googleapis.com/auth/calendar.readonly\"],\n * callback: \"callback-token-for-auth-completion\"\n * };\n *\n * // Callback link - triggers a twist method\n * const callbackLink: ActivityLink = {\n * type: ActivityLinkType.callback,\n * title: \"📅 Primary Calendar\",\n * token: \"callback-token-here\"\n * };\n * ```\n */\nexport type ActivityLink =\n | {\n /** External web link that opens in browser */\n type: ActivityLinkType.external;\n /** Display text for the link button */\n title: string;\n /** URL to open when clicked */\n url: string;\n }\n | {\n /** Video conferencing link with provider-specific handling */\n type: ActivityLinkType.conferencing;\n /** URL to join the conference */\n url: string;\n /** Conferencing provider for UI customization */\n provider: ConferencingProvider;\n }\n | {\n /** Authentication link that initiates an OAuth flow */\n type: ActivityLinkType.auth;\n /** Display text for the auth button */\n title: string;\n /** OAuth provider (e.g., \"google\", \"microsoft\") */\n provider: string;\n /** Authorization level (\"user\" or \"priority\") */\n level: string;\n /** Array of OAuth scopes to request */\n scopes: string[];\n /** Callback token for auth completion notification */\n callback: Callback;\n }\n | {\n /** Callback link that triggers a twist method when clicked */\n type: ActivityLinkType.callback;\n /** Display text for the callback button */\n title: string;\n /** Token identifying the callback to execute */\n callback: Callback;\n };\n\n/**\n * Represents metadata about an activity, typically from an external system.\n *\n * Activity metadata enables tracking where activities originated from,\n * which is useful for synchronization, deduplication, and linking\n * back to external systems.\n *\n * ## Source-Based Upsert\n *\n * When creating an activity with a `source` field, Plot automatically implements\n * **upsert behavior**. If an activity with the same source already exists (created\n * by the same twist definition), it will be **updated** instead of creating a duplicate.\n * This enables safe, idempotent sync operations.\n *\n * ### How Source Uniqueness Works\n *\n * - **Scoped to twist definition**: Sources are unique per twist, not per twist instance.\n * Different instances of the same twist (installed in different priorities) share\n * the same source namespace.\n * - **Independent twists**: Different twists can have activities with the same source value.\n * - **Archived activities**: Archived activities don't conflict with active ones - you can\n * create a new activity with the same source after archiving.\n * - **Optional**: Activities without sources are always created fresh - no deduplication.\n *\n * ### Upsert Behavior Details\n *\n * When an activity is upserted (updated instead of created):\n * - **All provided fields** are updated with new values\n * - **Tags** are merged (existing tags + new tags)\n * - **Notes** are appended (existing notes kept, new ones added)\n * - **Priority** is NOT changed (stays in original priority)\n *\n * @example\n * ```typescript\n * // First call creates the activity\n * await plot.createActivity({\n * type: ActivityType.Event,\n * title: \"Team Meeting\",\n * start: new Date(\"2024-01-15T10:00:00Z\"),\n * source: \"google-calendar:event-abc123\",\n * meta: {\n * calendarId: \"primary\",\n * htmlLink: \"https://calendar.google.com/event/abc123\"\n * }\n * });\n *\n * // Second call with same source updates the existing activity\n * await plot.createActivity({\n * type: ActivityType.Event,\n * title: \"Team Meeting (Updated)\", // Title will be updated\n * start: new Date(\"2024-01-15T14:00:00Z\"), // Time will be updated\n * source: \"google-calendar:event-abc123\" // Same source = upsert\n * });\n *\n * // Different twist, same source = creates new activity (independent)\n * // Different source = creates new activity\n * // No source = creates new activity (no deduplication)\n * ```\n */\nexport type ActivityMeta = {\n /** Source-specific properties and metadata */\n [key: string]: any;\n};\n\nexport type Tags = { [K in Tag]?: ActorId[] };\n\n/**\n * Represents a complete activity within the Plot system.\n *\n * Activities are the core entities in Plot, representing anything from simple notes\n * to complex recurring events. They support rich metadata including scheduling,\n * recurrence patterns, links, and external source tracking.\n *\n * @example\n * ```typescript\n * // Simple note\n * const task: Activity = {\n * type: ActivityType.Note,\n * title: \"New campaign brainstorming ideas\",\n * content: \"We could rent a bouncy castle...\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Simple action\n * const action: Activity = {\n * type: ActivityType.Action,\n * title: \"Review budget proposal\",\n * author: { id: \"user-1\", name: \"John Doe\", type: ActorType.User },\n * priority: { id: \"work\", title: \"Work\" },\n * // ... other fields\n * };\n *\n * // Recurring event\n * const meeting: Activity = {\n * type: ActivityType.Event,\n * title: \"Weekly standup\",\n * recurrenceRule: \"FREQ=WEEKLY;BYDAY=MO\",\n * recurrenceCount: 12,\n * // ... other fields\n * };\n * ```\n */\nexport type ActivityCommon = {\n /** Unique identifier for the activity */\n id: string;\n /** Information about who created the activity */\n author: Actor;\n /** Whether this activity is in draft state (not shown in do now view) */\n draft: boolean;\n /** Whether this activity is private (only visible to author) */\n private: boolean;\n /** Whether this activity has been archived */\n archived: boolean;\n /** Tags attached to this activity. Maps tag ID to array of actor IDs who added that tag. */\n tags: Tags | null;\n /** Array of actor IDs (users, contacts, or twists) mentioned in this activity via @-mentions */\n mentions: ActorId[] | null;\n};\n\nexport type Activity = ActivityCommon & {\n /** The display title/summary of the activity */\n title: string | null;\n /** The type of activity (Note, Task, or Event) */\n type: ActivityType;\n /**\n * The actor assigned to this activity.\n *\n * **For actions (tasks):** An assignee is required. If not explicitly provided when creating\n * an action, the assignee will default to the user who installed the twist (the twist owner).\n *\n * **For notes and events:** Assignee is optional and typically null.\n *\n * @example\n * ```typescript\n * // Create action with explicit assignee\n * const task: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review PR #123\",\n * assignee: {\n * id: userId as ActorId,\n * type: ActorType.User,\n * name: \"Alice\"\n * }\n * };\n *\n * // Create action with auto-assignment (defaults to twist owner)\n * const task: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Follow up on email\"\n * // assignee will be set automatically to twist owner\n * };\n *\n * // Update assignee\n * await plot.updateActivity({\n * id: activityId,\n * assignee: {\n * id: newUserId as ActorId,\n * type: ActorType.User,\n * name: \"Bob\"\n * }\n * });\n * ```\n */\n assignee: Actor | null;\n /** Timestamp when the activity was marked as complete. Null if not completed. */\n doneAt: Date | null;\n /**\n * Start time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the start of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n *\n * **Activity Scheduling States** (for Actions):\n * - **Do Now** (current/actionable): When creating a NewActivity of type Action, omitting `start` defaults to current time\n * - **Do Later** (future scheduled): Set `start` to a future Date or date string\n * - **Do Someday** (unscheduled backlog): Explicitly set `start: null`\n *\n * @example\n * ```typescript\n * // \"Do Now\" - defaults to current time when start is omitted\n * await this.tools.plot.createActivity({ type: ActivityType.Action, title: \"Urgent task\" });\n *\n * // \"Do Later\" - scheduled for a specific time\n * await this.tools.plot.createActivity({\n * type: ActivityType.Action,\n * title: \"Future task\",\n * start: new Date(\"2025-02-01\")\n * });\n *\n * // \"Do Someday\" - unscheduled backlog item\n * await this.tools.plot.createActivity({\n * type: ActivityType.Action,\n * title: \"Backlog task\",\n * start: null\n * });\n * ```\n */\n start: Date | string | null;\n /**\n * End time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.\n * For recurring events, this represents the end of the first occurrence.\n * Can be a Date object for timed events or a date string in \"YYYY-MM-DD\" format for all-day events.\n * Null for tasks or activities without defined end times.\n */\n end: Date | string | null;\n /**\n * For recurring activities, the last occurrence date (inclusive).\n * Can be a Date object, date string in \"YYYY-MM-DD\" format, or null if recurring indefinitely.\n * When both recurrenceCount and recurrenceUntil are provided, recurrenceCount takes precedence.\n */\n recurrenceUntil: Date | string | null;\n /**\n * For recurring activities, the number of occurrences to generate.\n * Takes precedence over recurrenceUntil if both are provided.\n * Null for non-recurring activities or indefinite recurrence.\n */\n recurrenceCount: number | null;\n /** The priority context this activity belongs to */\n priority: Priority;\n /** Recurrence rule in RFC 5545 RRULE format (e.g., \"FREQ=WEEKLY;BYDAY=MO,WE,FR\") */\n recurrenceRule: string | null;\n /** Array of dates to exclude from the recurrence pattern */\n recurrenceExdates: Date[] | null;\n /** Array of additional occurrence dates to include in the recurrence pattern */\n recurrenceDates: Date[] | null;\n /**\n * For recurring event exceptions, points to the root recurring activity.\n * Used when an individual occurrence of a recurring event is modified.\n */\n recurrence: Activity | null;\n /**\n * For recurring event exceptions, the original occurrence date being overridden.\n * Used to identify which occurrence of a recurring event this exception replaces.\n */\n occurrence: Date | null;\n /**\n * Unique identifier for this activity in the source system.\n *\n * Used for deduplication - activities with the same source are upserted instead\n * of creating duplicates. Format is typically \"source-name:external-id\"\n * (e.g., \"google-calendar:event-123\", \"outlook:message-456\").\n *\n * When provided, enables idempotent sync operations - calling createActivity()\n * multiple times with the same source will update the existing activity rather\n * than creating duplicates.\n */\n source: string | null;\n /** Metadata about the activity, typically from an external system that created it */\n meta: ActivityMeta | null;\n};\n\nexport type ActivityWithNotes = Activity & {\n notes: Note[];\n};\n\nexport type NewActivityWithNotes = NewActivity & {\n notes: Omit<NewNote, \"activity\">[];\n};\n\n/**\n * Configuration for automatic priority selection based on activity similarity.\n *\n * Maps activity fields to scoring weights or required exact matches:\n * - Number value: Maximum score for similarity matching on this field\n * - `true` value: Required exact match - activities must match exactly or be excluded\n *\n * Scoring rules:\n * - content: Uses vector similarity on activity embedding (cosine similarity)\n * - type: Exact match on ActivityType\n * - mentions: Percentage of existing activity's mentions that appear in new activity\n * - meta.field: Exact match on top-level meta fields (e.g., \"meta.sourceId\")\n *\n * When content is `true`, applies a strong similarity threshold to ensure only close matches.\n * Default (when neither priority nor pickPriority specified): `{content: true}`\n *\n * @example\n * ```typescript\n * // Require exact content match with strong similarity\n * pickPriority: { content: true }\n *\n * // Score based on content (max 100 points) and require exact type match\n * pickPriority: { content: 100, type: true }\n *\n * // Match on meta source and score content\n * pickPriority: { \"meta.source\": true, content: 50 }\n * ```\n */\nexport type PickPriorityConfig = {\n content?: number | true;\n type?: number | true;\n mentions?: number | true;\n [key: `meta.${string}`]: number | true;\n};\n\n/**\n * Type for creating new activities.\n *\n * Requires only the activity type, with all other fields optional.\n * The ID and author will be automatically assigned by the Plot system\n * based on the current execution context.\n *\n * **Important: Scheduling Defaults for Actions**\n *\n * When creating an Activity of type `Action`, the `start` field determines its scheduling state:\n * - **Omit `start`** → Defaults to current time → \"Do Now\" (appears in today's actionable list)\n * - **Set `start: null`** → Unscheduled → \"Do Someday\" (backlog item, no specific time)\n * - **Set `start` to future Date** → Scheduled → \"Do Later\" (appears on that date)\n *\n * For most external task integrations (project management, issue trackers), use `start: null`\n * to create backlog items unless the task is explicitly marked as current/active.\n *\n * Priority can be specified in three ways:\n * 1. Explicit priority: `priority: { id: \"...\" }` - Use specific priority (disables pickPriority)\n * 2. Pick priority config: `pickPriority: { ... }` - Auto-select based on similarity\n * 3. Neither: Defaults to `pickPriority: { content: true }` for automatic matching\n *\n * @example\n * ```typescript\n * // \"Do Now\" - Action defaults to current time (actionable today)\n * const urgentTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Review pull request\"\n * // Omitting start defaults to new Date()\n * };\n *\n * // \"Do Someday\" - Backlog item (recommended for most synced tasks)\n * const backlogTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Refactor user service\",\n * start: null // Explicitly set to null for backlog\n * };\n *\n * // \"Do Later\" - Scheduled for specific date\n * const futureTask: NewActivity = {\n * type: ActivityType.Action,\n * title: \"Prepare Q1 review\",\n * start: new Date(\"2025-03-15\")\n * };\n *\n * // Note (typically unscheduled)\n * const note: NewActivity = {\n * type: ActivityType.Note,\n * title: \"Meeting notes\",\n * content: \"Discussed Q4 roadmap...\",\n * start: null // Notes typically don't have scheduled times\n * };\n *\n * // Event (always has explicit start/end times)\n * const event: NewActivity = {\n * type: ActivityType.Event,\n * title: \"Team standup\",\n * start: new Date(\"2025-01-15T10:00:00\"),\n * end: new Date(\"2025-01-15T10:30:00\")\n * };\n * ```\n */\nexport type NewActivity = Pick<Activity, \"type\"> &\n Partial<Omit<Activity, \"id\" | \"author\" | \"type\" | \"priority\" | \"mentions\">> &\n (\n | {\n /** Explicit priority (required when specified) - disables automatic priority matching */\n priority: Pick<Priority, \"id\">;\n }\n | {\n /** Configuration for automatic priority selection based on similarity */\n pickPriority?: PickPriorityConfig;\n }\n | {}\n ) & {\n /**\n * Whether the activity should be marked as unread for users.\n * - true (default): Activity is unread for all users in the priority\n * - false: Activity is marked as read for all users in the priority at creation time\n *\n * Use false for historical imports to avoid marking old items as unread.\n */\n unread?: boolean;\n };\n\nexport type ActivityUpdate = Pick<Activity, \"id\"> &\n Partial<\n Pick<\n Activity,\n | \"type\"\n | \"start\"\n | \"end\"\n | \"doneAt\"\n | \"title\"\n | \"assignee\"\n | \"draft\"\n | \"private\"\n | \"source\"\n | \"meta\"\n | \"recurrenceRule\"\n | \"recurrenceDates\"\n | \"recurrenceExdates\"\n | \"recurrenceUntil\"\n | \"recurrenceCount\"\n | \"occurrence\"\n >\n > & {\n /**\n * Full tags object from Activity. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for activities created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other activities.\n */\n tags?: { [K in Tag]?: ActorId[] };\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all activities the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents a note within an activity.\n *\n * Notes contain the detailed content (note text, links) associated with an activity.\n * They are always ordered by creation time within their parent activity.\n */\nexport type Note = Omit<ActivityCommon, \"type\"> & {\n /** The parent activity this note belongs to */\n activity: Activity;\n /** Primary content for the note (markdown) */\n content: string | null;\n /** Array of interactive links attached to the note */\n links: Array<ActivityLink> | null;\n};\n\n/**\n * Type for creating new notes.\n *\n * Requires the activity reference, with all other fields optional.\n */\nexport type NewNote = Partial<Omit<Note, \"id\" | \"author\" | \"activity\">> & {\n /** Reference to the parent activity (required) */\n activity: Pick<Activity, \"id\">;\n\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n contentType?: ContentType;\n\n /**\n * Whether the note should mark the parent activity as unread for users.\n * - true (default): Activity becomes unread for users who haven't authored the note\n * - false: Activity is marked as read for all users in the priority at note creation time\n *\n * Use false for historical imports to avoid marking old items as unread.\n */\n unread?: boolean;\n};\n\n/**\n * Type for updating existing notes.\n */\nexport type NoteUpdate = Pick<Note, \"id\"> &\n Partial<\n Pick<Note, \"draft\" | \"private\" | \"content\" | \"links\" | \"mentions\">\n > & {\n /**\n * Format of the note content. Determines how the note is processed:\n * - 'text': Plain text that will be converted to markdown (auto-links URLs, preserves line breaks)\n * - 'markdown': Already in markdown format (default, no conversion)\n * - 'html': HTML content that will be converted to markdown\n */\n contentType?: ContentType;\n\n /**\n * Full tags object from Note. Maps tag ID to array of actor IDs who added that tag.\n * Only allowed for notes created by the twist.\n * Use twistTags instead for adding/removing the twist's tags on other notes.\n */\n tags?: { [K in Tag]?: ActorId[] };\n\n /**\n * Add or remove the twist's tags.\n * Maps tag ID to boolean: true = add tag, false = remove tag.\n * This is allowed on all notes the twist has access to.\n */\n twistTags?: Partial<Record<Tag, boolean>>;\n };\n\n/**\n * Represents an actor in Plot - a user, contact, or twist.\n *\n * Actors can be associated with activities as authors, assignees, or mentions.\n * The email field is only included when ContactAccess.Read permission is granted.\n *\n * @example\n * ```typescript\n * const actor: Actor = {\n * id: \"f0ffd5f8-1635-4b13-9532-35f97446db90\" as ActorId,\n * type: ActorType.Contact,\n * email: \"john.doe@example.com\", // Only if ContactAccess.Read\n * name: \"John Doe\"\n * };\n * ```\n */\nexport type Actor = {\n /** Unique identifier for the actor */\n id: ActorId;\n /** Type of actor (User, Contact, or Twist) */\n type: ActorType;\n /** Email address (only included with ContactAccess.Read permission) */\n email?: string;\n /** Display name (undefined if not included due to permissions, null if not set) */\n name?: string | null;\n};\n\n/**\n * Enumeration of author types that can create activities.\n *\n * The author type affects how activities are displayed and processed\n * within the Plot system.\n */\nexport enum ActorType {\n /** Activities created by human users */\n User,\n /** Activities created by external contacts */\n Contact,\n /** Activities created by automated twists */\n Twist,\n}\n\n/**\n * Represents contact information for creating a new contact.\n *\n * Contacts are used throughout Plot for representing people associated\n * with activities, such as event attendees or task assignees.\n *\n * @example\n * ```typescript\n * const newContact: NewContact = {\n * email: \"john.doe@example.com\",\n * name: \"John Doe\",\n * avatar: \"https://avatar.example.com/john.jpg\"\n * };\n * ```\n */\nexport type NewContact = {\n /** Email address of the contact (required) */\n email: string;\n /** Optional display name for the contact */\n name?: string;\n /** Optional avatar image URL for the contact */\n avatar?: string;\n};\n\nexport type ContentType = \"text\" | \"markdown\" | \"html\";\n";
8
8
  //# sourceMappingURL=plot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/llm-docs/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,4mlBAA4mlB,CAAC"}
1
+ {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../src/llm-docs/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,+hyBAA+hyB,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tag
2
+ * Generated LLM documentation for @plotday/twister/tag
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- declare const _default: "/**\n * Activity tags. Three types:\n * 1. Special tags, which trigger other behaviors\n * 2. Toggle tags, which anyone can toggle a shared value on or off\n * 3. Count tags, where everyone can add or remove their own\n */\nexport enum Tag {\n // Special tags\n Now = 1,\n Later = 2,\n Done = 3,\n Archived = 4,\n\n // Toggle tags\n Pinned = 100,\n Urgent = 101,\n Todo = 102,\n Goal = 103,\n Decision = 104,\n Waiting = 105,\n Blocked = 106,\n Warning = 107,\n Question = 108,\n Twist = 109,\n Star = 110,\n Idea = 111,\n Attachment = 112,\n Link = 113,\n\n // Count tags\n Yes = 1000,\n No = 1001,\n Volunteer = 1002,\n Tada = 1003,\n Fire = 1004,\n Totally = 1005,\n Looking = 1006,\n Love = 1007,\n Rocket = 1008,\n Sparkles = 1009,\n Thanks = 1010,\n Smile = 1011,\n Wave = 1012,\n Praise = 1015,\n Applause = 1016,\n Cool = 1017,\n Sad = 1018,\n Attend = 1019,\n Skip = 1020,\n Undecided = 1021,\n}\n";
7
+ declare const _default: "/**\n * Activity tags. Three types:\n * 1. Special tags, which trigger other behaviors\n * 2. Toggle tags, which anyone can toggle a shared value on or off\n * 3. Count tags, where everyone can add or remove their own\n */\nexport enum Tag {\n // Special tags\n Now = 1,\n Later = 2,\n Done = 3,\n Archived = 4,\n Someday = 7,\n\n // Toggle tags\n Pinned = 100,\n Urgent = 101,\n Inbox = 102,\n Goal = 103,\n Decision = 104,\n Waiting = 105,\n Blocked = 106,\n Warning = 107,\n Question = 108,\n Twist = 109,\n Star = 110,\n Idea = 111,\n\n // Count tags\n Yes = 1000,\n No = 1001,\n Volunteer = 1002,\n Tada = 1003,\n Fire = 1004,\n Totally = 1005,\n Looking = 1006,\n Love = 1007,\n Rocket = 1008,\n Sparkles = 1009,\n Thanks = 1010,\n Smile = 1011,\n Wave = 1012,\n Praise = 1015,\n Applause = 1016,\n Cool = 1017,\n Sad = 1018,\n Attend = 1019,\n Skip = 1020,\n Undecided = 1021,\n}\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=tag.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/llm-docs/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,q7BAAq7B;AAAp8B,wBAAq8B"}
1
+ {"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../src/llm-docs/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,k6BAAk6B;AAAj7B,wBAAk7B"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tag
2
+ * Generated LLM documentation for @plotday/twister/tag
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- export default "/**\n * Activity tags. Three types:\n * 1. Special tags, which trigger other behaviors\n * 2. Toggle tags, which anyone can toggle a shared value on or off\n * 3. Count tags, where everyone can add or remove their own\n */\nexport enum Tag {\n // Special tags\n Now = 1,\n Later = 2,\n Done = 3,\n Archived = 4,\n\n // Toggle tags\n Pinned = 100,\n Urgent = 101,\n Todo = 102,\n Goal = 103,\n Decision = 104,\n Waiting = 105,\n Blocked = 106,\n Warning = 107,\n Question = 108,\n Twist = 109,\n Star = 110,\n Idea = 111,\n Attachment = 112,\n Link = 113,\n\n // Count tags\n Yes = 1000,\n No = 1001,\n Volunteer = 1002,\n Tada = 1003,\n Fire = 1004,\n Totally = 1005,\n Looking = 1006,\n Love = 1007,\n Rocket = 1008,\n Sparkles = 1009,\n Thanks = 1010,\n Smile = 1011,\n Wave = 1012,\n Praise = 1015,\n Applause = 1016,\n Cool = 1017,\n Sad = 1018,\n Attend = 1019,\n Skip = 1020,\n Undecided = 1021,\n}\n";
7
+ export default "/**\n * Activity tags. Three types:\n * 1. Special tags, which trigger other behaviors\n * 2. Toggle tags, which anyone can toggle a shared value on or off\n * 3. Count tags, where everyone can add or remove their own\n */\nexport enum Tag {\n // Special tags\n Now = 1,\n Later = 2,\n Done = 3,\n Archived = 4,\n Someday = 7,\n\n // Toggle tags\n Pinned = 100,\n Urgent = 101,\n Inbox = 102,\n Goal = 103,\n Decision = 104,\n Waiting = 105,\n Blocked = 106,\n Warning = 107,\n Question = 108,\n Twist = 109,\n Star = 110,\n Idea = 111,\n\n // Count tags\n Yes = 1000,\n No = 1001,\n Volunteer = 1002,\n Tada = 1003,\n Fire = 1004,\n Totally = 1005,\n Looking = 1006,\n Love = 1007,\n Rocket = 1008,\n Sparkles = 1009,\n Thanks = 1010,\n Smile = 1011,\n Wave = 1012,\n Praise = 1015,\n Applause = 1016,\n Cool = 1017,\n Sad = 1018,\n Attend = 1019,\n Skip = 1020,\n Undecided = 1021,\n}\n";
8
8
  //# sourceMappingURL=tag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.js","sourceRoot":"","sources":["../../src/llm-docs/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,q7BAAq7B,CAAC"}
1
+ {"version":3,"file":"tag.js","sourceRoot":"","sources":["../../src/llm-docs/tag.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,k6BAAk6B,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tool
2
+ * Generated LLM documentation for @plotday/twister/tool
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- declare const _default: "import { type Priority } from \"./plot\";\nimport type { Callback } from \"./tools/callbacks\";\nimport type {\n InferOptions,\n InferTools,\n ToolBuilder,\n ToolShed,\n} from \"./utils/types\";\n\nexport type { ToolBuilder };\n\n/**\n * Abstrtact parent for both built-in tools and regular Tools.\n * Regular tools extend Tool.\n */\nexport abstract class ITool {}\n\n/**\n * Base class for regular tools.\n *\n * Regular tools run in isolation and can only access other tools declared\n * in their build method. They are ideal for external API integrations\n * and reusable functionality that doesn't require Plot's internal infrastructure.\n *\n * @example\n * ```typescript\n * class GoogleCalendarTool extends Tool<GoogleCalendarTool> {\n * constructor(id: string, options: { clientId: string }) {\n * super(id, options);\n * }\n *\n * build(tools: ToolBuilder) {\n * return {\n * auth: tools.build(Integrations),\n * network: tools.build(Network),\n * };\n * }\n *\n * async getCalendars() {\n * const token = await this.tools.auth.get(...);\n * // Implementation\n * }\n * }\n * ```\n */\nexport abstract class Tool<TSelf> implements ITool {\n constructor(\n protected id: string,\n protected options: InferOptions<TSelf>,\n private toolShed: ToolShed\n ) {}\n\n /**\n * Gets the initialized tools for this tool.\n * @throws Error if called before initialization is complete\n */\n protected get tools() {\n return this.toolShed.getTools<InferTools<TSelf>>();\n }\n\n /**\n * Declares tool dependencies for this tool.\n * Return an object mapping tool names to build() promises.\n * Default implementation returns empty object (no custom tools).\n *\n * @param build - The build function to use for declaring dependencies\n * @returns Object mapping tool names to tool promises\n *\n * @example\n * ```typescript\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, { urls: [\"https://api.example.com/*\"] }),\n * };\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n build(build: ToolBuilder): Record<string, Promise<ITool>> {\n return {};\n }\n\n /**\n * Creates a persistent callback to a method on this tool.\n *\n * ExtraArgs are strongly typed to match the method's signature after the first argument.\n *\n * @param fn - The method to callback\n * @param extraArgs - Additional arguments to pass (type-checked, must be serializable)\n * @returns Promise resolving to a persistent callback token\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onWebhook, \"calendar\", 123);\n * ```\n */\n protected async callback(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback> {\n return this.tools.callbacks.create(fn, ...extraArgs);\n }\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param token - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n protected async deleteCallback(token: Callback): Promise<void> {\n return this.tools.callbacks.delete(token);\n }\n\n /**\n * Deletes all callbacks for this tool.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n protected async deleteAllCallbacks(): Promise<void> {\n return this.tools.callbacks.deleteAll();\n }\n\n /**\n * Executes a callback by its token.\n *\n * @param token - The callback token to execute\n * @param args - Optional arguments to pass to the callback\n * @returns Promise resolving to the callback result\n */\n protected async run(token: Callback, args?: any): Promise<any> {\n return this.tools.callbacks.run(token, args);\n }\n\n /**\n * Retrieves a value from persistent storage by key.\n *\n * @template T - The expected type of the stored value\n * @param key - The storage key to retrieve\n * @returns Promise resolving to the stored value or null\n */\n protected async get<T>(key: string): Promise<T | null> {\n return this.tools.store.get(key);\n }\n\n /**\n * Stores a value in persistent storage.\n *\n * **Important**: Values must be JSON-serializable. Functions, Symbols, and undefined values\n * cannot be stored directly.\n *\n * **For function references**: Use callbacks instead of storing functions directly.\n *\n * @example\n * ```typescript\n * // \u274C WRONG: Cannot store functions directly\n * await this.set(\"handler\", this.myHandler);\n *\n * // \u2705 CORRECT: Create a callback token first\n * const token = await this.callback(this.myHandler, \"arg1\", \"arg2\");\n * await this.set(\"handler_token\", token);\n *\n * // Later, execute the callback\n * const token = await this.get<string>(\"handler_token\");\n * await this.run(token, args);\n * ```\n *\n * @template T - The type of value being stored\n * @param key - The storage key to use\n * @param value - The value to store (must be JSON-serializable)\n * @returns Promise that resolves when the value is stored\n */\n protected async set<T>(key: string, value: T): Promise<void> {\n return this.tools.store.set(key, value);\n }\n\n /**\n * Removes a specific key from persistent storage.\n *\n * @param key - The storage key to remove\n * @returns Promise that resolves when the key is removed\n */\n protected async clear(key: string): Promise<void> {\n return this.tools.store.clear(key);\n }\n\n /**\n * Removes all keys from this tool's storage.\n *\n * @returns Promise that resolves when all keys are removed\n */\n protected async clearAll(): Promise<void> {\n return this.tools.store.clearAll();\n }\n\n /**\n * Queues a callback to execute in a separate worker context.\n *\n * @param callback - The callback token created with `this.callback()`\n * @param options - Optional configuration for the execution\n * @param options.runAt - If provided, schedules execution at this time; otherwise runs immediately\n * @returns Promise resolving to a cancellation token (only for scheduled executions)\n */\n protected async runTask(\n callback: Callback,\n options?: { runAt?: Date }\n ): Promise<string | void> {\n return this.tools.tasks.runTask(callback, options);\n }\n\n /**\n * Cancels a previously scheduled execution.\n *\n * @param token - The cancellation token returned by runTask() with runAt option\n * @returns Promise that resolves when the cancellation is processed\n */\n protected async cancelTask(token: string): Promise<void> {\n return this.tools.tasks.cancelTask(token);\n }\n\n /**\n * Cancels all scheduled executions for this tool.\n *\n * @returns Promise that resolves when all cancellations are processed\n */\n protected async cancelAllTasks(): Promise<void> {\n return this.tools.tasks.cancelAllTasks();\n }\n\n /**\n * Called before the twist's activate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * activate method is called.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when pre-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n preActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's activate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when post-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n postActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's upgrade method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * upgrade method is called.\n *\n * @returns Promise that resolves when pre-upgrade is complete\n */\n preUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's upgrade method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-upgrade is complete\n */\n postUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's deactivate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * deactivate method is called.\n *\n * @returns Promise that resolves when pre-deactivation is complete\n */\n preDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's deactivate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-deactivation is complete\n */\n postDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Waits for tool initialization to complete.\n * Called automatically by the entrypoint before lifecycle methods.\n * @internal\n */\n async waitForReady(): Promise<void> {\n await this.toolShed.waitForReady();\n }\n}\n";
7
+ declare const _default: "import { type Priority } from \"./plot\";\nimport type { Callback } from \"./tools/callbacks\";\nimport type {\n InferOptions,\n InferTools,\n ToolBuilder,\n ToolShed,\n} from \"./utils/types\";\n\nexport type { ToolBuilder };\n\n/**\n * Abstrtact parent for both built-in tools and regular Tools.\n * Regular tools extend Tool.\n */\nexport abstract class ITool {}\n\n/**\n * Base class for regular tools.\n *\n * Regular tools run in isolation and can only access other tools declared\n * in their build method. They are ideal for external API integrations\n * and reusable functionality that doesn't require Plot's internal infrastructure.\n *\n * @example\n * ```typescript\n * class GoogleCalendarTool extends Tool<GoogleCalendarTool> {\n * constructor(id: string, options: { clientId: string }) {\n * super(id, options);\n * }\n *\n * build(tools: ToolBuilder) {\n * return {\n * auth: tools.build(Integrations),\n * network: tools.build(Network),\n * };\n * }\n *\n * async getCalendars() {\n * const token = await this.tools.auth.get(...);\n * // Implementation\n * }\n * }\n * ```\n */\nexport abstract class Tool<TSelf> implements ITool {\n constructor(\n protected id: string,\n protected options: InferOptions<TSelf>,\n private toolShed: ToolShed\n ) {}\n\n /**\n * Gets the initialized tools for this tool.\n * @throws Error if called before initialization is complete\n */\n protected get tools() {\n return this.toolShed.getTools<InferTools<TSelf>>();\n }\n\n /**\n * Declares tool dependencies for this tool.\n * Return an object mapping tool names to build() promises.\n * Default implementation returns empty object (no custom tools).\n *\n * @param build - The build function to use for declaring dependencies\n * @returns Object mapping tool names to tool promises\n *\n * @example\n * ```typescript\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, { urls: [\"https://api.example.com/*\"] }),\n * };\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n build(build: ToolBuilder): Record<string, Promise<ITool>> {\n return {};\n }\n\n /**\n * Creates a persistent callback to a method on this tool.\n *\n * ExtraArgs are strongly typed to match the method's signature.\n *\n * @param fn - The method to callback\n * @param extraArgs - Additional arguments to pass (type-checked, must be serializable)\n * @returns Promise resolving to a persistent callback token\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onWebhook, \"calendar\", 123);\n * ```\n */\n protected async callback<Fn extends (...args: any[]) => any>(\n fn: Fn,\n ...extraArgs: Parameters<Fn>\n ): Promise<Callback> {\n return this.tools.callbacks.create(fn, ...extraArgs);\n }\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param token - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n protected async deleteCallback(token: Callback): Promise<void> {\n return this.tools.callbacks.delete(token);\n }\n\n /**\n * Deletes all callbacks for this tool.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n protected async deleteAllCallbacks(): Promise<void> {\n return this.tools.callbacks.deleteAll();\n }\n\n /**\n * Executes a callback by its token.\n *\n * @param token - The callback token to execute\n * @param args - Optional arguments to pass to the callback\n * @returns Promise resolving to the callback result\n */\n protected async run(token: Callback, args?: any): Promise<any> {\n return this.tools.callbacks.run(token, args);\n }\n\n /**\n * Retrieves a value from persistent storage by key.\n *\n * @template T - The expected type of the stored value\n * @param key - The storage key to retrieve\n * @returns Promise resolving to the stored value or null\n */\n protected async get<T>(key: string): Promise<T | null> {\n return this.tools.store.get(key);\n }\n\n /**\n * Stores a value in persistent storage.\n *\n * **Important**: Values must be JSON-serializable. Functions, Symbols, and undefined values\n * cannot be stored directly.\n *\n * **For function references**: Use callbacks instead of storing functions directly.\n *\n * @example\n * ```typescript\n * // \u274C WRONG: Cannot store functions directly\n * await this.set(\"handler\", this.myHandler);\n *\n * // \u2705 CORRECT: Create a callback token first\n * const token = await this.callback(this.myHandler, \"arg1\", \"arg2\");\n * await this.set(\"handler_token\", token);\n *\n * // Later, execute the callback\n * const token = await this.get<string>(\"handler_token\");\n * await this.run(token, args);\n * ```\n *\n * @template T - The type of value being stored\n * @param key - The storage key to use\n * @param value - The value to store (must be JSON-serializable)\n * @returns Promise that resolves when the value is stored\n */\n protected async set<T>(key: string, value: T): Promise<void> {\n return this.tools.store.set(key, value);\n }\n\n /**\n * Removes a specific key from persistent storage.\n *\n * @param key - The storage key to remove\n * @returns Promise that resolves when the key is removed\n */\n protected async clear(key: string): Promise<void> {\n return this.tools.store.clear(key);\n }\n\n /**\n * Removes all keys from this tool's storage.\n *\n * @returns Promise that resolves when all keys are removed\n */\n protected async clearAll(): Promise<void> {\n return this.tools.store.clearAll();\n }\n\n /**\n * Queues a callback to execute in a separate worker context.\n *\n * @param callback - The callback token created with `this.callback()`\n * @param options - Optional configuration for the execution\n * @param options.runAt - If provided, schedules execution at this time; otherwise runs immediately\n * @returns Promise resolving to a cancellation token (only for scheduled executions)\n */\n protected async runTask(\n callback: Callback,\n options?: { runAt?: Date }\n ): Promise<string | void> {\n return this.tools.tasks.runTask(callback, options);\n }\n\n /**\n * Cancels a previously scheduled execution.\n *\n * @param token - The cancellation token returned by runTask() with runAt option\n * @returns Promise that resolves when the cancellation is processed\n */\n protected async cancelTask(token: string): Promise<void> {\n return this.tools.tasks.cancelTask(token);\n }\n\n /**\n * Cancels all scheduled executions for this tool.\n *\n * @returns Promise that resolves when all cancellations are processed\n */\n protected async cancelAllTasks(): Promise<void> {\n return this.tools.tasks.cancelAllTasks();\n }\n\n /**\n * Called before the twist's activate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * activate method is called.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when pre-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n preActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's activate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when post-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n postActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's upgrade method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * upgrade method is called.\n *\n * @returns Promise that resolves when pre-upgrade is complete\n */\n preUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's upgrade method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-upgrade is complete\n */\n postUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's deactivate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * deactivate method is called.\n *\n * @returns Promise that resolves when pre-deactivation is complete\n */\n preDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's deactivate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-deactivation is complete\n */\n postDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Waits for tool initialization to complete.\n * Called automatically by the entrypoint before lifecycle methods.\n * @internal\n */\n async waitForReady(): Promise<void> {\n await this.toolShed.waitForReady();\n }\n}\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/llm-docs/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,+1TAAq1T;AAAp2T,wBAAq2T"}
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/llm-docs/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,62TAAm2T;AAAl3T,wBAAm3T"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tool
2
+ * Generated LLM documentation for @plotday/twister/tool
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- export default "import { type Priority } from \"./plot\";\nimport type { Callback } from \"./tools/callbacks\";\nimport type {\n InferOptions,\n InferTools,\n ToolBuilder,\n ToolShed,\n} from \"./utils/types\";\n\nexport type { ToolBuilder };\n\n/**\n * Abstrtact parent for both built-in tools and regular Tools.\n * Regular tools extend Tool.\n */\nexport abstract class ITool {}\n\n/**\n * Base class for regular tools.\n *\n * Regular tools run in isolation and can only access other tools declared\n * in their build method. They are ideal for external API integrations\n * and reusable functionality that doesn't require Plot's internal infrastructure.\n *\n * @example\n * ```typescript\n * class GoogleCalendarTool extends Tool<GoogleCalendarTool> {\n * constructor(id: string, options: { clientId: string }) {\n * super(id, options);\n * }\n *\n * build(tools: ToolBuilder) {\n * return {\n * auth: tools.build(Integrations),\n * network: tools.build(Network),\n * };\n * }\n *\n * async getCalendars() {\n * const token = await this.tools.auth.get(...);\n * // Implementation\n * }\n * }\n * ```\n */\nexport abstract class Tool<TSelf> implements ITool {\n constructor(\n protected id: string,\n protected options: InferOptions<TSelf>,\n private toolShed: ToolShed\n ) {}\n\n /**\n * Gets the initialized tools for this tool.\n * @throws Error if called before initialization is complete\n */\n protected get tools() {\n return this.toolShed.getTools<InferTools<TSelf>>();\n }\n\n /**\n * Declares tool dependencies for this tool.\n * Return an object mapping tool names to build() promises.\n * Default implementation returns empty object (no custom tools).\n *\n * @param build - The build function to use for declaring dependencies\n * @returns Object mapping tool names to tool promises\n *\n * @example\n * ```typescript\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, { urls: [\"https://api.example.com/*\"] }),\n * };\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n build(build: ToolBuilder): Record<string, Promise<ITool>> {\n return {};\n }\n\n /**\n * Creates a persistent callback to a method on this tool.\n *\n * ExtraArgs are strongly typed to match the method's signature after the first argument.\n *\n * @param fn - The method to callback\n * @param extraArgs - Additional arguments to pass (type-checked, must be serializable)\n * @returns Promise resolving to a persistent callback token\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onWebhook, \"calendar\", 123);\n * ```\n */\n protected async callback(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback> {\n return this.tools.callbacks.create(fn, ...extraArgs);\n }\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param token - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n protected async deleteCallback(token: Callback): Promise<void> {\n return this.tools.callbacks.delete(token);\n }\n\n /**\n * Deletes all callbacks for this tool.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n protected async deleteAllCallbacks(): Promise<void> {\n return this.tools.callbacks.deleteAll();\n }\n\n /**\n * Executes a callback by its token.\n *\n * @param token - The callback token to execute\n * @param args - Optional arguments to pass to the callback\n * @returns Promise resolving to the callback result\n */\n protected async run(token: Callback, args?: any): Promise<any> {\n return this.tools.callbacks.run(token, args);\n }\n\n /**\n * Retrieves a value from persistent storage by key.\n *\n * @template T - The expected type of the stored value\n * @param key - The storage key to retrieve\n * @returns Promise resolving to the stored value or null\n */\n protected async get<T>(key: string): Promise<T | null> {\n return this.tools.store.get(key);\n }\n\n /**\n * Stores a value in persistent storage.\n *\n * **Important**: Values must be JSON-serializable. Functions, Symbols, and undefined values\n * cannot be stored directly.\n *\n * **For function references**: Use callbacks instead of storing functions directly.\n *\n * @example\n * ```typescript\n * // ❌ WRONG: Cannot store functions directly\n * await this.set(\"handler\", this.myHandler);\n *\n * // ✅ CORRECT: Create a callback token first\n * const token = await this.callback(this.myHandler, \"arg1\", \"arg2\");\n * await this.set(\"handler_token\", token);\n *\n * // Later, execute the callback\n * const token = await this.get<string>(\"handler_token\");\n * await this.run(token, args);\n * ```\n *\n * @template T - The type of value being stored\n * @param key - The storage key to use\n * @param value - The value to store (must be JSON-serializable)\n * @returns Promise that resolves when the value is stored\n */\n protected async set<T>(key: string, value: T): Promise<void> {\n return this.tools.store.set(key, value);\n }\n\n /**\n * Removes a specific key from persistent storage.\n *\n * @param key - The storage key to remove\n * @returns Promise that resolves when the key is removed\n */\n protected async clear(key: string): Promise<void> {\n return this.tools.store.clear(key);\n }\n\n /**\n * Removes all keys from this tool's storage.\n *\n * @returns Promise that resolves when all keys are removed\n */\n protected async clearAll(): Promise<void> {\n return this.tools.store.clearAll();\n }\n\n /**\n * Queues a callback to execute in a separate worker context.\n *\n * @param callback - The callback token created with `this.callback()`\n * @param options - Optional configuration for the execution\n * @param options.runAt - If provided, schedules execution at this time; otherwise runs immediately\n * @returns Promise resolving to a cancellation token (only for scheduled executions)\n */\n protected async runTask(\n callback: Callback,\n options?: { runAt?: Date }\n ): Promise<string | void> {\n return this.tools.tasks.runTask(callback, options);\n }\n\n /**\n * Cancels a previously scheduled execution.\n *\n * @param token - The cancellation token returned by runTask() with runAt option\n * @returns Promise that resolves when the cancellation is processed\n */\n protected async cancelTask(token: string): Promise<void> {\n return this.tools.tasks.cancelTask(token);\n }\n\n /**\n * Cancels all scheduled executions for this tool.\n *\n * @returns Promise that resolves when all cancellations are processed\n */\n protected async cancelAllTasks(): Promise<void> {\n return this.tools.tasks.cancelAllTasks();\n }\n\n /**\n * Called before the twist's activate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * activate method is called.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when pre-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n preActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's activate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when post-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n postActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's upgrade method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * upgrade method is called.\n *\n * @returns Promise that resolves when pre-upgrade is complete\n */\n preUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's upgrade method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-upgrade is complete\n */\n postUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's deactivate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * deactivate method is called.\n *\n * @returns Promise that resolves when pre-deactivation is complete\n */\n preDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's deactivate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-deactivation is complete\n */\n postDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Waits for tool initialization to complete.\n * Called automatically by the entrypoint before lifecycle methods.\n * @internal\n */\n async waitForReady(): Promise<void> {\n await this.toolShed.waitForReady();\n }\n}\n";
7
+ export default "import { type Priority } from \"./plot\";\nimport type { Callback } from \"./tools/callbacks\";\nimport type {\n InferOptions,\n InferTools,\n ToolBuilder,\n ToolShed,\n} from \"./utils/types\";\n\nexport type { ToolBuilder };\n\n/**\n * Abstrtact parent for both built-in tools and regular Tools.\n * Regular tools extend Tool.\n */\nexport abstract class ITool {}\n\n/**\n * Base class for regular tools.\n *\n * Regular tools run in isolation and can only access other tools declared\n * in their build method. They are ideal for external API integrations\n * and reusable functionality that doesn't require Plot's internal infrastructure.\n *\n * @example\n * ```typescript\n * class GoogleCalendarTool extends Tool<GoogleCalendarTool> {\n * constructor(id: string, options: { clientId: string }) {\n * super(id, options);\n * }\n *\n * build(tools: ToolBuilder) {\n * return {\n * auth: tools.build(Integrations),\n * network: tools.build(Network),\n * };\n * }\n *\n * async getCalendars() {\n * const token = await this.tools.auth.get(...);\n * // Implementation\n * }\n * }\n * ```\n */\nexport abstract class Tool<TSelf> implements ITool {\n constructor(\n protected id: string,\n protected options: InferOptions<TSelf>,\n private toolShed: ToolShed\n ) {}\n\n /**\n * Gets the initialized tools for this tool.\n * @throws Error if called before initialization is complete\n */\n protected get tools() {\n return this.toolShed.getTools<InferTools<TSelf>>();\n }\n\n /**\n * Declares tool dependencies for this tool.\n * Return an object mapping tool names to build() promises.\n * Default implementation returns empty object (no custom tools).\n *\n * @param build - The build function to use for declaring dependencies\n * @returns Object mapping tool names to tool promises\n *\n * @example\n * ```typescript\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, { urls: [\"https://api.example.com/*\"] }),\n * };\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n build(build: ToolBuilder): Record<string, Promise<ITool>> {\n return {};\n }\n\n /**\n * Creates a persistent callback to a method on this tool.\n *\n * ExtraArgs are strongly typed to match the method's signature.\n *\n * @param fn - The method to callback\n * @param extraArgs - Additional arguments to pass (type-checked, must be serializable)\n * @returns Promise resolving to a persistent callback token\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onWebhook, \"calendar\", 123);\n * ```\n */\n protected async callback<Fn extends (...args: any[]) => any>(\n fn: Fn,\n ...extraArgs: Parameters<Fn>\n ): Promise<Callback> {\n return this.tools.callbacks.create(fn, ...extraArgs);\n }\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param token - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n protected async deleteCallback(token: Callback): Promise<void> {\n return this.tools.callbacks.delete(token);\n }\n\n /**\n * Deletes all callbacks for this tool.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n protected async deleteAllCallbacks(): Promise<void> {\n return this.tools.callbacks.deleteAll();\n }\n\n /**\n * Executes a callback by its token.\n *\n * @param token - The callback token to execute\n * @param args - Optional arguments to pass to the callback\n * @returns Promise resolving to the callback result\n */\n protected async run(token: Callback, args?: any): Promise<any> {\n return this.tools.callbacks.run(token, args);\n }\n\n /**\n * Retrieves a value from persistent storage by key.\n *\n * @template T - The expected type of the stored value\n * @param key - The storage key to retrieve\n * @returns Promise resolving to the stored value or null\n */\n protected async get<T>(key: string): Promise<T | null> {\n return this.tools.store.get(key);\n }\n\n /**\n * Stores a value in persistent storage.\n *\n * **Important**: Values must be JSON-serializable. Functions, Symbols, and undefined values\n * cannot be stored directly.\n *\n * **For function references**: Use callbacks instead of storing functions directly.\n *\n * @example\n * ```typescript\n * // ❌ WRONG: Cannot store functions directly\n * await this.set(\"handler\", this.myHandler);\n *\n * // ✅ CORRECT: Create a callback token first\n * const token = await this.callback(this.myHandler, \"arg1\", \"arg2\");\n * await this.set(\"handler_token\", token);\n *\n * // Later, execute the callback\n * const token = await this.get<string>(\"handler_token\");\n * await this.run(token, args);\n * ```\n *\n * @template T - The type of value being stored\n * @param key - The storage key to use\n * @param value - The value to store (must be JSON-serializable)\n * @returns Promise that resolves when the value is stored\n */\n protected async set<T>(key: string, value: T): Promise<void> {\n return this.tools.store.set(key, value);\n }\n\n /**\n * Removes a specific key from persistent storage.\n *\n * @param key - The storage key to remove\n * @returns Promise that resolves when the key is removed\n */\n protected async clear(key: string): Promise<void> {\n return this.tools.store.clear(key);\n }\n\n /**\n * Removes all keys from this tool's storage.\n *\n * @returns Promise that resolves when all keys are removed\n */\n protected async clearAll(): Promise<void> {\n return this.tools.store.clearAll();\n }\n\n /**\n * Queues a callback to execute in a separate worker context.\n *\n * @param callback - The callback token created with `this.callback()`\n * @param options - Optional configuration for the execution\n * @param options.runAt - If provided, schedules execution at this time; otherwise runs immediately\n * @returns Promise resolving to a cancellation token (only for scheduled executions)\n */\n protected async runTask(\n callback: Callback,\n options?: { runAt?: Date }\n ): Promise<string | void> {\n return this.tools.tasks.runTask(callback, options);\n }\n\n /**\n * Cancels a previously scheduled execution.\n *\n * @param token - The cancellation token returned by runTask() with runAt option\n * @returns Promise that resolves when the cancellation is processed\n */\n protected async cancelTask(token: string): Promise<void> {\n return this.tools.tasks.cancelTask(token);\n }\n\n /**\n * Cancels all scheduled executions for this tool.\n *\n * @returns Promise that resolves when all cancellations are processed\n */\n protected async cancelAllTasks(): Promise<void> {\n return this.tools.tasks.cancelAllTasks();\n }\n\n /**\n * Called before the twist's activate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * activate method is called.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when pre-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n preActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's activate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @param priority - The priority context containing the priority ID\n * @returns Promise that resolves when post-activation is complete\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n postActivate(priority: Priority): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's upgrade method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * upgrade method is called.\n *\n * @returns Promise that resolves when pre-upgrade is complete\n */\n preUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's upgrade method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-upgrade is complete\n */\n postUpgrade(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called before the twist's deactivate method, starting from the deepest tool dependencies.\n *\n * This method is called in a depth-first manner, with the deepest dependencies\n * being called first, bubbling up to the top-level tools before the twist's\n * deactivate method is called.\n *\n * @returns Promise that resolves when pre-deactivation is complete\n */\n preDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Called after the twist's deactivate method, starting from the top-level tools.\n *\n * This method is called in reverse order, with top-level tools being called\n * first, then cascading down to the deepest dependencies.\n *\n * @returns Promise that resolves when post-deactivation is complete\n */\n postDeactivate(): Promise<void> {\n return Promise.resolve();\n }\n\n /**\n * Waits for tool initialization to complete.\n * Called automatically by the entrypoint before lifecycle methods.\n * @internal\n */\n async waitForReady(): Promise<void> {\n await this.toolShed.waitForReady();\n }\n}\n";
8
8
  //# sourceMappingURL=tool.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/llm-docs/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,q1TAAq1T,CAAC"}
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/llm-docs/tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,m2TAAm2T,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/ai
2
+ * Generated LLM documentation for @plotday/twister/tools/ai
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
6
6
  */
7
- declare const _default: "import type { Static, TSchema } from \"typebox\";\n\nimport { ITool } from \"..\";\n\n/**\n * Built-in tool for prompting Large Language Models (LLMs).\n *\n * The AI tool provides twists and tools with access to LLM capabilities\n * for natural language processing, text generation, data extraction,\n * and intelligent decision making within their workflows.\n *\n * **Features:**\n * - Access to multiple AI providers (OpenAI, Anthropic, Google, Workers AI)\n * - Multi-turn conversation support with `messages`\n * - Tool calling with automatic execution\n * - Structured output with Typebox schemas via `outputSchema`\n * - Unified API across all models via Vercel AI SDK\n * - Automatic response parsing and validation with full type inference\n *\n * @example\n * ```typescript\n * import { Type } from \"typebox\";\n *\n * class SmartEmailTool extends Tool {\n * private ai: AI;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.ai = tools.get(AI);\n * }\n *\n * async categorizeEmail(emailContent: string) {\n * // Define the output schema using Typebox\n * const schema = Type.Object({\n * category: Type.Union([\n * Type.Literal(\"work\"),\n * Type.Literal(\"personal\"),\n * Type.Literal(\"spam\"),\n * Type.Literal(\"promotional\")\n * ]),\n * confidence: Type.Number({ minimum: 0, maximum: 1 }),\n * reasoning: Type.Optional(Type.String())\n * });\n *\n * const response = await this.ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * system: \"Classify emails into categories: work, personal, spam, or promotional.\",\n * prompt: `Categorize this email: ${emailContent}`,\n * outputSchema: schema\n * });\n *\n * return response.output;\n * }\n *\n * async generateResponse(emailContent: string) {\n * const response = await this.ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * system: \"Generate professional email responses that are helpful and concise.\",\n * prompt: `Write a response to: ${emailContent}`\n * });\n *\n * return response.text;\n * }\n * }\n * ```\n */\nexport abstract class AI extends ITool {\n /**\n * Sends a request to an AI model and returns the response using the Vercel AI SDK.\n *\n * Supports text generation, multi-turn conversations, structured outputs,\n * and tool calling across multiple AI providers via Cloudflare AI Gateway.\n *\n * @param request - AI request with model, prompt/messages, and optional configuration\n * @returns Promise resolving to the AI response with generated text and metadata\n *\n * @example\n * ```typescript\n * // Simple text generation\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * prompt: \"Explain quantum computing in simple terms\"\n * });\n * console.log(response.text);\n *\n * // Fast and cheap for simple tasks\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"low\" },\n * prompt: \"Summarize this text...\"\n * });\n * console.log(response.text);\n *\n * // With system instructions for complex reasoning\n * const response = await ai.prompt({\n * model: { speed: \"capable\", cost: \"high\" },\n * system: \"You are a helpful physics tutor.\",\n * prompt: \"Explain quantum entanglement\"\n * });\n * console.log(response.text);\n *\n * // Multi-turn conversation\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * messages: [\n * { role: \"user\", content: \"What is 2+2?\" },\n * { role: \"assistant\", content: \"2+2 equals 4.\" },\n * { role: \"user\", content: \"What about 3+3?\" }\n * ]\n * });\n * console.log(response.text);\n *\n * // Structured output with Typebox schema\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * prompt: \"Extract information: John is 30 years old\",\n * outputSchema: Type.Object({\n * name: Type.String(),\n * age: Type.Number()\n * })\n * });\n * console.log(response.output); // { name: \"John\", age: 30 }\n *\n * // Tool calling\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * prompt: \"What's the weather in San Francisco?\",\n * tools: {\n * getWeather: {\n * description: \"Get weather for a city\",\n * parameters: Type.Object({\n * city: Type.String()\n * }),\n * execute: async ({ city }) => {\n * return { temp: 72, condition: \"sunny\" };\n * }\n * }\n * }\n * });\n * console.log(response.text); // Model's response using tool results\n * console.log(response.toolCalls); // Array of tool calls made\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract prompt<TOOLS extends AIToolSet, SCHEMA extends TSchema = never>(\n request: AIRequest<TOOLS, SCHEMA>\n ): Promise<AIResponse<TOOLS, SCHEMA>>;\n}\n\n/**\n * Model preferences for selecting an AI model based on performance and cost requirements.\n * This allows Plot to match those preferences with user preferences (such as preferred or\n * disallowed providers), as well as availability of newer and better models.\n *\n * @example\n * ```typescript\n * // Fast and cheap - uses Workers AI models like Llama 3.2 1B\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"low\" },\n * prompt: \"Summarize this in one sentence: ...\"\n * });\n *\n * // Balanced performance - uses GPT-5 Mini or Gemini 2.5 Flash\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * prompt: \"Analyze this data...\"\n * });\n *\n * // Most capable - uses Claude Sonnet 4.5 or Opus 4.1\n * const response = await ai.prompt({\n * model: { speed: \"capable\", cost: \"high\" },\n * prompt: \"Solve this complex reasoning problem...\"\n * });\n *\n * // Request a specific model with a hint\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\", hint: AIModel.CLAUDE_SONNET_45 },\n * prompt: \"...\"\n * });\n * ```\n */\nexport type ModelPreferences = {\n /**\n * Desired speed tier:\n * - \"fast\": Optimized for low latency and quick responses\n * - \"balanced\": Good balance of speed and capability\n * - \"capable\": Maximum reasoning and problem-solving ability\n */\n speed: \"fast\" | \"balanced\" | \"capable\";\n\n /**\n * Desired cost tier:\n * - \"low\": Minimal cost, often using Workers AI models (free/very cheap)\n * - \"medium\": Moderate pricing for good performance\n * - \"high\": Premium pricing for best-in-class models\n */\n cost: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional hint to suggest a specific model. The system will use this\n * model if possible, but may override it based on user preferences.\n */\n hint?: AIModel;\n};\n\n/**\n * Supported AI models available through Cloudflare AI Gateway and Workers AI.\n *\n * Models are organized by provider:\n * - **OpenAI**: Latest GPT models via AI Gateway\n * - **Anthropic**: Claude models via AI Gateway (prefix with \"anthropic/\")\n * - **Google**: Gemini models via AI Gateway (prefix with \"google-ai-studio/\")\n * - **Workers AI**: Models running on Cloudflare's network (free/low cost)\n */\nexport enum AIModel {\n // OpenAI models - Latest GPT and reasoning models\n GPT_5 = \"openai/gpt-5\",\n GPT_5_PRO = \"openai/gpt-5-pro\",\n GPT_5_MINI = \"openai/gpt-5-mini\",\n GPT_5_NANO = \"openai/gpt-5-nano\",\n GPT_4O = \"openai/gpt-4o\",\n GPT_4O_MINI = \"openai/gpt-4o-mini\",\n O3 = \"openai/o3\",\n O3_MINI = \"openai/o3-mini\",\n\n // Anthropic models - Claude 4.x and 3.7 series\n CLAUDE_SONNET_45 = \"anthropic/claude-sonnet-4-5\",\n CLAUDE_HAIKU_45 = \"anthropic/claude-haiku-4-5\",\n CLAUDE_OPUS_41 = \"anthropic/claude-opus-4-1\",\n CLAUDE_37_SONNET = \"anthropic/claude-3-7-sonnet-latest\",\n\n // Google models - Gemini 2.x series\n GEMINI_25_PRO = \"google/gemini-2.5-pro\",\n GEMINI_25_FLASH = \"google/gemini-2.5-flash\",\n GEMINI_25_FLASH_LITE = \"google/gemini-2.5-flash-lite\",\n GEMINI_20_FLASH = \"google/gemini-2.0-flash\",\n GEMINI_20_FLASH_LITE = \"google/gemini-2.0-flash-lite\",\n\n // Cloudflare Workers AI models - Free/low-cost models running on Cloudflare's network\n LLAMA_4_SCOUT_17B = \"meta/llama-4-scout-17b-16e-instruct\",\n LLAMA_33_70B = \"meta/llama-3.3-70b-instruct-fp8-fast\",\n LLAMA_31_8B = \"meta/llama-3.1-8b-instruct-fp8\",\n LLAMA_32_1B = \"meta/llama-3.2-1b-instruct\",\n DEEPSEEK_R1_32B = \"deepseek-ai/deepseek-r1-distill-qwen-32b\",\n}\n\n/**\n * Request parameters for AI text generation, matching Vercel AI SDK's generateText() function.\n */\nexport interface AIRequest<\n TOOLS extends AIToolSet,\n SCHEMA extends TSchema = never\n> {\n /**\n * Model selection preferences based on desired speed and cost characteristics.\n * Plot will automatically select the best available model matching these preferences.\n *\n * @example\n * // Fast and cheap - good for simple tasks\n * model: { speed: \"fast\", cost: \"low\" }\n *\n * @example\n * // Balanced performance - general purpose\n * model: { speed: \"balanced\", cost: \"medium\" }\n *\n * @example\n * // Maximum capability - complex reasoning\n * model: { speed: \"capable\", cost: \"high\" }\n *\n * @example\n * // With a specific model hint\n * model: { speed: \"balanced\", cost: \"medium\", hint: \"anthropic/claude-sonnet-4-5\" }\n */\n model: ModelPreferences;\n\n /**\n * System instructions to guide the model's behavior.\n */\n system?: string;\n\n /**\n * The user's input prompt. Can be a simple string or an array of messages for multi-turn conversations.\n */\n prompt?: string;\n\n /**\n * Conversation messages for multi-turn interactions.\n * Replaces 'prompt' for more complex conversations.\n */\n messages?: AIMessage[];\n\n /**\n * Tools that the model can call during generation.\n * Each tool definition includes a description, input schema, and optional execute function.\n */\n tools?: TOOLS;\n\n /**\n * Controls which tools the model can use.\n * - \"auto\": Model decides whether to use tools\n * - \"none\": Model cannot use tools\n * - \"required\": Model must use at least one tool\n * - { type: \"tool\", toolName: string }: Model must use specific tool\n */\n toolChoice?: ToolChoice<TOOLS>;\n\n /**\n * Structured output schema using Typebox.\n * Typebox schemas are JSON Schema objects that provide full TypeScript type inference.\n */\n outputSchema?: SCHEMA;\n\n /**\n * Maximum number of tokens to generate.\n */\n maxOutputTokens?: number;\n\n /**\n * Temperature for controlling randomness (0-2).\n * Higher values make output more random, lower values more deterministic.\n */\n temperature?: number;\n\n /**\n * Top P sampling parameter (0-1).\n * Controls diversity by limiting to top probability tokens.\n */\n topP?: number;\n}\n\n/**\n * Response from AI text generation, matching Vercel AI SDK's GenerateTextResult.\n */\nexport interface AIResponse<\n TOOLS extends AIToolSet,\n SCHEMA extends TSchema = never\n> {\n /**\n * The generated text.\n */\n text: string;\n\n /**\n * Tool calls made by the model during generation.\n */\n toolCalls?: ToolCallArray<TOOLS>;\n\n /**\n * Results from tool executions.\n */\n toolResults?: ToolResultArray<TOOLS>;\n\n /**\n * Reason why the model stopped generating.\n */\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n\n /**\n * Token usage information for this generation.\n */\n usage: AIUsage;\n\n /**\n * Sources used by the model (if supported).\n */\n sources?: Array<AISource>;\n\n /**\n * Structured output when using outputSchema.\n * Type is automatically inferred from the Typebox schema.\n */\n output?: Static<SCHEMA>;\n\n /**\n * Response metadata including messages.\n */\n response?: {\n id?: string;\n timestamp?: Date;\n modelId?: string;\n messages?: AIMessage[];\n };\n}\n\n// ============================================================================\n// Message Types\n// ============================================================================\n\n/**\n * A system message. It can contain system information.\n *\n * Note: using the \"system\" part of the prompt is strongly preferred\n * to increase the resilience against prompt injection attacks,\n * and because not all providers support several system messages.\n */\nexport type AISystemMessage = {\n role: \"system\";\n content: string;\n};\n\n/**\n * A user message. It can contain text or a combination of text and images.\n */\nexport type AIUserMessage = {\n role: \"user\";\n content: string | Array<TextPart | ImagePart | FilePart>;\n};\n\n/**\n * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.\n */\nexport type AIAssistantMessage = {\n role: \"assistant\";\n content:\n | string\n | Array<\n TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart\n >;\n};\n\n/**\n * A tool message. It contains the result of one or more tool calls.\n */\nexport type AIToolMessage = {\n role: \"tool\";\n content: Array<ToolResultPart>;\n};\n\n/**\n * A message that can be used in the `messages` field of a prompt.\n * It can be a user message, an assistant message, or a tool message.\n */\nexport type AIMessage =\n | AISystemMessage\n | AIUserMessage\n | AIAssistantMessage\n | AIToolMessage;\n\n// ============================================================================\n// Usage & Sources\n// ============================================================================\n\n/**\n * Represents the number of tokens used in a prompt and completion.\n */\nexport type AIUsage = {\n /**\n * The number of tokens used in the prompt.\n */\n inputTokens?: number;\n /**\n * The number of tokens used in the completion.\n */\n outputTokens?: number;\n /**\n * The total number of tokens used (promptTokens + completionTokens).\n */\n totalTokens?: number;\n /**\n * The number of reasoning tokens used in the completion.\n */\n reasoningTokens?: number;\n};\n\n/**\n * A source that has been used as input to generate the response.\n */\nexport type AISource =\n | {\n type: \"source\";\n /**\n * A URL source. This is returned by web search RAG models.\n */\n sourceType: \"url\";\n /**\n * The ID of the source.\n */\n id: string;\n /**\n * The URL of the source.\n */\n url: string;\n /**\n * The title of the source.\n */\n title?: string;\n }\n | {\n type: \"source\";\n /**\n * The type of source - document sources reference files/documents.\n */\n sourceType: \"document\";\n /**\n * The ID of the source.\n */\n id: string;\n /**\n * IANA media type of the document (e.g., 'application/pdf').\n */\n mediaType: string;\n /**\n * The title of the document.\n */\n title: string;\n /**\n * Optional filename of the document.\n */\n filename?: string;\n };\n\n// ============================================================================\n// Content Parts\n// ============================================================================\n\n/**\n * Text content part of a prompt. It contains a string of text.\n */\nexport interface TextPart {\n type: \"text\";\n /**\n * The text content.\n */\n text: string;\n}\n\n/**\n * Data content. Can either be a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer.\n */\nexport type DataContent = string | Uint8Array | ArrayBuffer | Buffer;\n\n/**\n * Image content part of a prompt. It contains an image.\n */\nexport interface ImagePart {\n type: \"image\";\n /**\n * Image data. Can either be:\n *\n * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer\n * - URL: a URL that points to the image\n */\n image: DataContent | URL;\n /**\n * Optional mime type of the image.\n */\n mimeType?: string;\n}\n\n/**\n * File content part of a prompt. It contains a file.\n */\nexport interface FilePart {\n type: \"file\";\n /**\n * File data. Can either be:\n *\n * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer\n * - URL: a URL that points to the file\n */\n data: DataContent | URL;\n /**\n * Optional filename of the file.\n */\n filename?: string;\n /**\n * IANA media type of the file.\n *\n * @see https://www.iana.org/assignments/media-types/media-types.xhtml\n */\n mediaType: string;\n}\n\n/**\n * Reasoning content part of a prompt. It contains a reasoning.\n */\nexport interface ReasoningPart {\n type: \"reasoning\";\n /**\n * The reasoning text.\n */\n text: string;\n /**\n * An optional signature for verifying that the reasoning originated from the model.\n */\n signature?: string;\n}\n\n/**\n * Redacted reasoning content part of a prompt.\n */\nexport interface RedactedReasoningPart {\n type: \"redacted-reasoning\";\n /**\n * Redacted reasoning data.\n */\n data: string;\n}\n\n/**\n * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).\n */\nexport interface ToolCallPart {\n type: \"tool-call\";\n /**\n * ID of the tool call. This ID is used to match the tool call with the tool result.\n */\n toolCallId: string;\n /**\n * Name of the tool that is being called.\n */\n toolName: string;\n /**\n * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.\n */\n input: unknown;\n}\n\ntype JSONValue = null | string | number | boolean | JSONObject | JSONArray;\ntype JSONObject = {\n [key: string]: JSONValue;\n};\ntype JSONArray = JSONValue[];\n\n/**\n * Tool result content part of a prompt. It contains the result of the tool call with the matching ID.\n */\nexport interface ToolResultPart {\n type: \"tool-result\";\n /**\n * ID of the tool call that this result is associated with.\n */\n toolCallId: string;\n /**\n * Name of the tool that generated this result.\n */\n toolName: string;\n /**\n * Result of the tool call. This is a JSON-serializable object.\n */\n output:\n | {\n type: \"text\";\n value: string;\n }\n | {\n type: \"json\";\n value: JSONValue;\n }\n | {\n type: \"error-text\";\n value: string;\n }\n | {\n type: \"error-json\";\n value: JSONValue;\n }\n | {\n type: \"content\";\n value: Array<\n | {\n type: \"text\";\n /**\nText content.\n*/\n text: string;\n }\n | {\n type: \"media\";\n /**\nBase-64 encoded media data.\n*/\n data: string;\n /**\nIANA media type.\n@see https://www.iana.org/assignments/media-types/media-types.xhtml\n*/\n mediaType: string;\n }\n >;\n };\n}\n\n// ============================================================================\n// Tool Types\n// ============================================================================\n\ntype ToolParameters = TSchema;\n\ntype inferParameters<PARAMETERS extends ToolParameters> = Static<PARAMETERS>;\n\n/**\n * Options passed to tool execution functions.\n */\nexport interface ToolExecutionOptions {\n /**\n * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.\n */\n toolCallId: string;\n /**\n * Messages that were sent to the language model to initiate the response that contained the tool call.\n * The messages **do not** include the system prompt nor the assistant response that contained the tool call.\n */\n messages: AIMessage[];\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\n/**\n * A tool contains the description and the schema of the input that the tool expects.\n * This enables the language model to generate the input.\n *\n * The tool can also contain an optional execute function for the actual execution function of the tool.\n */\nexport type AITool<PARAMETERS extends ToolParameters = any, RESULT = any> = {\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: PARAMETERS;\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n inputSchema: TSchema;\n /**\n * An optional description of what the tool does.\n * Will be used by the language model to decide whether to use the tool.\n * Not used for provider-defined tools.\n */\n description?: string;\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * If not provided, the tool will not be executed automatically.\n *\n * @param args - The input of the tool call\n * @param options - Execution options including abort signal and messages\n */\n execute?: (\n args: inferParameters<PARAMETERS>,\n options: ToolExecutionOptions\n ) => PromiseLike<RESULT>;\n} & (\n | {\n /**\n * Function tool.\n */\n type?: undefined | \"function\";\n }\n | {\n /**\n * Provider-defined tool.\n */\n type: \"provider-defined\";\n /**\n * The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.\n */\n id: `${string}.${string}`;\n /**\n * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.\n */\n args: Record<string, unknown>;\n }\n);\n\n/**\n * Tool choice for the generation. It supports the following settings:\n *\n * - `auto` (default): the model can choose whether and which tools to call.\n * - `required`: the model must call a tool. It can choose which tool to call.\n * - `none`: the model must not call tools\n * - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool\n */\ntype ToolChoice<TOOLS extends Record<string, unknown>> =\n | \"auto\"\n | \"none\"\n | \"required\"\n | {\n type: \"tool\";\n toolName: Extract<keyof TOOLS, string>;\n };\n\nexport type AIToolSet = Record<\n string,\n (\n | AITool<never, never>\n | AITool<any, any>\n | AITool<any, never>\n | AITool<never, any>\n ) &\n Pick<AITool<any, any>, \"execute\">\n>;\n\n// ============================================================================\n// Internal Helper Types\n// ============================================================================\n\ntype ToolCallUnion<_TOOLS extends AIToolSet> = {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n args?: unknown;\n};\n\ntype ToolCallArray<TOOLS extends AIToolSet> = Array<ToolCallUnion<TOOLS>>;\n\ntype ToolResultUnion<_TOOLS extends AIToolSet> = {\n type: \"tool-result\";\n toolCallId: string;\n toolName: string;\n args?: unknown;\n result?: unknown;\n};\n\ntype ToolResultArray<TOOLS extends AIToolSet> = Array<ToolResultUnion<TOOLS>>;\n";
7
+ declare const _default: "import type { Static, TSchema } from \"typebox\";\n\nimport { ITool } from \"..\";\n\n/**\n * Built-in tool for prompting Large Language Models (LLMs).\n *\n * The AI tool provides twists and tools with access to LLM capabilities\n * for natural language processing, text generation, data extraction,\n * and intelligent decision making within their workflows.\n *\n * **Features:**\n * - Access to multiple AI providers (OpenAI, Anthropic, Google, Workers AI)\n * - Multi-turn conversation support with `messages`\n * - Tool calling with automatic execution\n * - Structured output with Typebox schemas via `outputSchema`\n * - Unified API across all models via Vercel AI SDK\n * - Automatic response parsing and validation with full type inference\n *\n * @example\n * ```typescript\n * import { Type } from \"typebox\";\n *\n * class SmartEmailTool extends Tool {\n * private ai: AI;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.ai = tools.get(AI);\n * }\n *\n * async categorizeEmail(emailContent: string) {\n * // Define the output schema using Typebox\n * const schema = Type.Object({\n * category: Type.Union([\n * Type.Literal(\"work\"),\n * Type.Literal(\"personal\"),\n * Type.Literal(\"spam\"),\n * Type.Literal(\"promotional\")\n * ]),\n * confidence: Type.Number({ minimum: 0, maximum: 1 }),\n * reasoning: Type.Optional(Type.String())\n * });\n *\n * const response = await this.ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * system: \"Classify emails into categories: work, personal, spam, or promotional.\",\n * prompt: `Categorize this email: ${emailContent}`,\n * outputSchema: schema\n * });\n *\n * return response.output;\n * }\n *\n * async generateResponse(emailContent: string) {\n * const response = await this.ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * system: \"Generate professional email responses that are helpful and concise.\",\n * prompt: `Write a response to: ${emailContent}`\n * });\n *\n * return response.text;\n * }\n * }\n * ```\n */\nexport abstract class AI extends ITool {\n /**\n * Sends a request to an AI model and returns the response using the Vercel AI SDK.\n *\n * Supports text generation, multi-turn conversations, structured outputs,\n * and tool calling across multiple AI providers via Cloudflare AI Gateway.\n *\n * @param request - AI request with model, prompt/messages, and optional configuration\n * @returns Promise resolving to the AI response with generated text and metadata\n *\n * @example\n * ```typescript\n * // Simple text generation\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * prompt: \"Explain quantum computing in simple terms\"\n * });\n * console.log(response.text);\n *\n * // Fast and cheap for simple tasks\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"low\" },\n * prompt: \"Summarize this text...\"\n * });\n * console.log(response.text);\n *\n * // With system instructions for complex reasoning\n * const response = await ai.prompt({\n * model: { speed: \"capable\", cost: \"high\" },\n * system: \"You are a helpful physics tutor.\",\n * prompt: \"Explain quantum entanglement\"\n * });\n * console.log(response.text);\n *\n * // Multi-turn conversation\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * messages: [\n * { role: \"user\", content: \"What is 2+2?\" },\n * { role: \"assistant\", content: \"2+2 equals 4.\" },\n * { role: \"user\", content: \"What about 3+3?\" }\n * ]\n * });\n * console.log(response.text);\n *\n * // Structured output with Typebox schema\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"medium\" },\n * prompt: \"Extract information: John is 30 years old\",\n * outputSchema: Type.Object({\n * name: Type.String(),\n * age: Type.Number()\n * })\n * });\n * console.log(response.output); // { name: \"John\", age: 30 }\n *\n * // Tool calling\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * prompt: \"What's the weather in San Francisco?\",\n * tools: {\n * getWeather: {\n * description: \"Get weather for a city\",\n * parameters: Type.Object({\n * city: Type.String()\n * }),\n * execute: async ({ city }) => {\n * return { temp: 72, condition: \"sunny\" };\n * }\n * }\n * }\n * });\n * console.log(response.text); // Model's response using tool results\n * console.log(response.toolCalls); // Array of tool calls made\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract prompt<TOOLS extends AIToolSet, SCHEMA extends TSchema = never>(\n request: AIRequest<TOOLS, SCHEMA>\n ): Promise<AIResponse<TOOLS, SCHEMA>>;\n}\n\n/**\n * Model preferences for selecting an AI model based on performance and cost requirements.\n * This allows Plot to match those preferences with user preferences (such as preferred or\n * disallowed providers), as well as availability of newer and better models.\n *\n * @example\n * ```typescript\n * // Fast and cheap - uses Workers AI models like Llama 3.2 1B\n * const response = await ai.prompt({\n * model: { speed: \"fast\", cost: \"low\" },\n * prompt: \"Summarize this in one sentence: ...\"\n * });\n *\n * // Balanced performance - uses GPT-5 Mini or Gemini 2.5 Flash\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\" },\n * prompt: \"Analyze this data...\"\n * });\n *\n * // Most capable - uses Claude Sonnet 4.5 or Opus 4.1\n * const response = await ai.prompt({\n * model: { speed: \"capable\", cost: \"high\" },\n * prompt: \"Solve this complex reasoning problem...\"\n * });\n *\n * // Request a specific model with a hint\n * const response = await ai.prompt({\n * model: { speed: \"balanced\", cost: \"medium\", hint: AIModel.CLAUDE_SONNET_45 },\n * prompt: \"...\"\n * });\n * ```\n */\nexport type ModelPreferences = {\n /**\n * Desired speed tier:\n * - \"fast\": Optimized for low latency and quick responses\n * - \"balanced\": Good balance of speed and capability\n * - \"capable\": Maximum reasoning and problem-solving ability\n */\n speed: \"fast\" | \"balanced\" | \"capable\";\n\n /**\n * Desired cost tier:\n * - \"low\": Minimal cost, often using Workers AI models (free/very cheap)\n * - \"medium\": Moderate pricing for good performance\n * - \"high\": Premium pricing for best-in-class models\n */\n cost: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional hint to suggest a specific model. The system will use this\n * model if possible, but may override it based on user preferences.\n */\n hint?: AIModel;\n};\n\n/**\n * Supported AI models available through Cloudflare AI Gateway and Workers AI.\n *\n * Models are organized by provider:\n * - **OpenAI**: Latest GPT models via AI Gateway\n * - **Anthropic**: Claude models via AI Gateway (prefix with \"anthropic/\")\n * - **Google**: Gemini models via AI Gateway (prefix with \"google-ai-studio/\")\n * - **Workers AI**: Models running on Cloudflare's network (free/low cost)\n */\nexport enum AIModel {\n // OpenAI models - Latest GPT and reasoning models\n GPT_5 = \"openai/gpt-5\",\n GPT_5_PRO = \"openai/gpt-5-pro\",\n GPT_5_MINI = \"openai/gpt-5-mini\",\n GPT_5_NANO = \"openai/gpt-5-nano\",\n GPT_4O = \"openai/gpt-4o\",\n GPT_4O_MINI = \"openai/gpt-4o-mini\",\n O3 = \"openai/o3\",\n O3_MINI = \"openai/o3-mini\",\n\n // Anthropic models - Claude 4.x and 3.7 series\n CLAUDE_SONNET_45 = \"anthropic/claude-sonnet-4-5\",\n CLAUDE_HAIKU_45 = \"anthropic/claude-haiku-4-5\",\n CLAUDE_OPUS_41 = \"anthropic/claude-opus-4-1\",\n CLAUDE_37_SONNET = \"anthropic/claude-3-7-sonnet-latest\",\n\n // Google models - Gemini 2.x series\n GEMINI_25_PRO = \"google/gemini-2.5-pro\",\n GEMINI_25_FLASH = \"google/gemini-2.5-flash\",\n GEMINI_25_FLASH_LITE = \"google/gemini-2.5-flash-lite\",\n GEMINI_20_FLASH = \"google/gemini-2.0-flash\",\n GEMINI_20_FLASH_LITE = \"google/gemini-2.0-flash-lite\",\n\n // Cloudflare Workers AI models - Free/low-cost models running on Cloudflare's network\n LLAMA_4_SCOUT_17B = \"meta/llama-4-scout-17b-16e-instruct\",\n LLAMA_33_70B = \"meta/llama-3.3-70b-instruct-fp8-fast\",\n LLAMA_31_8B = \"meta/llama-3.1-8b-instruct-fp8\",\n LLAMA_32_1B = \"meta/llama-3.2-1b-instruct\",\n DEEPSEEK_R1_32B = \"deepseek-ai/deepseek-r1-distill-qwen-32b\",\n}\n\n/**\n * Request parameters for AI text generation, matching Vercel AI SDK's generateText() function.\n */\nexport interface AIRequest<\n TOOLS extends AIToolSet,\n SCHEMA extends TSchema = never\n> {\n /**\n * Model selection preferences based on desired speed and cost characteristics.\n * Plot will automatically select the best available model matching these preferences.\n *\n * @example\n * // Fast and cheap - good for simple tasks\n * model: { speed: \"fast\", cost: \"low\" }\n *\n * @example\n * // Balanced performance - general purpose\n * model: { speed: \"balanced\", cost: \"medium\" }\n *\n * @example\n * // Maximum capability - complex reasoning\n * model: { speed: \"capable\", cost: \"high\" }\n *\n * @example\n * // With a specific model hint\n * model: { speed: \"balanced\", cost: \"medium\", hint: \"anthropic/claude-sonnet-4-5\" }\n */\n model: ModelPreferences;\n\n /**\n * System instructions to guide the model's behavior.\n */\n system?: string;\n\n /**\n * The user's input prompt. Can be a simple string or an array of messages for multi-turn conversations.\n */\n prompt?: string;\n\n /**\n * Conversation messages for multi-turn interactions.\n * Replaces 'prompt' for more complex conversations.\n */\n messages?: AIMessage[];\n\n /**\n * Tools that the model can call during generation.\n * Each tool definition includes a description, input schema, and optional execute function.\n */\n tools?: TOOLS;\n\n /**\n * Controls which tools the model can use.\n * - \"auto\": Model decides whether to use tools\n * - \"none\": Model cannot use tools\n * - \"required\": Model must use at least one tool\n * - { type: \"tool\", toolName: string }: Model must use specific tool\n */\n toolChoice?: ToolChoice<TOOLS>;\n\n /**\n * Structured output schema using Typebox.\n * Typebox schemas are JSON Schema objects that provide full TypeScript type inference.\n */\n outputSchema?: SCHEMA;\n\n /**\n * Maximum number of tokens to generate.\n */\n maxOutputTokens?: number;\n\n /**\n * Temperature for controlling randomness (0-2).\n * Higher values make output more random, lower values more deterministic.\n */\n temperature?: number;\n\n /**\n * Top P sampling parameter (0-1).\n * Controls diversity by limiting to top probability tokens.\n */\n topP?: number;\n}\n\n/**\n * Response from AI text generation, matching Vercel AI SDK's GenerateTextResult.\n */\nexport interface AIResponse<\n TOOLS extends AIToolSet,\n SCHEMA extends TSchema = never\n> {\n /**\n * The generated text.\n */\n text: string;\n\n /**\n * Tool calls made by the model during generation.\n */\n toolCalls?: ToolCallArray<TOOLS>;\n\n /**\n * Results from tool executions.\n */\n toolResults?: ToolResultArray<TOOLS>;\n\n /**\n * Reason why the model stopped generating.\n */\n finishReason:\n | \"stop\"\n | \"length\"\n | \"content-filter\"\n | \"tool-calls\"\n | \"error\"\n | \"other\"\n | \"unknown\";\n\n /**\n * Token usage information for this generation.\n */\n usage: AIUsage;\n\n /**\n * Sources used by the model (if supported).\n */\n sources?: Array<AISource>;\n\n /**\n * Structured output when using outputSchema.\n * Type is automatically inferred from the Typebox schema.\n */\n output?: Static<SCHEMA>;\n\n /**\n * Response metadata including messages.\n */\n response?: {\n id?: string;\n timestamp?: Date;\n modelId?: string;\n messages?: AIMessage[];\n };\n}\n\n// ============================================================================\n// Message Types\n// ============================================================================\n\n/**\n * A system message. It can contain system information.\n *\n * Note: using the \"system\" part of the prompt is strongly preferred\n * to increase the resilience against prompt injection attacks,\n * and because not all providers support several system messages.\n */\nexport type AISystemMessage = {\n role: \"system\";\n content: string;\n};\n\n/**\n * A user message. It can contain text or a combination of text and images.\n */\nexport type AIUserMessage = {\n role: \"user\";\n content: string | Array<TextPart | ImagePart | FilePart>;\n};\n\n/**\n * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.\n */\nexport type AIAssistantMessage = {\n role: \"assistant\";\n content:\n | string\n | Array<\n TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart\n >;\n};\n\n/**\n * A tool message. It contains the result of one or more tool calls.\n */\nexport type AIToolMessage = {\n role: \"tool\";\n content: Array<ToolResultPart>;\n};\n\n/**\n * A message that can be used in the `messages` field of a prompt.\n * It can be a user message, an assistant message, or a tool message.\n */\nexport type AIMessage =\n | AISystemMessage\n | AIUserMessage\n | AIAssistantMessage\n | AIToolMessage;\n\n// ============================================================================\n// Usage & Sources\n// ============================================================================\n\n/**\n * Represents the number of tokens used in a prompt and completion.\n */\nexport type AIUsage = {\n /**\n * The number of tokens used in the prompt.\n */\n inputTokens?: number;\n /**\n * The number of tokens used in the completion.\n */\n outputTokens?: number;\n /**\n * The total number of tokens used (promptTokens + completionTokens).\n */\n totalTokens?: number;\n /**\n * The number of reasoning tokens used in the completion.\n */\n reasoningTokens?: number;\n};\n\n/**\n * A source that has been used as input to generate the response.\n */\nexport type AISource =\n | {\n type: \"source\";\n /**\n * A URL source. This is returned by web search RAG models.\n */\n sourceType: \"url\";\n /**\n * The ID of the source.\n */\n id: string;\n /**\n * The URL of the source.\n */\n url: string;\n /**\n * The title of the source.\n */\n title?: string;\n }\n | {\n type: \"source\";\n /**\n * The type of source - document sources reference files/documents.\n */\n sourceType: \"document\";\n /**\n * The ID of the source.\n */\n id: string;\n /**\n * IANA media type of the document (e.g., 'application/pdf').\n */\n mediaType: string;\n /**\n * The title of the document.\n */\n title: string;\n /**\n * Optional filename of the document.\n */\n filename?: string;\n };\n\n// ============================================================================\n// Content Parts\n// ============================================================================\n\n/**\n * Text content part of a prompt. It contains a string of text.\n */\nexport interface TextPart {\n type: \"text\";\n /**\n * The text content.\n */\n text: string;\n}\n\n/**\n * Data content. Can either be a base64-encoded string, a Uint8Array, or an ArrayBuffer.\n */\nexport type DataContent = string | Uint8Array | ArrayBuffer;\n\n/**\n * Image content part of a prompt. It contains an image.\n */\nexport interface ImagePart {\n type: \"image\";\n /**\n * Image data. Can either be:\n *\n * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer\n * - URL: a URL that points to the image\n */\n image: DataContent | URL;\n /**\n * Optional mime type of the image.\n */\n mimeType?: string;\n}\n\n/**\n * File content part of a prompt. It contains a file.\n */\nexport interface FilePart {\n type: \"file\";\n /**\n * File data. Can either be:\n *\n * - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer\n * - URL: a URL that points to the file\n */\n data: DataContent | URL;\n /**\n * Optional filename of the file.\n */\n filename?: string;\n /**\n * IANA media type of the file.\n *\n * @see https://www.iana.org/assignments/media-types/media-types.xhtml\n */\n mediaType: string;\n}\n\n/**\n * Reasoning content part of a prompt. It contains a reasoning.\n */\nexport interface ReasoningPart {\n type: \"reasoning\";\n /**\n * The reasoning text.\n */\n text: string;\n /**\n * An optional signature for verifying that the reasoning originated from the model.\n */\n signature?: string;\n}\n\n/**\n * Redacted reasoning content part of a prompt.\n */\nexport interface RedactedReasoningPart {\n type: \"redacted-reasoning\";\n /**\n * Redacted reasoning data.\n */\n data: string;\n}\n\n/**\n * Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).\n */\nexport interface ToolCallPart {\n type: \"tool-call\";\n /**\n * ID of the tool call. This ID is used to match the tool call with the tool result.\n */\n toolCallId: string;\n /**\n * Name of the tool that is being called.\n */\n toolName: string;\n /**\n * Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.\n */\n input: unknown;\n}\n\ntype JSONValue = null | string | number | boolean | JSONObject | JSONArray;\ntype JSONObject = {\n [key: string]: JSONValue;\n};\ntype JSONArray = JSONValue[];\n\n/**\n * Tool result content part of a prompt. It contains the result of the tool call with the matching ID.\n */\nexport interface ToolResultPart {\n type: \"tool-result\";\n /**\n * ID of the tool call that this result is associated with.\n */\n toolCallId: string;\n /**\n * Name of the tool that generated this result.\n */\n toolName: string;\n /**\n * Result of the tool call. This is a JSON-serializable object.\n */\n output:\n | {\n type: \"text\";\n value: string;\n }\n | {\n type: \"json\";\n value: JSONValue;\n }\n | {\n type: \"error-text\";\n value: string;\n }\n | {\n type: \"error-json\";\n value: JSONValue;\n }\n | {\n type: \"content\";\n value: Array<\n | {\n type: \"text\";\n /**\nText content.\n*/\n text: string;\n }\n | {\n type: \"media\";\n /**\nBase-64 encoded media data.\n*/\n data: string;\n /**\nIANA media type.\n@see https://www.iana.org/assignments/media-types/media-types.xhtml\n*/\n mediaType: string;\n }\n >;\n };\n}\n\n// ============================================================================\n// Tool Types\n// ============================================================================\n\ntype ToolParameters = TSchema;\n\ntype inferParameters<PARAMETERS extends ToolParameters> = Static<PARAMETERS>;\n\n/**\n * Options passed to tool execution functions.\n */\nexport interface ToolExecutionOptions {\n /**\n * The ID of the tool call. You can use it e.g. when sending tool-call related information with stream data.\n */\n toolCallId: string;\n /**\n * Messages that were sent to the language model to initiate the response that contained the tool call.\n * The messages **do not** include the system prompt nor the assistant response that contained the tool call.\n */\n messages: AIMessage[];\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n abortSignal?: AbortSignal;\n}\n\n/**\n * A tool contains the description and the schema of the input that the tool expects.\n * This enables the language model to generate the input.\n *\n * The tool can also contain an optional execute function for the actual execution function of the tool.\n */\nexport type AITool<PARAMETERS extends ToolParameters = any, RESULT = any> = {\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n parameters: PARAMETERS;\n /**\n * The schema of the input that the tool expects. The language model will use this to generate the input.\n * It is also used to validate the output of the language model.\n * Use descriptions to make the input understandable for the language model.\n */\n inputSchema: TSchema;\n /**\n * An optional description of what the tool does.\n * Will be used by the language model to decide whether to use the tool.\n * Not used for provider-defined tools.\n */\n description?: string;\n /**\n * An async function that is called with the arguments from the tool call and produces a result.\n * If not provided, the tool will not be executed automatically.\n *\n * @param args - The input of the tool call\n * @param options - Execution options including abort signal and messages\n */\n execute?: (\n args: inferParameters<PARAMETERS>,\n options: ToolExecutionOptions\n ) => PromiseLike<RESULT>;\n} & (\n | {\n /**\n * Function tool.\n */\n type?: undefined | \"function\";\n }\n | {\n /**\n * Provider-defined tool.\n */\n type: \"provider-defined\";\n /**\n * The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.\n */\n id: `${string}.${string}`;\n /**\n * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.\n */\n args: Record<string, unknown>;\n }\n);\n\n/**\n * Tool choice for the generation. It supports the following settings:\n *\n * - `auto` (default): the model can choose whether and which tools to call.\n * - `required`: the model must call a tool. It can choose which tool to call.\n * - `none`: the model must not call tools\n * - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool\n */\ntype ToolChoice<TOOLS extends Record<string, unknown>> =\n | \"auto\"\n | \"none\"\n | \"required\"\n | {\n type: \"tool\";\n toolName: Extract<keyof TOOLS, string>;\n };\n\nexport type AIToolSet = Record<\n string,\n (\n | AITool<never, never>\n | AITool<any, any>\n | AITool<any, never>\n | AITool<never, any>\n ) &\n Pick<AITool<any, any>, \"execute\">\n>;\n\n// ============================================================================\n// Internal Helper Types\n// ============================================================================\n\ntype ToolCallUnion<_TOOLS extends AIToolSet> = {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n args?: unknown;\n};\n\ntype ToolCallArray<TOOLS extends AIToolSet> = Array<ToolCallUnion<TOOLS>>;\n\ntype ToolResultUnion<_TOOLS extends AIToolSet> = {\n type: \"tool-result\";\n toolCallId: string;\n toolName: string;\n args?: unknown;\n result?: unknown;\n};\n\ntype ToolResultArray<TOOLS extends AIToolSet> = Array<ToolResultUnion<TOOLS>>;\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=ai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,ihvBAAihvB;AAAhivB,wBAAiivB"}
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,8/uBAA8/uB;AAA7gvB,wBAA8gvB"}