Files
inkreach-teable-cli/.agents/skills/inkreach-teable/guides/instance-access.md
T
yeuimu e1a91dfa84 feat(cli+skill): make documented field UX real + fix skill doc drift
CLI (packages/inkreach-cli):
- new src/lib/field-normalize.ts: type aliases (sel/num/text/mul/…),
  select string-choices -> {name}, compact --fields 'Name:type:choices'
  expansion, smart type inference from --options shape / --name
  (--type now optional), name->ID resolution for foreignTableName /
  linkFieldName / lookupFieldName (incl. link-field foreignTableId
  backfill + unknown-key stripping), rating/number/button required-
  option defaults
- field create: +--description/--lookup-options/--is-lookup
- field update --options + table create --fields route through the
  normalizer; DEFAULT_ENDPOINT :3000 -> :3003
- 20 unit tests (field-normalize.spec.ts, vitest); live-verified:
  string choices, alias, foreignTableName, lookup-by-names, compact
  format, inference (priority->singleSelect, max:5->rating)

Skill docs (.agents/skills/inkreach-teable):
- ports :3000 -> :3003 everywhere (backend real port; :3000 is an
  unrelated container on this host)
- remove dead hr_admin account; note throwaway signup + real admin
- plugin register: actual URL-based flags; document plugin csp
  list/set; view/dashboard install requires config enable first
- field-types.md marked verified-2026-08 (aliases/inference/name
  resolution now implemented + tested)
- development.md: webpack dist/index.js cache trap; PGPASSWORD
  placeholder instead of wrong literal
2026-08-16 05:58:01 +00:00

90 lines
4.4 KiB
Markdown

# Instance Access
How to reach the deployed inkreach-teable instance, acquire credentials, and
verify health. This file describes the **reference deployment** — adapt
endpoint/ports for your own deployment.
## Connection
| Service | URL / Port | Mode | Purpose |
|---------|-----------|------|---------|
| Backend API | `http://localhost:3003` | production (`NODE_ENV=production`) | REST API, automation engine, websocket |
| Frontend | `http://localhost:3002` | production | End-user web UI (Next.js) |
| PostgreSQL | `localhost:5432` | — | Database (db: `teable`, user: `teable`) |
| Redis | `localhost:6379` | — | BullMQ queue for automation runs, distributed lock |
- The frontend reads `SOCKET_PORT` from `.env` to point its websocket at the backend — verify it equals the backend port (3003 on this host), not the default 3001.
- End users browse `:3002`. The backend `:3003` is the API only (`BACKEND_SKIP_NEXT_START=true` disables the embedded Next server).
- ⚠️ Port map differs from upstream Teable docs (:3000) — on this host `:3000` is held by an **unrelated container** (`inkreach-web`). Always verify with `ss -tlnp` before assuming.
## Health Checks
```bash
# Backend API up?
curl -s -o /dev/null -w '%{http_code}' http://localhost:3003/api/auth/signin -X POST \
-H 'Content-Type: application/json' -d '{}' # expect 401 (endpoint exists, bad creds)
# Frontend up?
curl -s -o /dev/null -w '%{http_code}' http://localhost:3002 # expect 307 or 200
# Ports listening?
ss -tlnp | grep -E ':3003|:3002|:5432|:6379'
```
If `:3003` is unreachable but systemd shows `active`, the worker likely OOM-crashed while the `pnpm` parent stayed alive:
```bash
systemctl --user stop teable-backend.service
pkill -9 -f 'dist/index.js'
systemctl --user start teable-backend.service
```
## Acquiring a PAT (Personal Access Token)
The CLI authenticates with a PAT (`teable_{id}_{encryptedSign}`). Two ways to get one:
### Option A — via the CLI (needs a session cookie or existing token)
```bash
inkreach-teable auth token create --name my-cli \
--scopes automation|read,automation|create,automation|update,automation|delete,table|read,record|read,record|create,record|update \
--base-ids bseXXX --expires 2099-12-31
# → prints full token ONCE
```
Note: `auth token list/create` may require a **session** (browser login) rather than a PAT — if you get 403, use Option B.
### Option B — via the web UI (recommended for the first token)
1. Log in to `http://localhost:3002` as an admin.
2. User menu → **Settings** → **Personal Access Tokens**.
3. Create a token with scopes: `automation|*`, `table|*`, `record|*`, `field|*`, `view|*` as needed. Limit to the base if desired.
4. Copy the `teable_xxx_yyy` string.
### Configure the CLI
```bash
inkreach-teable auth login --endpoint http://localhost:3003 --token <PAT> --base-id bseXXX
inkreach-teable auth status # verify
```
## Reference Credentials (local dev)
> Never commit real secrets. The reference dev instance uses:
> - ⚠️ The old admin account `hr_admin@xingchen.tech` **no longer exists** (verified 2026-08). Current users: `inkreach@inkreach.pod` (admin) — password: ask maintainer, browser login only.
> - Throwaway accounts for testing can be created via `POST /api/auth/signup` (open on this instance).
> - Base: `bseeZR7yiDNeMPCa4CN` (人事薪资管理) — the test base with ~600 automations.
> - Test table: `tblzPOXQvUruQosKNP5` (has button fields for automation testing).
For CLI use, **always prefer a PAT** over the admin password.
## Permissions
- PAT scope ∩ base role = effective permission. To manage automations you need `automation|read/create/update/delete` scopes **and** a role of editor+ on the base.
- Roles: owner (all), creator (all on the base), editor (read/create/update), commenter (read), viewer (read).
- Workflows auto-create an internal token on activation (name `workflow:{id}`, scope limited to table/record read+write) — used by action nodes, not for CLI auth.
## Troubleshooting Access
| Symptom | Fix |
|---------|-----|
| `401 Unauthorized` | Token wrong/expired → recreate PAT, `auth login` again |
| `403 Forbidden` | Token lacks scope, or base role too low → widen scopes / raise role |
| `404 Base not found` | Wrong base id, or endpoint points to a different instance → `auth status`, check `--base-id` |
| Connection refused | Backend down → health check, restart service (see [development.md](development.md)) |