Skip to content

Commit a1541a5

Browse files
committed
feat: update documentation to reflect new authentication features and protocol namespaces
1 parent f1bcf08 commit a1541a5

9 files changed

Lines changed: 207 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11+
- **`os auth login` — browser-based device flow (Vercel CLI style)** — Running `os auth login` in an interactive TTY no longer requires typing a password into the terminal. The CLI now calls `POST /api/v1/auth/device/request` to obtain a one-time device code, prints the verification URL, auto-opens the browser, and polls `GET /api/v1/auth/device/token` every 2 s until the user approves. A new Studio page at `/_studio/auth/device?code=…` lets authenticated users (or users who sign in inline) approve the request with one click. The old `--email`/`--password` path is preserved for non-interactive / CI use; `--no-browser` skips auto-open. Server-side: two new endpoints (`/device/request`, `/device/token`) and an approval endpoint (`/device/approve`) added to `plugin-auth`; device codes expire after 5 min and are stored in-memory.
12+
- **`os auth register` CLI command** — New `os auth register` command creates an account and stores credentials in one step, with interactive prompts (email, name, password) and `--email`/`--name`/`--password`/`--url` flags for non-interactive use.
13+
- **`os auth login` — already-logged-in guard** — If a valid token already exists in `~/.objectstack/credentials.json`, `os auth login` now prints "Already logged in as \<email\>" and exits 0. Use `os auth logout` first to switch accounts, or pass `--force` to bypass the check.
14+
- **`os auth logout` — server-side session revocation**`os auth logout` now calls `POST /api/v1/auth/sign-out` before deleting the local credentials file, so the session is invalidated server-side. The logout completes successfully even if the API call fails (expired/invalid token).
15+
- **Studio device auth page** — New Studio route `/_studio/auth/device` provides the browser approval UI for the CLI device flow. The page matches the login page visual style (centered card, `bg-muted`, `max-w-sm`, ObjectStack logo). Unauthenticated users see an inline sign-in form; authenticated users see a one-click "Approve CLI Access" button. The `/auth/device` route is added to `PUBLIC_ROUTES` so the auth guard does not redirect before the form renders.
1116
- **`os auth login` / `register` / `me` now work against multi-project servers**`@objectstack/client` was sending requests to better-auth's `/sign-in/email`, `/sign-up/email`, `/sign-out`, `/get-session` without an `Origin` header, which better-auth rejected with `MISSING_OR_NULL_ORIGIN: Missing or null Origin` against the default `trustedOrigins: ['http://localhost:*']`. Auth methods now send `Origin: <baseUrl>` automatically. Additionally, the `login()` and `register()` response normalizer now accepts both the wrapped `{ data: { token, user } }` shape and better-auth's flat `{ token, user }` shape so the CLI's `auth login` flow stores the token correctly.
1217
- **`os projects bind` + `os projects create --artifact` CLI commands** — Third-party developers can now bind a locally-compiled bundle to a multi-project server without raw `curl`. `os projects create --org <id> --name <name> --artifact ./dist/objectstack.json` provisions a new project and seeds the bundle in one call (also supports `--template <id>` for the parity with built-in templates). The new `os projects bind <projectId> --artifact <path>` updates an existing project's `metadata.artifact_path`, with `--build` to run `objectstack compile` first and `--reseed` as a placeholder for the future server-side reseed endpoint. Both flags resolve relative paths to absolute and validate the file exists before issuing the API call. Verified end-to-end: project created via CLI, `/api/v1/projects/{id}/data/account` returns the seeded CRM accounts.
1318
- **Third-party project binding via `metadata.artifact_path`** — Multi-project `POST /api/v1/cloud/projects` now accepts `metadata.artifact_path` to bind a locally-compiled bundle (e.g. `examples/app-crm/dist/objectstack.json`) into a fresh project. Provisioning loads the JSON, registers schemas in the per-project ObjectQL engine, and seeds the bundle's `data` arrays — same pipeline that built-in templates use. New `TemplateSeeder.seedBundle({ projectId, bundle })` method exposes the seeder for arbitrary bundles. Bind errors (read failure, malformed JSON) are recorded as non-fatal `metadata.artifactBindError` so the project still flips to `active`. Verified end-to-end: query `/api/v1/projects/{id}/data/account` returns the seeded CRM accounts.

