@sf-explorer/agentscript-migration-tool 1.0.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 (68) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +342 -0
  4. package/dist/builders/actionBuilder.d.ts +39 -0
  5. package/dist/builders/actionBuilder.d.ts.map +1 -0
  6. package/dist/builders/actionBuilder.js +120 -0
  7. package/dist/builders/actionBuilder.js.map +1 -0
  8. package/dist/builders/configBuilder.d.ts +14 -0
  9. package/dist/builders/configBuilder.d.ts.map +1 -0
  10. package/dist/builders/configBuilder.js +22 -0
  11. package/dist/builders/configBuilder.js.map +1 -0
  12. package/dist/builders/index.d.ts +12 -0
  13. package/dist/builders/index.d.ts.map +1 -0
  14. package/dist/builders/index.js +12 -0
  15. package/dist/builders/index.js.map +1 -0
  16. package/dist/builders/languageBuilder.d.ts +13 -0
  17. package/dist/builders/languageBuilder.d.ts.map +1 -0
  18. package/dist/builders/languageBuilder.js +18 -0
  19. package/dist/builders/languageBuilder.js.map +1 -0
  20. package/dist/builders/startAgentBuilder.d.ts +14 -0
  21. package/dist/builders/startAgentBuilder.d.ts.map +1 -0
  22. package/dist/builders/startAgentBuilder.js +35 -0
  23. package/dist/builders/startAgentBuilder.js.map +1 -0
  24. package/dist/builders/systemBuilder.d.ts +14 -0
  25. package/dist/builders/systemBuilder.d.ts.map +1 -0
  26. package/dist/builders/systemBuilder.js +22 -0
  27. package/dist/builders/systemBuilder.js.map +1 -0
  28. package/dist/builders/topicBuilder.d.ts +23 -0
  29. package/dist/builders/topicBuilder.d.ts.map +1 -0
  30. package/dist/builders/topicBuilder.js +77 -0
  31. package/dist/builders/topicBuilder.js.map +1 -0
  32. package/dist/builders/variablesBuilder.d.ts +14 -0
  33. package/dist/builders/variablesBuilder.d.ts.map +1 -0
  34. package/dist/builders/variablesBuilder.js +46 -0
  35. package/dist/builders/variablesBuilder.js.map +1 -0
  36. package/dist/formatters/index.d.ts +5 -0
  37. package/dist/formatters/index.d.ts.map +1 -0
  38. package/dist/formatters/index.js +5 -0
  39. package/dist/formatters/index.js.map +1 -0
  40. package/dist/formatters/yamlFormatter.d.ts +17 -0
  41. package/dist/formatters/yamlFormatter.d.ts.map +1 -0
  42. package/dist/formatters/yamlFormatter.js +226 -0
  43. package/dist/formatters/yamlFormatter.js.map +1 -0
  44. package/dist/generator.d.ts +60 -0
  45. package/dist/generator.d.ts.map +1 -0
  46. package/dist/generator.js +109 -0
  47. package/dist/generator.js.map +1 -0
  48. package/dist/index.d.ts +15 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +15 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/types.d.ts +178 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +7 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/utils/index.d.ts +5 -0
  57. package/dist/utils/index.d.ts.map +1 -0
  58. package/dist/utils/index.js +5 -0
  59. package/dist/utils/index.js.map +1 -0
  60. package/dist/utils/nameSanitizer.d.ts +30 -0
  61. package/dist/utils/nameSanitizer.d.ts.map +1 -0
  62. package/dist/utils/nameSanitizer.js +76 -0
  63. package/dist/utils/nameSanitizer.js.map +1 -0
  64. package/dist/validation.d.ts +46 -0
  65. package/dist/validation.d.ts.map +1 -0
  66. package/dist/validation.js +123 -0
  67. package/dist/validation.js.map +1 -0
  68. package/package.json +54 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2024-01-09
