@elementumai/edk 0.9.11 → 0.9.13

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 (90) hide show
  1. package/README.md +39 -5
  2. package/dist-sdk/src/catalog/factories.d.ts +35 -14
  3. package/dist-sdk/src/catalog/factories.js +64 -13
  4. package/dist-sdk/src/catalog/from-authoring.js +4 -4
  5. package/dist-sdk/src/catalog/index.d.ts +1 -1
  6. package/dist-sdk/src/catalog/org.js +3 -2
  7. package/dist-sdk/src/catalog/token.js +4 -0
  8. package/dist-sdk/src/catalog/types.d.ts +13 -3
  9. package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
  10. package/dist-sdk/src/core/triggers/on-demand.js +2 -4
  11. package/dist-sdk/src/engine/entity.d.ts +2 -0
  12. package/dist-sdk/src/engine/logging.d.ts +90 -0
  13. package/dist-sdk/src/engine/logging.js +124 -0
  14. package/dist-sdk/src/engine/progress.d.ts +122 -0
  15. package/dist-sdk/src/engine/progress.js +685 -0
  16. package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
  17. package/dist-sdk/src/engine/pull/result-output.js +59 -0
  18. package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
  19. package/dist-sdk/src/entities/app/build.d.ts +8 -1
  20. package/dist-sdk/src/entities/app/from-tf.js +4 -4
  21. package/dist-sdk/src/entities/app/to-tf.js +9 -13
  22. package/dist-sdk/src/entities/automation/build.d.ts +11 -16
  23. package/dist-sdk/src/entities/automation/build.js +60 -16
  24. package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
  25. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
  26. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
  27. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +247 -35
  28. package/dist-sdk/src/entities/automation/from-tf.js +181 -24
  29. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  30. package/dist-sdk/src/entities/automation/module.js +2 -2
  31. package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
  32. package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
  33. package/dist-sdk/src/entities/automation/script-code.js +659 -101
  34. package/dist-sdk/src/entities/automation/task-label.js +25 -2
  35. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
  36. package/dist-sdk/src/entities/automation/tasks.js +31 -15
  37. package/dist-sdk/src/entities/automation/to-tf.js +443 -64
  38. package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
  39. package/dist-sdk/src/entities/automation/triggers.js +4 -2
  40. package/dist-sdk/src/entities/chart/build.d.ts +15 -3
  41. package/dist-sdk/src/entities/chart/build.js +6 -1
  42. package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
  43. package/dist-sdk/src/entities/chart/from-tf.js +71 -8
  44. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/chart/index.js +1 -1
  46. package/dist-sdk/src/entities/chart/printer.js +27 -7
  47. package/dist-sdk/src/entities/chart/to-tf.js +56 -2
  48. package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
  49. package/dist-sdk/src/entities/element/build.d.ts +6 -5
  50. package/dist-sdk/src/entities/element/from-tf.js +3 -2
  51. package/dist-sdk/src/entities/element/module.js +1 -0
  52. package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
  53. package/dist-sdk/src/entities/element/to-tf.js +9 -1
  54. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  55. package/dist-sdk/src/entities/field/from-tf.js +73 -1
  56. package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
  57. package/dist-sdk/src/entities/field/metadata.js +34 -0
  58. package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
  59. package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
  60. package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
  61. package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
  62. package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
  63. package/dist-sdk/src/entities/shared/context.d.ts +6 -3
  64. package/dist-sdk/src/entities/shared/context.js +19 -1
  65. package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
  66. package/dist-sdk/src/entities/shared/filters/index.js +36 -1
  67. package/dist-sdk/src/entities/shared/filters/print.js +2 -0
  68. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
  69. package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
  70. package/dist-sdk/src/entities/shared/filters/types.d.ts +2 -1
  71. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
  72. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
  73. package/dist-sdk/src/entities/skill/module.js +1 -0
  74. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  75. package/dist-sdk/src/entities/skill/to-tf.js +17 -0
  76. package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
  77. package/dist-sdk/src/entities/skill/tools.js +2 -1
  78. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
  79. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
  80. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
  81. package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
  82. package/dist-sdk/src/entities/table/build.js +10 -2
  83. package/dist-sdk/src/entities/view/to-tf.js +5 -7
  84. package/dist-sdk/src/entities/widget/build.d.ts +26 -0
  85. package/dist-sdk/src/entities/widget/from-tf.js +30 -5
  86. package/dist-sdk/src/entities/widget/to-tf.js +111 -7
  87. package/dist-sdk/src/graph/types.d.ts +5 -0
  88. package/package.json +1 -1
  89. package/dist-sdk/src/core/types/platform.d.ts +0 -2
  90. package/dist-sdk/src/core/types/platform.js +0 -1
package/README.md CHANGED
@@ -146,8 +146,38 @@ Terraform state. Adoption is gated to exactly the expected imports, zero
146
146
  create/update/destroy operations, and a clean follow-up plan. Use `--no-adopt`
147
147
  only when you deliberately want source without state adoption.
148
148
 