content/docs/concepts/north-star.mdx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ ObjectOS 的运行时输入分两类,**缺一不可**。把两类混在一起
387387
`ProjectArtifactSchema` envelope,定义在 [packages/spec/src/cloud/project-artifact.zod.ts](packages/spec/src/cloud/project-artifact.zod.ts)
388388

389389
```
390-
{ schemaVersion, projectId, commitId, checksum, builtAt, builtWith, metadata }
390+
{ schemaVersion, projectId, commitId, checksum, metadata, functions, manifest, builtAt, builtWith, payloadRef? }
391391
```
392392

393-
`metadata` 字段就是 `objectstack compile` 产出的 `dist/objectstack.json` 整体。承载所有声明性元数据(objects、views、flows、agents、插件清单等)+ 内联函数代码。Envelope 在外面包一层 `commitId` / `checksum`,让 ObjectOS 能做 ETag 校验和缓存失效。
393+
`metadata` 字段承载声明性元数据(objects、views、flows、agents 等),`functions` 内联可执行源码,`manifest` 声明插件 / driver / engine 要求。Envelope 在外面包一层 `commitId` / `checksum`,让 ObjectOS 能做完整性校验、ETag 校验和缓存失效`payloadRef` 为未来 S3 / signed URL 旁路保留,不需要 envelope 破坏性升级
394394

395395
**B. Deployment Config**(可变、不进 artifact、与元数据正交)
396396

@@ -443,7 +443,7 @@ Subsequent requests reuse the cached artifact. Cache invalidation strategy
443443

444444
## 7. Alignment Check
445445

446-
Honest state of the platform as of 2026-04-25, **re-classified under the Phase
446+
Honest state of the platform as of 2026-04-26, **re-classified under the Phase
447447
1 code-first model**. Every future architectural decision should preserve Built,
448448
reduce Drift, and advance Missing.
449449

@@ -460,6 +460,12 @@ reduce Drift, and advance Missing.
460460
- **Scaffolded TS file tree.** `create-objectstack` emits a `defineStack()` entry point plus split-out `src/objects/*.ts`, `src/views/*.ts` etc. - [packages/create-objectstack/src/index.ts](packages/create-objectstack/src/index.ts).
461461
- **ObjectOS metadata DB bridge removed.** `MetadataPlugin` no longer registers `sys_metadata` / `sys_metadata_history` into the ObjectOS manifest and no longer auto-connects ObjectQL to a `DatabaseLoader`; runtime metadata is hydrated from files or artifacts only - [packages/metadata/src/plugin.ts](packages/metadata/src/plugin.ts).
462462
- **JSON-payload metadata storage.** `sys_metadata.metadata` column is already a textarea-shaped JSON payload column - [packages/metadata/src/objects/sys-metadata.object.ts](packages/metadata/src/objects/sys-metadata.object.ts). (The *location* of the table still needs to move to the control plane - see Drift.)
463+
- **Project artifact envelope schema (M1).** `ProjectArtifactSchema` v0 exists with `schemaVersion`, `projectId`, `commitId`, `checksum`, `metadata`, `functions`, `manifest`, and reserved `payloadRef` - [packages/spec/src/cloud/project-artifact.zod.ts](packages/spec/src/cloud/project-artifact.zod.ts).
464+
- **Project artifact path binding.** Multi-project provisioning accepts `metadata.artifact_path`, and `os projects create --artifact` / `os projects bind --artifact` wire local compiled bundles into existing projects - [packages/cli/src/commands/projects/create.ts](packages/cli/src/commands/projects/create.ts), [packages/cli/src/commands/projects/bind.ts](packages/cli/src/commands/projects/bind.ts).
465+
- **Live kernel bundle resolver.** Project kernels read `sys_project.metadata.artifact_path` / `artifact_paths[]`, with `OBJECTSTACK_PROJECT_ARTIFACTS` and `OBJECTSTACK_PROJECT_ARTIFACT_ROOT` overrides for local development - [apps/server/server/fs-app-bundle-resolver.ts](apps/server/server/fs-app-bundle-resolver.ts).
466+
- **Object identity is single-sourced on `name`.** `ObjectSchemaBase.namespace` has been removed; package namespace remains internal registry metadata, not an object identity field - [packages/spec/src/data/object.zod.ts](packages/spec/src/data/object.zod.ts).
467+
- **Manifest scope enum trimmed.** `ManifestSchema.scope` accepts only `cloud`, `system`, and `project` - [packages/spec/src/kernel/manifest.zod.ts](packages/spec/src/kernel/manifest.zod.ts).
468+
- **Canonical package manifest files.** Plugin/service packages now share a single `src/manifest.ts` between compile-time config and runtime registration, reducing object-list drift.
463469
- **CLI `publish` link.** The end-to-end "local JSON -> remote server" wire is alive, even though the endpoint shape is wrong - [packages/cli/src/commands/publish.ts](packages/cli/src/commands/publish.ts).
464470

