@salesforce/afv-skills 1.6.9 → 1.7.1
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/README.md +28 -23
- package/package.json +1 -1
- package/skills/developing-agentforce/README.md +112 -0
- package/skills/{agentforce-development → developing-agentforce}/SKILL.md +109 -16
- package/skills/{agentforce-development → developing-agentforce}/assets/agents/README.md +2 -2
- package/skills/developing-agentforce/assets/agents/order-service.agent +272 -0
- package/skills/developing-agentforce/assets/agents/verification-gate.agent +280 -0
- package/skills/{agentforce-development → developing-agentforce}/assets/bundle-meta.xml +1 -1
- package/skills/{agentforce-development → developing-agentforce}/references/actions-reference.md +20 -0
- package/skills/{agentforce-development → developing-agentforce}/references/agent-design-and-spec-creation.md +1 -1
- package/skills/{agentforce-development → developing-agentforce}/references/agent-metadata-and-lifecycle.md +3 -3
- package/skills/{agentforce-development → developing-agentforce}/references/agent-script-core-language.md +40 -3
- package/skills/{agentforce-development → developing-agentforce}/references/agent-user-setup.md +60 -57
- package/skills/{agentforce-development → developing-agentforce}/references/agent-validation-and-debugging.md +22 -20
- package/skills/developing-agentforce/references/architecture-patterns.md +158 -0
- package/skills/developing-agentforce/references/complex-data-types.md +57 -0
- package/skills/developing-agentforce/references/deploy-reference.md +134 -0
- package/skills/developing-agentforce/references/discover-reference.md +102 -0
- package/skills/developing-agentforce/references/examples.md +350 -0
- package/skills/developing-agentforce/references/feature-validity.md +43 -0
- package/skills/developing-agentforce/references/instruction-resolution.md +545 -0
- package/skills/{agentforce-development → developing-agentforce}/references/known-issues.md +18 -18
- package/skills/{agentforce-development → developing-agentforce}/references/production-gotchas.md +24 -3
- package/skills/developing-agentforce/references/safety-review-reference.md +145 -0
- package/skills/{agentforce-development → developing-agentforce}/references/salesforce-cli-for-agents.md +9 -7
- package/skills/developing-agentforce/references/scaffold-reference.md +153 -0
- package/skills/developing-agentforce/references/scoring-rubric.md +24 -0
- package/skills/{agentforce-development → developing-agentforce}/references/version-history.md +2 -2
- package/skills/generating-flow/SKILL.md +3 -1
- package/skills/observing-agentforce/SKILL.md +368 -0
- package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls +1262 -0
- package/skills/observing-agentforce/apex/AgentforceOptimizeService.cls-meta.xml +5 -0
- package/skills/observing-agentforce/references/improve-reference.md +359 -0
- package/skills/observing-agentforce/references/issue-classification.md +220 -0
- package/skills/observing-agentforce/references/reproduce-reference.md +131 -0
- package/skills/observing-agentforce/references/stdm-queries.md +381 -0
- package/skills/observing-agentforce/references/stdm-schema.md +189 -0
- package/skills/testing-agentforce/SKILL.md +335 -0
- package/skills/testing-agentforce/assets/basic-test-spec.yaml +59 -0
- package/skills/testing-agentforce/assets/guardrail-test-spec.yaml +101 -0
- package/skills/testing-agentforce/assets/standard-test-spec.yaml +123 -0
- package/skills/testing-agentforce/references/action-execution.md +241 -0
- package/skills/testing-agentforce/references/batch-testing.md +274 -0
- package/skills/testing-agentforce/references/preview-testing.md +353 -0
- package/skills/testing-agentforce/references/test-report-format.md +160 -0
- package/skills/testing-agentforce/references/troubleshooting.md +73 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/README-legacy.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agent-spec-template.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/hello-world.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/multi-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/production-faq.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/production-faq.bundle-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/agents/simple-qa.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/apex/models-api-queueable.cls +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/apex-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/error-handling.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/escalation-setup.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/flow-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/n-ary-conditions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/components/topic-with-actions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/deterministic-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/escalation-pattern.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/flow-action-lookup.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/hub-and-spoke.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/invocable-apex-template.cls +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/local-info-agent-annotated.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-function-apex.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-function-flow.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/genai-plugin.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/http-callout-flow.flow-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/minimal-starter.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/README.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/action-callbacks.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/advanced-input-bindings.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/bidirectional-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/critical-input-collection.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/delegation-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/lifecycle-events.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/llm-controlled-actions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/multi-step-workflow.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/open-gate-routing.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/procedural-instructions.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/prompt-template-action.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/patterns/system-instruction-overrides.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/prompt-rag-search.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/template-multi-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/template-single-topic.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/assets/verification-gate.agent +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/action-prompt-templates.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/agent-access-guide.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/agent-topic-map-diagrams.md +0 -0
- /package/skills/{agentforce-development → developing-agentforce}/references/minimal-examples.md +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Architecture Patterns
|
|
2
|
+
|
|
3
|
+
> Extracted from SKILL.md Section 8. This file is loaded on demand when architecture pattern guidance is needed.
|
|
4
|
+
|
|
5
|
+
> All architecture patterns below work for both `AgentforceServiceAgent` and `AgentforceEmployeeAgent`. The only difference is that employee agents cannot use `@utils.escalate` or `connection messaging:` — replace escalation with a `@utils.transition` to a help topic or an action that creates a case/ticket.
|
|
6
|
+
|
|
7
|
+
## When to Use Each Pattern
|
|
8
|
+
|
|
9
|
+
| Pattern | Use When |
|
|
10
|
+
|---------|----------|
|
|
11
|
+
| Hub-and-Spoke | Agent has 2+ distinct topics with different intents (most common) |
|
|
12
|
+
| Verification Gate | Sensitive data, payments, or PII require identity verification first |
|
|
13
|
+
| Post-Action Loop | Actions produce state that drives follow-up logic (e.g., risk scoring) |
|
|
14
|
+
| Single Topic | Agent serves one focused purpose with no routing needed |
|
|
15
|
+
|
|
16
|
+
## Hub-and-Spoke (Most Common)
|
|
17
|
+
|
|
18
|
+
A central `topic_selector` routes to specialized spoke topics. Each spoke has a "back to hub" transition. Use when users may have multiple distinct intents.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
start_agent topic_selector:
|
|
22
|
+
description: "Route user requests to the appropriate topic"
|
|
23
|
+
reasoning:
|
|
24
|
+
instructions: |
|
|
25
|
+
You are a router only. Do NOT answer questions directly.
|
|
26
|
+
Always use a transition action to route immediately.
|
|
27
|
+
actions:
|
|
28
|
+
to_orders: @utils.transition to @topic.order_support
|
|
29
|
+
description: "Order questions"
|
|
30
|
+
to_returns: @utils.transition to @topic.return_support
|
|
31
|
+
description: "Return or refund requests"
|
|
32
|
+
to_general: @utils.transition to @topic.general_support
|
|
33
|
+
description: "General questions"
|
|
34
|
+
|
|
35
|
+
topic order_support:
|
|
36
|
+
description: "Handle order inquiries"
|
|
37
|
+
reasoning:
|
|
38
|
+
instructions: ->
|
|
39
|
+
| Help the customer with their order.
|
|
40
|
+
actions:
|
|
41
|
+
lookup: @actions.get_order
|
|
42
|
+
description: "Look up order"
|
|
43
|
+
back: @utils.transition to @topic.topic_selector
|
|
44
|
+
description: "Route to a different topic"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
> **Routing lives in `start_agent`** -- put all transition actions directly in `start_agent topic_selector:`. Do NOT create a separate routing-only topic (e.g. `main_menu`, `central_hub`) -- that duplicates the router, adds an extra LLM hop (~3-5s latency), and confuses the platform. Topics that need "go back" should transition to `@topic.topic_selector`.
|
|
48
|
+
|
|
49
|
+
## Verification Gate
|
|
50
|
+
|
|
51
|
+
Users must pass through identity verification before accessing protected topics. Use when handling sensitive data, payments, or PII.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
start_agent topic_selector:
|
|
55
|
+
description: "Route through identity verification"
|
|
56
|
+
reasoning:
|
|
57
|
+
instructions: |
|
|
58
|
+
You are a router only. Do NOT answer questions directly.
|
|
59
|
+
Route all users to identity verification first.
|
|
60
|
+
actions:
|
|
61
|
+
verify: @utils.transition to @topic.identity_verification
|
|
62
|
+
description: "Begin verification"
|
|
63
|
+
|
|
64
|
+
topic identity_verification:
|
|
65
|
+
description: "Verify customer identity"
|
|
66
|
+
reasoning:
|
|
67
|
+
instructions: ->
|
|
68
|
+
if @variables.failed_attempts >= 3:
|
|
69
|
+
| Too many failed attempts. Transferring to human agent.
|
|
70
|
+
transition to @topic.escalation
|
|
71
|
+
|
|
72
|
+
if @variables.is_verified == True:
|
|
73
|
+
| Identity verified! How can I help?
|
|
74
|
+
|
|
75
|
+
if @variables.is_verified == False:
|
|
76
|
+
| Please verify your identity.
|
|
77
|
+
|
|
78
|
+
actions:
|
|
79
|
+
verify_email: @actions.verify_identity
|
|
80
|
+
description: "Verify customer email"
|
|
81
|
+
set @variables.is_verified = @outputs.verified
|
|
82
|
+
|
|
83
|
+
to_account: @utils.transition to @topic.account_mgmt
|
|
84
|
+
description: "Account management"
|
|
85
|
+
available when @variables.is_verified == True
|
|
86
|
+
|
|
87
|
+
escalate_now: @utils.escalate
|
|
88
|
+
description: "Transfer to human"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Post-Action Loop
|
|
92
|
+
|
|
93
|
+
The topic re-resolves after an action completes. Place post-action checks at the TOP of `instructions: ->` so they trigger on the loop:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
reasoning:
|
|
97
|
+
instructions: ->
|
|
98
|
+
# POST-ACTION CHECK (at TOP - triggers on re-resolution)
|
|
99
|
+
if @variables.refund_status == "Approved":
|
|
100
|
+
run @actions.create_crm_case
|
|
101
|
+
with customer_id = @variables.customer_id
|
|
102
|
+
transition to @topic.confirmation
|
|
103
|
+
|
|
104
|
+
# PRE-LLM: Load data
|
|
105
|
+
run @actions.load_risk_score
|
|
106
|
+
with customer_id = @variables.customer_id
|
|
107
|
+
set @variables.risk_score = @outputs.score
|
|
108
|
+
|
|
109
|
+
# DYNAMIC INSTRUCTIONS
|
|
110
|
+
| Risk score: {!@variables.risk_score}
|
|
111
|
+
if @variables.risk_score >= 80:
|
|
112
|
+
| HIGH RISK - Offer retention package.
|
|
113
|
+
else:
|
|
114
|
+
| STANDARD - Follow normal process.
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Migrating to Hub-and-Spoke
|
|
118
|
+
|
|
119
|
+
When refactoring a flat agent (all logic in one topic) into hub-and-spoke:
|
|
120
|
+
|
|
121
|
+
1. **Identify distinct intents** — each becomes a spoke topic
|
|
122
|
+
2. **Move instructions and actions** from the monolithic topic into spoke topics. Each spoke needs BOTH its Level 1 action definitions (under `topic > actions`) AND Level 2 action invocations (under `topic > reasoning > actions`).
|
|
123
|
+
3. **Create `start_agent topic_selector:`** with transition actions pointing to each spoke
|
|
124
|
+
4. **Add "back to hub" transitions** in each spoke: `@utils.transition to @topic.topic_selector`
|
|
125
|
+
5. **Re-preview immediately** — verify topic routing works before making further changes
|
|
126
|
+
|
|
127
|
+
**Common migration mistakes:**
|
|
128
|
+
- Creating a separate `main_menu` topic instead of using `start_agent topic_selector:` as the hub — adds an unnecessary LLM hop
|
|
129
|
+
- Leaving action definitions in `start_agent` instead of moving them to spoke topics — all actions visible in all topics, confusing the planner
|
|
130
|
+
- Forgetting to add "back to hub" transitions — users get stuck in a spoke topic
|
|
131
|
+
- If trace shows `topic: "DefaultTopic"`, check that topic descriptions contain keywords matching test utterances
|
|
132
|
+
|
|
133
|
+
## Multi-Intent Handling
|
|
134
|
+
|
|
135
|
+
When a user sends multiple intents in one message, the start_agent router should handle the first intent and queue the second:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
instructions: |
|
|
139
|
+
You are a router only. Do NOT answer questions directly.
|
|
140
|
+
If the user asks about multiple topics in one message, route to the first
|
|
141
|
+
topic. After that task is complete, remind the user about the other request.
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Handling Incomplete Action Inputs
|
|
145
|
+
|
|
146
|
+
- Use `with param = ...` (slot-fill) for inputs the LLM should extract from conversation
|
|
147
|
+
- Add instructions that tell the LLM to invoke the action with whatever data is available
|
|
148
|
+
- Anti-pattern: Making the LLM ask for ALL inputs before invoking
|
|
149
|
+
|
|
150
|
+
## Controlling Opportunistic Action Chains
|
|
151
|
+
|
|
152
|
+
In long action chains (A->B->C->D), the LLM may invoke downstream actions as soon as prerequisites are met. To control this:
|
|
153
|
+
|
|
154
|
+
- Add explicit gating in instructions: "Only invoke generate_resolution if the user explicitly asks"
|
|
155
|
+
- Use `available when` guards on downstream actions
|
|
156
|
+
- Distinguish between "analyze only" and "full resolution" workflows in instructions
|
|
157
|
+
|
|
158
|
+
Anti-pattern: Leaving action chains ungated so the LLM runs the entire pipeline for every query.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!-- Parent: adlc-author/SKILL.md -->
|
|
2
|
+
|
|
3
|
+
# `complex_data_type_name` Mapping Table
|
|
4
|
+
|
|
5
|
+
> **"#1 source of compile errors"** - Use this table when defining action inputs/outputs in Agentforce Assets.
|
|
6
|
+
|
|
7
|
+
## Decision Tree: When Do I Need `complex_data_type_name`?
|
|
8
|
+
|
|
9
|
+
1. **Variable** with `number`? → Use `number` directly, no complex type needed
|
|
10
|
+
2. **Action I/O** with integer value, **Flow target** (`flow://`)? → Use `object` + `complex_data_type_name: "lightning__numberType"`
|
|
11
|
+
3. **Action I/O** with integer value, **Apex target** (`apex://`)? → Use `object` + `complex_data_type_name: "lightning__integerType"`
|
|
12
|
+
4. **Action input/output** with decimal value? → Use `object` + `complex_data_type_name: "lightning__doubleType"`
|
|
13
|
+
5. **Variable** with any other primitive? → Use the type directly (`string`, `boolean`, `date`)
|
|
14
|
+
6. **Action I/O** with non-primitive? → Use `object` + appropriate `complex_data_type_name` from table below
|
|
15
|
+
|
|
16
|
+
> **Key insight:** Bare `number` works in **variable declarations** but **fails at publish** in action inputs/outputs. This is the #1 cause of publish-fix-republish cycles.
|
|
17
|
+
|
|
18
|
+
> **CRITICAL: Target type matters!** The valid `complex_data_type_name` for integer values differs by target type:
|
|
19
|
+
> - **Flow targets** (`flow://`): Use `lightning__numberType` (NOT `lightning__integerType`)
|
|
20
|
+
> - **Apex targets** (`apex://`): Use `lightning__integerType` (NOT `lightning__numberType`)
|
|
21
|
+
> Using the wrong one causes a publish validation error.
|
|
22
|
+
|
|
23
|
+
## Full Mapping Table
|
|
24
|
+
|
|
25
|
+
| Data Type | `complex_data_type_name` Value | Notes |
|
|
26
|
+
|-----------|-------------------------------|-------|
|
|
27
|
+
| `string` | *(none needed)* | Primitive type — works in both variables and action I/O |
|
|
28
|
+
| `number` (variable only) | *(none needed)* | **Variables only** — do NOT use bare `number` in action I/O |
|
|
29
|
+
| `boolean` | *(none needed)* | Primitive type |
|
|
30
|
+
| `object` (SObject) | `lightning__recordInfoType` | Use for Account, Contact, etc. |
|
|
31
|
+
| `list[string]` | `lightning__textType` | Collection of text values |
|
|
32
|
+
| `list[object]` | `lightning__textType` | Serialized as JSON text |
|
|
33
|
+
| Apex Inner Class | `@apexClassType/NamespacedClass__InnerClass` | Namespace required |
|
|
34
|
+
| Custom LWC Type | `lightning__c__CustomTypeName` | Custom component types |
|
|
35
|
+
| Currency field | `lightning__currencyType` | For monetary values |
|
|
36
|
+
| `datetime` | `lightning__dateTimeStringType` | DateTime values |
|
|
37
|
+
| `integer` | `lightning__integerType` | Integer numbers (action I/O only) |
|
|
38
|
+
| `double` / `number` | `lightning__doubleType` | Decimal/floating-point numbers (action I/O only) |
|
|
39
|
+
| `object` (structured) | `lightning__objectType` | Complex data structures (action I/O only) |
|
|
40
|
+
| `list` (generic) | `lightning__listType` | Arrays/lists (action I/O only) |
|
|
41
|
+
|
|
42
|
+
> **Naming variance**: Upstream documentation uses `lightning__dateTimeType` while testing confirms `lightning__dateTimeStringType`. Both may be valid depending on API version — use `lightning__dateTimeStringType` as the tested default.
|
|
43
|
+
|
|
44
|
+
## Agent Script → Lightning Type Mapping
|
|
45
|
+
|
|
46
|
+
> Use this when troubleshooting type errors between Agent Script action I/O and Apex/Flow targets.
|
|
47
|
+
|
|
48
|
+
| Agent Script Type | Lightning Type | Apex Type | Notes |
|
|
49
|
+
|-------------------|---------------|-----------|-------|
|
|
50
|
+
| `string` | `lightning__textType` | `String` | No `complex_data_type_name` needed |
|
|
51
|
+
| `number` | `lightning__numberType` | `Decimal` / `Double` | No `complex_data_type_name` needed |
|
|
52
|
+
| `boolean` | `lightning__booleanType` | `Boolean` | No `complex_data_type_name` needed |
|
|
53
|
+
| `datetime` | `lightning__dateTimeStringType` | `DateTime` | **Actions only** — not valid for variables |
|
|
54
|
+
| `date` | `lightning__dateType` | `Date` | Valid for both variables and actions |
|
|
55
|
+
| `currency` | `lightning__currencyType` | `Decimal` | Annotated with currency type |
|
|
56
|
+
|
|
57
|
+
**Pro Tip**: Don't manually edit `complex_data_type_name` - use the UI dropdown in **Agentforce Assets > Action Definition**, then export/import the action definition.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Deploy -- Bundle Publication Reference
|
|
2
|
+
|
|
3
|
+
> Extracted from SKILL.md Section 18. This file is loaded on demand when deployment details are needed.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Full deployment lifecycle for Agentforce agents: validate, deploy metadata, publish bundle, and activate.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Validate + publish
|
|
13
|
+
sf agent publish authoring-bundle --json --api-name MyAgent -o <org-alias>
|
|
14
|
+
|
|
15
|
+
# Activate after publish
|
|
16
|
+
sf agent activate --json --api-name MyAgent -o <org-alias>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Deployment Phases
|
|
20
|
+
|
|
21
|
+
### Phase 0: Safety Gate (Required)
|
|
22
|
+
Read the `.agent` file and run safety review (see `safety-review-reference.md`). If any BLOCK finding exists, STOP deployment. WARN findings must be reported and acknowledged by the user before proceeding.
|
|
23
|
+
|
|
24
|
+
### Phase 1: Pre-Deployment Validation
|
|
25
|
+
```bash
|
|
26
|
+
sf agent validate authoring-bundle --json --api-name MyAgent -o <org-alias>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Phase 1b: Target Dependency Check
|
|
30
|
+
Verify all flow/apex targets exist in the org before publishing. If missing, scaffold and deploy them first.
|
|
31
|
+
|
|
32
|
+
### Phase 2: Deploy Supporting Metadata
|
|
33
|
+
```bash
|
|
34
|
+
sf project deploy start --json --source-dir force-app -o <org-alias>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Phase 3: Publish Agent Bundle
|
|
38
|
+
```bash
|
|
39
|
+
sf agent publish authoring-bundle --json --api-name MyAgent -o <org-alias>
|
|
40
|
+
```
|
|
41
|
+
4-step process: Validate (~1-2s) -> Publish (~8-10s) -> Retrieve (~5-7s) -> Deploy (~4-6s)
|
|
42
|
+
|
|
43
|
+
### Phase 4: Activate Agent
|
|
44
|
+
```bash
|
|
45
|
+
sf agent activate --json --api-name MyAgent -o <org-alias>
|
|
46
|
+
```
|
|
47
|
+
Note: `sf agent activate` may not support `--json` in all CLI versions. If it returns plain text, check for "successfully activated" in the output.
|
|
48
|
+
|
|
49
|
+
Publishing creates an **inactive** version. Without activation, preview fails with "No valid version available".
|
|
50
|
+
|
|
51
|
+
## Deploy vs Publish
|
|
52
|
+
|
|
53
|
+
| What changes | `sf project deploy start` | `sf agent publish authoring-bundle` |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| Bundle metadata | Yes | Yes |
|
|
56
|
+
| `system: instructions:` | Yes (via activate) | Yes |
|
|
57
|
+
| `reasoning: actions:` (transitions + invocations) | **NO** | Yes |
|
|
58
|
+
|
|
59
|
+
**Always prefer `sf agent publish authoring-bundle`.** If you change `reasoning: actions:`, publish is required.
|
|
60
|
+
|
|
61
|
+
## Common Errors
|
|
62
|
+
|
|
63
|
+
| Error | Cause | Fix |
|
|
64
|
+
|-------|-------|-----|
|
|
65
|
+
| `Required fields missing: [BundleType]` | Extra fields in bundle-meta.xml | Use minimal: only `<bundleType>AGENT</bundleType>` |
|
|
66
|
+
| `Internal Error, try again later` | Invalid default_agent_user or new agent platform bug | Query Einstein Agent Users; for new agents, create shell in Setup UI first |
|
|
67
|
+
| `Duplicate value found: GenAiPluginDefinition` | `start_agent` and `topic` share name | Use different names |
|
|
68
|
+
| `Flow not found` | Metadata not deployed | Deploy flows before publishing |
|
|
69
|
+
| `SetupEntityType is not supported for DML` | PermissionSet via Apex DML | Use Metadata API (`sf project deploy start`) |
|
|
70
|
+
|
|
71
|
+
## Rollback
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
sf agent deactivate --json --api-name MyAgent -o <org>
|
|
75
|
+
sf data query --json --query "SELECT Id, VersionNumber FROM BotVersion WHERE BotDefinition.DeveloperName = 'MyAgent' ORDER BY VersionNumber DESC LIMIT 2" -o <org>
|
|
76
|
+
sf agent activate --json --api-name MyAgent --version-number <previous> -o <org>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## CI/CD Integration
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
name: Deploy Agentforce Agent
|
|
83
|
+
on:
|
|
84
|
+
push:
|
|
85
|
+
branches: [main]
|
|
86
|
+
paths: ['force-app/**']
|
|
87
|
+
|
|
88
|
+
jobs:
|
|
89
|
+
deploy:
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/checkout@v3
|
|
93
|
+
- name: Install SF CLI
|
|
94
|
+
run: npm install -g @salesforce/cli
|
|
95
|
+
- name: Auth
|
|
96
|
+
run: |
|
|
97
|
+
echo "${{ secrets.SFDX_AUTH_URL }}" > auth.txt
|
|
98
|
+
sf org login sfdx-url --sfdx-url-file auth.txt --alias production
|
|
99
|
+
- name: Validate
|
|
100
|
+
run: sf agent validate authoring-bundle --json --api-name ${{ vars.AGENT_NAME }} -o production
|
|
101
|
+
- name: Deploy Metadata
|
|
102
|
+
run: sf project deploy start --json --source-dir force-app -o production
|
|
103
|
+
- name: Publish
|
|
104
|
+
run: sf agent publish authoring-bundle --json --api-name ${{ vars.AGENT_NAME }} -o production
|
|
105
|
+
- name: Activate
|
|
106
|
+
if: github.ref == 'refs/heads/main'
|
|
107
|
+
run: sf agent activate --json --api-name ${{ vars.AGENT_NAME }} -o production
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Pre-Deployment Checklist
|
|
111
|
+
|
|
112
|
+
- [ ] All action targets exist in org (run discover first)
|
|
113
|
+
- [ ] Agent Script validated (no syntax errors)
|
|
114
|
+
- [ ] Einstein Agent User configured correctly
|
|
115
|
+
- [ ] Supporting metadata deployed
|
|
116
|
+
- [ ] Previous version backed up
|
|
117
|
+
- [ ] Rollback plan documented
|
|
118
|
+
|
|
119
|
+
## Post-Deployment Testing
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sf agent preview start --json --use-live-actions --authoring-bundle MyAgent -o <org>
|
|
123
|
+
# Read sessionId from the JSON response, then:
|
|
124
|
+
sf agent preview send --json --authoring-bundle MyAgent --session-id <SESSION_ID> -u "Hello, I need help" -o <org>
|
|
125
|
+
sf agent preview end --json --authoring-bundle MyAgent --session-id <SESSION_ID> -o <org>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Exit Codes
|
|
129
|
+
|
|
130
|
+
| Code | Meaning |
|
|
131
|
+
|------|---------|
|
|
132
|
+
| 0 | Success |
|
|
133
|
+
| 1 | Validation/deployment failed |
|
|
134
|
+
| 2 | Critical failure |
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Discover -- Target Discovery Reference
|
|
2
|
+
|
|
3
|
+
> Extracted from SKILL.md Section 16. This file is loaded on demand when target discovery details are needed.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Validates that Agent Script `.agent` file targets actually exist in a Salesforce org, providing fuzzy suggestions for missing targets.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# List all active autolaunched flows (candidate action targets)
|
|
13
|
+
sf api request rest --json "/services/data/v63.0/tooling/query?q=SELECT+DeveloperName,ProcessType+FROM+Flow+WHERE+IsActive=true+AND+ProcessType='AutoLaunchedFlow'" -o <org-alias>
|
|
14
|
+
|
|
15
|
+
# List all @InvocableMethod Apex classes
|
|
16
|
+
sf api request rest --json "/services/data/v63.0/tooling/query?q=SELECT+Name+FROM+ApexClass+WHERE+Body+LIKE+'%25InvocableMethod%25'" -o <org-alias>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What it does
|
|
20
|
+
|
|
21
|
+
### 1. Target Extraction
|
|
22
|
+
- Finds all `.agent` files in the project
|
|
23
|
+
- Parses each file to extract action `target:` values
|
|
24
|
+
- Identifies target types: `flow://`, `apex://`, `retriever://`, `externalService://`, `generatePromptResponse://`
|
|
25
|
+
|
|
26
|
+
### 2. Org Validation
|
|
27
|
+
|
|
28
|
+
| Target Type | SOQL Query | Object Checked |
|
|
29
|
+
|-------------|------------|----------------|
|
|
30
|
+
| `flow://FlowName` | `SELECT ApiName FROM FlowDefinitionView WHERE ApiName = 'FlowName' AND IsActive = true` | Active flows only |
|
|
31
|
+
| `apex://ClassName` | `SELECT Name FROM ApexClass WHERE Name = 'ClassName'` | Apex classes |
|
|
32
|
+
| `retriever://RetrieverName` | `SELECT DeveloperName FROM DataKnowledgeSpace WHERE DeveloperName = 'RetrieverName'` | Data Cloud retrievers |
|
|
33
|
+
| `externalService://ServiceName` | `SELECT DeveloperName FROM ExternalServiceRegistration WHERE DeveloperName = 'ServiceName'` | External services |
|
|
34
|
+
| `generatePromptResponse://TemplateName` | `SELECT DeveloperName FROM PromptTemplate WHERE DeveloperName = 'TemplateName' AND Status = 'Active'` | Active prompt templates |
|
|
35
|
+
|
|
36
|
+
### 3. Fuzzy Matching
|
|
37
|
+
When a target is missing:
|
|
38
|
+
- Queries for similar names using SOQL `LIKE` patterns
|
|
39
|
+
- Calculates Levenshtein distance for close matches
|
|
40
|
+
- Suggests up to 3 alternatives sorted by similarity
|
|
41
|
+
|
|
42
|
+
### 4. I/O Parameter Validation (--validate-io)
|
|
43
|
+
- **Flows:** Queries `/services/data/v63.0/actions/custom/flow/{FlowApiName}` for actual I/O schema
|
|
44
|
+
- **Apex:** Checks `@InvocableVariable` field names match expected inputs/outputs
|
|
45
|
+
- Results appear as non-blocking warnings
|
|
46
|
+
|
|
47
|
+
### 5. Classification for Scaffold Pipeline
|
|
48
|
+
|
|
49
|
+
| Signal in Description | Classification | Scaffold Output |
|
|
50
|
+
|----------------------|---------------|-----------------|
|
|
51
|
+
| "API", "HTTP", "REST", "external", URL | `callout` | Apex with Http + Remote Site + Custom Metadata |
|
|
52
|
+
| SObject names, "query", "record", "SOQL" | `soql` | Apex with SOQL query logic |
|
|
53
|
+
| No special signals | `basic` | Standard placeholder Apex |
|
|
54
|
+
|
|
55
|
+
## Output Format
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
Agentforce ADLC Discovery Report
|
|
59
|
+
|
|
60
|
+
Agent: OrderManagement
|
|
61
|
+
Topic: order_inquiry
|
|
62
|
+
Action: get_order_status
|
|
63
|
+
Target: flow://Get_Order_Status Found
|
|
64
|
+
Action: track_shipment
|
|
65
|
+
Target: flow://Track_Shipment_Flow MISSING
|
|
66
|
+
Suggestions:
|
|
67
|
+
- Track_Shipping_Flow (distance: 2)
|
|
68
|
+
|
|
69
|
+
Summary: 2/3 targets found (66.7%)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Next Steps
|
|
73
|
+
|
|
74
|
+
- Missing targets: Run scaffold to generate stubs (see `scaffold-reference.md`)
|
|
75
|
+
- All found: Deploy (`sf agent publish authoring-bundle --json --api-name <AgentName> -o <org-alias>`)
|
|
76
|
+
|
|
77
|
+
## Error Handling
|
|
78
|
+
|
|
79
|
+
| Error | Cause | Resolution |
|
|
80
|
+
|-------|-------|------------|
|
|
81
|
+
| `No .agent files found` | Wrong directory | Check `--agent-file` path |
|
|
82
|
+
| `Invalid org alias` | Org not authenticated | Run `sf org login web --alias <org-alias>` |
|
|
83
|
+
| `SOQL query failed` | Missing permissions | Ensure read access to Flow, ApexClass, etc. |
|
|
84
|
+
|
|
85
|
+
## Exit Codes
|
|
86
|
+
|
|
87
|
+
| Code | Meaning |
|
|
88
|
+
|------|---------|
|
|
89
|
+
| 0 | All targets found |
|
|
90
|
+
| 1 | Some targets missing |
|
|
91
|
+
| 2 | Critical failure |
|
|
92
|
+
|
|
93
|
+
## Advanced (requires ADLC repo clone)
|
|
94
|
+
|
|
95
|
+
The `discover.py` script provides automated discovery with fuzzy matching and I/O validation. It is NOT bundled with the skill — requires cloning the ADLC repo.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# From ADLC repo root:
|
|
99
|
+
python3 scripts/discover.py -o <org-alias> --agent-file <path-to-agent-file>
|
|
100
|
+
python3 scripts/discover.py -o <org-alias> --agent-dir force-app/main/default/aiAuthoringBundles
|
|
101
|
+
python3 scripts/discover.py -o <org-alias> --agent-file MyAgent.agent --validate-io
|
|
102
|
+
```
|