@elementumai/edk 0.9.14 → 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
@@ -39,7 +39,7 @@ export interface AppRefAst {
39
39
  readonly kind: "app";
40
40
  readonly appHandle: string;
41
41
  /** Present for a foreign data lookup that is not in the local catalog. */
42
- readonly entityType?: "app" | "element";
42
+ readonly entityType?: "app" | "element" | "task";
43
43
  /** Provider lookup name for that foreign app/element. */
44
44
  readonly name?: string;
45
45
  }
@@ -57,7 +57,7 @@ export interface FieldRefAst {
57
57
  * `AppRefAst.name`, which this mirrors).
58
58
  */
59
59
  readonly foreign?: {
60
- readonly entityType: "app" | "element";
60
+ readonly entityType: "app" | "element" | "task";
61
61
  /** The owner's display name — resolves a same-name local catalog entry, same convention as `AppRefAst.name`. */
62
62
  readonly name: string;
63
63
  /** Stable namespace for a portable inline fieldRef owner lookup. */
@@ -16,4 +16,4 @@
16
16
  */
17
17
  import type { FromTfContext } from "../../engine/pull/context.js";
18
18
  import { type ChildResourceScope, type TfValue } from "../../engine/tf/index.js";
19
- export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope, ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
19
+ export declare function resolveToolFieldKey(fieldRef: TfValue | undefined, scopeTfLabel: string, scope?: ChildResourceScope | "task", ctx?: Pick<FromTfContext, "dataAttrs" | "foreignFieldRefsByDataAddress">): string | undefined;
@@ -4,12 +4,12 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
4
4
  if (fieldRef === undefined)
5
5
  return undefined;
6
6
  if (isTfExpr(fieldRef) && fieldRef.$expr === "resource-attr" && FIELD_SUB_TYPE_BY_RESOURCE.has(fieldRef.type)) {
7
- return scopedLabelToBagKey(scopeTfLabel, fieldRef.label, scope);
7
+ return scopedLabelToBagKey(scopeTfLabel, fieldRef.label, scope === "task" ? "app" : scope);
8
8
  }
9
9
  if (isTfExpr(fieldRef) && fieldRef.$expr === "data-attr" && fieldRef.type === "elementum_field") {
10
10
  const fieldAttrs = ctx?.dataAttrs?.("elementum_field", fieldRef.label);
11
11
  const objectId = fieldAttrs?.object_id;
12
- const ownerType = scope === "element" ? "elementum_element" : "elementum_app";
12
+ const ownerType = scope === "element" ? "elementum_element" : scope === "task" ? "elementum_task" : "elementum_app";
13
13
  const addressesResolvedToSameTarget = objectId !== undefined && isTfExpr(objectId) && objectId.$expr === "data-attr" &&
14
14
  objectId.type === ownerType && objectId.label === scopeTfLabel && objectId.path.join(".") === "id";
15
15
  if (addressesResolvedToSameTarget) {
@@ -30,6 +30,10 @@ export function resolveToolFieldKey(fieldRef, scopeTfLabel, scope = "app", ctx)
30
30
  if (fieldRef.label.startsWith(prefix)) {
31
31
  return tfLabelToTsLabel(fieldRef.label.slice(prefix.length));
32
32
  }
33
+ const taskPrefix = `elementum_task_${scopeTfLabel}_`;
34
+ if (scope === "task" && fieldRef.label.startsWith(taskPrefix)) {
35
+ return tfLabelToTsLabel(fieldRef.label.slice(taskPrefix.length));
36
+ }
33
37
  }
34
38
  if (isTfExpr(fieldRef) && fieldRef.$expr === "local") {
35
39
  const prefix = `${scopeTfLabel}_`;
@@ -35,6 +35,12 @@ export interface PrintSkillV2Options {
35
35
  * `catalog.<refName>` instead of the literal stub.
36
36
  */
37
37
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
38
+ /**
39
+ * Same as {@link foreignAppRefNames}, keyed for standalone tasks — a
40
+ * `foreignTask` tool target whose name is a key here prints
41
+ * `catalog.<refName>` instead of the literal stub.
42
+ */
43
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
38
44
  /** Raw foreign field id → typed catalog field identity, supplied by recursive pull. */
39
45
  readonly foreignFieldRefsById?: ReadonlyMap<string, {
40
46
  readonly ownerRefName: string;
@@ -116,7 +116,7 @@ export function printSkillV2(skill, opts) {
116
116
  if (skill.tools.length > 0) {
117
117
  lines.push(" tools: [");
118
118
  for (const tool of skill.tools) {
119
- lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignFieldRefsById, opts.foreignSearchTableRefsByName).map((l) => ` ${l}`));
119
+ lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignTaskRefNames, opts.foreignFieldRefsById, opts.foreignSearchTableRefsByName).map((l) => ` ${l}`));
120
120
  }
121
121
  lines.push(" ],");
122
122
  }
@@ -126,7 +126,7 @@ export function printSkillV2(skill, opts) {
126
126
  lines.push("");
127
127
  return lines.join("\n");
128
128
  }
129
- function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
129
+ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames) {
130
130
  // `fields` (and therefore this) is only ever reached for createRecord/
131
131
  // searchAspect/updateRecord, which always carry a target — automation/
132
132
  // runAgent tools return before this point. The undefined branch only
@@ -141,8 +141,20 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
141
141
  if (tool.target.kind === "unresolved") {
142
142
  return { kind: "raw", entityType: "app", name: tool.target.uuid, refName: tool.target.uuid };
143
143
  }
144
+ if (tool.target.kind === "foreignTask") {
145
+ const foreignRefName = foreignTaskRefNames?.get(tool.target.name) ?? tool.target.refName ?? tool.target.name;
146
+ return {
147
+ kind: "raw",
148
+ entityType: "task",
149
+ name: tool.target.name,
150
+ refName: foreignRefName,
151
+ ...(tool.target.namespace !== undefined && { namespace: tool.target.namespace }),
152
+ };
153
+ }
144
154
  const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
145
- const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
155
+ const refNames = tool.target.kind === "foreignElement"
156
+ ? foreignElementRefNames
157
+ : foreignAppRefNames;
146
158
  const foreignRefName = tool.target.refName ?? refNames?.get(tool.target.name);
147
159
  return foreignRefName !== undefined
148
160
  ? refNames?.get(tool.target.name) !== undefined
@@ -156,7 +168,7 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
156
168
  }
157
169
  : { kind: "raw", entityType: entityKind, name: tool.target.name, refName: tool.target.name };
158
170
  }