149
- Pull commands reserve stdout for one JSON summary. Diagnostics and stream kinds
150
- that do not yet have an extractor are reported rather than silently discarded.
149
+ Interactive pull commands finish with a concise stdout summary of what was
150
+ written and where. When stdout is piped or redirected, that summary remains one
151
+ machine-readable JSON object. Diagnostics and stream kinds that do not yet have
152
+ an extractor are reported rather than silently discarded.
153
+
154
+ ### Output and live feedback contract
155
+
156
+ Pull, plan, and adoption commands use one terminal-aware live status renderer.
157
+ The live spinner or progress bar is shown only on a TTY, is kept immediately
158
+ below durable output, and yields to messages arriving from `ei`, OpenTofu, or
159
+ the provider. It is removed cleanly when the operation ends or is interrupted;
160
+ `CTRL+C` restores the cursor.
161
+
162
+ Technical output is separated from user-facing output:
163
+
164
+ - stderr contains only newline-delimited JSON technical events when the EDK
165
+ bridge is active (logs, progress lifecycle, and protocol fallbacks);
166
+ - stdout contains user-facing messages and command results;
167
+ - `--json` enables machine-readable technical logging and disables live
168
+ progress, while keeping command result data on stdout;
169
+ - `--bridge` is an instruction to `ei` to use the EDK communication protocol,
170
+ not a log-format switch. Standalone `ei` output remains human-readable.
171
+
172
+ The bridge carries progress sections (`progress_enter`, `progress_update`, and
173
+ `progress_leave`) as well as structured logs. Text effects are sent as ordered
174
+ ranges and are rendered only for TTY output. ANSI styles from provider output
175
+ are converted into the same structured representation where possible.
176
+ OpenTofu lifecycle lines are logged as `tofu`, provider `tflog` lines as
177
+ `provider`, and malformed or unexpected child output is retained as a
178
+ structured fallback event instead of leaking raw text onto the technical
179
+ channel. Update failures are ordinary user messages; in JSON mode they are
180
+ included in the result object.
151
181
 
152
182
  ## CLI commands
153
183
 
@@ -155,7 +185,7 @@ The TypeScript-owned command surface is:
155
185
 
