@elementumai/edk 0.8.0-preview.11 → 0.8.1

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 (165) hide show
  1. package/README.md +378 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +65 -2
  6. package/dist-sdk/src/catalog/from-authoring.js +6 -1
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +83 -6
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +14 -0
  14. package/dist-sdk/src/catalog/types.d.ts +60 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +20 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +18 -0
  22. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  23. package/dist-sdk/src/engine/build/source-context.js +23 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  26. package/dist-sdk/src/engine/pull/org.js +34 -4
  27. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  28. package/dist-sdk/src/engine/tf/index.js +1 -1
  29. package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
  30. package/dist-sdk/src/engine/tf/labels.js +71 -0
  31. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  32. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  33. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  34. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
  37. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  38. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  39. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
  40. package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
  41. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  42. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  43. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
  46. package/dist-sdk/src/entities/agent/from-tf.js +135 -15
  47. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  48. package/dist-sdk/src/entities/agent/module.js +8 -2
  49. package/dist-sdk/src/entities/agent/to-tf.js +62 -10
  50. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  51. package/dist-sdk/src/entities/agent/tools.js +46 -7
  52. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
  56. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  57. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  58. package/dist-sdk/src/entities/app/build.d.ts +63 -13
  59. package/dist-sdk/src/entities/app/build.js +48 -1
  60. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  61. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/from-tf.js +32 -15
  63. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/app/index.js +2 -1
  65. package/dist-sdk/src/entities/app/module.js +9 -2
  66. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  67. package/dist-sdk/src/entities/app/to-tf.js +33 -4
  68. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  69. package/dist-sdk/src/entities/automation/build.js +48 -36
  70. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  71. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  72. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
  73. package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
  74. package/dist-sdk/src/entities/automation/filter.js +12 -2
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  76. package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
  77. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  78. package/dist-sdk/src/entities/automation/index.js +4 -0
  79. package/dist-sdk/src/entities/automation/module.js +29 -32
  80. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  81. package/dist-sdk/src/entities/automation/operators.js +27 -1
  82. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  84. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  85. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  86. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  87. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  88. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  89. package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
  90. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  91. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  92. package/dist-sdk/src/entities/automation/types.js +76 -46
  93. package/dist-sdk/src/entities/element/build.d.ts +23 -10
  94. package/dist-sdk/src/entities/element/build.js +1 -0
  95. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/element/from-tf.js +18 -3
  97. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  98. package/dist-sdk/src/entities/element/index.js +2 -1
  99. package/dist-sdk/src/entities/element/module.js +3 -1
  100. package/dist-sdk/src/entities/element/to-tf.js +21 -3
  101. package/dist-sdk/src/entities/field/build.d.ts +56 -13
  102. package/dist-sdk/src/entities/field/build.js +10 -0
  103. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  104. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  105. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  106. package/dist-sdk/src/entities/field/module.js +3 -2
  107. package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
  108. package/dist-sdk/src/entities/field/to-tf.js +62 -17
  109. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  110. package/dist-sdk/src/entities/field/types.js +34 -12
  111. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  112. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  113. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  114. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  115. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  116. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  117. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  118. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  119. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  120. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  121. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  122. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  123. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  124. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  125. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  126. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  127. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  128. package/dist-sdk/src/entities/org/connector.js +12 -14
  129. package/dist-sdk/src/entities/org/group.js +10 -1
  130. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  131. package/dist-sdk/src/entities/org/index.js +1 -0
  132. package/dist-sdk/src/entities/org/user.js +10 -1
  133. package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
  134. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  135. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  136. package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  138. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  140. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
  141. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  142. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  143. package/dist-sdk/src/entities/skill/module.js +6 -1
  144. package/dist-sdk/src/entities/skill/to-tf.js +3 -2
  145. package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
  146. package/dist-sdk/src/entities/skill/tools.js +17 -0
  147. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
  148. package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
  149. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  152. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  153. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  154. package/dist-sdk/src/entities/view/to-tf.js +33 -18
  155. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  156. package/dist-sdk/src/entities/view/types.js +1 -1
  157. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  158. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  159. package/dist-sdk/src/graph/index.d.ts +8 -0
  160. package/dist-sdk/src/graph/index.js +13 -9
  161. package/dist-sdk/src/graph/modules.js +6 -1
  162. package/dist-sdk/src/graph/types.d.ts +77 -3
  163. package/package.json +42 -14
  164. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  165. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
package/README.md CHANGED
@@ -1,409 +1,463 @@
1
1
  # @elementumai/edk
2
2
 
3
- Strongly typed TypeScript SDK and CLI for building Elementum apps, automations, agents, skills, flows, and search tables as code.
3
+ Statically typed TypeScript SDK for authoring Elementum apps, elements,
4
+ automations, agents, skills, flows, search tables, and related configuration as
5
+ code. `@elementumai/edk` is SDK-only; the standalone `elementum` CLI is
6
+ distributed separately as part of the signed toolchain.
4
7
 
5
- ## Install
8
+ This repository is the canonical source for the public SDK, the standalone
9
+ `elementum` CLI, the OpenTofu provider under `provider/`, and the temporary
10
+ private bridge under `cmd/elementum/`. The installed toolchain manages
11
+ the bridge and OpenTofu; neither is a separate public executable or checkout.
6
12
 