465471
### <AlertTriangle className="inline" /> Drift (Needs Cleanup)
@@ -468,18 +474,9 @@ reduce Drift, and advance Missing.
468474
scoped by `organization_id` + `project_id`; deployment target differences are
469475
runtime/deployment configuration, not metadata row partitioning. Branch-like
470476
variants are deferred rather than modeled through `env_id`.
471-
- **`namespace` residue**: deprecated in favor of embedding prefix in object
472-
`name`, but leftovers remain. Schema should be single-sourced on `name` for
473-
identity.
474-
- **Plugin `scope` enum bloat**: grew to 5 values (`cloud` / `system` / `project` /
475-
`platform` / `environment`) with last two marked as deprecated aliases. Break
476-
cleanly, don't carry aliases.
477477
- **Half-wired abstractions**: `ScopedServiceManager` and `SharedProjectPlugin`
478478
were added but their integration into the request path is incomplete. Either
479479
finish them or remove.
480-
- **Recent plugin-config churn** (commit `a4f5eb51`): large reorganization
481-
moving object registration between files without obvious feature value.
482-
Should converge on one home.
483480
- **`objectstack publish` uses the legacy `/api/v1/packages` endpoint.** Today
484481
it POSTs a "package" payload ([packages/cli/src/commands/publish.ts](packages/cli/src/commands/publish.ts))
485482
which is not the Phase 1 project metadata endpoint. It needs to become
@@ -493,7 +490,7 @@ reduce Drift, and advance Missing.
493490
### <Globe className="inline" /> Missing (Not Started)
494491

495492
- **Metadata migration to control plane** - move user metadata out of project DBs into the control-plane DB, scoped by `organization_id` + `project_id`.
496-
- **Project Artifact API** - `GET /api/v1/apps/:projectId/artifact` assembles the current project metadata + inlined function code into a single consumable blob, with content hash/ETag for cache validation.
493+
- **Project Artifact API** - `GET /api/v1/cloud/projects/:projectId/artifact` assembles the current project metadata + inlined function code into a single consumable blob, with content hash/ETag for cache validation.
497494
- **ObjectOS Artifact API loader** - add the production HTTP fetch source for `MetadataPlugin` and local artifact cache durability across control-plane outages.
498495
- **Project publish endpoint** - `POST /api/v1/apps/:projectId/metadata` receives compiled JSON, validates with Zod, writes the current project metadata state, and returns `commitId` + checksum.
499496
- **Studio metadata/artifact viewer** - browse published metadata, artifact envelope, commit id, checksum, publish history, logs, and runtime health. No metadata editing.
@@ -540,9 +537,9 @@ without explicit project-level buy-in.
540537
Questions this document deliberately leaves unresolved. Answer them in follow-up
541538
design docs before building.
542539

543-
1. **Artifact content format details.** Phase 1 chooses a single JSON document,
544-
but the exact envelope, manifest fields, function-code packaging, and driver
545-
requirement declaration still need a Zod schema.
540+
1. ~~**Artifact content format details.**~~ **Resolved (2026-04-26):**
541+
`ProjectArtifactSchema` v0 defines the envelope, manifest requirements,
542+
function-code packaging, checksum, and future `payloadRef` indirection.
546543
2. ~~**Business DB connection config ownership.**~~ **Resolved (2026-04-25):**
547544
Business DB coordinates and credentials are **Deployment Config**, never
548545
part of the Artifact. See §6.3 Runtime Inputs. Cloud mode sources them from

