How you have a server of your own decide each action of your agents: setting the address, what STACK sends, what your server answers, and what happens when it does not. What this is and what it costs is on Controls.
npx @getstackrun/cli control-socket set-decision https://decide.example.com/stackSTACK sends a signed request for each action and waits for a signed answer. The SDK has the two helpers:
import { createServer } from 'node:http';
import { verifyControlSocketRequest, signControlSocketAnswer } from '@getstackrun/sdk';
const secrets = [process.env.STACK_DECISION_SECRET!];
createServer(async (req, res) => {
const chunks: Buffer[] = [];
for await (const chunk of req) chunks.push(chunk as Buffer);
const body = Buffer.concat(chunks).toString('utf8'); // the body exactly as received
const check = verifyControlSocketRequest({ headers: req.headers, body, secret: secrets });
if (!check.ok) {
res.statusCode = 401;
return res.end();
}
const r = check.request;
// Your rule. Here: email may go only to example.com.
const recipients = (r.target['recipients'] as Array<{ domain?: string }> | undefined) ?? [];
const outside = r.action.type === 'email.send' && recipients.some((x) => x.domain !== 'example.com');
const deny = !r.test && outside; // always allow a test request
const answer = signControlSocketAnswer({
decisionId: r.decision_id,
requestDigest: r.request_digest,
verdict: deny ? 'deny' : 'allow',
...(deny ? { reason: { code: 'external_recipient', message: 'Only example.com recipients' } } : {}),
secrets,
});
res.writeHead(200, { 'content-type': 'application/json', ...answer.headers });
res.end(answer.body); // the body exactly as signed
}).listen(8080);The request never carries message text, subjects, prompts, model output, commands, page text, card numbers or logins.
npx @getstackrun/cli control-socket verify decisionVerify sends one real signed request marked as a test. Your server must answer allow. From that moment your server decides. If hosted controls were deciding before, this replaces them and needs your approval in a browser. control-socket test decision sends the same request at any time and changes nothing.
# Ask only about email, texts and payments.
npx @getstackrun/cli control-socket checked-types email.send sms.send card.checkout wallet.payment
# Ask about everything again.
npx @getstackrun/cli control-socket checked-types --allEvery kind is asked by default. Taking a kind off the list counts as loosening and needs your approval in a browser.
npx @getstackrun/cli control-socket decisions --verdict denyThe tools are stack_list_control_decisions and stack_get_control_decision. Each decision shows the action, the verdict, the reason, how long your server took, and whether it was charged. Decisions are kept 90 days, and the request behind a refused or unanswered one 30 days.
control-socket rotate-secret decision gives a new secret. The old one keeps working for 24 hours, so give your server both during the change.
Each answer your server gives, allow or deny, is charged at the own-server price. A request your server did not answer is not charged, and neither are tests. An action your server refuses is not counted as an action.
Every field of the request and the answer is on Controls. To have STACK decide from a policy instead, see Policies.