@elementumai/edk 0.9.13 → 0.9.15

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 (82) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +4 -0
  3. package/dist-sdk/src/catalog/from-authoring.js +5 -1
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/token.js +2 -2
  7. package/dist-sdk/src/catalog/types.d.ts +7 -2
  8. package/dist-sdk/src/core/types/app.d.ts +4 -4
  9. package/dist-sdk/src/engine/build/context.d.ts +3 -2
  10. package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
  11. package/dist-sdk/src/engine/build/source-context.js +16 -0
  12. package/dist-sdk/src/engine/progress.d.ts +15 -1
  13. package/dist-sdk/src/engine/progress.js +17 -1
  14. package/dist-sdk/src/engine/pull/context.d.ts +4 -1
  15. package/dist-sdk/src/engine/pull/ref-only.d.ts +2 -2
  16. package/dist-sdk/src/engine/pull/ref-only.js +3 -3
  17. package/dist-sdk/src/engine/workspace/loader.js +23 -2
  18. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
  19. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +23 -2
  20. package/dist-sdk/src/entities/agent/module.js +1 -0
  21. package/dist-sdk/src/entities/agent/to-tf.js +1 -0
  22. package/dist-sdk/src/entities/agent/tools.d.ts +20 -4
  23. package/dist-sdk/src/entities/agent/tools.js +10 -2
  24. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +4 -0
  25. package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -1
  26. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
  27. package/dist-sdk/src/entities/agent-tool/to-tf.js +11 -6
  28. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  29. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
  30. package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
  31. package/dist-sdk/src/entities/approval-chain/build.js +3 -0
  32. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
  33. package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
  34. package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
  35. package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
  36. package/dist-sdk/src/entities/automation/build.d.ts +7 -7
  37. package/dist-sdk/src/entities/automation/build.js +6 -2
  38. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
  39. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +114 -42
  40. package/dist-sdk/src/entities/automation/from-tf.d.ts +13 -1
  41. package/dist-sdk/src/entities/automation/from-tf.js +105 -33
  42. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  43. package/dist-sdk/src/entities/automation/index.js +2 -2
  44. package/dist-sdk/src/entities/automation/module.js +15 -9
  45. package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
  46. package/dist-sdk/src/entities/automation/script-code.js +59 -1
  47. package/dist-sdk/src/entities/automation/tasks.d.ts +19 -19
  48. package/dist-sdk/src/entities/automation/tasks.js +2 -5
  49. package/dist-sdk/src/entities/automation/to-tf.js +38 -10
  50. package/dist-sdk/src/entities/chart/build.d.ts +3 -3
  51. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  52. package/dist-sdk/src/entities/chart/from-tf.js +20 -13
  53. package/dist-sdk/src/entities/chart/to-tf.js +7 -5
  54. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
  55. package/dist-sdk/src/entities/field/build.d.ts +2 -2
  56. package/dist-sdk/src/entities/field/from-tf.js +35 -3
  57. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  58. package/dist-sdk/src/entities/field/to-tf.js +11 -4
  59. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
  60. package/dist-sdk/src/entities/relationship/from-tf.js +6 -3
  61. package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
  62. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
  63. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
  64. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -2
  65. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  66. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  67. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
  68. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +29 -16
  69. package/dist-sdk/src/entities/skill/module.js +1 -0
  70. package/dist-sdk/src/entities/skill/to-tf.js +1 -0
  71. package/dist-sdk/src/entities/skill/tools.d.ts +11 -3
  72. package/dist-sdk/src/entities/skill/tools.js +5 -1
  73. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +6 -0
  74. package/dist-sdk/src/entities/skill-tool/from-tf.js +19 -1
  75. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  76. package/dist-sdk/src/entities/skill-tool/to-tf.js +13 -4
  77. package/dist-sdk/src/entities/task/module.js +1 -1
  78. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  79. package/dist-sdk/src/graph/index.d.ts +2 -0
  80. package/dist-sdk/src/graph/index.js +14 -0
  81. package/dist-sdk/src/graph/types.d.ts +27 -1
  82. package/package.json +1 -1
@@ -21,8 +21,8 @@
21
21
  * nothing reads those interim values.
22
22
  */
23
23
  import type { AiProviderLlmModel, AiProviderType } from "./ai-provider-models.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";
25
- export declare function recordIdentity<const Target extends AppOrElementRef | TableRef>(target: Target): RecordIdentityRef<Target>;
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, TaskCatalogRef, TriggerParameterRef } from "./types.js";
25
+ export declare function recordIdentity<const Target extends AppOrElementRef | TaskCatalogRef | TableRef>(target: Target): RecordIdentityRef<Target>;
26
26
  /** Fixed platform user-directory schema used by userSearch filters. */