content/docs/concepts/terminology.mdx

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,27 @@ To navigate the ObjectStack ecosystem effectively, it is helpful to understand t
1010
## The Ecosystem
1111

1212
### ObjectStack
13-
The umbrella term for the entire suite of protocols and reference implementations. It is organized into **11 protocol namespaces** grouped into three architectural layers.
13+
The umbrella term for the entire suite of protocols and reference implementations. It is organized into **15 protocol namespaces** grouped into three architectural layers.
1414

1515
### Protocol Namespace
16-
A logical grouping of related schemas and types defined with Zod. ObjectStack has 11 protocol namespaces: Data, Driver, Permission, UI, System, Auth, Kernel, Hub, AI, API, and Automation.
16+
A logical grouping of related schemas and types defined with Zod. ObjectStack has 15 protocol namespaces: Data, UI, System, Automation, AI, API, Identity, Security, Kernel, Cloud, QA, Contracts, Integration, Studio, and Shared.
1717

1818
---
1919

20-
## The 11 Protocol Namespaces
20+
## The 15 Protocol Namespaces
2121

2222
### Data Protocol
2323
Defines the core business data model. Includes Object schema, Field types, Validation rules, Query AST, and Filter conditions. This is the foundation of ObjectQL.
2424

25-
### Driver Protocol
26-
Database adapter interface for connecting to various storage engines (PostgreSQL, MongoDB, SQLite, Redis, etc.). Drivers implement a standard interface for CRUD operations and query execution.
27-
28-
### Permission Protocol
29-
Access control system including object-level permissions (CRUD), field-level security (FLS), sharing rules, and territory management. Determines who can see and modify what data.
30-
3125
### UI Protocol
3226
Server-Driven UI specification for building user interfaces. Includes App structure, Views (List/Form/Kanban/Calendar), Dashboards, Reports, Themes, and Actions.
3327

3428
### System Protocol
3529
Infrastructure services including Event Bus, Job Scheduling, Translation (i18n), and Audit Logging. Manages system-level concerns.
3630

37-
### Auth Protocol
38-
Identity and access management including User accounts, Sessions, Roles, Organization structure, and various authentication strategies (OAuth, SAML, LDAP, etc.).
39-
4031
### Kernel Protocol
4132
Plugin system and runtime management. Includes Plugin lifecycle, Manifest definition, Logger configuration, and Runtime Context. The core of ObjectOS.
4233

43-
### Hub Protocol
44-
SaaS and marketplace features including Multi-tenancy, Licensing, Marketplace plugins, and Deployment configurations. Enables commercial distribution.
45-
4634
### AI Protocol
4735
Artificial intelligence capabilities including AI Agents, RAG pipelines, Natural Language Query (NLQ), Predictive models, Cost tracking, and Orchestration.
4836

@@ -52,6 +40,30 @@ External communication layer including REST contracts, API discovery, Realtime s
5240
### Automation Protocol
5341
Business process automation including Workflows (state machines), Flows (visual logic), and Webhooks (HTTP callbacks).
5442

43+
### Identity Protocol
44+
User, organization, and profile schemas for identity management.
45+
46+
### Security Protocol
47+
RBAC, permissions, policy, and access-control schemas.
48+
49+
### Cloud Protocol
50+
Multi-tenant cloud, deployment, environment, and package distribution schemas.
51+
52+
### QA Protocol
53+
Test, validation, and quality-assurance schemas.
54+
55+
### Contracts Protocol
56+
Cross-package interface contracts shared by runtime packages and services.
57+
58+
### Integration Protocol
59+
External system integration schemas and connection metadata.
60+
61+
### Studio Protocol
62+
Studio UI metadata and builder-specific schemas.
63+
64+
### Shared Protocol
65+
Reusable error maps, suggestions, and metadata normalization utilities.
66+
5567
---
5668

5769
## Architecture Concepts

content/docs/getting-started/cli.mdx

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ os validate path/to/config # Validate specific file
214214