9
+
10
+ ### Added
11
+ - Initial release of AgentScript Migration Tool
12
+ - Core generator functionality (`AgentScriptGenerator` class)
13
+ - Convenience function (`generateAgentScript`)
14
+ - Comprehensive TypeScript type definitions
15
+ - Input validation with `ValidationError` class
16
+ - Support for all Salesforce action types (Flow, Apex, Standard Invocable, etc.)
17
+ - YAML formatting following Salesforce Agent Script Recipes spec
18
+ - Python-style boolean conversion (True/False)
19
+ - Compact YAML format for variables and actions
20
+ - Multi-line instruction formatting with `->` syntax
21
+ - Name sanitization for topics and actions
22
+ - Comprehensive test suite
23
+ - Example code demonstrating usage
24
+ - Full documentation
25
+
26
+ ### Features
27
+ - ✅ 85% automated migration from UI-based to code-based AgentScript
28
+ - ✅ Spec-compliant YAML generation
29
+ - ✅ Type-safe TypeScript interfaces
30
+ - ✅ Input validation and error handling
31
+ - ✅ Framework-agnostic design
32
+ - ✅ Zero runtime dependencies (except js-yaml)
33
+
34
+ ### Documentation
35
+ - Complete README with examples
36
+ - API documentation with JSDoc comments
37
+ - Publishing guide
38
+ - Example code in `/examples` directory
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SF Explorer Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,342 @@
1
+ # @sf-explorer/agentscript-migration-tool
2
+
3
+ Generate Salesforce Agent Script YAML from Agentforce planner configurations. This tool helps accelerate migration from UI-based Agentforce configurations to code-based AgentScript format.
4
+
5
+ ## Features
6
+
7
+ - ✅ **85% Automated Migration** - Generate complete agent scripts automatically
8
+ - ✅ **Spec Compliant** - Follows official [Salesforce Agent Script Recipes](https://developer.salesforce.com/sample-apps/agent-script-recipes/)
9
+ - ✅ **Type Safe** - Full TypeScript support with comprehensive interfaces
10
+ - ✅ **Zero Dependencies** - Only requires `js-yaml` for YAML generation
11
+ - ✅ **Framework Agnostic** - Works with any data structure matching the planner interface
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @sf-explorer/agentscript-migration-tool
17
+ ```
18
+
19
+ ### Requirements
20
+
21
+ - Node.js >= 18.x
22
+ - TypeScript >= 5.3 (for TypeScript projects)
23
+
24
+ ## Quick Example
25
+
26
+ ```typescript
27
+ import { generateAgentScript } from '@sf-explorer/agentscript-migration-tool'
28
+ import type { PlannerDefinition } from '@sf-explorer/agentscript-migration-tool'
29
+
30
+ const planner: PlannerDefinition = {
31
+ DeveloperName: "my_agent",
32
+ MasterLabel: "My Agent",
33
+ topics: [/* ... */]
34
+ }
35
+
36
+ const yaml = generateAgentScript(planner)
37
+ console.log(yaml)
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ```typescript
43
+ import { generateAgentScript } from '@sf-explorer/agentscript-migration-tool'
44
+ import type { PlannerDefinition } from '@sf-explorer/agentscript-migration-tool'
45
+
46
+ // Define your planner data
47
+ const planner: PlannerDefinition = {
48
+ DeveloperName: "customer_service_agent",
49
+ MasterLabel: "Customer Service Agent",
50
+ Metadata: {
51
+ description: "Assists customers with their service requests"
52
+ },
53
+ topics: [
54
+ {
55
+ DeveloperName: "Orders",
56
+ MasterLabel: "Orders",
57
+ Description: "Handle order-related inquiries",
58
+ actions: [
59
+ {
60
+ DeveloperName: "LookupOrder",
61
+ MasterLabel: "Lookup Order",
62
+ Description: "Look up order by ID",
63
+ InvocationTarget: "GetOrderDetails",
64
+ InvocationTargetType: "Flow",
65
+ Metadata: {
66
+ inputs: {
67
+ order_id: "string"
68
+ },
69
+ outputs: {
70
+ order_summary: "string"
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ ],
77
+ variables: [
78
+ {
79
+ DeveloperName: "customer_verified",
80
+ parameterName: "customer_verified",
81
+ mappingType: "Boolean",
82
+ description: "Whether customer is verified"
83
+ }
84
+ ]
85
+ }
86
+
87
+ // Generate Agent Script YAML
88
+ const yaml = generateAgentScript(planner, {
89
+ includeComments: true,
90
+ includeLanguageConfig: true
91
+ })
92
+
93
+ console.log(yaml)
94
+ ```
95
+
96
+ ## API
97
+
98
+ ### `generateAgentScript(planner, options?)`
99
+
100
+ Convenience function to generate Agent Script YAML.
101
+
102
+ **Parameters:**
103
+ - `planner: PlannerDefinition` - The planner definition object
104
+ - `options?: AgentScriptGenerationOptions` - Optional generation options
105
+
106
+ **Returns:** `string` - Generated YAML content
107
+
108
+ ### `AgentScriptGenerator`
109
+
110
+ Class-based generator for more control.
111
+
112
+ ```typescript
113
+ import { AgentScriptGenerator } from '@sf-explorer/agentscript-migration-tool'
114
+
115
+ const generator = new AgentScriptGenerator(planner, {
116
+ includeComments: true,
117
+ yamlIndent: 4,
118
+ includeLanguageConfig: true
119
+ })
120
+
121
+ const yaml = generator.generate()
122
+ ```
123
+
124
+ ### Generation Options
125
+
126
+ ```typescript
127
+ interface AgentScriptGenerationOptions {
128
+ includeComments?: boolean // Add header comments (default: true)
129
+ includeExamples?: boolean // Include example code (default: false)
130
+ yamlIndent?: number // YAML indentation (default: 4)
131
+ generateVariables?: boolean // Generate variables section (default: false)
132
+ includeLanguageConfig?: boolean // Include language block (default: true)
133
+ }
134
+ ```
135
+
136
+ ## Generated Structure
137
+
138
+ The tool generates complete Agent Script YAML following Salesforce patterns:
139
+
140
+ - **Config Block**: Agent metadata and configuration
141
+ - **System Block**: Global instructions and messages
142
+ - **Language Block**: Locale configuration (optional)
143
+ - **Variables**: State management variables (if provided)
144
+ - **Start Agent**: Topic selector with transitions
145
+ - **Topics**: Individual topics with reasoning and actions
146
+ - **Actions**: External integrations (Flow, Apex, API)
147
+
148
+ ### Example Output
149
+
150
+ ```yaml
151
+ # Agent Script
152
+ # Generated from GenAI Planner: Customer Service Agent
153
+ # Developer Name: customer_service_agent
154
+
155
+ config:
156
+ developer_name: "customer_service_agent"
157
+ default_agent_user: "agentforce@salesforce.com"
158
+ description: "Assists customers with their service requests"
159
+
160
+ system:
161
+ instructions: "You are a helpful assistant..."
162
+ messages:
163
+ welcome: "Hi, I'm your Customer Service Agent assistant..."
164
+ error: "Sorry, something went wrong..."
165
+
166
+ variables:
167
+ customer_verified: mutable boolean
168
+ description: "Whether customer is verified"
169
+
170
+ start_agent topic_selector:
171
+ description: "Welcome the user and determine the appropriate topic"
172
+ reasoning:
173
+ instructions: ->
174
+ | You are a topic selector assistant...
175
+ actions:
176
+ go_to_orders: @utils.transition to @topic.Orders
177
+ description: "Handle order-related inquiries"
178
+
179
+ topic Orders:
180
+ description: "Handle order-related inquiries"
181
+ reasoning:
182
+ instructions: ->
183
+ | Handle order-related inquiries.
184
+
185
+ Available actions:
186
+ - Use @actions.LookupOrder to Look up order by ID
187
+ actions:
188
+ LookupOrder: @actions.LookupOrder
189
+ description: "Look up order by ID"
190
+ actions:
191
+ LookupOrder:
192
+ description: "Look up order by ID"
193
+ inputs:
194
+ order_id: string
195
+ outputs:
196
+ order_summary: string
197
+ target: "flow://GetOrderDetails"
198
+ ```
199
+
200
+ ## Type Definitions
201
+
202
+ The package exports comprehensive TypeScript types:
203
+
204
+ - `PlannerDefinition` - Main input interface
205
+ - `PlannerTopic` - Topic definition
206
+ - `PlannerAction` - Action definition
207
+ - `PlannerVariable` - Variable definition
208
+ - `AgentScriptStructure` - Generated YAML structure
209
+ - `AgentScriptGenerationOptions` - Generation options
210
+
211
+ See the [types.ts](./src/types.ts) file for complete definitions.
212
+
213
+ ## Supported Action Types
214
+
215
+ The tool automatically formats action targets based on type:
216
+
217
+ - **Flow**: `flow://FlowName`
218
+ - **Apex**: `apex://ClassName`
219
+ - **Standard Invocable Action**: `standardInvocableAction://ActionName`
220
+ - **Generate Prompt Response**: `generatePromptResponse://TemplateName`
221
+ - **External Service**: `externalService://ServiceName`
222
+ - **Custom Protocols**: Preserved as-is
223
+
224
+ ## Migration Workflow
225
+
226
+ 1. **Extract Planner Data** - Get your planner configuration from Salesforce
227
+ 2. **Transform to Interface** - Map your data to `PlannerDefinition` interface
228
+ 3. **Generate YAML** - Use `generateAgentScript()` to create YAML
229
+ 4. **Review & Customize** - Add business logic and detailed instructions
230
+ 5. **Deploy** - Deploy to Salesforce using Salesforce CLI
231
+
232
+ ## Best Practices
233
+
234
+ ### 1. Start Small
235
+ Begin with 1-2 non-critical agents to learn the patterns.
236
+
237
+ ### 2. Review Generated Code
238
+ The generated script is 85% complete. Review and add:
239
+ - Detailed reasoning instructions
240
+ - Specific business rules
241
+ - Custom error handling
242
+ - Advanced routing logic
243
+
244
+ ### 3. Test Thoroughly
245
+ Always test in sandbox before production:
246
+ - Compare behavior with UI version
247
+ - Validate all topics
248
+ - Check action parameters
249
+ - Test error scenarios
250
+
251
+ ### 4. Version Control
252
+ Treat AgentScript like any code:
253
+ - Use Git for version control
254
+ - Code reviews
255
+ - Feature branches
256
+ - Documentation
257
+
258
+ ## Based on Salesforce Patterns
259
+
260
+ This implementation follows the official [Salesforce Agent Script Recipes](https://developer.salesforce.com/sample-apps/agent-script-recipes/getting-started/overview) including:
261
+
262
+ - **Language Essentials**: HelloWorld, VariableManagement, TemplateExpressions
263
+ - **Action Configuration**: ActionDefinitions, ActionCallbacks, AdvancedInputBindings
264
+ - **Architectural Patterns**: MultiTopicNavigation, SimpleQA, BidirectionalNavigation
265
+ - **Reasoning Mechanics**: ReasoningInstructions, BeforeAfterReasoning
266
+
267
+ ## Contributing
268
+
269
+ Contributions are welcome! Please:
270
+
271
+ 1. Fork the repository
272
+ 2. Create a feature branch
273
+ 3. Make your changes
274
+ 4. Add tests
275
+ 5. Submit a pull request
276
+
277
+ ## License
278
+
279
+ MIT
280
+
281
+ ## References
282
+
283
+ - [Salesforce Agent Script Recipes](https://developer.salesforce.com/sample-apps/agent-script-recipes/getting-started/overview)
284
+ - [Agentforce Documentation](https://developer.salesforce.com/docs/einstein/genai/guide/)
285
+ - [Agent Script Syntax Guide](https://developer.salesforce.com/sample-apps/agent-script-recipes/)
286
+
287
+ ## Error Handling
288
+
289
+ The package includes comprehensive error handling:
290
+
291
+ ```typescript
292
+ import { generateAgentScript, ValidationError } from '@sf-explorer/agentscript-migration-tool'
293
+
294
+ try {
295
+ const yaml = generateAgentScript(planner)
296
+ } catch (error) {
297
+ if (error instanceof ValidationError) {
298
+ console.error('Validation error:', error.message)
299
+ console.error('Field:', error.field)
300
+ } else {
301
+ console.error('Generation error:', error)
302
+ }
303
+ }
304
+ ```
305
+
306
+ ## Testing
307
+
308
+ Run the test suite:
309
+
310
+ ```bash
311
+ npm test
312
+ ```
313
+
314
+ Run tests with coverage:
315
+
316
+ ```bash
317
+ npm run test:coverage
318
+ ```
319
+
320
+ ## Support
321
+
322
+ For issues or questions:
323
+
324
+ 1. Check the [official recipes](https://developer.salesforce.com/sample-apps/agent-script-recipes/getting-started/overview)
325
+ 2. Review the [examples](./examples/) directory
326
+ 3. Review type definitions in `types.ts`
327
+ 4. Examine generator implementation in `generator.ts`
328
+ 5. Open an issue on GitHub
329
+
330
+ ## Contributing
331
+
332
+ Contributions are welcome! Please see our contributing guidelines:
333
+
334
+ 1. Fork the repository
335
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
336
+ 3. Make your changes
337
+ 4. Add tests for new functionality
338
+ 5. Ensure all tests pass (`npm test`)
339
+ 6. Commit your changes (`git commit -m 'Add amazing feature'`)
340
+ 7. Push to the branch (`git push origin feature/amazing-feature`)
341
+ 8. Open a Pull Request
342
+ # agentscript-migration-tool
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Action Builder
3
+ * Builds action definitions for Agent Script
4
+ */
5
+ import type { PlannerAction, AgentScriptActionDefinition } from "../types";
6
+ /**
7
+ * Build action target
8
+ * Formats target string based on invocation type
9
+ * Supports: flow://, apex://, standardInvocableAction://, generatePromptResponse://, and other protocols
10
+ *
11
+ * @param action - The action definition
12
+ * @returns Formatted target string
13
+ */
14
+ export declare function buildActionTarget(action: PlannerAction): string;
15
+ /**
16
+ * Build action inputs
17
+ * Extracts or generates input parameters
18
+ *
19
+ * @param action - The action definition
20
+ * @returns Record of input parameter definitions
21
+ */
22
+ export declare function buildActionInputs(action: PlannerAction): Record<string, string>;
23
+ /**
24
+ * Build action outputs
25
+ * Extracts or generates output parameters
26
+ *
27
+ * @param action - The action definition
28
+ * @returns Record of output parameter definitions
29
+ */
30
+ export declare function buildActionOutputs(action: PlannerAction): Record<string, string | Record<string, unknown>>;
31
+ /**
32
+ * Build action definition
33
+ * Converts PlannerAction to Agent Script action
34
+ *
35
+ * @param action - The action definition
36
+ * @returns AgentScriptActionDefinition
37
+ */
38
+ export declare function buildAction(action: PlannerAction): AgentScriptActionDefinition;
39
+ //# sourceMappingURL=actionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/actionBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAA;AAG1E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CA0C/D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBxB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBlD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,GACpB,2BAA2B,CAO7B"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Action Builder
3
+ * Builds action definitions for Agent Script
4
+ */
5
+ import { cleanDeveloperName } from "../utils/nameSanitizer";
6
+ /**
7
+ * Build action target
8
+ * Formats target string based on invocation type
9
+ * Supports: flow://, apex://, standardInvocableAction://, generatePromptResponse://, and other protocols
10
+ *
11
+ * @param action - The action definition
12
+ * @returns Formatted target string
13
+ */
14
+ export function buildActionTarget(action) {
15
+ if (action.InvocationTarget) {
16
+ const target = action.InvocationTarget;
17
+ const targetType = action.InvocationTargetType || "";
18
+ // If target already has a protocol, return as-is
19
+ if (target.includes("://") ||
20
+ target.startsWith("@") ||
21
+ target.startsWith("flow://") ||
22
+ target.startsWith("apex://") ||
23
+ target.startsWith("standardInvocableAction://") ||
24
+ target.startsWith("generatePromptResponse://")) {
25
+ return target;
26
+ }
27
+ // Map target type to protocol
28
+ switch (targetType.toLowerCase()) {
29
+ case "generatepromptresponse":
30
+ return `generatePromptResponse://${target}`;
31
+ case "flow":
32
+ return `flow://${cleanDeveloperName(action.DeveloperName || target)}`;
33
+ case "apex":
34
+ return `apex://${action.DeveloperName || target}`;
35
+ case "standardinvocableaction":
36
+ // For knowledge actions, use Source field if available (e.g., "KnowledgeArticleVersion")
37
+ // Otherwise use InvocationTarget
38
+ const source = action.Source;
39
+ const actionTarget = source || target;
40
+ return `standardInvocableAction://${actionTarget}`;
41
+ case "externalservice":
42
+ return `externalService://${cleanDeveloperName(action.DeveloperName || target)}`;
43
+ default:
44
+ // If target type is not recognized, return the target as-is
45
+ // (it might be a URL or other valid target)
46
+ return target;
47
+ }
48
+ }
49
+ // No InvocationTarget provided - use default
50
+ return "flow://DefaultFlow";
51
+ }
52
+ /**
53
+ * Build action inputs
54
+ * Extracts or generates input parameters
55
+ *
56
+ * @param action - The action definition
57
+ * @returns Record of input parameter definitions
58
+ */
59
+ export function buildActionInputs(action) {
60
+ const inputs = {};
61
+ // Try to extract from metadata
62
+ if (action.Metadata) {
63
+ const metadata = action.Metadata;
64
+ if (metadata.inputs) {
65
+ Object.entries(metadata.inputs).forEach(([key, value]) => {
66
+ inputs[key] = typeof value === "string" ? value : "string";
67
+ });
68
+ }
69
+ }
70
+ // Default input if none found
71
+ if (Object.keys(inputs).length === 0) {
72
+ inputs.query = "string";
73
+ }
74
+ return inputs;
75
+ }
76
+ /**
77
+ * Build action outputs
78
+ * Extracts or generates output parameters
79
+ *
80
+ * @param action - The action definition
81
+ * @returns Record of output parameter definitions
82
+ */
83
+ export function buildActionOutputs(action) {
84
+ const outputs = {};
85
+ // Try to extract from metadata
86
+ if (action.Metadata) {
87
+ const metadata = action.Metadata;
88
+ if (metadata.outputs) {
89
+ Object.entries(metadata.outputs).forEach(([key, value]) => {
90
+ if (typeof value === "object" && value !== null) {
91
+ outputs[key] = value;
92
+ }
93
+ else {
94
+ outputs[key] = typeof value === "string" ? value : "string";
95
+ }
96
+ });
97
+ }
98
+ }
99
+ // Default output if none found
100
+ if (Object.keys(outputs).length === 0) {
101
+ outputs.result = "string";
102
+ }
103
+ return outputs;
104
+ }
105
+ /**
106
+ * Build action definition
107
+ * Converts PlannerAction to Agent Script action
108
+ *
109
+ * @param action - The action definition
110
+ * @returns AgentScriptActionDefinition
111
+ */
112
+ export function buildAction(action) {
113
+ return {
114
+ description: action.Description || "Performs an action",
115
+ inputs: buildActionInputs(action),
116
+ outputs: buildActionOutputs(action),
117
+ target: buildActionTarget(action),
118
+ };
119
+ }
120
+ //# sourceMappingURL=actionBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionBuilder.js","sourceRoot":"","sources":["../../src/builders/actionBuilder.ts"],"names":[],"m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,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBAChD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAgC,CAAA;gBACjD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;gBAC7D,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAA;IAC3B,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAAqB;IAErB,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,oBAAoB;QACvD,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;QACjC,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC;QACnC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;KAClC,CAAA;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Config Block Builder
3
+ * Builds the config block for Agent Script
4
+ */
5
+ import type { PlannerDefinition, AgentScriptConfig } from "../types";
6
+ /**
7
+ * Build config block
8
+ * Defines agent metadata
9
+ *
10
+ * @param planner - The planner definition
11
+ * @returns AgentScriptConfig object
12
+ */
13
+ export declare function buildConfig(planner: PlannerDefinition): AgentScriptConfig;
14
+ //# sourceMappingURL=configBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/configBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAGpE;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAYzE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Config Block Builder
3
+ * Builds the config block for Agent Script
4
+ */
5
+ import { sanitizeString } from "../validation";
6
+ /**
7
+ * Build config block
8
+ * Defines agent metadata
9
+ *
10
+ * @param planner - The planner definition
11
+ * @returns AgentScriptConfig object
12
+ */
13
+ export function buildConfig(planner) {
14
+ const developerName = sanitizeString(planner.DeveloperName || "agent_assistant");
15
+ const description = sanitizeString(planner.Metadata?.description || "AI-powered assistant for your needs.");
16
+ return {
17
+ developer_name: developerName,
18
+ default_agent_user: "agentforce@salesforce.com",
19
+ description: description,
20
+ };
21
+ }
22
+ //# sourceMappingURL=configBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configBuilder.js","sourceRoot":"","sources":["../../src/builders/configBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAA0B;IACpD,MAAM,aAAa,GACjB,cAAc,CAAC,OAAO,CAAC,aAAa,IAAI,iBAAiB,CAAC,CAAA;IAC5D,MAAM,WAAW,GAAG,cAAc,CAChC,OAAO,CAAC,QAAQ,EAAE,WAAW,IAAI,sCAAsC,CACxE,CAAA;IAED,OAAO;QACL,cAAc,EAAE,aAAa;QAC7B,kBAAkB,EAAE,2BAA2B;QAC/C,WAAW,EAAE,WAAW;KACzB,CAAA;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Builder Module Exports
3
+ * Centralized exports for all builder functions
4
+ */
5
+ export * from "./configBuilder";
6
+ export * from "./systemBuilder";
7
+ export * from "./languageBuilder";
8
+ export * from "./variablesBuilder";
9
+ export * from "./topicBuilder";
10
+ export * from "./actionBuilder";
11
+ export * from "./startAgentBuilder";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Builder Module Exports
3
+ * Centralized exports for all builder functions
4
+ */
5
+ export * from "./configBuilder";
6
+ export * from "./systemBuilder";
7
+ export * from "./languageBuilder";
8
+ export * from "./variablesBuilder";
9
+ export * from "./topicBuilder";
10
+ export * from "./actionBuilder";
11
+ export * from "./startAgentBuilder";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builders/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Language Block Builder
3
+ * Builds the language block for Agent Script
4
+ */
5
+ import type { AgentScriptLanguageBlock } from "../types";
6
+ /**
7
+ * Build language block
8
+ * Defines locale configuration
9
+ *
10
+ * @returns AgentScriptLanguageBlock object
11
+ */
12
+ export declare function buildLanguage(): AgentScriptLanguageBlock;
13
+ //# sourceMappingURL=languageBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"languageBuilder.d.ts","sourceRoot":"","sources":["../../src/builders/languageBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAExD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,wBAAwB,CAMxD"}