7
- ```bash
8
- npm install @elementumai/edk
9
- ```
13
+ ## Installation
10
14
 
11
- The SDK is a public npm package. Use Node 24.
15
+ Install the signed macOS toolchain:
12
16
 
13
- ## Configure Auth
17
+ ```sh
18
+ curl -fsSL https://elementum-toolchain-distribution.vercel.app | sh
19
+ elementum init
20
+ ```
14
21
 
15
- Auth lives entirely in `ei` — edk holds no credentials and never talks to the
16
- platform itself. Sign in once with `ei`, and edk reads the active tenant from it:
22
+ The installer places `elementum` in `~/.elementum/bin` and adds that directory
23
+ to PATH via your shell profile (`~/.zprofile` for zsh). The current shell won't
24
+ see it until the profile reloads, so `elementum: command not found` right after
25
+ install just means you need a fresh shell — open a new terminal or run
26
+ `source ~/.zprofile`.
17
27
 
18
- ```bash
19
- ei auth login
20
- ```
28
+ Install the SDK in the package workspace that contains your Elementum org
29
+ folders:
21
30
 
22
- Non-interactive / CI — pick one **CLI mode** per command:
31
+ ```sh
32
+ npm install @elementumai/edk
33
+ ```
23
34
 
24
- ```bash
25
- # Ambient: current profile (auth config) + .env + shell
26
- edk plan
35
+ Use Node 24 or newer. The npm package is the authoring SDK; the only public
36
+ executable is `elementum`.
27
37
 
28
- # Explicit flags
29
- edk plan --organization <organization> --environment <environment> --instance <instance> \
30
- --client-id "$ELEMENTUM_CLIENT_ID" --client-secret "$ELEMENTUM_CLIENT_SECRET"
38
+ ### Platform support
31
39
 
32
- # Named profile
33
- edk plan --profile <profile>
40
+ The signed `elementum` toolchain currently targets **macOS only** — Apple
41
+ Silicon (`darwin-arm64`) and Intel (`darwin-x64`). Linux builds are on the
42
+ roadmap but not yet available. The authoring SDK (`@elementumai/edk`) is pure
43
+ TypeScript and runs anywhere Node 24+ runs, so Linux CI can install the SDK and
44
+ typecheck or build authored source; the platform commands (`auth`, `pull`,
45
+ `plan`, `apply`) require running `elementum` on macOS for now.
34
46
 
35
- # Allowlisted env file for this command
36
- edk plan --profile-env-file=.env.staging
37
- ```
47
+ ## Authentication and profiles
38
48
 
39
- Auth is owned by `ei` (not edk env vars):
49
+ The SDK is credential-free and never calls the platform. Authentication and all
50
+ platform I/O are owned by the managed private bridge:
40
51
 
41
- ```bash
42
- ei auth login
43
- ei auth status
52
+ ```sh
53
+ elementum auth login --profile <profile>
54
+ elementum --profile=<profile> auth status
44
55
  ```
45
56
 
46
- edk never reads `ELEMENTUM_INSTANCE` / `ELEMENTUM_ORGANIZATION`. Workspace paths
47
- come from the folder you run in, an explicit `--root`, or
48
- `<cwd>/<instance>/<org>` from the active `ei` profile.
49
-
50
- **Before apply:** run `edk plan`. This validates that the workspace folder's
51
- instance/org matches `ei auth status`.
57
+ A profile selects the organization, instance, optional organization
58
+ environment, credentials, and custom endpoints. Pass it explicitly before any
59
+ command when reproducibility matters:
52
60
 
53
- ## Set Up An Agent Workspace
61
+ ```sh
62
+ elementum --profile=<profile> pull org --data-only
63
+ elementum --profile=<profile> plan
64
+ ```
54
65
 
55
- ```bash
56
- edk import org
57
- npx edk skills install
66
+ For `plan` and `apply`, `--profile` is optional. The CLI resolves the marked org
67
+ root from the explicit target or current directory, including targets nested
68
+ under `apps/`, `elements/`, or an individual authored file. It reads
69
+ `<instance>/<organization>` from that org root's path and selects the one saved
70
+ profile with the same identity. It does not infer tenant identity from shell
71
+ variables.
72
+
73
+ An explicit `--profile` overrides filesystem selection. The existing safety
74
+ check still rejects that profile if its instance or organization differs from
75
+ the workspace path. If no saved profile matches, or multiple profiles have the
76
+ same filesystem identity, the command fails before planning with the workspace
77
+ identity and tells you to pass `--profile` explicitly. Commands that bootstrap a
78
+ workspace should use an explicit profile because no org root exists yet.
79
+
80
+ ## Workspace setup
81
+
82
+ Start from the parent directory that will contain one or more
83
+ `<instance>/<organization>` workspaces:
84
+
85
+ ```sh
86
+ mkdir elementum-workspace
87
+ cd elementum-workspace
88
+ npm init -y
89
+ npm install @elementumai/edk
90
+ elementum auth login --profile <profile>
91
+ elementum --profile=<profile> pull org --data-only
92
+ cd <instance>/<organization>
93
+ elementum --profile=<profile> init
58
94
  ```
59
95
 
