Playground · the in-tab shape
Reins, running in this tab
Nothing on this page is a mock-up. The page hosts the real broker, driver and agent SDK from dist/bundle/reins.js, joined by in-memory links: no hub process and no network. A scripted assistant drives the small coffee kiosk below. The prompts, the indicator and the panel it opens (permission levels, activity, chat), Pause and Stop are the driver's own, and the inspector beside it shows every reins.v1 frame that crosses a link.
Brew Kiosk
Tap a drink, name your order, and we will call you.
Your order
Your order is empty. Pick a drink to begin.
Total$0.00
Insights
Staff
No frame has crossed a link yet. The driver connects to the broker as soon as the bundle has loaded.
Press “Run the assistant”. Each step it takes is listed here with the answer it got, the way an agent harness would see it.
memoryAudit(). Arguments appear only as a digest; every record carries the hash of the one before.No record yet.
| seq | kind | agent | method | outcome | args digest | hash |
|---|
Things to try
Run the assistant and let it finish its tour. It then stays attached and listens. Select “AI connected” in the corner: its text opens the panel, on your click and on nothing else. The panel lies over part of the inspector: close it with × or Escape to read the frames.
- Raise the level and watch a prompt stop appearing. Add a drink, then type “place my order” in the Chat tab: the page asks you, as it did in the tour. Refuse. Set the assistant to Auto under Permissions (a second step names what stops asking), and ask again: the order is placed with no prompt, and the indicator shows the level. The dangerous
order.refundstays “Blocked by app” at every level. - Block an action. Under Permissions set
cart.addto Block, then type “add a latte” in the chat. The call comes backE_CONSENTwith no prompt, and the assistant says so. Reset takes the rule away; where the action would then run unasked, that has a confirm step too. - Press “Always allow” on a prompt. At the level Ask, “place my order” brings the prompt with three buttons. Always allow takes two presses: the first says what the rule covers, the second sets it. The indicator then shows “1 rule”, and the next order is placed without asking.
- Switch a scope off. Under “What it may do”, switch
actoff for the assistant and ask it for a drink. The request comes backE_SCOPE, the assistant says so, and anevt grantwith the scopes now in force crosses the wire. The grant goes on: switch it back on. Withchatswitched off the assistant is out of the room, and the Chat tab says that no agent is attached with chat. - Tighten something, send the assistant away, and run it again. Set
cart.addto Block (or the level to Strict, or switch a scope off), press “Send it away”, then “Run the assistant”. The attach card lists what you set before and says that it stays, the answer to the attach carrieskept, and the firstcart.addof the new grant comes backE_CONSENT. What loosens does not come back: Auto and an Allow rule end with the grant. - Answer a prompt from the keyboard. The card takes the focus onto itself, not onto a button, so a key meant for the page presses nothing. Tab to Allow, let the focus rest there for half a second, and press Enter. Type a letter first and the card says that keys do not answer for a moment; the pointer works all along.
- Chat with the assistant. “add two mochas”, “what is in my order”, “place my order”, “stop”. The answers are the demo's own script,
examples/kiosk/public/chat-script.js: no model. A message is a request, never an approval: “place my order” still asks you on the page's prompt, and while that prompt is up the chat is hidden. - Attach the Console as a second agent, and try the relay switch. In the Console tab send
surface.attach, thenchat.say. You see both agents in the Chat tab, but underguardedthey do not hear each other:chat.sayto the other agent answersE_DENIED. Switch “Agents can hear each other” on in the Chat tab, confirm, and send it again: anevt chatnow reaches the assistant. (tois the other agent's session id, shown after its name:a1when the assistant connected first.) - Read what you set, as an agent sees it. The Script tab logs what the assistant is told, and “what the person set for you” in the Console reads the same from the SDK. In the Wire tab, type
user,grantorchatinto the filter.
And as before:
- Press Pause in the indicator while the assistant works. Its next command comes back
E_PAUSED; reading the page still works. Resume, and it carries on. - Press Stop. The driver revokes the grant: an
evt grantwithkind: "revoked"crosses the wire and every later request is refused. - Refuse the order. The assistant gets
E_CONSENT, and asking again at once getsE_RATE: a cool-off after each refusal. - Open the Staff panel and send
observefrom the console. The PIN field appears as[private], with no value, andui.typeinto it is refused. - Switch the profile to kiosk. No prompt on attach, no
uiand nochatscope, only annotated elements in the tree, and placing the order is refused outright. The indicator opens no panel there and has no Stop: a kiosk visitor is not the owner. - Read one request on both links. An agent sends
req actwiths, the surface id. The broker checks the grant, the scope and the rate, stripss, and forwards it withag, the agent's session.
How this page is put together
It is the README's “Run the assistant in the tab”, with one addition: each in-memory link is cut in two and a relay passes every message on unchanged, noting it for the Wire tab. The agent side authenticated with a key, so its session is sealed: each message carries a MAC, and the relay can read it but could not alter, reorder or replay it without the next message failing to verify.
import { Broker, connect, createDriver, linkPair, randomToken } from '@offensiveadhd/reins';
const key = randomToken(32);
const broker = new Broker({
agents: [{ kid: 'tab-assistant', key, name: 'Tab assistant', origins: [location.origin] }],
surfaces: { origins: [location.origin] },
policy: 'guarded',
});
// the page side
const [pageEnd, brokerEnd] = linkPair();
broker.accept(brokerEnd, { origin: location.origin });
const driver = createDriver({ app: { id: 'my-app', name: 'My app', version: '1.0.0' }, link: pageEnd, policy: 'guarded' });
// ... driver.action(...), driver.view(...), driver.state(...)
await driver.connect();
// the assistant side
const [agentEnd, brokerEnd2] = linkPair();
broker.accept(brokerEnd2, { origin: location.origin });
const client = await connect({ link: agentEnd, kid: 'tab-assistant', key, name: 'Tab assistant' });
const [surface] = await client.surfaces();
const page = await client.attach(surface.s, { scopes: ['observe', 'act', 'cursor', 'show'], reason: 'Help with your order' });The demo app's logic and its action definitions are the repository's own files, examples/kiosk/public/app.js and actions.js, copied here when the site is built. The in-tab shape, step by step · The source of this page