156
186
  ```sh
157
187
  elementum init [--check] [--json]
158
- elementum update [--check | --dry-run] [--channel stable|preview] [--version <semver>]
188
+ elementum update [--check | --dry-run] [--channel stable|preview] [--version <semver>] [--json]
159
189
  elementum migrate backend [orgRoot] [--check | --dry-run | --auto-approve] [--reconfigure]
160
190
  elementum migrate provider-source [orgRoot] [--check | --dry-run | --auto-approve]
161
191
 
@@ -165,8 +195,8 @@ elementum pull app <namespace> [--root <orgRoot>] [--no-adopt]
165
195
  elementum pull element <namespace> [--root <orgRoot>] [--no-adopt]
166
196
  elementum clone app <namespace> --as <newName> [--namespace <newns>] [--root <orgRoot>]
167
197
  elementum build [orgRoot]
168
- elementum plan [orgRoot-or-nested-target] [bridge args...]
169
- elementum apply [orgRoot-or-nested-target] [bridge args...]
198
+ elementum plan [orgRoot-or-nested-target] [--json] [bridge args...]
199
+ elementum apply [orgRoot-or-nested-target] [--json] [bridge args...]
170
200
 
171
201
  elementum list apps|elements|users|groups|categories|cloud-links
172
202
  elementum list ai-provider-connectors|automations|tables
@@ -427,6 +457,10 @@ stdio. With no explicit profile, the CLI selects the unique saved profile
427
457
  matching the org root's `<instance>/<organization>` path. Review destroy and
428
458
  replacement actions just as you would in any Terraform plan.
429
459
 
460
+ Use `--json` for automation and log ingestion. It disables the interactive
461
+ spinner/progress renderer and emits technical diagnostics as one JSON object per
462
+ line on stderr; do not parse human-facing stdout as a log stream.
463
+
430
464
  ## Identity and state recovery
431
465
 
432
466
  Terraform state is the durable binding between authored labels and live
@@ -2,8 +2,8 @@
2
2
  * Typed factory functions for every catalog ref kind.
3
3
  *
4
4
  * Each function accepts all fields except `__kind` and `handle`, so generated
5
- * and authored code never contains a raw `__kind` string literal — and, for
6
- * every kind here, never an identity property either. `resolveRef`
5
+ * and authored code never contains a raw `__kind` string literal. Inside catalog
6
+ * bags, authored calls need no identity properties either. `resolveRef`
7
7
  * (`src/deploy/resolve/resolve.ts`) and `resolvePayload` read `.handle`
8
8
  * directly off an embedded ref with no other context available once it's been
9
9
  * destructured out of its parent bag, so that property has to keep existing
@@ -11,15 +11,17 @@
11
11
  * constructed as a bag entry (`agents: { agent11: agentRef() }`), and the
12
12
  * bag's own object-literal key *is* the ref name. `appCatalog`/`elementCatalog`/
13
13
  * `orgCatalog` read that key, stamp it onto `.handle`, and also inject `parent`
14
- * from the catalog root's own identity — so no factory call for automations or
15
- * agents needs to restate either property.
14
+ * from the catalog root's own identity — so catalog-embedded factory calls for
15
+ * automations or agents need not restate either property. Standalone
16
+ * {@link automationRef} / {@link widgetRef} calls consumed directly (e.g. a
17
+ * `runAutomation` widget) should pass `refName` and `parent`.
16
18
  *
17
19
  * Each factory still sets `.handle`/`.name` to something internally purely so
18
20
  * the object satisfies `CatalogRef`'s structural shape before bag-level stamping;
19
21
  * nothing reads those interim values.
20
22
  */
21
23
  import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.js";
22
- import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AppOrElementRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, WidgetRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, RecordIdentityRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableRef, TriggerParameterRef } from "./types.js";
24
+ import type { AgentEvaluationRef, AgentRef, AppCatalogRef, AppOrElementRef, AiProviderRef, ApprovalChainRef, AutomationCatalogRef, CatalogRef, CategoryRef, ChartRef, DashboardRef, WidgetRef, CloudLinkRef, ConnectorRef, DatamineRef, GroupRef, PhoneProviderRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, FileReaderCatalogRef, DocumentModelFieldRef, ElementCatalogRef, FieldRef, OutputPropertyRef, RecordIdentityRef, SearchTableRef, StoredFunctionRef, StoredFunctionScalarType, SkillRef, TableColumnRef, TableOwnedSearchTableRef, TableRef, TriggerParameterRef } from "./types.js";
23
25
  export declare function recordIdentity<const Target extends AppOrElementRef | TableRef>(target: Target): RecordIdentityRef<Target>;
24
26
  /** Fixed platform user-directory schema used by userSearch filters. */
25
27
  export declare const usersCatalog: {
@@ -89,20 +91,32 @@ type WithOwnedCharts<B extends AppCatalogBags, Parent extends string> = B extend
89
91
  } : B;
90
92
  type WithOwnedCatalogChildren<B extends AppCatalogBags, Parent extends string> = WithOwnedCharts<WithOwnedAgents<B, Parent>, Parent>;
91
93
  /**
92
- * Automation ref. Accepts optional `trigger` and `outputs` bags of typed parameter/property refs —
93
- * e.g. `automationRef({ trigger: { topic: triggerParameterRef({ name: "topic", parent: "auto" }) } })`
94
- * gives `catalog.app.automations.auto.trigger.topic` as a typed `TriggerParameterRef` usable in
95
- * `executeWorkflow` inputs. `handle` and `parent` are injected by the enclosing `appCatalog`/
96
- * `elementCatalog`; factory calls need not supply them.
94
+ * Automation ref — same identity knobs as {@link widgetRef}: optional `refName`
95
+ * and `parent`, plus optional `trigger`/`outputs` bags of typed parameter/
96
+ * property refs.
97
+ *
98
+ * Standalone use (a `runAutomation` widget or task outside a generated
99
+ * catalog) must pass `refName` (the automation file's bag key) and `parent`
100
+ * (the owning app/element refName). Empty `refName` is dropped at build.
101
+ *
102
+ * Inside `appCatalog`/`elementCatalog`, the bag key and catalog identity
103
+ * overwrite `refName`/`parent` after the factory returns — those call sites
104
+ * can keep passing only `name`/`trigger`/`outputs`. Prefer
105
+ * `catalog.<app>.automations.<refName>` or `app().withRefs((self) =>
106
+ * self.automation(refName, name))` when that owner file is in scope.
107
+ * Elements have no `withRefs` helper yet.
97
108
  *
98
109
  * Generic parameters `T`/`O` preserve specific key shapes on the returned ref so TypeScript can
99
- * narrow `.trigger.<name>` and `.outputs.<name>` at the call site.
110
+ * narrow `.trigger.<name>` and `.outputs.<name>` at the call site. `Parent`/
111
+ * `RefName` match {@link widgetRef}.
100
112
  */
101
- export declare function automationRef<T extends Readonly<Record<string, TriggerParameterRef>> | undefined = undefined, O extends Readonly<Record<string, OutputPropertyRef>> | undefined = undefined>(opts?: {
113
+ export declare function automationRef<T extends Readonly<Record<string, TriggerParameterRef>> | undefined = undefined, O extends Readonly<Record<string, OutputPropertyRef>> | undefined = undefined, const Parent extends string = string, const RefName extends string = string>(opts?: {
114
+ readonly refName?: RefName;
102
115
  readonly name?: string;
116
+ readonly parent?: Parent;
103
117
  readonly trigger?: T;
104
118
  readonly outputs?: O;
105
- }): AutomationCatalogRef & {
119
+ }): AutomationCatalogRef<Parent, RefName> & {
106
120
  readonly trigger: T;
107
121
  readonly outputs: O;
108
122
  };
@@ -148,6 +162,7 @@ export declare const outputPropertyRef: <const T extends {
148
162
  readonly name: string;
149
163
  readonly parent: string;
150
164
  readonly valueType?: string;
165
+ readonly multiple?: boolean;
151
166
  }>(opts: T) => T & {
152
167
  readonly __kind: "outputProperty";
153
168
  readonly refName: string;
@@ -192,10 +207,16 @@ export declare function phoneServiceRef(opts?: {
192
207
  readonly name?: string;
193
208
  readonly parent?: string;
194
209
  }): PhoneServiceRef;
210
+ /**
211
+ * Datamine reference factory.
212
+ * `columnNames` is populated automatically by `tableRef`, `stampTableRefs`, and `table().ref()`
213
+ * from the parent table's columns, but explicit overrides may be provided.
214
+ */
195
215
  export declare function datamineRef(opts?: {
196
216
  readonly name?: string;
197
217
  readonly parent?: string;
198
218
  readonly parentName?: string;
219
+ readonly columnNames?: Readonly<Record<string, string>>;
199
220
  }): DatamineRef;
200
221
  export declare const approvalChainRef: (opts: Omit<ApprovalChainRef<string, string>, "parent" | "refName" | "__kind">) => Omit<ApprovalChainRef<string, string>, "parent" | "refName" | "__kind"> & {
201
222
  readonly __kind: "approvalChain";
@@ -206,7 +227,7 @@ export declare function searchTableRef(opts: Omit<SearchTableRef, "__kind" | "re
206
227
  /** Reference to an existing linked Cortex Search Service. */
207
228
  export declare function linkedSearchTableRef(opts: Omit<SearchTableRef, "__kind" | "refName" | "parent">): SearchTableRef;
208
229
  /** Reference to a managed search table owned by an Elementum Table. */
209
- export declare function tableSearchTableRef(opts: Omit<SearchTableRef, "__kind" | "refName" | "parent">): SearchTableRef;
230
+ export declare function tableSearchTableRef(opts: Omit<SearchTableRef, "__kind" | "refName">): TableOwnedSearchTableRef;
210
231
  export declare const connectorRef: (opts: Omit<import("./types.js").AiServiceRef, "refName" | "__kind">) => Omit<import("./types.js").AiServiceRef, "refName" | "__kind"> & {
211
232
  readonly __kind: "connector";
212
233
  readonly refName: string;
@@ -23,20 +23,31 @@ function refFactory(kind) {
23
23
  return (opts) => ({ __kind: kind, refName: opts.name, ...opts });
24
24
  }
25
25
  /**
26
- * Automation ref. Accepts optional `trigger` and `outputs` bags of typed parameter/property refs —
27
- * e.g. `automationRef({ trigger: { topic: triggerParameterRef({ name: "topic", parent: "auto" }) } })`
28
- * gives `catalog.app.automations.auto.trigger.topic` as a typed `TriggerParameterRef` usable in
29
- * `executeWorkflow` inputs. `handle` and `parent` are injected by the enclosing `appCatalog`/
30
- * `elementCatalog`; factory calls need not supply them.
26
+ * Automation ref — same identity knobs as {@link widgetRef}: optional `refName`
27
+ * and `parent`, plus optional `trigger`/`outputs` bags of typed parameter/
28
+ * property refs.
29
+ *
30
+ * Standalone use (a `runAutomation` widget or task outside a generated
31
+ * catalog) must pass `refName` (the automation file's bag key) and `parent`
32
+ * (the owning app/element refName). Empty `refName` is dropped at build.
33
+ *
34
+ * Inside `appCatalog`/`elementCatalog`, the bag key and catalog identity
35
+ * overwrite `refName`/`parent` after the factory returns — those call sites
36
+ * can keep passing only `name`/`trigger`/`outputs`. Prefer
37
+ * `catalog.<app>.automations.<refName>` or `app().withRefs((self) =>
38
+ * self.automation(refName, name))` when that owner file is in scope.
39
+ * Elements have no `withRefs` helper yet.
31
40
  *
32
41
  * Generic parameters `T`/`O` preserve specific key shapes on the returned ref so TypeScript can
33
- * narrow `.trigger.<name>` and `.outputs.<name>` at the call site.
42
+ * narrow `.trigger.<name>` and `.outputs.<name>` at the call site. `Parent`/
43
+ * `RefName` match {@link widgetRef}.
34
44
  */
35
45
  export function automationRef(opts) {
36
46
  return {
37
47
  __kind: "automation",
38
- refName: "",
48
+ refName: opts?.refName ?? "",
39
49
  name: opts?.name ?? "",
50
+ ...(opts?.parent !== undefined ? { parent: opts.parent } : {}),
40
51
  ...(opts?.trigger !== undefined ? { trigger: opts.trigger } : {}),
41
52
  ...(opts?.outputs !== undefined ? { outputs: opts.outputs } : {}),
42
53
  };
@@ -109,6 +120,11 @@ export function skillRef(opts) {
109
120
  export function phoneServiceRef(opts) {
110
121
  return { __kind: "phone-service", refName: "", name: opts?.name ?? "", ...(opts?.parent !== undefined ? { parent: opts.parent } : {}) };
111
122
  }
123
+ /**
124
+ * Datamine reference factory.
125
+ * `columnNames` is populated automatically by `tableRef`, `stampTableRefs`, and `table().ref()`
126
+ * from the parent table's columns, but explicit overrides may be provided.
127
+ */
112
128
  export function datamineRef(opts) {
113
129
  return {
114
130
  __kind: "datamine",
@@ -116,6 +132,7 @@ export function datamineRef(opts) {
116
132
  name: opts?.name ?? "",
117
133
  ...(opts?.parent !== undefined ? { parent: opts.parent } : {}),
118
134
  ...(opts?.parentName !== undefined ? { parentName: opts.parentName } : {}),
135
+ ...(opts?.columnNames !== undefined ? { columnNames: opts.columnNames } : {}),
119
136
  };
120
137
  }
121
138
  export const approvalChainRef = refFactory("approvalChain");
@@ -226,12 +243,26 @@ export function tableRef(opts) {
226
243
  refName,
227
244
  { ...column, refName, parent: opts.refName ?? opts.name, parentName: opts.name },
228
245
  ]));
246
+ const derivedColumnNames = opts.columns === undefined
247
+ ? undefined
248
+ : Object.fromEntries(Object.entries(opts.columns).map(([colKey, col]) => [colKey, col.name ?? colKey]));
229
249
  const datamines = opts.datamines === undefined
230
250
  ? undefined
231
- : Object.fromEntries(Object.entries(opts.datamines).map(([refName, datamine]) => [
232
- refName,
233
- { ...datamine, refName, parent: opts.refName ?? opts.name },
234
- ]));
251
+ : Object.fromEntries(Object.entries(opts.datamines).map(([refName, datamine]) => {
252
+ const mergedColumnNames = derivedColumnNames === undefined && datamine.columnNames === undefined
253
+ ? undefined
254
+ : { ...derivedColumnNames, ...datamine.columnNames };
255
+ return [
256
+ refName,
257
+ {
258
+ ...datamine,
259
+ refName,
260
+ parent: opts.refName ?? opts.name,
261
+ parentName: opts.name,
262
+ ...(mergedColumnNames !== undefined ? { columnNames: mergedColumnNames } : {}),
263
+ },
264
+ ];
265
+ }));
235
266
  return {
236
267
  __kind: "table",
237
268
  refName,
@@ -326,9 +357,29 @@ function stampTableRefs(bag) {
326
357
  ? undefined
327
358
  : Object.fromEntries(Object.entries(ref.columns).map(([columnRefName, column]) => [
328
359
  columnRefName,
329
- { ...column, refName: columnRefName, parent: tableRefName },
360
+ { ...column, refName: columnRefName, parent: tableRefName, ...(ref.name !== undefined ? { parentName: ref.name } : {}) },
330
361
  ]));
331
- const datamines = withOwnKeyAsHandle(ref.datamines, tableRefName);
362
+ const parentName = ref.name;
363
+ const derivedColumnNames = ref.columns === undefined
364
+ ? undefined
365
+ : Object.fromEntries(Object.entries(ref.columns).map(([colKey, col]) => [colKey, col.name ?? colKey]));
366
+ const datamines = ref.datamines === undefined
367
+ ? undefined
368
+ : Object.fromEntries(Object.entries(ref.datamines).map(([datamineRefName, datamine]) => {
369
+ const mergedColumnNames = derivedColumnNames === undefined && datamine.columnNames === undefined
370
+ ? undefined
371
+ : { ...derivedColumnNames, ...datamine.columnNames };
372
+ return [
373
+ datamineRefName,
374
+ {
375
+ ...datamine,
376
+ refName: datamineRefName,
377
+ parent: tableRefName,
378
+ ...(parentName !== undefined ? { parentName } : {}),
379
+ ...(mergedColumnNames !== undefined ? { columnNames: mergedColumnNames } : {}),
380
+ },
381
+ ];
382
+ }));
332
383
  out[tableRefName] = {
333
384
  ...ref,
334
385
  refName: tableRefName,
@@ -22,6 +22,7 @@
22
22
  import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
23
23
  import { basename, dirname, join, resolve } from "node:path";
24
24
  import { createWorkspaceLoader } from "../engine/workspace/loader.js";
25
+ import { writeTechnicalLog } from "../engine/progress.js";
25
26
  import { KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
26
27
  import { writeCatalogBarrel } from "./org.js";
27
28
  import { renderCatalog } from "./render.js";
@@ -207,10 +208,9 @@ async function loadCatalogChildBag(appDir, child, parent, catalogPath, defsOut)
207
208
  }
208
209
  catch (err) {
209
210
  const message = err instanceof Error ? err.message : String(err);
210
- console.error(`[edk] warning: could not load catalog child ${file}; ` +
211
- `using typed stub ${parent}.${refName}: ${message}`);
211
+ writeTechnicalLog("WARN", "edk", `could not load catalog child ${file}; using typed stub ${parent}.${refName}: ${message}`);
212
212
  if (process.env.EDK_DEBUG) {
213
- console.error(`[EDK_DEBUG] Failed to import ${file}:`, err);
213
+ writeTechnicalLog("DEBUG", "edk", `Failed to import ${file}: ${String(err)}`);
214
214
  }
215
215
  // Keep the on-disk child visible to sibling authoring even when its full
216
216
  // module cannot load yet (for example, a skill that references an
@@ -466,7 +466,7 @@ export async function regenerateAppCatalogsUnder(pathOrPaths, tenant) {
466
466
  }
467
467
  catch (err) {
468
468
  if (process.env.EDK_DEBUG) {
469
- console.error(`[EDK_DEBUG] Failed to import ${file}:`, err);
469
+ writeTechnicalLog("DEBUG", "edk", `Failed to import ${file}: ${String(err)}`);
470
470
  }
471
471
  continue;
472
472
  }
@@ -4,7 +4,7 @@
4
4
  * ids appear here (identity lives in `src/deploy/state`).
5
5
  */
6
6
  export { AI_PROVIDER_LLM_MODELS, type AiProviderLlmModel, type AiProviderType } from "./ai-provider-models.js";
7
- export { REF_SCOPE, REF_UPDATABLE, type AgentRef, type AgentEvaluationRef, type AiProviderRef, type ApprovalChainRef, type ApprovalProcessRef, type AppCatalogRef, type AppOrElementRef, type AutomationCatalogRef, type AutomationRef, type CatalogRef, type CatalogRefKind, type CategoryRef, type ChartRef, type DashboardRef, type WidgetRef, type CloudLinkRef, type AiServiceRef, type ConnectorRef, type GroupRef, type PhoneProviderRef, type PhoneServiceRef, PROCEDURE_PARAMETER_TYPES, type ProcedureParameterType, type ProcedureRef, type FileReaderCatalogRef, type DocumentModelFieldRef, type ElementCatalogRef, type FieldRef, type OutputPropertyRef, type RecordIdentityRef, type SearchTableRef, type StoredFunctionRef, type StoredFunctionScalarType, type DatamineRef, type SkillRef, type TableColumnRef, type TableRef, type TriggerParameterRef, USER_FIELD_KEYS, type UserFieldKey, type UserFieldRef, } from "./types.js";
7
+ export { REF_SCOPE, REF_UPDATABLE, type AgentRef, type AgentEvaluationRef, type AiProviderRef, type ApprovalChainRef, type ApprovalProcessRef, type AppCatalogRef, type AppOrElementRef, type AutomationCatalogRef, type AutomationRef, type CatalogRef, type CatalogRefKind, type CategoryRef, type ChartRef, type DashboardRef, type WidgetRef, type CloudLinkRef, type AiServiceRef, type ConnectorRef, type GroupRef, type PhoneProviderRef, type PhoneServiceRef, PROCEDURE_PARAMETER_TYPES, type ProcedureParameterType, type ProcedureRef, type FileReaderCatalogRef, type DocumentModelFieldRef, type ElementCatalogRef, type FieldRef, type OutputPropertyRef, type RecordIdentityRef, type SearchTableRef, type TableOwnedSearchTableRef, type StoredFunctionRef, type StoredFunctionScalarType, type DatamineRef, type SkillRef, type TableColumnRef, type TableRef, type TriggerParameterRef, USER_FIELD_KEYS, type UserFieldKey, type UserFieldRef, } from "./types.js";
8
8
  export { renderBarrel, renderCatalog, renderFragment, type BarrelEntry, type BarrelRoot, } from "./render.js";
9
9
  export { appCatalogTarget, barrelPathFor, orgCatalogTarget, regenerateBarrel, writeCatalog, writeFlatCatalog, writeFragment, type CatalogTarget, } from "./write.js";
10
10
  export { isCatalogToken, slimToken, slimTokens } from "./token.js";
@@ -24,6 +24,7 @@ import { AI_PROVIDER_TYPE_BY_RESOURCE_TYPE, ORG_IDENTITY_BAGS, orgRootOwnFileBag
24
24
  import { sanitizeName, tfLabelToTsLabel, tsLabelToTfLabel } from "../engine/tf/index.js";
25
25
  import { sdkPackageSpecifier } from "../internal/sdk-package.js";
26
26
  import { OrgExtractError } from "../engine/pull/org.js";
27
+ import { writeTechnicalLog } from "../engine/progress.js";
27
28
  // ---------------------------------------------------------------------------
28
29
  // Public entry points
29
30
  // ---------------------------------------------------------------------------
@@ -159,7 +160,7 @@ function supportedStoredFunction(fn) {
159
160
  : fn.parameterTypes.some((type) => STORED_FUNCTION_TYPE[type] === undefined) ? `unsupported argument in ${fn.parameterTypes.join(", ")}`
160
161
  : undefined;
161
162
  if (problem !== undefined) {
162
- console.error(`[elementum] skipping stored function ${fn.name}: ${problem}`);
163
+ writeTechnicalLog("WARN", "edk", `skipping stored function ${fn.name}: ${problem}`);
163
164
  return undefined;
164
165
  }
165
166
  return {
@@ -334,7 +335,7 @@ function computeElementKeys(appHandles, elementHandles) {
334
335
  }
335
336
  elementKeys.set(h, candidate);
336
337
  used.add(candidate);
337
- console.error(`[elementum] warning: "${h}" names both an app and an element — the element is exposed as catalog.${candidate} (the app keeps catalog.${h}) to avoid a collision.`);
338
+ writeTechnicalLog("WARN", "edk", `"${h}" names both an app and an element — the element is exposed as catalog.${candidate} (the app keeps catalog.${h}) to avoid a collision.`);
338
339
  }
339
340
  return elementKeys;
340
341
  }
@@ -66,6 +66,10 @@ export function slimToken(token) {
66
66
  out.databaseName = token.databaseName;
67
67
  if (token.__kind === "procedure" && typeof token.schemaName === "string")
68
68
  out.schemaName = token.schemaName;
69
+ // Datamines carry table column names so trigger filters can resolve ctx.trigger.record.<col>.
70
+ if (token.__kind === "datamine" && typeof token.columnNames === "object" && token.columnNames !== null) {
71
+ out.columnNames = token.columnNames;
72
+ }
69
73
  // Search-table resource selection is generated by catalog factories, not
70
74
  // authored as public API. Preserve the private discriminator so tool HCL
71
75
  // can reference the correct resource family.
@@ -113,7 +113,13 @@ export interface TableRef<RefName extends string = string, Columns extends Reado
113
113
  /** Raw category id, when imported. Categories are not tokenized yet. */
114
114
  readonly categoryId?: string;
115
115
  }
116
- export type SearchTableRef<Parent extends string = string, RefName extends string = string> = CatalogRef<"searchTable", RefName, Parent>;
116
+ export interface SearchTableRef<Parent extends string = string, RefName extends string = string> extends CatalogRef<"searchTable", RefName, Parent> {
117
+ /** Display name of a table owner when the reference is outside the workspace. */
118
+ readonly parentName?: string;
119
+ }
120
+ export type TableOwnedSearchTableRef<Parent extends string = string, RefName extends string = string> = SearchTableRef<Parent, RefName> & {
121
+ readonly __variant: "table";
122
+ };
117
123
  export interface DatamineRef<Parent extends string = string, RefName extends string = string> extends CatalogRef<"datamine", RefName, Parent> {
118
124
  /**
119
125
  * The owning table's display NAME, stamped alongside `parent` for the same
@@ -123,6 +129,8 @@ export interface DatamineRef<Parent extends string = string, RefName extends str
123
129
  * name, which `parent` (a refName) doesn't carry.
124
130
  */
125
131
  readonly parentName?: string;
132
+ /** Map of column refName / sanitized key → display name for column resolution in filters. */
133
+ readonly columnNames?: Readonly<Record<string, string>>;
126
134
  }
127
135
  /** Public reference to an AI service/model selected for runtime use. */
128
136
  export type AiServiceRef = CatalogRef<"connector">;
@@ -264,8 +272,10 @@ export interface TriggerParameterRef extends CatalogRef<"triggerParameter"> {
264
272
  * a non-executeScript task). Kept a bare generic `string` here (no import
265
273
  * from `entities/`) — same decoupling as {@link FieldRef}'s `fieldType`.
266
274
  */
267
- export interface OutputPropertyRef<ValueType extends string = string> extends CatalogRef<"outputProperty"> {
275
+ export interface OutputPropertyRef<ValueType extends string = string, Multiple extends boolean = boolean> extends CatalogRef<"outputProperty"> {
268
276
  readonly valueType?: ValueType;
277
+ /** True when the output resolves to a list of values rather than one value. */
278
+ readonly multiple?: Multiple;
269
279
  }
270
280
  export type DocumentModelFieldRef = CatalogRef<"documentModelField">;
271
281
  /**
@@ -290,7 +300,7 @@ export interface FileReaderCatalogRef extends CatalogRef<"documentModel"> {
290
300
  * fragment renders for an automation and the form `app.automations.<auto>` takes
291
301
  * in the barrel. `parent` on each nested ref is this automation's handle.
292
302
  */
293
- export interface AutomationCatalogRef extends CatalogRef<"automation"> {
303
+ export interface AutomationCatalogRef<Parent extends string = string, RefName extends string = string> extends CatalogRef<"automation", RefName, Parent> {
294
304
  readonly parentKind?: "app" | "element";
295
305
  readonly parentName?: string;
296
306
  readonly parentNamespace?: string;
@@ -8,7 +8,6 @@
8
8
  import type { AppOrElementRef } from "../../catalog/types.js";
9
9
  import type { RecordShape } from "../../entities/field/record-shape.js";
10
10
  import type { FieldTypeToTS, TriggerFieldTypeAlias } from "../../entities/shared/types/field-types.js";
11
- import type { User } from "../types/platform.js";
12
11
  /**
13
12
  * Scalar `type` values are constrained to the aliases Mobius accepts.
14
13
  * A `record` input additionally requires the app/element whose record is
@@ -38,43 +37,21 @@ export type TriggerInputFieldDef = ScalarTriggerInputFieldDef | RecordTriggerInp
38
37
  * { invoiceId: { type: "text", required: true }, amount: { type: "number" } }
39
38
  */
40
39
  export type TriggerInputSchema = Record<string, TriggerInputFieldDef>;
41
- /**
42
- * Options carried alongside the schema. `ShowTriggeredBy` defaults to
43
- * `false`; when true, the built-in `triggeredBy` parameter is
44
- * referenceable from tasks via `ctx.trigger.triggeredBy` and the
45
- * conditional in {@link InferTriggerType} adds it to the typed context.
46
- *
47
- * Record-detail context is a schema entry (`type: "record"`), not an option.
48
- */
49
- export interface OnDemandTriggerOptions {
50
- showTriggeredBy?: boolean;
51
- }
52
40
  /**
53
41
  * Given a TriggerInputSchema, derive the TypeScript object type
54
42
  * where each key maps to its TS type based on the field's `type`.
55
43
  * This becomes the TTrigger generic on the builder chain.
56
44
  *
57
- * When `Options.showTriggeredBy` is the literal type `true`, merge a
58
- * `triggeredBy: User` key so tasks can `ctx.trigger.triggeredBy.email`
59
- * with full type safety. When omitted or `false`, the key is absent
60
- * and the reference is a `tsc` error.
61
- *
62
45
  * Record entries preserve both their authored parameter key and target
63
46
  * app/element, so `ctx.trigger.<name>` has that target's RecordShape.
64
47
  */
65
48
  type TriggerInputFieldToTS<D extends TriggerInputFieldDef> = D extends RecordTriggerInputFieldDef<infer A> ? RecordShape<A> : FieldTypeToTS<D["type"]>;
66
- export type InferTriggerType<S extends TriggerInputSchema, Options extends OnDemandTriggerOptions = {}> = {
49
+ export type InferTriggerType<S extends TriggerInputSchema> = {
67
50
  [K in keyof S]: TriggerInputFieldToTS<S[K]>;
68
- } & (Options extends {
69
- showTriggeredBy: true;
70
- } ? {
71
- triggeredBy: User;
72
- } : {});
51
+ };
73
52
  export interface OnDemandTriggerDef<T, S extends TriggerInputSchema = TriggerInputSchema> {
74
53
  readonly kind: "onDemand";
75
54
  readonly schema: S;
76
- /** When true, mobius exposes the built-in `triggeredBy` parameter. */
77
- readonly showTriggeredBy?: boolean;
78
55
  /** Phantom — carries the inferred TS type for the builder chain. */
79
56
  readonly __triggerType: T;
80
57
  /** Phantom — carries the raw schema type so downstream builders can infer param shapes. */
@@ -92,7 +69,7 @@ export interface OnDemandTriggerDef<T, S extends TriggerInputSchema = TriggerInp
92
69
  * })
93
70
  * ```