60
- `edk import org` initializes the workspace when needed, then imports org-level
61
- cloud links and AI provider connectors into the generated catalog/state. It
62
- creates:
96
+ `pull org --data-only` bootstraps and refreshes org reference identities. It
97
+ creates the package/workspace scaffolding, `org.ts`, the `@catalog` path alias,
98
+ and the Terraform input/output skeleton:
63
99
 
64
100
  ```text
65
101
  <workspace>/
66
102
  package.json
67
- .npmrc
68
103
  <instance>/
69
- <org>/
104
+ <organization>/
105
+ org.ts
106
+ tsconfig.json
107
+ terraform.tfstate # created by OpenTofu; commit this
70
108
  apps/
71
109
  elements/
72
- tables/
73
110
  generated/
74
111
  catalog.ts
75
- state.<env>.json
112
+ .tf/ # generated and ignored
113
+ in/ # bridge export input
114
+ out/ # SDK build output
76
115
  ```
77
116
 
78
- The org folder is always `<instance>/<org>` from active `ei auth`. It also gets
79
- a `tsconfig.json` path alias so authored files can import the generated catalog
80
- with `import catalog from "@catalog";`.
117
+ `elementum init` is an idempotent installation/workspace convergence command.
118
+ It verifies the managed compatibility train, auth, SDK namespace/version,
119
+ workspace layout, and provider identity. It never logs in or silently migrates
120
+ Terraform state.
81
121
 
82
- `edk init` is deprecated and no longer needed. Workspace initialization happens
83
- automatically as part of `edk pull org --data-only`.
122
+ Do not hand-edit `org.ts`, `generated/`, or `.tf/`. Refresh those through their
123
+ owning commands.
84
124
 
85
- Run import/pull commands from the parent workspace folder. By default they write
86
- to `<cwd>/<instance>/<org>` from `ei auth`: for example, from `edk-project`,
87
- the `edk` org on instance `dev` writes `dev/edk/generated/...` and
88
- `dev/edk/apps/...`. Plan/apply refuse a folder that doesn't match the active
89
- ei profile.
125
+ ## Recommended flow
90
126
 
91
- `edk skills install` prints the Skills CLI install command for the bundled `elementum-edk-authoring` agent skill. Pass `--yes` to run it.
127
+ Pull first when editing an object that already exists:
92
128
 
93
- ## Recommended Flow
129
+ ```sh
130
+ cd <workspace>/<instance>/<organization>
131
+ elementum --profile=<profile> pull org --data-only
132
+ elementum --profile=<profile> pull app <namespace>
133
+ # or: elementum --profile=<profile> pull element <namespace>
94
134
 
95
- For editing what already exists in Elementum, use the pull-first flow:
135
+ # edit apps/<ref>/... or elements/<ref>/...
136
+ npx tsc --noEmit
137
+ elementum build
138
+ elementum --profile=<profile> plan
139
+ elementum --profile=<profile> apply
140
+ ```
96
141
 
