@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,8 +1,8 @@
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
- export 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
+ export 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
  //# sourceMappingURL=ai.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,ihvBAAihvB,CAAC"}
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/ai.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,8/uBAA8/uB,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/callbacks
2
+ * Generated LLM documentation for @plotday/twister/tools/callbacks
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 { ITool } from \"..\";\nimport type { CallbackMethods, NoFunctions, NonFunction } from \"../utils/types\";\n\n// Re-export types for consumers\nexport type { CallbackMethods, NoFunctions, NonFunction };\n\n/**\n * Represents a callback token for persistent function references.\n *\n * Callbacks enable tools and twists to create persistent references to functions\n * that can survive worker restarts and be invoked across different execution contexts.\n *\n * This is a branded string type to prevent mixing callback tokens with regular strings.\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onCalendarSelected, \"primary\", \"google\");\n * ```\n */\nexport type Callback = string & { readonly __brand: \"Callback\" };\n\n/**\n * Built-in tool for creating and managing persistent callback references.\n *\n * The Callbacks tool enables twists and tools to create callback links that persist\n * across worker invocations and restarts. This is essential for webhook handlers,\n * scheduled operations, and user interaction flows that need to survive runtime\n * boundaries.\n *\n * **Note:** Callback methods are also available directly on Twist and Tool classes\n * via `this.callback()`, `this.deleteCallback()`, `this.deleteAllCallbacks()`, and\n * `this.run()`. This is the recommended approach for most use cases.\n *\n * **When to use callbacks:**\n * - Webhook handlers that need persistent function references\n * - Scheduled operations that run after worker timeouts\n * - User interaction links (ActivityLinkType.callback)\n * - Cross-tool communication that survives restarts\n *\n * **Type Safety:**\n * Callbacks are fully type-safe - extraArgs are type-checked against the function signature.\n *\n * @example\n * ```typescript\n * class MyTool extends Tool {\n * async setupWebhook() {\n * // Using built-in callback method (recommended)\n * const callback = await this.callback(this.handleWebhook, \"calendar\");\n * return `https://api.plot.day/webhook/${callback}`;\n * }\n *\n * async handleWebhook(data: any, webhookType: string) {\n * console.log(\"Webhook received:\", data, webhookType);\n * }\n * }\n * ```\n */\nexport abstract class Callbacks extends ITool {\n /**\n * Creates a persistent callback to a method on the current class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract create(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Creates a persistent callback to a function from the parent twist/tool.\n * Use this when the callback function is passed in from outside this class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable, validated at runtime)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createFromParent(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param callback - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract delete(callback: Callback): Promise<void>;\n\n /**\n * Deletes all callbacks for the tool's parent.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n abstract deleteAll(): Promise<void>;\n\n /**\n * Executes a callback by its token.\n *\n * @param callback - The callback token returned by create()\n * @param args - Optional arguments to pass to the callback function\n * @returns Promise resolving to the callback result\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract run<T = unknown>(callback: Callback, ...args: any[]): Promise<T>;\n}\n";
7
+ declare const _default: "import { ITool } from \"..\";\nimport type { CallbackMethods, NoFunctions, NonFunction } from \"../utils/types\";\n\n// Re-export types for consumers\nexport type { CallbackMethods, NoFunctions, NonFunction };\n\n/**\n * Represents a callback token for persistent function references.\n *\n * Callbacks enable tools and twists to create persistent references to functions\n * that can survive worker restarts and be invoked across different execution contexts.\n *\n * This is a branded string type to prevent mixing callback tokens with regular strings.\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onCalendarSelected, \"primary\", \"google\");\n * ```\n */\nexport type Callback = string & { readonly __brand: \"Callback\" };\n\n/**\n * Built-in tool for creating and managing persistent callback references.\n *\n * The Callbacks tool enables twists and tools to create callback links that persist\n * across worker invocations and restarts. This is essential for webhook handlers,\n * scheduled operations, and user interaction flows that need to survive runtime\n * boundaries.\n *\n * **Note:** Callback methods are also available directly on Twist and Tool classes\n * via `this.callback()`, `this.deleteCallback()`, `this.deleteAllCallbacks()`, and\n * `this.run()`. This is the recommended approach for most use cases.\n *\n * **When to use callbacks:**\n * - Webhook handlers that need persistent function references\n * - Scheduled operations that run after worker timeouts\n * - User interaction links (ActivityLinkType.callback)\n * - Cross-tool communication that survives restarts\n *\n * **Type Safety:**\n * Callbacks are fully type-safe - extraArgs are type-checked against the function signature.\n *\n * @example\n * ```typescript\n * class MyTool extends Tool {\n * async setupWebhook() {\n * // Using built-in callback method (recommended)\n * const callback = await this.callback(this.handleWebhook, \"calendar\");\n * return `https://api.plot.day/webhook/${callback}`;\n * }\n *\n * async handleWebhook(data: any, webhookType: string) {\n * console.log(\"Webhook received:\", data, webhookType);\n * }\n * }\n * ```\n */\nexport abstract class Callbacks extends ITool {\n /**\n * Creates a persistent callback to a method on the current class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract create<Fn extends (...args: any[]) => any>(\n fn: Fn,\n ...extraArgs: Parameters<Fn>\n ): Promise<Callback>;\n\n /**\n * Creates a persistent callback to a function from the parent twist/tool.\n * Use this when the callback function is passed in from outside this class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable, validated at runtime)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createFromParent(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param callback - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract delete(callback: Callback): Promise<void>;\n\n /**\n * Deletes all callbacks for the tool's parent.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n abstract deleteAll(): Promise<void>;\n\n /**\n * Executes a callback by its token.\n *\n * @param callback - The callback token returned by create()\n * @param args - Optional arguments to pass to the callback function\n * @returns Promise resolving to the callback result\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract run<T = unknown>(callback: Callback, ...args: any[]): Promise<T>;\n}\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=callbacks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/callbacks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,6jIAA6jI;AAA5kI,wBAA6kI"}
1
+ {"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/callbacks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,omIAAomI;AAAnnI,wBAAonI"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/callbacks
2
+ * Generated LLM documentation for @plotday/twister/tools/callbacks
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 { ITool } from \"..\";\nimport type { CallbackMethods, NoFunctions, NonFunction } from \"../utils/types\";\n\n// Re-export types for consumers\nexport type { CallbackMethods, NoFunctions, NonFunction };\n\n/**\n * Represents a callback token for persistent function references.\n *\n * Callbacks enable tools and twists to create persistent references to functions\n * that can survive worker restarts and be invoked across different execution contexts.\n *\n * This is a branded string type to prevent mixing callback tokens with regular strings.\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onCalendarSelected, \"primary\", \"google\");\n * ```\n */\nexport type Callback = string & { readonly __brand: \"Callback\" };\n\n/**\n * Built-in tool for creating and managing persistent callback references.\n *\n * The Callbacks tool enables twists and tools to create callback links that persist\n * across worker invocations and restarts. This is essential for webhook handlers,\n * scheduled operations, and user interaction flows that need to survive runtime\n * boundaries.\n *\n * **Note:** Callback methods are also available directly on Twist and Tool classes\n * via `this.callback()`, `this.deleteCallback()`, `this.deleteAllCallbacks()`, and\n * `this.run()`. This is the recommended approach for most use cases.\n *\n * **When to use callbacks:**\n * - Webhook handlers that need persistent function references\n * - Scheduled operations that run after worker timeouts\n * - User interaction links (ActivityLinkType.callback)\n * - Cross-tool communication that survives restarts\n *\n * **Type Safety:**\n * Callbacks are fully type-safe - extraArgs are type-checked against the function signature.\n *\n * @example\n * ```typescript\n * class MyTool extends Tool {\n * async setupWebhook() {\n * // Using built-in callback method (recommended)\n * const callback = await this.callback(this.handleWebhook, \"calendar\");\n * return `https://api.plot.day/webhook/${callback}`;\n * }\n *\n * async handleWebhook(data: any, webhookType: string) {\n * console.log(\"Webhook received:\", data, webhookType);\n * }\n * }\n * ```\n */\nexport abstract class Callbacks extends ITool {\n /**\n * Creates a persistent callback to a method on the current class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract create(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Creates a persistent callback to a function from the parent twist/tool.\n * Use this when the callback function is passed in from outside this class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable, validated at runtime)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createFromParent(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param callback - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract delete(callback: Callback): Promise<void>;\n\n /**\n * Deletes all callbacks for the tool's parent.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n abstract deleteAll(): Promise<void>;\n\n /**\n * Executes a callback by its token.\n *\n * @param callback - The callback token returned by create()\n * @param args - Optional arguments to pass to the callback function\n * @returns Promise resolving to the callback result\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract run<T = unknown>(callback: Callback, ...args: any[]): Promise<T>;\n}\n";
7
+ export default "import { ITool } from \"..\";\nimport type { CallbackMethods, NoFunctions, NonFunction } from \"../utils/types\";\n\n// Re-export types for consumers\nexport type { CallbackMethods, NoFunctions, NonFunction };\n\n/**\n * Represents a callback token for persistent function references.\n *\n * Callbacks enable tools and twists to create persistent references to functions\n * that can survive worker restarts and be invoked across different execution contexts.\n *\n * This is a branded string type to prevent mixing callback tokens with regular strings.\n *\n * @example\n * ```typescript\n * const callback = await this.callback(this.onCalendarSelected, \"primary\", \"google\");\n * ```\n */\nexport type Callback = string & { readonly __brand: \"Callback\" };\n\n/**\n * Built-in tool for creating and managing persistent callback references.\n *\n * The Callbacks tool enables twists and tools to create callback links that persist\n * across worker invocations and restarts. This is essential for webhook handlers,\n * scheduled operations, and user interaction flows that need to survive runtime\n * boundaries.\n *\n * **Note:** Callback methods are also available directly on Twist and Tool classes\n * via `this.callback()`, `this.deleteCallback()`, `this.deleteAllCallbacks()`, and\n * `this.run()`. This is the recommended approach for most use cases.\n *\n * **When to use callbacks:**\n * - Webhook handlers that need persistent function references\n * - Scheduled operations that run after worker timeouts\n * - User interaction links (ActivityLinkType.callback)\n * - Cross-tool communication that survives restarts\n *\n * **Type Safety:**\n * Callbacks are fully type-safe - extraArgs are type-checked against the function signature.\n *\n * @example\n * ```typescript\n * class MyTool extends Tool {\n * async setupWebhook() {\n * // Using built-in callback method (recommended)\n * const callback = await this.callback(this.handleWebhook, \"calendar\");\n * return `https://api.plot.day/webhook/${callback}`;\n * }\n *\n * async handleWebhook(data: any, webhookType: string) {\n * console.log(\"Webhook received:\", data, webhookType);\n * }\n * }\n * ```\n */\nexport abstract class Callbacks extends ITool {\n /**\n * Creates a persistent callback to a method on the current class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract create<Fn extends (...args: any[]) => any>(\n fn: Fn,\n ...extraArgs: Parameters<Fn>\n ): Promise<Callback>;\n\n /**\n * Creates a persistent callback to a function from the parent twist/tool.\n * Use this when the callback function is passed in from outside this class.\n *\n * @param fn - The function to callback\n * @param extraArgs - Additional arguments to pass to the function (must be serializable, validated at runtime)\n * @returns Promise resolving to a persistent callback token\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createFromParent(\n fn: Function,\n ...extraArgs: any[]\n ): Promise<Callback>;\n\n /**\n * Deletes a specific callback by its token.\n *\n * @param callback - The callback token to delete\n * @returns Promise that resolves when the callback is deleted\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract delete(callback: Callback): Promise<void>;\n\n /**\n * Deletes all callbacks for the tool's parent.\n *\n * @returns Promise that resolves when all callbacks are deleted\n */\n abstract deleteAll(): Promise<void>;\n\n /**\n * Executes a callback by its token.\n *\n * @param callback - The callback token returned by create()\n * @param args - Optional arguments to pass to the callback function\n * @returns Promise resolving to the callback result\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract run<T = unknown>(callback: Callback, ...args: any[]): Promise<T>;\n}\n";
8
8
  //# sourceMappingURL=callbacks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/callbacks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,6jIAA6jI,CAAC"}
1
+ {"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/callbacks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,omIAAomI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/integrations
2
+ * Generated LLM documentation for @plotday/twister/tools/integrations
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/integrations
2
+ * Generated LLM documentation for @plotday/twister/tools/integrations
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/network
2
+ * Generated LLM documentation for @plotday/twister/tools/network
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 { ITool } from \"..\";\nimport { type AuthProvider, type Authorization } from \"./integrations\";\n\n/**\n * Represents an incoming webhook request.\n *\n * This object is passed to webhook callback functions and contains all\n * the information about the HTTP request that triggered the webhook.\n *\n * @example\n * ```typescript\n * async onWebhookReceived(request: WebhookRequest, context: any) {\n * console.log(`${request.method} request received`);\n * console.log(\"Headers:\", request.headers);\n * console.log(\"Query params:\", request.params);\n * console.log(\"Body:\", request.body);\n * console.log(\"Context:\", context);\n * }\n * ```\n */\nexport type WebhookRequest = {\n /** HTTP method of the request (GET, POST, etc.) */\n method: string;\n /** HTTP headers from the request */\n headers: Record<string, string>;\n /** Query string parameters from the request URL */\n params: Record<string, string>;\n /** Request body (parsed as JSON if applicable) */\n body: any;\n};\n\n/**\n * Built-in tool for requesting HTTP access permissions and managing webhooks.\n *\n * The Network tool serves two purposes:\n * 1. Declares which URLs a twist or tool is allowed to access via HTTP/HTTPS\n * 2. Provides webhook creation and management for receiving HTTP callbacks\n *\n * **IMPORTANT**: Must be requested in the Twist or Tool Init method to declare\n * HTTP access permissions. Without requesting this tool with the appropriate URLs,\n * all outbound HTTP requests (fetch, etc.) will be blocked.\n *\n * **Permission Patterns:**\n * - `*` - Allow access to all URLs\n * - `https://*.example.com` - Allow access to all subdomains\n * - `https://api.example.com/*` - Allow access to all paths on the domain\n * - `https://api.example.com/v1/*` - Allow access to specific path prefix\n *\n * **Webhook Characteristics:**\n * - Persistent across worker restarts\n * - Automatic callback routing to parent tool/twist\n * - Support for all HTTP methods\n * - Context preservation for callback execution\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist<MyTwist> {\n * build(build: ToolBuilder) {\n * return {\n * // Request HTTP access to specific APIs\n * network: build(Network, {\n * urls: [\n * 'https://api.github.com/*',\n * 'https://api.openai.com/*'\n * ]\n * })\n * };\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * class CalendarTool extends Tool<CalendarTool> {\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, {\n * urls: ['https://www.googleapis.com/calendar/*']\n * })\n * };\n * }\n *\n * async setupCalendarWebhook(calendarId: string) {\n * // Create webhook URL that will call onCalendarEvent\n * const webhookUrl = await this.tools.network.createWebhook({\n * callback: this.onCalendarEvent,\n * extraArgs: [calendarId, \"google\"]\n * });\n *\n * // Register webhook with Google Calendar API\n * await this.registerWithGoogleCalendar(calendarId, webhookUrl);\n *\n * return webhookUrl;\n * }\n *\n * async onCalendarEvent(request: WebhookRequest, calendarId: string, provider: string) {\n * console.log(\"Calendar event received:\", {\n * method: request.method,\n * calendarId,\n * provider,\n * body: request.body\n * });\n *\n * // Process the calendar event change\n * await this.processCalendarChange(request.body);\n * }\n *\n * async cleanup(webhookUrl: string) {\n * await this.tools.network.deleteWebhook(webhookUrl);\n * }\n * }\n * ```\n */\nexport abstract class Network extends ITool {\n static readonly Options: {\n /**\n * All network access is blocked except the specified URLs.\n * Wildcards (*) are supported for domains and paths.\n */\n urls: string[];\n };\n\n /**\n * Creates a new webhook endpoint.\n *\n * Generates a unique HTTP endpoint that will invoke the callback function\n * when requests are received. The callback receives the WebhookRequest plus any extraArgs.\n *\n * **Provider-Specific Behavior:**\n * - **Slack**: Uses provider-specific routing via team_id. Requires `authorization` parameter.\n * - **Gmail** (Google with Gmail scopes): Returns a Google Pub/Sub topic name instead of a webhook URL.\n * The topic name (e.g., \"projects/plot-prod/topics/gmail-webhook-abc123\") should be passed\n * to the Gmail API's `users.watch` endpoint. Requires `authorization` parameter with Gmail scopes.\n * - **Default**: Returns a standard webhook URL for all other cases.\n *\n * @param options - Webhook creation options\n * @param options.callback - Function receiving (request, ...extraArgs)\n * @param options.extraArgs - Additional arguments to pass to the callback (type-checked)\n * @param options.provider - Optional provider for provider-specific webhook routing\n * @param options.authorization - Optional authorization for provider-specific webhooks (required for Slack and Gmail)\n * @returns Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name\n *\n * @example\n * ```typescript\n * // Gmail webhook - returns Pub/Sub topic name\n * const topicName = await this.tools.network.createWebhook({\n * callback: this.onGmailNotification,\n * provider: AuthProvider.Google,\n * authorization: gmailAuth,\n * extraArgs: [\"inbox\"]\n * });\n * // topicName: \"projects/plot-prod/topics/gmail-webhook-abc123\"\n *\n * // Pass topic name to Gmail API\n * await gmailApi.users.watch({\n * userId: 'me',\n * requestBody: {\n * topicName: topicName, // Use the returned topic name\n * labelIds: ['INBOX']\n * }\n * });\n * ```\n */\n abstract createWebhook<\n TCallback extends (request: WebhookRequest, ...args: any[]) => any\n >(options: {\n callback: TCallback;\n extraArgs?: TCallback extends (req: any, ...rest: infer R) => any ? R : [];\n provider?: AuthProvider;\n authorization?: Authorization;\n }): Promise<string>;\n\n /**\n * Deletes an existing webhook endpoint.\n *\n * Removes the webhook endpoint and stops processing requests.\n * Works with all webhook types (standard, Slack, and Gmail).\n *\n * **For Gmail webhooks:** Also deletes the associated Google Pub/Sub topic and subscription.\n *\n * **For Slack webhooks:** Removes the callback registration for the specific team.\n *\n * **For standard webhooks:** Removes the webhook endpoint. Any subsequent requests\n * to the deleted webhook will return 404.\n *\n * @param url - The webhook identifier returned from `createWebhook()`.\n * This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),\n * or an opaque identifier (Slack). Always pass the exact value returned\n * from `createWebhook()`.\n * @returns Promise that resolves when the webhook is deleted\n */\n abstract deleteWebhook(url: string): Promise<void>;\n}\n";
7
+ declare const _default: "import { ITool } from \"..\";\nimport { type AuthProvider, type Authorization } from \"./integrations\";\n\n/**\n * Represents an incoming webhook request.\n *\n * This object is passed to webhook callback functions and contains all\n * the information about the HTTP request that triggered the webhook.\n *\n * @example\n * ```typescript\n * async onWebhookReceived(request: WebhookRequest, context: any) {\n * console.log(`${request.method} request received`);\n * console.log(\"Headers:\", request.headers);\n * console.log(\"Query params:\", request.params);\n * console.log(\"Body:\", request.body);\n * console.log(\"Context:\", context);\n * }\n * ```\n */\nexport type WebhookRequest = {\n /** HTTP method of the request (GET, POST, etc.) */\n method: string;\n /** HTTP headers from the request */\n headers: Record<string, string>;\n /** Query string parameters from the request URL */\n params: Record<string, string>;\n /** Request body (parsed as JSON if applicable) */\n body: any;\n /** Raw request body (for signature verification) */\n rawBody?: string;\n};\n\n/**\n * Built-in tool for requesting HTTP access permissions and managing webhooks.\n *\n * The Network tool serves two purposes:\n * 1. Declares which URLs a twist or tool is allowed to access via HTTP/HTTPS\n * 2. Provides webhook creation and management for receiving HTTP callbacks\n *\n * **IMPORTANT**: Must be requested in the Twist or Tool Init method to declare\n * HTTP access permissions. Without requesting this tool with the appropriate URLs,\n * all outbound HTTP requests (fetch, etc.) will be blocked.\n *\n * **Permission Patterns:**\n * - `*` - Allow access to all URLs\n * - `https://*.example.com` - Allow access to all subdomains\n * - `https://api.example.com/*` - Allow access to all paths on the domain\n * - `https://api.example.com/v1/*` - Allow access to specific path prefix\n *\n * **Webhook Characteristics:**\n * - Persistent across worker restarts\n * - Automatic callback routing to parent tool/twist\n * - Support for all HTTP methods\n * - Context preservation for callback execution\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist<MyTwist> {\n * build(build: ToolBuilder) {\n * return {\n * // Request HTTP access to specific APIs\n * network: build(Network, {\n * urls: [\n * 'https://api.github.com/*',\n * 'https://api.openai.com/*'\n * ]\n * })\n * };\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * class CalendarTool extends Tool<CalendarTool> {\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, {\n * urls: ['https://www.googleapis.com/calendar/*']\n * })\n * };\n * }\n *\n * async setupCalendarWebhook(calendarId: string) {\n * // Create webhook URL that will call onCalendarEvent\n * const webhookUrl = await this.tools.network.createWebhook({\n * callback: this.onCalendarEvent,\n * extraArgs: [calendarId, \"google\"]\n * });\n *\n * // Register webhook with Google Calendar API\n * await this.registerWithGoogleCalendar(calendarId, webhookUrl);\n *\n * return webhookUrl;\n * }\n *\n * async onCalendarEvent(request: WebhookRequest, calendarId: string, provider: string) {\n * console.log(\"Calendar event received:\", {\n * method: request.method,\n * calendarId,\n * provider,\n * body: request.body\n * });\n *\n * // Process the calendar event change\n * await this.processCalendarChange(request.body);\n * }\n *\n * async cleanup(webhookUrl: string) {\n * await this.tools.network.deleteWebhook(webhookUrl);\n * }\n * }\n * ```\n */\nexport abstract class Network extends ITool {\n static readonly Options: {\n /**\n * All network access is blocked except the specified URLs.\n * Wildcards (*) are supported for domains and paths.\n */\n urls: string[];\n };\n\n /**\n * Creates a new webhook endpoint.\n *\n * Generates a unique HTTP endpoint that will invoke the callback function\n * when requests are received. The callback receives the WebhookRequest plus any extraArgs.\n *\n * **Provider-Specific Behavior:**\n * - **Slack**: Uses provider-specific routing via team_id. Requires `authorization` parameter.\n * - **Gmail** (Google with Gmail scopes): Returns a Google Pub/Sub topic name instead of a webhook URL.\n * The topic name (e.g., \"projects/plot-prod/topics/gmail-webhook-abc123\") should be passed\n * to the Gmail API's `users.watch` endpoint. Requires `authorization` parameter with Gmail scopes.\n * - **Default**: Returns a standard webhook URL for all other cases.\n *\n * @param options - Webhook creation options\n * @param options.callback - Function receiving (request, ...extraArgs)\n * @param options.extraArgs - Additional arguments to pass to the callback (type-checked)\n * @param options.provider - Optional provider for provider-specific webhook routing\n * @param options.authorization - Optional authorization for provider-specific webhooks (required for Slack and Gmail)\n * @returns Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name\n *\n * @example\n * ```typescript\n * // Gmail webhook - returns Pub/Sub topic name\n * const topicName = await this.tools.network.createWebhook({\n * callback: this.onGmailNotification,\n * provider: AuthProvider.Google,\n * authorization: gmailAuth,\n * extraArgs: [\"inbox\"]\n * });\n * // topicName: \"projects/plot-prod/topics/gmail-webhook-abc123\"\n *\n * // Pass topic name to Gmail API\n * await gmailApi.users.watch({\n * userId: 'me',\n * requestBody: {\n * topicName: topicName, // Use the returned topic name\n * labelIds: ['INBOX']\n * }\n * });\n * ```\n */\n abstract createWebhook<\n TCallback extends (request: WebhookRequest, ...args: any[]) => any\n >(options: {\n callback: TCallback;\n extraArgs?: TCallback extends (req: any, ...rest: infer R) => any ? R : [];\n provider?: AuthProvider;\n authorization?: Authorization;\n }): Promise<string>;\n\n /**\n * Deletes an existing webhook endpoint.\n *\n * Removes the webhook endpoint and stops processing requests.\n * Works with all webhook types (standard, Slack, and Gmail).\n *\n * **For Gmail webhooks:** Also deletes the associated Google Pub/Sub topic and subscription.\n *\n * **For Slack webhooks:** Removes the callback registration for the specific team.\n *\n * **For standard webhooks:** Removes the webhook endpoint. Any subsequent requests\n * to the deleted webhook will return 404.\n *\n * @param url - The webhook identifier returned from `createWebhook()`.\n * This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),\n * or an opaque identifier (Slack). Always pass the exact value returned\n * from `createWebhook()`.\n * @returns Promise that resolves when the webhook is deleted\n */\n abstract deleteWebhook(url: string): Promise<void>;\n}\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=network.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,46NAA46N;AAA37N,wBAA47N"}
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,y/NAAy/N;AAAxgO,wBAAygO"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/network
2
+ * Generated LLM documentation for @plotday/twister/tools/network
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 { ITool } from \"..\";\nimport { type AuthProvider, type Authorization } from \"./integrations\";\n\n/**\n * Represents an incoming webhook request.\n *\n * This object is passed to webhook callback functions and contains all\n * the information about the HTTP request that triggered the webhook.\n *\n * @example\n * ```typescript\n * async onWebhookReceived(request: WebhookRequest, context: any) {\n * console.log(`${request.method} request received`);\n * console.log(\"Headers:\", request.headers);\n * console.log(\"Query params:\", request.params);\n * console.log(\"Body:\", request.body);\n * console.log(\"Context:\", context);\n * }\n * ```\n */\nexport type WebhookRequest = {\n /** HTTP method of the request (GET, POST, etc.) */\n method: string;\n /** HTTP headers from the request */\n headers: Record<string, string>;\n /** Query string parameters from the request URL */\n params: Record<string, string>;\n /** Request body (parsed as JSON if applicable) */\n body: any;\n};\n\n/**\n * Built-in tool for requesting HTTP access permissions and managing webhooks.\n *\n * The Network tool serves two purposes:\n * 1. Declares which URLs a twist or tool is allowed to access via HTTP/HTTPS\n * 2. Provides webhook creation and management for receiving HTTP callbacks\n *\n * **IMPORTANT**: Must be requested in the Twist or Tool Init method to declare\n * HTTP access permissions. Without requesting this tool with the appropriate URLs,\n * all outbound HTTP requests (fetch, etc.) will be blocked.\n *\n * **Permission Patterns:**\n * - `*` - Allow access to all URLs\n * - `https://*.example.com` - Allow access to all subdomains\n * - `https://api.example.com/*` - Allow access to all paths on the domain\n * - `https://api.example.com/v1/*` - Allow access to specific path prefix\n *\n * **Webhook Characteristics:**\n * - Persistent across worker restarts\n * - Automatic callback routing to parent tool/twist\n * - Support for all HTTP methods\n * - Context preservation for callback execution\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist<MyTwist> {\n * build(build: ToolBuilder) {\n * return {\n * // Request HTTP access to specific APIs\n * network: build(Network, {\n * urls: [\n * 'https://api.github.com/*',\n * 'https://api.openai.com/*'\n * ]\n * })\n * };\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * class CalendarTool extends Tool<CalendarTool> {\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, {\n * urls: ['https://www.googleapis.com/calendar/*']\n * })\n * };\n * }\n *\n * async setupCalendarWebhook(calendarId: string) {\n * // Create webhook URL that will call onCalendarEvent\n * const webhookUrl = await this.tools.network.createWebhook({\n * callback: this.onCalendarEvent,\n * extraArgs: [calendarId, \"google\"]\n * });\n *\n * // Register webhook with Google Calendar API\n * await this.registerWithGoogleCalendar(calendarId, webhookUrl);\n *\n * return webhookUrl;\n * }\n *\n * async onCalendarEvent(request: WebhookRequest, calendarId: string, provider: string) {\n * console.log(\"Calendar event received:\", {\n * method: request.method,\n * calendarId,\n * provider,\n * body: request.body\n * });\n *\n * // Process the calendar event change\n * await this.processCalendarChange(request.body);\n * }\n *\n * async cleanup(webhookUrl: string) {\n * await this.tools.network.deleteWebhook(webhookUrl);\n * }\n * }\n * ```\n */\nexport abstract class Network extends ITool {\n static readonly Options: {\n /**\n * All network access is blocked except the specified URLs.\n * Wildcards (*) are supported for domains and paths.\n */\n urls: string[];\n };\n\n /**\n * Creates a new webhook endpoint.\n *\n * Generates a unique HTTP endpoint that will invoke the callback function\n * when requests are received. The callback receives the WebhookRequest plus any extraArgs.\n *\n * **Provider-Specific Behavior:**\n * - **Slack**: Uses provider-specific routing via team_id. Requires `authorization` parameter.\n * - **Gmail** (Google with Gmail scopes): Returns a Google Pub/Sub topic name instead of a webhook URL.\n * The topic name (e.g., \"projects/plot-prod/topics/gmail-webhook-abc123\") should be passed\n * to the Gmail API's `users.watch` endpoint. Requires `authorization` parameter with Gmail scopes.\n * - **Default**: Returns a standard webhook URL for all other cases.\n *\n * @param options - Webhook creation options\n * @param options.callback - Function receiving (request, ...extraArgs)\n * @param options.extraArgs - Additional arguments to pass to the callback (type-checked)\n * @param options.provider - Optional provider for provider-specific webhook routing\n * @param options.authorization - Optional authorization for provider-specific webhooks (required for Slack and Gmail)\n * @returns Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name\n *\n * @example\n * ```typescript\n * // Gmail webhook - returns Pub/Sub topic name\n * const topicName = await this.tools.network.createWebhook({\n * callback: this.onGmailNotification,\n * provider: AuthProvider.Google,\n * authorization: gmailAuth,\n * extraArgs: [\"inbox\"]\n * });\n * // topicName: \"projects/plot-prod/topics/gmail-webhook-abc123\"\n *\n * // Pass topic name to Gmail API\n * await gmailApi.users.watch({\n * userId: 'me',\n * requestBody: {\n * topicName: topicName, // Use the returned topic name\n * labelIds: ['INBOX']\n * }\n * });\n * ```\n */\n abstract createWebhook<\n TCallback extends (request: WebhookRequest, ...args: any[]) => any\n >(options: {\n callback: TCallback;\n extraArgs?: TCallback extends (req: any, ...rest: infer R) => any ? R : [];\n provider?: AuthProvider;\n authorization?: Authorization;\n }): Promise<string>;\n\n /**\n * Deletes an existing webhook endpoint.\n *\n * Removes the webhook endpoint and stops processing requests.\n * Works with all webhook types (standard, Slack, and Gmail).\n *\n * **For Gmail webhooks:** Also deletes the associated Google Pub/Sub topic and subscription.\n *\n * **For Slack webhooks:** Removes the callback registration for the specific team.\n *\n * **For standard webhooks:** Removes the webhook endpoint. Any subsequent requests\n * to the deleted webhook will return 404.\n *\n * @param url - The webhook identifier returned from `createWebhook()`.\n * This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),\n * or an opaque identifier (Slack). Always pass the exact value returned\n * from `createWebhook()`.\n * @returns Promise that resolves when the webhook is deleted\n */\n abstract deleteWebhook(url: string): Promise<void>;\n}\n";
7
+ export default "import { ITool } from \"..\";\nimport { type AuthProvider, type Authorization } from \"./integrations\";\n\n/**\n * Represents an incoming webhook request.\n *\n * This object is passed to webhook callback functions and contains all\n * the information about the HTTP request that triggered the webhook.\n *\n * @example\n * ```typescript\n * async onWebhookReceived(request: WebhookRequest, context: any) {\n * console.log(`${request.method} request received`);\n * console.log(\"Headers:\", request.headers);\n * console.log(\"Query params:\", request.params);\n * console.log(\"Body:\", request.body);\n * console.log(\"Context:\", context);\n * }\n * ```\n */\nexport type WebhookRequest = {\n /** HTTP method of the request (GET, POST, etc.) */\n method: string;\n /** HTTP headers from the request */\n headers: Record<string, string>;\n /** Query string parameters from the request URL */\n params: Record<string, string>;\n /** Request body (parsed as JSON if applicable) */\n body: any;\n /** Raw request body (for signature verification) */\n rawBody?: string;\n};\n\n/**\n * Built-in tool for requesting HTTP access permissions and managing webhooks.\n *\n * The Network tool serves two purposes:\n * 1. Declares which URLs a twist or tool is allowed to access via HTTP/HTTPS\n * 2. Provides webhook creation and management for receiving HTTP callbacks\n *\n * **IMPORTANT**: Must be requested in the Twist or Tool Init method to declare\n * HTTP access permissions. Without requesting this tool with the appropriate URLs,\n * all outbound HTTP requests (fetch, etc.) will be blocked.\n *\n * **Permission Patterns:**\n * - `*` - Allow access to all URLs\n * - `https://*.example.com` - Allow access to all subdomains\n * - `https://api.example.com/*` - Allow access to all paths on the domain\n * - `https://api.example.com/v1/*` - Allow access to specific path prefix\n *\n * **Webhook Characteristics:**\n * - Persistent across worker restarts\n * - Automatic callback routing to parent tool/twist\n * - Support for all HTTP methods\n * - Context preservation for callback execution\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist<MyTwist> {\n * build(build: ToolBuilder) {\n * return {\n * // Request HTTP access to specific APIs\n * network: build(Network, {\n * urls: [\n * 'https://api.github.com/*',\n * 'https://api.openai.com/*'\n * ]\n * })\n * };\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * class CalendarTool extends Tool<CalendarTool> {\n * build(build: ToolBuilder) {\n * return {\n * network: build(Network, {\n * urls: ['https://www.googleapis.com/calendar/*']\n * })\n * };\n * }\n *\n * async setupCalendarWebhook(calendarId: string) {\n * // Create webhook URL that will call onCalendarEvent\n * const webhookUrl = await this.tools.network.createWebhook({\n * callback: this.onCalendarEvent,\n * extraArgs: [calendarId, \"google\"]\n * });\n *\n * // Register webhook with Google Calendar API\n * await this.registerWithGoogleCalendar(calendarId, webhookUrl);\n *\n * return webhookUrl;\n * }\n *\n * async onCalendarEvent(request: WebhookRequest, calendarId: string, provider: string) {\n * console.log(\"Calendar event received:\", {\n * method: request.method,\n * calendarId,\n * provider,\n * body: request.body\n * });\n *\n * // Process the calendar event change\n * await this.processCalendarChange(request.body);\n * }\n *\n * async cleanup(webhookUrl: string) {\n * await this.tools.network.deleteWebhook(webhookUrl);\n * }\n * }\n * ```\n */\nexport abstract class Network extends ITool {\n static readonly Options: {\n /**\n * All network access is blocked except the specified URLs.\n * Wildcards (*) are supported for domains and paths.\n */\n urls: string[];\n };\n\n /**\n * Creates a new webhook endpoint.\n *\n * Generates a unique HTTP endpoint that will invoke the callback function\n * when requests are received. The callback receives the WebhookRequest plus any extraArgs.\n *\n * **Provider-Specific Behavior:**\n * - **Slack**: Uses provider-specific routing via team_id. Requires `authorization` parameter.\n * - **Gmail** (Google with Gmail scopes): Returns a Google Pub/Sub topic name instead of a webhook URL.\n * The topic name (e.g., \"projects/plot-prod/topics/gmail-webhook-abc123\") should be passed\n * to the Gmail API's `users.watch` endpoint. Requires `authorization` parameter with Gmail scopes.\n * - **Default**: Returns a standard webhook URL for all other cases.\n *\n * @param options - Webhook creation options\n * @param options.callback - Function receiving (request, ...extraArgs)\n * @param options.extraArgs - Additional arguments to pass to the callback (type-checked)\n * @param options.provider - Optional provider for provider-specific webhook routing\n * @param options.authorization - Optional authorization for provider-specific webhooks (required for Slack and Gmail)\n * @returns Promise resolving to the webhook URL, or for Gmail, a Pub/Sub topic name\n *\n * @example\n * ```typescript\n * // Gmail webhook - returns Pub/Sub topic name\n * const topicName = await this.tools.network.createWebhook({\n * callback: this.onGmailNotification,\n * provider: AuthProvider.Google,\n * authorization: gmailAuth,\n * extraArgs: [\"inbox\"]\n * });\n * // topicName: \"projects/plot-prod/topics/gmail-webhook-abc123\"\n *\n * // Pass topic name to Gmail API\n * await gmailApi.users.watch({\n * userId: 'me',\n * requestBody: {\n * topicName: topicName, // Use the returned topic name\n * labelIds: ['INBOX']\n * }\n * });\n * ```\n */\n abstract createWebhook<\n TCallback extends (request: WebhookRequest, ...args: any[]) => any\n >(options: {\n callback: TCallback;\n extraArgs?: TCallback extends (req: any, ...rest: infer R) => any ? R : [];\n provider?: AuthProvider;\n authorization?: Authorization;\n }): Promise<string>;\n\n /**\n * Deletes an existing webhook endpoint.\n *\n * Removes the webhook endpoint and stops processing requests.\n * Works with all webhook types (standard, Slack, and Gmail).\n *\n * **For Gmail webhooks:** Also deletes the associated Google Pub/Sub topic and subscription.\n *\n * **For Slack webhooks:** Removes the callback registration for the specific team.\n *\n * **For standard webhooks:** Removes the webhook endpoint. Any subsequent requests\n * to the deleted webhook will return 404.\n *\n * @param url - The webhook identifier returned from `createWebhook()`.\n * This can be a URL (standard webhooks), a Pub/Sub topic name (Gmail),\n * or an opaque identifier (Slack). Always pass the exact value returned\n * from `createWebhook()`.\n * @returns Promise that resolves when the webhook is deleted\n */\n abstract deleteWebhook(url: string): Promise<void>;\n}\n";
8
8
  //# sourceMappingURL=network.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,46NAA46N,CAAC"}
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/network.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,y/NAAy/N,CAAC"}
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/plot
2
+ * Generated LLM documentation for @plotday/twister/tools/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 {\n type Activity,\n type ActivityUpdate,\n type Actor,\n type ActorId,\n ITool,\n type NewActivity,\n type NewActivityWithNotes,\n type NewContact,\n type NewNote,\n type NewPriority,\n type Note,\n type NoteUpdate,\n type Priority,\n type Tag,\n} from \"..\";\n\nexport enum ActivityAccess {\n /**\n * Create new Note on an Activity where the twist was mentioned.\n * Add/remove tags on Activity or Note where the twist was mentioned.\n */\n Respond,\n /**\n * Create new Activity.\n * Create new Note in an Activity the twist created.\n * All Respond permissions.\n */\n Create,\n}\n\nexport enum PriorityAccess {\n /**\n * Create a new Priority within the twist's Priority.\n * Update Priority created by the twist.\n */\n Create,\n /**\n * Read all Priority within the twist's Priority.\n * Create a new Priority within the twist's Priority.\n * Update and archive any Priority within the twist's Priority.\n */\n Full,\n}\n\nexport enum ContactAccess {\n /** Read existing contacts. */\n Read,\n /** Create and update contacts. */\n Write,\n}\n\n/**\n * Intent handler for activity mentions.\n * Defines how the twist should respond when mentioned in an activity.\n */\nexport type NoteIntentHandler = {\n /** Human-readable description of what this intent handles */\n description: string;\n /** Example phrases or activity content that would match this intent */\n examples: string[];\n /** The function to call when this intent is matched */\n handler: (note: Note) => Promise<void>;\n};\n\n/**\n * Built-in tool for interacting with the core Plot data layer.\n *\n * The Plot tool provides twists with the ability to create and manage activities,\n * priorities, and contacts within the Plot system. This is the primary interface\n * for twists to persist data and interact with the Plot database.\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist {\n * private plot: Plot;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.plot = tools.get(Plot);\n * }\n *\n * async activate(priority) {\n * // Create a welcome activity\n * await this.plot.createActivity({\n * type: ActivityType.Note,\n * title: \"Welcome to Plot!\",\n * links: [{\n * title: \"Get Started\",\n * type: ActivityLinkType.external,\n * url: \"https://plot.day/docs\"\n * }]\n * });\n * }\n * }\n * ```\n */\nexport abstract class Plot extends ITool {\n static readonly Options: {\n activity?: {\n /**\n * Capability to create Notes and modify tags.\n */\n access?: ActivityAccess;\n /**\n * Called when an activity created by this twist is updated.\n * This is often used to implement two-way sync with an external system.\n *\n * @param activity - The updated activity\n * @param changes - Optional changes object containing the previous version and tag modifications\n */\n updated?: (\n activity: Activity,\n changes: {\n previous: Activity;\n tagsAdded: Record<Tag, ActorId[]>;\n tagsRemoved: Record<Tag, ActorId[]>;\n }\n ) => Promise<void>;\n };\n note?: {\n /**\n * Respond to mentions in notes.\n *\n * When a note mentions this twist, the system will match the note\n * content against these intents and call the matching handler.\n *\n * @example\n * ```typescript\n * intents: [{\n * description: \"Schedule or reschedule calendar events\",\n * examples: [\"Schedule a meeting tomorrow at 2pm\", \"Move my 3pm meeting to 4pm\"],\n * handler: this.onSchedulingRequest\n * }, {\n * description: \"Find available meeting times\",\n * examples: [\"When am I free this week?\", \"Find time for a 1 hour meeting\"],\n * handler: this.onAvailabilityRequest\n * }]\n * ```\n */\n intents?: NoteIntentHandler[];\n };\n priority?: {\n access?: PriorityAccess;\n };\n contact?: {\n access?: ContactAccess;\n };\n };\n\n /**\n * Creates a new activity in the Plot system.\n *\n * The activity will be automatically assigned an ID and author information\n * based on the current execution context. All other fields from NewActivity\n * will be preserved in the created activity.\n *\n * @param activity - The activity data to create\n * @returns Promise resolving to the complete created activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivity(\n activity: NewActivity | NewActivityWithNotes\n ): Promise<Activity>;\n\n /**\n * Creates multiple activities in a single batch operation.\n *\n * This method efficiently creates multiple activities at once, which is\n * more performant than calling createActivity() multiple times individually.\n * All activities are created with the same author and access control rules.\n *\n * @param activities - Array of activity data to create\n * @returns Promise resolving to array of created activities\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivities(\n activities: (NewActivity | NewActivityWithNotes)[]\n ): Promise<Activity[]>;\n\n /**\n * Updates an existing activity in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire activity object.\n *\n * For tags, provide a Record<number, boolean> where true adds a tag and false removes it.\n * Tags not included in the update remain unchanged.\n *\n * When updating the parent, the activity's path will be automatically recalculated to\n * maintain the correct hierarchical structure.\n *\n * When updating scheduling fields (start, end, recurrence*), the database will\n * automatically recalculate duration and range values to maintain consistency.\n *\n * @param activity - The activity update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Mark a task as complete\n * await this.plot.updateActivity({\n * id: \"task-123\",\n * doneAt: new Date()\n * });\n *\n * // Reschedule an event\n * await this.plot.updateActivity({\n * id: \"event-456\",\n * start: new Date(\"2024-03-15T10:00:00Z\"),\n * end: new Date(\"2024-03-15T11:00:00Z\")\n * });\n *\n * // Add and remove tags\n * await this.plot.updateActivity({\n * id: \"activity-789\",\n * tags: {\n * 1: true, // Add tag with ID 1\n * 2: false // Remove tag with ID 2\n * }\n * });\n *\n * // Update a recurring event exception\n * await this.plot.updateActivity({\n * id: \"exception-123\",\n * occurrence: new Date(\"2024-03-20T09:00:00Z\"),\n * title: \"Rescheduled meeting\"\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateActivity(activity: ActivityUpdate): Promise<void>;\n\n /**\n * Retrieves all notes within an activity.\n *\n * Notes are detailed entries within an activity, ordered by creation time.\n * Each note can contain markdown content, links, and other detailed information\n * related to the parent activity.\n *\n * @param activity - The activity whose notes to retrieve\n * @returns Promise resolving to array of notes in the activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getNotes(activity: Activity): Promise<Note[]>;\n\n /**\n * Creates a new note in an activity.\n *\n * Notes provide detailed content within an activity, supporting markdown,\n * links, and other rich content. The note will be automatically assigned\n * an ID and author information based on the current execution context.\n *\n * @param note - The note data to create\n * @returns Promise resolving to the complete created note\n *\n * @example\n * ```typescript\n * // Create a note with content\n * await this.plot.createNote({\n * activity: { id: \"activity-123\" },\n * note: \"Discussion notes from the meeting...\",\n * noteType: \"markdown\"\n * });\n *\n * // Create a note with links\n * await this.plot.createNote({\n * activity: { id: \"activity-456\" },\n * note: \"Meeting recording available\",\n * links: [{\n * type: ActivityLinkType.external,\n * title: \"View Recording\",\n * url: \"https://example.com/recording\"\n * }]\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNote(note: NewNote): Promise<Note>;\n\n /**\n * Creates multiple notes in a single batch operation.\n *\n * This method efficiently creates multiple notes at once, which is\n * more performant than calling createNote() multiple times individually.\n * All notes are created with the same author and access control rules.\n *\n * @param notes - Array of note data to create\n * @returns Promise resolving to array of created notes\n *\n * @example\n * ```typescript\n * // Create multiple notes in one batch\n * await this.plot.createNotes([\n * {\n * activity: { id: \"activity-123\" },\n * note: \"First message in thread\"\n * },\n * {\n * activity: { id: \"activity-123\" },\n * note: \"Second message in thread\"\n * }\n * ]);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNotes(notes: NewNote[]): Promise<Note[]>;\n\n /**\n * Updates an existing note in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire note object.\n *\n * @param note - The note update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Update note content\n * await this.plot.updateNote({\n * id: \"note-123\",\n * note: \"Updated content with more details\"\n * });\n *\n * // Add tags to a note\n * await this.plot.updateNote({\n * id: \"note-456\",\n * twistTags: {\n * [Tag.Important]: true\n * }\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateNote(note: NoteUpdate): Promise<void>;\n\n /**\n * Finds an activity by its meta.source.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n *\n * @param source - The meta.source value to search for\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityBySource(source: string): Promise<Activity | null>;\n\n /**\n * Creates a new priority in the Plot system.\n *\n * Priorities serve as organizational containers for activities and twists.\n * The created priority will be automatically assigned a unique ID.\n *\n * @param priority - The priority data to create\n * @returns Promise resolving to the complete created priority\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createPriority(priority: NewPriority): Promise<Priority>;\n\n /**\n * Adds contacts to the Plot system.\n *\n * Contacts are used for associating people with activities, such as\n * event attendees or task assignees. Duplicate contacts (by email)\n * will be merged or updated as appropriate.\n * This method requires ContactAccess.Write permission.\n *\n * @param contacts - Array of contact information to add\n * @returns Promise resolving to array of created/updated actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract addContacts(contacts: Array<NewContact>): Promise<Actor[]>;\n\n /**\n * Retrieves actors by their IDs.\n *\n * Actors represent users, contacts, or twists in the Plot system.\n * This method requires ContactAccess.Read permission.\n *\n * @param ids - Array of actor IDs to retrieve\n * @returns Promise resolving to array of actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActors(ids: ActorId[]): Promise<Actor[]>;\n}\n";
7
+ declare const _default: "import {\n type Activity,\n type ActivityMeta,\n type ActivityUpdate,\n type Actor,\n type ActorId,\n ITool,\n type NewActivity,\n type NewActivityWithNotes,\n type NewContact,\n type NewNote,\n type NewPriority,\n type Note,\n type NoteUpdate,\n type Priority,\n type Tag,\n} from \"..\";\n\nexport enum ActivityAccess {\n /**\n * Create new Note on an Activity where the twist was mentioned.\n * Add/remove tags on Activity or Note where the twist was mentioned.\n */\n Respond,\n /**\n * Create new Activity.\n * Create new Note in an Activity the twist created.\n * All Respond permissions.\n */\n Create,\n}\n\nexport enum PriorityAccess {\n /**\n * Create a new Priority within the twist's Priority.\n * Update Priority created by the twist.\n */\n Create,\n /**\n * Read all Priority within the twist's Priority.\n * Create a new Priority within the twist's Priority.\n * Update and archive any Priority within the twist's Priority.\n */\n Full,\n}\n\nexport enum ContactAccess {\n /** Read existing contacts. */\n Read,\n /** Create and update contacts. */\n Write,\n}\n\n/**\n * Intent handler for activity mentions.\n * Defines how the twist should respond when mentioned in an activity.\n */\nexport type NoteIntentHandler = {\n /** Human-readable description of what this intent handles */\n description: string;\n /** Example phrases or activity content that would match this intent */\n examples: string[];\n /** The function to call when this intent is matched */\n handler: (note: Note) => Promise<void>;\n};\n\n/**\n * Built-in tool for interacting with the core Plot data layer.\n *\n * The Plot tool provides twists with the ability to create and manage activities,\n * priorities, and contacts within the Plot system. This is the primary interface\n * for twists to persist data and interact with the Plot database.\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist {\n * private plot: Plot;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.plot = tools.get(Plot);\n * }\n *\n * async activate(priority) {\n * // Create a welcome activity\n * await this.plot.createActivity({\n * type: ActivityType.Note,\n * title: \"Welcome to Plot!\",\n * links: [{\n * title: \"Get Started\",\n * type: ActivityLinkType.external,\n * url: \"https://plot.day/docs\"\n * }]\n * });\n * }\n * }\n * ```\n */\nexport abstract class Plot extends ITool {\n static readonly Options: {\n activity?: {\n /**\n * Capability to create Notes and modify tags.\n */\n access?: ActivityAccess;\n /**\n * Called when an activity created by this twist is updated.\n * This is often used to implement two-way sync with an external system.\n *\n * @param activity - The updated activity\n * @param changes - Changes to the activity and the previous version\n */\n updated?: (\n activity: Activity,\n changes: {\n update: ActivityUpdate;\n previous: Activity;\n tagsAdded: Record<Tag, ActorId[]>;\n tagsRemoved: Record<Tag, ActorId[]>;\n }\n ) => Promise<void>;\n };\n note?: {\n /**\n * Respond to mentions in notes.\n *\n * When a note mentions this twist, the system will match the note\n * content against these intents and call the matching handler.\n *\n * @example\n * ```typescript\n * intents: [{\n * description: \"Schedule or reschedule calendar events\",\n * examples: [\"Schedule a meeting tomorrow at 2pm\", \"Move my 3pm meeting to 4pm\"],\n * handler: this.onSchedulingRequest\n * }, {\n * description: \"Find available meeting times\",\n * examples: [\"When am I free this week?\", \"Find time for a 1 hour meeting\"],\n * handler: this.onAvailabilityRequest\n * }]\n * ```\n */\n intents?: NoteIntentHandler[];\n /**\n * Called when a note is created on an activity created by this twist.\n * This is often used to implement two-way sync with an external system,\n * such as syncing notes as comments back to the source system.\n *\n * Notes created by the twist itself are automatically filtered out to prevent loops.\n * The parent activity is available via note.activity.\n *\n * @param note - The newly created note\n */\n created?: (note: Note) => Promise<void>;\n };\n priority?: {\n access?: PriorityAccess;\n };\n contact?: {\n access?: ContactAccess;\n };\n };\n\n /**\n * Creates a new activity in the Plot system.\n *\n * The activity will be automatically assigned an ID and author information\n * based on the current execution context. All other fields from NewActivity\n * will be preserved in the created activity.\n *\n * @param activity - The activity data to create\n * @returns Promise resolving to the complete created activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivity(\n activity: NewActivity | NewActivityWithNotes\n ): Promise<Activity>;\n\n /**\n * Creates multiple activities in a single batch operation.\n *\n * This method efficiently creates multiple activities at once, which is\n * more performant than calling createActivity() multiple times individually.\n * All activities are created with the same author and access control rules.\n *\n * @param activities - Array of activity data to create\n * @returns Promise resolving to array of created activities\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivities(\n activities: (NewActivity | NewActivityWithNotes)[]\n ): Promise<Activity[]>;\n\n /**\n * Updates an existing activity in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire activity object.\n *\n * For tags, provide a Record<number, boolean> where true adds a tag and false removes it.\n * Tags not included in the update remain unchanged.\n *\n * When updating the parent, the activity's path will be automatically recalculated to\n * maintain the correct hierarchical structure.\n *\n * When updating scheduling fields (start, end, recurrence*), the database will\n * automatically recalculate duration and range values to maintain consistency.\n *\n * @param activity - The activity update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Mark a task as complete\n * await this.plot.updateActivity({\n * id: \"task-123\",\n * doneAt: new Date()\n * });\n *\n * // Reschedule an event\n * await this.plot.updateActivity({\n * id: \"event-456\",\n * start: new Date(\"2024-03-15T10:00:00Z\"),\n * end: new Date(\"2024-03-15T11:00:00Z\")\n * });\n *\n * // Add and remove tags\n * await this.plot.updateActivity({\n * id: \"activity-789\",\n * tags: {\n * 1: true, // Add tag with ID 1\n * 2: false // Remove tag with ID 2\n * }\n * });\n *\n * // Update a recurring event exception\n * await this.plot.updateActivity({\n * id: \"exception-123\",\n * occurrence: new Date(\"2024-03-20T09:00:00Z\"),\n * title: \"Rescheduled meeting\"\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateActivity(activity: ActivityUpdate): Promise<void>;\n\n /**\n * Retrieves all notes within an activity.\n *\n * Notes are detailed entries within an activity, ordered by creation time.\n * Each note can contain markdown content, links, and other detailed information\n * related to the parent activity.\n *\n * @param activity - The activity whose notes to retrieve\n * @returns Promise resolving to array of notes in the activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getNotes(activity: Activity): Promise<Note[]>;\n\n /**\n * Creates a new note in an activity.\n *\n * Notes provide detailed content within an activity, supporting markdown,\n * links, and other rich content. The note will be automatically assigned\n * an ID and author information based on the current execution context.\n *\n * @param note - The note data to create\n * @returns Promise resolving to the complete created note\n *\n * @example\n * ```typescript\n * // Create a note with content\n * await this.plot.createNote({\n * activity: { id: \"activity-123\" },\n * note: \"Discussion notes from the meeting...\",\n * contentType: \"markdown\"\n * });\n *\n * // Create a note with links\n * await this.plot.createNote({\n * activity: { id: \"activity-456\" },\n * note: \"Meeting recording available\",\n * links: [{\n * type: ActivityLinkType.external,\n * title: \"View Recording\",\n * url: \"https://example.com/recording\"\n * }]\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNote(note: NewNote): Promise<Note>;\n\n /**\n * Creates multiple notes in a single batch operation.\n *\n * This method efficiently creates multiple notes at once, which is\n * more performant than calling createNote() multiple times individually.\n * All notes are created with the same author and access control rules.\n *\n * @param notes - Array of note data to create\n * @returns Promise resolving to array of created notes\n *\n * @example\n * ```typescript\n * // Create multiple notes in one batch\n * await this.plot.createNotes([\n * {\n * activity: { id: \"activity-123\" },\n * note: \"First message in thread\"\n * },\n * {\n * activity: { id: \"activity-123\" },\n * note: \"Second message in thread\"\n * }\n * ]);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNotes(notes: NewNote[]): Promise<Note[]>;\n\n /**\n * Updates an existing note in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire note object.\n *\n * @param note - The note update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Update note content\n * await this.plot.updateNote({\n * id: \"note-123\",\n * note: \"Updated content with more details\"\n * });\n *\n * // Add tags to a note\n * await this.plot.updateNote({\n * id: \"note-456\",\n * twistTags: {\n * [Tag.Important]: true\n * }\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateNote(note: NoteUpdate): Promise<void>;\n\n /**\n * Finds an activity by its meta.source.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n *\n * By default, archived activities are excluded from the search. Set includeArchived\n * to true to include them in the results.\n *\n * @param source - The meta.source value to search for\n * @param includeArchived - Whether to include archived activities in search (default: false)\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityBySource(\n source: string,\n includeArchived?: boolean\n ): Promise<Activity | null>;\n\n /**\n * Finds an activity by its metadata.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n * Uses JSON containment matching - the provided meta must be contained\n * within the activity's meta field.\n *\n * By default, archived activities are excluded from the search. Set includeArchived\n * to true to include them in the results.\n *\n * @param meta - The metadata to search for (uses JSON containment matching)\n * @param includeArchived - Whether to include archived activities in search (default: false)\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityByMeta(\n meta: ActivityMeta,\n includeArchived?: boolean\n ): Promise<Activity | null>;\n\n /**\n * Creates a new priority in the Plot system.\n *\n * Priorities serve as organizational containers for activities and twists.\n * The created priority will be automatically assigned a unique ID.\n *\n * @param priority - The priority data to create\n * @returns Promise resolving to the complete created priority\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createPriority(priority: NewPriority): Promise<Priority>;\n\n /**\n * Adds contacts to the Plot system.\n *\n * Contacts are used for associating people with activities, such as\n * event attendees or task assignees. Duplicate contacts (by email)\n * will be merged or updated as appropriate.\n * This method requires ContactAccess.Write permission.\n *\n * @param contacts - Array of contact information to add\n * @returns Promise resolving to array of created/updated actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract addContacts(contacts: Array<NewContact>): Promise<Actor[]>;\n\n /**\n * Retrieves actors by their IDs.\n *\n * Actors represent users, contacts, or twists in the Plot system.\n * This method requires ContactAccess.Read permission.\n *\n * @param ids - Array of actor IDs to retrieve\n * @returns Promise resolving to array of actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActors(ids: ActorId[]): Promise<Actor[]>;\n}\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/tools/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,07YAA07Y;AAAz8Y,wBAA08Y"}
1
+ {"version":3,"file":"plot.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,ipcAAipc;AAAhqc,wBAAiqc"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/plot
2
+ * Generated LLM documentation for @plotday/twister/tools/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 {\n type Activity,\n type ActivityUpdate,\n type Actor,\n type ActorId,\n ITool,\n type NewActivity,\n type NewActivityWithNotes,\n type NewContact,\n type NewNote,\n type NewPriority,\n type Note,\n type NoteUpdate,\n type Priority,\n type Tag,\n} from \"..\";\n\nexport enum ActivityAccess {\n /**\n * Create new Note on an Activity where the twist was mentioned.\n * Add/remove tags on Activity or Note where the twist was mentioned.\n */\n Respond,\n /**\n * Create new Activity.\n * Create new Note in an Activity the twist created.\n * All Respond permissions.\n */\n Create,\n}\n\nexport enum PriorityAccess {\n /**\n * Create a new Priority within the twist's Priority.\n * Update Priority created by the twist.\n */\n Create,\n /**\n * Read all Priority within the twist's Priority.\n * Create a new Priority within the twist's Priority.\n * Update and archive any Priority within the twist's Priority.\n */\n Full,\n}\n\nexport enum ContactAccess {\n /** Read existing contacts. */\n Read,\n /** Create and update contacts. */\n Write,\n}\n\n/**\n * Intent handler for activity mentions.\n * Defines how the twist should respond when mentioned in an activity.\n */\nexport type NoteIntentHandler = {\n /** Human-readable description of what this intent handles */\n description: string;\n /** Example phrases or activity content that would match this intent */\n examples: string[];\n /** The function to call when this intent is matched */\n handler: (note: Note) => Promise<void>;\n};\n\n/**\n * Built-in tool for interacting with the core Plot data layer.\n *\n * The Plot tool provides twists with the ability to create and manage activities,\n * priorities, and contacts within the Plot system. This is the primary interface\n * for twists to persist data and interact with the Plot database.\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist {\n * private plot: Plot;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.plot = tools.get(Plot);\n * }\n *\n * async activate(priority) {\n * // Create a welcome activity\n * await this.plot.createActivity({\n * type: ActivityType.Note,\n * title: \"Welcome to Plot!\",\n * links: [{\n * title: \"Get Started\",\n * type: ActivityLinkType.external,\n * url: \"https://plot.day/docs\"\n * }]\n * });\n * }\n * }\n * ```\n */\nexport abstract class Plot extends ITool {\n static readonly Options: {\n activity?: {\n /**\n * Capability to create Notes and modify tags.\n */\n access?: ActivityAccess;\n /**\n * Called when an activity created by this twist is updated.\n * This is often used to implement two-way sync with an external system.\n *\n * @param activity - The updated activity\n * @param changes - Optional changes object containing the previous version and tag modifications\n */\n updated?: (\n activity: Activity,\n changes: {\n previous: Activity;\n tagsAdded: Record<Tag, ActorId[]>;\n tagsRemoved: Record<Tag, ActorId[]>;\n }\n ) => Promise<void>;\n };\n note?: {\n /**\n * Respond to mentions in notes.\n *\n * When a note mentions this twist, the system will match the note\n * content against these intents and call the matching handler.\n *\n * @example\n * ```typescript\n * intents: [{\n * description: \"Schedule or reschedule calendar events\",\n * examples: [\"Schedule a meeting tomorrow at 2pm\", \"Move my 3pm meeting to 4pm\"],\n * handler: this.onSchedulingRequest\n * }, {\n * description: \"Find available meeting times\",\n * examples: [\"When am I free this week?\", \"Find time for a 1 hour meeting\"],\n * handler: this.onAvailabilityRequest\n * }]\n * ```\n */\n intents?: NoteIntentHandler[];\n };\n priority?: {\n access?: PriorityAccess;\n };\n contact?: {\n access?: ContactAccess;\n };\n };\n\n /**\n * Creates a new activity in the Plot system.\n *\n * The activity will be automatically assigned an ID and author information\n * based on the current execution context. All other fields from NewActivity\n * will be preserved in the created activity.\n *\n * @param activity - The activity data to create\n * @returns Promise resolving to the complete created activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivity(\n activity: NewActivity | NewActivityWithNotes\n ): Promise<Activity>;\n\n /**\n * Creates multiple activities in a single batch operation.\n *\n * This method efficiently creates multiple activities at once, which is\n * more performant than calling createActivity() multiple times individually.\n * All activities are created with the same author and access control rules.\n *\n * @param activities - Array of activity data to create\n * @returns Promise resolving to array of created activities\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivities(\n activities: (NewActivity | NewActivityWithNotes)[]\n ): Promise<Activity[]>;\n\n /**\n * Updates an existing activity in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire activity object.\n *\n * For tags, provide a Record<number, boolean> where true adds a tag and false removes it.\n * Tags not included in the update remain unchanged.\n *\n * When updating the parent, the activity's path will be automatically recalculated to\n * maintain the correct hierarchical structure.\n *\n * When updating scheduling fields (start, end, recurrence*), the database will\n * automatically recalculate duration and range values to maintain consistency.\n *\n * @param activity - The activity update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Mark a task as complete\n * await this.plot.updateActivity({\n * id: \"task-123\",\n * doneAt: new Date()\n * });\n *\n * // Reschedule an event\n * await this.plot.updateActivity({\n * id: \"event-456\",\n * start: new Date(\"2024-03-15T10:00:00Z\"),\n * end: new Date(\"2024-03-15T11:00:00Z\")\n * });\n *\n * // Add and remove tags\n * await this.plot.updateActivity({\n * id: \"activity-789\",\n * tags: {\n * 1: true, // Add tag with ID 1\n * 2: false // Remove tag with ID 2\n * }\n * });\n *\n * // Update a recurring event exception\n * await this.plot.updateActivity({\n * id: \"exception-123\",\n * occurrence: new Date(\"2024-03-20T09:00:00Z\"),\n * title: \"Rescheduled meeting\"\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateActivity(activity: ActivityUpdate): Promise<void>;\n\n /**\n * Retrieves all notes within an activity.\n *\n * Notes are detailed entries within an activity, ordered by creation time.\n * Each note can contain markdown content, links, and other detailed information\n * related to the parent activity.\n *\n * @param activity - The activity whose notes to retrieve\n * @returns Promise resolving to array of notes in the activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getNotes(activity: Activity): Promise<Note[]>;\n\n /**\n * Creates a new note in an activity.\n *\n * Notes provide detailed content within an activity, supporting markdown,\n * links, and other rich content. The note will be automatically assigned\n * an ID and author information based on the current execution context.\n *\n * @param note - The note data to create\n * @returns Promise resolving to the complete created note\n *\n * @example\n * ```typescript\n * // Create a note with content\n * await this.plot.createNote({\n * activity: { id: \"activity-123\" },\n * note: \"Discussion notes from the meeting...\",\n * noteType: \"markdown\"\n * });\n *\n * // Create a note with links\n * await this.plot.createNote({\n * activity: { id: \"activity-456\" },\n * note: \"Meeting recording available\",\n * links: [{\n * type: ActivityLinkType.external,\n * title: \"View Recording\",\n * url: \"https://example.com/recording\"\n * }]\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNote(note: NewNote): Promise<Note>;\n\n /**\n * Creates multiple notes in a single batch operation.\n *\n * This method efficiently creates multiple notes at once, which is\n * more performant than calling createNote() multiple times individually.\n * All notes are created with the same author and access control rules.\n *\n * @param notes - Array of note data to create\n * @returns Promise resolving to array of created notes\n *\n * @example\n * ```typescript\n * // Create multiple notes in one batch\n * await this.plot.createNotes([\n * {\n * activity: { id: \"activity-123\" },\n * note: \"First message in thread\"\n * },\n * {\n * activity: { id: \"activity-123\" },\n * note: \"Second message in thread\"\n * }\n * ]);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNotes(notes: NewNote[]): Promise<Note[]>;\n\n /**\n * Updates an existing note in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire note object.\n *\n * @param note - The note update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Update note content\n * await this.plot.updateNote({\n * id: \"note-123\",\n * note: \"Updated content with more details\"\n * });\n *\n * // Add tags to a note\n * await this.plot.updateNote({\n * id: \"note-456\",\n * twistTags: {\n * [Tag.Important]: true\n * }\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateNote(note: NoteUpdate): Promise<void>;\n\n /**\n * Finds an activity by its meta.source.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n *\n * @param source - The meta.source value to search for\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityBySource(source: string): Promise<Activity | null>;\n\n /**\n * Creates a new priority in the Plot system.\n *\n * Priorities serve as organizational containers for activities and twists.\n * The created priority will be automatically assigned a unique ID.\n *\n * @param priority - The priority data to create\n * @returns Promise resolving to the complete created priority\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createPriority(priority: NewPriority): Promise<Priority>;\n\n /**\n * Adds contacts to the Plot system.\n *\n * Contacts are used for associating people with activities, such as\n * event attendees or task assignees. Duplicate contacts (by email)\n * will be merged or updated as appropriate.\n * This method requires ContactAccess.Write permission.\n *\n * @param contacts - Array of contact information to add\n * @returns Promise resolving to array of created/updated actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract addContacts(contacts: Array<NewContact>): Promise<Actor[]>;\n\n /**\n * Retrieves actors by their IDs.\n *\n * Actors represent users, contacts, or twists in the Plot system.\n * This method requires ContactAccess.Read permission.\n *\n * @param ids - Array of actor IDs to retrieve\n * @returns Promise resolving to array of actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActors(ids: ActorId[]): Promise<Actor[]>;\n}\n";
7
+ export default "import {\n type Activity,\n type ActivityMeta,\n type ActivityUpdate,\n type Actor,\n type ActorId,\n ITool,\n type NewActivity,\n type NewActivityWithNotes,\n type NewContact,\n type NewNote,\n type NewPriority,\n type Note,\n type NoteUpdate,\n type Priority,\n type Tag,\n} from \"..\";\n\nexport enum ActivityAccess {\n /**\n * Create new Note on an Activity where the twist was mentioned.\n * Add/remove tags on Activity or Note where the twist was mentioned.\n */\n Respond,\n /**\n * Create new Activity.\n * Create new Note in an Activity the twist created.\n * All Respond permissions.\n */\n Create,\n}\n\nexport enum PriorityAccess {\n /**\n * Create a new Priority within the twist's Priority.\n * Update Priority created by the twist.\n */\n Create,\n /**\n * Read all Priority within the twist's Priority.\n * Create a new Priority within the twist's Priority.\n * Update and archive any Priority within the twist's Priority.\n */\n Full,\n}\n\nexport enum ContactAccess {\n /** Read existing contacts. */\n Read,\n /** Create and update contacts. */\n Write,\n}\n\n/**\n * Intent handler for activity mentions.\n * Defines how the twist should respond when mentioned in an activity.\n */\nexport type NoteIntentHandler = {\n /** Human-readable description of what this intent handles */\n description: string;\n /** Example phrases or activity content that would match this intent */\n examples: string[];\n /** The function to call when this intent is matched */\n handler: (note: Note) => Promise<void>;\n};\n\n/**\n * Built-in tool for interacting with the core Plot data layer.\n *\n * The Plot tool provides twists with the ability to create and manage activities,\n * priorities, and contacts within the Plot system. This is the primary interface\n * for twists to persist data and interact with the Plot database.\n *\n * @example\n * ```typescript\n * class MyTwist extends Twist {\n * private plot: Plot;\n *\n * constructor(id: string, tools: ToolBuilder) {\n * super();\n * this.plot = tools.get(Plot);\n * }\n *\n * async activate(priority) {\n * // Create a welcome activity\n * await this.plot.createActivity({\n * type: ActivityType.Note,\n * title: \"Welcome to Plot!\",\n * links: [{\n * title: \"Get Started\",\n * type: ActivityLinkType.external,\n * url: \"https://plot.day/docs\"\n * }]\n * });\n * }\n * }\n * ```\n */\nexport abstract class Plot extends ITool {\n static readonly Options: {\n activity?: {\n /**\n * Capability to create Notes and modify tags.\n */\n access?: ActivityAccess;\n /**\n * Called when an activity created by this twist is updated.\n * This is often used to implement two-way sync with an external system.\n *\n * @param activity - The updated activity\n * @param changes - Changes to the activity and the previous version\n */\n updated?: (\n activity: Activity,\n changes: {\n update: ActivityUpdate;\n previous: Activity;\n tagsAdded: Record<Tag, ActorId[]>;\n tagsRemoved: Record<Tag, ActorId[]>;\n }\n ) => Promise<void>;\n };\n note?: {\n /**\n * Respond to mentions in notes.\n *\n * When a note mentions this twist, the system will match the note\n * content against these intents and call the matching handler.\n *\n * @example\n * ```typescript\n * intents: [{\n * description: \"Schedule or reschedule calendar events\",\n * examples: [\"Schedule a meeting tomorrow at 2pm\", \"Move my 3pm meeting to 4pm\"],\n * handler: this.onSchedulingRequest\n * }, {\n * description: \"Find available meeting times\",\n * examples: [\"When am I free this week?\", \"Find time for a 1 hour meeting\"],\n * handler: this.onAvailabilityRequest\n * }]\n * ```\n */\n intents?: NoteIntentHandler[];\n /**\n * Called when a note is created on an activity created by this twist.\n * This is often used to implement two-way sync with an external system,\n * such as syncing notes as comments back to the source system.\n *\n * Notes created by the twist itself are automatically filtered out to prevent loops.\n * The parent activity is available via note.activity.\n *\n * @param note - The newly created note\n */\n created?: (note: Note) => Promise<void>;\n };\n priority?: {\n access?: PriorityAccess;\n };\n contact?: {\n access?: ContactAccess;\n };\n };\n\n /**\n * Creates a new activity in the Plot system.\n *\n * The activity will be automatically assigned an ID and author information\n * based on the current execution context. All other fields from NewActivity\n * will be preserved in the created activity.\n *\n * @param activity - The activity data to create\n * @returns Promise resolving to the complete created activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivity(\n activity: NewActivity | NewActivityWithNotes\n ): Promise<Activity>;\n\n /**\n * Creates multiple activities in a single batch operation.\n *\n * This method efficiently creates multiple activities at once, which is\n * more performant than calling createActivity() multiple times individually.\n * All activities are created with the same author and access control rules.\n *\n * @param activities - Array of activity data to create\n * @returns Promise resolving to array of created activities\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createActivities(\n activities: (NewActivity | NewActivityWithNotes)[]\n ): Promise<Activity[]>;\n\n /**\n * Updates an existing activity in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire activity object.\n *\n * For tags, provide a Record<number, boolean> where true adds a tag and false removes it.\n * Tags not included in the update remain unchanged.\n *\n * When updating the parent, the activity's path will be automatically recalculated to\n * maintain the correct hierarchical structure.\n *\n * When updating scheduling fields (start, end, recurrence*), the database will\n * automatically recalculate duration and range values to maintain consistency.\n *\n * @param activity - The activity update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Mark a task as complete\n * await this.plot.updateActivity({\n * id: \"task-123\",\n * doneAt: new Date()\n * });\n *\n * // Reschedule an event\n * await this.plot.updateActivity({\n * id: \"event-456\",\n * start: new Date(\"2024-03-15T10:00:00Z\"),\n * end: new Date(\"2024-03-15T11:00:00Z\")\n * });\n *\n * // Add and remove tags\n * await this.plot.updateActivity({\n * id: \"activity-789\",\n * tags: {\n * 1: true, // Add tag with ID 1\n * 2: false // Remove tag with ID 2\n * }\n * });\n *\n * // Update a recurring event exception\n * await this.plot.updateActivity({\n * id: \"exception-123\",\n * occurrence: new Date(\"2024-03-20T09:00:00Z\"),\n * title: \"Rescheduled meeting\"\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateActivity(activity: ActivityUpdate): Promise<void>;\n\n /**\n * Retrieves all notes within an activity.\n *\n * Notes are detailed entries within an activity, ordered by creation time.\n * Each note can contain markdown content, links, and other detailed information\n * related to the parent activity.\n *\n * @param activity - The activity whose notes to retrieve\n * @returns Promise resolving to array of notes in the activity\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getNotes(activity: Activity): Promise<Note[]>;\n\n /**\n * Creates a new note in an activity.\n *\n * Notes provide detailed content within an activity, supporting markdown,\n * links, and other rich content. The note will be automatically assigned\n * an ID and author information based on the current execution context.\n *\n * @param note - The note data to create\n * @returns Promise resolving to the complete created note\n *\n * @example\n * ```typescript\n * // Create a note with content\n * await this.plot.createNote({\n * activity: { id: \"activity-123\" },\n * note: \"Discussion notes from the meeting...\",\n * contentType: \"markdown\"\n * });\n *\n * // Create a note with links\n * await this.plot.createNote({\n * activity: { id: \"activity-456\" },\n * note: \"Meeting recording available\",\n * links: [{\n * type: ActivityLinkType.external,\n * title: \"View Recording\",\n * url: \"https://example.com/recording\"\n * }]\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNote(note: NewNote): Promise<Note>;\n\n /**\n * Creates multiple notes in a single batch operation.\n *\n * This method efficiently creates multiple notes at once, which is\n * more performant than calling createNote() multiple times individually.\n * All notes are created with the same author and access control rules.\n *\n * @param notes - Array of note data to create\n * @returns Promise resolving to array of created notes\n *\n * @example\n * ```typescript\n * // Create multiple notes in one batch\n * await this.plot.createNotes([\n * {\n * activity: { id: \"activity-123\" },\n * note: \"First message in thread\"\n * },\n * {\n * activity: { id: \"activity-123\" },\n * note: \"Second message in thread\"\n * }\n * ]);\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createNotes(notes: NewNote[]): Promise<Note[]>;\n\n /**\n * Updates an existing note in the Plot system.\n *\n * Only the fields provided in the update object will be modified - all other fields\n * remain unchanged. This enables partial updates without needing to fetch and resend\n * the entire note object.\n *\n * @param note - The note update containing the ID and fields to change\n * @returns Promise that resolves when the update is complete\n *\n * @example\n * ```typescript\n * // Update note content\n * await this.plot.updateNote({\n * id: \"note-123\",\n * note: \"Updated content with more details\"\n * });\n *\n * // Add tags to a note\n * await this.plot.updateNote({\n * id: \"note-456\",\n * twistTags: {\n * [Tag.Important]: true\n * }\n * });\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract updateNote(note: NoteUpdate): Promise<void>;\n\n /**\n * Finds an activity by its meta.source.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n *\n * By default, archived activities are excluded from the search. Set includeArchived\n * to true to include them in the results.\n *\n * @param source - The meta.source value to search for\n * @param includeArchived - Whether to include archived activities in search (default: false)\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityBySource(\n source: string,\n includeArchived?: boolean\n ): Promise<Activity | null>;\n\n /**\n * Finds an activity by its metadata.\n *\n * This method enables lookup of activities that were created from external\n * systems, using the metadata to locate the corresponding Plot activity.\n * Uses JSON containment matching - the provided meta must be contained\n * within the activity's meta field.\n *\n * By default, archived activities are excluded from the search. Set includeArchived\n * to true to include them in the results.\n *\n * @param meta - The metadata to search for (uses JSON containment matching)\n * @param includeArchived - Whether to include archived activities in search (default: false)\n * @returns Promise resolving to the matching activity or null if not found\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActivityByMeta(\n meta: ActivityMeta,\n includeArchived?: boolean\n ): Promise<Activity | null>;\n\n /**\n * Creates a new priority in the Plot system.\n *\n * Priorities serve as organizational containers for activities and twists.\n * The created priority will be automatically assigned a unique ID.\n *\n * @param priority - The priority data to create\n * @returns Promise resolving to the complete created priority\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract createPriority(priority: NewPriority): Promise<Priority>;\n\n /**\n * Adds contacts to the Plot system.\n *\n * Contacts are used for associating people with activities, such as\n * event attendees or task assignees. Duplicate contacts (by email)\n * will be merged or updated as appropriate.\n * This method requires ContactAccess.Write permission.\n *\n * @param contacts - Array of contact information to add\n * @returns Promise resolving to array of created/updated actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract addContacts(contacts: Array<NewContact>): Promise<Actor[]>;\n\n /**\n * Retrieves actors by their IDs.\n *\n * Actors represent users, contacts, or twists in the Plot system.\n * This method requires ContactAccess.Read permission.\n *\n * @param ids - Array of actor IDs to retrieve\n * @returns Promise resolving to array of actors\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract getActors(ids: ActorId[]): Promise<Actor[]>;\n}\n";
8
8
  //# sourceMappingURL=plot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,07YAA07Y,CAAC"}
1
+ {"version":3,"file":"plot.js","sourceRoot":"","sources":["../../../src/llm-docs/tools/plot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,ipcAAipc,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/store
2
+ * Generated LLM documentation for @plotday/twister/tools/store
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/store
2
+ * Generated LLM documentation for @plotday/twister/tools/store
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/tasks
2
+ * Generated LLM documentation for @plotday/twister/tools/tasks
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/tasks
2
+ * Generated LLM documentation for @plotday/twister/tools/tasks
3
3
  *
4
4
  * This file is auto-generated during build. Do not edit manually.
5
5
  * Generated from: prebuild.ts
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Generated LLM documentation for @plotday/sdk/tools/twists
2
+ * Generated LLM documentation for @plotday/twister/tools/twists
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 Callback, ITool } from \"..\";\n\n/**\n * Twist source code structure containing dependencies and source files.\n */\nexport interface TwistSource {\n /**\n * Package dependencies with version specifiers\n * @example { \"@plotday/sdk\": \"workspace:^\", \"@plotday/tool-google-calendar\": \"^1.0.0\" }\n */\n dependencies: Record<string, string>;\n\n /**\n * Source files with their content\n * Must include \"index.ts\" as the entry point\n * @example { \"index.ts\": \"export default class MyTwist extends Twist {...}\" }\n */\n files: Record<string, string>;\n}\n\n/**\n * Represents a log entry from a twist execution.\n */\nexport type Log = {\n timestamp: Date;\n environment: \"personal\" | \"private\" | \"review\" | \"public\";\n severity: \"log\" | \"error\" | \"warn\" | \"info\";\n message: string;\n};\n\n/**\n * Twist permissions returned after deployment.\n * Nested structure mapping domains to entities to permission flags.\n *\n * Format: { domain: { entity: flags[] } }\n * - domain: Tool name (e.g., \"network\", \"plot\")\n * - entity: Domain-specific identifier (e.g., URL pattern, resource type)\n * - flags: Array of permission flags (\"read\", \"write\", \"update\", \"use\")\n *\n * @example\n * ```typescript\n * {\n * \"network\": {\n * \"https://api.example.com/*\": [\"use\"],\n * \"https://googleapis.com/*\": [\"use\"]\n * },\n * \"plot\": {\n * \"activity:mentioned\": [\"read\", \"write\", \"update\"],\n * \"priority\": [\"read\", \"write\", \"update\"]\n * }\n * }\n * ```\n */\nexport type TwistPermissions = Record<string, Record<string, string[]>>;\n\n/**\n * Built-in tool for managing twists and deployments.\n *\n * The Twists tool provides twists with the ability to create twist IDs\n * and programmatically deploy twists.\n *\n * @example\n * ```typescript\n * class TwistBuilderTwist extends Twist {\n * build(build: ToolBuilder) {\n * return {\n * twists: build.get(Twists)\n * }\n * }\n *\n * async activate() {\n * const twistId = await this.tools.twists.create();\n * // Display twist ID to user\n * }\n * }\n * ```\n */\nexport abstract class Twists extends ITool {\n /**\n * Creates a new twist ID and grants access to people in the current priority.\n *\n * @returns Promise resolving to the generated twist ID\n * @throws When twist creation fails\n *\n * @example\n * ```typescript\n * const twistId = await twist.create();\n * console.log(`Your twist ID: ${twistId}`);\n * ```\n */\n abstract create(): Promise<string>;\n\n /**\n * Generates twist source code from a specification using AI.\n *\n * This method uses Claude AI to generate TypeScript source code and dependencies\n * from a markdown specification. The generated source is validated by attempting\n * to build it, with iterative error correction (up to 3 attempts).\n *\n * @param spec - Markdown specification describing the twist functionality\n * @returns Promise resolving to twist source (dependencies and files)\n * @throws When generation fails after maximum attempts\n *\n * @example\n * ```typescript\n * const source = await twist.generate(`\n * # Calendar Sync Twist\n *\n * This twist syncs Google Calendar events to Plot activities.\n *\n * ## Features\n * - Authenticate with Google\n * - Sync calendar events\n * - Create activities from events\n * `);\n *\n * // source.dependencies: { \"@plotday/sdk\": \"workspace:^\", ... }\n * // source.files: { \"index.ts\": \"export default class...\" }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract generate(spec: string): Promise<TwistSource>;\n\n /**\n * Deploys a twist programmatically.\n *\n * This method provides the same functionality as the plot deploy CLI\n * command, but can be called from within a twist. Accepts either:\n * - A pre-bundled module (JavaScript code)\n * - A source object (dependencies + files) which is built in a sandbox\n *\n * @param options - Deployment configuration\n * @param options.twistId - Twist ID for deployment\n * @param options.module - Pre-bundled twist module code (mutually exclusive with source)\n * @param options.source - Twist source code with dependencies (mutually exclusive with module)\n * @param options.environment - Target environment (defaults to \"personal\")\n * @param options.name - Optional twist name (required for first deploy)\n * @param options.description - Optional twist description (required for first deploy)\n * @param options.dryRun - If true, validates without deploying (returns errors if any)\n * @returns Promise resolving to deployment result with version and optional errors\n * @throws When deployment fails or user lacks access\n *\n * @example\n * ```typescript\n * // Deploy with a module\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * module: 'export default class MyTwist extends Twist {...}',\n * environment: 'personal',\n * name: 'My Twist',\n * description: 'Does something cool'\n * });\n * console.log(`Deployed version ${result.version}`);\n *\n * // Deploy with source\n * const source = await twist.generate(spec);\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * source,\n * environment: 'personal',\n * name: 'My Twist',\n * });\n *\n * // Validate with dryRun\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * source,\n * dryRun: true,\n * });\n * if (result.errors?.length) {\n * console.error('Build errors:', result.errors);\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract deploy(\n options: {\n twistId: string;\n environment?: \"personal\" | \"private\" | \"review\";\n name?: string;\n description?: string;\n dryRun?: boolean;\n } & (\n | {\n module: string;\n }\n | {\n source: TwistSource;\n }\n )\n ): Promise<{\n version: string;\n permissions: TwistPermissions;\n errors?: string[];\n }>;\n\n /**\n * Subscribes to logs from a twist.\n *\n * This method registers a callback to receive batches of logs from twist executions.\n * The callback will be invoked with an array of logs whenever new logs are captured\n * from the twist's console output.\n *\n * @param twistId - Twist ID (root ID) to watch logs for\n * @param callback - Callback token created via CallbackTool that will receive log batches\n * @returns Promise that resolves when the subscription is created\n * @throws When subscription fails\n *\n * @example\n * ```typescript\n * // Create twist and callback\n * const twistId = await this.twist.create();\n * const callback = await this.callback.create(\"onLogs\");\n *\n * // Subscribe to logs\n * await this.twist.watchLogs(twistId, callback);\n *\n * // Implement handler\n * async onLogs(logs: Log[]) {\n * for (const log of logs) {\n * console.log(`[${log.environment}] ${log.severity}: ${log.message}`);\n * }\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract watchLogs(twistId: string, callback: Callback): Promise<void>;\n}\n";
7
+ declare const _default: "import { type Callback, ITool } from \"..\";\n\n/**\n * Twist source code structure containing dependencies and source files.\n */\nexport interface TwistSource {\n /**\n * Package dependencies with version specifiers\n * @example { \"@plotday/twister\": \"workspace:^\", \"@plotday/tool-google-calendar\": \"^1.0.0\" }\n */\n dependencies: Record<string, string>;\n\n /**\n * Source files with their content\n * Must include \"index.ts\" as the entry point\n * @example { \"index.ts\": \"export default class MyTwist extends Twist {...}\" }\n */\n files: Record<string, string>;\n}\n\n/**\n * Represents a log entry from a twist execution.\n */\nexport type Log = {\n timestamp: Date;\n environment: \"personal\" | \"private\" | \"review\" | \"public\";\n severity: \"log\" | \"error\" | \"warn\" | \"info\";\n message: string;\n};\n\n/**\n * Twist permissions returned after deployment.\n * Nested structure mapping domains to entities to permission flags.\n *\n * Format: { domain: { entity: flags[] } }\n * - domain: Tool name (e.g., \"network\", \"plot\")\n * - entity: Domain-specific identifier (e.g., URL pattern, resource type)\n * - flags: Array of permission flags (\"read\", \"write\", \"update\", \"use\")\n *\n * @example\n * ```typescript\n * {\n * \"network\": {\n * \"https://api.example.com/*\": [\"use\"],\n * \"https://googleapis.com/*\": [\"use\"]\n * },\n * \"plot\": {\n * \"activity:mentioned\": [\"read\", \"write\", \"update\"],\n * \"priority\": [\"read\", \"write\", \"update\"]\n * }\n * }\n * ```\n */\nexport type TwistPermissions = Record<string, Record<string, string[]>>;\n\n/**\n * Built-in tool for managing twists and deployments.\n *\n * The Twists tool provides twists with the ability to create twist IDs\n * and programmatically deploy twists.\n *\n * @example\n * ```typescript\n * class TwistBuilderTwist extends Twist {\n * build(build: ToolBuilder) {\n * return {\n * twists: build.get(Twists)\n * }\n * }\n *\n * async activate() {\n * const twistId = await this.tools.twists.create();\n * // Display twist ID to user\n * }\n * }\n * ```\n */\nexport abstract class Twists extends ITool {\n /**\n * Creates a new twist ID and grants access to people in the current priority.\n *\n * @returns Promise resolving to the generated twist ID\n * @throws When twist creation fails\n *\n * @example\n * ```typescript\n * const twistId = await twist.create();\n * console.log(`Your twist ID: ${twistId}`);\n * ```\n */\n abstract create(): Promise<string>;\n\n /**\n * Generates twist source code from a specification using AI.\n *\n * This method uses Claude AI to generate TypeScript source code and dependencies\n * from a markdown specification. The generated source is validated by attempting\n * to build it, with iterative error correction (up to 3 attempts).\n *\n * @param spec - Markdown specification describing the twist functionality\n * @returns Promise resolving to twist source (dependencies and files)\n * @throws When generation fails after maximum attempts\n *\n * @example\n * ```typescript\n * const source = await twist.generate(`\n * # Calendar Sync Twist\n *\n * This twist syncs Google Calendar events to Plot activities.\n *\n * ## Features\n * - Authenticate with Google\n * - Sync calendar events\n * - Create activities from events\n * `);\n *\n * // source.dependencies: { \"@plotday/twister\": \"workspace:^\", ... }\n * // source.files: { \"index.ts\": \"export default class...\" }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract generate(spec: string): Promise<TwistSource>;\n\n /**\n * Deploys a twist programmatically.\n *\n * This method provides the same functionality as the plot deploy CLI\n * command, but can be called from within a twist. Accepts either:\n * - A pre-bundled module (JavaScript code)\n * - A source object (dependencies + files) which is built in a sandbox\n *\n * @param options - Deployment configuration\n * @param options.twistId - Twist ID for deployment\n * @param options.module - Pre-bundled twist module code (mutually exclusive with source)\n * @param options.source - Twist source code with dependencies (mutually exclusive with module)\n * @param options.environment - Target environment (defaults to \"personal\")\n * @param options.name - Optional twist name (required for first deploy)\n * @param options.description - Optional twist description (required for first deploy)\n * @param options.dryRun - If true, validates without deploying (returns errors if any)\n * @returns Promise resolving to deployment result with version and optional errors\n * @throws When deployment fails or user lacks access\n *\n * @example\n * ```typescript\n * // Deploy with a module\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * module: 'export default class MyTwist extends Twist {...}',\n * environment: 'personal',\n * name: 'My Twist',\n * description: 'Does something cool'\n * });\n * console.log(`Deployed version ${result.version}`);\n *\n * // Deploy with source\n * const source = await twist.generate(spec);\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * source,\n * environment: 'personal',\n * name: 'My Twist',\n * });\n *\n * // Validate with dryRun\n * const result = await twist.deploy({\n * twistId: 'abc-123-...',\n * source,\n * dryRun: true,\n * });\n * if (result.errors?.length) {\n * console.error('Build errors:', result.errors);\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract deploy(\n options: {\n twistId: string;\n environment?: \"personal\" | \"private\" | \"review\";\n name?: string;\n description?: string;\n dryRun?: boolean;\n } & (\n | {\n module: string;\n }\n | {\n source: TwistSource;\n }\n )\n ): Promise<{\n version: string;\n permissions: TwistPermissions;\n errors?: string[];\n }>;\n\n /**\n * Subscribes to logs from a twist.\n *\n * This method registers a callback to receive batches of logs from twist executions.\n * The callback will be invoked with an array of logs whenever new logs are captured\n * from the twist's console output.\n *\n * @param twistId - Twist ID (root ID) to watch logs for\n * @param callback - Callback token created via CallbackTool that will receive log batches\n * @returns Promise that resolves when the subscription is created\n * @throws When subscription fails\n *\n * @example\n * ```typescript\n * // Create twist and callback\n * const twistId = await this.twist.create();\n * const callback = await this.callback.create(\"onLogs\");\n *\n * // Subscribe to logs\n * await this.twist.watchLogs(twistId, callback);\n *\n * // Implement handler\n * async onLogs(logs: Log[]) {\n * for (const log of logs) {\n * console.log(`[${log.environment}] ${log.severity}: ${log.message}`);\n * }\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n abstract watchLogs(twistId: string, callback: Callback): Promise<void>;\n}\n";
8
8
  export default _default;
9
9
  //# sourceMappingURL=twists.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"twists.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/twists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,kuOAAkuO;AAAjvO,wBAAkvO"}
1
+ {"version":3,"file":"twists.d.ts","sourceRoot":"","sources":["../../../src/llm-docs/tools/twists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;wBAEY,0uOAA0uO;AAAzvO,wBAA0vO"}