215215
**Warnings checked:**
216216
- Missing `manifest.id` (required for deployment)
217-
- Missing `manifest.namespace` (required for multi-app hosting)
217+
- Invalid `manifest.scope` (must be `cloud`, `system`, or `project`)
218218
- No objects defined
219219
- No apps or plugins defined
220220

@@ -338,6 +338,91 @@ os doctor -v # Show fix suggestions for warnings
338338
- `@objectstack/spec` build status
339339
- Git availability
340340

341+
### Authentication
342+
343+
| Command | Description |
344+
|---------|-------------|
345+
| `os auth register` | Create an account and store local credentials |
346+
| `os auth login` | Sign in and store credentials in `~/.objectstack/credentials.json` |
347+
| `os auth whoami` | Show the current authenticated user |
348+
| `os auth logout` | Revoke the server session and clear local credentials |
349+
350+
#### `os auth register`
351+
352+
Creates a user account and stores the returned token locally.
353+
354+
```bash
355+
os auth register
356+
os auth register --email user@example.com --name "Jane Doe" --password secret
357+
os auth register --url https://api.example.com
358+
```
359+
360+
#### `os auth login`
361+
362+
In an interactive terminal, login uses a browser-based device flow by default:
363+
the CLI prints a one-time verification URL, opens the browser, and polls until
364+
you approve access in Studio.
365+
366+
```bash
367+
os auth login
368+
os auth login --url https://api.example.com
369+
os auth login --no-browser
370+
```
371+
372+
If a valid token already exists, `os auth login` exits successfully with
373+
"Already logged in as <email>". Use `os auth logout` to switch users, or pass
374+
`--force` to re-authenticate.
375+
376+
For CI and other non-interactive contexts, pass email/password directly:
377+
378+
```bash
379+
os auth login --email user@example.com --password secret
380+
```
381+
382+
#### `os auth logout`
383+
384+
Logout calls `POST /api/v1/auth/sign-out` before deleting local credentials, so
385+
the server-side session is revoked as well.
386+
387+
```bash
388+
os auth logout
389+
```
390+
391+
### Cloud Projects
392+
393+
| Command | Description |
394+
|---------|-------------|
395+
| `os projects list` | List projects visible to the current session |
396+
| `os projects show <id>` | Show one project |
397+
| `os projects create` | Provision a new project |
398+
| `os projects switch <id>` | Set the active project for later CLI calls |
399+
| `os projects bind <id>` | Bind a compiled local artifact to an existing project |
400+
401+
#### Create a project from a local artifact
402+
403+
Compile first, then create a project and bind the generated
404+
`dist/objectstack.json` in one call:
405+
406+
```bash
407+
os compile
408+
os projects create --org <org-id> --name CRM --artifact ./dist/objectstack.json
409+
```
410+
411+
The server stores the absolute path in `sys_project.metadata.artifact_path`.
412+
On project-kernel boot, ObjectOS loads the JSON bundle, registers schemas, and
413+
seeds records from the bundle's `data` arrays.
414+
415+
#### Bind an existing project
416+
417+
```bash
418+
os projects bind <project-id> --artifact ./dist/objectstack.json
419+
os projects bind <project-id> --artifact ./dist/objectstack.json --build
420+
```
421+
422+
`--build` runs `objectstack compile` before updating the project. `--reseed`
423+
is reserved for the server-side reseed endpoint; use it only when that endpoint
424+
is available in your deployment.
425+
341426
## Configuration
342427

343428
The CLI looks for `objectstack.config.ts` (or `.js`, `.mjs`) in the current directory:

content/docs/getting-started/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Each app declares a `namespace` in its manifest, but **the short object name is
313313
| CRM | `crm` | `account` | `account` |
314314
| BI | `bi` | `report` | `report` |
315315

316-
If two packages contribute objects with the same short name, the registry logs a warning. In that rare case, callers can disambiguate by passing the FQN (`crm__account`) — but this is the only situation where FQN appears in user code.
316+
If two packages contribute objects with the same short name, the registry logs a warning. Resolve the collision by renaming one object's short `name` (for example, `crm_account`) rather than using FQN strings in user code.
317317

318318
### Run It
319319

0 commit comments

Comments
 (0)