97
- ```bash
98
- cd <workspace>
99
- ei auth login
100
- edk pull org --data-only
101
- edk pull app <namespace>
102
- # edit the generated/authoring TypeScript
103
- edk plan
104
- edk apply
142
+ `pull app` and `pull element` reconstruct editable TypeScript, regenerate the
143
+ catalog, then automatically adopt the exported resources into committed
144
+ Terraform state. Adoption is gated to exactly the expected imports, zero
145
+ create/update/destroy operations, and a clean follow-up plan. Use `--no-adopt`
146
+ only when you deliberately want source without state adoption.
147
+
148
+ Pull commands reserve stdout for one JSON summary. Diagnostics and stream kinds
149
+ that do not yet have an extractor are reported rather than silently discarded.
150
+
151
+ ## CLI commands
152
+
153
+ The TypeScript-owned command surface is:
154
+
155
+ ```sh
156
+ elementum init [--check] [--json]
157
+ elementum update [--check | --dry-run] [--channel stable|preview] [--version <semver>]
158
+ elementum migrate provider-source [orgRoot] [--check | --dry-run | --auto-approve]
159
+
160
+ elementum pull org --data-only [--root <orgRoot>]
161
+ elementum pull app <namespace> [--root <orgRoot>] [--no-adopt]
162
+ elementum pull element <namespace> [--root <orgRoot>] [--no-adopt]
163
+ elementum clone app <namespace> --as <newName> [--namespace <newns>] [--root <orgRoot>]
164
+ elementum build [orgRoot]
165
+ elementum plan [orgRoot-or-nested-target] [bridge args...]
166
+ elementum apply [orgRoot-or-nested-target] [bridge args...]
167
+
168
+ elementum list apps|elements|users|groups|categories|cloud-links
169
+ elementum list ai-provider-connectors|automations|tables
170
+ elementum new agent --app <appRef> --name "Triage Bot"
171
+ elementum new skill --app <appRef> --name "Lookup Ticket"
172
+ elementum canvas <orgRoot-or-file> [--port <port>] [--no-open]
173
+ elementum playbooks list|install|status|path|print
105
174
  ```
106
175
 
107
- Run `edk pull org --data-only` before app pull workflows so org-level cloud
108
- links and AI provider connectors exist in the workspace catalog. `edk pull app`
109
- writes editable TypeScript under `<instance>/<org>/apps/<appRef>/...`;
110
- `edk plan` / `edk apply` preview and push from `.tf/out/`.
111
-
112
- ## CLI
113
-
114
- All CLI commands share one auth path: the active `ei auth` profile (`ei auth login`).
115
-
116
- ```bash
117
- edk list apps
118
- edk list users
119
- edk list groups
120
- edk list categories
121
- edk list cloud-links
122
- edk list ai-provider-connectors
123
- edk fetch app --aspect-id <uuid> --fields --agents --automations --search-tables
124
- edk import org
125
- edk import app --id <uuid>
126
- edk import element --id <uuid>
127
- edk import cloud-links
128
- edk import connectors
129
- edk import automation --id <uuid> --app-id <uuid>
130
- edk import agent --id <uuid> --app-id <uuid>
131
- edk import skill --id <uuid> --app-id <uuid>
132
- edk new agent --app <appRef> --name "Triage Bot"
133
- edk new skill --app <appRef> --name "Lookup Ticket"
134
- edk plan <instance>/<org>
135
- edk plan <instance>/<org>/apps/<appRef>
136
- edk apply <instance>/<org>
137
- edk apply <instance>/<org>/apps/<appRef>
138
- edk pull app --id <uuid> --all
139
- edk pull app --aspect-id <uuid>
140
- edk pull app --aspect-id <uuid> --all
141
- edk pull element --id <uuid>
142
- edk pull element --id <uuid> --all
143
- edk pull automation --workflow <uuid>
144
- edk pull agent --agent <uuid>
145
- edk pull skill --skill <uuid>
146
- edk pull search-table --aspect <uuid> --search-table <uuid>
147
- edk pull -i
148
- edk canvas <instance>/<org>/apps/myApp/automations/someAutomation.ts
149
- edk skills path
150
- edk skills print
176
+ `auth` and other bridge-owned commands route through the managed bridge. Run
177
+ `elementum --help` for the combined local and bridge command surface.
178
+
179
+ `build` loads app, element, and supported child authoring files and replaces its
180
+ marker-owned files under `.tf/out/`; it never calls the platform. `plan` and
181
+ `apply` run from `.tf/out/`, initialize OpenTofu there when necessary, and
182
+ forward extra arguments:
183
+
184
+ ```sh
185
+ elementum plan <instance>/<organization>/apps/myApp/myApp.ts
186
+ elementum --profile=<profile> apply <instance>/<organization> -auto-approve
151
187
  ```
152
188
 
153
- `edk import org` writes the org-level **reference-only catalog** and identity
154
- bindings for cloud links and AI provider connectors. Other `edk import ...`
155
- commands remain available as optional bootstrap/adoption tools for app or
156
- entity references; they do not write editable entity source and never put ids in
157
- source. `edk pull` writes editable EDK TypeScript under
158
- `<instance>/<org>/apps/<appRef>/...` when run from the parent workspace (plus
159
- supporting app catalog files). `--root <dir>` overrides the org workspace root
160
- for `import`.
161
- `edk pull -i` opens an interactive terminal interface for selecting entities to
162
- pull within selected application(s).
163
- `edk pull app --aspect-id <uuid> --all` pulls all entities linked to an app.
164
-
165
- `edk new agent`/`edk new skill` scaffold a new, empty agent/skill authoring
166
- file under an already-imported app's `agents/`/`skills/` folder (agents and
167
- skills are app-owned only — elements never own them). The refName is minted
168
- from `--name` and regenerates the owning app's catalog so the new entity is
169
- immediately referenceable; re-running with the same `--name` mints a
170
- disambiguated refName rather than overwriting the existing file. Run these
171
- from the parent workspace, same as `edk import`/`edk pull` — `--app` must
172
- match a refName already imported/pulled there (e.g.
173
- `<instance>/<organization>/apps/<appRef>`),
174
- so a "not imported" error usually means either the wrong `--app` value or that
175
- you ran the command from inside the org folder instead of its parent. A
176
- scaffolded agent's `connector` is left as an unresolved
177
- `catalog.connectors` placeholder — open the file and let IDE autocomplete on
178
- `catalog.connectors.` pick a real handle; it won't typecheck until you do. A
179
- scaffolded skill starts with `tools: []`, immediately compilable, plus a
180
- commented-out example call for each of the six skill tool factories
181
- (`skillSearchAspect`, `skillSearchTable`, `skillCreateRecord`,
182
- `skillUpdateRecord`, `skillAutomation`, `skillRunAgent`) with the app's own
183
- handle already filled in — uncomment whichever kinds you need, add the
184
- matching import, and autocomplete the remaining `catalog.` refs.
185
-
186
- Ignore legacy top-level files such as `generated/apps/aspects-catalog.ts`
187
- (sometimes remembered as `aspect-catalog.ts`) if you find them in an older
188
- workspace. Current catalogs live under each instance/org folder, for example
189
- `<instance>/<organization>/generated/catalog.ts` and
190
- `<instance>/<organization>/apps/<appRef>/generated/catalog.ts`.
191
-
192
- ## Canvas — explore your workspace
193
-
194
- `edk canvas` opens a local, fully offline explorer for an org workspace:
195
-
196
- ```bash
197
- edk canvas <instance>/<org> # explore a workspace directory
198
- edk canvas # same, resolved from ei auth / org workspace cwd
189
+ The optional path may be the org root or anything nested beneath it. Run from
190
+ any directory inside the marked org workspace to omit it. The CLI always runs
191
+ the bridge/OpenTofu pass-through from that root's `.tf/out/`; it does not scan
192
+ or deploy an individual target file.
193
+
194
+ `new agent` and `new skill` create offline app-owned scaffolds without
195
+ overwriting an existing ref. Here, `skill` means an Elementum **agentic
196
+ skill** attached to an agent. Coding-agent guidance is packaged separately as
197
+ **playbooks** (Agent Skills-standard `SKILL.md` directories):
198
+
199
+ ```sh
200
+ elementum playbooks list
201
+ elementum playbooks install --yes
199
202
  ```
200
203
 
201
- The explorer opens `http://localhost:3456` and lets you navigate everything
202
- EDK manages in the workspace: apps (fields with types/flags/options, status
203
- options, the stage pipeline) and the org reference identities (cloud links,
204
- categories, connectors, groups, shown with their `org.<bag>.<key>` authoring
205
- tokens). It watches the workspace and hot-reloads on every save; `/` focuses
206
- search, which filters apps, fields, and identities live. Broken authoring
207
- files degrade to an inline error card — the rest of the workspace stays
208
- navigable.
204
+ The installed slash commands are `/elementum`, `/elementum-uat`,
205
+ `/elementum-debug`, `/elementum-deployments`, and `/elementum-design`.
206
+ `elementum skills ...` remains the platform command family for agentic-skill
207
+ operations.
209
208
 
