forcedotcom/sf-skills / plugins/builder/service-itsm/skills/service-itsm-agentic-setup-agent-runtime-access-assign
service-itsm-agentic-setup-agent-runtime-access-assign
VerifiedGrant a user the runtime permissions an activated ITSM agent's actions need so the actions do not fail on permission errors. After a Fulfiller or Employee agent is activated, this skill detects which platform feature permission sets are provisioned (Prompt Templates, Data Cloud, Unified Catalog), lets you pick a tier (user/agent vs admin) per feature and which user(s) to assign, then assigns them (license first when license-gated). It also creates a custom "Agent Access" permission set granting the activated agents you choose and assigns it to the user — all via the Salesforce CLI. Use to grant a user access to an activated agent, to assign prompt-template, data-cloud, or unified-catalog access, or to create an Agent Access permission set. DO NOT TRIGGER for enabling Agentforce for IT Service toggles, creating or activating an agent, the Fulfiller activation action-surfacing gap (service-itsm-agentic-setup-itsm-agentforce-permset-assign), CMDB access, or generic permission-set assignment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 21.4 KB |
| references/cli-invocation.md | markdown | 9.7 KB |
| references/helper-contracts.md | markdown | 10.6 KB |
| references/permset-topology.md | markdown | 7.4 KB |
| scripts/classify-activated-agents.mjsexecutable | script | 4.3 KB |
| scripts/classify-agent-access-state.mjsexecutable | script | 5.4 KB |
| scripts/classify-assignment-state.mjsexecutable | script | 4.7 KB |
| scripts/classify-platform-permset-availability.mjsexecutable | script | 6.3 KB |
| scripts/gate-unified-catalog-tiers.mjsexecutable | script | 4.7 KB |
| scripts/rank-candidate-users.mjsexecutable | script | 4.7 KB |
| scripts/resolve-target-user.mjsexecutable | script | 3.0 KB |
scripts/rank-candidate-users.mjs
View on GitHub#!/usr/bin/env node
// Ranks REAL, human candidate users to offer as selectable options behind the
// Phase-2 AskUserQuestion when the caller did not name a target user. This is a
// presentation aid, never a gating decision — it keeps the offered list
// deterministic (no editorializing down to one name) and audience-appropriate.
//
// Inputs (argv):
// 1. users.json — capture of `sf data query --json` selecting active users
// with Id, Name, Username, Profile.Name, Profile.UserLicense.Name.
// 2. audience — 'fulfiller' | 'employee' | 'any' (anything else ⇒ 'any').
// A Fulfiller agent is run by IT staff on a STANDARD license;
// an Employee agent by end employees on a UNIFIED EMPLOYEE
// license — so the matching cohort is surfaced first.
// 3. runningUserId — optional; the "Me" user, excluded here (offered separately
// as the recommended option).
//
// Output (stdout JSON):
// { candidates: [ { Id, Name, Username, profile, cohort } ], audience, total, note }
// at most 5 candidates; service/integration/bot/agent accounts removed. Exit is
// always 0 on a parseable body (empty candidates ⇒ offer "Me" + free-text only);
// exit 2 only on missing argv.
import { readFileSync } from 'node:fs';
// Non-human / service accounts are never good runtime-access targets. Matched on
// profile name, license name, username, OR display name so a mislabeled record
// on any one field is still filtered.
const SERVICE_RE = /integration|automated process|einstein agent|analytics cloud|salesforceiq|\binsights\b|chatter (free|external)|guest|portal|sites|\bbot\b|botuser|digitalagent/i;
// The Unified Employee cohort — the human tier an Employee agent's users belong to.
// It is defined by the Unified Employee USER LICENSE, which is the authoritative
// signal; the profile name is only a defensive fallback (a custom profile carrying
// the license must still rank as Unified Employee).
const UNIFIED_RE = /unified\s*employee/i;
function readEnvelope(path) {
try {
const text = readFileSync(path, 'utf8').trim();
if (!text) return { ok: false, reason: `empty file: ${path}` };
const data = JSON.parse(text);
if (data && typeof data.status === 'number' && data.status !== 0) {
return { ok: false, reason: `sf data query at ${path} failed with status ${data.status}` };
}
const records = Array.isArray(data?.result?.records) ? data.result.records : null;
if (!records) return { ok: false, reason: `missing result.records[] at ${path}` };
return { ok: true, records };
} catch (e) {
return { ok: false, reason: `unreadable/invalid JSON at ${path}: ${e?.message ?? e}` };
}
}
function emit(obj) {
process.stdout.write(JSON.stringify(obj, null, 2) + '\n');
}
const [usersPath, audienceArg, runningUserId] = process.argv.slice(2);
if (!usersPath) {
process.stderr.write('usage: node rank-candidate-users.mjs <users.json> [fulfiller|employee|any] [runningUserId]\n');
process.exit(2);
}
const audience = (audienceArg === 'fulfiller' || audienceArg === 'employee') ? audienceArg : 'any';
const env = readEnvelope(usersPath);
if (!env.ok) {
emit({ candidates: [], audience, total: 0, note: `${env.reason} — offer "Me" plus free-text entry only.` });
process.exit(0);
}
const profileName = (r) => `${r?.Profile?.Name ?? ''}`;
const licenseName = (r) => `${r?.Profile?.UserLicense?.Name ?? ''}`;
const isService = (r) =>
SERVICE_RE.test(profileName(r)) || SERVICE_RE.test(licenseName(r)) ||
SERVICE_RE.test(`${r?.Username ?? ''}`) || SERVICE_RE.test(`${r?.Name ?? ''}`);
const cohortOf = (r) =>
(UNIFIED_RE.test(licenseName(r)) || UNIFIED_RE.test(profileName(r)) ? 'unified-employee' : 'standard');
const humans = env.records
.filter((r) => r && typeof r.Id === 'string')
.filter((r) => r.Id !== runningUserId)
.filter((r) => !isService(r))
.map((r) => ({ Id: r.Id, Name: r.Name ?? r.Username, Username: r.Username, profile: profileName(r), cohort: cohortOf(r) }));
// Rank the audience-matching cohort first, preserving input order within a cohort
// (the query already orders by most-recent login).
const prefer = audience === 'employee' ? 'unified-employee' : audience === 'fulfiller' ? 'standard' : null;
const ranked = prefer
? [...humans.filter((u) => u.cohort === prefer), ...humans.filter((u) => u.cohort !== prefer)]
: humans;
const candidates = ranked.slice(0, 5);
const note = candidates.length === 0
? 'No non-service human users found besides the running user — offer "Me" plus free-text entry only.'
: `Offering ${candidates.length} candidate(s)${prefer ? `, ${prefer} cohort first (audience: ${audience})` : ''}.`;
emit({ candidates, audience, total: humans.length, note });
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |