@salesforce/afv-skills 1.30.0 → 1.32.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 (126) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-bot-upgrade/SKILL.md +217 -0
  3. package/skills/agentforce-bot-upgrade/references/extraction-blueprint.md +242 -0
  4. package/skills/agentforce-bot-upgrade/references/generate-agent-spec.md +128 -0
  5. package/skills/agentforce-bot-upgrade/references/handoff-output-format.md +208 -0
  6. package/skills/agentforce-bot-upgrade/references/input-contract.md +101 -0
  7. package/skills/agentforce-bot-upgrade/references/mapping-rules.md +113 -0
  8. package/skills/agentforce-bot-upgrade/references/planner-workflow-reference.md +78 -0
  9. package/skills/agentforce-bot-upgrade/references/post-conversion-enhancements-reference.md +67 -0
  10. package/skills/agentforce-bot-upgrade/references/quality-checklist.md +33 -0
  11. package/skills/agentforce-bot-upgrade/references/sf-cli-bot-reference.md +116 -0
  12. package/skills/data360-code-extension-generate/SKILL.md +15 -2
  13. package/skills/dx-devops-work-item-manage/SKILL.md +270 -0
  14. package/skills/dx-devops-work-item-manage/examples/common-workflows.md +479 -0
  15. package/skills/dx-devops-work-item-manage/references/cli-commands.md +476 -0
  16. package/skills/dx-org-manage/SKILL.md +8 -5
  17. package/skills/dx-org-trial-expiration-check/SKILL.md +239 -0
  18. package/skills/dx-org-trial-expiration-check/scripts/check_expiration.sh +588 -0
  19. package/skills/dx-pkg-post-install-configure/SKILL.md +184 -0
  20. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +202 -35
  21. package/skills/experience-ui-bundle-app-coordinate/scripts/check-hosting-target.sh +26 -0
  22. package/skills/experience-ui-bundle-app-coordinate/scripts/check-sfdx-project.sh +15 -0
  23. package/skills/experience-ui-bundle-custom-app-generate/SKILL.md +29 -5
  24. package/skills/experience-ui-bundle-custom-app-generate/references/configure-metadata-custom-application.md +1 -1
  25. package/skills/experience-ui-bundle-custom-app-generate/scripts/resolve-uibundle-path.sh +30 -0
  26. package/skills/experience-ui-bundle-features-generate/SKILL.md +86 -11
  27. package/skills/experience-ui-bundle-features-generate/references/conflict-resolution-schema.json +20 -0
  28. package/skills/experience-ui-bundle-features-generate/scripts/verify-react-bundle.sh +14 -0
  29. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +6 -1
  30. package/skills/experience-ui-bundle-frontend-generate/references/component.md +34 -1
  31. package/skills/experience-ui-bundle-frontend-generate/references/page.md +1 -1
  32. package/skills/experience-ui-bundle-metadata-generate/SKILL.md +19 -8
  33. package/skills/experience-ui-bundle-metadata-generate/references/csp-metadata-format.md +2 -2
  34. package/skills/experience-ui-bundle-metadata-generate/scripts/check-api-version.sh +30 -0
  35. package/skills/experience-ui-bundle-project-generate/SKILL.md +111 -0
  36. package/skills/experience-ui-bundle-project-generate/scripts/flatten-project.mjs +33 -0
  37. package/skills/platform-custom-field-generate/SKILL.md +12 -11
  38. package/skills/platform-custom-field-generate/references/advanced-picklists.md +17 -17
  39. package/skills/platform-custom-lightning-type-generate/SKILL.md +9 -14
  40. package/skills/platform-custom-lightning-type-generate/references/widget-rendition.md +27 -111
  41. package/skills/platform-custom-report-type-generate/SKILL.md +259 -0
  42. package/skills/platform-custom-report-type-generate/examples/AccountProjectsWithTasks.reportType-meta.xml +51 -0
  43. package/skills/platform-custom-report-type-generate/examples/AccountsWithIndustry.reportType-meta.xml +27 -0
  44. package/skills/platform-custom-report-type-generate/examples/AccountsWithProjects.reportType-meta.xml +44 -0
  45. package/skills/platform-custom-report-type-generate/references/category-values.md +32 -0
  46. package/skills/platform-custom-report-type-generate/references/errors-and-troubleshooting.md +24 -0
  47. package/skills/platform-dataspace-access-configure/SKILL.md +318 -0
  48. package/skills/platform-docs-get/SKILL.md +4 -0
  49. package/skills/platform-docs-get/scripts/extract_salesforce_doc.py +78 -13
  50. package/skills/platform-encryption-configure/SKILL.md +122 -0
  51. package/skills/platform-encryption-configure/assets/EncryptionKey.settings-meta.xml +17 -0
  52. package/skills/platform-encryption-configure/assets/PlatformEncryption.settings-meta.xml +15 -0
  53. package/skills/platform-encryption-configure/assets/encrypted-field.field-meta.xml +22 -0
  54. package/skills/platform-encryption-configure/examples/cache-only-keys.settings-meta.xml +11 -0
  55. package/skills/platform-encryption-configure/references/encryption-schemes.md +34 -0
  56. package/skills/platform-encryption-configure/references/key-models.md +34 -0
  57. package/skills/platform-encryption-configure/references/tenant-secret-lifecycle.md +23 -0
  58. package/skills/platform-encryption-configure/scripts/validate-encryption-metadata.sh +54 -0
  59. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +214 -0
  60. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +80 -0
  61. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +75 -0
  62. package/skills/platform-lightning-type-widget-coordinate/references/build-plan-format.md +67 -0
  63. package/skills/platform-lightning-type-widget-coordinate/references/lightning-type-discovery.md +124 -0
  64. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +130 -0
  65. package/skills/platform-metadata-api-context-get/SKILL.md +13 -10
  66. package/skills/platform-sharing-owd-configure/SKILL.md +142 -0
  67. package/skills/platform-sharing-owd-configure/examples/get_owd_output.md +38 -0
  68. package/skills/platform-sharing-owd-configure/examples/update_owd_output.md +44 -0
  69. package/skills/platform-sharing-owd-configure/references/access_levels.md +49 -0
  70. package/skills/platform-sharing-owd-configure/references/metadata_api_approach.md +69 -0
  71. package/skills/platform-sharing-rules-generate/SKILL.md +89 -19
  72. package/skills/platform-sharing-rules-generate/examples/test-cases.md +381 -0
  73. package/skills/platform-widget-generate/SKILL.md +241 -0
  74. package/skills/platform-widget-generate/examples/conditional.json +73 -0
  75. package/skills/platform-widget-generate/examples/list-with-foreach.json +66 -0
  76. package/skills/platform-widget-generate/examples/single-object.json +64 -0
  77. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +76 -0
  78. package/skills/platform-widget-generate/references/widget-bundle-layout.md +116 -0
  79. package/skills/platform-widget-generate/references/widget-meta-directives.md +130 -0
  80. package/skills/sales-agentforce-pipeline-management-configure/SKILL.md +268 -0
  81. package/skills/sales-agentforce-pipeline-management-configure/assets/field-completion-template.genAiPromptTemplate-meta.xml +141 -0
  82. package/skills/sales-agentforce-pipeline-management-configure/assets/pipeline_management_flow.flow-meta.xml +548 -0
  83. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.agent +2938 -0
  84. package/skills/sales-agentforce-pipeline-management-configure/assets/sales_management_agent.bundle-meta.xml +4 -0
  85. package/skills/sales-agentforce-pipeline-management-configure/assets/sfdx-project.json +12 -0
  86. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/bant.txt +11 -0
  87. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/meddic.txt +11 -0
  88. package/skills/sales-agentforce-pipeline-management-configure/assets/stage-descriptions/spiced.txt +11 -0
  89. package/skills/sales-agentforce-pipeline-management-configure/examples/custom-prompt-instructions.md +317 -0
  90. package/skills/sales-agentforce-pipeline-management-configure/references/admin-communication.md +355 -0
  91. package/skills/sales-agentforce-pipeline-management-configure/references/agent-creation.md +383 -0
  92. package/skills/sales-agentforce-pipeline-management-configure/references/auth-and-cli.md +146 -0
  93. package/skills/sales-agentforce-pipeline-management-configure/references/automation-matrix.md +23 -0
  94. package/skills/sales-agentforce-pipeline-management-configure/references/autonomous-updates.md +215 -0
  95. package/skills/sales-agentforce-pipeline-management-configure/references/canonical-agent-path.md +75 -0
  96. package/skills/sales-agentforce-pipeline-management-configure/references/data-sources.md +155 -0
  97. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompt-template.md +120 -0
  98. package/skills/sales-agentforce-pipeline-management-configure/references/field-completion-prompts.md +149 -0
  99. package/skills/sales-agentforce-pipeline-management-configure/references/flags.md +13 -0
  100. package/skills/sales-agentforce-pipeline-management-configure/references/flow-clone-from-template.md +447 -0
  101. package/skills/sales-agentforce-pipeline-management-configure/references/metadata-inventory.md +330 -0
  102. package/skills/sales-agentforce-pipeline-management-configure/references/opportunity-stages.md +246 -0
  103. package/skills/sales-agentforce-pipeline-management-configure/references/repair-diagnostics.md +265 -0
  104. package/skills/sales-agentforce-pipeline-management-configure/references/setup-order.md +263 -0
  105. package/skills/sales-agentforce-pipeline-management-configure/references/soap-api-enablement.md +528 -0
  106. package/skills/sales-agentforce-pipeline-management-configure/scripts/CHANGES.md +180 -0
  107. package/skills/sales-agentforce-pipeline-management-configure/scripts/README.md +56 -0
  108. package/skills/sales-agentforce-pipeline-management-configure/scripts/add-field-suggestion.sh +679 -0
  109. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-agent.sh +302 -0
  110. package/skills/sales-agentforce-pipeline-management-configure/scripts/create-flow.sh +250 -0
  111. package/skills/sales-agentforce-pipeline-management-configure/scripts/define-agent-access.sh +430 -0
  112. package/skills/sales-agentforce-pipeline-management-configure/scripts/deploy-settings.sh +77 -0
  113. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-deal-agent.sh +241 -0
  114. package/skills/sales-agentforce-pipeline-management-configure/scripts/enable-prerequisites.sh +538 -0
  115. package/skills/sales-agentforce-pipeline-management-configure/scripts/flow-debug-and-verify.sh +385 -0
  116. package/skills/sales-agentforce-pipeline-management-configure/scripts/retrieve-settings.sh +131 -0
  117. package/skills/sales-agentforce-pipeline-management-configure/scripts/setup-all.sh +2791 -0
  118. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-bundle-publish.sh +189 -0
  119. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/agent-detection.sh +239 -0
  120. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/flow-builder.sh +238 -0
  121. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/psg.sh +48 -0
  122. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/soap.sh +140 -0
  123. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/stage-descriptions.sh +448 -0
  124. package/skills/sales-agentforce-pipeline-management-configure/scripts/shared/test-opp.sh +166 -0
  125. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-all.sh +636 -0
  126. package/skills/sales-agentforce-pipeline-management-configure/scripts/verify-prompt-generation.sh +346 -0