210
- Pointing it at a **file** instead keeps the original render-tree preview:
211
- the first export with `toUI()` (or `.build().toUI()`) renders and reloads on
212
- save. Pass `--port <port>` to avoid conflicts or `--no-open` to skip opening
213
- a browser.
209
+ ## Canvas
214
210
 
215
- ## Package Imports
211
+ Canvas is an offline, live-reloading view of authored source:
216
212
 
217
- Use package subpaths instead of repo-relative imports. Each entity's builder,
218
- trigger/task/tool factories, and types all live under one subpath:
213
+ ```sh
214
+ elementum canvas <instance>/<organization>
215
+ elementum canvas apps/myApp/flows/someFlow.ts
216
+ ```
217
+
218
+ A directory target opens the workspace explorer at `http://localhost:3456`,
219
+ covering pulled org identities, apps, fields, status/stages, agents and their
220
+ tools, and supported automations. A file target renders the first export with
221
+ `toUI()` (or `.build().toUI()`). Use `--port <port>` to choose another port or
222
+ `--no-open` to suppress browser launch.
223
+
224
+ ## Package imports
225
+
226
+ Import public package subpaths, not repository-relative modules:
219
227
 
220
228
  ```ts
221
- import { defineApp, calc } from "@elementumai/edk/app";
222
- import { defineAutomation, defineWorkflow, onDemand, recordSearch } from "@elementumai/edk/automations";
223
- import { defineAgent, agentSearchAspect } from "@elementumai/edk/agents";
229
+ import { calc, defineApp } from "@elementumai/edk/app";
230
+ import { defineElement } from "@elementumai/edk/elements";
231
+ import {
232
+ defineAutomation,
233
+ defineWorkflow,
234
+ executeScript,
235
+ onDemand,
236
+ } from "@elementumai/edk/automations";
237
+ import {
238
+ agentCreateRecord,
239
+ agentRunAutomation,
240
+ agentSearchAspect,
241
+ defineAgent,
242
+ } from "@elementumai/edk/agents";
224
243
  import { defineSkill } from "@elementumai/edk/agents/skills";
225
244
  import { defineFlow } from "@elementumai/edk/flows";
226
245
  import { defineSearchTable } from "@elementumai/edk/searchTables";
227
246
  import { defineApprovalChain } from "@elementumai/edk/approvalChains";
228
247
  import { defineTable } from "@elementumai/edk/tables";
229
248
  import { eq } from "@elementumai/edk/core/filters";
249
+ import catalog from "@catalog";
230
250
  ```
231
251
 
