Skip to content

forcedotcom/sf-skills / plugins/builder/service-itsm/skills/service-itsm-agentic-setup-agent-runtime-access-assign

service-itsm-agentic-setup-agent-runtime-access-assign

Verified

Grant 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.

scripts/resolve-target-user.mjs

View on GitHub
#!/usr/bin/env node
// Deterministic target-user resolver for the agent-runtime-access-assign flow.
//
// Reads the `GET /services/data/v67.0/` capture (or an equivalent versions-list
// response the CLI writes when hitting the API root), and extracts the running
// user's Id from the `identity` URL. The URL shape is:
//     https://<mydomain>.my.salesforce.com/id/<orgId 00D…>/<userId 005…>
// so we take the LAST path segment and require it to start with `005` and be
// 15 or 18 chars (case-preserving).
//
// This exists so no prose step ever tries to parse the identity URL by hand
// (A9 — deterministic decisions belong in scripts).
//
// Usage:
//   node resolve-target-user.mjs <api-root.json>
//
// Emits a single JSON object to stdout:
//   { userId: "005…" | null,
//     identity: "<full URL>" | null,
//     verdict: "RESOLVED" | "CANNOT-CONFIRM",
//     reasons: [...] }
// Exit is always 0 on parseable bodies; verdict carries the decision.

import { readFileSync } from 'node:fs';

const [rootPath] = process.argv.slice(2);
if (!rootPath) {
  process.stderr.write('usage: node resolve-target-user.mjs <api-root.json>\n');
  process.exit(2);
}

function fail(reasons) {
  process.stdout.write(JSON.stringify({
    userId: null, identity: null, verdict: 'CANNOT-CONFIRM', reasons,
  }, null, 2) + '\n');
  process.exit(0);
}

let text;
try {
  text = readFileSync(rootPath, 'utf8').trim();
} catch (e) {
  fail([`unreadable file at ${rootPath}: ${e?.message ?? e}`]);
}
if (!text) fail([`empty file: ${rootPath}`]);

let data;
try {
  data = JSON.parse(text);
} catch (e) {
  fail([`invalid JSON at ${rootPath}: ${e?.message ?? e}`]);
}
if (!data || typeof data !== 'object') fail([`non-object JSON at ${rootPath}`]);
if (typeof data.status === 'number' && data.status !== 0) {
  fail([`sf api request at ${rootPath} failed with status ${data.status}`]);
}

// `sf api request rest` returns the raw body directly; the API root response
// contains `identity`, `rest`, and version fields at the top level.
const identity = typeof data.identity === 'string'
  ? data.identity
  : (typeof data.result?.identity === 'string' ? data.result.identity : null);

if (!identity) {
  fail(['response body has no `identity` field — cannot resolve the running user without it. Confirm the org is reachable and re-run `sf api request rest "/services/data/v67.0/"`.']);
}

const segments = identity.split('/').filter(Boolean);
const last = segments[segments.length - 1] ?? '';

// Salesforce user Ids: 15-char case-sensitive or 18-char case-insensitive, prefix `005`.
if (!/^005[A-Za-z0-9]{12}([A-Za-z0-9]{3})?$/.test(last)) {
  fail([
    `identity URL trailing segment "${last}" does not match the expected user-Id shape (005 + 12 or 15 alphanum chars).`,
    `full identity URL: ${identity}`,
  ]);
}

process.stdout.write(JSON.stringify({
  userId: last,
  identity,
  verdict: 'RESOLVED',
  reasons: [
    `Extracted running-user Id "${last}" from identity URL trailing path segment.`,
  ],
}, null, 2) + '\n');
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: 471kUpdated Claude CodeCodexVerifiedInstall
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 322kUpdated Claude CodeCodexVerifiedInstall