## Build an embedded app Your own web application appears inside AANCER. It stays on your own server. > need: the licence feature Embedded apps. ### Prepare your server 1. Give the app its own https address, for example `https://planner.example.com`. 2. Let its pages send this header, with the address of AANCER: ```text Content-Security-Policy: frame-ancestors https://aancer.example.com ``` 3. Remove `X-Frame-Options` if your server sends it. ### Write the pack 1. Put this item into the manifest: ``` { "kind": "app", "schemaVersion": 2, "id": "shift-board", "scope": "workspace", "workspace": "{{param.target_workspace}}", "spec": { "id": "shift-board", "title": "Shift board", "icon": "Table", "group": "Operations", "order": 31, "url": "https://planner.example.com/board.html", "origin": "https://planner.example.com", "sso": { "mode": "none" }, "capabilities": ["read:dataset:shift_plan"], "egress": { "hosts": [] }, "embed": { "sandbox": ["allow-scripts", "allow-same-origin"] } } } ``` 2. Ask only for what the app needs: | Capability | Allows the app to | |-|-| | `read:me` | know who the user is | | `read:dataset:` | read a dataset | | `write:dataset:` | write into a dataset | | `query:model:` | ask a model of a dashboard | | `navigate` | open another page | | `notify` | show a short message | ### Read data in your page 1. Take `bridge.js` from the example `examples/apps/shift-board`. 2. Connect and read: ``` const PLATFORM = 'https://aancer.example.com'; const bridge = await AancerBridge.connect({ platformOrigin: PLATFORM }); const result = await bridge.call('read:dataset', { datasetId: 'shift_plan', limit: 100 }); render(result.rows); ``` ### Install and approve 1. Sign, import, activate. 2. Open the pack and choose **Manage app**. 3. Read what the app wants and choose **Approve**. 4. If it uses sign-in, choose **Create app secret** and give the secret to the person who runs the app server. It is shown once. 5. Open the app under **Dashboards**. ### Know who the user is (sign-in) Use `"sso": { "mode": "code" }`. The complete program is in `examples/apps/shift-planner`. This is what happens: 1. Your server makes a secret pair (PKCE) and gives one half to the page. 2. The page says hello to AANCER and receives a code. It is valid for 60 seconds, once. 3. Your server exchanges the code for a token at `/api/apps/oauth/token`. 4. Your server checks the token at `/api/apps/introspect`. The answer says who it is. > warn: Keep the app secret and the token on the server. Never send them to the browser. Do not use the role to decide what somebody may do. ## Build a connector A connector links another system. You write it in TypeScript with the connector framework `@aancer/connector-framework` from the developer kit. On your developer edition you sign it yourself. For customers, AANCER certifies and signs it. ### Write it 1. Run `aancer-pack init connector my-items`. You get a working project: an API key connection, two actions and a polling trigger. 2. Install the framework from the kit file, then build: ``` cd my-items npm install /absolute/path/to/aancer-connector-framework-.tgz npm install npm run build ``` 3. Use these names: `createConnector`, `createAction`, `createTrigger`, `ConnectorAuth`, `Property`, `TriggerStrategy`. The older names `createPiece` and `PieceAuth` still work but are deprecated. 4. Name the hosts it calls in `pack.json` under `egressHosts`. A `*` alone is not allowed. 5. If every customer runs the system themselves, use `egressFromConnection` instead. 6. Look at the three reference connectors: [API key](https://aancer.ai/dev/manual/examples/reference-connectors/apikey-contacts/src/index.ts), [OAuth2](https://aancer.ai/dev/manual/examples/reference-connectors/oauth2-tasks/src/index.ts) and [webhook](https://aancer.ai/dev/manual/examples/reference-connectors/webhook-events/src/index.ts). ### Run and check it on your computer 1. Run one step: `aancer-pack connector run create_item --props test/props.create_item.json --auth test/auth.json`. Keep `test/auth.json` out of git. 2. Check the certification rules: `aancer-pack connector check`. It lists every problem, one per line. The rules: no install scripts in any dependency, no native add-ons, no known vulnerabilities, only MIT, ISC, BSD-2-Clause, BSD-3-Clause, Apache-2.0 or 0BSD licences, and `package-lock.json` is included. ### Try it on your developer edition 1. Run `aancer-pack trust-key --print`. In **Admin** > **Extensions**, choose **Add trust key**, paste it and tick **Developer key**. 2. Run `aancer-pack connector pack`. You get a signed `.ancpack` file in `dist-pack/`. 3. Choose **Admin** > **Extensions** > **Import pack**, pick the file and activate it. 4. In **Admin** > **Connectors** > **Catalog**, enable it, add a connection and use it in a workflow. Or run `aancer-pack dev --target http://localhost --trust-key-on-target --watch` and it does steps 1 to 3 on every save. Other editions refuse a pack signed with your key. ### Submit for customers 1. Submit the source through [aancer.ai/partners](https://aancer.ai/partners). 2. You get back a signed `.ancpack` file. 3. Choose **Connectivity** > **Connectors** > **Add from files** and pick it. 4. Choose **Enable**. Only now may it reach its hosts. 5. Create a connection and use it. ## Use the API and the MCP server ### Call the API Every page of AANCER uses the API under `/api`. You sign in with a token from your sign-in service. 1. Put the token into `TOKEN`. 2. Call, for example: ``` export AANCER=https://aancer.example.com # import a pack curl -X POST "$AANCER/api/extensions/packs/import" \ -H "Authorization: Bearer $TOKEN" \ --data-binary @acme.business-skills-1.0.0.ancpack # activate it curl -X POST "$AANCER/api/extensions/packs/acme.business-skills/activate" \ -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \ -d '{"version":"1.0.0"}' ``` | What | Where | |-|-| | Packs | `/api/extensions` | | Agents | `/api/agents` | | Workflows | `/api/automations` | | Skills | `/api/skills` | | Dashboards | `/api/dashboards`, `/api/models`, `/api/widgets` | | Hooks | `/api/event-hooks` | | Apps | `/api/apps` | If a right is missing, the answer is 403 and names it. ### Let another AI program use your agents > need: the licence features for the MCP server and chat surfaces, and the right `mcp.tokens_own`. 1. Create a personal MCP token (right `mcp.tokens_own`), or ask an administrator for one. 2. Copy it. It is shown once. 3. Enter this in the other program: ``` { "mcpServers": { "aancer": { "type": "http", "url": "https://aancer.example.com/mcp/v1", "headers": { "Authorization": "Bearer mcp_..." } } } } ``` 4. Ask there: "Use find_agent to find the invoice agent, then ask it to summarise this week's open invoices." If an agent wants to change something, the answer is "approval required" with a link. A person decides in AANCER. ## Publish in the certified catalog 1. Become a partner at [aancer.ai/partners](https://aancer.ai/partners). 2. Add these two blocks to the manifest: ``` "listing": { "v": 1, "summary": "Sorts incoming invoices.", "category": "finance" }, "declarations": { "v": 1, "licence": "LicenseRef-Acme-Commercial", "dataFlows": [ { "purpose": "Read invoices to extract amounts", "data": ["invoice-documents"], "personalData": true, "destination": "installation" } ], "egress": [], "aiUse": { "intendedPurpose": "Drafts a proposal a person approves", "annexIII": false, "humanOversight": "approval-step" }, "attestations": { "ownsRights": true, "noProhibitedPractice": true } } ``` 3. Check the pack: ```bash aancer-pack lint manifest.json content/ ``` 4. Correct every line it prints. 5. Submit the pack. AANCER checks and certifies it. > warn: The two statements under `attestations` are legally important: you own the rights, and there is no prohibited practice. Only confirm what is true. ## When something does not work | Message | What to do | |-|-| | `PACK_UNSIGNED` | Sign the pack | | `PACK_SIGNATURE_INVALID` | A file changed after signing, or an unused file is in `content/`. Sign again | | `PACK_SIGNER_UNKNOWN` | The administrator adds your public key | | `PACK_SIGNER_NOT_ALLOWED` | It is a connector. Submit it | | `PACK_SCHEMA_INVALID` | Read the path in the message and correct that field | | `PACK_VERSION_CONFLICT` | Raise `version` | | `PACK_PLATFORM_INCOMPATIBLE` | Correct `requires.platform`, or update the installation | | `PACK_PARAMETER_MISSING` | Fill in the parameters when activating | | `EXTENSION_REFERENCED` | Remove what depends on it first | | `TPL_RESIDUAL_BINDING` | A step still holds an id. Use a parameter | | `TPL_SECRET_FOUND` | Remove the password or key | | `TPL_AIACT_REQUIRED` | Set risk class and purpose | | `AGENT_BLUEPRINT_REF` | Knowledge must be a parameter; workflow and agent must be in the pack | | `HOOK_HANDLER_INACTIVE` | Publish the workflow with an event trigger, then enable the hook | | `THEME_ILLEGIBLE` | Choose colours with more contrast | | `APP_EMBED_REFUSED` | Correct the header of the app | | `APP_ORIGIN_UNAPPROVED` | An administrator approves the app | | 403 Permission denied | The answer names the missing right | All messages are in the **AANCER Developer Reference**. ### Checklist before you deliver - The pack was tested in a test installation - `aancer-pack verify` prints OK - `version` was raised - No passwords, keys or ids of an installation inside - Workspaces and connections are parameters - Removing and installing again works - The customer has your public key and key id - You told the customer which rights and licence features are needed End of AANCER Developer Guide (English), step by step. All parts: https://aancer.ai/dev/llms.txt