27
27
  export declare const usersCatalog: {
28
28
  readonly fields: {
@@ -60,6 +60,8 @@ export declare function appRef<const RefName extends string>(refName: RefName, n
60
60
  export declare function elementRef<const RefName extends string>(refName: RefName, name?: string, namespace?: string): CatalogRef<"element", RefName> & {
61
61
  readonly namespace?: string;
62
62
  };
63
+ /** Lightweight typed task-owner token. Prefer the generated catalog in authored workspace source. */
64
+ export declare function taskRef<const RefName extends string>(refName: RefName, name?: string, namespace?: string): TaskCatalogRef<RefName>;
63
65
  /** An app/element catalog's bags: reference-only kinds plus behavioral kinds sourced from authoring files. */
64
66
  interface AppCatalogBags {
65
67
  readonly fields?: Record<string, FieldRef>;
@@ -18,6 +18,10 @@ export function appRef(refName, name = refName, namespace) {
18
18
  export function elementRef(refName, name = refName, namespace) {
19
19
  return { __kind: "element", refName, name, ...(namespace !== undefined ? { namespace } : {}) };
20
20
  }
21
+ /** Lightweight typed task-owner token. Prefer the generated catalog in authored workspace source. */
22
+ export function taskRef(refName, name = refName, namespace) {
23
+ return { __kind: "task", refName, name, ...(namespace !== undefined ? { namespace } : {}) };
24
+ }
21
25
  /** Build a ref-kind factory: no identity parameter, `.refName` defaults to `name` (stamped over by the enclosing bag). */
22
26
  function refFactory(kind) {
23
27
  return (opts) => ({ __kind: kind, refName: opts.name, ...opts });
@@ -23,7 +23,7 @@ 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
25
  import { writeTechnicalLog } from "../engine/progress.js";
26
- import { KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
26
+ import { companionDirsByBag, KIND_BY_ID, ownFileCatalogChildrenOf, } from "../graph/index.js";
27
27
  import { writeCatalogBarrel } from "./org.js";
28
28
  import { renderCatalog } from "./render.js";
29
29
  import { assertAuthoringPathForTenant, assertValidAuthoringLayout, isAuthoringHelperFile, isStreamRootAuthoringFile, } from "../engine/workspace/authoring-layout.js";
@@ -95,6 +95,10 @@ async function listEntityFilesRecursive(dir) {
95
95
  for (const entry of entries) {
96
96
  if (entry.isDirectory() && SKIP_DIR_NAMES.has(entry.name))
97
97
  continue;
98
+ // Printer-owned companion folders (an automation's plain-JS script
99
+ // files) hold no entity source.
100
+ if (entry.isDirectory() && companionDirsByBag().get(basename(dir))?.has(entry.name) === true)
101
+ continue;
98
102
  const full = join(dir, entry.name);
99
103
  if (entry.isDirectory())
100
104
  out.push(...(await listEntityFilesRecursive(full)));
@@ -4,9 +4,9 @@
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 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";
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 TaskCatalogRef, type AppOrElementOrTaskRef, 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";
11
11
  export { buildAppCatalogFromAuthoring, listEntityFilesFromPaths, refNameOf, regenerateAppCatalogsUnder, writeAppCatalog, writeAppCatalogFromAuthoring, type AppAuthoringCatalog, type AppCatalogRegenResult, type ConfiguredEntity, } from "./from-authoring.js";
12
- export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, taskRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -9,4 +9,4 @@ export { renderBarrel, renderCatalog, renderFragment, } from "./render.js";
9
9
  export { appCatalogTarget, barrelPathFor, orgCatalogTarget, regenerateBarrel, writeCatalog, writeFlatCatalog, writeFragment, } from "./write.js";
10
10
  export { isCatalogToken, slimToken, slimTokens } from "./token.js";
11
11
  export { buildAppCatalogFromAuthoring, listEntityFilesFromPaths, refNameOf, regenerateAppCatalogsUnder, writeAppCatalog, writeAppCatalogFromAuthoring, } from "./from-authoring.js";
12
- export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, triggerParameterRef, usersCatalog, } from "./factories.js";
12
+ export { agentRef, agentEvaluationRef, appRef, appCatalog, approvalChainRef, automationRef, categoryRef, chartRef, dashboardRef, widgetRef, cloudLinkRef, connectorRef, aiProvider, groupRef, linkedSearchTableRef, phoneProviderRef, phoneServiceRef, procedureRef, documentModelFieldRef, documentModelRef, elementCatalog, elementRef, fieldRef, orgCatalog, outputPropertyRef, recordIdentity, searchTableRef, datamineRef, skillRef, storedFunctionRef, tableColumnRef, tableRef, tableSearchTableRef, taskRef, triggerParameterRef, usersCatalog, } from "./factories.js";
@@ -30,10 +30,10 @@ export function slimToken(token) {
30
30
  out.name = token.name;
31
31
  if (token.parent !== undefined)
32
32
  out.parent = token.parent;
33
- if ((token.__kind === "app" || token.__kind === "element") && typeof token.namespace === "string") {
33
+ if ((token.__kind === "app" || token.__kind === "element" || token.__kind === "task") && typeof token.namespace === "string") {
34
34
  out.namespace = token.namespace;
35
35
  }
36
- if ((token.parentKind === "app" || token.parentKind === "element"))
36
+ if (token.parentKind === "app" || token.parentKind === "element" || token.parentKind === "task")
37
37
  out.parentKind = token.parentKind;
38
38
  if (typeof token.parentName === "string")
39
39
  out.parentName = token.parentName;
@@ -199,9 +199,14 @@ export type ElementCatalogRef<RefName extends string = string> = CatalogRef<"ele
199
199
  /** Stable cross-organization lookup identity. Pulled/generated refs always carry it. */
200
200
  readonly namespace?: string;
201
201
  };
202
+ export type TaskCatalogRef<RefName extends string = string> = CatalogRef<"task", RefName> & {
203
+ /** Stable cross-organization lookup identity. Pulled/generated refs always carry it. */
204
+ readonly namespace?: string;
205
+ };
202
206
  export type AppOrElementRef<RefName extends string = string> = AppCatalogRef<RefName> | ElementCatalogRef<RefName>;
207
+ export type AppOrElementOrTaskRef<RefName extends string = string> = AppCatalogRef<RefName> | ElementCatalogRef<RefName> | TaskCatalogRef<RefName>;
203
208
  /** A record's own identity, referenceable without exposing its platform id. */
204
- export interface RecordIdentityRef<Target extends AppOrElementRef | TableRef = AppOrElementRef | TableRef> {
209
+ export interface RecordIdentityRef<Target extends AppOrElementRef | TaskCatalogRef | TableRef = AppOrElementRef | TaskCatalogRef | TableRef> {
205
210
  readonly __kind: "recordIdentity";
206
211
  readonly refName: "id";
207
212
  readonly name: "Record ID";
@@ -227,7 +232,7 @@ export interface FieldRef<Parent extends string = string, RefName extends string
227
232
  * `elementum_app` vs `elementum_element` for its owner lookup without
228
233
  * depending on the owner also appearing elsewhere in the same payload.
229
234
  */
230
- readonly parentKind?: "app" | "element";
235
+ readonly parentKind?: "app" | "element" | "task";
231
236
  /**
232
237
  * The parent's display NAME, stamped alongside `parent` for the same
233
238
  * reason `parentKind` is — a foreign owner lookup (`data.elementum_app` /
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { type Ref, type ValueOrRef } from "../../entities/shared/ref.js";
11
11
  import type { WorkflowFieldType } from "../../entities/shared/types/field-types.js";
12
- import type { AppOrElementRef, FieldRef } from "../../catalog/types.js";
12
+ import type { AppOrElementOrTaskRef, FieldRef } from "../../catalog/types.js";
13
13
  import type { RefExpr } from "../../entities/shared/filters/ast.js";
14
14
  import type { Filter } from "../../entities/shared/filters/types.js";
15
15
  import type { CloudLink } from "./cloud-link.js";
@@ -211,10 +211,10 @@ export interface JsonAppField<Scope extends FieldScope = "unscoped"> extends Asp
211
211
  * RefExpr>` shape `NormalizedAccessPolicy` already uses.
212
212
  */
213
213
  export interface NormalizedPicklistDynamicConfig {
214
- readonly relatedAspectId: AppOrElementRef | string;
214
+ readonly relatedAspectId: AppOrElementOrTaskRef | string;
215
215
  readonly relatedLabelFieldId: string | {
216
216
  readonly ownerRefName: string;
217
- readonly ownerKind?: "app" | "element";
217
+ readonly ownerKind?: "app" | "element" | "task";
218
218
  readonly ownerName?: string;
219
219
  readonly ownerNamespace?: string;
220
220
  readonly fieldKey: string;
@@ -336,7 +336,7 @@ export interface AttachmentAppField<Scope extends FieldScope = "unscoped"> exten
336
336
  */
337
337
  export interface RelationAppField<Scope extends FieldScope = "unscoped"> extends AspectFieldBase<Scope> {
338
338
  readonly type: "RELATION";
339
- readonly relatedObject: AppOrElementRef | string;
339
+ readonly relatedObject: AppOrElementOrTaskRef | string;
340
340
  readonly relatedLabelField: FieldRef | string;
341
341
  /** Defaults to `true` on the platform. */
342
342
  readonly autoRelate?: boolean;
@@ -50,6 +50,7 @@ export interface OrgRefLookup {
50
50
  byName(bag: string, name: string): OrgRefResolution | undefined;
51
51
  /** Legacy typed convenience routed through app's graph-declared root strategy. */
52
52
  foreignApp(tfLabel: string, name: string, namespace?: string): void;
53
+ foreignTask(tfLabel: string, name: string, namespace?: string): void;
53
54
  /**
54
55
  * Record a name-keyed `data.elementum_agentic_skill` lookup for a FOREIGN
55
56
  * skill (an agent's `skillAccess` pointing at a skill owned by a
@@ -85,7 +86,7 @@ export interface OrgRefLookup {
85
86
  }
86
87
  /** A stream root discovered elsewhere in THIS workspace build, keyed by {@link workspaceAspectKey}. */
87
88
  export interface WorkspaceAspect {
88
- readonly kind: ChildResourceScope | "table";
89
+ readonly kind: ChildResourceScope | "table" | "task";
89
90
  readonly tfLabel: string;
90
91
  /** Loaded stream root, available to entity-owned cross-stream resolvers. */
91
92
  readonly streamRootEntity?: DeployableEntity;
@@ -106,7 +107,7 @@ export interface WorkspaceAspect {
106
107
  * so `refName` alone is not a unique map key). Keying by kind+refName keeps
107
108
  * an app "tickets" and an element "tickets" from colliding.
108
109
  */
109
- export declare function workspaceAspectKey(kind: ChildResourceScope | "table", refName: string): string;
110
+ export declare function workspaceAspectKey(kind: ChildResourceScope | "table" | "task", refName: string): string;
110
111
  export interface ToTfContext {
111
112
  /** The owning app's refName — its authoring directory / catalog key. */
112
113
  readonly appRefName: string;
@@ -40,3 +40,5 @@ export interface SourceTextContext {
40
40
  export declare function withSourceText<T>(filePath: string, text: string, fn: () => Promise<T>): Promise<T>;
41
41
  /** The file/text currently being imported via {@link withSourceText}, or undefined outside that context. */
42
42
  export declare function currentSourceText(): SourceTextContext | undefined;
43
+ /** The workspace file currently being imported by the workspace loader, if any. */
44
+ export declare function currentImportingFile(): string | undefined;
@@ -21,3 +21,19 @@ export async function withSourceText(filePath, text, fn) {
21
21
  export function currentSourceText() {
22
22
  return slot()[GLOBAL_KEY];
23
23
  }
24
+ // ---------------------------------------------------------------------------
25
+ // The file being imported (path only)
26
+ // ---------------------------------------------------------------------------
27
+ //
28
+ // {@link withSourceText} carries a file's TEXT and is only set by the build's
29
+ // own-file discovery. Some authored values need just the importing file's
30
+ // PATH to resolve a relative reference (an automation's `scriptFile("./x.js")`),
31
+ // and they must resolve for EVERY importer (canvas, catalog regeneration,
32
+ // build), not only the one that also wants the text. The workspace loader
33
+ // (`engine/workspace/loader.ts`) sets this around each import under the same
34
+ // `Symbol.for` key; same `globalThis` registry rationale as above.
35
+ const IMPORTING_FILE_KEY = Symbol.for("elementumEdk.engine.build.importingFile");
36
+ /** The workspace file currently being imported by the workspace loader, if any. */
37
+ export function currentImportingFile() {
38
+ return globalThis[IMPORTING_FILE_KEY];
39
+ }
@@ -26,8 +26,22 @@ export declare function writeTechnicalLog(level: LogLevel, source: string, messa
26
26
  /** Emit suppressed WARN/ERROR summaries at the end of a command. */
27
27
  export declare function flushRepeatedTechnicalLogs(): void;
28
28
  export declare function resetTechnicalLogDeduplication(): void;
29
- /** Write user-owned output without allowing it to collide with the live row. */
29
+ /**
30
+ * Write user-facing output without allowing it to collide with the live row.
31
+ *
32
+ * Machine-readable mode drops this channel. Status text and non-bridge
33
+ * OpenTofu transcript stay off stdout under `--json`. Bridged command
34
+ * payloads go through {@link writeUserPayload}.
35
+ */
30
36
  export declare function writeUserOutput(text: string, destination?: NodeJS.WritableStream): void;
37
+ /**
38
+ * Write a bridged passthrough payload.
39
+ *
40
+ * Unlike {@link writeUserOutput}, this still reaches `destination` when
41
+ * machine-readable logs are on, so `records list --json` and other bridged
42
+ * commands keep their stdout.
43
+ */
44
+ export declare function writeUserPayload(text: string, destination?: NodeJS.WritableStream): void;
31
45
  /** Write a final user-facing operation status without contaminating pipes. */
32
46
  export declare function writeUserStatus(message: string, color: "green" | "red" | "yellow"): void;
33
47
  export interface LiveProgressOptions {
@@ -110,10 +110,26 @@ function configuredLogLevel() {
110
110
  return "DEBUG";
111
111
  return "INFO";
112
112
  }
113
- /** Write user-owned output without allowing it to collide with the live row. */
113
+ /**
114
+ * Write user-facing output without allowing it to collide with the live row.
115
+ *
116
+ * Machine-readable mode drops this channel. Status text and non-bridge
117
+ * OpenTofu transcript stay off stdout under `--json`. Bridged command
118
+ * payloads go through {@link writeUserPayload}.
119
+ */
114
120
  export function writeUserOutput(text, destination = process.stdout) {
115
121
  if (machineReadableLogs)
116
122
  return;
123
+ writeUserPayload(text, destination);
124
+ }
125
+ /**
126
+ * Write a bridged passthrough payload.
127
+ *
128
+ * Unlike {@link writeUserOutput}, this still reaches `destination` when
129
+ * machine-readable logs are on, so `records list --json` and other bridged
130
+ * commands keep their stdout.
131
+ */
132
+ export function writeUserPayload(text, destination = process.stdout) {
117
133
  const live = activeProgress;
118
134
  if (live !== undefined) {
119
135
  live.writeUserOutput(text, destination);
@@ -37,11 +37,13 @@ export interface FromTfContext {
37
37
  */
38
38
  readonly foreignAppRefNames?: ReadonlyMap<string, string>;
39
39
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
40
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
40
41
  /** Imported platform field id -> typed owner/key, assembled by the recursive pull workspace context. */
41
42
  readonly foreignFieldRefsById?: ReadonlyMap<string, {
42
43
  readonly ownerRefName: string;
43
44
  readonly fieldKey: string;
44
45
  readonly fieldName?: string;
46
+ readonly fieldType?: string;
45
47
  }>;
46
48
  /** Platform table id -> typed org catalog identity, loaded by recursive pull when table refs are present. */
47
49
  readonly foreignTableRefsById?: ReadonlyMap<string, {
@@ -53,10 +55,11 @@ export interface FromTfContext {
53
55
  /** Namespace → refName for portable ref-only app/element catalogs. */
54
56
  readonly foreignAppRefNamespaces?: ReadonlyMap<string, string>;
55
57
  readonly foreignElementRefNamespaces?: ReadonlyMap<string, string>;
58
+ readonly foreignTaskRefNamespaces?: ReadonlyMap<string, string>;
56
59
  /** `data.<field-type>.<label>` → generated ref-only catalog member. */
57
60
  readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
58
61
  readonly ownerRefName: string;
59
- readonly ownerKind?: "app" | "element";
62
+ readonly ownerKind?: "app" | "element" | "task";
60
63
  readonly ownerName?: string;
61
64
  readonly ownerNamespace?: string;
62
65
  readonly fieldKey: string;
@@ -2,7 +2,7 @@ import type { FieldRef } from "../../catalog/index.js";
2
2
  import type { UnresolvedReferenceDiagnostic } from "../../graph/types.js";
3
3
  import { type TfDocument } from "../tf/index.js";
4
4
  export interface DirectReferenceRoot {
5
- readonly kind: "app" | "element" | "table";
5
+ readonly kind: "app" | "element" | "table" | "task";
6
6
  readonly refName: string;
7
7
  readonly name: string;
8
8
  readonly namespace?: string;
@@ -42,7 +42,7 @@ export interface RefOnlyMetadata {
42
42
  export declare function readRefOnlyMetadata(doc: TfDocument): RefOnlyMetadata;
43
43
  export declare function fieldDataReferenceMap(doc: TfDocument, roots: readonly DirectReferenceRoot[]): ReadonlyMap<string, {
44
44
  readonly ownerRefName: string;
45
- readonly ownerKind?: "app" | "element";
45
+ readonly ownerKind?: "app" | "element" | "task";
46
46
  readonly ownerName?: string;
47
47
  readonly ownerNamespace?: string;
48
48
  readonly fieldKey: string;
@@ -37,7 +37,7 @@ function parseRoot(payload) {
37
37
  const kind = stringAt(obj, "kind");
38
38
  const name = stringAt(obj, "name");
39
39
  const wireRefName = stringAt(obj, "refName");
40
- if ((kind !== "app" && kind !== "element" && kind !== "table") || name === undefined || wireRefName === undefined)
40
+ if ((kind !== "app" && kind !== "element" && kind !== "table" && kind !== "task") || name === undefined || wireRefName === undefined)
41
41
  return undefined;
42
42
  const fields = [];
43
43
  for (const rawField of Array.isArray(obj.fields) ? obj.fields : []) {
@@ -197,7 +197,7 @@ export function readRefOnlyMetadata(doc) {
197
197
  }
198
198
  }
199
199
  const deduped = new Map(roots.map((root) => [
200
- root.kind === "table" ? `table:${root.name}` : `${root.kind}:${root.namespace}`,
200
+ root.kind === "table" || root.kind === "task" ? `${root.kind}:${root.name}` : `${root.kind}:${root.namespace}`,
201
201
  root,
202
202
  ]));
203
203
  return { roots: [...deduped.values()], unresolved, diagnostics };
@@ -225,7 +225,7 @@ export function fieldDataReferenceMap(doc, roots) {
225
225
  if (owner !== undefined && field !== undefined)
226
226
  out.set(`${block.type}.${block.label}`, {
227
227
  ownerRefName: owner.refName,
228
- ...(owner.kind === "app" || owner.kind === "element" ? { ownerKind: owner.kind } : {}),
228
+ ...(owner.kind === "app" || owner.kind === "element" || owner.kind === "task" ? { ownerKind: owner.kind } : {}),
229
229
  ownerName: owner.name,
230
230
  ...(owner.namespace !== undefined ? { ownerNamespace: owner.namespace } : {}),
231
231
  fieldKey: field.refName,
@@ -45,6 +45,25 @@ const activeRoots = new Set();
45
45
  let hooksRegistered = false;
46
46
  /** What the resolve hook stamps. Only mutated inside the import queue. */
47
47
  let stampGeneration = 0;
48
+ /**
49
+ * Records which workspace file is being imported, for authored values that
50
+ * resolve a path relative to it (an automation's `scriptFile("./x.js")`).
51
+ * Same `globalThis` registry key `engine/build/source-context.ts` reads; kept
52
+ * inline because this module is loaded natively (no `.js` -> `.ts` mapping)
53
+ * and can only import `node:` builtins.
54
+ */
55
+ const IMPORTING_FILE_KEY = Symbol.for("elementumEdk.engine.build.importingFile");
56
+ async function withImportingFile(filePath, fn) {
57
+ const slot = globalThis;
58
+ const previous = slot[IMPORTING_FILE_KEY];
59
+ slot[IMPORTING_FILE_KEY] = filePath;
60
+ try {
61
+ return await fn();
62
+ }
63
+ finally {
64
+ slot[IMPORTING_FILE_KEY] = previous;
65
+ }
66
+ }
48
67
  /** Monotonic allocator. Incremented only inside the import queue so
49
68
  * constructing a second loader cannot change the in-flight stamp. */
50
69
  let nextGeneration = 0;
@@ -294,7 +313,7 @@ function createJitiLoader(root) {
294
313
  });
295
314
  });
296
315
  const jiti = await pending;
297
- return (await jiti.import(resolve(file)));
316
+ return (await withImportingFile(resolve(file), () => jiti.import(resolve(file))));
298
317
  },
299
318
  };
300
319
  }
@@ -317,7 +336,9 @@ export function createWorkspaceLoader(orgRoot) {
317
336
  stampGeneration = generation;
318
337
  try {
319
338
  const url = pathToFileURL(resolve(file)).href;
320
- return await nativeImport(`${url}?${GENERATION_KEY}=${generation}`);
339
+ // Set inside the serialized section so overlapping imports cannot
340
+ // see each other's file.
341
+ return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
321
342
  }
322
343
  finally {
323
344
  stampGeneration = previous;
@@ -49,6 +49,12 @@ export interface PrintAgentV2Options {
49
49
  * key here prints `catalog.<refName>` instead of the literal stub.
50
50
  */
51
51
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
52
+ /**
53
+ * Name → refName for every task already on disk in this workspace. A
54
+ * `foreignTask` tool target whose name is a key here prints
55
+ * `catalog.<refName>` instead of the literal stub.
56
+ */
57
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
52
58
  /** Aspect/table display-name pair → typed search-table identity. */
53
59
  readonly foreignSearchTableRefsByName?: ReadonlyMap<string, {
54
60
  readonly ownerRefName: string;
@@ -193,7 +193,7 @@ export function printAgentV2(agent, opts) {
193
193
  if (agent.tools.length > 0) {
194
194
  lines.push(" tools: [");
195
195
  for (const tool of agent.tools) {
196
- lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignSearchTableRefsByName, opts.foreignFieldRefsById).map((l) => ` ${l}`));
196
+ lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignTaskRefNames, opts.foreignSearchTableRefsByName, opts.foreignFieldRefsById).map((l) => ` ${l}`));
197
197
  }
198
198
  lines.push(" ],");
199
199
  }
@@ -384,6 +384,9 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
384
384
  ? { kind: "catalog", expr: `catalog.${foreignRefName}` }
385
385
  : { kind: "raw", entityType: "app", name: tool.target.name };
386
386
  }
387
+ if (tool.target.kind === "foreignTask") {
388
+ return { kind: "raw", entityType: "task", name: tool.target.name };
389
+ }
387
390
  const foreignRefName = foreignElementRefNames?.get(tool.target.name);
388
391
  return foreignRefName !== undefined
389
392
  ? { kind: "catalog", expr: `catalog.${foreignRefName}` }
@@ -408,7 +411,7 @@ function searchTableFieldMatchesTarget(fieldId, targetOwnerRefName, foreignField
408
411
  const resolved = foreignFieldRefsById?.get(fieldId);
409
412
  return resolved !== undefined && targetOwnerRefName !== undefined && resolved.ownerRefName === targetOwnerRefName;
410
413
  }
411
- function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignSearchTableRefsByName, foreignFieldRefsById) {
414
+ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames, foreignSearchTableRefsByName, foreignFieldRefsById) {
412
415
  const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "agentSearchRecords";
413
416
  const lines = [`${factory}({`];
414
417
  lines.push(` name: ${quote(tool.name)},`);
@@ -518,6 +521,15 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
518
521
  lines.push(` element: { __kind: "element", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },${todo}`);
519
522
  }
520
523
  }
524
+ else if (tool.target !== undefined && tool.target.kind === "foreignTask") {
525
+ const foreignRefName = foreignTaskRefNames?.get(tool.target.name);
526
+ if (foreignRefName !== undefined) {
527
+ lines.push(` task: catalog.${foreignRefName},`);
528
+ }
529
+ else {
530
+ lines.push(` task: { __kind: "task", refName: ${quote(tool.target.name)}, name: ${quote(tool.target.name)} },`);
531
+ }
532
+ }
521
533
  if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "self") {
522
534
  lines.push(` relatedApp: catalog.${appRefName},`);
523
535
  }
@@ -552,6 +564,15 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
552
564
  lines.push(` relatedElement: { __kind: "element", refName: ${quote(tool.relatedTarget.name)}, name: ${quote(tool.relatedTarget.name)} },${todo}`);
553
565
  }
554
566
  }
567
+ else if (tool.typeKey === "relateRecord" && tool.relatedTarget?.kind === "foreignTask") {
568
+ const foreignRefName = foreignTaskRefNames?.get(tool.relatedTarget.name);
569
+ if (foreignRefName !== undefined) {
570
+ lines.push(` relatedTask: catalog.${foreignRefName},`);
571
+ }
572
+ else {
573
+ lines.push(` relatedTask: { __kind: "task", refName: ${quote(tool.relatedTarget.name)}, name: ${quote(tool.relatedTarget.name)} },`);
574
+ }
575
+ }
555
576
  if (tool.typeKey === "searchAspect" || tool.typeKey === "searchTable") {
556
577
  lines.push(` queryDescription: ${quote(tool.queryDescription ?? "")},`);
557
578
  if (tool.limit !== undefined)
@@ -101,6 +101,7 @@ export const agentModule = {
101
101
  ...(opts.connectorKeyOverride !== undefined && { connectorKeyOverride: opts.connectorKeyOverride }),
102
102
  ...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
103
103
  ...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
104
+ ...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
104
105
  ...(opts.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
105
106
  ...(opts.foreignSearchTableRefsByName !== undefined && {
106
107
  foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName,
@@ -462,6 +462,7 @@ export function agentToTf(entity, ctx) {
462
462
  activeAutomationRefNames: ctx.activeAutomationRefNames,
463
463
  foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
464
464
  foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
465
+ foreignTaskRef: (l, n) => ctx.orgRefs.rawLookup("elementum_task", l, n),
465
466
  foreignAutomationRef: (l, n, owner) => {
466
467
  const ownerKind = owner.kind === "element" ? "element" : "app";
467
468
  const ownerRef = resolveForeignRef(ownerKind, { name: owner.name, namespace: owner.namespace }, ctx.orgRefs, ctx.diagnostics, `agent run-automation owner`);
@@ -10,7 +10,7 @@
10
10
  * object. Optional `startMessage` / `runAs` are emitted only when supplied,
11
11
  * matching the v1 serializer's field-by-field discipline.
12
12
  */
13
- import type { AutomationCatalogRef, AgentRef, AppCatalogRef, AutomationRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, TriggerParameterRef } from "../../catalog/index.js";
13
+ import type { AutomationCatalogRef, AgentRef, AppCatalogRef, AutomationRef, ElementCatalogRef, FieldRef, OutputPropertyRef, SearchTableRef, TaskCatalogRef, TriggerParameterRef } from "../../catalog/index.js";
14
14
  import type { UnsafePlatformId } from "../../core/platform-id.js";
15
15
  import type { AgentToolRunAs } from "./run-as.js";
16
16
  import type { Filter } from "../automation/filter.js";
@@ -21,15 +21,23 @@ export type AgentTool = Record<string, unknown> & {
21
21
  readonly [agentToolBrand]: "AgentTool";
22
22
  };
23
23
  /** A field exposed to a search tool. */
24
- type ToolTarget = AppCatalogRef | ElementCatalogRef;
24
+ type ToolTarget = AppCatalogRef | ElementCatalogRef | TaskCatalogRef;
25
25
  type TargetOption<Target extends ToolTarget> = Target extends {
26
26
  readonly __kind: "app";
27
27
  } ? {
28
28
  readonly app: Target;
29
29
  readonly element?: never;
30
- } : {
30
+ readonly task?: never;
31
+ } : Target extends {
32
+ readonly __kind: "element";
33
+ } ? {
31
34
  readonly app?: never;
32
35
  readonly element: Target;
36
+ readonly task?: never;
37
+ } : {
38
+ readonly app?: never;
39
+ readonly element?: never;
40
+ readonly task: Target;
33
41
  };
34
42
  export interface AgentSearchField<Target extends ToolTarget = ToolTarget> {
35
43
  readonly field: FieldRef<Target["refName"]>;
@@ -207,9 +215,17 @@ type RelatedTargetOption<Target extends ToolTarget> = Target extends {
207
215
  } ? {
208
216
  readonly relatedApp: Target;
209
217
  readonly relatedElement?: never;
210
- } : {
218
+ readonly relatedTask?: never;
219
+ } : Target extends {
220
+ readonly __kind: "element";
221
+ } ? {
211
222
  readonly relatedApp?: never;
212
223
  readonly relatedElement: Target;
224
+ readonly relatedTask?: never;
225
+ } : {
226
+ readonly relatedApp?: never;
227
+ readonly relatedElement?: never;
228
+ readonly relatedTask: Target;
213
229
  };
214
230
  export type RelateRecordToolV2<Target extends ToolTarget = ToolTarget, RelatedTarget extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & RelatedTargetOption<RelatedTarget>;
215
231
  export declare function agentRelateRecord<Target extends ToolTarget, RelatedTarget extends ToolTarget>(opts: RelateRecordToolV2<Target, RelatedTarget>): AgentTool;
@@ -1,7 +1,11 @@
1
1
  import { isValidToolName } from "../agent-tool/types.js";
2
2
  import { assertHandleDescriptionNotEmpty } from "../shared/handle-description.js";
3
3
  function targetOf(opts) {
4
- return ("app" in opts && opts.app !== undefined ? opts.app : opts.element);
4
+ return ("app" in opts && opts.app !== undefined
5
+ ? opts.app
6
+ : "element" in opts && opts.element !== undefined
7
+ ? opts.element
8
+ : opts.task);
5
9
  }
6
10
  function filterVariableToken(variable) {
7
11
  return {
@@ -163,7 +167,11 @@ export function agentUpdateRecord(opts) {
163
167
  });
164
168
  }
165
169
  export function agentRelateRecord(opts) {
166
- const relatedTarget = "relatedApp" in opts && opts.relatedApp !== undefined ? opts.relatedApp : opts.relatedElement;
170
+ const relatedTarget = "relatedApp" in opts && opts.relatedApp !== undefined
171
+ ? opts.relatedApp
172
+ : "relatedElement" in opts && opts.relatedElement !== undefined
173
+ ? opts.relatedElement
174
+ : opts.relatedTask;
167
175
  return tool({
168
176
  relateRecord: {
169
177
  ...common(opts),
@@ -56,6 +56,10 @@ export type NormalizedToolTarget = {
56
56
  /** A foreign ELEMENT via `data.elementum_element.<label>` — `name` from the stream's data block (board issue #42). */
57
57
  readonly kind: "foreignElement";
58
58
  readonly name: string;
59
+ } | {
60
+ /** A foreign TASK via `data.elementum_task.<label>` — `name` from the stream's data block. */
61
+ readonly kind: "foreignTask";
62
+ readonly name: string;
59
63
  } | {
60
64
  /**
61
65
  * `target_id` didn't resolve to any portable reference at export
@@ -344,12 +344,13 @@ function aspectTargetFromTf(value, attrName, owner, ctx, where) {
344
344
  ctx.diagnostics.push(`${where}: ${attrName} is missing; skipped`);
345
345
  return undefined;
346
346
  }
347
- if (value !== undefined && resourceRefLabel(value, owner.appType) === owner.appLabel) {
347
+ if (owner.appLabel !== undefined && resourceRefLabel(value, owner.appType) === owner.appLabel) {
348
348
  return { target: { kind: "self" }, fieldScopeLabel: owner.ownerTfLabel, fieldScope: "app" };
349
349
  }
350
350
  for (const [type, kind, scope] of [
351
351
  ["elementum_app", "foreignApp", "app"],
352
352
  ["elementum_element", "foreignElement", "element"],
353
+ ["elementum_task", "foreignTask", "task"],
353
354
  ]) {
354
355
  if (!isTfExpr(value) || value.$expr !== "data-attr" || value.type !== type)
355
356
  continue;
@@ -24,6 +24,8 @@ export interface ToolToTfContext {
24
24
  foreignAppRef(tfLabel: string, name: string, namespace?: string): void;
25
25
  /** Records a foreign-ELEMENT data lookup for data.tf (board issue #42). */
26
26
  foreignElementRef(tfLabel: string, name: string, namespace?: string): void;
27
+ /** Records a foreign-TASK data lookup for data.tf. */
28
+ foreignTaskRef?(tfLabel: string, name: string, namespace?: string): void;
27
29
  foreignAutomationRef?(tfLabel: string, name: string, owner: {
28
30
  readonly kind: "app" | "element";
29
31
  readonly refName: string;