beddel 1.0.6 → 1.0.8

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 (58) hide show
  1. package/README.md +79 -1
  2. package/dist/agents/{business-analyzer.yaml → google-business/business-analyzer.yaml} +41 -27
  3. package/dist/agents/index.d.ts +24 -3
  4. package/dist/agents/index.d.ts.map +1 -1
  5. package/dist/agents/index.js +56 -11
  6. package/dist/agents/marketing/newsletter-signup.yaml +106 -0
  7. package/dist/agents/observability/observability-demo-stream.yaml +48 -0
  8. package/dist/agents/observability/observability-demo.yaml +67 -0
  9. package/dist/client.d.ts +3 -2
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +1 -1
  12. package/dist/core/workflow.d.ts +12 -0
  13. package/dist/core/workflow.d.ts.map +1 -1
  14. package/dist/core/workflow.js +104 -15
  15. package/dist/primitives/chat.d.ts.map +1 -1
  16. package/dist/primitives/chat.js +44 -1
  17. package/dist/server/handler.js +4 -4
  18. package/dist/types/index.d.ts +34 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/dist/types/observability.d.ts +59 -0
  21. package/dist/types/observability.d.ts.map +1 -0
  22. package/dist/types/observability.js +5 -0
  23. package/docs/architecture/api-reference.md +281 -11
  24. package/docs/architecture/components.md +24 -12
  25. package/docs/architecture/core-workflows.md +1 -0
  26. package/docs/architecture/observability.md +293 -0
  27. package/docs/architecture/source-tree.md +47 -21
  28. package/docs/prd/requirements.md +1 -1
  29. package/package.json +9 -9
  30. package/src/agents/{business-analyzer.yaml → google-business/business-analyzer.yaml} +41 -27
  31. package/src/agents/index.ts +68 -13
  32. package/src/agents/marketing/newsletter-signup.yaml +106 -0
  33. package/src/agents/observability/observability-demo-stream.yaml +48 -0
  34. package/src/agents/observability/observability-demo.yaml +67 -0
  35. package/src/client.ts +11 -1
  36. package/src/core/workflow.ts +116 -18
  37. package/src/primitives/chat.ts +51 -0
  38. package/src/server/handler.ts +4 -4
  39. package/src/types/index.ts +46 -0
  40. package/src/types/observability.ts +64 -0
  41. package/dist/primitives/notion-api.d.ts +0 -20
  42. package/dist/primitives/notion-api.d.ts.map +0 -1
  43. package/dist/primitives/notion-api.js +0 -150
  44. package/dist/validation/index.d.ts +0 -33
  45. package/dist/validation/index.d.ts.map +0 -1
  46. package/dist/validation/index.js +0 -74
  47. /package/dist/agents/{assistant-bedrock.yaml → chat/assistant-bedrock.yaml} +0 -0
  48. /package/dist/agents/{assistant-openrouter.yaml → chat/assistant-openrouter.yaml} +0 -0
  49. /package/dist/agents/{assistant.yaml → chat/assistant.yaml} +0 -0
  50. /package/dist/agents/{multi-step-assistant.yaml → examples/multi-step-assistant.yaml} +0 -0
  51. /package/dist/agents/{assistant-gitmcp.yaml → mcp/assistant-gitmcp.yaml} +0 -0
  52. /package/dist/agents/{text-generator.yaml → utility/text-generator.yaml} +0 -0
  53. /package/src/agents/{assistant-bedrock.yaml → chat/assistant-bedrock.yaml} +0 -0
  54. /package/src/agents/{assistant-openrouter.yaml → chat/assistant-openrouter.yaml} +0 -0
  55. /package/src/agents/{assistant.yaml → chat/assistant.yaml} +0 -0
  56. /package/src/agents/{multi-step-assistant.yaml → examples/multi-step-assistant.yaml} +0 -0
  57. /package/src/agents/{assistant-gitmcp.yaml → mcp/assistant-gitmcp.yaml} +0 -0
  58. /package/src/agents/{text-generator.yaml → utility/text-generator.yaml} +0 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Beddel Protocol