232
- ## The Authoring Model
233
-
234
- EDK is Terraform-like. You don't paste UUIDs into source — instead:
235
-
236
- 1. `edk auth login` establishes the CLI auth profile. It can prompt
237
- interactively or accept explicit tenant/credential flags.
238
- 2. `edk import org` initializes the workspace if needed, then writes org-level
239
- reference-only catalogs/state for cloud links and AI provider connectors.
240
- Run it before pull workflows.
241
- 3. `edk pull <entity> <args>` writes editable TypeScript for live Elementum
242
- objects under `<instance>/<org>/apps/<appRef>/...` when run from the parent workspace,
243
- plus supporting catalog/state files.
244
- 4. You author against **handle-tokens** imported with
245
- `import catalog from "@catalog";` (`catalog.myApp.fields.status`,
246
- `catalog.myApp.automations.someAutomation`, `catalog.connectors.claude`). Some
247
- builders return configured `{ ref(refName), def(refName) }` objects whose
248
- refName comes from the file name; others still return `DeployableEntity` directly.
249
- There is no `.deploy()` method.
250
- 5. `edk plan <dir>` / `edk apply <dir>` regenerate app catalogs from authoring files, resolve
251
- tokens against state, diff each entity structurally against its recorded
252
- baseline, and create or update.
253
-
254
- `edk import app --id <uuid>` is still useful as an optional reference-only
255
- bootstrap/adoption path when you need app refs without pulling editable source.
256
-
257
- ## Author An Automation
258
-
259
- Start from the live app source, then author against its handle-tokens:
260
-
261
- ```bash
262
- cd <workspace>
263
- edk import org
264
- edk pull app --id <uuid> --all
265
- ```
252
+ The package exports and `typesVersions` map are kept in lockstep. Generated
253
+ source uses the same public subpaths.
254
+
255
+ ## Authoring model
256
+
257
+ EDK uses names and typed tokens in source, with Terraform state providing
258
+ platform identity:
259
+
260
+ 1. `pull org --data-only` writes org reference bags to `org.ts`, including
261
+ cloud links, categories, connectors, and groups.
262
+ 2. `pull app` or `pull element` writes editable source and adopts existing
263
+ resources into `terraform.tfstate`.
264
+ 3. `generated/catalog.ts` is a pure barrel derived from the authored file tree.
265
+ Import app/entity tokens from `@catalog`; import org tokens from `org.ts`.
266
+ 4. `build` converts TypeScript to the one supported HCL dialect in `.tf/out/`.
267
+ 5. OpenTofu resolves references and computes create/update/replace/destroy
268
+ behavior during `plan` and `apply`.
269
+
270
+ There are no UUIDs or minted handles in authored source. The TypeScript bag key
271
+ is the Terraform label in camelCase through a lossless label conversion. For
272
+ example, a field's key in `fields: {}` is its identity; its display `name` can
273
+ change.
274
+
275
+ Configured builders such as `defineAgent` and `defineAutomation` return
276
+ `{ ref(refName), def(refName) }`. Workspace discovery supplies the ref name from
277
+ the file path. There is no `.deploy()` method.
278
+
279
+ ## Automation example
280
+
281
+ The Terraform path currently round-trips on-demand triggers plus execute-script
282
+ and create-variable tasks. Other typed trigger/task factories remain available
283
+ to the authoring API but are reported as unsupported by `build` until their
284
+ Terraform mappings land.
266
285
 
267
286
  ```ts
268
- import { defineAutomation, defineWorkflow, filter, onDemand, recordSearch } from "@elementumai/edk/automations";
269
- import catalog from "@catalog";
287
+ import { defineAutomation, onDemand } from "@elementumai/edk/automations";
288
+ import { template } from "@elementumai/edk/core";
270
289
 
271
290
  export default defineAutomation({
272
- name: "Some Automation",
273
- parent: "myApp",
274
- workflow: defineWorkflow()
275
- .trigger(onDemand({}))
276
- .task("findTickets", () => recordSearch({
277
- app: catalog.myApp,
278
- filter: filter.eq(catalog.myApp.fields.status, "Escalated"),
279
- limit: 10,
291
+ name: "Greet New Student",
292
+ parent: "students",
293
+ workflowRevision: "1.0.0",
294
+ workflow: onDemand({ STUDENT_NAME: "text" })
295
+ .setVariable("GREETING", {
296
+ value: (ctx) => template("Welcome, ", ctx.trigger.STUDENT_NAME),
297
+ })
298
+ .executeScript("FORMAT_GREETING", {
299
+ inputs: (ctx) => ({ greeting: ctx.variables.GREETING }),
300
+ code: (input) => ({
301
+ message: `${input.parameters.greeting}!`,
302
+ }),
303
+ })
304
+ .outputs((ctx) => ({
305
+ message: ctx.tasks.FORMAT_GREETING.result.message,
280
306
  })),
281
307
  });
282
308
  ```
283
309
 
284
- ## Author An Agent
310
+ The file path supplies the automation ref; `parent` is the owning app ref.
311
+ `workflowRevision` is required SemVer and is the explicit publish gate. Editing
312
+ tasks or triggers updates the draft; bump the revision only when that draft
313
+ should be published.
285
314
 
286
- The AI provider connector is a `catalog.connectors.<key>` handle-token from the
287
- org catalog (`edk import org`). The builder takes options (including a
288
- `tools:` array) and returns a configured entity:
315
+ ## Agent example
316
+
317
+ Agents live under `apps/<appRef>/agents/<agentRef>.ts`. Their connector comes
318
+ from the org catalog, while app and field targets come from `@catalog`:
289
319
 
