@bubblelab/bubble-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +202 -0
- package/dist/bubble-bundle.d.ts +2021 -0
- package/dist/bubble-factory.d.ts +161 -0
- package/dist/bubble-factory.d.ts.map +1 -0
- package/dist/bubble-factory.js +426 -0
- package/dist/bubble-factory.js.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts +19 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.js +23 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts +15 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js +63 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js.map +1 -0
- package/dist/bubble-flow/sample/error-ts.d.ts +23 -0
- package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -0
- package/dist/bubble-flow/sample/error-ts.js +31 -0
- package/dist/bubble-flow/sample/error-ts.js.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts +10 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.js +13 -0
- package/dist/bubble-flow/sample/sanitytest.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts +19 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js +23 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts +10 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.js +18 -0
- package/dist/bubble-flow/sample/simple-webhook.js.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +29 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +150 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts +10 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.js +59 -0
- package/dist/bubble-flow/sample/slack-v0.1.js.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts +10 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.js +59 -0
- package/dist/bubble-flow/sample/slackagenttest.js.map +1 -0
- package/dist/bubble-trigger/index.d.ts +2 -0
- package/dist/bubble-trigger/index.d.ts.map +1 -0
- package/dist/bubble-trigger/index.js +2 -0
- package/dist/bubble-trigger/index.js.map +1 -0
- package/dist/bubble-trigger/types.d.ts +87 -0
- package/dist/bubble-trigger/types.d.ts.map +1 -0
- package/dist/bubble-trigger/types.js +14 -0
- package/dist/bubble-trigger/types.js.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts +428 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.js +881 -0
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -0
- package/dist/bubbles/service-bubble/gmail.d.ts +3073 -0
- package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/gmail.js +908 -0
- package/dist/bubbles/service-bubble/gmail.js.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts +3377 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.js +527 -0
- package/dist/bubbles/service-bubble/google-calendar.js.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts +1152 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.js +943 -0
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts +1811 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.js +904 -0
- package/dist/bubbles/service-bubble/google-sheets.js.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts +74 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.js +67 -0
- package/dist/bubbles/service-bubble/hello-world.js.map +1 -0
- package/dist/bubbles/service-bubble/http.d.ts +134 -0
- package/dist/bubbles/service-bubble/http.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/http.js +184 -0
- package/dist/bubbles/service-bubble/http.js.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts +180 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.js +448 -0
- package/dist/bubbles/service-bubble/postgresql.js.map +1 -0
- package/dist/bubbles/service-bubble/resend.d.ts +301 -0
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/resend.js +253 -0
- package/dist/bubbles/service-bubble/resend.js.map +1 -0
- package/dist/bubbles/service-bubble/slack.d.ts +5869 -0
- package/dist/bubbles/service-bubble/slack.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/slack.js +1536 -0
- package/dist/bubbles/service-bubble/slack.js.map +1 -0
- package/dist/bubbles/service-bubble/storage.d.ts +571 -0
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/storage.js +504 -0
- package/dist/bubbles/service-bubble/storage.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +308 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +285 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +416 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js +570 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +99 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +645 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +112 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js +82 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +413 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +327 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +122 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js +343 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +131 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js +147 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts +257 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.js +238 -0
- package/dist/bubbles/tool-bubble/tool-template.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts +8 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js +65 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts +125 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js +169 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +218 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js +255 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js +175 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +228 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js +214 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js +155 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +114 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +777 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts +97 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js +327 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +303 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js +297 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts +157 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js +310 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +543 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js +628 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +679 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js +604 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +1011 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +841 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +883 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +781 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +300 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +508 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +731 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +690 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +401 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +382 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts +144 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js +124 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/BubbleLogger.d.ts +146 -0
- package/dist/logging/BubbleLogger.d.ts.map +1 -0
- package/dist/logging/BubbleLogger.js +472 -0
- package/dist/logging/BubbleLogger.js.map +1 -0
- package/dist/logging/StreamingBubbleLogger.d.ts +85 -0
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -0
- package/dist/logging/StreamingBubbleLogger.js +340 -0
- package/dist/logging/StreamingBubbleLogger.js.map +1 -0
- package/dist/types/ai-models.d.ts +4 -0
- package/dist/types/ai-models.d.ts.map +1 -0
- package/dist/types/ai-models.js +14 -0
- package/dist/types/ai-models.js.map +1 -0
- package/dist/types/available-tools.d.ts +4 -0
- package/dist/types/available-tools.d.ts.map +1 -0
- package/dist/types/available-tools.js +19 -0
- package/dist/types/available-tools.js.map +1 -0
- package/dist/types/base-bubble-class.d.ts +47 -0
- package/dist/types/base-bubble-class.d.ts.map +1 -0
- package/dist/types/base-bubble-class.js +212 -0
- package/dist/types/base-bubble-class.js.map +1 -0
- package/dist/types/bubble-errors.d.ts +44 -0
- package/dist/types/bubble-errors.d.ts.map +1 -0
- package/dist/types/bubble-errors.js +51 -0
- package/dist/types/bubble-errors.js.map +1 -0
- package/dist/types/bubble.d.ts +73 -0
- package/dist/types/bubble.d.ts.map +1 -0
- package/dist/types/bubble.js +2 -0
- package/dist/types/bubble.js.map +1 -0
- package/dist/types/credentials.d.ts +6 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +6 -0
- package/dist/types/credentials.js.map +1 -0
- package/dist/types/service-bubble-class.d.ts +31 -0
- package/dist/types/service-bubble-class.d.ts.map +1 -0
- package/dist/types/service-bubble-class.js +36 -0
- package/dist/types/service-bubble-class.js.map +1 -0
- package/dist/types/streaming-events.d.ts +18 -0
- package/dist/types/streaming-events.d.ts.map +1 -0
- package/dist/types/streaming-events.js +5 -0
- package/dist/types/streaming-events.js.map +1 -0
- package/dist/types/tool-bubble-class.d.ts +19 -0
- package/dist/types/tool-bubble-class.d.ts.map +1 -0
- package/dist/types/tool-bubble-class.js +48 -0
- package/dist/types/tool-bubble-class.js.map +1 -0
- package/dist/types/workflow-bubble-class.d.ts +25 -0
- package/dist/types/workflow-bubble-class.d.ts.map +1 -0
- package/dist/types/workflow-bubble-class.js +30 -0
- package/dist/types/workflow-bubble-class.js.map +1 -0
- package/dist/utils/bubbleflow-parser.d.ts +32 -0
- package/dist/utils/bubbleflow-parser.d.ts.map +1 -0
- package/dist/utils/bubbleflow-parser.js +332 -0
- package/dist/utils/bubbleflow-parser.js.map +1 -0
- package/dist/utils/bubbleflow-validation.d.ts +9 -0
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -0
- package/dist/utils/bubbleflow-validation.js +116 -0
- package/dist/utils/bubbleflow-validation.js.map +1 -0
- package/dist/utils/json-parsing.d.ts +20 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +394 -0
- package/dist/utils/json-parsing.js.map +1 -0
- package/dist/utils/mock-data-generator.d.ts +43 -0
- package/dist/utils/mock-data-generator.d.ts.map +1 -0
- package/dist/utils/mock-data-generator.js +312 -0
- package/dist/utils/mock-data-generator.js.map +1 -0
- package/dist/utils/param-helper.d.ts +2 -0
- package/dist/utils/param-helper.d.ts.map +1 -0
- package/dist/utils/param-helper.js +5 -0
- package/dist/utils/param-helper.js.map +1 -0
- package/dist/utils/source-bubble-parser.d.ts +31 -0
- package/dist/utils/source-bubble-parser.d.ts.map +1 -0
- package/dist/utils/source-bubble-parser.js +231 -0
- package/dist/utils/source-bubble-parser.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOOL BUBBLE TEMPLATE
|
|
3
|
+
*
|
|
4
|
+
* This template provides a starting point for creating new tool bubbles in the NodeX system.
|
|
5
|
+
* Tool bubbles are specialized bubbles that provide utility functions for other bubbles,
|
|
6
|
+
* particularly useful for AI agents that need to perform specific operations.
|
|
7
|
+
*
|
|
8
|
+
* NEW FEATURES (v2):
|
|
9
|
+
* - Automatic credential injection via base class
|
|
10
|
+
* - Config parameter support for runtime configuration
|
|
11
|
+
* - No need to implement toAgentTool() - handled automatically
|
|
12
|
+
* - IMPORTANT: credentials and config are HIDDEN from AI agents
|
|
13
|
+
* - AI agents only see your actual tool parameters (inputData, options, etc.)
|
|
14
|
+
* - credentials and config are injected at runtime and available in performAction()
|
|
15
|
+
* - This keeps the tool interface clean for AI while providing access to secrets
|
|
16
|
+
*
|
|
17
|
+
* To create a new tool bubble:
|
|
18
|
+
* 1. Copy this template and rename it (e.g., my-custom-tool.ts)
|
|
19
|
+
* 2. Replace all instances of "MyCustomTool" with your tool name
|
|
20
|
+
* 3. Update the schema to define your input parameters
|
|
21
|
+
* 4. Add credentials/config fields if needed (see examples below)
|
|
22
|
+
* 5. Update the result schema to define your output structure
|
|
23
|
+
* 6. Implement the performAction method with your tool logic
|
|
24
|
+
* 7. Update all static metadata (bubbleName, descriptions, etc.)
|
|
25
|
+
* 8. Register your tool in the BubbleFactory
|
|
26
|
+
*/
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
import { ToolBubble } from '../../types/tool-bubble-class.js';
|
|
29
|
+
import type { BubbleContext } from '../../types/bubble.js';
|
|
30
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
31
|
+
/**
|
|
32
|
+
* Define the parameters schema using Zod
|
|
33
|
+
* This schema validates and types the input parameters for your tool
|
|
34
|
+
*
|
|
35
|
+
* Common patterns:
|
|
36
|
+
* - Required string: z.string().min(1, 'Field is required')
|
|
37
|
+
* - Optional string: z.string().optional()
|
|
38
|
+
* - Number with range: z.number().min(0).max(100)
|
|
39
|
+
* - Enum: z.enum(['option1', 'option2'])
|
|
40
|
+
* - Array: z.array(z.string())
|
|
41
|
+
* - Object: z.object({ key: z.string() })
|
|
42
|
+
* - Credentials: z.record(z.nativeEnum(CredentialType), z.string()).optional()
|
|
43
|
+
*/
|
|
44
|
+
declare const MyCustomToolParamsSchema: z.ZodObject<{
|
|
45
|
+
inputData: z.ZodString;
|
|
46
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
includeDetails: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
maxResults: z.ZodDefault<z.ZodNumber>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
maxResults: number;
|
|
51
|
+
includeDetails: boolean;
|
|
52
|
+
}, {
|
|
53
|
+
maxResults?: number | undefined;
|
|
54
|
+
includeDetails?: boolean | undefined;
|
|
55
|
+
}>>;
|
|
56
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
57
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
+
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
inputData: string;
|
|
60
|
+
options?: {
|
|
61
|
+
maxResults: number;
|
|
62
|
+
includeDetails: boolean;
|
|
63
|
+
} | undefined;
|
|
64
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
65
|
+
config?: Record<string, unknown> | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
inputData: string;
|
|
68
|
+
options?: {
|
|
69
|
+
maxResults?: number | undefined;
|
|
70
|
+
includeDetails?: boolean | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
73
|
+
config?: Record<string, unknown> | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Type definitions derived from schemas
|
|
77
|
+
* These provide TypeScript types for compile-time type safety
|
|
78
|
+
*/
|
|
79
|
+
type MyCustomToolParamsInput = z.input<typeof MyCustomToolParamsSchema>;
|
|
80
|
+
type MyCustomToolParams = z.output<typeof MyCustomToolParamsSchema>;
|
|
81
|
+
type MyCustomToolResult = z.output<typeof MyCustomToolResultSchema>;
|
|
82
|
+
/**
|
|
83
|
+
* Define the result schema
|
|
84
|
+
* This schema defines what your tool returns
|
|
85
|
+
* Always include success and error fields for consistent error handling
|
|
86
|
+
*/
|
|
87
|
+
declare const MyCustomToolResultSchema: z.ZodObject<{
|
|
88
|
+
processedData: z.ZodString;
|
|
89
|
+
metadata: z.ZodObject<{
|
|
90
|
+
processedAt: z.ZodString;
|
|
91
|
+
itemsProcessed: z.ZodNumber;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
processedAt: string;
|
|
94
|
+
itemsProcessed: number;
|
|
95
|
+
}, {
|
|
96
|
+
processedAt: string;
|
|
97
|
+
itemsProcessed: number;
|
|
98
|
+
}>;
|
|
99
|
+
success: z.ZodBoolean;
|
|
100
|
+
error: z.ZodString;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
success: boolean;
|
|
103
|
+
error: string;
|
|
104
|
+
metadata: {
|
|
105
|
+
processedAt: string;
|
|
106
|
+
itemsProcessed: number;
|
|
107
|
+
};
|
|
108
|
+
processedData: string;
|
|
109
|
+
}, {
|
|
110
|
+
success: boolean;
|
|
111
|
+
error: string;
|
|
112
|
+
metadata: {
|
|
113
|
+
processedAt: string;
|
|
114
|
+
itemsProcessed: number;
|
|
115
|
+
};
|
|
116
|
+
processedData: string;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Main tool class implementation
|
|
120
|
+
* Extends ToolBubble with your parameter and result types
|
|
121
|
+
*/
|
|
122
|
+
export declare class MyCustomTool extends ToolBubble<MyCustomToolParams, MyCustomToolResult> {
|
|
123
|
+
/**
|
|
124
|
+
* REQUIRED STATIC METADATA
|
|
125
|
+
* These fields are used by the BubbleFactory and AI agents
|
|
126
|
+
*/
|
|
127
|
+
static readonly type: "tool";
|
|
128
|
+
static readonly bubbleName = "my-custom-tool";
|
|
129
|
+
static readonly schema: z.ZodObject<{
|
|
130
|
+
inputData: z.ZodString;
|
|
131
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
includeDetails: z.ZodDefault<z.ZodBoolean>;
|
|
133
|
+
maxResults: z.ZodDefault<z.ZodNumber>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
maxResults: number;
|
|
136
|
+
includeDetails: boolean;
|
|
137
|
+
}, {
|
|
138
|
+
maxResults?: number | undefined;
|
|
139
|
+
includeDetails?: boolean | undefined;
|
|
140
|
+
}>>;
|
|
141
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
142
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
inputData: string;
|
|
145
|
+
options?: {
|
|
146
|
+
maxResults: number;
|
|
147
|
+
includeDetails: boolean;
|
|
148
|
+
} | undefined;
|
|
149
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
150
|
+
config?: Record<string, unknown> | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
inputData: string;
|
|
153
|
+
options?: {
|
|
154
|
+
maxResults?: number | undefined;
|
|
155
|
+
includeDetails?: boolean | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
158
|
+
config?: Record<string, unknown> | undefined;
|
|
159
|
+
}>;
|
|
160
|
+
static readonly resultSchema: z.ZodObject<{
|
|
161
|
+
processedData: z.ZodString;
|
|
162
|
+
metadata: z.ZodObject<{
|
|
163
|
+
processedAt: z.ZodString;
|
|
164
|
+
itemsProcessed: z.ZodNumber;
|
|
165
|
+
}, "strip", z.ZodTypeAny, {
|
|
166
|
+
processedAt: string;
|
|
167
|
+
itemsProcessed: number;
|
|
168
|
+
}, {
|
|
169
|
+
processedAt: string;
|
|
170
|
+
itemsProcessed: number;
|
|
171
|
+
}>;
|
|
172
|
+
success: z.ZodBoolean;
|
|
173
|
+
error: z.ZodString;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
success: boolean;
|
|
176
|
+
error: string;
|
|
177
|
+
metadata: {
|
|
178
|
+
processedAt: string;
|
|
179
|
+
itemsProcessed: number;
|
|
180
|
+
};
|
|
181
|
+
processedData: string;
|
|
182
|
+
}, {
|
|
183
|
+
success: boolean;
|
|
184
|
+
error: string;
|
|
185
|
+
metadata: {
|
|
186
|
+
processedAt: string;
|
|
187
|
+
itemsProcessed: number;
|
|
188
|
+
};
|
|
189
|
+
processedData: string;
|
|
190
|
+
}>;
|
|
191
|
+
static readonly shortDescription = "Brief description of what your tool does";
|
|
192
|
+
static readonly longDescription = "\n A comprehensive description of your tool bubble.\n \n What it does:\n - Main functionality point 1\n - Main functionality point 2\n \n How it works:\n - Implementation detail 1\n - Implementation detail 2\n \n Use cases:\n - When an AI agent needs to perform X\n - When processing Y type of data\n - When integrating with Z system\n ";
|
|
193
|
+
static readonly alias = "custom";
|
|
194
|
+
/**
|
|
195
|
+
* Constructor
|
|
196
|
+
* Initialize your tool with parameters and optional context
|
|
197
|
+
*/
|
|
198
|
+
constructor(params: MyCustomToolParamsInput, context?: BubbleContext);
|
|
199
|
+
/**
|
|
200
|
+
* Main action method - this is where your tool logic goes
|
|
201
|
+
* This method is called when the tool is executed
|
|
202
|
+
*
|
|
203
|
+
* @param context - Optional bubble context (contains metadata, credentials, etc.)
|
|
204
|
+
* @returns Promise with your result object
|
|
205
|
+
*/
|
|
206
|
+
performAction(context?: BubbleContext): Promise<MyCustomToolResult>;
|
|
207
|
+
/**
|
|
208
|
+
* PRIVATE HELPER METHODS
|
|
209
|
+
* Add your internal logic methods here
|
|
210
|
+
*/
|
|
211
|
+
private processData;
|
|
212
|
+
}
|
|
213
|
+
export {};
|
|
214
|
+
/**
|
|
215
|
+
* REGISTRATION AND USAGE
|
|
216
|
+
*
|
|
217
|
+
* 1. Register your tool in the BubbleFactory:
|
|
218
|
+
* ```typescript
|
|
219
|
+
* import { MyCustomTool } from './bubbles/tool-bubble/my-custom-tool.js';
|
|
220
|
+
*
|
|
221
|
+
* // In registerDefaults() method:
|
|
222
|
+
* this.register('my-custom-tool', MyCustomTool as BubbleClassWithMetadata);
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* 2. Direct usage:
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const tool = new MyCustomTool({
|
|
228
|
+
* inputData: 'some data',
|
|
229
|
+
* options: { includeDetails: true },
|
|
230
|
+
* credentials: { DATABASE_CRED: 'connection_string' }
|
|
231
|
+
* });
|
|
232
|
+
* const result = await tool.action();
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* 3. AI Agent usage:
|
|
236
|
+
* ```typescript
|
|
237
|
+
* // When AI agent calls your tool, it ONLY sees these parameters:
|
|
238
|
+
* {
|
|
239
|
+
* "inputData": "some data",
|
|
240
|
+
* "options": { "includeDetails": true }
|
|
241
|
+
* }
|
|
242
|
+
*
|
|
243
|
+
* // The AI agent configuration provides credentials/config separately:
|
|
244
|
+
* tools: [{
|
|
245
|
+
* name: 'my-custom-tool',
|
|
246
|
+
* credentials: { DATABASE_CRED: 'connection_string' }, // Runtime injection
|
|
247
|
+
* config: { someOption: true } // Runtime injection
|
|
248
|
+
* }]
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* IMPORTANT SECURITY FEATURE:
|
|
252
|
+
* - AI agents NEVER see credentials or config in the tool schema
|
|
253
|
+
* - The base ToolBubble class automatically strips these from the AI-visible schema
|
|
254
|
+
* - Runtime injects credentials/config before calling performAction()
|
|
255
|
+
* - This prevents AI from accidentally exposing or misusing secrets
|
|
256
|
+
*/
|
|
257
|
+
//# sourceMappingURL=tool-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-template.d.ts","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/tool-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D;;;;;;;;;;;;GAYG;AACH,QAA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TEMPLATE
|
|
3
|
+
*
|
|
4
|
+
* This template provides a starting point for creating new tool bubbles in the NodeX system.
|
|
5
|
+
* Tool bubbles are specialized bubbles that provide utility functions for other bubbles,
|
|
6
|
+
* particularly useful for AI agents that need to perform specific operations.
|
|
7
|
+
*
|
|
8
|
+
* NEW FEATURES (v2):
|
|
9
|
+
* - Automatic credential injection via base class
|
|
10
|
+
* - Config parameter support for runtime configuration
|
|
11
|
+
* - No need to implement toAgentTool() - handled automatically
|
|
12
|
+
* - IMPORTANT: credentials and config are HIDDEN from AI agents
|
|
13
|
+
* - AI agents only see your actual tool parameters (inputData, options, etc.)
|
|
14
|
+
* - credentials and config are injected at runtime and available in performAction()
|
|
15
|
+
* - This keeps the tool interface clean for AI while providing access to secrets
|
|
16
|
+
*
|
|
17
|
+
* To create a new tool bubble:
|
|
18
|
+
* 1. Copy this template and rename it (e.g., my-custom-tool.ts)
|
|
19
|
+
* 2. Replace all instances of "MyCustomTool" with your tool name
|
|
20
|
+
* 3. Update the schema to define your input parameters
|
|
21
|
+
* 4. Add credentials/config fields if needed (see examples below)
|
|
22
|
+
* 5. Update the result schema to define your output structure
|
|
23
|
+
* 6. Implement the performAction method with your tool logic
|
|
24
|
+
* 7. Update all static metadata (bubbleName, descriptions, etc.)
|
|
25
|
+
* 8. Register your tool in the BubbleFactory
|
|
26
|
+
*/
|
|
27
|
+
import { z } from 'zod';
|
|
28
|
+
import { ToolBubble } from '../../types/tool-bubble-class.js';
|
|
29
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
30
|
+
// Import BubbleFactory if you need to access other bubbles
|
|
31
|
+
// import { BubbleFactory } from '../../bubble-factory.js';
|
|
32
|
+
/**
|
|
33
|
+
* Define the parameters schema using Zod
|
|
34
|
+
* This schema validates and types the input parameters for your tool
|
|
35
|
+
*
|
|
36
|
+
* Common patterns:
|
|
37
|
+
* - Required string: z.string().min(1, 'Field is required')
|
|
38
|
+
* - Optional string: z.string().optional()
|
|
39
|
+
* - Number with range: z.number().min(0).max(100)
|
|
40
|
+
* - Enum: z.enum(['option1', 'option2'])
|
|
41
|
+
* - Array: z.array(z.string())
|
|
42
|
+
* - Object: z.object({ key: z.string() })
|
|
43
|
+
* - Credentials: z.record(z.nativeEnum(CredentialType), z.string()).optional()
|
|
44
|
+
*/
|
|
45
|
+
const MyCustomToolParamsSchema = z.object({
|
|
46
|
+
// Example required parameter
|
|
47
|
+
inputData: z.string().min(1, 'Input data is required'),
|
|
48
|
+
// Example optional parameter with description
|
|
49
|
+
options: z
|
|
50
|
+
.object({
|
|
51
|
+
includeDetails: z.boolean().default(false),
|
|
52
|
+
maxResults: z.number().min(1).max(100).default(10),
|
|
53
|
+
})
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('Configuration options for the tool'),
|
|
56
|
+
// IMPORTANT: These fields are AUTOMATICALLY REMOVED from AI agent schema
|
|
57
|
+
// AI agents will NOT see these parameters - they're injected at runtime
|
|
58
|
+
// Credentials (if your tool needs API keys or other secrets)
|
|
59
|
+
credentials: z
|
|
60
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('Database credentials (HIDDEN from AI - injected at runtime)'),
|
|
63
|
+
// Optional configuration passed from the agent system
|
|
64
|
+
config: z
|
|
65
|
+
.record(z.string(), z.unknown())
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('Configuration for the tool bubble (HIDDEN from AI - injected at runtime)'),
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Define the result schema
|
|
71
|
+
* This schema defines what your tool returns
|
|
72
|
+
* Always include success and error fields for consistent error handling
|
|
73
|
+
*/
|
|
74
|
+
const MyCustomToolResultSchema = z.object({
|
|
75
|
+
// Your custom result fields
|
|
76
|
+
processedData: z.string(),
|
|
77
|
+
metadata: z.object({
|
|
78
|
+
processedAt: z.string(),
|
|
79
|
+
itemsProcessed: z.number(),
|
|
80
|
+
}),
|
|
81
|
+
// Standard result fields (always include these)
|
|
82
|
+
success: z.boolean(),
|
|
83
|
+
error: z.string(),
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Main tool class implementation
|
|
87
|
+
* Extends ToolBubble with your parameter and result types
|
|
88
|
+
*/
|
|
89
|
+
export class MyCustomTool extends ToolBubble {
|
|
90
|
+
/**
|
|
91
|
+
* REQUIRED STATIC METADATA
|
|
92
|
+
* These fields are used by the BubbleFactory and AI agents
|
|
93
|
+
*/
|
|
94
|
+
// Bubble type - always 'tool' for tool bubbles
|
|
95
|
+
static type = 'tool';
|
|
96
|
+
// Unique identifier for your tool (use kebab-case)
|
|
97
|
+
static bubbleName = 'my-custom-tool';
|
|
98
|
+
// Schemas for validation
|
|
99
|
+
static schema = MyCustomToolParamsSchema;
|
|
100
|
+
static resultSchema = MyCustomToolResultSchema;
|
|
101
|
+
// Short description (one line, used in lists and summaries)
|
|
102
|
+
static shortDescription = 'Brief description of what your tool does';
|
|
103
|
+
// Long description with detailed information
|
|
104
|
+
static longDescription = `
|
|
105
|
+
A comprehensive description of your tool bubble.
|
|
106
|
+
|
|
107
|
+
What it does:
|
|
108
|
+
- Main functionality point 1
|
|
109
|
+
- Main functionality point 2
|
|
110
|
+
|
|
111
|
+
How it works:
|
|
112
|
+
- Implementation detail 1
|
|
113
|
+
- Implementation detail 2
|
|
114
|
+
|
|
115
|
+
Use cases:
|
|
116
|
+
- When an AI agent needs to perform X
|
|
117
|
+
- When processing Y type of data
|
|
118
|
+
- When integrating with Z system
|
|
119
|
+
`;
|
|
120
|
+
// Optional: Short alias for the tool (e.g., 'custom' instead of 'my-custom-tool')
|
|
121
|
+
static alias = 'custom';
|
|
122
|
+
// Optional: Define which credentials this tool can use
|
|
123
|
+
// static readonly credentialOptions = [CredentialType.OPENAI_CRED];
|
|
124
|
+
/**
|
|
125
|
+
* Constructor
|
|
126
|
+
* Initialize your tool with parameters and optional context
|
|
127
|
+
*/
|
|
128
|
+
constructor(params, context) {
|
|
129
|
+
super(params, context);
|
|
130
|
+
// Initialize any instance variables here
|
|
131
|
+
// Example: this.factory = new BubbleFactory();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Main action method - this is where your tool logic goes
|
|
135
|
+
* This method is called when the tool is executed
|
|
136
|
+
*
|
|
137
|
+
* @param context - Optional bubble context (contains metadata, credentials, etc.)
|
|
138
|
+
* @returns Promise with your result object
|
|
139
|
+
*/
|
|
140
|
+
async performAction(context) {
|
|
141
|
+
// Context is available but often not used in tools
|
|
142
|
+
void context;
|
|
143
|
+
try {
|
|
144
|
+
// Extract parameters
|
|
145
|
+
// NOTE: credentials and config are automatically injected by the base class
|
|
146
|
+
// AI agents only provided inputData and options - never see credentials/config
|
|
147
|
+
const { inputData, options } = this.params;
|
|
148
|
+
// Access credentials if needed (injected by runtime, not provided by AI)
|
|
149
|
+
// const dbConnection = credentials?.DATABASE_CRED;
|
|
150
|
+
// const apiKey = credentials?.OPENAI_CRED;
|
|
151
|
+
// Access config if needed (injected by runtime, not provided by AI)
|
|
152
|
+
// const customSetting = config?.customSetting;
|
|
153
|
+
// Implement your tool logic here
|
|
154
|
+
// Example: Process the input data
|
|
155
|
+
const processedData = await this.processData(inputData, options);
|
|
156
|
+
// Return successful result
|
|
157
|
+
return {
|
|
158
|
+
processedData,
|
|
159
|
+
metadata: {
|
|
160
|
+
processedAt: new Date().toISOString(),
|
|
161
|
+
itemsProcessed: 1,
|
|
162
|
+
},
|
|
163
|
+
success: true,
|
|
164
|
+
error: '',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
// Handle errors gracefully
|
|
169
|
+
return {
|
|
170
|
+
processedData: '',
|
|
171
|
+
metadata: {
|
|
172
|
+
processedAt: new Date().toISOString(),
|
|
173
|
+
itemsProcessed: 0,
|
|
174
|
+
},
|
|
175
|
+
success: false,
|
|
176
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Note: The toAgentTool() static method is now implemented in the base ToolBubble class
|
|
181
|
+
// It automatically handles credential and config injection
|
|
182
|
+
// You don't need to implement it unless you need custom behavior
|
|
183
|
+
/**
|
|
184
|
+
* PRIVATE HELPER METHODS
|
|
185
|
+
* Add your internal logic methods here
|
|
186
|
+
*/
|
|
187
|
+
async processData(data, options) {
|
|
188
|
+
// Example processing logic
|
|
189
|
+
const includeDetails = options?.includeDetails ?? false;
|
|
190
|
+
const maxResults = options?.maxResults ?? 10;
|
|
191
|
+
// Your actual processing logic here
|
|
192
|
+
return `Processed: ${data} (details: ${includeDetails}, max: ${maxResults})`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* REGISTRATION AND USAGE
|
|
197
|
+
*
|
|
198
|
+
* 1. Register your tool in the BubbleFactory:
|
|
199
|
+
* ```typescript
|
|
200
|
+
* import { MyCustomTool } from './bubbles/tool-bubble/my-custom-tool.js';
|
|
201
|
+
*
|
|
202
|
+
* // In registerDefaults() method:
|
|
203
|
+
* this.register('my-custom-tool', MyCustomTool as BubbleClassWithMetadata);
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* 2. Direct usage:
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const tool = new MyCustomTool({
|
|
209
|
+
* inputData: 'some data',
|
|
210
|
+
* options: { includeDetails: true },
|
|
211
|
+
* credentials: { DATABASE_CRED: 'connection_string' }
|
|
212
|
+
* });
|
|
213
|
+
* const result = await tool.action();
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* 3. AI Agent usage:
|
|
217
|
+
* ```typescript
|
|
218
|
+
* // When AI agent calls your tool, it ONLY sees these parameters:
|
|
219
|
+
* {
|
|
220
|
+
* "inputData": "some data",
|
|
221
|
+
* "options": { "includeDetails": true }
|
|
222
|
+
* }
|
|
223
|
+
*
|
|
224
|
+
* // The AI agent configuration provides credentials/config separately:
|
|
225
|
+
* tools: [{
|
|
226
|
+
* name: 'my-custom-tool',
|
|
227
|
+
* credentials: { DATABASE_CRED: 'connection_string' }, // Runtime injection
|
|
228
|
+
* config: { someOption: true } // Runtime injection
|
|
229
|
+
* }]
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* IMPORTANT SECURITY FEATURE:
|
|
233
|
+
* - AI agents NEVER see credentials or config in the tool schema
|
|
234
|
+
* - The base ToolBubble class automatically strips these from the AI-visible schema
|
|
235
|
+
* - Runtime injects credentials/config before calling performAction()
|
|
236
|
+
* - This prevents AI from accidentally exposing or misusing secrets
|
|
237
|
+
*/
|
|
238
|
+
//# sourceMappingURL=tool-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-template.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/tool-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,2DAA2D;AAC3D,2DAA2D;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,6BAA6B;IAC7B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;IAEtD,8CAA8C;IAC9C,OAAO,EAAE,CAAC;SACP,MAAM,CAAC;QACN,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;KACnD,CAAC;SACD,QAAQ,EAAE;SACV,QAAQ,CAAC,oCAAoC,CAAC;IAEjD,y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AK,CAAC,WAAW,CACvB,IAAY,EACZ,OAAyD;QAEzD,2BAA2B;QAC3B,MAAM,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,KAAK,CAAC;QACxD,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;QAE7C,oCAAoC;QACpC,OAAO,cAAc,IAAI,cAAc,cAAc,UAAU,UAAU,GAAG,CAAC;IAC/E,CAAC;;AAUH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EXAMPLE: Virtual File Editor Tool with Hidden Parameters
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how the VirtualFileEditorTool now works with
|
|
5
|
+
* codeLines hidden from AI agents and stored in the config field.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=virtual-file-editor-example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-file-editor-example.d.ts","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/virtual-file-editor-example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EXAMPLE: Virtual File Editor Tool with Hidden Parameters
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates how the VirtualFileEditorTool now works with
|
|
5
|
+
* codeLines hidden from AI agents and stored in the config field.
|
|
6
|
+
*/
|
|
7
|
+
import { VirtualFileEditorTool } from './virtual-file-editor.tool.js';
|
|
8
|
+
// Example 1: AI Agent sees clean interface
|
|
9
|
+
console.log('=== AI Agent Interface ===');
|
|
10
|
+
console.log('AI agents only see these parameters:');
|
|
11
|
+
console.log('- edits: Array of edit operations');
|
|
12
|
+
console.log('- (credentials and config are hidden)');
|
|
13
|
+
// Example 2: How the tool is used internally
|
|
14
|
+
console.log('\n=== Internal Usage ===');
|
|
15
|
+
// First call - initialize with empty file
|
|
16
|
+
const tool1 = new VirtualFileEditorTool({
|
|
17
|
+
edits: [
|
|
18
|
+
{
|
|
19
|
+
op: 'insert',
|
|
20
|
+
startLine: 1,
|
|
21
|
+
text: 'function hello() {\n console.log("Hello World");\n}',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
config: {
|
|
25
|
+
codeLines: [], // Hidden from AI - starts with empty file
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const result1 = await tool1.performAction();
|
|
29
|
+
console.log('First call result:');
|
|
30
|
+
console.log('Code lines:', result1.codeLines);
|
|
31
|
+
console.log('Success:', result1.success);
|
|
32
|
+
// Second call - AI agent only provides edits, codeLines maintained in config
|
|
33
|
+
const tool2 = new VirtualFileEditorTool({
|
|
34
|
+
edits: [
|
|
35
|
+
{
|
|
36
|
+
op: 'insert',
|
|
37
|
+
startLine: 2,
|
|
38
|
+
text: ' // Added comment',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
config: {
|
|
42
|
+
codeLines: result1.codeLines, // Previous state maintained
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const result2 = await tool2.performAction();
|
|
46
|
+
console.log('\nSecond call result:');
|
|
47
|
+
console.log('Code lines:', result2.codeLines);
|
|
48
|
+
console.log('Success:', result2.success);
|
|
49
|
+
// Example 3: How AI agents would use this tool
|
|
50
|
+
console.log('\n=== AI Agent Usage ===');
|
|
51
|
+
console.log('AI agents would call the tool like this:');
|
|
52
|
+
console.log(`
|
|
53
|
+
{
|
|
54
|
+
"edits": [
|
|
55
|
+
{
|
|
56
|
+
"op": "insert",
|
|
57
|
+
"startLine": 1,
|
|
58
|
+
"text": "// New comment"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
`);
|
|
63
|
+
console.log('The codeLines parameter is completely hidden from AI agents!');
|
|
64
|
+
console.log('The tool maintains state through the config field internally.');
|
|
65
|
+
//# sourceMappingURL=virtual-file-editor-example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-file-editor-example.js","sourceRoot":"","sources":["../../../src/bubbles/tool-bubble/virtual-file-editor-example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,2CAA2C;AAC3C,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC1C,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AACpD,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;AACjD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAErD,6CAA6C;AAC7C,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAExC,0CAA0C;AAC1C,MAAM,KAAK,GAAG,IAAI,qBAAqB,CAAC;IACtC,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,sDAAsD;SAC7D;KACF;IACD,MAAM,EAAE;QACN,SAAS,EAAE,EAAE,EAAE,0CAA0C;KAC1D;CACF,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,aAAa,EAAE,CAAC;AAC5C,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;AAC9C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzC,6EAA6E;AAC7E,MAAM,KAAK,GAAG,IAAI,qBAAqB,CAAC;IACtC,KAAK,EAAE;QACL;YACE,EAAE,EAAE,QAAQ;YACZ,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,oBAAoB;SAC3B;KACF;IACD,MAAM,EAAE;QACN,SAAS,EAAE,OAAO,CAAC,SAAS,E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