sf-builder-agent 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.js +27 -8
- package/dist/ai.js.map +1 -1
- package/package.json +1 -1
- package/src/ai.ts +29 -8
package/dist/ai.js
CHANGED
|
@@ -63,10 +63,19 @@ Use this knowledge to navigate Salesforce efficiently:
|
|
|
63
63
|
- Custom Objects: /lightning/setup/ObjectManager/home
|
|
64
64
|
- Apex Classes: /lightning/setup/ApexClasses/home
|
|
65
65
|
|
|
66
|
-
### Agentforce Agent Builder
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
### Agentforce Agent Builder — Creating a New Agent
|
|
67
|
+
The "New Agent" flow has multiple screens you MUST progress through:
|
|
68
|
+
1. Click "+ New Agent" button on the Agentforce Agents list page
|
|
69
|
+
2. **Template Selection screen** appears: "Select an agent" with two tabs: "Create from a Template" and "Create with Gen AI"
|
|
70
|
+
- You MUST click one of the template cards (e.g., "Agentforce Employee Agent", "Agentforce Service Agent", "Sales Agent") to proceed
|
|
71
|
+
- After clicking a template, a "Next" or "Continue" button appears — click it
|
|
72
|
+
- If the objective mentions a specific agent type, pick the matching template
|
|
73
|
+
- If unsure which template, use "ask_user" to ask the human which template to select
|
|
74
|
+
3. **Agent Details screen**: Fill in Name, API Name, Description
|
|
75
|
+
4. **Agent Builder** opens with tabs: Details, Topics, Actions, Instructions
|
|
76
|
+
|
|
77
|
+
### Agentforce Agent Builder — Editing an Existing Agent
|
|
78
|
+
When editing an agent that already exists:
|
|
70
79
|
- **Details tab**: Set Name, API Name, Description
|
|
71
80
|
- **Topics tab**: Add topics (each topic = a capability domain the agent handles)
|
|
72
81
|
- **Actions tab** (within a topic): Link Flows, Apex classes, or Prompt Templates as actions
|
|
@@ -120,7 +129,9 @@ When creating/editing an Agentforce Agent:
|
|
|
120
129
|
10. The main Setup content is in the center-right area
|
|
121
130
|
11. If you encounter something you can't handle (CAPTCHA, 2FA prompt, unexpected dialog, element you can't find after multiple attempts), use "ask_user" and explain what you need the human to do
|
|
122
131
|
12. When a "user_hint" appears in action history, prioritize following the human's guidance — they can see the screen and know what to do
|
|
123
|
-
13. Use Quick Find (search box at top-left of Setup) to navigate instead of clicking through menu trees — it's faster and more reliable
|
|
132
|
+
13. Use Quick Find (search box at top-left of Setup) to navigate instead of clicking through menu trees — it's faster and more reliable
|
|
133
|
+
14. IMPORTANT: Salesforce uses multi-step wizards. If clicking a button brought you to a new screen (template picker, configuration form, etc.), do NOT click the same button again. Instead, look at what the NEW screen is asking you to do and interact with it (select a template, fill a form, click Next/Continue)
|
|
134
|
+
15. If you see a selection grid (cards/tiles to choose from), you must CLICK one of them to proceed. Look for the option that best matches the objective`;
|
|
124
135
|
// ─── Main Function ───────────────────────────────────────────────────
|
|
125
136
|
/**
|
|
126
137
|
* Analyze a screenshot and decide the next action to accomplish the objective.
|
|
@@ -130,8 +141,12 @@ When creating/editing an Agentforce Agent:
|
|
|
130
141
|
export async function decideNextAction(screenshot, objective, actionHistory, pageUrl, pageTitle, fieldValues, verifyPrompt) {
|
|
131
142
|
const apiKey = getApiKey();
|
|
132
143
|
// Build user message with context
|
|
133
|
-
|
|
134
|
-
|
|
144
|
+
// Separate user hints from regular action history so they stand out
|
|
145
|
+
const regularActions = actionHistory.filter((a) => a.action !== "user_hint");
|
|
146
|
+
const userHints = actionHistory.filter((a) => a.action === "user_hint");
|
|
147
|
+
const latestHint = userHints.length > 0 ? userHints[userHints.length - 1].result : null;
|
|
148
|
+
const historyText = regularActions.length > 0
|
|
149
|
+
? `\n\nActions taken so far:\n${regularActions.map((a, i) => `${i + 1}. ${a.action} → ${a.target} (${a.result})`).join("\n")}`
|
|
135
150
|
: "";
|
|
136
151
|
const fieldsText = fieldValues
|
|
137
152
|
? `\n\nField values to enter:\n${Object.entries(fieldValues).map(([k, v]) => `- ${k}: "${v}"`).join("\n")}`
|
|
@@ -139,7 +154,11 @@ export async function decideNextAction(screenshot, objective, actionHistory, pag
|
|
|
139
154
|
const verifyText = verifyPrompt
|
|
140
155
|
? `\n\nCompletion criteria: ${verifyPrompt}`
|
|
141
156
|
: "";
|
|
142
|
-
|
|
157
|
+
// Make user hints VERY prominent — they override normal AI reasoning
|
|
158
|
+
const hintText = latestHint
|
|
159
|
+
? `\n\n>>> HUMAN INSTRUCTION (FOLLOW THIS NOW): ${latestHint} <<<\nThe human is watching the screen and telling you exactly what to do. Execute their instruction immediately.`
|
|
160
|
+
: "";
|
|
161
|
+
const userText = `URL: ${pageUrl}\nTitle: ${pageTitle}\n\nObjective: ${objective}${fieldsText}${verifyText}${historyText}${hintText}\n\nWhat is the single next action?`;
|
|
143
162
|
const res = await fetch(OPENROUTER_URL, {
|
|
144
163
|
method: "POST",
|
|
145
164
|
headers: {
|
package/dist/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyBH,wEAAwE;AAExE,MAAM,cAAc,GAAG,+CAA+C,CAAC;AACvE,MAAM,KAAK,GAAG,6BAA6B,CAAC;AAE5C,kEAAkE;AAClE,MAAM,UAAU,SAAS;IACvB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC5E,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACzE,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wEAAwE;AAExE,MAAM,aAAa,GAAG
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"m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AAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IAED,mEAAmE;IACnE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;IAED,gEAAgE;IAChE,4CAA4C;IAC5C,OAAO,CAAC,GAAG,CAAC,gDAAgD,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IACxF,OAAO;QACL,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;QAChC,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/ai.ts
CHANGED
|
@@ -91,10 +91,19 @@ Use this knowledge to navigate Salesforce efficiently:
|
|
|
91
91
|
- Custom Objects: /lightning/setup/ObjectManager/home
|
|
92
92
|
- Apex Classes: /lightning/setup/ApexClasses/home
|
|
93
93
|
|
|
94
|
-
### Agentforce Agent Builder
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
### Agentforce Agent Builder — Creating a New Agent
|
|
95
|
+
The "New Agent" flow has multiple screens you MUST progress through:
|
|
96
|
+
1. Click "+ New Agent" button on the Agentforce Agents list page
|
|
97
|
+
2. **Template Selection screen** appears: "Select an agent" with two tabs: "Create from a Template" and "Create with Gen AI"
|
|
98
|
+
- You MUST click one of the template cards (e.g., "Agentforce Employee Agent", "Agentforce Service Agent", "Sales Agent") to proceed
|
|
99
|
+
- After clicking a template, a "Next" or "Continue" button appears — click it
|
|
100
|
+
- If the objective mentions a specific agent type, pick the matching template
|
|
101
|
+
- If unsure which template, use "ask_user" to ask the human which template to select
|
|
102
|
+
3. **Agent Details screen**: Fill in Name, API Name, Description
|
|
103
|
+
4. **Agent Builder** opens with tabs: Details, Topics, Actions, Instructions
|
|
104
|
+
|
|
105
|
+
### Agentforce Agent Builder — Editing an Existing Agent
|
|
106
|
+
When editing an agent that already exists:
|
|
98
107
|
- **Details tab**: Set Name, API Name, Description
|
|
99
108
|
- **Topics tab**: Add topics (each topic = a capability domain the agent handles)
|
|
100
109
|
- **Actions tab** (within a topic): Link Flows, Apex classes, or Prompt Templates as actions
|
|
@@ -148,7 +157,9 @@ When creating/editing an Agentforce Agent:
|
|
|
148
157
|
10. The main Setup content is in the center-right area
|
|
149
158
|
11. If you encounter something you can't handle (CAPTCHA, 2FA prompt, unexpected dialog, element you can't find after multiple attempts), use "ask_user" and explain what you need the human to do
|
|
150
159
|
12. When a "user_hint" appears in action history, prioritize following the human's guidance — they can see the screen and know what to do
|
|
151
|
-
13. Use Quick Find (search box at top-left of Setup) to navigate instead of clicking through menu trees — it's faster and more reliable
|
|
160
|
+
13. Use Quick Find (search box at top-left of Setup) to navigate instead of clicking through menu trees — it's faster and more reliable
|
|
161
|
+
14. IMPORTANT: Salesforce uses multi-step wizards. If clicking a button brought you to a new screen (template picker, configuration form, etc.), do NOT click the same button again. Instead, look at what the NEW screen is asking you to do and interact with it (select a template, fill a form, click Next/Continue)
|
|
162
|
+
15. If you see a selection grid (cards/tiles to choose from), you must CLICK one of them to proceed. Look for the option that best matches the objective`;
|
|
152
163
|
|
|
153
164
|
// ─── Main Function ───────────────────────────────────────────────────
|
|
154
165
|
|
|
@@ -169,9 +180,14 @@ export async function decideNextAction(
|
|
|
169
180
|
const apiKey = getApiKey();
|
|
170
181
|
|
|
171
182
|
// Build user message with context
|
|
183
|
+
// Separate user hints from regular action history so they stand out
|
|
184
|
+
const regularActions = actionHistory.filter((a) => a.action !== "user_hint");
|
|
185
|
+
const userHints = actionHistory.filter((a) => a.action === "user_hint");
|
|
186
|
+
const latestHint = userHints.length > 0 ? userHints[userHints.length - 1].result : null;
|
|
187
|
+
|
|
172
188
|
const historyText =
|
|
173
|
-
|
|
174
|
-
? `\n\nActions taken so far:\n${
|
|
189
|
+
regularActions.length > 0
|
|
190
|
+
? `\n\nActions taken so far:\n${regularActions.map((a, i) => `${i + 1}. ${a.action} → ${a.target} (${a.result})`).join("\n")}`
|
|
175
191
|
: "";
|
|
176
192
|
|
|
177
193
|
const fieldsText = fieldValues
|
|
@@ -182,7 +198,12 @@ export async function decideNextAction(
|
|
|
182
198
|
? `\n\nCompletion criteria: ${verifyPrompt}`
|
|
183
199
|
: "";
|
|
184
200
|
|
|
185
|
-
|
|
201
|
+
// Make user hints VERY prominent — they override normal AI reasoning
|
|
202
|
+
const hintText = latestHint
|
|
203
|
+
? `\n\n>>> HUMAN INSTRUCTION (FOLLOW THIS NOW): ${latestHint} <<<\nThe human is watching the screen and telling you exactly what to do. Execute their instruction immediately.`
|
|
204
|
+
: "";
|
|
205
|
+
|
|
206
|
+
const userText = `URL: ${pageUrl}\nTitle: ${pageTitle}\n\nObjective: ${objective}${fieldsText}${verifyText}${historyText}${hintText}\n\nWhat is the single next action?`;
|
|
186
207
|
|
|
187
208
|
const res = await fetch(OPENROUTER_URL, {
|
|
188
209
|
method: "POST",
|