@elementumai/edk 0.10.4 → 0.12.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 (171) hide show
  1. package/README.md +49 -13
  2. package/dist-sdk/src/catalog/token.js +2 -1
  3. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
  4. package/dist-sdk/src/core/triggers/on-demand.js +3 -0
  5. package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
  6. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  7. package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
  8. package/dist-sdk/src/engine/coverage-gaps.js +12 -0
  9. package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
  10. package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
  11. package/dist-sdk/src/engine/ei/run.d.ts +42 -1
  12. package/dist-sdk/src/engine/ei/run.js +201 -32
  13. package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
  14. package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
  15. package/dist-sdk/src/engine/ei/state.d.ts +1 -1
  16. package/dist-sdk/src/engine/ei/state.js +17 -4
  17. package/dist-sdk/src/engine/progress.d.ts +3 -1
  18. package/dist-sdk/src/engine/progress.js +7 -3
  19. package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
  20. package/dist-sdk/src/engine/pull/authored-address.js +180 -29
  21. package/dist-sdk/src/engine/pull/context.d.ts +37 -2
  22. package/dist-sdk/src/engine/pull/context.js +7 -4
  23. package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
  24. package/dist-sdk/src/engine/pull/ref-only.js +52 -0
  25. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  26. package/dist-sdk/src/engine/tf/index.js +2 -2
  27. package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
  28. package/dist-sdk/src/engine/tf/labels.js +50 -0
  29. package/dist-sdk/src/engine/tf/model.d.ts +2 -0
  30. package/dist-sdk/src/engine/tf/model.js +26 -0
  31. package/dist-sdk/src/engine/validation.d.ts +2 -0
  32. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
  33. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
  34. package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
  35. package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
  36. package/dist-sdk/src/entities/access-policy/module.js +10 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
  39. package/dist-sdk/src/entities/agent/build.js +7 -5
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
  41. package/dist-sdk/src/entities/agent/from-tf.js +13 -3
  42. package/dist-sdk/src/entities/agent/to-tf.js +11 -5
  43. package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
  44. package/dist-sdk/src/entities/agent/tools.js +6 -2
  45. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  46. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
  47. package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
  48. package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
  49. package/dist-sdk/src/entities/agent-tool/types.js +13 -9
  50. package/dist-sdk/src/entities/app/build.d.ts +12 -1
  51. package/dist-sdk/src/entities/app/build.js +80 -4
  52. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
  53. package/dist-sdk/src/entities/app/from-tf.js +17 -12
  54. package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
  55. package/dist-sdk/src/entities/app/stage-keys.js +40 -6
  56. package/dist-sdk/src/entities/app/to-tf.js +7 -4
  57. package/dist-sdk/src/entities/automation/build.d.ts +52 -31
  58. package/dist-sdk/src/entities/automation/build.js +59 -20
  59. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
  60. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
  61. package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
  62. package/dist-sdk/src/entities/automation/from-tf.js +721 -93
  63. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  64. package/dist-sdk/src/entities/automation/module.d.ts +22 -2
  65. package/dist-sdk/src/entities/automation/module.js +244 -57
  66. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
  67. package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
  68. package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
  69. package/dist-sdk/src/entities/automation/run-target.js +104 -0
  70. package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
  71. package/dist-sdk/src/entities/automation/script-code.js +106 -4
  72. package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
  73. package/dist-sdk/src/entities/automation/script-lint.js +418 -0
  74. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
  75. package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
  76. package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
  77. package/dist-sdk/src/entities/automation/tasks.js +18 -4
  78. package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
  79. package/dist-sdk/src/entities/automation/to-tf.js +354 -64
  80. package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
  81. package/dist-sdk/src/entities/automation/triggers.js +45 -5
  82. package/dist-sdk/src/entities/automation/types.d.ts +21 -0
  83. package/dist-sdk/src/entities/automation/types.js +26 -0
  84. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  85. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  86. package/dist-sdk/src/entities/chart/from-tf.js +25 -1
  87. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  88. package/dist-sdk/src/entities/chart/printer.js +5 -2
  89. package/dist-sdk/src/entities/chart/to-tf.js +19 -1
  90. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
  91. package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
  92. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  93. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
  94. package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
  95. package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
  96. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  97. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
  98. package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
  99. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
  100. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
  101. package/dist-sdk/src/entities/element/build.d.ts +10 -0
  102. package/dist-sdk/src/entities/element/build.js +1 -0
  103. package/dist-sdk/src/entities/element/from-tf.js +14 -9
  104. package/dist-sdk/src/entities/element/to-tf.js +7 -4
  105. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  106. package/dist-sdk/src/entities/field/from-tf.js +79 -1
  107. package/dist-sdk/src/entities/field/module.js +14 -1
  108. package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
  109. package/dist-sdk/src/entities/field/to-tf.js +108 -34
  110. package/dist-sdk/src/entities/file-reader/module.js +3 -3
  111. package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
  112. package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
  113. package/dist-sdk/src/entities/file-reader/types.js +7 -0
  114. package/dist-sdk/src/entities/org/group.d.ts +1 -0
  115. package/dist-sdk/src/entities/org/group.js +2 -1
  116. package/dist-sdk/src/entities/org/role.js +5 -0
  117. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
  118. package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
  119. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
  120. package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
  121. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
  122. package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
  123. package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
  124. package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
  125. package/dist-sdk/src/entities/role/from-tf.js +24 -7
  126. package/dist-sdk/src/entities/role/to-tf.js +25 -7
  127. package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
  128. package/dist-sdk/src/entities/service-account/module.js +20 -0
  129. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
  130. package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
  131. package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
  132. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  133. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  134. package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
  135. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
  136. package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
  137. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
  138. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
  139. package/dist-sdk/src/entities/skill/from-tf.js +10 -3
  140. package/dist-sdk/src/entities/skill/module.js +18 -0
  141. package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
  142. package/dist-sdk/src/entities/skill/to-tf.js +23 -14
  143. package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
  144. package/dist-sdk/src/entities/skill/tools.js +6 -2
  145. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  146. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  147. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
  148. package/dist-sdk/src/entities/task/to-tf.js +1 -0
  149. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
  150. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
  152. package/dist-sdk/src/entities/view/from-tf.js +394 -22
  153. package/dist-sdk/src/entities/view/module.js +20 -0
  154. package/dist-sdk/src/entities/view/portable.d.ts +11 -0
  155. package/dist-sdk/src/entities/view/portable.js +47 -0
  156. package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
  157. package/dist-sdk/src/entities/view/to-tf.js +25 -7
  158. package/dist-sdk/src/entities/view/types.js +1 -1
  159. package/dist-sdk/src/entities/widget/build.d.ts +4 -3
  160. package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
  161. package/dist-sdk/src/entities/widget/from-tf.js +100 -3
  162. package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
  163. package/dist-sdk/src/entities/widget/to-tf.js +77 -14
  164. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
  165. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  166. package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
  167. package/dist-sdk/src/graph/field-resource-types.js +11 -0
  168. package/dist-sdk/src/graph/index.d.ts +41 -3
  169. package/dist-sdk/src/graph/index.js +24 -2
  170. package/dist-sdk/src/graph/types.d.ts +195 -5
  171. package/package.json +1 -1
