@elevasis/sdk 1.23.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cli.cjs +5408 -6605
  2. package/dist/index.d.ts +183 -242
  3. package/dist/index.js +1829 -2912
  4. package/dist/node/index.d.ts +3722 -2
  5. package/dist/node/index.js +163 -1
  6. package/dist/test-utils/index.d.ts +60 -72
  7. package/dist/test-utils/index.js +239 -1479
  8. package/dist/types/worker/index.d.ts +2 -0
  9. package/dist/types/worker/utils.d.ts +9 -0
  10. package/dist/worker/index.js +260 -1487
  11. package/package.json +5 -4
  12. package/reference/_navigation.md +1 -0
  13. package/reference/claude-config/rules/active-change-index.md +11 -80
  14. package/reference/claude-config/rules/agent-start-here.md +11 -277
  15. package/reference/claude-config/rules/deployment.md +11 -57
  16. package/reference/claude-config/rules/error-handling.md +11 -56
  17. package/reference/claude-config/rules/execution.md +11 -40
  18. package/reference/claude-config/rules/frontend.md +11 -43
  19. package/reference/claude-config/rules/observability.md +11 -31
  20. package/reference/claude-config/rules/operations.md +11 -80
  21. package/reference/claude-config/rules/organization-model.md +5 -110
  22. package/reference/claude-config/rules/organization-os.md +7 -111
  23. package/reference/claude-config/rules/package-taxonomy.md +11 -33
  24. package/reference/claude-config/rules/platform.md +11 -42
  25. package/reference/claude-config/rules/shared-types.md +10 -48
  26. package/reference/claude-config/rules/task-tracking.md +11 -47
  27. package/reference/claude-config/rules/ui.md +11 -200
  28. package/reference/claude-config/rules/vibe.md +5 -229
  29. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  30. package/reference/claude-config/sync-notes/2026-05-15-om-skill-rename-and-write-family.md +2 -2
  31. package/reference/claude-config/sync-notes/2026-05-17-sdk-boundary-consolidation.md +33 -0
  32. package/reference/rules/active-change-index.md +83 -0
  33. package/reference/rules/agent-start-here.md +280 -0
  34. package/reference/rules/deployment.md +60 -0
  35. package/reference/rules/error-handling.md +59 -0
  36. package/reference/rules/execution.md +43 -0
  37. package/reference/rules/frontend.md +46 -0
  38. package/reference/rules/observability.md +34 -0
  39. package/reference/rules/operations.md +85 -0
  40. package/reference/rules/organization-model.md +119 -0
  41. package/reference/rules/organization-os.md +118 -0
  42. package/reference/rules/package-taxonomy.md +36 -0
  43. package/reference/rules/platform.md +45 -0
  44. package/reference/rules/shared-types.md +52 -0
  45. package/reference/rules/task-tracking.md +50 -0
  46. package/reference/rules/ui.md +203 -0
  47. package/reference/rules/vibe.md +238 -0
  48. package/reference/scaffold/core/organization-graph.mdx +4 -5
  49. package/reference/scaffold/core/organization-model.mdx +1 -1
  50. package/reference/scaffold/reference/contracts.md +14 -2
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: Deployment workflow -- check-first, dev vs prod, version bumping, common errors
3
+ paths:
4
+ - operations/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Deployment
11
+
12
+ ## Always Check Before Deploy
13
+
14
+ ```bash
15
+ pnpm -C operations run check # Validate resource definitions
16
+ pnpm -C operations run check-types # TypeScript type-check
17
+ pnpm -C operations run deploy # Deploy to dev (only after both pass)
18
+ ```
19
+
20
+ `check` catches duplicate resource IDs, OM descriptor/code mismatches, invalid step chains, broken relationships, and schema serialization issues. Same validation runs during deploy -- if `check` passes, deploy validation will pass.
21
+
22
+ ## Dev vs Prod
23
+
24
+ | Command | Target | When |
25
+ | ------------------------------------ | ----------------- | ----------------------- |
26
+ | `pnpm -C operations run deploy` | Local dev API | Development and testing |
27
+ | `pnpm -C operations run deploy:prod` | `api.elevasis.io` | Production release |
28
+
29
+ Always test in dev first, verify with `elevasis-sdk exec`, then deploy to prod.
30
+
31
+ ## Version Bumping
32
+
33
+ Deploy accepts `--major`, `--minor`, `--patch` flags to bump the deployment version. The bumped version is written back to `src/index.ts`. Bump on contract changes (input/output schema modifications).
34
+
35
+ ## What Gets Deployed
36
+
37
+ 1. **Bundle:** esbuild compiles `src/index.ts` + all dependencies into a single self-contained CJS file. No `node_modules` needed at runtime.
38
+ 2. **Metadata:** Resource definitions, OM Resources descriptor bindings, Zod schemas (converted to JSON Schema), relationships, triggers.
39
+
40
+ ## Environment
41
+
42
+ - `ELEVASIS_PLATFORM_KEY` in `.env` is required for CLI auth
43
+ - `.env` is never included in the bundle -- it stays local
44
+ - Integration credentials live in Command Center, not `.env`
45
+
46
+ ## Common Errors
47
+
48
+ | Error | Fix |
49
+ | ---------------------------------------- | --------------------------------------------------------------------------------------------------- |
50
+ | `401: Invalid API key` | Check `ELEVASIS_PLATFORM_KEY` in `.env` |
51
+ | `Duplicate resource ID` | Fix the duplicated OM Resource descriptor ID, then derive runtime `resourceId` from that descriptor |
52
+ | `Missing OM Resource descriptor` | Add the descriptor to `core/config/organization-model.ts` under the id-keyed `resources` map |
53
+ | `Step references non-existent next step` | Fix the `next:` field in the step chain |
54
+ | `Schema serialization failed` | Simplify the Zod schema (warning, still deploys) |
55
+ | `No default export found` | `src/index.ts` must `export default` a `DeploymentSpec` |
56
+ | `Documentation file exceeds 100KB` | Split the `.md` file |
57
+
58
+ ## Deployment Replaces Previous
59
+
60
+ Only one deployment can be `active` at a time. Deploying again automatically marks the previous deployment as `stopped`. Resources become executable immediately after deploy succeeds.
@@ -0,0 +1,59 @@
1
+ ---
2
+ description: Error handling -- ExecutionError vs PlatformToolError, retry logic, no auto-retry
3
+ paths:
4
+ - operations/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Error Handling
11
+
12
+ ## Error Types
13
+
14
+ Two error classes from `@elevasis/sdk`:
15
+
16
+ **`ExecutionError`** -- base class for workflow/step failures.
17
+
18
+ ```typescript
19
+ import { ExecutionError } from '@elevasis/sdk'
20
+
21
+ throw new ExecutionError('Payment processing failed', {
22
+ context: { invoiceId: '123', amount: 500 }
23
+ })
24
+ ```
25
+
26
+ **`PlatformToolError`** -- thrown by `platform.call()` and typed adapters.
27
+
28
+ ```typescript
29
+ import { PlatformToolError } from '@elevasis/sdk'
30
+
31
+ try {
32
+ await attio.createRecord({ ... })
33
+ } catch (err) {
34
+ if (err instanceof PlatformToolError && err.retryable) {
35
+ // Transient error (rate limit, timeout, network) -- safe to retry
36
+ } else {
37
+ // Permanent error (invalid credentials, bad input) -- don't retry
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## No Auto-Retry
43
+
44
+ The platform does NOT automatically retry failed steps. Your handler is responsible for retry logic. Check `PlatformToolError.retryable` to decide whether retrying is safe.
45
+
46
+ ## Error Visibility
47
+
48
+ - Unhandled exceptions in handlers surface directly to CLI output and AI Studio.
49
+ - Use `context.logger.error()` to log errors -- `console.error()` is NOT captured by the platform.
50
+ - Write clear, descriptive error messages -- they're the primary debugging signal for end users.
51
+
52
+ ## Common PlatformToolError Codes
53
+
54
+ | Code | Retryable | Cause |
55
+ | --------------------- | --------- | --------------------------------- |
56
+ | `rate_limit_exceeded` | Yes | Integration API rate limit hit |
57
+ | `timeout_error` | Yes | Integration call timed out |
58
+ | `credentials_invalid` | No | Credential not found or expired |
59
+ | `validation_error` | No | Invalid parameters passed to tool |
@@ -0,0 +1,43 @@
1
+ ---
2
+ description: Execution model -- timeouts, memory, concurrency, org isolation, runtime constraints
3
+ paths:
4
+ - operations/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Execution Model
11
+
12
+ ## Runtime Environment
13
+
14
+ Each execution runs in an isolated Node.js worker thread spawned from the deployed bundle. Workers are ephemeral -- created on execution start, terminated on completion. No state persists between executions.
15
+
16
+ ## Constraints
17
+
18
+ | Constraint | Workflows | Agents |
19
+ | ---------- | ------------------------------- | ----------------------------------------------------- |
20
+ | Timeout | 300s (5 min) | 600s (10 min, configurable via `constraints.timeout`) |
21
+ | Memory | 256MB hard limit | 256MB hard limit |
22
+ | Disk | None (no persistent filesystem) | None |
23
+
24
+ - Platform enforces timeouts -- no handler code needed, worker terminates automatically.
25
+ - Memory overflow crashes the worker. Other tenants are unaffected.
26
+ - For long-running tasks, break work into multiple steps or use agents with extended timeout.
27
+
28
+ ## Concurrency
29
+
30
+ Concurrent executions for the same organization run in completely separate workers with zero shared state. No locking, no race conditions between executions.
31
+
32
+ ## Organization Isolation
33
+
34
+ - `organizationId` is injected server-side from the JWT context -- workers never see it.
35
+ - Storage paths are automatically org-prefixed.
36
+ - Resource IDs are scoped per organization (not global).
37
+ - External developers cannot access other organizations' data by construction.
38
+
39
+ No developer action needed for multi-tenancy -- the platform handles it.
40
+
41
+ ## Cancellation
42
+
43
+ The platform can cancel in-flight executions. The worker terminates immediately with no cleanup handler.
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Frontend conventions -- React, routing, state, styling, testing, pages
3
+ paths:
4
+ - ui/src/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Frontend
11
+
12
+ ## Safety Invariants
13
+
14
+ - `ElevasisUIProvider` in `ui/src/main.tsx` auto-composes shared UI, auth, and API surface -- route files do not wire providers manually
15
+ - `useApiClient()` from `@/lib/hooks/useApiClient` for authenticated API calls -- never raw `fetch` with auth headers
16
+ - `routeTree.gen.ts` is auto-generated on `pnpm dev` -- never edit manually
17
+ - Auth protection: wrap page content with `ProtectedRoute` from `@elevasis/ui/auth`. Admin pages nest `AdminGuard` inside `ProtectedRoute`
18
+ - Never fork `@elevasis/ui` components -- if a published component needs a tweak, that missing capability is a bug in `@elevasis/ui`
19
+
20
+ ## Silent-Break Gotchas
21
+
22
+ - Route files vs layout files: `operations.tsx` is a layout (renders `<Outlet />`), `operations/my-page.index.tsx` is a page. Confusing the two breaks routing silently
23
+ - `core/` cannot import React or `@elevasis/sdk/worker` -- it is runtime-agnostic shared types and organization configuration only
24
+ - `@/*` resolves to `ui/src/*`, `@core/*` resolves to `core/*` -- never import from `operations/` (separate runtime)
25
+
26
+ ## Stack Constraints
27
+
28
+ - Mantine 8.2.7 for all UI components -- no Radix UI, no Tailwind CSS, no shadcn
29
+ - `@tabler/icons-react` for icons -- never Lucide
30
+ - Server state: TanStack Query. Client state: Zustand + Immer. Never mix the two
31
+ - Glass background is the primary surface treatment: `var(--glass-background)` with `backdrop-filter: var(--glass-blur)`
32
+ - Import shared components from `@elevasis/ui/components`, `@elevasis/ui/layout`, `@elevasis/ui/charts`
33
+ - Import charts from `@elevasis/ui/charts`, not directly from `@mantine/charts`
34
+
35
+ ## Integration UI Surfaces
36
+
37
+ When building pages that display external data, use published `@elevasis/ui` components before building custom UI. Use Mantine components and CSS variables exclusively -- no inline hex colors, no custom design tokens. Match existing page density and spacing.
38
+
39
+ ## Detailed Reference
40
+
41
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/recipes.md` -- add a page, add a nav item, theme tokens, feature-scoped components, route patterns (static, nested, dynamic)
42
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/feature-flags-and-gating.md` -- `systemKey` / `SystemGuard` / `AdminGuard` model
43
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/customization.md` -- sidebar composition via manifest overrides
44
+ - `node_modules/@elevasis/sdk/reference/scaffold/reference/contracts.md` -- TypeScript shapes (`SystemModule`, `NavItem`, `OrganizationModel`)
45
+ - `ui/src/config/theme.ts` -- theme configuration and CSS variable definitions
46
+ - `ui/src/config/nav-items.ts` -- sidebar navigation entries
@@ -0,0 +1,34 @@
1
+ ---
2
+ description: Observability -- context.logger API, execution inspection, step-level context
3
+ paths:
4
+ - operations/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Observability
11
+
12
+ ## Safety Invariants
13
+
14
+ - Use `context.logger` for all logging in step handlers -- `console.*` is NOT captured by the platform
15
+ - Log levels: `debug` (verbose), `info` (normal progress), `warn` (non-fatal, processing continues), `error` (fatal, processing stops)
16
+ - Step lifecycle events (started, completed, failed, route taken) are auto-logged by the SDK worker -- no handler code needed
17
+
18
+ ## Key Rules
19
+
20
+ - Every handler should log at: entry (step name + key params), decisions (skips, branches), progress (per-item in loops), summary (counts at end)
21
+ - Error messages in handlers surface as the execution's error message -- write for humans, not machines
22
+ - String values truncated at 200 characters in logs
23
+ - 30-day log retention (includes logs from deleted resources)
24
+
25
+ ## Inspecting Executions
26
+
27
+ ```bash
28
+ pnpm elevasis-sdk execution <resourceId> <executionId>
29
+ pnpm elevasis-sdk executions <resourceId>
30
+ ```
31
+
32
+ ## Detailed Reference
33
+
34
+ - `node_modules/@elevasis/sdk/reference/scaffold/operations/workflow-recipes.md` -- full logging patterns and handler examples
@@ -0,0 +1,85 @@
1
+ ---
2
+ description: Platform workflows, agents, resource definitions, and deployment for the operations/ surface
3
+ paths:
4
+ - operations/**
5
+ ---
6
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
7
+ <!-- Regenerate: pnpm scaffold:sync -->
8
+
9
+
10
+ # Operations
11
+
12
+ **Status:** Stable
13
+
14
+ ## Overview
15
+
16
+ The `operations/` directory contains platform resources and deployment metadata that deploy to the Elevasis platform. It is a standalone TypeScript project with its own `package.json`, `tsconfig.json`, and dependencies.
17
+
18
+ **Discovering deployed resources:** Read `operations/src/index.ts` for deployment assembly and `core/config/organization-model.ts` for the OM Resources descriptor catalog. Run `pnpm elevasis-sdk project:list --pretty` against the live DB for the deployed surface.
19
+
20
+ ## Echo Workflow (Starter Example)
21
+
22
+ **Location:** `operations/src/example/echo.ts`
23
+
24
+ The echo workflow accepts a message string and returns it unchanged. Its purpose is the wiring, not the logic: input and output schemas are defined in `core/types/index.ts` and imported by both the workflow and the frontend.
25
+
26
+ ```
27
+ core/types/index.ts -- defines echoInputSchema, echoOutputSchema
28
+ operations/src/example/echo.ts -- imports schemas for workflow contract
29
+ ui/src/routes/ -- imports schemas for form validation and display
30
+ ```
31
+
32
+ The workflow is registered in `operations/src/index.ts` as part of the `example` group and deployed with `pnpm -C operations deploy`.
33
+
34
+ ## Adding a New Workflow
35
+
36
+ 1. **Define the descriptor in `core/config/organization-model.ts`** -- Add the OM Resource descriptor under the id-keyed `resources` map so identity, System membership, owner role, and governance status are authored once.
37
+
38
+ 2. **Model the semantic surface** -- Add durable business nouns, verbs, catalogs, links, events, and surfaces to the owning System's `ontology`; bind executable Resources through `resource.ontology.actions` and optional `resource.ontology.primaryAction`; add system-local defaults/settings to `System.config`; add explanatory or governing material to `knowledge`; and keep transient DTOs and handler internals out of the OM. Top-level `entities`, top-level `actions`, and `System.content` are compatibility mirrors only when current published consumers still need them.
39
+
40
+ 3. **Define the contract in `core/types/`** -- Add Zod schemas and inferred types to `core/types/index.ts` (or a new file under `core/types/`). Use `core/types/entities.ts` when workflows operate on project-specific entity contracts.
41
+
42
+ 4. **Implement the workflow in `operations/src/`** -- Create a new directory under `operations/src/` for the feature. Import the descriptor, derive runtime `resourceId`, `type`, `name`, and `description` from it, export the workflow from its `index.ts`, and register it in `operations/src/index.ts`.
43
+
44
+ Workflow-side signing and platform adapter error bucketing should use the worker SDK surface: import `generateHmacToken` and `classifyPlatformToolError` from `@elevasis/sdk/worker`. Keep provider-specific timeout messages, error codes, and message snippets in tenant code, then pass them into the generic classifier.
45
+
46
+ 5. **Add the UI in `ui/src/routes/`** -- Create a new route file. Use TanStack Query to call the workflow execution endpoint. Import schemas from `@core/types` for validation and type inference. Read OM resources, ontology, knowledge, and graph data where possible instead of creating page-local semantic registries.
47
+
48
+ 6. **Update rules when the pattern persists** -- If the workflow introduces a reusable adapter pattern, checkpoint/schedule convention, domain vocabulary, or workflow family behavior that future agents must follow, update this rule or add a scoped rule under `.claude/rules/` in the same change.
49
+
50
+ 7. **Deploy and verify:**
51
+
52
+ ```bash
53
+ pnpm -C operations check # validate resource definitions
54
+ pnpm -C operations deploy # deploy to dev
55
+ ```
56
+
57
+ ## Resource Registry
58
+
59
+ `operations/src/index.ts` default-exports a `DeploymentSpec` with `version`, `organizationModel`, `workflows`, `agents`, and optional deployment mechanics such as `triggers`, `integrations`, `relationships`, `humanCheckpoints`, and `externalResources`. Durable operational wiring belongs in `organizationModel.topology.relationships`; deployment mechanics, credentials, provider webhook details, and per-run state stay outside the OM. Each feature group exports `workflows` and `agents` arrays from its own `index.ts`, spread into the top-level spec. `DeploymentSpec` assembles deployable behavior; it should not be treated as a second resource identity catalog.
60
+
61
+ When you need breadth first, read:
62
+
63
+ - `operations/src/README.md` for the source boundary and drill-down guidance
64
+ - `core/config/organization-model.ts` for descriptor identity and governance metadata
65
+ - `operations/src/index.ts` for deployment assembly
66
+ - `pnpm elevasis-sdk project:list --pretty` for the live deployed surface
67
+
68
+ ## Commands
69
+
70
+ | Command | Purpose |
71
+ | -------------------------------- | ----------------------------- |
72
+ | `pnpm -C operations check` | Validate resource definitions |
73
+ | `pnpm -C operations check-types` | TypeScript type-check |
74
+ | `pnpm -C operations deploy` | Deploy to dev |
75
+ | `pnpm -C operations deploy:prod` | Deploy to production |
76
+
77
+ Always run `check` before `deploy`.
78
+
79
+ ## Rule Updates
80
+
81
+ When developing resources, workflows, agents, integrations, checkpoints, schedules, or recurring operational conventions, keep `.claude/rules/` current.
82
+
83
+ - Update `operations.md` for package-wide operations invariants.
84
+ - Add a scoped rule for domain-specific workflow families whose conventions should autoload for future edits.
85
+ - Do not bury durable operational rules only in task notes or chat context.
@@ -0,0 +1,119 @@
1
+ ---
2
+ description: Edits to the canonical organization model go through /om
3
+ paths:
4
+ - core/config/organization-model.ts
5
+ - core/config/extensions/**/*.ts
6
+ ---
7
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
8
+ <!-- Regenerate: pnpm scaffold:sync -->
9
+
10
+
11
+ # Organization Model Edit Guide
12
+
13
+ `core/config/organization-model.ts` is the single source of truth for this
14
+ project's organizational identity -- it encodes customers, offerings, roles, goals,
15
+ Systems, ontology, Policies, Knowledge, config, and Resources
16
+ descriptors that agents, workflows, and the UI shell all consume at runtime.
17
+ New semantic authoring should start in system-colocated `ontology` scopes. Top-level
18
+ `entities` and top-level `actions` remain compatibility mirrors while published
19
+ consumers finish moving to compiled ontology indexes. `System.content` is retired.
20
+
21
+ ## Preferred Entry Point: `/om`
22
+
23
+ Direct edits to `organization-model.ts` are discouraged. Instead, use `/om` (or
24
+ `/om <domain>`) to run the read → propose → confirm → write → validate ceremony:
25
+
26
+ 1. The skill reads the current model so proposals start from ground truth.
27
+ 2. It drafts only the specific block being changed, leaving everything else intact.
28
+ 3. The user confirms before any file is written.
29
+ 4. After writing, `pnpm -C operations check-types` runs and `OrganizationModelSchema.parse()`
30
+ is verified. On failure the file is rolled back automatically.
31
+
32
+ Use `/om <domain>` for targeted edits: `identity`, `customers`, `offerings`,
33
+ `roles`, `goals`, `techStack`, `systems`, `actions`, or `labels`. Resource identity and
34
+ governance metadata belong in the id-keyed `resources` map; operations code derives runtime
35
+ `resourceId` / `type` from those descriptors.
36
+
37
+ Author system-local semantics by boundary:
38
+
39
+ - `System.ontology` owns durable object types, action types, catalog types, link types, event types, and surfaces.
40
+ - `System.config` owns system-local JSON settings and defaults.
41
+ - `resources` own executable workflow/agent descriptors, `systemPath`, owners, governance status, code references, and runtime implementation links.
42
+ - `resource.ontology.actions` describes the ontology actions a Resource performs; `resource.ontology.primaryAction` names the default/selectable action when a Resource has one.
43
+ - `resource.ontology` also describes reads, writes, catalog use, and emitted events.
44
+ - `topology.relationships` owns durable operational wiring between Systems, Resources, ontology nodes, policies, roles, triggers, checkpoints, and external resources.
45
+ - `knowledge` owns long-form playbooks, strategies, references, and governance context.
46
+ - Top-level `entities` and top-level `actions` are compatibility mirrors only. Keep them aligned when current published consumers still need them, but do not treat them as the primary authoring surface.
47
+
48
+ Do not author Resource `actionKey` in the target contract. Runtime/UI routing that needs a single selectable action should read `resource.ontology.primaryAction`.
49
+
50
+ ## Runtime Validation
51
+
52
+ The model is validated at startup via `resolveOrganizationModel()` followed by
53
+ `OrganizationModelSchema.parse()`. Cross-reference checks (segment ID refs in offerings,
54
+ role reporting lines, period ordering in goals) are runtime-only and not caught by tsc
55
+ alone -- always let the ceremony run both checks before treating a change as complete.
56
+
57
+ ## Extension Files
58
+
59
+ New Zod extension files under `core/config/extensions/` are Level B codify
60
+ operations. Route these through `/om <domain>` as well -- the skill gates Level B
61
+ to explicit user confirmation before scaffolding a new `.ts` file.
62
+
63
+ This is a soft guide, not a hard block. The ceremony exists to prevent silent schema
64
+ drift and to keep the model's editorial history visible.
65
+
66
+ ## Resource System Attachment
67
+
68
+ Every resource in the id-keyed `organizationModel.resources` map declares which System it belongs to
69
+ via `systemPath` -- a dot-separated path that resolves against the OM system tree
70
+ (e.g. `"sys.operations"`, `"sales.crm"`):
71
+
72
+ ```ts
73
+ {
74
+ id: 'apify-website-crawl',
75
+ systemPath: 'sys.operations', // canonical system attachment
76
+ kind: 'workflow',
77
+ ...
78
+ }
79
+ ```
80
+
81
+ `systemPath` is validated at parse time by `SystemPathSchema` and cross-checked by
82
+ `OrganizationModelSchema.superRefine` -- an unresolvable path causes a Zod error at
83
+ schema validation. Use `getResourcesForSystem(model, path)` (from `@elevasis/core`) to
84
+ query resources for a system at runtime. Pass `{ includeDescendants: true }` to include
85
+ all descendant systems (segment-aware -- `'sales'` does NOT match `'salesforce.foo'`).
86
+
87
+ Some external templates may carry a `systemId` compatibility mirror while published
88
+ `@elevasis/core` releases catch up to the current source contract. Treat that field as
89
+ legacy adapter data only; author new resource relationships against `systemPath`.
90
+
91
+ Do not fetch resources for every system-oriented read by default. For agent workflows, start
92
+ with the user's requested OM/om context and query resources only when the task involves
93
+ runtime ownership, executable implementation, observability, deployment, or resource governance.
94
+ Use the descendant rollup only when parent-system scope is intended.
95
+
96
+ `resource.category` and `resource.links[].nodeId` are **runtime filter overlays** -- they
97
+ drive UI faceted filtering in the Command Center but do NOT define system membership.
98
+ System membership is `systemPath` only.
99
+
100
+ ```ts
101
+ // category and links power UI filter chips; systemPath is the
102
+ // canonical OM attachment used for graph edges and getResourcesForSystem queries.
103
+ ```
104
+
105
+ `resource.codeRefs[]` are repo-relative implementation breadcrumbs for agents and
106
+ operators. Use them to point from a governed OM Resource descriptor to the operations
107
+ entrypoint, handler, schema, test, docs, or config files that implement it. They do
108
+ not define resource identity, System membership, runtime execution topology, or graph
109
+ relationships.
110
+
111
+ `topology.relationships` defines durable operational wiring in the OM. Keep credential
112
+ values, provider webhook mechanics, deployment environment settings, execution logs,
113
+ and per-run scheduler state outside the OM.
114
+
115
+ `System.ontology` owns durable semantic contracts: object types, action types, catalog
116
+ types, link types, event types, and surfaces. `System.config` owns local settings and
117
+ defaults. If current UI or runtime code still needs legacy mirrors, keep `entities`
118
+ or `actions` aligned with the ontology record instead of inventing a separate
119
+ source of truth.
@@ -0,0 +1,118 @@
1
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
2
+ <!-- Regenerate: pnpm scaffold:sync -->
3
+
4
+ # Organization OS
5
+
6
+ Organization OS is the semantic contract layer defining how organizations, Systems, Actions, ontology, resources, policies, roles, goals, knowledge, and runtime surfaces relate. This project consumes Organization OS through published `@elevasis/core` / `@elevasis/sdk` configuration and does not maintain the monorepo schema.
7
+
8
+ This rule is an orientation and reference map. Concrete edit rules for `core/config/organization-model.ts`, `systemPath`, resources, ontology, knowledge, and validation live in `.claude/rules/organization-model.md`.
9
+
10
+ ## Key Files in This Project
11
+
12
+ - `core/config/organization-model.ts` -- project-specific org model definition, Systems, system-local ontology/config, Knowledge, and Resources descriptor catalog (`organizationModel.resources`)
13
+ - `core/config/extensions/` -- project-owned entity extension schemas
14
+ - `core/types/entities.ts` -- typed entity contracts (Project, Deal, etc.). Extends `BaseProject`, `BaseDeal` from `@elevasis/core/entities` with project-specific metadata. Read this when authoring workflows that operate on these entities.
15
+ - `ui/src/routes/__root.tsx` -- wires `ElevasisSystemsProvider` with `canonicalOrganizationModel`
16
+ - `ui/src/app-config.ts` -- references the org model
17
+ - `operations/src/index.ts` -- `DeploymentSpec` registry for workflows and agents
18
+
19
+ ## Domain Overview
20
+
21
+ As of the 2026-05 resource-governance expansion, `OrganizationModel` includes platform configuration, organizational reality, governance, and knowledge domains:
22
+
23
+ **Platform configuration:** `systems`, `branding`, `navigation`
24
+
25
+ **Organizational reality:** `identity`, `customers`, `offerings`, `roles`, `goals`
26
+
27
+ **Governance:** `resources`, `policies`, and resource-to-System relationships
28
+
29
+ **Ontology, config, and knowledge:** `System.ontology` owns durable semantic contracts such as object types, action types, catalog types, link types, event types, and surfaces. `System.config` owns system-local JSON settings and defaults. `knowledge` is a flat id-keyed map of playbooks, strategies, and references that explain or govern systems and ontology records.
30
+
31
+ Resource identity is authored once in the id-keyed `resources` map. Each resource attaches to a System via `systemPath` and can declare ontology relationships through `resource.ontology`. Operations imports those descriptors and derives runtime `resourceId` / `type` while assembling the `DeploymentSpec`.
32
+
33
+ ### Domain Rename Note
34
+
35
+ Some legacy UI feature constants and consumer-facing route keys are intentionally unchanged for compatibility:
36
+
37
+ | Old field | New field | Legacy key (unchanged) | UI constant (unchanged) |
38
+ | ---------- | ------------- | ---------------------- | ----------------------- |
39
+ | `crm` | `sales` | `'crm'` | `CRM_FEATURE_ID` |
40
+ | `leadGen` | `prospecting` | `'lead-gen'` | `LEAD_GEN_FEATURE_ID` |
41
+ | `delivery` | `projects` | `'projects'` | `PROJECTS_FEATURE_ID` |
42
+
43
+ ## Reference Documentation
44
+
45
+ Full Organization OS documentation ships with the SDK and is available locally after `pnpm install`:
46
+
47
+ ### Scaffold Reference (via SDK)
48
+
49
+ All paths under `node_modules/@elevasis/sdk/reference/scaffold/`:
50
+
51
+ - `node_modules/@elevasis/sdk/reference/scaffold/index.mdx` -- scaffold root and navigation
52
+ - `node_modules/@elevasis/sdk/reference/scaffold/core/organization-model.mdx` -- semantic contract, domains, adapter authoring, validation gate, `/om` entry point
53
+ - `node_modules/@elevasis/sdk/reference/scaffold/core/organization-graph.mdx` -- graph derivation, node/edge taxonomy, lenses
54
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/feature-shell.mdx` -- SystemModule manifest, provider runtime
55
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/composition-extensibility.mdx` -- layout primitives, router abstraction
56
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/recipes.md` -- copy-paste UI recipes for pages, nav items, components
57
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/feature-flags-and-gating.md` -- three-concept gating model
58
+ - `node_modules/@elevasis/sdk/reference/scaffold/ui/customization.md` -- sidebar composition via manifest overrides
59
+ - `node_modules/@elevasis/sdk/reference/scaffold/recipes/add-a-feature.md` -- end-to-end OM-backed System recipe through manifest, routes, and gating
60
+ - `node_modules/@elevasis/sdk/reference/scaffold/recipes/add-a-resource.md` -- author and deploy a workflow or agent
61
+ - `node_modules/@elevasis/sdk/reference/scaffold/recipes/gate-by-feature-or-admin.md` -- decision table for access control patterns
62
+ - `node_modules/@elevasis/sdk/reference/scaffold/recipes/extend-lead-gen.md` -- build or extend lead-gen pages, sidebars, hooks, list/member state, artifacts, workflow adapters, and prospecting semantics
63
+ - `node_modules/@elevasis/sdk/reference/scaffold/operations/workflow-recipes.md` -- workflow anatomy, adapter patterns, trigger patterns
64
+ - `node_modules/@elevasis/sdk/reference/scaffold/operations/propagation-pipeline.md` -- how sync and verification work across projects
65
+ - `node_modules/@elevasis/sdk/reference/scaffold/operations/scaffold-maintenance.md` -- content placement and auto-generation pipeline
66
+ - `node_modules/@elevasis/sdk/reference/scaffold/reference/glossary.md` -- Organization OS term definitions
67
+ - `node_modules/@elevasis/sdk/reference/scaffold/reference/contracts.md` -- auto-generated TypeScript contract shapes
68
+ - `node_modules/@elevasis/sdk/reference/scaffold/reference/feature-registry.md` -- auto-generated feature manifest catalog
69
+
70
+ ### Local Project Docs
71
+
72
+ - `.claude/rules/agent-start-here.md` -- canonical first-read for agents (includes task-class routing)
73
+
74
+ ## Published Subpaths and Constants
75
+
76
+ - `@elevasis/core/organization-model` -- the curated organization-model barrel. Exports `defineOrganizationModel`, `resolveOrganizationModel`, `OrganizationModelSchema`, `DEFAULT_ORGANIZATION_MODEL`, organization-model types, and typed System/Action plus legacy UI feature/surface constants.
77
+ - Legacy UI feature IDs: `CRM_FEATURE_ID`, `LEAD_GEN_FEATURE_ID`, `PROJECTS_FEATURE_ID`, `OPERATIONS_FEATURE_ID`, `MONITORING_FEATURE_ID`, `SETTINGS_FEATURE_ID`, `SEO_FEATURE_ID`
78
+ - Headline surface IDs: `CRM_PIPELINE_SURFACE_ID`, `LEAD_GEN_LISTS_SURFACE_ID`, `PROJECTS_INDEX_SURFACE_ID`, `OPERATIONS_ORGANIZATION_GRAPH_SURFACE_ID`
79
+ - Reality domain types: `OrganizationModelIdentity`, `OrganizationModelCustomers`, `OrganizationModelCustomerSegment`, `OrganizationModelOfferings`, `OrganizationModelProduct`, `OrganizationModelRoles`, `OrganizationModelRole`, `OrganizationModelGoals`, `OrganizationModelObjective`, `OrganizationModelKeyResult`
80
+ - TechStack: `TechStackEntrySchema`, `OrganizationModelTechStackEntry`
81
+ - Use constants instead of magic strings when overriding the org model.
82
+ - `@elevasis/core/entities` -- entity contracts barrel. Exports `BaseProject`, `BaseProjectSchema`, `BaseProjectInput` and the equivalents for `Milestone`, `Task`, `Deal`, `Company`, `Contact`. Each base interface is generic over a `\<TMeta>` extension slot. Extend these in `core/types/entities.ts` to add project-specific fields.
83
+
84
+ ## When Working with Organization OS
85
+
86
+ - **Changing org model (structural reality):** Use `/om` as the entry point. Direct edits to `core/config/organization-model.ts` are discouraged -- `/om` runs the read -> propose -> confirm -> write -> validate ceremony. Run `/om` for the full layered flow or `/om \<domain>` for a targeted domain. See `.claude/rules/organization-model.md` for the concrete authoring boundary.
87
+ - **Building or extending CRM:** Start with `node_modules/@elevasis/sdk/reference/scaffold/recipes/extend-crm.md`. CRM spans Organization OS sales semantics, shared UI primitives, deal hooks, workflow adapters, and generated contracts.
88
+ - **Building or extending lead gen:** Start with `node_modules/@elevasis/sdk/reference/scaffold/recipes/extend-lead-gen.md`. Lead gen spans Organization OS prospecting semantics, shared UI primitives, list/member hooks, artifact hooks, workflow adapters, and generated contracts.
89
+ - **Customizing CRM deal actions:** Follow `node_modules/@elevasis/sdk/reference/scaffold/recipes/customize-crm-actions.md`. Do not add `sales.actions` to the org model; the v1 server-side override surface is intentionally deferred.
90
+ - **Adding or toggling a System:** Follow the current scaffold recipes when they mention UI features, but translate Organization OS changes to Systems, navigation surfaces, and Actions. Use `/om systems` for availability/routing changes.
91
+ - **Adding a resource:** Follow `node_modules/@elevasis/sdk/reference/scaffold/recipes/add-a-resource.md`.
92
+ - **Extending entities:** Start with `core/types/entities.ts` for the demo extension pattern. Base shapes come from `@elevasis/core/entities`.
93
+ - **Authoring a workflow that takes a Project/Deal/etc.:** Reference entity types from `core/types/entities.ts` in the input schema -- do not redeclare them.
94
+ - **Adding system-local ontology/config:** Put durable business schema in `System.ontology`, local defaults/settings in `System.config`, executable implementations in `resources`, and explanatory or governing material in `knowledge`.
95
+ - **Understanding contracts:** Check `node_modules/@elevasis/sdk/reference/scaffold/reference/contracts.md` for current type shapes.
96
+ - **Debugging sync issues:** Check `node_modules/@elevasis/sdk/reference/scaffold/operations/propagation-pipeline.md` for the verification pipeline.
97
+
98
+ ## `/om` -- Org Model QA Entry Point
99
+
100
+ `/om` is the recurring, safe-to-re-run org model editor for this project. It is a skill (not a command) at `.claude/skills/om/SKILL.md`.
101
+
102
+ **Usage:**
103
+
104
+ - `/om` -- layered flow: identity → customers → offerings → roles → goals → techStack
105
+ - `/om identity` -- legal identity, mission/vision, industry, geography, timezone
106
+ - `/om customers` -- customer segments with jobs-to-be-done, pains, gains, firmographics
107
+ - `/om offerings` -- products and services with pricing model and segment references
108
+ - `/om roles` -- role chart with responsibilities, reporting lines, and holders
109
+ - `/om goals` -- organizational goals with period and measurable outcomes
110
+ - `/om techStack` -- external-SaaS and integration context; resource identity still belongs in OM Resources descriptors
111
+ - `/om systems` -- enable, disable, or add Systems; route invokable behavior through Actions
112
+ - `/om labels` -- edit display labels on enum entries (statuses, stages)
113
+
114
+ Every write is gated: `resolveOrganizationModel()` must succeed (Zod cross-refs pass) and `pnpm -C operations check-types` must pass. On failure the change is rolled back.
115
+
116
+ **Distinction from `/setup`:** `/setup` is first-time bootstrap only. After bootstrap it delegates here. `/om` is idempotent and safe to re-run at any time.
117
+
118
+ The ambient vibe layer (`.claude/rules/vibe.md`) automatically detects Codify intent in plain language and delegates to `/om`. Power users can invoke `/om` directly to bypass the ambient layer entirely.
@@ -0,0 +1,36 @@
1
+ <!-- @generated by packages/sdk/scripts/copy-reference-docs.mjs -- DO NOT EDIT -->
2
+ <!-- Regenerate: pnpm scaffold:sync -->
3
+
4
+ # Package Taxonomy (Consumer View)
5
+
6
+ External projects consume the **published `@elevasis/*` surface only**. The Elevasis monorepo also has workspace-internal `@repo/elevasis-*` packages — those are NOT installable here and should never appear in your imports or `package.json`.
7
+
8
+ ## What You Can Import
9
+
10
+ | Package | Subpaths | Where it lives in `node_modules` |
11
+ | ---------------- | -------------------------------------------- | -------------------------------- |
12
+ | `@elevasis/sdk` | default, `/worker`, `/node`, `/test-utils` | `node_modules/@elevasis/sdk/` |
13
+ | `@elevasis/ui` | default, `/auth`, `/initialization`, etc. | `node_modules/@elevasis/ui/` |
14
+ | `@elevasis/core` | `/organization-model`, `/entities`, `/utils` | `node_modules/@elevasis/core/` |
15
+
16
+ ## What You Will See in Monorepo Docs (and should NOT import)
17
+
18
+ Monorepo source and docs reference `@repo/elevasis-core` and `@repo/elevasis-operations`. These are workspace-internal packages used by Elevasis as a tenant of its own platform. They are `private: true` and never published. If you see them mentioned:
19
+
20
+ - Do NOT add them to this project's `package.json`
21
+ - Do NOT try to import from them — they are not in your `node_modules`
22
+ - They are not a substitute for `@elevasis/core` even though the name overlaps
23
+
24
+ ## Confused About Where Something Lives?
25
+
26
+ Check the import path:
27
+
28
+ - `@elevasis/...` → published, consumable here
29
+ - `@repo/...` → monorepo-internal, not consumable
30
+
31
+ This project's own org-model and workflows live in `core/config/organization-model.ts` and `operations/src/**` — those are project-owned, not part of either family above.
32
+
33
+ ## References
34
+
35
+ - `node_modules/@elevasis/sdk/reference/scaffold/index.mdx` — full SDK scaffold reference
36
+ - Monorepo source rule: `.claude/rules/package-taxonomy.md` in the elevasis-monorepo (when working across both)