Apps
Build governed React apps on top of the platform's own tools. An app ships as an immutable version, declares exactly which tools it may call, and every call runs as the person using it.
Key Concepts
An app is a private React/TSX application that lives directly under your organization. Its source files and build artifacts are stored in Buckets, and its runtime never talks to the network on its own — every read and write goes through the platform's tool catalog, the same catalog agents use.
Apps run in caller-authorized mode: there is no app principal and no service account. When someone opens an app, the host authenticates them, and each tool call the app makes is checked by IAM against that person's own permissions before anything is dispatched. An app can therefore never do more than its user may do on the platform — a bug in the app does not become an escalation.
Three objects make up an app: the source tree (TSX, CSS, JSON, and static assets), the versions built from it (a mutable draft plus immutable published versions), and the tool policies that allow-list the tools the app may call. Tags group apps for filtering.
Source & Builds
The required files are ergon.json and the modules it declares under modules: the main module (main.tsx unless it names another file) and, for a portal, the auth module (see Build a portal). Every other source file must be imported, directly or indirectly, by at least one module, or the build reports it as unreachable. ergon.json and the declared module files cannot be deleted while they are declared. Dependencies are resolved only from the platform's curated catalog (listed under Dependencies) and pinned in ergon.json. Builds never run npm or contact a package registry, and runtime CDN imports are blocked by the sandbox policy.
Writes are guarded by the app's source version: every file write, patch, or restore sends the expected_source_version it last read, and a stale value is rejected with 409, so two authors — or an author and an agent — never overwrite each other silently. A full rewrite may also send the expected_sha256 of the file it last read. A draft build compiles the tree and returns structured diagnostics; saving a version freezes the artifact, and publishing points the app at one immutable version. Earlier versions can be restored.
Images, fonts, and other binary assets enter the tree through a validated asset import, and the self-hosted font packages are embedded into the same immutable HTML artifact as the app code and CSS.
Size limits are platform settings, the same for every company. The live values are whatever GET /api/v1/apps/catalog/constraints returns. A deployment can lower them; it cannot raise them past this ceiling, and there is no per-company override.
| Limit | Ceiling |
|---|---|
| Source files | 400 |
| Total source | 25 MB |
| One source file | 1 MB |
| One image or font | 2 MB |
| Compiled bundle | 16 MB |
| Build timeout | 60 seconds |
Dependencies
An app declares the packages it imports in ergon.json at these versions, or as *. A plain X.Y.Z version also accepts a compatible ^ range; a prerelease pin such as Glide's accepts only the exact version or *. Each build bundles and minifies them into the app's HTML and stores a sourcemap next to the build record. Packages listed under "bundled with" ship inside another package and cannot be imported on their own.
| Package | Version | License | Use |
|---|---|---|---|
@base-ui/react | 1.7.0 | MIT | Unstyled, accessible React primitives for custom component systems. |
@fontsource-variable/inter | 5.3.0 | OFL-1.1 | Self-hosted Inter variable font, bundled immutably under OFL-1.1. |
@fontsource-variable/jetbrains-mono | 5.3.0 | OFL-1.1 | Self-hosted JetBrains Mono variable font, bundled under OFL-1.1. |
@fontsource-variable/source-sans-3 | 5.3.0 | OFL-1.1 | Self-hosted Source Sans 3 variable font, bundled under OFL-1.1. |
@glideapps/glide-data-grid | 6.0.4-alpha24 | MIT | Canvas-rendered data grid for large, editable tables with smooth scrolling.Prerelease pin: the first Glide release that supports React 19. Declare it as exactly 6.0.4-alpha24 (or *); caret ranges do not match prereleases. Import the stylesheet once. Its peers are bundled with it and cannot be imported on their own.Bundled with: lodash@4.18.1, marked@16.4.2, react-responsive-carousel@3.2.23 |
@hookform/resolvers | 5.9.1 | MIT | Schema adapters for React Hook Form, including Zod. |
@tanstack/react-query | 5.102.8 | MIT | Async state, caching, retries, and request lifecycle management. |
@tanstack/react-table | 9.2.4 | MIT | Headless tables with sorting, filtering, grouping, and pagination. |
@tanstack/react-virtual | 3.14.26 | MIT | Headless virtualization for long lists and large tables. |
class-variance-authority | 0.7.1 | Apache-2.0 | Typed component style variants. |
clsx | 2.1.1 | MIT | Conditional class-name composition. |
d3-array | 3.2.5 | ISC | Statistics, binning, grouping, and sorting helpers for arrays. |
d3-geo | 3.1.2 | ISC | Geographic projections and GeoJSON path generation for SVG maps.Ship the GeoJSON with the App or read it through a tool; the sandbox cannot fetch it. d3-geo expects clockwise exterior rings, the reverse of RFC 7946 GeoJSON: if a shape fills the whole map, reverse its rings. |
d3-scale | 4.0.3 | ISC | Linear, ordinal, time, and color scales for custom charts and maps. |
date-fns | 4.4.0 | MIT | Tree-shakeable date formatting and calculation helpers. |
leaflet | 1.9.4 | BSD-2-Clause | Interactive maps with pan, zoom, and GeoJSON layers.No basemap tiles: the sandbox CSP blocks remote images, so draw GeoJSON layers on a blank map. Create the map in a useEffect on a container ref, give it a view with fitBounds or setView before adding layers, and call map.remove() on cleanup. For markers, use L.circleMarker or pass an imported PNG to L.icon. |
lodash-es | 4.18.1 | MIT | Tree-shakeable ES-module build of the Lodash utilities. |
lucide-react | 1.38.0 | ISC | Tree-shakeable SVG icon components. |
motion | 13.1.1 | MIT | Declarative React animation and gesture primitives. |
qrcode.react | 4.2.0 | ISC | QR code components, for example to show a two-factor otpauth:// address.Renders the code locally as SVG (QRCodeSVG) or canvas (QRCodeCanvas); it needs no network. |
react | 19.1.1 | MIT | Component framework for App interfaces. |
react-dom | 19.1.1 | MIT | React browser renderer used by the canonical App entry point. |
react-hook-form | 7.87.0 | MIT | Performant form state and validation orchestration. |
react-router-dom | 7.18.3 | MIT | Client-side routing for multi-screen App experiences. |
recharts | 3.8.1 | MIT | Composable React charts for dashboards and operational views. |
sonner | 2.0.8 | MIT | Accessible toast notifications for operation outcomes. |
tailwind-merge | 3.6.0 | MIT | Conflict-aware Tailwind utility class merging. |
tailwindcss | 4.3.3 | MIT | Build-time utility CSS compilation with no runtime CDN. |
zod | 3.25.76 | MIT | TypeScript-first runtime schema validation. |
Tool Policies
An app has no tools until you allow-list them. Each policy names one tool slug from the catalog; where the tool exposes trusted resource metadata, the policy can additionally pin an exact resource or a resource prefix — one workflow, one worksheet — narrowing the app below what its users could otherwise reach. No policy means no tool: the server rejects the call before it looks at the arguments.
Policies constrain; they never grant. The final answer always comes from IAM evaluating the current caller, so adding a policy for a tool a user has no permission to use changes nothing for that user.
Runtime Tools
Inside the sandbox the host exposes a small bridge. Before rendering a control, the app can ask whether a tool is available to the current user; it can check a batch of calls at once; and it can invoke a tool and receive the owning service's response. The check is advisory — it lets the UI hide what the user cannot do — and the invoke is authoritative: it re-reads the policy and re-authorizes immediately before any network I/O.
- window.ergon.tools.can(slug, args)
- window.ergon.tools.check([{ slug, args }, ...])
- window.ergon.tools.call(slug, args)
- window.ergon.files.upload(file, { request, confirm })
- window.ergon.files.preview({ file_id } | { request })
These functions exist only in the main module. A portal's auth module has only the sign-in functions described under Build a portal, and a tool or file request from it is refused with bridge_disabled.
File handling stays governed too. Uploads are handed to the host, which runs the owning service's upload flow under the caller's identity; downloads of workflow or worksheet attachments go through short-lived signed URLs that the owning service issues after its own authorization. To show a file without leaving the app, the app asks the host to preview it in response to a user gesture inside the app: the host checks the download-url tool through the app's policy and opens the file over the app, so the sandbox never sees the signed URL. The host enforces the gesture itself: it ignores activation left by its own clicks, refuses a preview for a few seconds after one closes, and caps how many previews an app opens per minute. Buckets files open in the platform's read-only file viewer with HTML isolated; other workflow or worksheet attachments open in a lightweight viewer that picks its renderer from the response content type (image, PDF, script-free sandboxed HTML, bounded text, or a download of the fetched bytes that the browser can only save). For a member without console access, Buckets files open in that lightweight viewer too, fetched through the same download-url tool and the app's policy for it.
An app cannot open popups or point its own frame at another site. Links open in a new tab through the host: platform pages, and download links the app received from its own download-url calls, open directly; any other site first asks the viewer to confirm the destination, because a link can carry data the app has read.
Access
Who may open an app is an IAM decision like any other. The app's members page adds the members and teams who use it. The security page grants permissions on the app to any principal IAM accepts there (members, teams, roles, API keys, agents and other machine principals) through four presets: Viewer (find and see the app without running it), User (open and run it), Editor (also change it), and Owner (everything, including managing grants). Opening an app always requires the use permission, so a Viewer alone cannot run it.
Whether an app shows as private or shared counts only members and teams; a grant to an API key or agent does not make it shared. An agent that authors or maintains an app is covered in the last section.
Granting use of an app is independent of console access. A member whose console access is switched off uses exactly the apps they hold the User preset on, and every tool call those apps make on their behalf works subject to their normal permissions. See Sign-in and access.
Apps Start Page
Every company has an apps start page at /apps/{company_slug}. It lists the apps the signed-in person may use, and only those, each opening the app's published version. When there are none it says “No apps have been shared with you yet”. People who belong to several companies can switch company there (it opens the other company's start page), and people with console access also see a link to the console.
Members without console access land on this page after signing in (after choosing the company on the organizations page, if they belong to several), and console pages send them back to it. Members whose access portal is set to Apps start page land here too, with the console one click away, and so do members whose access portal is a portal app they can't open. There is nothing to configure: publishing an app and granting someone the User preset is what puts it on their start page. Apps that have never been published, and archived apps, are not listed, so publish an app before sharing it.
The page is titled “Your apps” and shows the company's logo (uploaded in IAM → Profile, or the platform logo when none is set). Its address is the company's start URL: signed out, the same address shows the company's sign-in page (see Start URL). Each app on it opens at its own address (see App address). People with console access open the start page from the Your apps link in the console sidebar; it lists the apps they themselves may use.
App Address
Every app has its own address, /apps/{company_slug}/{app_slug} (for example https://platform.ergondata.ai/apps/acme-corp/orders). It opens the app full-window, with nothing around it, and always shows the version that is currently published: publishing a new version changes what the address shows, never the address, so share it once and people keep getting the latest app. The app's Open app button and every entry on the apps start page use it.
Signed out, the address shows the company's sign-in page first and then the app: the built-in company sign-in, or, for an app marked as a portal, the app's own sign-in screen (see Build a portal). The address grants nothing by itself: whoever opens it must be signed in and hold use of the app; anyone without use sees that the app is not available. Working hours, IP allowlists, and Apps service access still apply, and show as a refusal.
The last part of the address is the app's slug, made from its title when the app is created. Change it under Overview → App details → Address, or with the slug field of PATCH /api/v1/apps/{app_id}. Each slug is used by one app per company. The old address keeps opening the app until another app in the company takes that slug, so links already shared keep working. The app's id works in place of the slug too, /apps/{company_slug}/{app_id}, and moves the address bar to the current slug; a slug shaped like an app id is refused with 422. An archived app opens at no address, old or current, until it is restored.
A link to one specific version, from the app's versions, still opens that version, which is useful for reviewing a draft or an older release.
Build a Portal
A portal is an app that carries your company's own sign-in page at its address. Signed-out visitors see a sign-in screen you design; signing in there signs them in to the company, exactly like the start URL, and continues into the app. The company's sign-in methods, SSO domains, two-factor requirement, sign-in protection, and working hours apply without any code in the app. What visitors see in each situation, and why the session is company-wide, is explained in Portals.
1. Declare the auth module
The sign-in screen is the app's auth module, declared next to the main module in ergon.json. Each module is built into its own bundle of the same version, with the same security policy and each with its own size limit. A module path is a .tsx file in the app, written plainly (no ./), outside _dist/, and the two modules are different files. A static app ("profile": "static") cannot have an auth module.
{
"name": "Customer portal",
"version": "1",
"modules": { "main": "main.tsx", "auth": "auth.tsx" },
"dependencies": { "react": "19.1.1", "react-dom": "19.1.1" }
}The easiest way is the modules field of PATCH /api/v1/apps/{app_id} (the apps.apps.update tool), or the app's settings in the console. The platform writes ergon.json for you, and when auth.tsx does not exist yet it creates a starter sign-in screen that already handles passwords, single sign-on, codes, password reset, and two-factor setup; an existing file is never overwritten. "auth": null removes the auth module. You can also edit ergon.json yourself and create the file. Older apps that still say "entry": "main.tsx" keep building; write modules instead.
2. What the auth module may do
- It draws the screen with any React code and catalog package, and calls only
window.ergon.auth. It has nowindow.ergon.toolsorwindow.ergon.files; such a request is refused withbridge_disabled. - It cannot fetch anything or load scripts, fonts, or images from other addresses: import your logo as an asset (
import logo from "./assets/logo.svg"). - It does see what people type into it, and hands it to the platform. That is why, on an app marked as a portal, publishing a changed auth module needs
iam:company:settings, and why a portal's sign-in is only ever offered for the company that owns the app. It never receives tokens, cookies, the two-factor challenge, or the password reset token. Keep typed passwords and codes in component state only. - It must not navigate its own frame (for example by setting
location.href): the platform closes a frame that loads another page and stops answering it. Use an ordinary link (<a href>): the platform opens it, and asks first before leaving for another site. - Anyone can load it without signing in. Never put confidential content in the auth module or in any file it imports.
3. The sign-in functions
Every function returns a promise. Every answer about the sign-in resolves with an object whose status says what happened. The promise rejects only when the call itself is wrong (bad arguments, too many calls at once) or gets no answer within 60 seconds; the error's code says which, for example invalid_arguments or timeout. Show a generic error for a rejection, never “wrong password”.
| Call | Resolves with |
|---|---|
context() | The company (name, slug), the sign-in methods it allows, the person's language, the step to show first, the email of someone already signed in on this browser, and the reason a Google or Microsoft sign-in was refused. |
signIn({ email, password }) | entered, no_access, mfa_required (with attempts_left), enrollment_required, or failed. A failed answer once the password was accepted (for example outside working hours) means the person is signed in: call finish() to try again. |
verifyCode({ code }) or verifyCode({ recovery_code }) | entered, no_access, or failed (with attempts_left after a wrong code). Pass exactly one of the two. As with signIn, a failed answer after the code was accepted is retried with finish(). |
startSso({ provider: "google" | "microsoft" }) | The whole browser window leaves for the provider and comes back to the app's address, so the promise never settles; failed (method_not_allowed) when the provider is not in context().methods. |
forgotPassword({ email }) | password_reset_sent, whatever the email: it never reveals whether an account exists. |
resetPassword({ password }) | password_reset, or failed (reset_link_invalid, password_rejected). |
resendVerification({ email }) | verification_sent, whatever the email: it never reveals whether an account exists. |
openTwoFactorSetup() | Opens the platform's two-factor setup dialog over the app; entered or no_access when done, cancelled when closed. A failed answer after setup (for example outside working hours) means setup is done: call finish() to try again. |
startTwoFactorSetup() | two_factor_setup, with secret and otpauth_uri; or failed (challenge_expired, too_many_attempts, not_available, failed). |
confirmTwoFactorSetup({ code }) | recovery_codes, with recovery_codes; or failed (invalid_code). |
finish() | entered or no_access, or failed again. Call it after the recovery codes were shown, or to try again after a failed answer from a step that signed the person in; otherwise failed (not_available). |
cancel() | cancelled: drops a pending code step, a two-factor setup, or the reset link, and goes back to the sign-in screen. |
context().step says which screen to show first: sign_in, mfa_required or enrollment_required (back from Google or Microsoft and the company asks for its two-factor code), or reset_password (opened from a reset link). The platform reads what the provider or the reset link put in the address and removes it before the auth module loads, so the module never parses the URL. Offer only the methods in context().methods: the company's settings decide them, and a method it does not allow is refused anyway.
After a sign-in completes, entered means the platform removes the sign-in screen and opens the main module fresh (code after the call may never run), and no_access means it shows its own “you don't have access to this app” screen and never loads the main module. A failed result has a reason and a readable message in the person's language:
| reason | What to show |
|---|---|
invalid_credentials | Wrong email or password. Also the answer for an unknown email and for an account locked after too many attempts. |
email_not_verified | Offer to resend the verification email. |
account_locked | The account is disabled; only an administrator can turn it back on. A temporary lock after wrong passwords answers invalid_credentials instead. |
method_not_allowed | The company does not allow this method here. |
outside_working_hours | The person may sign in only during their working hours; message says when they can sign in again, when that is known. |
invalid_code | Wrong authenticator or recovery code; show attempts_left. |
challenge_expired | The code step took too long; sign in again. |
too_many_attempts | Too many wrong codes, or too many tries in a short time; sign in again or wait a moment. |
reset_link_invalid | The reset link expired or was used; send a new one. |
password_rejected | The new password does not meet the password rules. |
not_available | The call does not apply right now (back to the sign-in screen), or another sign-in step is still running (wait for its answer). |
failed | Anything else, such as a network the company does not allow; show message. |
The platform runs one call at a time: a call made while another is still running answers not_available, so disable the button until the answer arrives. When the person changes the language before signing in, the auth module loads again from the start and reads the new context().locale; the step to show is kept. Once someone is signed in through the auth module but the app did not open, the platform offers Sign out above it, and the module loads again from the start. An error thrown in the module shows a general message from the platform, never the module's own text.
Google and Microsoft sign-in leaves for the provider in the whole browser window and comes back to the app's address, where the auth module loads again from the start. When the provider refused, context().sso_error is one of sso_method_not_allowed, sso_domain_not_allowed, sso_account_unverified, sso_signup_not_allowed, or sso_failed.
A password reset requested from the portal emails a link back to the portal's address when the account is a member of the company; for anyone else the email carries the platform's usual reset link. forgotPassword answers password_reset_sent either way. The portal's link opens the auth module at reset_password, except that it goes to the platform's reset page when the portal's sign-in cannot load by then, or when the person is already signed in.
4. A complete sign-in screen
Password, Google and Microsoft, two-factor and recovery codes, forgot and reset password, an unverified email, and two-factor setup through the platform's dialog:
// auth.tsx — the portal's sign-in screen
import { StrictMode, useEffect, useState, type FormEvent } from "react";
import { createRoot } from "react-dom/client";
import logo from "./assets/logo.svg";
type Result = {
status: string;
reason?: string;
message?: string;
attempts_left?: number;
};
type Context = {
company: { name: string; slug: string };
methods: string[];
step: "sign_in" | "mfa_required" | "enrollment_required" | "reset_password";
email?: string;
sso_error?: string;
};
type Screen = "loading" | "sign_in" | "code" | "forgot" | "sent" | "reset" | "unverified";
const auth = (window as any).ergon.auth;
function SignIn() {
const [ctx, setCtx] = useState<Context | null>(null);
const [screen, setScreen] = useState<Screen>("loading");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [code, setCode] = useState("");
const [recovery, setRecovery] = useState(false);
const [message, setMessage] = useState<string | null>(null);
useEffect(() => {
auth.context().then((c: Context) => {
setCtx(c);
setEmail(c.email ?? "");
if (c.sso_error) setMessage("That Google or Microsoft sign-in did not work. Try again or use another way.");
if (c.step === "mfa_required") setScreen("code");
else if (c.step === "reset_password") setScreen("reset");
else if (c.step === "enrollment_required") void enroll();
else setScreen("sign_in");
});
}, []);
// entered and no_access: the platform replaces this screen.
function handle(r: Result) {
setPassword("");
setCode("");
if (r.status === "mfa_required") setScreen("code");
else if (r.status === "enrollment_required") void enroll();
else if (r.status === "password_reset_sent") setScreen("sent");
else if (r.status === "verification_sent") setMessage("If your account needs it, a new email is on its way.");
else if (r.status === "password_reset") {
setMessage("Password changed. Sign in with your new password.");
setScreen("sign_in");
} else if (r.status === "cancelled") setScreen("sign_in");
else if (r.status === "failed") {
if (r.reason === "email_not_verified") return setScreen("unverified");
if (r.reason === "challenge_expired" || r.reason === "too_many_attempts") setScreen("sign_in");
if (r.reason === "invalid_credentials") return setMessage("Email or password is incorrect.");
if (r.reason === "invalid_code" && r.attempts_left !== undefined) {
return setMessage("That code didn't work. Attempts left: " + r.attempts_left);
}
// message is written for the person, in their language.
setMessage(r.message ?? "Something went wrong.");
}
}
// A rejection means the call itself was wrong or timed out, never a wrong password.
function run(call: () => Promise<Result>) {
setMessage(null);
call().then(handle, () => setMessage("Something went wrong. Try again."));
}
function enroll() {
// The platform's own setup dialog: QR code, first code, recovery codes.
run(() => auth.openTwoFactorSetup());
}
function submit(event: FormEvent, call: () => Promise<Result>) {
event.preventDefault();
run(call);
}
if (!ctx || screen === "loading") return <main>Loading…</main>;
const allows = (method: string) => ctx.methods.includes(method);
return (
<main className="card">
<img src={logo} alt={ctx.company.name} />
{message && <p role="alert">{message}</p>}
{screen === "sign_in" && (
<>
{allows("password") && (
<form onSubmit={(e) => submit(e, () => auth.signIn({ email, password }))}>
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} required />
<button>Sign in</button>
<button type="button" onClick={() => setScreen("forgot")}>Forgot password?</button>
</form>
)}
{allows("google") && (
<button onClick={() => run(() => auth.startSso({ provider: "google" }))}>Continue with Google</button>
)}
{allows("microsoft") && (
<button onClick={() => run(() => auth.startSso({ provider: "microsoft" }))}>Continue with Microsoft</button>
)}
</>
)}
{screen === "code" && (
<form onSubmit={(e) => submit(e, () => auth.verifyCode(recovery ? { recovery_code: code } : { code }))}>
<input value={code} onChange={(e) => setCode(e.target.value)} autoComplete="one-time-code" required />
<button>Verify</button>
<button type="button" onClick={() => setRecovery(!recovery)}>
{recovery ? "Use the authenticator code" : "Use a recovery code"}
</button>
<button type="button" onClick={() => run(() => auth.cancel())}>Back</button>
</form>
)}
{screen === "forgot" && (
<form onSubmit={(e) => submit(e, () => auth.forgotPassword({ email }))}>
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
<button>Send reset link</button>
</form>
)}
{screen === "sent" && <p>If an account exists for {email}, a reset link is on its way.</p>}
{screen === "reset" && (
<form onSubmit={(e) => submit(e, () => auth.resetPassword({ password }))}>
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} required />
<button>Save new password</button>
</form>
)}
{screen === "unverified" && (
<>
<p>Confirm your email with the link we sent to {email}, then sign in.</p>
<button onClick={() => run(() => auth.resendVerification({ email }))}>Resend email</button>
<button onClick={() => setScreen("sign_in")}>Back</button>
</>
)}
</main>
);
}
createRoot(document.getElementById("root")!).render(
<StrictMode>
<SignIn />
</StrictMode>,
);5. Two-factor setup, two ways
When the company requires two-factor and the person has none, sign-in answers enrollment_required. The recommended answer is openTwoFactorSetup(): the platform shows its own setup dialog over the app (QR code, key, first code, recovery codes) and continues the sign-in. The starter screen does this.
To draw the setup yourself, call startTwoFactorSetup(), draw a QR code of otpauth_uri with qrcode.react (in the catalog) and show secret for manual entry, send the first code to confirmTwoFactorSetup(), show the recovery_codes it returns until the person confirms they saved them, then call finish().
// Add "qrcode.react": "4.2.0" to ergon.json dependencies.
import { useEffect, useState } from "react";
import { QRCodeSVG } from "qrcode.react";
const auth = (window as any).ergon.auth;
export function TwoFactorSetup() {
const [setup, setSetup] = useState<{ secret: string; otpauth_uri: string } | null>(null);
const [codes, setCodes] = useState<string[] | null>(null);
const [code, setCode] = useState("");
const [saved, setSaved] = useState(false);
useEffect(() => {
auth.startTwoFactorSetup().then((r: any) => r.status === "two_factor_setup" && setSetup(r));
}, []);
async function confirm() {
const r = await auth.confirmTwoFactorSetup({ code });
if (r.status === "recovery_codes") setCodes(r.recovery_codes);
}
if (codes) {
// Required: people need these codes if they lose their phone.
return (
<section>
<h1>Save your recovery codes</h1>
<ul>{codes.map((c) => <li key={c}><code>{c}</code></li>)}</ul>
<label>
<input type="checkbox" checked={saved} onChange={(e) => setSaved(e.target.checked)} />
I saved these codes
</label>
<button disabled={!saved} onClick={() => auth.finish()}>Continue</button>
</section>
);
}
if (!setup) return <p>Preparing…</p>;
return (
<section>
<QRCodeSVG value={setup.otpauth_uri} size={192} />
<p>Or type this key: <code>{setup.secret}</code></p>
<input value={code} onChange={(e) => setCode(e.target.value)} inputMode="numeric" />
<button onClick={confirm}>Confirm</button>
</section>
);
}Always show the recovery codes
Recovery codes are the only way back in for someone who loses their phone, and they are shown once. A custom setup that skips them locks people out.
6. Publish and mark the portal
- Build, save a version, and publish it. Builds and versions show whether they carry an auth module (
auth_module). - Mark the app as a portal in its settings, or with
PUT /api/v1/apps/{app_id}/portal(theapps.apps.portal.settool). This needsapps:apps:manageon the app andiam:company:settingson the company, and a published version with an auth module; otherwise the answer is 409portal_requires_auth_module. An app that expires (a conversation app not saved to the library) answers 409portal_requires_library_app. Marking and unmarking are recorded asapps.app.portal.markedandapps.app.portal.unmarked. - Share the app's address. Open it in a private window to see what signed-out visitors see.
curl -X PUT https://platform.ergondata.ai/api/v1/apps/{app_id}/portal \
-H "Authorization: Bearer {token}" \
-H "X-Company-Id: {company_id}" \
-H "Content-Type: application/json" \
-d '{ "portal": true }'Once the app is a portal, its auth module is the company's sign-in page. Publishing or rolling back to a version without an auth module is refused with portal_requires_auth_module (unmark the app first), and a version whose auth module differs from the published one also needs iam:company:settings. Versions that change only the main module need only the usual edit permission. Archiving or deleting a portal also needs iam:company:settings and unmarks it first; unarchiving does not mark it again.
7. Land people in it and open other apps
A portal can be the access portal where people land after signing in, for the whole organization in IAM → Sign-in or for single members in IAM → Users (see Land people in a portal app). Its main module can then act as their home: two launcher tools list the other apps the person may use and open one. Add a tool policy for each (no resource scope) before calling them.
apps.launcher.listreturnsitems: the published apps the person may use in the company, by title, as their apps start page lists them, 100 at a time (limitup to 200,offset, andtotalfor all of them). Each hasid,title,descriptionandslug; the host addsaddress, the app's full address, andcurrent, true for the app making the call.apps.launcher.openwith{ slug }(a former slug or the app's id also work) checks the person may open that app and returns it with its current slug and address. Where the calling app fills the window (its own address or a version preview), the host then leaves it and opens the other app there; in the builder preview and in chat the result only carries the address. An app the person may not use, or that is not published, answers 404 and nothing happens.
const { items } = await window.ergon.tools.call("apps.launcher.list", {});
const others = items.filter((app) => !app.current);
// later, when the person picks one:
await window.ergon.tools.call("apps.launcher.open", { slug: others[0].slug });The launcher only shows and opens what the person could already reach: it needs no permission beyond using the apps themselves, and grants nothing. Any app can call these tools, not only portals.
Agents as Authors
Every authoring operation — create an app, read and write files, build, save and publish versions, manage tool policies — is also a tool in the catalog, under the same permissions a human author would need. An agent asked for an operational screen loads the platform manuals of the services the app composes, writes modular TSX against the current source version, builds, reads the diagnostics, and publishes. The result is an app the team owns, with no special path and no hidden authority.
Not in this release
Public users without a platform account, public share links, custom domains, and an app-specific chat protocol are deferred. The Apps API reference lists exactly what is callable today.