290
320
  ```ts
291
- import { defineAgent, agentSearchAspect } from "@elementumai/edk/agents";
321
+ import { agentSearchAspect, defineAgent } from "@elementumai/edk/agents";
292
322
  import catalog from "@catalog";
323
+ import { org } from "../../../org.js";
293
324
 
294
325
  export default defineAgent({
295
326
  name: "Support Agent",
296
- parent: "myApp",
297
- connector: catalog.connectors.claude,
298
- description: "Helps with records in myApp.",
299
- instructions: "Search records and summarize next actions.",
300
- temperature: 0.2,
301
- maxLength: 2000,
327
+ parent: "support",
328
+ connector: org.connectors.claudeSonnet,
329
+ description: "Finds support records.",
330
+ instructions: "Search records and summarize the next action.",
302
331
  tools: [
303
332
  agentSearchAspect({
304
- name: "searchRecords",
305
- description: "Search myApp records.",
306
- aspect: catalog.myApp,
307
- queryDescription: "Describe the record or user request.",
333
+ name: "find_records",
334
+ description: "Searches support records.",
335
+ aspect: catalog.support,
336
+ queryDescription: "Describe the record to find.",
337
+ fields: [
338
+ {
339
+ field: catalog.support.fields.status,
340
+ description: "Current status",
341
+ },
342
+ ],
308
343
  }),
309
344
  ],
310
345
  });
311
346
  ```
312
347
 
