beddel 1.0.5 → 1.0.6
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/dist/agents/business-analyzer.yaml +99 -0
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +1 -0
- package/dist/core/variable-resolver.d.ts +2 -1
- package/dist/core/variable-resolver.d.ts.map +1 -1
- package/dist/core/variable-resolver.js +13 -1
- package/dist/core/workflow.d.ts +3 -1
- package/dist/core/workflow.d.ts.map +1 -1
- package/dist/core/workflow.js +26 -2
- package/dist/primitives/google-business.d.ts +33 -0
- package/dist/primitives/google-business.d.ts.map +1 -0
- package/dist/primitives/google-business.js +433 -0
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +16 -0
- package/dist/primitives/mcp-tool.d.ts.map +1 -1
- package/dist/primitives/mcp-tool.js +12 -1
- package/dist/primitives/notion-api.d.ts +20 -0
- package/dist/primitives/notion-api.d.ts.map +1 -0
- package/dist/primitives/notion-api.js +150 -0
- package/dist/primitives/notion.d.ts +34 -0
- package/dist/primitives/notion.d.ts.map +1 -0
- package/dist/primitives/notion.js +432 -0
- package/dist/primitives/output.d.ts +3 -0
- package/dist/primitives/output.d.ts.map +1 -1
- package/dist/primitives/output.js +68 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/docs/primitives/google-business-primitive.md +379 -0
- package/docs/primitives/notion-primitive.md +462 -0
- package/package.json +1 -1
- package/src/agents/business-analyzer.yaml +99 -0
- package/src/agents/index.ts +1 -0
- package/src/core/variable-resolver.ts +16 -1
- package/src/core/workflow.ts +32 -2
- package/src/primitives/google-business.ts +669 -0
- package/src/primitives/index.ts +18 -0
- package/src/primitives/mcp-tool.ts +15 -1
- package/src/primitives/notion.ts +570 -0
- package/src/primitives/output.ts +84 -1
- package/src/types/index.ts +2 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Business Analyzer Agent
|
|
2
|
+
# Analyzes Google Business Profile reviews and generates insights
|
|
3
|
+
#
|
|
4
|
+
# Required Environment Variables:
|
|
5
|
+
# - GOOGLE_CLIENT_ID
|
|
6
|
+
# - GOOGLE_CLIENT_SECRET
|
|
7
|
+
# - GOOGLE_REFRESH_TOKEN
|
|
8
|
+
# - GEMINI_API_KEY (for AI analysis)
|
|
9
|
+
#
|
|
10
|
+
# Input:
|
|
11
|
+
# - accountId: Google Business Account ID
|
|
12
|
+
# - locationId: Location ID to analyze
|
|
13
|
+
|
|
14
|
+
metadata:
|
|
15
|
+
name: "Business Analyzer"
|
|
16
|
+
version: "1.0.0"
|
|
17
|
+
description: "Analyzes business reviews and generates actionable insights"
|
|
18
|
+
|
|
19
|
+
workflow:
|
|
20
|
+
# Step 1: Fetch all reviews with auto-pagination
|
|
21
|
+
- id: "fetch-reviews"
|
|
22
|
+
type: "google-business"
|
|
23
|
+
config:
|
|
24
|
+
action: "listReviews"
|
|
25
|
+
accountId: "$input.accountId"
|
|
26
|
+
locationId: "$input.locationId"
|
|
27
|
+
pageSize: 100
|
|
28
|
+
maxPages: 10
|
|
29
|
+
orderBy: "update_time desc"
|
|
30
|
+
result: "reviewsData"
|
|
31
|
+
|
|
32
|
+
# Step 2: Analyze reviews with AI
|
|
33
|
+
- id: "analyze-sentiment"
|
|
34
|
+
type: "llm"
|
|
35
|
+
config:
|
|
36
|
+
provider: "google"
|
|
37
|
+
model: "gemini-2.0-flash-exp"
|
|
38
|
+
system: |
|
|
39
|
+
You are a business analytics expert. Analyze the provided reviews and generate a comprehensive report.
|
|
40
|
+
|
|
41
|
+
Your analysis must include:
|
|
42
|
+
1. Overall sentiment score (1-10)
|
|
43
|
+
2. Top 5 positive themes with mention counts
|
|
44
|
+
3. Top 5 areas for improvement with mention counts
|
|
45
|
+
4. Reviews requiring urgent response (rating <= 2)
|
|
46
|
+
5. Trend analysis comparing recent vs older reviews
|
|
47
|
+
6. Actionable recommendations
|
|
48
|
+
|
|
49
|
+
Format your response as structured JSON.
|
|
50
|
+
messages:
|
|
51
|
+
- 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
|
|
60
|
+
result: "analysis"
|
|
61
|
+
|
|
62
|
+
# Step 3: Generate response suggestions for negative reviews
|
|
63
|
+
- id: "generate-responses"
|
|
64
|
+
type: "llm"
|
|
65
|
+
config:
|
|
66
|
+
provider: "google"
|
|
67
|
+
model: "gemini-2.0-flash-exp"
|
|
68
|
+
system: |
|
|
69
|
+
You are a customer service expert. For each negative review (rating <= 3),
|
|
70
|
+
generate a professional, empathetic response suggestion.
|
|
71
|
+
|
|
72
|
+
Guidelines:
|
|
73
|
+
- Acknowledge the customer's concern
|
|
74
|
+
- Apologize for their experience
|
|
75
|
+
- Offer a solution or next steps
|
|
76
|
+
- Keep responses under 150 words
|
|
77
|
+
- Be specific to the complaint mentioned
|
|
78
|
+
|
|
79
|
+
Format as JSON array with reviewId and suggestedResponse.
|
|
80
|
+
messages:
|
|
81
|
+
- role: "user"
|
|
82
|
+
content: |
|
|
83
|
+
Generate response suggestions for these reviews:
|
|
84
|
+
$stepResult.reviewsData.reviews
|
|
85
|
+
result: "responseSuggestions"
|
|
86
|
+
|
|
87
|
+
# Step 4: Compile final report
|
|
88
|
+
- id: "compile-report"
|
|
89
|
+
type: "output-generator"
|
|
90
|
+
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"
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* List of built-in agent IDs available in the package
|
|
9
9
|
*/
|
|
10
|
-
export declare const BUILTIN_AGENTS: readonly ["assistant", "assistant-bedrock", "assistant-openrouter", "assistant-gitmcp", "text-generator", "multi-step-assistant"];
|
|
10
|
+
export declare const BUILTIN_AGENTS: readonly ["assistant", "assistant-bedrock", "assistant-openrouter", "assistant-gitmcp", "text-generator", "multi-step-assistant", "business-analyzer"];
|
|
11
11
|
export type BuiltinAgentId = typeof BUILTIN_AGENTS[number];
|
|
12
12
|
/**
|
|
13
13
|
* Get the absolute path to the built-in agents directory
|
|
@@ -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,
|
|
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"}
|
package/dist/agents/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Beddel Protocol - Variable Resolver
|
|
3
3
|
*
|
|
4
4
|
* Resolves template variables in step configurations.
|
|
5
|
-
* Patterns: $input.path.to.value, $stepResult.path.to.value
|
|
5
|
+
* Patterns: $input.path.to.value, $stepResult.path.to.value, $env.VAR_NAME
|
|
6
6
|
*
|
|
7
7
|
* Server-only: Used within WorkflowExecutor during step execution.
|
|
8
8
|
*/
|
|
@@ -11,6 +11,7 @@ import type { ExecutionContext } from '../types';
|
|
|
11
11
|
* Resolve variable references in a template value.
|
|
12
12
|
*
|
|
13
13
|
* Supports:
|
|
14
|
+
* - "$env.VAR_NAME" → process.env.VAR_NAME (server-side only)
|
|
14
15
|
* - "$input.messages" → context.input.messages
|
|
15
16
|
* - "$stepResult.llmOutput.text" → context.variables.get('llmOutput').text
|
|
16
17
|
* - Nested objects/arrays are resolved recursively
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variable-resolver.d.ts","sourceRoot":"","sources":["../../src/core/variable-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"variable-resolver.d.ts","sourceRoot":"","sources":["../../src/core/variable-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoFjD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CA6EtF"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Beddel Protocol - Variable Resolver
|
|
3
3
|
*
|
|
4
4
|
* Resolves template variables in step configurations.
|
|
5
|
-
* Patterns: $input.path.to.value, $stepResult.path.to.value
|
|
5
|
+
* Patterns: $input.path.to.value, $stepResult.path.to.value, $env.VAR_NAME
|
|
6
6
|
*
|
|
7
7
|
* Server-only: Used within WorkflowExecutor during step execution.
|
|
8
8
|
*/
|
|
@@ -39,6 +39,12 @@ function interpolateVariables(template, context) {
|
|
|
39
39
|
// Matches: $word.word.word... (stops at whitespace, newline, or end)
|
|
40
40
|
const variablePattern = /\$([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)/g;
|
|
41
41
|
return template.replace(variablePattern, (match, fullPath) => {
|
|
42
|
+
// Handle $env.* pattern (environment variables)
|
|
43
|
+
if (fullPath.startsWith('env.')) {
|
|
44
|
+
const envVar = fullPath.slice(4); // Remove "env."
|
|
45
|
+
const value = process.env[envVar];
|
|
46
|
+
return value !== undefined ? value : match;
|
|
47
|
+
}
|
|
42
48
|
// Handle $input.* pattern
|
|
43
49
|
if (fullPath.startsWith('input.')) {
|
|
44
50
|
const path = fullPath.slice(6); // Remove "input."
|
|
@@ -76,6 +82,7 @@ function interpolateVariables(template, context) {
|
|
|
76
82
|
* Resolve variable references in a template value.
|
|
77
83
|
*
|
|
78
84
|
* Supports:
|
|
85
|
+
* - "$env.VAR_NAME" → process.env.VAR_NAME (server-side only)
|
|
79
86
|
* - "$input.messages" → context.input.messages
|
|
80
87
|
* - "$stepResult.llmOutput.text" → context.variables.get('llmOutput').text
|
|
81
88
|
* - Nested objects/arrays are resolved recursively
|
|
@@ -92,6 +99,11 @@ export function resolveVariables(template, context) {
|
|
|
92
99
|
// Handle string patterns
|
|
93
100
|
if (typeof template === 'string') {
|
|
94
101
|
// Check if entire string is a single variable reference
|
|
102
|
+
// Check for $env.* pattern (entire string) - environment variables
|
|
103
|
+
if (template.startsWith('$env.') && !template.includes(' ') && !template.includes('\n')) {
|
|
104
|
+
const envVar = template.slice(5); // Remove "$env."
|
|
105
|
+
return process.env[envVar];
|
|
106
|
+
}
|
|
95
107
|
// Check for $input.* pattern (entire string)
|
|
96
108
|
if (template.startsWith('$input.') && !template.includes(' ') && !template.includes('\n')) {
|
|
97
109
|
const path = template.slice(7); // Remove "$input."
|
package/dist/core/workflow.d.ts
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* - If a handler returns a Response instance (streaming), execution stops
|
|
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
|
+
* - If 'return' is defined in YAML, it shapes the final API response.
|
|
12
13
|
*/
|
|
13
14
|
import type { ParsedYaml } from '../types';
|
|
14
15
|
export declare class WorkflowExecutor {
|
|
15
16
|
private steps;
|
|
17
|
+
private returnTemplate?;
|
|
16
18
|
/**
|
|
17
19
|
* Create a new WorkflowExecutor from parsed YAML.
|
|
18
20
|
* @param yaml - Parsed YAML document containing workflow steps
|
|
@@ -22,7 +24,7 @@ export declare class WorkflowExecutor {
|
|
|
22
24
|
* Execute the workflow pipeline.
|
|
23
25
|
*
|
|
24
26
|
* @param input - Input data (e.g., { messages: [...] } for chat)
|
|
25
|
-
* @returns Response if streaming, or accumulated variables object
|
|
27
|
+
* @returns Response if streaming, last step result if no 'result' key, or accumulated variables object
|
|
26
28
|
*
|
|
27
29
|
* @example
|
|
28
30
|
* ```typescript
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/core/workflow.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/dist/core/workflow.js
CHANGED
|
@@ -9,22 +9,26 @@
|
|
|
9
9
|
* - If a handler returns a Response instance (streaming), execution stops
|
|
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
|
+
* - If 'return' is defined in YAML, it shapes the final API response.
|
|
12
13
|
*/
|
|
13
14
|
import { handlerRegistry } from '../primitives';
|
|
15
|
+
import { resolveVariables } from './variable-resolver';
|
|
14
16
|
export class WorkflowExecutor {
|
|
15
17
|
steps;
|
|
18
|
+
returnTemplate;
|
|
16
19
|
/**
|
|
17
20
|
* Create a new WorkflowExecutor from parsed YAML.
|
|
18
21
|
* @param yaml - Parsed YAML document containing workflow steps
|
|
19
22
|
*/
|
|
20
23
|
constructor(yaml) {
|
|
21
24
|
this.steps = yaml.workflow;
|
|
25
|
+
this.returnTemplate = yaml.return;
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Execute the workflow pipeline.
|
|
25
29
|
*
|
|
26
30
|
* @param input - Input data (e.g., { messages: [...] } for chat)
|
|
27
|
-
* @returns Response if streaming, or accumulated variables object
|
|
31
|
+
* @returns Response if streaming, last step result if no 'result' key, or accumulated variables object
|
|
28
32
|
*
|
|
29
33
|
* @example
|
|
30
34
|
* ```typescript
|
|
@@ -41,6 +45,7 @@ export class WorkflowExecutor {
|
|
|
41
45
|
input,
|
|
42
46
|
variables: new Map(),
|
|
43
47
|
};
|
|
48
|
+
let lastResult = null;
|
|
44
49
|
for (const step of this.steps) {
|
|
45
50
|
const handler = handlerRegistry[step.type];
|
|
46
51
|
if (!handler) {
|
|
@@ -57,8 +62,27 @@ export class WorkflowExecutor {
|
|
|
57
62
|
if (step.result) {
|
|
58
63
|
context.variables.set(step.result, result);
|
|
59
64
|
}
|
|
65
|
+
// Track last result for final return
|
|
66
|
+
lastResult = result;
|
|
60
67
|
}
|
|
61
|
-
//
|
|
68
|
+
// If last step has no 'result' key, return its output directly
|
|
69
|
+
// This allows the final step to define the API response shape
|
|
70
|
+
const lastStep = this.steps[this.steps.length - 1];
|
|
71
|
+
if (lastStep && !lastStep.result && lastResult) {
|
|
72
|
+
return lastResult;
|
|
73
|
+
}
|
|
74
|
+
// If 'return' template is defined, resolve and return it
|
|
75
|
+
// This provides explicit control over the API response contract
|
|
76
|
+
if (this.returnTemplate !== undefined) {
|
|
77
|
+
const resolved = resolveVariables(this.returnTemplate, context);
|
|
78
|
+
// Ensure we return a Record
|
|
79
|
+
if (typeof resolved === 'object' && resolved !== null && !Array.isArray(resolved)) {
|
|
80
|
+
return resolved;
|
|
81
|
+
}
|
|
82
|
+
// Wrap primitives and arrays in an object
|
|
83
|
+
return { value: resolved };
|
|
84
|
+
}
|
|
85
|
+
// Fallback: return accumulated variables as object
|
|
62
86
|
return Object.fromEntries(context.variables);
|
|
63
87
|
}
|
|
64
88
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Beddel Protocol - Google Business Profile Primitive
|
|
3
|
+
*
|
|
4
|
+
* Integrates with Google Business Profile APIs to manage reviews,
|
|
5
|
+
* posts, Q&A, and performance metrics for business locations.
|
|
6
|
+
*
|
|
7
|
+
* Server-only: Uses googleapis which requires Node.js.
|
|
8
|
+
*
|
|
9
|
+
* Supported Actions:
|
|
10
|
+
* - listReviews: Fetch all reviews with auto-pagination
|
|
11
|
+
* - replyReview: Reply to a specific review
|
|
12
|
+
* - batchGetReviews: Fetch reviews from multiple locations
|
|
13
|
+
* - createPost: Create a local post
|
|
14
|
+
* - listPosts: List all posts for a location
|
|
15
|
+
* - getMetrics: Fetch performance metrics
|
|
16
|
+
* - listQuestions: List Q&A for a location
|
|
17
|
+
* - answerQuestion: Answer a question
|
|
18
|
+
*
|
|
19
|
+
* @see https://developers.google.com/my-business/content/overview
|
|
20
|
+
*/
|
|
21
|
+
import type { PrimitiveHandler } from '../types';
|
|
22
|
+
/**
|
|
23
|
+
* Google Business Profile Primitive Handler
|
|
24
|
+
*
|
|
25
|
+
* Executes Google Business Profile API operations based on the action specified.
|
|
26
|
+
* Supports reviews, posts, Q&A, and performance metrics.
|
|
27
|
+
*
|
|
28
|
+
* @param config - Step configuration from YAML
|
|
29
|
+
* @param context - Execution context with input and variables
|
|
30
|
+
* @returns GoogleBusinessResult with success status and data or error
|
|
31
|
+
*/
|
|
32
|
+
export declare const googleBusinessPrimitive: PrimitiveHandler;
|
|
33
|
+
//# sourceMappingURL=google-business.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-business.d.ts","sourceRoot":"","sources":["../../src/primitives/google-business.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAgC,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAyjB/E;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAoErC,CAAC"}
|