2
2
 
3
3
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
4
- [![npm version](https://img.shields.io/badge/npm-1.0.4-brightgreen.svg)](https://www.npmjs.com/package/beddel)
4
+ [![npm version](https://img.shields.io/badge/npm-1.0.8-brightgreen.svg)](https://www.npmjs.com/package/beddel)
5
5
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue.svg)](https://www.typescriptlang.org/)
6
6
  [![AI SDK](https://img.shields.io/badge/AI%20SDK-v6-purple.svg)](https://sdk.vercel.ai/)
7
7
 
@@ -16,6 +16,7 @@
16
16
  - 📦 **Bundle Separation** — Three entry points for server, client, and full API access
17
17
  - 🌐 **Multi-Provider** — Built-in support for Google Gemini, Amazon Bedrock, and OpenRouter (400+ models)
18
18
  - 🔀 **Semantic Primitives** — `chat` for streaming frontend, `llm` for blocking workflows
19
+ - 📊 **Native Observability** — Built-in workflow tracing with step lifecycle events
19
20
 
20
21
  ## Installation
21
22
 
@@ -142,6 +143,82 @@ export default function Chat() {
142
143
  }
143
144
  ```
144
145
 
146
+ ## Observability
147
+
148
+ Beddel includes native observability support for workflow execution tracing. Enable it in your agent's metadata:
149
+
150
+ ```yaml
151
+ metadata:
152
+ name: "My Agent"
153
+ version: "1.0.0"
154
+ observability:
155
+ enabled: true
156
+
157
+ workflow:
158
+ # ... steps
159
+ ```
160
+
161
+ When enabled, the response includes a `__trace` array with step lifecycle events:
162
+
163
+ ```json
164
+ {
165
+ "success": true,
166
+ "data": { ... },
167
+ "__trace": [
168
+ { "type": "step-start", "stepId": "fetch-docs", "stepType": "mcp-tool", "stepIndex": 0, "totalSteps": 3, "timestamp": 1705849200000 },
169
+ { "type": "step-complete", "stepId": "fetch-docs", "stepType": "mcp-tool", "stepIndex": 0, "totalSteps": 3, "timestamp": 1705849201500, "duration": 1500 },
170
+ { "type": "step-start", "stepId": "analyze", "stepType": "llm", "stepIndex": 1, "totalSteps": 3, "timestamp": 1705849201501 },
171
+ ...
172
+ ]
173
+ }
174
+ ```
175
+
176
+ ### Event Types
177
+
178
+ | Event | Description | Extra Fields |
179
+ |-------|-------------|--------------|
180
+ | `step-start` | Step execution begins | — |
181
+ | `step-complete` | Step completed successfully | `duration` (ms) |
182
+ | `step-error` | Step threw an error | `duration` (ms), `errorType` |
183
+
184
+ ### Error Types (Sanitized)
185
+
186
+ For security, error messages are never exposed. Instead, errors are categorized:
187
+
188
+ | Error Type | Description |
189
+ |------------|-------------|
190
+ | `timeout` | Operation timed out |
191
+ | `auth_failed` | Authentication/authorization error |
192
+ | `validation` | Input validation failed |
193
+ | `network` | Network connectivity issue |
194
+ | `unknown` | Uncategorized error |
195
+
196
+ ### Streaming with Observability
197
+
198
+ For `chat` primitives (streaming), trace events are sent as transient data before the stream.
199
+
200
+ > **Note:** Transient data parts are only accessible via the `onData` callback. They do not appear in the `messages` array.
201
+
202
+ ```typescript
203
+ // Client-side handling with useChat (AI SDK v6)
204
+ import { useChat } from '@ai-sdk/react';
205
+ import { DefaultChatTransport } from 'ai';
206
+
207
+ const [streamTrace, setStreamTrace] = useState<StepEvent[]>([]);
208
+
209
+ const { messages, sendMessage, status } = useChat({
210
+ transport: new DefaultChatTransport({
211
+ api: '/api/beddel/chat',
212
+ body: { agentId: 'observability-demo-stream' },
213
+ }),
214
+ onData: (dataPart) => {
215
+ if (dataPart.type === 'data-trace') {
216
+ setStreamTrace(dataPart.data.events);
217
+ }
218
+ },
219
+ });
220
+ ```
221
+
145
222
  ## Built-in Providers
146
223
 
147
224
  | Provider | Environment Variables | Default Model |
@@ -236,6 +313,7 @@ workflow:
236
313
  |---------|-------------|---------|
237
314
  | `$input.*` | Access request input | `$input.messages` |
238
315
  | `$stepResult.varName.*` | Access step result | `$stepResult.llmOutput.text` |
316
+ | `$env.*` | Access environment variables | `$env.NOTION_DATABASE_ID` |
239
317
 
240
318
  ## Built-in Tools
241
319
 
@@ -13,8 +13,9 @@
13
13
 
14
14
  metadata:
15
15
  name: "Business Analyzer"
16
- version: "1.0.0"
16
+ version: "1.1.0"
17
17
  description: "Analyzes business reviews and generates actionable insights"
18
+ builtin: true
18
19
 
19
20
  workflow:
20
21
  # Step 1: Fetch all reviews with auto-pagination
@@ -46,20 +47,28 @@ workflow:
46
47
  5. Trend analysis comparing recent vs older reviews
47
48
  6. Actionable recommendations
48
49
 
49
- Format your response as structured JSON.
50
+ Return ONLY valid JSON (no markdown, no ```):
51
+ {
52
+ "sentimentScore": 8,
53
+ "positiveThemes": [{"theme": "Great service", "count": 15}],
54
+ "improvementAreas": [{"area": "Wait times", "count": 5}],
55
+ "urgentReviews": [{"reviewId": "xxx", "rating": 1, "issue": "summary"}],
56
+ "trendAnalysis": "Recent reviews show improvement...",
57
+ "recommendations": ["Focus on...", "Consider..."]
58
+ }
50
59
  messages:
51
60
  - role: "user"
52
- content: |
53
- Analyze these business reviews:
54
-
55
- Total Reviews: $stepResult.reviewsData.totalReviewCount
56
- Average Rating: $stepResult.reviewsData.averageRating
57
-
58
- Reviews Data:
59
- $stepResult.reviewsData.reviews
61
+ content: "$input.reviewsPayload"
62
+ result: "analysisRaw"
63
+
64
+ # Step 3: Parse analysis JSON
65
+ - id: "parse-analysis"
66
+ type: "output-generator"
67
+ config:
68
+ json: "$stepResult.analysisRaw.text"
60
69
  result: "analysis"
61
70
 
62
- # Step 3: Generate response suggestions for negative reviews
71
+ # Step 4: Generate response suggestions for negative reviews
63
72
  - id: "generate-responses"
64
73
  type: "llm"
65
74
  config:
@@ -76,24 +85,29 @@ workflow:
76
85
  - Keep responses under 150 words
77
86
  - Be specific to the complaint mentioned
78
87
 
79
- Format as JSON array with reviewId and suggestedResponse.
88
+ Return ONLY valid JSON array (no markdown, no ```):
89
+ [{"reviewId": "xxx", "rating": 2, "originalComment": "...", "suggestedResponse": "..."}]
90
+
91
+ If no negative reviews, return: []
80
92
  messages:
81
93
  - role: "user"
82
- content: |
83
- Generate response suggestions for these reviews:
84
- $stepResult.reviewsData.reviews
85
- result: "responseSuggestions"
94
+ content: "$input.reviewsPayload"
95
+ result: "responsesRaw"
86
96
 
87
- # Step 4: Compile final report
88
- - id: "compile-report"
97
+ # Step 5: Parse responses JSON
98
+ - id: "parse-responses"
89
99
  type: "output-generator"
90
100
  config:
91
- template:
92
- summary:
93
- totalReviews: "$stepResult.reviewsData.totalReviewCount"
94
- averageRating: "$stepResult.reviewsData.averageRating"
95
- analysisDate: "$input.analysisDate"
96
- analysis: "$stepResult.analysis.text"
97
- responseSuggestions: "$stepResult.responseSuggestions.text"
98
- rawReviews: "$stepResult.reviewsData.reviews"
99
- result: "finalReport"
101
+ json: "$stepResult.responsesRaw.text"
102
+ result: "responseSuggestions"
103
+
104
+ # Explicit Return: Define the API response contract
105
+ return:
106
+ success: true
107
+ summary:
108
+ totalReviews: "$stepResult.reviewsData.totalReviewCount"
109
+ averageRating: "$stepResult.reviewsData.averageRating"
110
+ pagesFetched: "$stepResult.reviewsData.data.pagesFetched"
111
+ analysis: "$stepResult.analysis"
112
+ responseSuggestions: "$stepResult.responseSuggestions"
113
+ reviews: "$stepResult.reviewsData.reviews"
@@ -3,12 +3,24 @@
3
3
  *
4
4
  * Lists all agents bundled with the beddel package.
5
5
  * These are available automatically without user configuration.
6
+ *
7
+ * Agents are organized by category:
8
+ * - chat/ Streaming chat assistants (different providers)
9
+ * - mcp/ MCP server integrations (GitMCP, Context7, etc.)
10
+ * - google-business/ Google Business Profile agents
11
+ * - marketing/ Lead capture, newsletters, CRM
12
+ * - utility/ General-purpose tools
13
+ * - examples/ Demo pipelines showing multi-step workflows
14
+ */
15
+ /**
16
+ * Built-in agent definitions with their category paths
6
17
  */
18
+ export declare const BUILTIN_AGENT_PATHS: Record<string, string>;
7
19
  /**
8
20
  * List of built-in agent IDs available in the package
9
21
  */
10
- export declare const BUILTIN_AGENTS: readonly ["assistant", "assistant-bedrock", "assistant-openrouter", "assistant-gitmcp", "text-generator", "multi-step-assistant", "business-analyzer"];
11
- export type BuiltinAgentId = typeof BUILTIN_AGENTS[number];
22
+ export declare const BUILTIN_AGENTS: readonly string[];
23
+ export type BuiltinAgentId = keyof typeof BUILTIN_AGENT_PATHS;
12
24
  /**
13
25
  * Get the absolute path to the built-in agents directory
14
26
  */
@@ -20,5 +32,14 @@ export declare function isBuiltinAgent(agentId: string): agentId is BuiltinAgent
20
32
  /**
21
33
  * Get the full path to a built-in agent YAML file
22
34
  */
23
- export declare function getBuiltinAgentPath(agentId: BuiltinAgentId): string;
35
+ export declare function getBuiltinAgentPath(agentId: string): string | null;
36
+ /**
37
+ * Get all agents in a specific category
38
+ */
39
+ export declare function getAgentsByCategory(category: string): string[];
40
+ /**
41
+ * Available categories
42
+ */
43
+ export declare const AGENT_CATEGORIES: readonly ["chat", "mcp", "google-business", "marketing", "utility", "observability", "examples"];
44
+ export type AgentCategory = typeof AGENT_CATEGORIES[number];
24
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,eAAO,MAAM,cAAc,wJAQjB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;AAE3D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,cAAc,CAEzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAEnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwBtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAuC,SAAS,MAAM,EAAE,CAAC;AAEpF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE9D;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,cAAc,CAEzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAI9D;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,kGAQnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
@@ -3,24 +3,46 @@
3
3
  *
4
4
  * Lists all agents bundled with the beddel package.
5
5
  * These are available automatically without user configuration.
6
+ *
7
+ * Agents are organized by category:
8
+ * - chat/ Streaming chat assistants (different providers)
9
+ * - mcp/ MCP server integrations (GitMCP, Context7, etc.)
10
+ * - google-business/ Google Business Profile agents
11
+ * - marketing/ Lead capture, newsletters, CRM
12
+ * - utility/ General-purpose tools
13
+ * - examples/ Demo pipelines showing multi-step workflows
6
14
  */
7
15
  import { fileURLToPath } from 'url';
8
16
  import { dirname, join } from 'path';
9
17
  // Get the directory where built-in agents are located
10
18
  const __filename = fileURLToPath(import.meta.url);
11
19
  const __dirname = dirname(__filename);
20
+ /**
21
+ * Built-in agent definitions with their category paths
22
+ */
23
+ export const BUILTIN_AGENT_PATHS = {
24
+ // Chat assistants
25
+ 'assistant': 'chat/assistant.yaml',
26
+ 'assistant-bedrock': 'chat/assistant-bedrock.yaml',
27
+ 'assistant-openrouter': 'chat/assistant-openrouter.yaml',
28
+ // MCP integrations
29
+ 'assistant-gitmcp': 'mcp/assistant-gitmcp.yaml',
30
+ // Google Business
31
+ 'business-analyzer': 'google-business/business-analyzer.yaml',
32
+ // Marketing
33
+ 'newsletter-signup': 'marketing/newsletter-signup.yaml',
34
+ // Utility
35
+ 'text-generator': 'utility/text-generator.yaml',
36
+ // Observability
37
+ 'observability-demo': 'observability/observability-demo.yaml',
38
+ 'observability-demo-stream': 'observability/observability-demo-stream.yaml',
39
+ // Examples
40
+ 'multi-step-assistant': 'examples/multi-step-assistant.yaml',
41
+ };
12
42
  /**
13
43
  * List of built-in agent IDs available in the package
14
44
  */
15
- export const BUILTIN_AGENTS = [
16
- 'assistant',
17
- 'assistant-bedrock',
18
- 'assistant-openrouter',
19
- 'assistant-gitmcp',
20
- 'text-generator',
21
- 'multi-step-assistant',
22
- 'business-analyzer',
23
- ];
45
+ export const BUILTIN_AGENTS = Object.keys(BUILTIN_AGENT_PATHS);
24
46
  /**
25
47
  * Get the absolute path to the built-in agents directory
26
48
  */
@@ -31,11 +53,34 @@ export function getBuiltinAgentsPath() {
31
53
  * Check if an agent ID is a built-in agent
32
54
  */
33
55
  export function isBuiltinAgent(agentId) {
34
- return BUILTIN_AGENTS.includes(agentId);
56
+ return agentId in BUILTIN_AGENT_PATHS;
35
57
  }
36
58
  /**
37
59
  * Get the full path to a built-in agent YAML file
38
60
  */
39
61
  export function getBuiltinAgentPath(agentId) {
40
- return join(__dirname, `${agentId}.yaml`);
62
+ const relativePath = BUILTIN_AGENT_PATHS[agentId];
63
+ if (!relativePath)
64
+ return null;
65
+ return join(__dirname, relativePath);
66
+ }
67
+ /**
68
+ * Get all agents in a specific category
69
+ */
70
+ export function getAgentsByCategory(category) {
71
+ return Object.entries(BUILTIN_AGENT_PATHS)
72
+ .filter(([_, path]) => path.startsWith(`${category}/`))
73
+ .map(([id]) => id);
41
74
  }
75
+ /**
76
+ * Available categories
77
+ */
78
+ export const AGENT_CATEGORIES = [
79
+ 'chat',
80
+ 'mcp',
81
+ 'google-business',
82
+ 'marketing',
83
+ 'utility',
84
+ 'observability',
85
+ 'examples',
86
+ ];
@@ -0,0 +1,106 @@
1
+ # Newsletter Signup Agent
2
+ # Registers users to the newsletter with AI analysis and saves to Notion
3
+ #
4
+ # Required Environment Variables:
5
+ # - NOTION_TOKEN (Internal Integration Secret)
6
+ # - NOTION_DATABASE_ID (Database ID for newsletter signups)
7
+ # - GEMINI_API_KEY (for AI analysis)
8
+ #
9
+ # Input:
10
+ # - name: User's name
11
+ # - email: User's email
12
+ # - message: Optional message from user
13
+ # - createdAt: ISO date string
14
+
15
+ metadata:
16
+ name: "Newsletter Signup Agent"
17
+ version: "1.3.0"
18
+ description: "Registers users to the newsletter with AI analysis and saves to Notion"
19
+ builtin: true
20
+
21
+ workflow:
22
+ # Step 1: Analyze user profile and generate structured JSON
23
+ - id: "analyze-user"
24
+ type: "llm"
25
+ config:
26
+ provider: "google"
27
+ model: "gemini-2.0-flash-exp"
28
+ system: |
29
+ You are a lead analyst for a technology newsletter.
30
+
31
+ Analyze the user data and return ONLY a valid JSON (no markdown, no ```):
32
+ {
33
+ "tags": [{"name": "Tag1"}],
34
+ "sentiment": {"name": "Positive"},
35
+ "summary": "One-line summary"
36
+ }
37
+
38
+ IMPORTANT RULES:
39
+ - tags: Array of objects with "name". Allowed values: "Support", "Sales", "Partnership", "Feedback"
40
+ - sentiment: Object with "name". Allowed values: "Positive", "Neutral", "Negative"
41
+ - summary: Short summary string (maximum 100 characters)
42
+
43
+ Example for a positive message about the product:
44
+ {"tags": [{"name": "Feedback"}], "sentiment": {"name": "Positive"}, "summary": "User praises the product"}
45
+
46
+ If there is no significant message:
47
+ {"tags": [{"name": "Feedback"}], "sentiment": {"name": "Neutral"}, "summary": "New newsletter subscriber"}
48
+
49
+ Return ONLY the JSON, nothing else.
50
+ messages:
51
+ - role: "user"
52
+ content: |
53
+ Name: $input.name
54
+ Email: $input.email
55
+ Message: $input.message
56
+ result: "userAnalysis"
57
+
58
+ # Step 2: Parse the JSON from LLM
59
+ - id: "parse-analysis"
60
+ type: "output-generator"
61
+ config:
62
+ json: "$stepResult.userAnalysis.text"
63
+ result: "parsedAnalysis"
64
+
65
+ # Step 3: Create Notion page with structured data
66
+ - id: "create-notion-entry"
67
+ type: "notion"
68
+ config:
69
+ action: "createPage"
70
+ parent:
71
+ type: "database_id"
72
+ database_id: "$env.NOTION_DATABASE_ID"
73
+ properties:
74
+ Name:
75
+ title:
76
+ - text:
77
+ content: "$input.name"
78
+ Email:
79
+ email: "$input.email"
80
+ Message:
81
+ rich_text:
82
+ - text:
83
+ content: "$input.message"
84
+ Summary:
85
+ rich_text:
86
+ - text:
87
+ content: "$stepResult.parsedAnalysis.summary"
88
+ Tags:
89
+ multi_select: "$stepResult.parsedAnalysis.tags"
90
+ Sentiment:
91
+ select: "$stepResult.parsedAnalysis.sentiment"
92
+ CreatedAt:
93
+ date:
94
+ start: "$input.createdAt"
95
+ result: "notionResult"
96
+
97
+ # Explicit Return: Define the API response contract
98
+ return:
99
+ success: true
100
+ message: "Registration completed successfully!"
101
+ notionPageId: "$stepResult.notionResult.pageId"
102
+ notionUrl: "$stepResult.notionResult.url"
103
+ analysis:
104
+ tags: "$stepResult.parsedAnalysis.tags"
105
+ sentiment: "$stepResult.parsedAnalysis.sentiment"
106
+ summary: "$stepResult.parsedAnalysis.summary"
@@ -0,0 +1,48 @@
1
+ metadata:
2
+ name: "Beddel Protocol Expert (Streaming)"
3
+ version: "1.0.0"
4
+ builtin: true
5
+ description: "Multi-step assistant with streaming response"
6
+ observability:
7
+ enabled: true
8
+
9
+ workflow:
10
+ # Step 1: Fetch Beddel documentation via GitMCP
11
+ - id: "fetch-docs"
12
+ type: "mcp-tool"
13
+ config:
14
+ url: "https://gitmcp.io/botanarede/beddel"
15
+ tool: "fetch_beddel_documentation"
16
+ arguments: {}
17
+ result: "beddelDocs"
18
+
19
+ # Step 2: Search for specific content in documentation
20
+ - id: "search-docs"
21
+ type: "mcp-tool"
22
+ config:
23
+ url: "https://gitmcp.io/botanarede/beddel"
24
+ tool: "search_beddel_documentation"
25
+ arguments:
26
+ query: "$input.query"
27
+ result: "searchResults"
28
+
29
+ # Step 3: Stream response using chat primitive
30
+ - id: "respond"
31
+ type: "chat"
32
+ config:
33
+ provider: "google"
34
+ model: "gemini-2.0-flash-exp"
35
+ system: |
36
+ You are an expert assistant specialized in the Beddel Protocol.
37
+ Use the documentation provided to answer questions accurately.
38
+
39
+ Always respond in Portuguese (Brazilian).
40
+ Be concise but complete. Include code examples when relevant.
41
+ If the documentation doesn't cover the topic, say so clearly.
42
+
43
+ ## Beddel Documentation Index
44
+ $stepResult.beddelDocs.data
45
+
46
+ ## Search Results for User Query
47
+ $stepResult.searchResults.data
48
+ messages: "$input.messages"
@@ -0,0 +1,67 @@
1
+ metadata:
2
+ name: "Beddel Protocol Expert"
3
+ version: "1.0.0"
4
+ builtin: true
5
+ description: "Multi-step assistant demonstrating observability - Expert in Beddel Protocol"
6
+ observability:
7
+ enabled: true
8
+
9
+ workflow:
10
+ # Step 1: Fetch Beddel documentation via GitMCP
11
+ - id: "fetch-docs"
12
+ type: "mcp-tool"
13
+ config:
14
+ url: "https://gitmcp.io/botanarede/beddel"
15
+ tool: "fetch_beddel_documentation"
16
+ arguments: {}
17
+ result: "beddelDocs"
18
+
19
+ # Step 2: Search for specific content in documentation
20
+ - id: "search-docs"
21
+ type: "mcp-tool"
22
+ config:
23
+ url: "https://gitmcp.io/botanarede/beddel"
24
+ tool: "search_beddel_documentation"
25
+ arguments:
26
+ query: "$input.query"
27
+ result: "searchResults"
28
+
29
+ # Step 3: Generate expert response using documentation context
30
+ - id: "generate-response"
31
+ type: "llm"
32
+ config:
33
+ provider: "google"
34
+ model: "gemini-2.0-flash-exp"
35
+ system: |
36
+ You are an expert assistant specialized in the Beddel Protocol.
37
+ Use the documentation provided to answer questions accurately.
38
+
39
+ Always respond in Portuguese (Brazilian).
40
+ Be concise but complete. Include code examples when relevant.
41
+ If the documentation doesn't cover the topic, say so clearly.
42
+
43
+ ## Beddel Documentation Index
44
+ $stepResult.beddelDocs.data
45
+
46
+ ## Search Results for User Query
47
+ $stepResult.searchResults.data
48
+ messages:
49
+ - role: "user"
50
+ content: "$input.query"
51
+ result: "expertResponse"
52
+
53
+ # Step 4: Structure final output
54
+ - id: "format-output"
55
+ type: "output-generator"
56
+ config:
57
+ template:
58
+ query: "$input.query"
59
+ answer: "$stepResult.expertResponse.text"
60
+ sources:
61
+ - "Beddel Protocol Documentation"
62
+ - "https://github.com/botanarede/beddel"
63
+ result: "finalOutput"
64
+
65
+ return:
66
+ success: true
67
+ data: "$stepResult.finalOutput"
package/dist/client.d.ts CHANGED
@@ -4,7 +4,8 @@
4
4
  * This entry point exports ONLY types and utilities safe for client-side use.
5
5
  * No Node.js dependencies (fs, crypto, etc.) are included here.
6
6
  *
7
- * Usage: import type { ParsedYaml } from 'beddel/client';
7
+ * Usage: import type { ParsedYaml, BeddelResponse } from 'beddel/client';
8
8
  */
9
- export type { ParsedYaml, WorkflowStep, StepConfig, YamlMetadata, ExecutionContext, PrimitiveHandler, } from './types';
9
+ export type { ParsedYaml, WorkflowStep, StepConfig, YamlMetadata, ExecutionContext, PrimitiveHandler, BeddelResponse, } from './types';
10
+ export type { ObservabilityConfig, StepEvent, StepStartEvent, StepCompleteEvent, StepErrorEvent, } from './types/observability';
10
11
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACjB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACR,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,cAAc,GACjB,MAAM,uBAAuB,CAAC"}
package/dist/client.js CHANGED
@@ -4,6 +4,6 @@
4
4
  * This entry point exports ONLY types and utilities safe for client-side use.
5
5
  * No Node.js dependencies (fs, crypto, etc.) are included here.
6
6
  *
7
- * Usage: import type { ParsedYaml } from 'beddel/client';
7
+ * Usage: import type { ParsedYaml, BeddelResponse } from 'beddel/client';
8
8
  */
9
9
  export {};
@@ -10,16 +10,28 @@
10
10
  * and that Response is returned immediately to the client.
11
11
  * - Non-Response results are stored in context.variables for subsequent steps.
12
12
  * - If 'return' is defined in YAML, it shapes the final API response.
13
+ * - When observability is enabled, trace events are collected and attached to results.
13
14
  */
14
15
  import type { ParsedYaml } from '../types';
15
16
  export declare class WorkflowExecutor {
16
17
  private steps;
17
18
  private returnTemplate?;
19
+ private observabilityEnabled;
18
20
  /**
19
21
  * Create a new WorkflowExecutor from parsed YAML.
20
22
  * @param yaml - Parsed YAML document containing workflow steps
21
23
  */
22
24
  constructor(yaml: ParsedYaml);
25
+ /**
26
+ * Push a trace event to the context (no-op if observability disabled).
27
+ * Errors are caught to prevent trace failures from breaking workflow execution.
28
+ */
29
+ private pushEvent;
30
+ /**
31
+ * Sanitize error into a safe error type category.
32
+ * SECURITY: Never exposes full error messages, only categorized types.
33
+ */
34
+ private sanitizeErrorType;
23
35
  /**
24
36
  * Execute the workflow pipeline.
25
37
  *
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/core/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAA8C,MAAM,UAAU,CAAC;AAIvF,qBAAa,gBAAgB;IACzB,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,cAAc,CAAC,CAAU;IAEjC;;;OAGG;gBACS,IAAI,EAAE,UAAU;IAK5B;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CA2D7E"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/core/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACR,UAAU,EAOb,MAAM,UAAU,CAAC;AAIlB,qBAAa,gBAAgB;IACzB,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,cAAc,CAAC,CAAU;IACjC,OAAO,CAAC,oBAAoB,CAAU;IAEtC;;;OAGG;gBACS,IAAI,EAAE,UAAU;IAU5B;;;OAGG;IACH,OAAO,CAAC,SAAS;IASjB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;;;;;;;;;;;;;;OAeG;IACG,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAiH7E"}