313
- ## Plan And Apply
314
-
315
- Run the Terraform-style commands against one or more directories and/or entity
316
- files. Directory targets discover every file below that directory whose
317
- default export is a built `DeployableEntity`; file targets plan/apply only that
318
- entity. Multiple targets aggregate into one plan. Only `apply` writes:
319
-
320
- ```bash
321
- # From the parent folder that contains instance/org workspaces:
322
- edk plan <instance>/<org>
323
- edk apply <instance>/<org>
324
- edk plan <instance>/<org>/apps/myApp
325
- edk apply <instance>/<org>/apps/myApp
326
-
327
- # From inside the instance/org workspace:
328
- edk plan .
329
- edk apply .
330
- edk plan apps/myApp
331
- edk apply apps/myApp
332
-
333
- # Apply one entity in place, or several paths at once:
334
- edk plan apps/myApp/automations/someAutomation.ts
335
- edk apply elements/tag/tag.ts elements/address/address.ts
348
+ The Terraform path currently round-trips create-record, search-aspect, and
349
+ run-automation agent tools. Unsupported tools and runtime-only knobs are
350
+ reported as build diagnostics instead of being emitted as partial resources.
351
+ Authored tool names use 1–64 letters, digits, or underscores, with no doubled
352
+ underscores.
353
+
354
+ ## Plan and apply
355
+
356
+ Always build before planning:
357
+
358
+ ```sh
359
+ cd <workspace>/<instance>/<organization>
360
+ elementum build
361
+ elementum plan
362
+ elementum apply
363
+ ```
364
+
365
+ `plan` and `apply` are pass-throughs to the managed bridge with inherited
366
+ stdio. With no explicit profile, the CLI selects the unique saved profile
367
+ matching the org root's `<instance>/<organization>` path. Review destroy and
368
+ replacement actions just as you would in any Terraform plan.
369
+
370
+ ## Identity and state recovery
371
+
372
+ `terraform.tfstate` at the org root is the durable binding between authored
373
+ labels and live platform objects. Commit it to the workspace repository.
374
+ `.tf/` remains generated and ignored.
375
+
376
+ The generated `providers.tf` pins a **local** OpenTofu backend at
377
+ `<orgRoot>/terraform.tfstate` and is regenerated on every `build`, so a remote
378
+ backend cannot be substituted in this release. The committed `terraform.tfstate`
379
+ is the source of truth; coordinate concurrent changes through your normal git
380
+ workflow (single writer, review on change) rather than distributed state
381
+ locking. Remote backends and state locking are candidates for a later release.
382
+
383
+ If state is lost, do not apply the built configuration: OpenTofu would see the
384
+ live objects as new. Restore the state file from version control or re-adopt
385
+ each stream with:
386
+
387
+ ```sh
388
+ elementum --profile=<profile> pull org --data-only
389
+ elementum --profile=<profile> pull app <namespace>
390
+ elementum --profile=<profile> pull element <namespace>
391
+ ```
392
+
393
+ After an update reports an old provider identity, inspect and explicitly
394
+ migrate the committed state:
395
+
396
+ ```sh
397
+ elementum migrate provider-source <orgRoot> --check
398
+ elementum migrate provider-source <orgRoot> --auto-approve
399
+ elementum --profile=<profile> plan <orgRoot>
336
400
  ```
337
401
 
338
- `apply` prints the same plan first, then asks for confirmation. Only typing
339
- `yes` applies creates and updates. If no target is supplied, the command
340
- uses the current working directory. Files starting with `_` and
341
- test/declaration files are ignored, so private helper scripts are not
342
- imported.
343
-
344
- Every target must live under an org workspace whose folder matches the active
345
- auth org — either a bare `<org>/...` or the nested `<instance>/<org>/...`
346
- (for example `eu/sanofi/elements/foo.ts`). When the org folder sits directly
347
- under a recognized instance name (`us`, `eu`, `stage`, `dev`, `local`), that
348
- instance segment must also match the active auth config. Authoring files
349
- inside must additionally sit under `apps/<ref>/` or `elements/<ref>/` in one of
350
- the accepted shapes (the aspect file itself, or a child bag like
351
- `automations/<name>.ts`) — a flat `apps/<name>.ts` is rejected.
352
-
353
- Plan output uses the recorded `generated/state.<env>.json` bindings and reports
354
- create, update, skip, blocked, disabled, and update-unsupported verdicts.
355
-
356
- Builds are local. `plan`/`apply` require an active `ei auth` profile matching the workspace folder.
357
-
358
- ## Create Vs Update
359
-
360
- `plan`/`apply` resolve each entity's handle-tokens against `generated/state.<env>.json`, then
361
- decide per entity:
362
-
363
- - **create** — no binding recorded for this `kind::refName` → POST.
364
- - **skip** — bound, and a structural diff against the recorded baseline is
365
- empty → no wire call.
366
- - **update** — bound, and the payload differs → PUT against the bound id,
367
- carrying the changed fields. (A bound-but-baseline-less entity — e.g. one
368
- imported reference-only and now being managed — diffs as all-changed and
369
- reconciles the platform to local source.)
370
- - **update-unsupported** — bound and changed, but the kind has no platform
371
- PUT. Apply reports `DeployUpdateUnsupportedError`; delete the entity on the
372
- platform and re-create.
373
- - **blocked** — a referenced handle isn't bound yet (import the app/entity it
374
- points at). Apply surfaces the miss rather than POSTing a dangling reference.
375
-
376
- Support today:
377
-
378
- - **Automations, agents, skills** support create, update, and skip.
379
- - **Flows, search tables, tables** are create-only — a change to a deployed one
380
- is `update-unsupported` until the platform ships PUT.
381
-
382
- There are no source-level ids and no `.deploy()` seed refs anymore: identity
383
- lives entirely in state. On disk, state is consolidated into
384
- `generated/state.<env>.json` in the org workspace; it contains org bindings,
385
- the app registry, per-app bindings, and baselines. Override the generated-state
386
- directory with `EDK_STATE_DIR`. Commit the state file to share identity across
387
- machines; gitignore it for per-developer state.
388
-
389
- If a state file is corrupt or schema-incompatible, the loader throws
390
- `DeployStateCorruptError` rather than silently rebuilding it — re-import the
391
- owning app to rebuild bindings.
392
-
393
- ### Recovering identity
394
-
395
- Lost `generated/state.<env>.json` (fresh clone, deleted by accident) means EDK no longer knows
396
- which platform entities your handle-tokens map to. Re-run `edk import org` for
397
- org references, then pull the app/entity again or use `edk import app --id
398
- <uuid>` as a reference-only bootstrap when you only need bindings. Author files
399
- keep working unchanged because they only reference handles, never ids.
402
+ The migration creates an ignored recovery snapshot, runs OpenTofu
403
+ `state replace-provider`, refreshes generated provider configuration, and never
404
+ applies infrastructure.
405
+
406
+ ## Create and update semantics
407
+
408
+ Terraform owns lifecycle decisions; EDK has no second deployment state machine:
409
+
410
+ - Configured resource absent from state: create.
411
+ - Resource present in config and state with changed attributes: update in place
412
+ or replace, according to provider schema.
413
+ - Resource present in state but absent from built config: destroy.
414
+ - Existing platform resource mapped into state by pull: adopt.
415
+
416
+ Pull adoption's zero-write gates prevent an existing resource from being
417
+ mistaken for a create. Build diagnostics are part of the safety contract:
418
+ unsupported stream kinds are never silently adopted or emitted. Renames that
419
+ change an exported Terraform label are guarded during adoption and rebound with
420
+ state moves when the existing platform identity can be proven.
400
421
 
401
422
  ## Development
402
423
 
403
- ```bash
404
- npm install
405
- npm run build
406
- npm run typecheck
407
- npm test
408
- npm run pack:dry-run
424
+ The repository builds three distinct output trees:
425
+
426
+ - `dist-sdk/` — `tsc -p tsconfig.sdk.json` output, the sole source tree packed
427
+ into the `@elementumai/edk` SDK package;
428
+ - `dist-cli/` — Node-compatible `tsc -p tsconfig.cli.json` output used by local
429
+ development, tests, integration tooling, and the binary build script; it is
430
+ not part of the SDK package or the final release payload;
431
+ - `dist-bin/` — standalone `elementum` executables produced from `dist-cli` by
432
+ the locked local Bun dependency; these are the CLI release inputs distributed
433
+ separately from npm.
434
+
435
+ The repository's principal source roots are siblings:
436
+
437
+ ```text
438
+ src/ # TypeScript SDK and public CLI
439
+ cmd/elementum/ # temporary private Go bridge module
440
+ provider/ # OpenTofu provider module
441
+ distribution/ # registry and installer package
442
+ ```
443
+
444
+ Contributor setup, change-specific tests, Go/provider checks, and pull-request
445
+ verification are documented in [CONTRIBUTING.md](CONTRIBUTING.md). The shortest
446
+ local CLI path is:
447
+
448
+ ```sh
449
+ npm run local:setup
450
+ npm run elementum -- --help
451
+ npm run test:cli
409
452
  ```
453
+
454
+ See [binary validation](docs/edk-binary.md) for release and
455
+ compatibility-train checks.
456
+
457
+ ## Contributor integration harness
458
+
459
+ The Preston High harness creates, mutates, renames, and deletes live resources.
460
+ Use only a dedicated test organization and profile. The complete setup,
461
+ required org identities, golden-workspace flow, command flags, and failure
462
+ semantics live in the
463
+ [Golden integration test](CONTRIBUTING.md#golden-integration-test).