package/README.md CHANGED
@@ -51,6 +51,25 @@ elementum auth login --profile <profile>
51
51
  elementum --profile=<profile> auth status
52
52
  ```
53
53
 
54
+ `auth login` asks how to sign in. **Browser** (recommended) needs only your
55
+ Elementum URL: the browser opens, you click **Approve**, and the organization,
56
+ environment and profile name are filled in from the URL. Pass the URL to skip
57
+ the form, with or without a terminal:
58
+
59
+ ```sh
60
+ elementum auth login --url https://acme.elementum.io
61
+ ```
62
+
63
+ A browser login stores no client secret. Its tokens are kept in the OS keychain
64
+ and renew automatically for 30 days from the last use, up to 90 days from the
65
+ sign-in; approving requires the CREATE_OAUTH_TOKENS permission in the org.
66
+ It works for every command, `plan` and `apply` included. `auth env` prints its
67
+ current access token (good for up to 24 hours, it does not renew), and `auth
68
+ export` carries the profile's settings without its tokens, so you sign in once
69
+ on the other machine. **Client ID and secret** (from an OAuth token created on
70
+ the OAuth settings page) remains available, for CI and other places where no
71
+ one can click Approve.
72
+
54
73
  A profile selects the organization, instance, optional organization
55
74
  environment, credentials, and custom endpoints. Pass it explicitly before any
56
75
  command when reproducibility matters:
@@ -191,10 +210,11 @@ elementum migrate provider-source [orgRoot] [--check | --dry-run | --auto-approv
191
210
 
192
211
  elementum pull org [--root <orgRoot>] [--no-adopt]
193
212
  elementum pull org --data-only [--root <orgRoot>]
194
- elementum pull app <namespace> [--root <orgRoot>] [--no-adopt] [--skip-unsupported-layouts]
195
- elementum pull element <namespace> [--root <orgRoot>] [--no-adopt] [--skip-unsupported-layouts]
213
+ elementum pull app <namespace> [--root <orgRoot>] [--no-adopt] [--skip-unsupported-layouts] [--portable [--map <file>]]
214
+ elementum pull element <namespace> [--root <orgRoot>] [--no-adopt] [--skip-unsupported-layouts] [--portable [--map <file>]]
215
+ elementum pull task <namespace> [--root <orgRoot>] [--no-adopt] [--portable [--map <file>]]
196
216
  elementum pull --restore-previous [--root <orgRoot>] # after a failed pull: .tf/in.previous -> .tf/in (failed copy kept as .tf/in.failed); never automatic
197
- elementum clone app <namespace> --as <newName> [--namespace <newns>] [--root <orgRoot>]
217
+ elementum clone app <namespace> --as <newName> [--namespace <newns>] [--root <orgRoot>] [--target-root <destOrgRoot>] [--map <file>]
198
218
  elementum build [orgRoot]
199
219
  elementum plan [orgRoot-or-nested-target] [--json] [bridge args...]
200
220
  elementum apply [orgRoot-or-nested-target] [--json] [bridge args...]
@@ -202,7 +222,9 @@ elementum plan --smart [--base <branch>] [orgRoot-or-nested-target] [bridge args
202
222
  elementum apply --smart [--base <branch>] [orgRoot-or-nested-target] [-auto-approve] [bridge args...]
203
223
 
204
224
  elementum list apps|elements|users|groups|categories|cloud-links
205
- elementum list ai-provider-connectors|automations|tables
225
+ elementum list ai-provider-connectors|automations|tables|portals
226
+ elementum list relationships <namespace-or-id> [--json] # read-only: the related end and column mappings of each relationship
227
+ elementum apps export <namespace> [--recursive=false] [--directory <dir>] # raw Terraform export (runs the bridge's `ei apps export`)
206
228
  elementum new category --name "Operations"
207
229
  elementum new app --name "Support Tickets" --namespace support --category "Operations" --handle SUPPORT
208
230
  elementum new element --name "Locations" --namespace locations --category "Operations" --handle LOCATION
@@ -218,6 +240,15 @@ elementum playbooks list|install|status|path|print
218
240
  `auth` and other bridge-owned commands route through the managed bridge. Run
219
241
  `elementum --help` for the combined local and bridge command surface.
220
242
 
243
+ `elementum apps export` is the supported way to get a raw Terraform export of a
244
+ live app. It is a pass-through to the bridge's `ei apps export`, which does the
245
+ work: the same flags, the same output, and the same exit code. When an export
246
+ stops on an incomplete read, the error names the read. If the platform sent
247
+ errors, it also gives their message and ends with a `[not retried: …]` or
248
+ `[retries exhausted …]` detail. A stop with no platform errors (for example a
249
+ null workflow and no GraphQL errors) has no bracket. Report the error as
250
+ printed. Use `elementum apps export` rather than calling `ei` directly.
251
+
221
252
  `build` loads app, element, and supported child authoring files and replaces its
222
253
  marker-owned files under `.tf/out/`; it never calls the platform. `plan` and
223
254
  `apply` run from `.tf/out/`, initialize OpenTofu there when necessary, and
@@ -286,10 +317,12 @@ The server exposes `run` (any CLI command as argument tokens after
286
317
  login, auth-check, pull/build/plan/apply, and pass profiles. Nested
287
318
  `mcp`/`canvas`/`chat` are refused, as are `auth env` / `auth export` /
288
319
  `auth import` (credential dump or passphrase TTY). `auth login` over MCP is
289
- non-interactive: it reads `ELEMENTUM_ORGANIZATION`, `ELEMENTUM_INSTANCE`,
290
- `ELEMENTUM_CLIENT_ID`, `ELEMENTUM_CLIENT_SECRET`, and optional
291
- `ELEMENTUM_PROFILE` (or the matching flags) and persists a profile. A human
292
- TTY login still uses the form. `apply` still goes through the real CLI; after
320
+ non-interactive. With `["auth", "login", "--url", "<the user's Elementum
321
+ URL>"]` it opens the user's browser and waits up to five minutes for them to
322
+ click **Approve**, then persists a profile. Without `--url` it reads
323
+ `ELEMENTUM_ORGANIZATION`, `ELEMENTUM_INSTANCE`, `ELEMENTUM_CLIENT_ID`,
324
+ `ELEMENTUM_CLIENT_SECRET`, and optional `ELEMENTUM_PROFILE` (or the matching
325
+ flags). A human TTY login still uses the form. `apply` still goes through the real CLI; after
293
326
  the user reviews the plan, use `["apply", "-auto-approve"]` (stdin is not a
294
327
  TTY, so a bare apply cannot prompt).
295
328
 
@@ -462,8 +495,9 @@ export default agent({
462
495
  The Terraform path currently round-trips create-record, record-search, and
463
496
  run-automation agent tools. Unsupported tools and runtime-only knobs are
464
497
  reported as build diagnostics instead of being emitted as partial resources.
465
- Authored tool names use 1–64 letters, digits, or underscores, with no doubled
466
- underscores.
498
+ Tool names use 1–64 letters, digits, underscores, or hyphens, with no spaces
499
+ or doubled underscores (the platform's own rule, so platform-generated names
500
+ such as `resolve_<field>-<8 hex>` pull and build unchanged).
467
501
 
468
502
  ## Plan and apply
469
503
 
@@ -626,8 +660,10 @@ elementum --profile=<profile> plan <orgRoot>
626
660
  ```
627
661
 
628
662
  The migration reads the configured local or remote state, creates an ignored
629
- recovery snapshot, runs backend-bound OpenTofu `state replace-provider`,
630
- refreshes generated provider configuration, and never applies infrastructure.
663
+ recovery snapshot, runs OpenTofu `state replace-provider` (in `.tf/out` against
664
+ a declared backend, or directly on `terraform.tfstate` on the default local
665
+ backend), refreshes generated provider configuration, and never applies
666
+ infrastructure.
631
667
 
632
668
  ### CI/CD
633
669
 
@@ -639,7 +675,7 @@ GitHub Actions job (the public signed toolchain is macOS-only today) looks like:
639
675
  ```yaml
640
676
  jobs:
641
677
  apply:
642
- runs-on: macos-14
678
+ runs-on: macos-26
643
679
  concurrency:
644
680
  group: elementum-prod
645
681
  cancel-in-progress: false
@@ -65,7 +65,8 @@ export function slimToken(token) {
65
65
  if (token.__kind === "documentModel" && typeof token.readerType === "string")
66
66
  out.readerType = token.readerType;
67
67
  // A platform-managed automation is looked up by display name when a widget
68
- // runs it; `name` can be the refName.
68
+ // runs it. Pull prints that in `name`; sources pulled before edk#1894 carry
69
+ // it in `displayName`, so keep it for them.
69
70
  if (token.__kind === "automation" && typeof token.displayName === "string")
70
71
  out.displayName = token.displayName;
71
72
  // Procedure lookup must carry the exact ordered Snowflake signature so the
@@ -140,6 +140,8 @@ type WireDefaultValue = {
140
140
  datetime: string;
141
141
  } | {
142
142
  userId: OnDemandUserDefault;
143
+ } | {
144
+ groupId: string;
143
145
  } | {
144
146
  attachmentId: string;
145
147
  };
@@ -89,6 +89,9 @@ function wrapDefaultValueForWire(alias, value) {
89
89
  }
90
90
  return { userId: { __kind: "user", email: user.email } };
91
91
  }
92
+ case "groupId":
93
+ // A group's platform id, like attachmentId's (#2204).
94
+ return { groupId: value };
92
95
  case "attachmentId":
93
96
  return { attachmentId: value };
94
97
  case "record":
@@ -53,6 +53,18 @@ function serializeTemplate(data) {
53
53
  let templateStr = "";
54
54
  const parameters = [];
55
55
  let paramIndex = 1;
56
+ // A string part may already contain `{{{p1}}}` — the platform's mention
57
+ // chip text inside rich-text HTML. Naming a real reference `p1` makes the
58
+ // platform substitute that reference into the chip (#2086). Skip any
59
+ // placeholder name the literal text already uses. A template with no
60
+ // literal placeholders still starts at p1.
61
+ const reserved = literalPlaceholderNames(data.parts);
62
+ const nextParamName = () => {
63
+ let name = `p${paramIndex++}`;
64
+ while (reserved.has(name))
65
+ name = `p${paramIndex++}`;
66
+ return name;
67
+ };
56
68
  for (const part of data.parts) {
57
69
  if (typeof part === "string") {
58
70
  templateStr += part;
@@ -65,13 +77,26 @@ function serializeTemplate(data) {
65
77
  if (templateStr.length > 0 && templateStr.endsWith("$")) {
66
78
  templateStr += DOLLAR_PLACEHOLDER_ESCAPE;
67
79
  }
68
- const paramName = `p${paramIndex++}`;
80
+ const paramName = nextParamName();
69
81
  templateStr += `{{{${paramName}}}}`;
70
82
  parameters.push({ value: { name: paramName, value: serializeRefData(part) } });
71
83
  }
72
84
  }
73
85
  return { templateReference: { template: templateStr, parameters } };
74
86
  }
87
+ /** `{{{name}}}` occurrences in literal string parts. Those names are not free for generated parameters. */
88
+ function literalPlaceholderNames(parts) {
89
+ const names = new Set();
90
+ for (const part of parts) {
91
+ if (typeof part !== "string")
92
+ continue;
93
+ for (const match of part.matchAll(/\{\{\{(\w+)\}\}\}/g)) {
94
+ if (match[1] !== undefined)
95
+ names.add(match[1]);
96
+ }
97
+ }
98
+ return names;
99
+ }
75
100
  /**
76
101
  * Placeholder marker emitted for variableParam refs.
77
102
  * Resolved to real `{ variableReference: { id, name } }` by
@@ -96,6 +96,10 @@ export interface WorkspaceAspect {
96
96
  readonly automationRefNames?: ReadonlySet<string>;
97
97
  /** Sole on-demand record parameter targeting this same owner, keyed by automation refName, for CURRENT_RECORD widget binding. */
98
98
  readonly onDemandRecordParamByAutomationRefName?: ReadonlyMap<string, string>;
99
+ /** Every on-demand record input, keyed by automation refName; a static runAutomation mapping into one is refused (edk#1868). */
100
+ readonly onDemandRecordInputsByAutomationRefName?: ReadonlyMap<string, ReadonlySet<string>>;
101
+ /** Automations recorded in applied-automation-revisions.json: the platform already has them, so a live shape build refuses for new ones is reported instead. */
102
+ readonly pulledAutomationRefNames?: ReadonlySet<string>;
99
103
  /** Terraform labels of datamines managed by a table in this workspace. */
100
104
  readonly managedDatamineLabels?: ReadonlySet<string>;
101
105
  /** Ref names of own-file children present in this workspace, grouped by kind. */
@@ -11,8 +11,15 @@
11
11
  * the config they mention is built and applied as authored:
12
12
  * - skill input-coverage lint (`skill "x" input coverage gap [input-schema-missing]: …`)
13
13
  * - the unbumped-automation revision reminder
14
+ * - a live runAutomation call into a record input the platform already runs
15
+ * (edk#2250; the mapping is emitted, and the called workflow fails at run time)
16
+ * - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
17
+ * the task is emitted, and the caller never resumes at run time)
14
18
  * - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
15
19
  * emitted exactly as authored, edk#1771)
20
+ * - the executeScript lint for an undeclared input, an output no return sets
21
+ * (edk#2286), or a script with no top-level return (edk#2364); the script is
22
+ * emitted as authored
16
23
  *
17
24
  * The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
18
25
  * Rather than rewrite every site, they are classified here, where they leave
@@ -11,8 +11,15 @@
11
11
  * the config they mention is built and applied as authored:
12
12
  * - skill input-coverage lint (`skill "x" input coverage gap [input-schema-missing]: …`)
13
13
  * - the unbumped-automation revision reminder
14
+ * - a live runAutomation call into a record input the platform already runs
15
+ * (edk#2250; the mapping is emitted, and the called workflow fails at run time)
16
+ * - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
17
+ * the task is emitted, and the caller never resumes at run time)
14
18
  * - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
15
19
  * emitted exactly as authored, edk#1771)
20
+ * - the executeScript lint for an undeclared input, an output no return sets
21
+ * (edk#2286), or a script with no top-level return (edk#2364); the script is
22
+ * emitted as authored
16
23
  *
17
24
  * The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
18
25
  * Rather than rewrite every site, they are classified here, where they leave
@@ -23,6 +30,11 @@ const INPUT_COVERAGE = /^(skill "[^"]*") input coverage gap \[([a-z-]+)\]: /;
23
30
  const ADVISORY_DIAGNOSTICS = [
24
31
  INPUT_COVERAGE,
25
32
  /^automation \S+: compiled steps changed since the last apply but its revision is still /,
33
+ /^automation \S+: maps automation /,
34
+ // edk#1870. The task and loop names are quoted as authored and may contain `"`, so match them with
35
+ // [\s\S]* and anchor on the fixed rest of the message, end included (the label is a sanitized TF label).
36
+ /^automation \S+: task "[\s\S]*" is a synchronous Dynamic Reference runAutomation inside forEach "[\s\S]*"; the platform never resumes the caller after the called automation finishes, so the steps after it never run and the run stays parked\. Move the call out of the forEach, or call a known automation by its catalog ref \(Select Automation\)$/,
37
+ /^automation \S+: executeScript ".*" (?:reads input|declares output|has no top-level return) /,
26
38
  /^applied-automation-revisions\.json .*; until then no automation is checked for an edit without a revision bump$/,
27
39
  /\.root: "[^"]*" is (?:untyped|a [A-Za-z0-9_]+); the root is usually a PanesBlock \(needed for record lists to open the details pane\)$/,
28
40
  ];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A JSON object read as it streams in, for machine-owned OpenTofu output that
3
+ * grows with the org root and outgrows any fixed in-memory capture (edk#1861):
4
+ * a saved plan's `tofu show -json` and the `state pull` snapshot. The reader
5
+ * walks into the containers it is told to and parses everything else under
6
+ * them one value at a time (a resource, a resource change), so no single
7
+ * string is ever the size of the document. Top-level keys outside `keptRootKeys`
8
+ * are skipped without being held. A skipped value is still checked as strict
9
+ * JSON (matched closers, commas, string escapes, and every number or literal),
10
+ * so output that `JSON.parse` would reject is never read.
11
+ */
12
+ export interface JsonStreamReaderOptions {
13
+ /** What the document is, for errors ("the saved plan's JSON"). */
14
+ readonly subject: string;
15
+ /** Top-level keys kept; every key when undefined. Everything else is skipped unparsed. */
16
+ readonly keptRootKeys?: ReadonlySet<string>;
17
+ /**
18
+ * Containers walked into instead of parsed whole. The root is `""`; an
19
+ * element of an array at path `p` has path `p[]`. Anything not listed is
20
+ * parsed as one value.
21
+ */
22
+ readonly walkedPaths: ReadonlySet<string>;
23
+ }
24
+ /** Feed the output chunk by chunk with {@link write}, then call {@link end}. */
25
+ export declare class JsonStreamReader<T extends object = Record<string, unknown>> {
26
+ private readonly options;
27
+ private readonly stack;
28
+ private root;
29
+ private done;
30
+ private capture;
31
+ private offset;
32
+ constructor(options: JsonStreamReaderOptions);
33
+ write(chunk: Buffer): void;
34
+ end(): T;
35
+ /** Handle one non-whitespace byte outside a captured value; true when it starts a capture. */
36
+ private structural;
37
+ private startValue;
38
+ private finishCapture;
39
+ /** Attach a value to the innermost walked container; skipped keys never reach here. */
40
+ private deliver;
41
+ private close;
42
+ private fail;
43
+ }
@@ -0,0 +1,234 @@
1
+ const QUOTE = 0x22;
2
+ const BACKSLASH = 0x5c;
3
+ const COMMA = 0x2c;
4
+ const COLON = 0x3a;
5
+ const OPEN_BRACE = 0x7b;
6
+ const CLOSE_BRACE = 0x7d;
7
+ const OPEN_BRACKET = 0x5b;
8
+ const CLOSE_BRACKET = 0x5d;
9
+ const LOWER_U = 0x75;
10
+ /** Characters allowed after a backslash in a JSON string, other than `u`. */
11
+ const SIMPLE_ESCAPES = new Set([QUOTE, BACKSLASH, 0x2f, 0x62, 0x66, 0x6e, 0x72, 0x74]);
12
+ function isHexDigit(byte) {
13
+ return (byte >= 0x30 && byte <= 0x39) || (byte >= 0x41 && byte <= 0x46) || (byte >= 0x61 && byte <= 0x66);
14
+ }
15
+ function isWhitespace(byte) {
16
+ return byte === 0x20 || byte === 0x09 || byte === 0x0a || byte === 0x0d;
17
+ }
18
+ /** Feed the output chunk by chunk with {@link write}, then call {@link end}. */
19
+ export class JsonStreamReader {
20
+ options;
21
+ stack = [];
22
+ root;
23
+ done = false;
24
+ capture;
25
+ offset = 0;
26
+ constructor(options) {
27
+ this.options = options;
28
+ }
29
+ write(chunk) {
30
+ let start = 0;
31
+ let i = 0;
32
+ while (i < chunk.length) {
33
+ const byte = chunk[i];
34
+ const capture = this.capture;
35
+ if (capture !== undefined) {
36
+ if (capture.scalar) {
37
+ if (byte === COMMA || byte === CLOSE_BRACE || byte === CLOSE_BRACKET || isWhitespace(byte)) {
38
+ this.finishCapture(capture, chunk.subarray(start, i));
39
+ continue; // the delimiter belongs to the enclosing container
40
+ }
41
+ }
42
+ else if (capture.inString) {
43
+ if (capture.hex > 0) {
44
+ if (!isHexDigit(byte))
45
+ this.fail("has a bad \\u escape in a string", i);
46
+ capture.hex--;
47
+ }
48
+ else if (capture.escape) {
49
+ capture.escape = false;
50
+ if (byte === LOWER_U)
51
+ capture.hex = 4;
52
+ else if (!SIMPLE_ESCAPES.has(byte))
53
+ this.fail("has a bad escape in a string", i);
54
+ }
55
+ else if (byte === BACKSLASH)
56
+ capture.escape = true;
57
+ else if (byte === QUOTE) {
58
+ capture.inString = false;
59
+ if (capture.depth === 0) {
60
+ this.finishCapture(capture, chunk.subarray(start, i + 1));
61
+ i++;
62
+ continue;
63
+ }
64
+ }
65
+ else if (byte < 0x20)
66
+ this.fail("has a control character in a string", i);
67
+ }
68
+ else if (byte === QUOTE)
69
+ capture.inString = true;
70
+ else if (byte === OPEN_BRACE || byte === OPEN_BRACKET)
71
+ capture.depth++;
72
+ else if (byte === CLOSE_BRACE || byte === CLOSE_BRACKET) {
73
+ capture.depth--;
74
+ if (capture.depth === 0) {
75
+ this.finishCapture(capture, chunk.subarray(start, i + 1));
76
+ i++;
77
+ continue;
78
+ }
79
+ }
80
+ i++;
81
+ continue;
82
+ }
83
+ if (isWhitespace(byte)) {
84
+ i++;
85
+ continue;
86
+ }
87
+ const startsCapture = this.structural(byte, i);
88
+ if (startsCapture)
89
+ start = i;
90
+ i++;
91
+ }
92
+ if (this.capture?.hold === true)
93
+ this.capture.parts.push(Buffer.from(chunk.subarray(start)));
94
+ this.offset += chunk.length;
95
+ }
96
+ end() {
97
+ if (!this.done || this.root === undefined || this.capture !== undefined)
98
+ this.fail("ends before the top-level object closes");
99
+ return this.root;
100
+ }
101
+ /** Handle one non-whitespace byte outside a captured value; true when it starts a capture. */
102
+ structural(byte, index) {
103
+ const frame = this.stack.at(-1);
104
+ if (frame === undefined) {
105
+ if (this.done || byte !== OPEN_BRACE)
106
+ this.fail(this.done ? "has data after the top-level object" : "is not a JSON object", index);
107
+ this.root = {};
108
+ this.stack.push({ kind: "object", keep: true, path: "", value: this.root, key: "", state: "keyOrEnd" });
109
+ return false;
110
+ }
111
+ if (frame.kind === "object") {
112
+ switch (frame.state) {
113
+ case "keyOrEnd":
114
+ case "key":
115
+ if (byte === CLOSE_BRACE && frame.state === "keyOrEnd") {
116
+ this.close();
117
+ return false;
118
+ }
119
+ if (byte !== QUOTE)
120
+ this.fail("expected an object key", index);
121
+ this.capture = { keep: true, hold: true, isKey: true, scalar: false, parts: [], depth: 0, inString: true, escape: false, hex: 0 };
122
+ return true;
123
+ case "colon":
124
+ if (byte !== COLON)
125
+ this.fail("expected ':'", index);
126
+ frame.state = "value";
127
+ return false;
128
+ case "value": {
129
+ const childPath = frame.path === "" ? frame.key : `${frame.path}.${frame.key}`;
130
+ frame.state = "commaOrEnd";
131
+ const keptRootKeys = this.options.keptRootKeys;
132
+ return this.startValue(byte, index, childPath, frame.keep && (frame.path !== "" || keptRootKeys === undefined || keptRootKeys.has(frame.key)));
133
+ }
134
+ case "commaOrEnd":
135
+ if (byte === COMMA)
136
+ frame.state = "key";
137
+ else if (byte === CLOSE_BRACE)
138
+ this.close();
139
+ else
140
+ this.fail("expected ',' or '}'", index);
141
+ return false;
142
+ }
143
+ }
144
+ switch (frame.state) {
145
+ case "valueOrEnd":
146
+ case "value":
147
+ if (byte === CLOSE_BRACKET && frame.state === "valueOrEnd") {
148
+ this.close();
149
+ return false;
150
+ }
151
+ frame.state = "commaOrEnd";
152
+ return this.startValue(byte, index, `${frame.path}[]`, frame.keep);
153
+ case "commaOrEnd":
154
+ if (byte === COMMA)
155
+ frame.state = "value";
156
+ else if (byte === CLOSE_BRACKET)
157
+ this.close();
158
+ else
159
+ this.fail("expected ',' or ']'", index);
160
+ return false;
161
+ }
162
+ }
163
+ startValue(byte, index, path, keep) {
164
+ if (byte === COMMA || byte === COLON || byte === CLOSE_BRACE || byte === CLOSE_BRACKET)
165
+ this.fail("expected a value", index);
166
+ const container = byte === OPEN_BRACE || byte === OPEN_BRACKET;
167
+ // A walked container is kept piece by piece; a skipped one is walked the
168
+ // same way, so its structure is checked without holding any of it.
169
+ if (container && (keep ? this.options.walkedPaths.has(path) : true)) {
170
+ const frame = byte === OPEN_BRACE
171
+ ? { kind: "object", keep, path, value: {}, key: "", state: "keyOrEnd" }
172
+ : { kind: "array", keep, path, value: [], state: "valueOrEnd" };
173
+ if (keep)
174
+ this.deliver(frame.value);
175
+ this.stack.push(frame);
176
+ return false;
177
+ }
178
+ const scalar = !container && byte !== QUOTE;
179
+ this.capture = {
180
+ keep,
181
+ hold: keep || scalar,
182
+ isKey: false,
183
+ scalar,
184
+ parts: [],
185
+ depth: container ? 1 : 0,
186
+ inString: byte === QUOTE,
187
+ escape: false,
188
+ hex: 0,
189
+ };
190
+ return true;
191
+ }
192
+ finishCapture(capture, tail) {
193
+ this.capture = undefined;
194
+ if (!capture.hold)
195
+ return; // a skipped string, already checked as it streamed
196
+ const text = (capture.parts.length === 0 ? tail : Buffer.concat([...capture.parts, tail])).toString("utf8");
197
+ let value;
198
+ try {
199
+ // eslint-disable-next-line no-restricted-syntax -- one value of machine-owned OpenTofu output, not an entity.
200
+ value = JSON.parse(text);
201
+ }
202
+ catch (error) {
203
+ this.fail(`has an unreadable value (${error.message})`);
204
+ }
205
+ if (!capture.keep)
206
+ return;
207
+ const frame = this.stack.at(-1);
208
+ if (capture.isKey) {
209
+ if (frame.kind !== "object" || typeof value !== "string")
210
+ this.fail("has a non-string object key");
211
+ frame.key = value;
212
+ frame.state = "colon";
213
+ return;
214
+ }
215
+ this.deliver(value);
216
+ }
217
+ /** Attach a value to the innermost walked container; skipped keys never reach here. */
218
+ deliver(value) {
219
+ const frame = this.stack.at(-1);
220
+ if (frame.kind === "array")
221
+ frame.value.push(value);
222
+ else
223
+ Object.defineProperty(frame.value, frame.key, { value, enumerable: true, writable: true, configurable: true });
224
+ }
225
+ close() {
226
+ this.stack.pop();
227
+ if (this.stack.length === 0)
228
+ this.done = true;
229
+ }
230
+ fail(problem, index) {
231
+ const at = index === undefined ? "" : ` at byte ${this.offset + index}`;
232
+ throw new Error(`${this.options.subject} ${problem}${at}`);
233
+ }
234
+ }
@@ -18,6 +18,7 @@
18
18
  * ei owns auth (`ei auth login`) — Elementum sets no credentials and never talks
19
19
  * to the platform itself.
20
20
  */
21
+ import { type SavedPlan } from "./saved-plan.js";
21
22
  import { type PartialReadEvent, type ProgressEvent } from "../logging.js";
22
23
  export declare class EiRunError extends Error {
23
24
  readonly exitCode: number | null;
@@ -118,6 +119,22 @@ export declare function runOpenTofuCapture(args: readonly string[], opts?: {
118
119
  suppressStderr?: boolean;
119
120
  binary?: string;
120
121
  }): Promise<string>;
122
+ /**
123
+ * `tofu show -json <planPath>` for an EDK check of a saved plan (edk#2057),
124
+ * read as it streams so a plan of any size fits (edk#1861): only
125
+ * `resource_changes` and `prior_state` are kept ({@link SavedPlanReader}).
126
+ * The capture keeps OpenTofu's stderr off the terminal, so a failure would
127
+ * otherwise reach the user as a bare exit code. Reject with the EDK step
128
+ * that read the plan and OpenTofu's own `Error:` diagnostics (or, when it
129
+ * printed none, the tail of its stderr) instead. Output that is not one
130
+ * complete JSON object rejects too. Callers still stop: a plan that cannot
131
+ * be read back is never applied unchecked.
132
+ */
133
+ export declare function readSavedPlan(planPath: string, opts: {
134
+ readonly cwd: string;
135
+ readonly step: string;
136
+ readonly binary?: string;
137
+ }): Promise<SavedPlan>;
121
138
  /**
122
139
  * Run `ei` capturing stdout (the machine-consumed stream); stderr is routed by
123
140
  * EDK to the diagnostics sink. Non-zero exit rejects — partial output must be
@@ -127,6 +144,10 @@ export declare function runOpenTofuCapture(args: readonly string[], opts?: {
127
144
  * captured commands whose output is also the user's only progress signal
128
145
  * (adoption's `ei plan`). It never moves anything onto our stdout, so the
129
146
  * caller's single-JSON-summary contract holds.
147
+ *
148
+ * `onStdout` hands stdout to the caller chunk by chunk instead of buffering
149
+ * it, with no size cap (edk#2248), and the promise resolves to "". When it
150
+ * throws, `ei` is stopped and the promise rejects with that error.
130
151
  */
131
152
  export declare function runEiCapture(args: readonly string[], opts?: {
132
153
  cwd?: string;
@@ -136,6 +157,7 @@ export declare function runEiCapture(args: readonly string[], opts?: {
136
157
  tofuJsonProgress?: {
137
158
  readonly expectedAddresses: ReadonlySet<string>;
138
159
  };
160
+ onStdout?: (chunk: Buffer) => void;
139
161
  }): Promise<string>;
140
162
  export type TofuJsonEvent = {
141
163
  readonly type: "refresh_start" | "refresh_complete";
@@ -144,10 +166,27 @@ export type TofuJsonEvent = {
144
166
  } | {
145
167
  readonly type: "diagnostic";
146
168
  readonly level: "INFO" | "WARN" | "ERROR";
169
+ /** `summary: detail`, as logged. */
147
170
  readonly message: string;
171
+ readonly summary: string;
172
+ readonly detail?: string;
173
+ /** Where OpenTofu says the error is (`range` and `address`), when it says. */
174
+ readonly location?: TofuDiagnosticLocation;
148
175
  } | {
149
176
  readonly type: "other";
150
177
  };
178
+ /**
179
+ * Where an OpenTofu diagnostic points: the file and line from its location
180
+ * line or JSON `range`, and the resource address from its `with` line or JSON
181
+ * `address` (edk#2295). Names only; never a snippet or a value.
182
+ */
183
+ export interface TofuDiagnosticLocation {
184
+ readonly file?: string;
185
+ readonly line?: number;
186
+ readonly address?: string;
187
+ }
188
+ /** `automations.tf line 27, elementum_x.y`: the location as one parenthetical. */
189
+ export declare function formatTofuDiagnosticLocation(location: TofuDiagnosticLocation): string;
151
190
  /** Parse the stable subset of OpenTofu's line-delimited JSON UI used by adoption. */
152
191
  export declare function parseTofuJsonEvent(line: string): TofuJsonEvent;
153
192
  /** Capture both bridge output streams for small machine-inspection commands. */
@@ -164,6 +203,8 @@ export declare function capTofuDiagnostics(diagnostics: readonly string[], max?:
164
203
  * Error diagnostics from a failed OpenTofu run: `diagnostic` events with
165
204
  * severity error from `-json` stdout, plus human `Error:` blocks from stderr.
166
205
  * Deduplicated, in order. Used to explain why `ei plan` failed instead of
167
- * discarding its output (edk#1402).
206
+ * discarding its output (edk#1402). Each names the file, line and resource
207
+ * address OpenTofu reported, right after the summary (edk#2295):
208
+ * `Invalid index (automations.tf line 27, elementum_x.y): The given key …`.
168
209
  */
169
210
  export declare function tofuErrorDiagnostics(stdout: string | undefined, stderr: string | undefined): string[];