Skip to content
Cognolo

Cognolo is in early access, and its hosted service isn’t open yet. This guide describes how the dashboard and the runtime are built to work. Some parts, such as the GitHub App and the code reader, have so far been tried only on sample code. Ask about early access

Guide › Setting up › Install in your app

Who the person is

The sign-in check every request goes through: who is asking, which conversations are theirs, and which tools they get.

What it’s for
Tells the assistant who is signed in to your app. It then acts as that person: it can only do what they’re allowed to do, and they only see their own conversations.
Who does it
Your developer. If your app uses Clerk for signing in, it’s usually filled in already; they just check it.
You’ll know it worked when
Signed in, the assistant answers you. Signed out, it says to sign in.

Until this step is done, the assistant answers nobody. That’s on purpose: Cognolo never guesses who your users are.

Asking someone else to do it

Copy this and send it to your developer, or paste it into an AI coding assistant working in your app:

Cognolo needs to know who is signed in. Please check `open()` in `lib/cognolo/assistant.ts`: it should use our own sign-in check and the user’s id (never their email). Details are in Cognolo’s guide, “Who the person is”.

For your developer

Every request to the assistant goes through open() in lib/cognolo/assistant.ts. It finds the signed-in person and returns three things: whose conversations these are, what your tools receive when they run, and which tools this person gets. The assistant then acts as that person, and can never do more than they may.

What the install fills in

Clerk
Filled in. It uses the Clerk user id, so each person sees only their own conversations. If people work inside organisations, add the organisation to the scope as well.
Auth.js (version 5)
Filled in by npx cognolo init, which can see the version, with the user’s id. Make the change leaves it for you, as it can’t tell version 4 from 5. Auth.js leaves the id out of the session unless your session callback adds it (session.user.id = token.sub); until then the assistant refuses everyone, with a message saying why.
Anything else
Left for you, including Auth.js version 4. Until it is written, open() refuses every request: Cognolo doesn’t guess who your users are.

Writing it yourself

Use your app’s own sign-in check. If nobody is signed in, refuse with a short message the person will see:

async open() {
  const user = await getSignedInUser();   // your app's own sign-in check
  if (!user) throw new AssistantUnavailable("Sign in to use the assistant.");
  return {
    scope: { userId: user.id },   // whose conversations these are
    ctx: { userId: user.id },     // what your tools receive when they run
    tools: toolsFor(user.id),     // only the tools this person may use
    system: "You help people use this app. Use the tools you are given; if you can't do something, say so plainly.",
  };
}
  • Use the person’s id, never their email. An email can change, be reused, or arrive unverified.
  • The scope decides whose conversations a person sees. Each storage helper reaches a conversation only through it, and refuses a scope with a missing value, so nobody sees anyone else’s.
  • Put in `ctx` what your tools need to act as this person: their id, their organisation, their permissions.

Check this file before you merge the install. It is the step that decides who the assistant acts for.

Next

Give it tools.