159
- function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignFieldRefsById, foreignSearchTableRefsByName) {
171
+ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames, foreignFieldRefsById, foreignSearchTableRefsByName) {
160
172
  const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "skillSearchRecords";
161
173
  const lines = [`${factory}({`];
162
174
  const targetRefName = tool.target?.kind === "self"
@@ -165,7 +177,9 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
165
177
  ? tool.target.refName ?? foreignElementRefNames?.get(tool.target.name)
166
178
  : tool.target?.kind === "foreignApp"
167
179
  ? tool.target.refName ?? foreignAppRefNames?.get(tool.target.name)
168
- : undefined;
180
+ : tool.target?.kind === "foreignTask"
181
+ ? tool.target.refName ?? foreignTaskRefNames?.get(tool.target.name)
182
+ : undefined;
169
183
  lines.push(` name: ${quote(tool.name)},`);
170
184
  lines.push(` description: ${quote(tool.description)},`);
171
185
  if (tool.status !== undefined)
@@ -236,19 +250,18 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
236
250
  // platform response. Do not manufacture an empty unsafePlatformId.
237
251
  }
238
252
  else if (tool.target !== undefined) {
239
- // Board issue #42: the target can be a foreign APP or a foreign
240
- // ELEMENT — each stub carries the right `__kind` and is looked up
241
- // against its own map, never conflated.
242
- const entityKind = tool.target.kind === "foreignElement" ? "element" : "app";
243
- const refNames = tool.target.kind === "foreignElement" ? foreignElementRefNames : foreignAppRefNames;
253
+ const entityKind = tool.target.kind === "foreignElement" ? "element" : tool.target.kind === "foreignTask" ? "task" : "app";
254
+ const refNames = tool.target.kind === "foreignElement"
255
+ ? foreignElementRefNames
256
+ : tool.target.kind === "foreignTask"
257
+ ? foreignTaskRefNames
258
+ : foreignAppRefNames;
244
259
  const catalogRefName = refNames?.get(tool.target.name);
245
260
  if (catalogRefName !== undefined) {
246
- // The dependency is already pulled into this workspace (board issue
247
- // #40) — a typed token, not a stub.
248
261
  lines.push(` ${entityKind}: catalog.${catalogRefName},`);
249
262
  }
250
263
  else {
251
- // The foreign app/element's catalog may not exist in this workspace —
264
+ // The foreign app/element/task's catalog may not exist in this workspace —
252
265
  // a literal token compiles and deploys; swap for a catalog token when
253
266
  // available (`edk pull app`/`edk pull element` reports missing
254
267
  // dependencies like this one).
@@ -268,14 +281,14 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
268
281
  lines.push(` table: catalog.${targetRefName ?? appRefName}.searchTables${safeMember(tool.searchTableKey)},`);
269
282
  }
270
283
  else {
271
- const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
284
+ const targetNameOrUuid = tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement" || tool.target?.kind === "foreignTask"
272
285
  ? tool.target.name
273
286
  : tool.target?.kind === "tableOwned"
274
287
  ? tool.searchTableOwnerName
275
288
  : tool.target?.kind === "unresolved" ? tool.target.uuid : undefined;
276
289
  const parent = tool.target?.kind === "self"
277
290
  ? appRefName
278
- : tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement"
291
+ : tool.target?.kind === "foreignApp" || tool.target?.kind === "foreignElement" || tool.target?.kind === "foreignTask"
279
292
  ? tool.target.refName ?? targetNameOrUuid ?? ""
280
293
  : tool.target?.kind === "tableOwned"
281
294
  ? tool.searchTableOwnerRefName ?? targetNameOrUuid ?? ""
@@ -315,7 +328,7 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
315
328
  lines.push(` handleDescription: ${quote(tool.handleDescription)},`);
316
329
  }
317
330
  if (tool.fields !== undefined && tool.fields.length > 0) {
318
- const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
331
+ const owner = fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNames, foreignTaskRefNames);
319
332
  lines.push(" fields: [");
320
333
  for (const f of tool.fields) {
321
334
  // A foreign/out-of-scope aspect's field has no field resource ei can
@@ -88,6 +88,7 @@ export const skillModule = {
88
88
  ...(opts.crossOrg !== undefined && { crossOrg: opts.crossOrg }),
89
89
  ...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
90
90
  ...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
91
+ ...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
91
92
  ...(opts.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
92
93
  ...(opts.foreignTableRefsById !== undefined && { foreignTableRefsById: opts.foreignTableRefsById }),
93
94
  ...(opts.foreignSearchTableRefsByName !== undefined && {
@@ -115,6 +115,7 @@ export function skillToTf(entity, ctx) {
115
115
  ...(ctx.activeAutomationRefNames !== undefined && { activeAutomationRefNames: ctx.activeAutomationRefNames }),
116
116
  foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
117
117
  foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
118
+ foreignTaskRef: (l, n) => ctx.orgRefs.rawLookup("elementum_task", l, n),
118
119
  foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
119
120
  workspaceAspects: ctx.workspaceAspects,
120
121
  serviceAccountRef: (_label, serviceAccountName) => serviceAccountValue(serviceAccountName, ctx),
@@ -9,7 +9,7 @@
9
9
  * Search/record fields require `name` + `description` (matching the v1 skill
10
10
  * serializer, which always emits them).
11
11
  */
12
- import type { AgentRef, AppCatalogRef, AutomationCatalogRef, ElementCatalogRef, FieldRef, SearchTableRef, TableColumnRef, TableOwnedSearchTableRef } from "../../catalog/index.js";
12
+ import type { AgentRef, AppCatalogRef, AutomationCatalogRef, ElementCatalogRef, FieldRef, SearchTableRef, TableColumnRef, TableOwnedSearchTableRef, TaskCatalogRef } from "../../catalog/index.js";
13
13
  import type { UnsafePlatformId } from "../../core/platform-id.js";
14
14
  import type { AgentToolRunAs, OutputBagOf, RunAutomationOptionalInput, RunAutomationOutput, RunAutomationOutputs, TriggerBagOf } from "../agent/tools.js";
15
15
  declare const skillToolBrand: unique symbol;
@@ -18,15 +18,23 @@ export type SkillTool = Record<string, unknown> & {
18
18
  readonly [skillToolBrand]: "SkillTool";
19
19
  };
20
20
  export type SkillToolStatus = "ACTIVE" | "INACTIVE";
21
- type ToolTarget = AppCatalogRef | ElementCatalogRef;
21
+ type ToolTarget = AppCatalogRef | ElementCatalogRef | TaskCatalogRef;
22
22
  type TargetOption<Target extends ToolTarget> = Target extends {
23
23
  readonly __kind: "app";
24
24
  } ? {
25
25
  readonly app: Target;
26
26
  readonly element?: never;
27
- } : {
27
+ readonly task?: never;
28
+ } : Target extends {
29
+ readonly __kind: "element";
30
+ } ? {
28
31
  readonly app?: never;
29
32
  readonly element: Target;
33
+ readonly task?: never;
34
+ } : {
35
+ readonly app?: never;
36
+ readonly element?: never;
37
+ readonly task: Target;
30
38
  };
31
39
  export interface SkillSearchField<Target extends ToolTarget = ToolTarget> {
32
40
  readonly field: FieldRef<Target["refName"]>;
@@ -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 {
@@ -46,6 +46,12 @@ export type NormalizedSkillToolTarget = {
46
46
  readonly name: string;
47
47
  readonly refName?: string;
48
48
  readonly namespace?: string;
49
+ } | {
50
+ /** A foreign TASK via `data.elementum_task.<label>` — `name` from the stream's data block. */
51
+ readonly kind: "foreignTask";
52
+ readonly name: string;
53
+ readonly refName?: string;
54
+ readonly namespace?: string;
49
55
  } | {
50
56
  /**
51
57
  * `target_id` didn't resolve to any portable reference at export
@@ -238,7 +238,7 @@ export function skillToolFromTf(block, owner, ctx) {
238
238
  return undefined;
239
239
  }
240
240
  }
241
- else if (selfLabel === owner.appLabel) {
241
+ else if (owner.appLabel !== undefined && selfLabel === owner.appLabel) {
242
242
  target = { kind: "self" };
243
243
  }
244
244
  else if (isTfExpr(targetAttr) && targetAttr.$expr === "data-attr" && targetAttr.type === "elementum_app") {
@@ -277,6 +277,24 @@ export function skillToolFromTf(block, owner, ctx) {
277
277
  fieldScopeLabel = targetAttr.label;
278
278
  fieldScope = "element";
279
279
  }
280
+ else if (isTfExpr(targetAttr) && targetAttr.$expr === "data-attr" && targetAttr.type === "elementum_task") {
281
+ const taskName = dataAspectDisplayName(ctx, "task", targetAttr.label);
282
+ if (taskName === undefined) {
283
+ ctx.diagnostics.push(`${where}: target_id references data.elementum_task.${targetAttr.label} but the stream has no such data block; skipped`);
284
+ return undefined;
285
+ }
286
+ const attrs = ctx.dataAttrs?.("elementum_task", targetAttr.label);
287
+ const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
288
+ const refName = dataAspectRefName(ctx, "task", targetAttr.label, taskName);
289
+ target = {
290
+ kind: "foreignTask",
291
+ name: taskName,
292
+ ...(refName !== undefined && { refName }),
293
+ ...(namespace !== undefined && { namespace }),
294
+ };
295
+ fieldScopeLabel = targetAttr.label;
296
+ fieldScope = "task";
297
+ }
280
298
  else if (typeof targetAttr === "string") {
281
299
  // No portable reference was available at export time (ei fell back to
282
300
  // the raw platform UUID) — keep the tool with an unresolved target
@@ -26,6 +26,8 @@ export interface SkillToolToTfContext {
26
26
  foreignAppRef(tfLabel: string, name: string, namespace?: string): void;
27
27
  /** Records a foreign-ELEMENT data lookup for data.tf (board issue #42). */
28
28
  foreignElementRef(tfLabel: string, name: string, namespace?: string): void;
29
+ /** Records a foreign-TASK data lookup for data.tf. */
30
+ foreignTaskRef?(tfLabel: string, name: string, namespace?: string): void;
29
31
  /** Records an object-scoped data lookup owned by a foreign app/element. */
30
32
  foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string): void;
31
33
  /** App/element roots authored in this same workspace. */
@@ -45,7 +45,7 @@ function targetIdValue(token, ctx) {
45
45
  return { value: token.value, refName: token.value, kind: "app" };
46
46
  }
47
47
  const refName = token.refName ?? "";
48
- const kind = token.__kind === "element" ? "element" : "app";
48
+ const kind = token.__kind === "element" ? "element" : token.__kind === "task" ? "task" : "app";
49
49
  if (kind === "app" && refName === ctx.appRefName) {
50
50
  return {
51
51
  value: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
@@ -56,7 +56,7 @@ function targetIdValue(token, ctx) {
56
56
  }
57
57
  const sibling = ctx.workspaceAspects?.get(workspaceAspectKey(kind, refName));
58
58
  if (sibling !== undefined) {
59
- const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
59
+ const resourceType = kind === "element" ? "elementum_element" : kind === "task" ? "elementum_task" : "elementum_app";
60
60
  return {
61
61
  value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]),
62
62
  refName,
@@ -76,6 +76,15 @@ function targetIdValue(token, ctx) {
76
76
  foreignTfLabel: tfLabel,
77
77
  };
78
78
  }
79
+ if (kind === "task") {
80
+ ctx.foreignTaskRef?.(tfLabel, name, token.namespace);
81
+ return {
82
+ value: expr.dataAttr("elementum_task", tfLabel, ["id"]),
83
+ refName,
84
+ kind,
85
+ foreignTfLabel: tfLabel,
86
+ };
87
+ }
79
88
  ctx.foreignAppRef(tfLabel, name, token.namespace);
80
89
  return {
81
90
  value: expr.dataAttr("elementum_app", tfLabel, ["id"]),
@@ -115,7 +124,7 @@ function fieldRefValue(token, where, ctx, target) {
115
124
  ctx.diagnostics.push(`${where}: field "${refName}" belongs to ${parentKind} "${parent}", not the tool's target ${target.kind} "${target.refName}" — a tool's fields must belong to its own target aspect; dropped`);
116
125
  return undefined;
117
126
  }
118
- if (target.localTfLabel === undefined) {
127
+ if (target.localTfLabel === undefined || target.kind === "task") {
119
128
  return foreignTargetFieldRefValue(token, refName, target, ctx);
120
129
  }
121
130
  const authoringType = token.fieldType ?? "";
@@ -298,7 +307,7 @@ export function skillToolToTf(entry, ctx) {
298
307
  : table.__variant === "table"
299
308
  ? "elementum_table_search_table"
300
309
  : "elementum_ai_search_table";
301
- attrs["search_table_id"] = expr.resourceAttr(resourceType, scopedResourceLabel(target.localTfLabel, tsLabelToTfLabel(table.refName), target.kind), ["id"]);
310
+ attrs["search_table_id"] = expr.resourceAttr(resourceType, scopedResourceLabel(target.localTfLabel, tsLabelToTfLabel(table.refName), target.kind === "element" ? "element" : "app"), ["id"]);
302
311
  }
303
312
  }
304
313
  if (typeKey === "updateRecord") {
@@ -6,7 +6,7 @@ function extract(stream, ctx) { const blocks = stream.byKind.get("task") ?? [];
6
6
  throw new Error(`expected exactly one ${TASK_RESOURCE_TYPE}, found ${blocks.length}`); return { instance: taskFromTf(blocks[0], ctx) }; }
7
7
  export const taskModule = {
8
8
  kind: "task", stream: { role: "streamRoot", exportVerb: "tasks" }, authoring: { unit: "ownFile", bag: "tasks" }, parents: [{ parent: "org", child: "task" }],
9
- resource: { shape: "single", resourceType: TASK_RESOURCE_TYPE, adoptable: true }, data: { participates: true, lookupAttr: "name", referencedByBuild: false },
9
+ resource: { shape: "single", resourceType: TASK_RESOURCE_TYPE, adoptable: true }, data: { participates: true, lookupAttr: "name", referencedByBuild: true, referenceLookups: [{ strategy: "rootNamespace", compatibilityFallback: "name" }] },
10
10
  lifecycle: { participates: true, extractStreamRoot: extract, toTf: (entity, ctx) => taskToTf(entity, { orgRefs: ctx.orgRefs, diagnostics: ctx.diagnostics }) },
11
11
  canvas: { participates: true, label: "Tasks", glyph: "☑", component: "appDetail" }, catalog: NO_CATALOG,
12
12
  };
@@ -213,7 +213,7 @@ function widgetFieldRef(value, target, owner, ctx) {
213
213
  : target.key === owner.ownerRefName
214
214
  ? owner.ownerTfLabel
215
215
  : target.namespace ?? tsLabelToTfLabel(target.key);
216
- const targetScope = typeof target === "string" || target.kind === "automation" || target.kind === "field" || target.kind === "recordIdentity" ? owner.scope : target.kind;
216
+ const targetScope = typeof target === "string" || target.kind === "automation" || target.kind === "field" || target.kind === "recordIdentity" || target.kind === "task" ? owner.scope : target.kind;
217
217
  if (targetLabel !== undefined) {
218
218
  const key = fieldKeyFromTfRef(value, targetLabel, targetScope);
219
219
  if (key !== undefined) {
@@ -323,7 +323,7 @@ function fieldRefFromRawId(id, target, owner, ctx) {
323
323
  fieldType: subType.authoringType,
324
324
  };
325
325
  }
326
- if (typeof target !== "string" && target.kind !== "automation" && target.kind !== "field" && target.kind !== "recordIdentity") {
326
+ if (typeof target !== "string" && target.kind !== "automation" && target.kind !== "field" && target.kind !== "recordIdentity" && target.kind !== "task") {
327
327
  const targetTfLabel = target.key === owner.ownerRefName
328
328
  ? owner.ownerTfLabel
329
329
  : target.namespace ?? tsLabelToTfLabel(target.key);
@@ -89,6 +89,8 @@ export declare function ownFileChildrenOf(parent: KindId): readonly EntityKindMo
89
89
  export declare function ownFileCatalogChildrenOf(parent: KindId): readonly EntityKindModule[];
90
90
  /** All own-file bags declared under a parent (including stubs without lifecycle). */
91
91
  export declare function ownFileBagsUnder(parent: KindId): readonly string[];
92
+ /** Own-file bag -> printer-owned companion subfolders (skipped when looking for entity files). */
93
+ export declare function companionDirsByBag(): ReadonlyMap<string, ReadonlySet<string>>;
92
94
  /** Org-root own-file bags (apps, tables, …) — authoring path roots. */
93
95
  export declare function orgRootOwnFileBags(): readonly string[];
94
96
  /** Parent edges for tests / docs. */
@@ -126,6 +126,20 @@ export function ownFileBagsUnder(parent) {
126
126
  }
127
127
  return [...bags].sort();
128
128
  }
129
+ /** Own-file bag -> printer-owned companion subfolders (skipped when looking for entity files). */
130
+ export function companionDirsByBag() {
131
+ const out = new Map();
132
+ for (const m of KIND_MODULES) {
133
+ const dirs = m.lifecycle.participates ? m.lifecycle.companionDirs : undefined;
134
+ if (m.authoring.unit !== "ownFile" || dirs === undefined)
135
+ continue;
136
+ const set = out.get(m.authoring.bag) ?? new Set();
137
+ for (const dir of dirs)
138
+ set.add(dir);
139
+ out.set(m.authoring.bag, set);
140
+ }
141
+ return out;
142
+ }
129
143
  /** Org-root own-file bags (apps, tables, …) — authoring path roots. */
130
144
  export function orgRootOwnFileBags() {
131
145
  return ownFileBagsUnder("org");
@@ -262,6 +262,14 @@ export interface AdoptionAddressAlias {
262
262
  export interface PrintedOwnFile {
263
263
  readonly refName: string;
264
264
  readonly source: string;
265
+ /**
266
+ * Extra files printed with this one (e.g. an automation's plain-JS script
267
+ * files). `path` is relative to the kind's own folder (`automations/`).
268
+ */
269
+ readonly companionFiles?: readonly {
270
+ readonly path: string;
271
+ readonly content: string;
272
+ }[];
265
273
  }
266
274
  /** Bridge diagnostic attached to a raw, source-organization-only UUID fallback. */
267
275
  export interface UnresolvedReferenceDiagnostic {
@@ -320,6 +328,12 @@ export interface PrintOwnFileOptions {
320
328
  * prints `catalog.<refName>` instead of the literal stub.
321
329
  */
322
330
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
331
+ /**
332
+ * Same as {@link foreignAppRefNames}, keyed for tasks (#1011) — a
333
+ * task target whose name is a key here prints `catalog.<refName>` instead
334
+ * of the literal stub.
335
+ */
336
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
323
337
  /**
324
338
  * Live field id → pulled catalog identity. Recursive pull populates this
325
339
  * from each dependency export's import blocks so a root export that can
@@ -378,7 +392,7 @@ export interface BuildChildContext {
378
392
  readonly allowUnknownPicklistOptions?: boolean;
379
393
  /** Every app/element/table stream root in this build, by refName (see `ToTfContext.workspaceAspects`). */
380
394
  readonly workspaceAspects?: ReadonlyMap<string, {
381
- readonly kind: ChildResourceScope | "table";
395
+ readonly kind: ChildResourceScope | "table" | "task";
382
396
  readonly tfLabel: string;
383
397
  readonly streamRootEntity?: DeployableEntity;
384
398
  }>;
@@ -457,6 +471,18 @@ export type LifecycleFacet = {
457
471
  * (plus the full partitioned stream for cross-block grouping).
458
472
  */
459
473
  readonly extractOwnFile?: (ownBlocks: readonly TfBlock[], stream: StreamPartition, ctx: StreamExtractContext) => OwnFileExtractResult;
474
+ /**
475
+ * Subfolders of this kind's own folder that hold printer-owned
476
+ * companion files (e.g. `scripts` under `automations/`). Walkers that
477
+ * look for entity source files skip them. After a complete pull, files
478
+ * in them that no source file of the kind references are archived.
479
+ */
480
+ readonly companionDirs?: readonly string[];
481
+ /**
482
+ * Paths of the companion files a source file references, as written in
483
+ * the source (relative to its folder). Required for the pruning above.
484
+ */
485
+ readonly companionRefs?: (source: string) => readonly string[];
460
486
  /** Print one extracted own-file instance to TypeScript source. */
461
487
  readonly printOwnFile?: (item: unknown, opts: PrintOwnFileOptions) => PrintedOwnFile;
462
488
  /** Re-pull: preserve author-owned values that the live export cannot represent. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementumai/edk",
3
- "version": "0.9.14",
3
+ "version": "0.9.15",
4
4
  "description": "Elementum Development Kit — statically typed SDK for building Elementum apps, automations, and agents",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",