94
71
  */
95
- export declare function onDemand<S extends TriggerInputSchema, Options extends OnDemandTriggerOptions = {}>(schema: S, options?: Options & Record<Exclude<keyof Options, keyof OnDemandTriggerOptions>, never>): OnDemandTriggerDef<InferTriggerType<S, Options>, S>;
72
+ export declare function onDemand<S extends TriggerInputSchema>(schema: S): OnDemandTriggerDef<InferTriggerType<S>, S>;
96
73
  /**
97
74
  * Wire shape for an onDemand `defaultValue`. Mirrors mobius's
98
75
  * `WorkflowTriggerParameterDefaultValueInput` Java record — a
@@ -140,8 +117,7 @@ export interface SerializedOnDemandTrigger {
140
117
  defaultValue?: WireDefaultValue;
141
118
  app?: AppOrElementRef;
142
119
  }>;
143
- showTriggeredBy?: boolean;
144
120
  };
145
121
  }
146
- export declare function serializeOnDemandTrigger(schema: TriggerInputSchema, options?: OnDemandTriggerOptions): SerializedOnDemandTrigger;
122
+ export declare function serializeOnDemandTrigger(schema: TriggerInputSchema): SerializedOnDemandTrigger;
147
123
  export {};
@@ -18,11 +18,10 @@ import { FIELD_TYPE_MAP } from "../../entities/shared/types/field-types.js";
18
18
  * })
19
19
  * ```
20
20
  */