@@ -0,0 +1,538 @@
1
+ #!/bin/bash
2
+
3
+ # Enable all prerequisite settings for Pipeline Management
4
+ # Usage: ./enable-prerequisites.sh <org-alias>
5
+
6
+ set -euo pipefail
7
+
8
+ # sf CLI can emit ANSI color codes inside --json stdout, breaking jq parsing.
9
+ # 2>/dev/null only strips stderr; these env vars are the reliable fix (see PM notes).
10
+ export NO_COLOR=1
11
+ export FORCE_COLOR=0
12
+
13
+ # Source shared SOAP parsing library
14
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ source "$SCRIPT_DIR/shared/soap.sh"
16
+
17
+ ORG_ALIAS="${1:-}"
18
+
19
+ if [[ -z "$ORG_ALIAS" ]]; then
20
+ echo "❌ Error: Missing org alias"
21
+ echo "Usage: $0 <org-alias>"
22
+ exit 1
23
+ fi
24
+
25
+ if [[ ! -f "sfdx-project.json" ]]; then
26
+ echo "❌ Error: sfdx-project.json not found in current directory"
27
+ echo "Copy from ../assets/sfdx-project.json first"
28
+ exit 1
29
+ fi
30
+
31
+ echo "🚀 Enabling Pipeline Management prerequisites for org: $ORG_ALIAS"
32
+ echo ""
33
+
34
+ # Get org details
35
+ ORG_INFO=$(sf org display --target-org "$ORG_ALIAS" --json 2>/dev/null)
36
+ ORG_ID=$(echo "$ORG_INFO" | jq -r '.result.id')
37
+ INSTANCE_URL=$(echo "$ORG_INFO" | jq -r '.result.instanceUrl')
38
+ ACCESS_TOKEN=$(echo "$ORG_INFO" | jq -r '.result.accessToken')
39
+
40
+ # Newer CLI versions redact accessToken — use show-access-token fallback
41
+ if [[ -z "$ACCESS_TOKEN" || "$ACCESS_TOKEN" == "null" || "$ACCESS_TOKEN" == *"REDACTED"* ]]; then
42
+ ACCESS_TOKEN=$(echo "y" | sf org auth show-access-token --target-org "$ORG_ALIAS" --no-prompt --json 2>/dev/null | jq -r '.result.accessToken // empty')
43
+ fi
44
+
45
+ if [[ -z "$ORG_ID" || -z "$INSTANCE_URL" || -z "$ACCESS_TOKEN" || "$ACCESS_TOKEN" == "null" ]]; then
46
+ echo "Error: Could not retrieve org details. Is the org authenticated?"
47
+ exit 1
48
+ fi
49
+
50
+ echo "Org ID: $ORG_ID"
51
+ echo "Instance URL: $INSTANCE_URL"
52
+ echo ""
53
+
54
+ # Function to enable setting via SOAP API
55
+ enable_via_soap() {
56
+ local SETTING_NAME="$1"
57
+ local DISPLAY_NAME="$2"
58
+ local FIELD_NAME="$3"
59
+ local API_VERSION="${4:-62.0}"
60
+
61
+ echo -n "Enabling ${DISPLAY_NAME}... "
62
+
63
+ # Check if already enabled
64
+ local QUERY="SELECT ${FIELD_NAME} FROM ${SETTING_NAME}"
65
+ local CURRENT_VALUE
66
+ CURRENT_VALUE=$(sf data query --query "$QUERY" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -r ".result.records[0].${FIELD_NAME}")
67
+
68
+ if [[ "$CURRENT_VALUE" == "true" ]]; then
69
+ echo "✅ (already enabled)"
70
+ return 0
71
+ fi
72
+
73
+ # Build SOAP request
74
+ local SOAP_REQUEST
75
+ SOAP_REQUEST=$(cat <<EOF
76
+ <?xml version="1.0" encoding="utf-8"?>
77
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
78
+ <soapenv:Header>
79
+ <met:SessionHeader>
80
+ <met:sessionId>${ACCESS_TOKEN}</met:sessionId>
81
+ </met:SessionHeader>
82
+ </soapenv:Header>
83
+ <soapenv:Body>
84
+ <met:updateMetadata>
85
+ <met:metadata xsi:type="met:${SETTING_NAME}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
86
+ <met:fullName>${SETTING_NAME}</met:fullName>
87
+ <met:${FIELD_NAME}>true</met:${FIELD_NAME}>
88
+ </met:metadata>
89
+ </met:updateMetadata>
90
+ </soapenv:Body>
91
+ </soapenv:Envelope>
92
+ EOF
93
+ )
94
+
95
+ # Send SOAP request
96
+ local RESPONSE
97
+ RESPONSE=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/${API_VERSION}" \
98
+ -H "Content-Type: text/xml; charset=utf-8" \
99
+ -H "SOAPAction: update" \
100
+ -d "$SOAP_REQUEST")
101
+
102
+ if echo "$RESPONSE" | grep -q "<success>true</success>"; then
103
+ echo "✅"
104
+ return 0
105
+ else
106
+ echo "❌"
107
+ echo "SOAP Response: $RESPONSE"
108
+ return 1
109
+ fi
110
+ }
111
+
112
+ # Function to enable setting via CLI retrieve+modify+deploy
113
+ enable_via_cli() {
114
+ local SETTING_NAME="$1"
115
+ local DISPLAY_NAME="$2"
116
+ local FIELD_NAME="$3"
117
+ local FIELD_VALUE="${4:-true}"
118
+
119
+ echo -n "Enabling ${DISPLAY_NAME}... "
120
+
121
+ # Check if already enabled
122
+ local QUERY="SELECT ${FIELD_NAME} FROM ${SETTING_NAME}"
123
+ local CURRENT_VALUE
124
+ CURRENT_VALUE=$(sf data query --query "$QUERY" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -r ".result.records[0].${FIELD_NAME}" 2>/dev/null || echo "null")
125
+
126
+ if [[ "$CURRENT_VALUE" == "$FIELD_VALUE" || "$CURRENT_VALUE" == "true" ]]; then
127
+ echo "✅ (already enabled)"
128
+ return 0
129
+ fi
130
+
131
+ # Retrieve current settings
132
+ local SETTINGS_DIR="force-app/main/default/settings"
133
+ mkdir -p "$SETTINGS_DIR"
134
+
135
+ if ! sf project retrieve start --metadata "Settings:${SETTING_NAME}" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -e '.status == 0' >/dev/null 2>&1; then
136
+ echo "❌ (retrieve failed)"
137
+ return 1
138
+ fi
139
+
140
+ local SETTINGS_FILE="${SETTINGS_DIR}/${SETTING_NAME}.settings-meta.xml"
141
+
142
+ if [[ ! -f "$SETTINGS_FILE" ]]; then
143
+ echo "❌ (file not found after retrieve)"
144
+ return 1
145
+ fi
146
+
147
+ # Modify setting using sed (non-greedy)
148
+ if grep -q "<${FIELD_NAME}>" "$SETTINGS_FILE"; then
149
+ # Update existing field
150
+ sed -i.bak "0,/<${FIELD_NAME}>[^<]*<\/${FIELD_NAME}>/s|<${FIELD_NAME}>[^<]*</${FIELD_NAME}>|<${FIELD_NAME}>${FIELD_VALUE}</${FIELD_NAME}>|" "$SETTINGS_FILE"
151
+ else
152
+ # Insert field before closing tag
153
+ sed -i.bak "/<\/.*Settings>/i\\
154
+ <${FIELD_NAME}>${FIELD_VALUE}</${FIELD_NAME}>" "$SETTINGS_FILE"
155
+ fi
156
+
157
+ # Deploy
158
+ if sf project deploy start --source-dir "$SETTINGS_DIR" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -e '.status == 0' >/dev/null 2>&1; then
159
+ echo "✅"
160
+ rm -f "${SETTINGS_FILE}.bak"
161
+ return 0
162
+ else
163
+ echo "❌ (deploy failed)"
164
+ mv "${SETTINGS_FILE}.bak" "$SETTINGS_FILE" 2>/dev/null || true
165
+ return 1
166
+ fi
167
+ }
168
+
169
+ # Read a settings boolean via SOAP readMetadata and classify the response using
170
+ # the shared shared/soap.sh parser. Distinguishes a genuine "false" from an
171
+ # auth/SOAP fault or a network/service error instead of collapsing all three to
172
+ # empty (the W-23215519 bug). Captures the HTTP status so 5xx/HTML error pages
173
+ # are not mistaken for a disabled setting.
174
+ # Args: $1 = metadata type, $2 = fullName, $3 = field name
175
+ # Echoes: "true" | "false" | "AUTH_ERROR:..." | "TYPE_UNAVAILABLE:..." | "NETWORK_ERROR"
176
+ read_setting_status() {
177
+ local type="$1"
178
+ local full_name="$2"
179
+ local field="$3"
180
+ local response http_status xml
181
+ response=$(curl -s -w "\n%{http_code}" "${INSTANCE_URL}/services/Soap/m/64.0" \
182
+ -H "Content-Type: text/xml; charset=UTF-8" \
183
+ -H "SOAPAction: readMetadata" \
184
+ -d "<?xml version='1.0' encoding='utf-8'?>
185
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
186
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
187
+ <soapenv:Body><met:readMetadata><met:type>${type}</met:type><met:fullNames>${full_name}</met:fullNames></met:readMetadata></soapenv:Body>
188
+ </soapenv:Envelope>" 2>/dev/null || echo "")
189
+ http_status=$(echo "$response" | tail -1)
190
+ xml=$(echo "$response" | sed '$d')
191
+ parse_soap_response "$xml" "$field" "$http_status"
192
+ }
193
+
194
+ # Read OpportunitySettings.enableOpportunityTeam via SOAP readMetadata.
195
+ # OpportunitySettings is NOT queryable via SOQL, so SOAP is the only option
196
+ # (the fullName for OpportunitySettings is "Opportunity", not the type name).
197
+ # Echoes a classification string (see read_setting_status).
198
+ get_opp_team_status() {
199
+ read_setting_status "OpportunitySettings" "Opportunity" "enableOpportunityTeam"
200
+ }
201
+
202
+ # Step 1: Enable EinsteinGptSettings (MUST succeed for Copilot)
203
+ # NOTE: The critical field for Pipeline Management is enableEinsteinGptPlatform.
204
+ # We enable it via SOAP with the correct fullName pattern (fullName = type name for settings).
205
+ echo "Step 1: Enabling Einstein Generative AI"
206
+ echo -n " Checking EinsteinGptSettings... "
207
+
208
+ GENAI_CURRENT=$(read_setting_status "EinsteinGptSettings" "EinsteinGpt" "enableEinsteinGptPlatform")
209
+
210
+ if [[ "$GENAI_CURRENT" == "true" ]]; then
211
+ echo "✅ (already enabled)"
212
+ else
213
+ echo "enabling..."
214
+ RESULT=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
215
+ -H "Content-Type: text/xml; charset=utf-8" \
216
+ -H "SOAPAction: update" \
217
+ -d "<?xml version='1.0' encoding='utf-8'?>
218
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
219
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
220
+ <soapenv:Body><met:updateMetadata>
221
+ <met:metadata xsi:type='met:EinsteinGptSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
222
+ <met:fullName>EinsteinGpt</met:fullName>
223
+ <met:enableEinsteinGptPlatform>true</met:enableEinsteinGptPlatform>
224
+ </met:metadata>
225
+ </met:updateMetadata></soapenv:Body>
226
+ </soapenv:Envelope>")
227
+
228
+ if echo "$RESULT" | grep -q "<success>true</success>"; then
229
+ echo " ✅ Einstein Generative AI enabled (SOAP)"
230
+ else
231
+ echo " ⚠️ SOAP failed — trying CLI deploy fallback..."
232
+ enable_via_cli "EinsteinGptSettings" "Einstein Generative AI (CLI)" "enableEinsteinGptPlatform"
233
+ GENAI_VERIFY=$(read_setting_status "EinsteinGptSettings" "EinsteinGpt" "enableEinsteinGptPlatform")
234
+ if [[ "$GENAI_VERIFY" != "true" ]]; then
235
+ echo " ❌ Critical failure: Cannot enable Einstein Generative AI (all approaches failed)"
236
+ echo "$RESULT" | grep -o '<message>[^<]*</message>' | sed 's/<[^>]*>//g' | head -1 || true
237
+ exit 1
238
+ fi
239
+ echo " ✅ Einstein Generative AI enabled (CLI fallback)"
240
+ fi
241
+ sleep 3
242
+ fi
243
+ echo ""
244
+
245
+ # Step 2: Enable EinsteinCopilotSettings (depends on GPT)
246
+ echo "Step 2: Enabling Agentforce Agent (Einstein Copilot)"
247
+ echo -n " Checking EinsteinCopilotSettings... "
248
+
249
+ COPILOT_CURRENT=$(read_setting_status "EinsteinCopilotSettings" "EinsteinCopilot" "enableEinsteinGptCopilot")
250
+
251
+ if [[ "$COPILOT_CURRENT" == "true" ]]; then
252
+ echo "✅ (already enabled)"
253
+ else
254
+ echo "enabling..."
255
+ RESULT=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
256
+ -H "Content-Type: text/xml; charset=utf-8" \
257
+ -H "SOAPAction: update" \
258
+ -d "<?xml version='1.0' encoding='utf-8'?>
259
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
260
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
261
+ <soapenv:Body><met:updateMetadata>
262
+ <met:metadata xsi:type='met:EinsteinCopilotSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
263
+ <met:fullName>EinsteinCopilot</met:fullName>
264
+ <met:enableEinsteinGptCopilot>true</met:enableEinsteinGptCopilot>
265
+ </met:metadata>
266
+ </met:updateMetadata></soapenv:Body>
267
+ </soapenv:Envelope>")
268
+
269
+ if echo "$RESULT" | grep -q "<success>true</success>"; then
270
+ echo " ✅ Agentforce Agent enabled (SOAP)"
271
+ else
272
+ echo " ⚠️ SOAP failed — trying CLI deploy fallback..."
273
+ enable_via_cli "EinsteinCopilotSettings" "Agentforce Agent (CLI)" "enableEinsteinGptCopilot"
274
+ COPILOT_VERIFY=$(read_setting_status "EinsteinCopilotSettings" "EinsteinCopilot" "enableEinsteinGptCopilot")
275
+ if [[ "$COPILOT_VERIFY" != "true" ]]; then
276
+ echo " ⚠️ Warning: Agentforce Agent enable failed (all approaches — continuing)"
277
+ echo "$RESULT" | grep -o '<message>[^<]*</message>' | sed 's/<[^>]*>//g' | head -1 || true
278
+ else
279
+ echo " ✅ Agentforce Agent enabled (CLI fallback)"
280
+ fi
281
+ fi
282
+ sleep 3
283
+ fi
284
+ echo ""
285
+
286
+ # Step 2b: Enable AgentPlatformSettings (Agentforce Studio — gates Deal Agent)
287
+ # AgentPlatformSettings.enableAgentPlatform (OrgPreference AgentPlatformEnabled)
288
+ # must be ON before SalesDealAgentSettings can be enabled; core rejects Deal Agent
289
+ # enablement otherwise. Depends on Einstein GPT + Copilot (Steps 1–2).
290
+ echo "Step 2b: Enabling Agentforce Studio (Agent Platform)"
291
+ echo -n " Checking AgentPlatformSettings... "
292
+
293
+ AGENT_PLATFORM_CURRENT=$(read_setting_status "AgentPlatformSettings" "AgentPlatform" "enableAgentPlatform")
294
+
295
+ if [[ "$AGENT_PLATFORM_CURRENT" == "true" ]]; then
296
+ echo "✅ (already enabled)"
297
+ else
298
+ echo "enabling..."
299
+ RESULT=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
300
+ -H "Content-Type: text/xml; charset=utf-8" \
301
+ -H "SOAPAction: update" \
302
+ -d "<?xml version='1.0' encoding='utf-8'?>
303
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
304
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
305
+ <soapenv:Body><met:updateMetadata>
306
+ <met:metadata xsi:type='met:AgentPlatformSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
307
+ <met:fullName>AgentPlatform</met:fullName>
308
+ <met:enableAgentPlatform>true</met:enableAgentPlatform>
309
+ </met:metadata>
310
+ </met:updateMetadata></soapenv:Body>
311
+ </soapenv:Envelope>")
312
+
313
+ if echo "$RESULT" | grep -q "<success>true</success>"; then
314
+ echo " ✅ Agentforce Studio (Agent Platform) enabled (SOAP)"
315
+ else
316
+ echo " ⚠️ SOAP failed — trying CLI deploy fallback..."
317
+ enable_via_cli "AgentPlatformSettings" "Agentforce Studio (CLI)" "enableAgentPlatform"
318
+ AGENT_PLATFORM_VERIFY=$(read_setting_status "AgentPlatformSettings" "AgentPlatform" "enableAgentPlatform")
319
+ if [[ "$AGENT_PLATFORM_VERIFY" != "true" ]]; then
320
+ echo " ⚠️ Warning: Agentforce Studio enable failed (all approaches — continuing)"
321
+ echo "$RESULT" | grep -o '<message>[^<]*</message>' | sed 's/<[^>]*>//g' | head -1 || true
322
+ else
323
+ echo " ✅ Agentforce Studio (Agent Platform) enabled (CLI fallback)"
324
+ fi
325
+ fi
326
+ sleep 3
327
+ fi
328
+ echo ""
329
+
330
+ # Step 3: Enable Enhanced Notes (required for Pipeline Management data sources)
331
+ echo "Step 3: Enabling Enhanced Notes"
332
+ echo -n " Checking EnhancedNotesSettings... "
333
+
334
+ NOTES_CURRENT=$(read_setting_status "EnhancedNotesSettings" "EnhancedNotes" "enableEnhancedNotes")
335
+
336
+ if [[ "$NOTES_CURRENT" == "true" ]]; then
337
+ echo "✅ (already enabled)"
338
+ else
339
+ echo "enabling..."
340
+ RESULT=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
341
+ -H "Content-Type: text/xml; charset=utf-8" \
342
+ -H "SOAPAction: update" \
343
+ -d "<?xml version='1.0' encoding='utf-8'?>
344
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
345
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
346
+ <soapenv:Body><met:updateMetadata>
347
+ <met:metadata xsi:type='met:EnhancedNotesSettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
348
+ <met:fullName>EnhancedNotes</met:fullName>
349
+ <met:enableEnhancedNotes>true</met:enableEnhancedNotes>
350
+ </met:metadata>
351
+ </met:updateMetadata></soapenv:Body>
352
+ </soapenv:Envelope>")
353
+
354
+ if echo "$RESULT" | grep -q "<success>true</success>"; then
355
+ echo " ✅ Enhanced Notes enabled"
356
+ else
357
+ echo " ⚠️ SOAP failed — trying CLI deploy fallback..."
358
+ enable_via_cli "EnhancedNotesSettings" "Enhanced Notes" "enableEnhancedNotes" || echo " ❌ Enhanced Notes failed (Pipeline Management may not activate)"
359
+ fi
360
+ sleep 2
361
+ fi
362
+ echo ""
363
+
364
+ # Step 4: Enable Email Administration (CLI is OK, handle compliance field removal)
365
+ echo "Step 4: Enabling Email Administration"
366
+ if ! enable_via_cli "EmailAdministrationSettings" "Email Administration" "enableInternalNotesInEmailSnippet"; then
367
+ echo "⚠️ Retrying without enableEmailSenderIdCompliance..."
368
+
369
+ # Retrieve again
370
+ sf project retrieve start --metadata "Settings:EmailAdministrationSettings" --target-org "$ORG_ALIAS" >/dev/null 2>&1 || true
371
+
372
+ SETTINGS_FILE="force-app/main/default/settings/EmailAdministrationSettings.settings-meta.xml"
373
+
374
+ if [[ -f "$SETTINGS_FILE" ]]; then
375
+ # Remove problematic field if present
376
+ sed -i.bak '/<enableEmailSenderIdCompliance>/d' "$SETTINGS_FILE"
377
+
378
+ # Ensure enableInternalNotesInEmailSnippet is true
379
+ if grep -q "<enableInternalNotesInEmailSnippet>" "$SETTINGS_FILE"; then
380
+ sed -i.bak2 "0,/<enableInternalNotesInEmailSnippet>[^<]*<\/enableInternalNotesInEmailSnippet>/s|<enableInternalNotesInEmailSnippet>[^<]*</enableInternalNotesInEmailSnippet>|<enableInternalNotesInEmailSnippet>true</enableInternalNotesInEmailSnippet>|" "$SETTINGS_FILE"
381
+ fi
382
+
383
+ sf project deploy start --source-dir "force-app/main/default/settings" --target-org "$ORG_ALIAS" >/dev/null 2>&1 || true
384
+ rm -f "${SETTINGS_FILE}.bak" "${SETTINGS_FILE}.bak2" 2>/dev/null || true
385
+ fi
386
+ fi
387
+ echo ""
388
+
389
+ # Step 5: Enable Opportunity Team (CRITICAL — flow uses OpportunityTeamMember)
390
+ # Without this, the Pipeline Management flow deploy fails with an OppTeamMemRec error.
391
+ # OpportunitySettings is NOT queryable via SOQL, so we use SOAP readMetadata/update
392
+ # (matching Steps 1-3 and setup-all.sh). The fullName for OpportunitySettings is
393
+ # "Opportunity", not the type name.
394
+ echo "Step 5: Enabling Opportunity Team"
395
+ echo -n " Checking OpportunitySettings.enableOpportunityTeam... "
396
+
397
+ OPP_TEAM_CURRENT=$(get_opp_team_status)
398
+
399
+ if [[ "$OPP_TEAM_CURRENT" == "true" ]]; then
400
+ echo "✅ (already enabled)"
401
+ else
402
+ echo "enabling..."
403
+ RESULT=$(curl -s -X POST "${INSTANCE_URL}/services/Soap/m/64.0" \
404
+ -H "Content-Type: text/xml; charset=utf-8" \
405
+ -H "SOAPAction: update" \
406
+ -d "<?xml version='1.0' encoding='utf-8'?>
407
+ <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:met='http://soap.sforce.com/2006/04/metadata'>
408
+ <soapenv:Header><met:SessionHeader><met:sessionId>${ACCESS_TOKEN}</met:sessionId></met:SessionHeader></soapenv:Header>
409
+ <soapenv:Body><met:updateMetadata>
410
+ <met:metadata xsi:type='met:OpportunitySettings' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
411
+ <met:fullName>Opportunity</met:fullName>
412
+ <met:enableOpportunityTeam>true</met:enableOpportunityTeam>
413
+ </met:metadata>
414
+ </met:updateMetadata></soapenv:Body>
415
+ </soapenv:Envelope>" 2>/dev/null)
416
+
417
+ if echo "$RESULT" | grep -q "<success>true</success>"; then
418
+ echo " ✅ Opportunity Team enabled"
419
+ else
420
+ echo " ❌ Opportunity Team enable failed — verifying below..."
421
+ echo "$RESULT" | grep -o '<message>[^<]*</message>' | sed 's/<[^>]*>//g' | head -1 || true
422
+ echo " Note: cannot coexist with Opportunity Splits — disable Splits first if enabled."
423
+ fi
424
+ sleep 2
425
+ fi
426
+ echo ""
427
+
428
+ # Step 6: Enable Opportunity settings (Find Similar Opportunities — optional)
429
+ echo "Step 6: Enabling Opportunity Settings"
430
+ enable_via_cli "OpportunitySettings" "Opportunity Settings" "enableFindSimilarOpportunities" || echo "⚠️ Warning: Opportunity Settings failed but continuing..."
431
+ echo ""
432
+
433
+ # Verification — use SOAP readMetadata (matches enable-deal-agent.sh pre-flight checks)
434
+ echo "🔍 Verifying prerequisites via SOAP readMetadata..."
435
+ echo ""
436
+
437
+ VERIFICATION_FAILED=false
438
+
439
+ # Report a verification status classified by shared/soap.sh. Distinguishes a
440
+ # genuine disabled setting from an auth fault or a network/service error so the
441
+ # operator knows whether to re-auth, check connectivity, or actually enable the
442
+ # setting (the W-23215519 fix). Args: $1=label, $2=status string, $3=severity
443
+ # severity "critical" → sets VERIFICATION_FAILED on a real "false"
444
+ # severity "warn" → reports but never blocks
445
+ report_status() {
446
+ local label="$1"
447
+ local status="$2"
448
+ local severity="$3"
449
+ case "$status" in
450
+ true)
451
+ echo " ✅ ${label}: enabled"
452
+ ;;
453
+ false)
454
+ if [[ "$severity" == "critical" ]]; then
455
+ echo " ❌ ${label}: NOT enabled (CRITICAL)"
456
+ VERIFICATION_FAILED=true
457
+ else
458
+ echo " ⚠️ ${label}: NOT enabled"
459
+ fi
460
+ ;;
461
+ AUTH_ERROR:*)
462
+ echo " ❌ ${label}: cannot verify — authentication/SOAP fault (${status#AUTH_ERROR:})"
463
+ echo " Re-authenticate: sf org login web --instance-url $INSTANCE_URL --alias $ORG_ALIAS"
464
+ # if/then/fi (not `[[ ]] && ...`): a bare `&&` would return 1 when severity
465
+ # is "warn", and as the case arm's last statement that makes report_status
466
+ # return 1 — aborting the script at the bare warn call sites under set -e.
467
+ if [[ "$severity" == "critical" ]]; then VERIFICATION_FAILED=true; fi
468
+ ;;
469
+ TYPE_UNAVAILABLE:*)
470
+ echo " ❌ ${label}: not available in this org edition (${status#TYPE_UNAVAILABLE:})"
471
+ if [[ "$severity" == "critical" ]]; then VERIFICATION_FAILED=true; fi
472
+ ;;
473
+ NETWORK_ERROR)
474
+ echo " ❌ ${label}: cannot verify — network/service error (check instance URL and connectivity)"
475
+ if [[ "$severity" == "critical" ]]; then VERIFICATION_FAILED=true; fi
476
+ ;;
477
+ *)
478
+ echo " ⚠️ ${label}: unknown status ($status)"
479
+ ;;
480
+ esac
481
+ }
482
+
483
+ # Verify Einstein GPT (critical — checked by enable-deal-agent.sh pre-flight)
484
+ VERIFY_GENAI=$(read_setting_status "EinsteinGptSettings" "EinsteinGpt" "enableEinsteinGptPlatform")
485
+ report_status "Einstein Generative AI (enableEinsteinGptPlatform)" "$VERIFY_GENAI" "critical"
486
+
487
+ # Verify Einstein Copilot (checked by enable-deal-agent.sh pre-flight)
488
+ VERIFY_COPILOT=$(read_setting_status "EinsteinCopilotSettings" "EinsteinCopilot" "enableEinsteinGptCopilot")
489
+ report_status "Agentforce Agent (enableEinsteinGptCopilot)" "$VERIFY_COPILOT" "warn"
490
+
491
+ # Verify Agentforce Studio / Agent Platform (gates Deal Agent; enable-deal-agent.sh
492
+ # pre-flight hard-blocks on this — a disabled state here explains a downstream
493
+ # Deal Agent activation failure).
494
+ VERIFY_AGENT_PLATFORM=$(read_setting_status "AgentPlatformSettings" "AgentPlatform" "enableAgentPlatform")
495
+ report_status "Agentforce Studio / Agent Platform (enableAgentPlatform)" "$VERIFY_AGENT_PLATFORM" "warn"
496
+
497
+ # Verify Enhanced Notes (checked by enable-deal-agent.sh pre-flight)
498
+ VERIFY_NOTES=$(read_setting_status "EnhancedNotesSettings" "EnhancedNotes" "enableEnhancedNotes")
499
+ report_status "Enhanced Notes (enableEnhancedNotes)" "$VERIFY_NOTES" "warn"
500
+
501
+ # Verify Opportunity Team (CRITICAL — PM flow deploy fails with OppTeamMemRec error
502
+ # without it). OpportunitySettings is not queryable via SOQL — use SOAP readMetadata.
503
+ VERIFY_OPP_TEAM=$(get_opp_team_status)
504
+ if [[ "$VERIFY_OPP_TEAM" != "true" ]]; then
505
+ report_status "Opportunity Team (enableOpportunityTeam)" "$VERIFY_OPP_TEAM" "critical"
506
+ echo " The Pipeline Management flow requires OpportunityTeamMember access;"
507
+ echo " without it, flow deployment fails with an OppTeamMemRec error."
508
+ echo " Note: cannot coexist with Opportunity Splits — disable Splits first if enabled."
509
+ else
510
+ report_status "Opportunity Team (enableOpportunityTeam)" "$VERIFY_OPP_TEAM" "critical"
511
+ fi
512
+
513
+ # Verify Email Administration (best-effort, not blocking)
514
+ VERIFY_EMAIL=$(sf data query --query "SELECT enableEnhancedEmailEnabled FROM EmailAdministrationSettings" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -r '.result.records[0].enableEnhancedEmailEnabled // "unknown"' 2>/dev/null || echo "unknown")
515
+ if [[ "$VERIFY_EMAIL" == "true" ]]; then
516
+ echo " ✅ Enhanced Email: enabled"
517
+ else
518
+ echo " ⚠️ Enhanced Email: not enabled (optional — email body indexing)"
519
+ fi
520
+
521
+ # Verify Opportunity Settings (best-effort, not blocking)
522
+ VERIFY_OPP=$(sf data query --query "SELECT enableFindSimilarOpportunities FROM OpportunitySettings" --target-org "$ORG_ALIAS" --json 2>/dev/null | jq -r '.result.records[0].enableFindSimilarOpportunities // "unknown"' 2>/dev/null || echo "unknown")
523
+ if [[ "$VERIFY_OPP" == "true" ]]; then
524
+ echo " ✅ Opportunity Settings: enabled"
525
+ else
526
+ echo " ⚠️ Opportunity Settings: not enabled (optional)"
527
+ fi
528
+
529
+ echo ""
530
+
531
+ if [[ "$VERIFICATION_FAILED" == "true" ]]; then
532
+ echo "❌ Critical prerequisites failed. Cannot proceed to Deal Agent setup."
533
+ exit 1
534
+ fi
535
+
536
+ echo "✅ All prerequisites enabled successfully"
537
+ echo ""
538
+ echo "Next step: Run ./enable-deal-agent.sh $ORG_ALIAS"