21
- export function onDemand(schema, options) {
21
+ export function onDemand(schema) {
22
22
  return {
23
23
  kind: "onDemand",
24
24
  schema,
25
- ...(options?.showTriggeredBy && { showTriggeredBy: true }),
26
25
  __triggerType: undefined,
27
26
  };
28
27
  }
@@ -93,7 +92,7 @@ function wrapDefaultValueForWire(alias, value) {
93
92
  `type for this input.`);
94
93
  }
95
94
  }
96
- export function serializeOnDemandTrigger(schema, options) {
95
+ export function serializeOnDemandTrigger(schema) {
97
96
  const inputs = Object.entries(schema).map(([name, def]) => {
98
97
  if (def.type === "record") {
99
98
  const runtimeDef = def;
@@ -127,7 +126,6 @@ export function serializeOnDemandTrigger(schema, options) {
127
126
  return {
128
127
  onDemand: {
129
128
  inputs,
130
- ...(options?.showTriggeredBy && { showTriggeredBy: true }),
131
129
  },
132
130
  };
133
131
  }
@@ -31,6 +31,8 @@ export interface RecordFieldContext {
31
31
  readonly triggerAppRefName?: string;
32
32
  /** Each record-bearing task's refKey → its owning app refName. */
33
33
  readonly taskAppRefNameByRefKey?: Readonly<Record<string, string>>;
34
+ /** Each record-bearing task's refKey → whether that target is an app or element. */
35
+ readonly taskAppKindByRefKey?: Readonly<Record<string, "app" | "element">>;
34
36
  }
35
37
  /** Read the `recordFieldContext` extension off an entity, if its producer attached one. */
36
38
  export declare function recordFieldContextOf(entity: DeployableEntity): RecordFieldContext | undefined;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Runtime-neutral structured logging contract shared by the TypeScript CLI,
3
+ * ei, and the provider. Renderers and verbosity policy deliberately live
4
+ * elsewhere; this module only defines the event shape.
5
+ */
6
+ export declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "WARN", "ERROR"];
7
+ export type LogLevel = (typeof LOG_LEVELS)[number];
8
+ export declare const LOG_COMPONENTS: readonly ["edk", "ei", "provider", "tofu"];
9
+ export type LogComponent = (typeof LOG_COMPONENTS)[number];
10
+ /** Diagnostic rendering defaults to structured plaintext; JSON is explicit. */
11
+ export declare const LOG_FORMATS: readonly ["text", "json"];
12
+ export type LogFormat = (typeof LOG_FORMATS)[number];
13
+ export type LogValue = string | number | boolean | null | readonly LogValue[] | {
14
+ readonly [key: string]: LogValue;
15
+ };
16
+ export interface LogEvent {
17
+ readonly timestamp: string;
18
+ readonly level: LogLevel;
19
+ readonly component: LogComponent;
20
+ readonly message: string;
21
+ readonly [key: string]: unknown;
22
+ }
23
+ /** Lifecycle update emitted by `ei` for a live pull renderer. */
24
+ export interface ProgressEvent {
25
+ readonly protocol_version: 1;
26
+ readonly sequence: number;
27
+ readonly timestamp: string;
28
+ readonly event: "progress_enter" | "progress_update" | "progress_leave" | "progress_suspend" | "progress_resume";
29
+ readonly operation: string;
30
+ readonly phase: string;
31
+ readonly label?: string;
32
+ readonly section_id?: string;
33
+ readonly outcome?: "success" | "error" | "cancelled";
34
+ readonly reason?: string;
35
+ readonly text_effects?: readonly TextEffect[];
36
+ readonly current?: number;
37
+ readonly total?: number;
38
+ }
39
+ export interface EventStyle {
40
+ readonly color?: string;
41
+ readonly bold?: boolean;
42
+ readonly italic?: boolean;
43
+ readonly underline?: boolean;
44
+ readonly dim?: boolean;
45
+ readonly strikethrough?: boolean;
46
+ readonly inverse?: boolean;
47
+ readonly blink?: boolean;
48
+ readonly rapid_blink?: boolean;
49
+ readonly hidden?: boolean;
50
+ readonly overline?: boolean;
51
+ readonly double_underline?: boolean;
52
+ readonly framed?: boolean;
53
+ readonly encircled?: boolean;
54
+ }
55
+ /** A terminal effect applied to the half-open UTF-16 text range [start, end). */
56
+ export interface TextEffect extends EventStyle {
57
+ readonly start: number;
58
+ readonly end: number;
59
+ }
60
+ export interface BridgeLogEvent {
61
+ readonly protocol_version: number;
62
+ readonly sequence: number;
63
+ readonly timestamp: string;
64
+ readonly event: "log";
65
+ readonly level: "DEBUG" | "INFO" | "WARN" | "ERROR";
66
+ readonly component: string;
67
+ readonly message: string;
68
+ readonly text_effects?: readonly TextEffect[];
69
+ }
70
+ export declare function parseProgressEvent(line: string): ProgressEvent | undefined;
71
+ export declare function parseBridgeLogEvent(line: string): BridgeLogEvent | undefined;
72
+ /** Convert common JS camelCase keys to the contract's flat snake_case keys. */
73
+ export declare function snakeCaseKey(key: string): string;
74
+ export declare function createLogEvent(input: {
75
+ readonly level: LogLevel;
76
+ readonly component: LogComponent;
77
+ readonly message: string;
78
+ readonly timestamp?: string;
79
+ readonly [key: string]: unknown;
80
+ }): LogEvent;
81
+ /** Serialize exactly one complete JSON event, suitable for NDJSON output. */
82
+ export declare function serializeLogEvent(event: LogEvent): string;
83
+ /** A small active logger for engine code; renderers can be added at the CLI boundary. */
84
+ export interface LogWriter {
85
+ emit(input: Parameters<typeof createLogEvent>[0]): void;
86
+ }
87
+ export interface LogDestination {
88
+ write(chunk: string): unknown;
89
+ }
90
+ export declare function createLogWriter(destination?: LogDestination): LogWriter;