@elementumai/edk 0.9.17 → 0.9.19

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 (130) hide show
  1. package/README.md +8 -3
  2. package/dist-sdk/src/catalog/factories.d.ts +11 -0
  3. package/dist-sdk/src/catalog/factories.js +6 -0
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +2 -2
  6. package/dist-sdk/src/catalog/org.d.ts +39 -1
  7. package/dist-sdk/src/catalog/org.js +460 -50
  8. package/dist-sdk/src/catalog/types.d.ts +12 -2
  9. package/dist-sdk/src/catalog/types.js +2 -0
  10. package/dist-sdk/src/engine/pull/ref-only.js +54 -20
  11. package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
  12. package/dist-sdk/src/engine/pull/result-output.js +1 -1
  13. package/dist-sdk/src/engine/tf/expr.js +38 -13
  14. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  15. package/dist-sdk/src/engine/tf/index.js +2 -2
  16. package/dist-sdk/src/engine/tf/labels.d.ts +2 -0
  17. package/dist-sdk/src/engine/tf/labels.js +4 -0
  18. package/dist-sdk/src/engine/tf/parse.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/parse.js +105 -6
  20. package/dist-sdk/src/engine/workspace/loader.js +49 -12
  21. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +11 -1
  22. package/dist-sdk/src/entities/access-policy/from-tf.js +6 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +11 -0
  24. package/dist-sdk/src/entities/access-policy/to-tf.js +11 -4
  25. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -1
  26. package/dist-sdk/src/entities/app/build.d.ts +10 -0
  27. package/dist-sdk/src/entities/app/build.js +0 -13
  28. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
  29. package/dist-sdk/src/entities/app/from-tf.js +4 -3
  30. package/dist-sdk/src/entities/app/index.d.ts +2 -0
  31. package/dist-sdk/src/entities/app/index.js +1 -0
  32. package/dist-sdk/src/entities/app/module.js +13 -0
  33. package/dist-sdk/src/entities/app/to-tf.js +2 -0
  34. package/dist-sdk/src/entities/automation/build.d.ts +2 -1
  35. package/dist-sdk/src/entities/automation/build.js +27 -0
  36. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +6 -0
  37. package/dist-sdk/src/entities/automation/from-tf.js +156 -26
  38. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  39. package/dist-sdk/src/entities/automation/module.d.ts +2 -0
  40. package/dist-sdk/src/entities/automation/module.js +56 -0
  41. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -4
  42. package/dist-sdk/src/entities/automation/output-field-types.js +23 -5
  43. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +16 -0
  44. package/dist-sdk/src/entities/automation/system-ref-name.js +44 -0
  45. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +15 -0
  46. package/dist-sdk/src/entities/automation/task-output-labels.js +38 -0
  47. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -5
  48. package/dist-sdk/src/entities/automation/tasks.js +23 -1
  49. package/dist-sdk/src/entities/automation/to-tf.js +158 -84
  50. package/dist-sdk/src/entities/automation/types.js +1 -0
  51. package/dist-sdk/src/entities/chart/from-tf.js +33 -17
  52. package/dist-sdk/src/entities/chart/module.js +3 -1
  53. package/dist-sdk/src/entities/chart/printer.d.ts +1 -0
  54. package/dist-sdk/src/entities/chart/printer.js +26 -16
  55. package/dist-sdk/src/entities/chart/rebind-owner.d.ts +3 -0
  56. package/dist-sdk/src/entities/chart/rebind-owner.js +42 -0
  57. package/dist-sdk/src/entities/chart/to-tf.js +12 -10
  58. package/dist-sdk/src/entities/dashboard/build.d.ts +4 -0
  59. package/dist-sdk/src/entities/dashboard/from-tf.js +15 -4
  60. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
  61. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  62. package/dist-sdk/src/entities/dashboard-widget/module.js +4 -0
  63. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +51 -2
  64. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +3 -0
  65. package/dist-sdk/src/entities/dynamic-layout/dialect.js +5 -0
  66. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +9 -6
  67. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +188 -26
  68. package/dist-sdk/src/entities/dynamic-layout/module.js +4 -1
  69. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +5 -1
  70. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +254 -23
  71. package/dist-sdk/src/entities/element/build.d.ts +8 -0
  72. package/dist-sdk/src/entities/element/build.js +1 -0
  73. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  74. package/dist-sdk/src/entities/element/from-tf.js +6 -2
  75. package/dist-sdk/src/entities/element/index.d.ts +1 -0
  76. package/dist-sdk/src/entities/element/index.js +1 -0
  77. package/dist-sdk/src/entities/element/module.js +2 -0
  78. package/dist-sdk/src/entities/element/to-tf.js +12 -0
  79. package/dist-sdk/src/entities/field/from-tf.d.ts +2 -0
  80. package/dist-sdk/src/entities/field/from-tf.js +11 -0
  81. package/dist-sdk/src/entities/field/to-tf.js +13 -9
  82. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -1
  83. package/dist-sdk/src/entities/relationship/from-tf.js +53 -10
  84. package/dist-sdk/src/entities/relationship/to-tf.d.ts +8 -0
  85. package/dist-sdk/src/entities/relationship/to-tf.js +19 -10
  86. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -2
  87. package/dist-sdk/src/entities/shared/filters/index.d.ts +23 -2
  88. package/dist-sdk/src/entities/shared/filters/index.js +24 -1
  89. package/dist-sdk/src/entities/shared/filters/print.js +22 -4
  90. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +23 -3
  91. package/dist-sdk/src/entities/shared/filters/tf-codec.js +60 -18
  92. package/dist-sdk/src/entities/shared/filters/types.d.ts +13 -4
  93. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +16 -0
  94. package/dist-sdk/src/entities/shared/foreign-ref.js +17 -1
  95. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -9
  96. package/dist-sdk/src/entities/skill/access-policy.d.ts +17 -0
  97. package/dist-sdk/src/entities/skill/access-policy.js +101 -0
  98. package/dist-sdk/src/entities/skill/build.d.ts +3 -0
  99. package/dist-sdk/src/entities/skill/build.js +3 -0
  100. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +4 -1
  101. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +21 -0
  102. package/dist-sdk/src/entities/skill/from-tf.d.ts +2 -0
  103. package/dist-sdk/src/entities/skill/from-tf.js +4 -9
  104. package/dist-sdk/src/entities/skill/index.d.ts +2 -0
  105. package/dist-sdk/src/entities/skill/index.js +1 -0
  106. package/dist-sdk/src/entities/skill/module.js +1 -0
  107. package/dist-sdk/src/entities/skill/to-tf.d.ts +2 -2
  108. package/dist-sdk/src/entities/skill/to-tf.js +5 -2
  109. package/dist-sdk/src/entities/skill-tool/to-tf.js +2 -1
  110. package/dist-sdk/src/entities/table/to-tf.js +3 -3
  111. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -0
  112. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +224 -0
  113. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +36 -0
  114. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +288 -0
  115. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +121 -0
  116. package/dist-sdk/src/entities/view/agent-view-layout.js +21 -0
  117. package/dist-sdk/src/entities/view/from-tf.d.ts +3 -1
  118. package/dist-sdk/src/entities/view/from-tf.js +42 -7
  119. package/dist-sdk/src/entities/view/ragnarok.d.ts +7 -0
  120. package/dist-sdk/src/entities/view/ragnarok.js +1 -0
  121. package/dist-sdk/src/entities/view/to-tf.d.ts +10 -1
  122. package/dist-sdk/src/entities/view/to-tf.js +30 -1
  123. package/dist-sdk/src/entities/view/types.js +2 -0
  124. package/dist-sdk/src/entities/widget/to-tf.js +2 -2
  125. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +815 -0
  126. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +5 -0
  127. package/dist-sdk/src/graph/index.d.ts +43 -0
  128. package/dist-sdk/src/graph/index.js +9 -0
  129. package/dist-sdk/src/graph/types.d.ts +78 -0
  130. package/package.json +11 -1
@@ -0,0 +1,17 @@
1
+ import type { GroupRef } from "../../catalog/index.js";
2
+ import type { OrgRefLookup } from "../../engine/build/context.js";
3
+ import { type FromTfContext } from "../../engine/pull/context.js";
4
+ import { type TfValue } from "../../engine/tf/index.js";
5
+ import type { RoleUserRef } from "../role/build.js";
6
+ /** A portable user identity for a skill visibility grant. */
7
+ export type SkillUserRef = RoleUserRef;
8
+ /** Restrict skill visibility to these users or group members. Empty lists remove the restriction. */
9
+ export interface SkillAccessPolicy {
10
+ readonly users?: readonly SkillUserRef[];
11
+ readonly groups?: readonly GroupRef[];
12
+ }
13
+ /** Validate the complete policy before emitting any access-changing configuration. */
14
+ export declare function normalizeSkillAccessPolicy(value: unknown): SkillAccessPolicy;
15
+ export declare function skillAccessPolicyToTf(value: unknown, orgRefs: OrgRefLookup): Record<string, TfValue>;
16
+ /** Any unresolved principal blocks pull; dropping even one could broaden access on the next apply. */
17
+ export declare function skillAccessPolicyFromTf(attrs: Readonly<Record<string, TfValue>>, ctx: FromTfContext): SkillAccessPolicy | undefined;
@@ -0,0 +1,101 @@
1
+ import { EntityTfError } from "../../engine/entity.js";
2
+ import { dataRefLabel } from "../../engine/pull/context.js";
3
+ import { expr, sanitizeName, tfLabelToTsLabel } from "../../engine/tf/index.js";
4
+ function object(value) {
5
+ return value !== null && typeof value === "object" && !Array.isArray(value);
6
+ }
7
+ /** Validate the complete policy before emitting any access-changing configuration. */
8
+ export function normalizeSkillAccessPolicy(value) {
9
+ if (!object(value))
10
+ throw new EntityTfError("skill accessPolicy must contain portable users or groups");
11
+ for (const key of Object.keys(value))
12
+ if (key !== "users" && key !== "groups")
13
+ throw new EntityTfError(`skill accessPolicy has unsupported key ${JSON.stringify(key)}`);
14
+ const out = {};
15
+ for (const key of ["users", "groups"]) {
16
+ const entries = value[key];
17
+ if (entries === undefined)
18
+ continue;
19
+ if (!Array.isArray(entries))
20
+ throw new EntityTfError(`skill accessPolicy.${key} must be a list of portable references`);
21
+ if (key === "users") {
22
+ const users = new Map();
23
+ for (const entry of entries) {
24
+ if (!object(entry) || entry.__kind !== "user" || typeof entry.email !== "string" || !/^[^\s@]+@[^\s@]+$/.test(entry.email)) {
25
+ throw new EntityTfError("skill accessPolicy.users requires userRef(email); raw IDs and other principal kinds are unsupported");
26
+ }
27
+ users.set(entry.email, { __kind: "user", email: entry.email });
28
+ }
29
+ out.users = [...users.values()];
30
+ }
31
+ else {
32
+ const groups = new Map();
33
+ for (const entry of entries) {
34
+ if (!object(entry) || entry.__kind !== "group" || typeof entry.refName !== "string" || entry.refName.trim() === "" || typeof entry.name !== "string" || entry.name.trim() === "") {
35
+ throw new EntityTfError("skill accessPolicy.groups requires an org.groups reference; raw IDs and other principal kinds are unsupported");
36
+ }
37
+ const previous = groups.get(entry.refName);
38
+ if (previous !== undefined && previous.name !== entry.name)
39
+ throw new EntityTfError(`skill accessPolicy.groups has conflicting names for ${JSON.stringify(entry.refName)}`);
40
+ groups.set(entry.refName, { __kind: "group", refName: entry.refName, name: entry.name });
41
+ }
42
+ out.groups = [...groups.values()];
43
+ }
44
+ }
45
+ return Object.keys(out).length === 0 ? { users: [], groups: [] } : out;
46
+ }
47
+ export function skillAccessPolicyToTf(value, orgRefs) {
48
+ const policy = normalizeSkillAccessPolicy(value);
49
+ const out = {};
50
+ const labels = new Map();
51
+ if (policy.users !== undefined)
52
+ out.user_ids = policy.users.map((user) => {
53
+ const label = sanitizeName(user.email.split("@", 1)[0]);
54
+ const previous = labels.get(label);
55
+ if (previous !== undefined && previous !== user.email)
56
+ throw new EntityTfError(`skill accessPolicy.users has colliding email lookup label ${JSON.stringify(label)}`);
57
+ labels.set(label, user.email);
58
+ orgRefs.rawLookup("elementum_user", label, user.email);
59
+ return expr.dataAttr("elementum_user", label, ["id"]);
60
+ });
61
+ if (policy.groups !== undefined)
62
+ out.group_ids = policy.groups.map((group) => {
63
+ const resolved = orgRefs.byTsLabel("groups", group.refName);
64
+ if (resolved === undefined)
65
+ throw new EntityTfError(`skill accessPolicy group ${JSON.stringify(group.refName)} is not in org.ts`);
66
+ return resolved.managed
67
+ ? expr.resourceAttr("elementum_group", resolved.tfLabel, ["id"])
68
+ : expr.dataAttr("elementum_group", resolved.tfLabel, ["id"]);
69
+ });
70
+ return out;
71
+ }
72
+ /** Any unresolved principal blocks pull; dropping even one could broaden access on the next apply. */
73
+ export function skillAccessPolicyFromTf(attrs, ctx) {
74
+ if (attrs.user_ids === undefined && attrs.group_ids === undefined)
75
+ return undefined;
76
+ const policy = {};
77
+ for (const [key, type, output] of [["user_ids", "elementum_user", "users"], ["group_ids", "elementum_group", "groups"]]) {
78
+ const values = attrs[key];
79
+ if (values === undefined)
80
+ continue;
81
+ if (!Array.isArray(values))
82
+ throw new EntityTfError(`skill access policy ${key} must be a list; refusing to omit a restriction`);
83
+ const users = [];
84
+ const groups = [];
85
+ for (const value of values) {
86
+ const label = dataRefLabel(value, type);
87
+ const identity = label === undefined ? undefined : ctx.dataName(type, label);
88
+ if (label === undefined || identity === undefined || identity.trim() === "")
89
+ throw new EntityTfError(`skill access policy ${key} contains an unresolved principal; refusing to omit a restriction`);
90
+ if (output === "users")
91
+ users.push({ __kind: "user", email: identity });
92
+ else
93
+ groups.push({ __kind: "group", refName: tfLabelToTsLabel(label), name: identity });
94
+ }
95
+ if (output === "users")
96
+ policy.users = users;
97
+ else
98
+ policy.groups = groups;
99
+ }
100
+ return normalizeSkillAccessPolicy(policy);
101
+ }
@@ -1,6 +1,7 @@
1
1
  import type { CatalogRef, SkillRef } from "../../catalog/index.js";
2
2
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
3
3
  import type { SkillTool } from "./tools.js";
4
+ import { type SkillAccessPolicy } from "./access-policy.js";
4
5
  export interface SkillInputSpec {
5
6
  /** Optional explicit field name (defaults to the record key when using an object shape). */
6
7
  readonly name?: string;
@@ -29,6 +30,8 @@ export type SkillV2Options = EntityDeployOptions & {
29
30
  readonly properties?: Record<string, unknown>;
30
31
  /** Typed discovery signals used when routing user requests to this skill. */
31
32
  readonly discovery?: SkillDiscoveryOptions;
33
+ /** Restrict visibility to portable users/group members. Omission or empty lists removes an existing policy; no policy is open to otherwise-authorized users. */
34
+ readonly accessPolicy?: SkillAccessPolicy;
32
35
  readonly tools?: readonly SkillTool[];
33
36
  } & ({
34
37
  /**
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import { slimTokens } from "../../catalog/index.js";
14
14
  import { deriveSkillInstructions, } from "./input-coverage.js";
15
+ import { normalizeSkillAccessPolicy } from "./access-policy.js";
15
16
  /**
16
17
  * `name` is a free-text display name, like an agent's — confirmed against
17
18
  * the platform's actual create/update path, which only rejects a blank
@@ -74,6 +75,7 @@ export function skill(opts) {
74
75
  throw new Error("skill discovery.routingPriority must be a finite number from -100 to 100");
75
76
  }
76
77
  const normalizedInputs = normalizeInputs(opts.inputs);
78
+ const accessPolicy = opts.accessPolicy === undefined ? undefined : normalizeSkillAccessPolicy(opts.accessPolicy);
77
79
  const normalizedLookups = normalizeLookups(opts.lookups);
78
80
  const instructions = deriveSkillInstructions(opts.instructions, normalizedInputs, normalizedLookups);
79
81
  if (instructions.trim() === "") {
@@ -98,6 +100,7 @@ export function skill(opts) {
98
100
  type: "CUSTOM",
99
101
  ...(opts.properties !== undefined ? { properties: opts.properties } : {}),
100
102
  ...(opts.discovery !== undefined ? { discovery: opts.discovery } : {}),
103
+ ...(accessPolicy !== undefined ? { accessPolicy } : {}),
101
104
  },
102
105
  tools: opts.tools ?? [],
103
106
  }),
@@ -16,10 +16,13 @@ import type { NormalizedSkill } from "../from-tf.js";
16
16
  export interface PrintSkillV2Options {
17
17
  /** The owning app's refName — `parent:` and the catalog token root. */
18
18
  readonly appRefName: string;
19
+ /** Relative import of the workspace's portable org catalog. */
20
+ readonly orgImportPath?: string;
19
21
  /**
20
22
  * Set for a cross-org clone: a foreign-app tool target was resolved
21
23
  * against the SOURCE org, so it's flagged as a TODO for manual review
22
- * instead of silently carried over — same treatment as agent tools
24
+ * instead of silently carried over. Access-policy groups require explicit
25
+ * destination review and print a build-blocking placeholder — same treatment as agent tools
23
26
  * (`src/entities/agent/deserializer/print-agent-v2.ts`).
24
27
  */
25
28
  readonly crossOrg?: boolean;
@@ -46,6 +46,7 @@ export function printSkillV2(skill, opts) {
46
46
  const factories = [
47
47
  ...new Set([
48
48
  ...skill.tools.map((t) => TOOL_FACTORY_BY_TYPE_KEY[t.typeKey]).filter(Boolean),
49
+ ...((skill.accessPolicy?.users?.length ?? 0) > 0 ? ["userRef"] : []),
49
50
  ...(skill.tools.some((t) => t.runAs !== undefined && "serviceAccount" in t.runAs)
50
51
  ? ["serviceAccountRef"]
51
52
  : []),
@@ -68,6 +69,8 @@ export function printSkillV2(skill, opts) {
68
69
  if (skill.tools.some((tool) => tool.typeKey === "searchTable" && tool.target?.kind === "tableOwned")) {
69
70
  lines.push(`import { tableSearchTableRef } from ${JSON.stringify(sdkPackageSpecifier("catalog"))};`);
70
71
  }
72
+ if ((skill.accessPolicy?.groups?.length ?? 0) > 0)
73
+ lines.push(`import { org } from ${quote(opts.orgImportPath ?? "../../../org.js")};`);
71
74
  if (usesUnsafePlatformId)
72
75
  lines.push(`import { unsafePlatformId } from ${JSON.stringify(sdkPackageSpecifier("core"))};`);
73
76
  lines.push(`import catalog from "@catalog";`);
@@ -115,6 +118,24 @@ export function printSkillV2(skill, opts) {
115
118
  if (skill.discovery !== undefined) {
116
119
  lines.push(` discovery: ${JSON.stringify(skill.discovery)},`);
117
120
  }
121
+ if (skill.accessPolicy !== undefined) {
122
+ lines.push(" accessPolicy: {");
123
+ if (skill.accessPolicy.users !== undefined)
124
+ lines.push(` users: [${skill.accessPolicy.users.map((user) => `userRef(${quote(user.email)})`).join(", ")}],`);
125
+ if (skill.accessPolicy.groups !== undefined) {
126
+ if (crossOrg && skill.accessPolicy.groups.length > 0) {
127
+ lines.push(" groups: [");
128
+ for (const group of skill.accessPolicy.groups) {
129
+ lines.push(` TODO_DESTINATION_GROUP, // TODO: cross-org clone — verify the destination group's membership, then replace with org.groups.<key> for source group ${quote(group.name)}.`);
130
+ }
131
+ lines.push(" ],");
132
+ }
133
+ else {
134
+ lines.push(` groups: [${skill.accessPolicy.groups.map((group) => `org.groups${safeMember(group.refName)}`).join(", ")}],`);
135
+ }
136
+ }
137
+ lines.push(" },");
138
+ }
118
139
  if (skill.tools.length > 0) {
119
140
  lines.push(" tools: [");
120
141
  for (const tool of skill.tools) {
@@ -9,6 +9,7 @@ import { type FromTfContext } from "../../engine/pull/context.js";
9
9
  import { type TfBlock } from "../../engine/tf/index.js";
10
10
  import { type NormalizedSkillTool } from "../skill-tool/from-tf.js";
11
11
  import { type SkillInputDefinition, type SkillLookupDefinition } from "./input-coverage.js";
12
+ import { type SkillAccessPolicy } from "./access-policy.js";
12
13
  export interface NormalizedSkillDiscovery {
13
14
  readonly routingPriority?: number;
14
15
  readonly aliases?: readonly string[];
@@ -28,6 +29,7 @@ export interface NormalizedSkill {
28
29
  readonly status?: "ACTIVE" | "INACTIVE";
29
30
  readonly properties?: Record<string, unknown>;
30
31
  readonly discovery?: NormalizedSkillDiscovery;
32
+ readonly accessPolicy?: SkillAccessPolicy;
31
33
  readonly tools: readonly NormalizedSkillTool[];
32
34
  }
33
35
  export interface SkillFromTfResult {
@@ -12,6 +12,7 @@ import { skillToolFromTf } from "../skill-tool/from-tf.js";
12
12
  import { APP_RESOURCE_TYPE } from "../app/module.js";
13
13
  import { analyzeSkillInputCoverage, decomposeSkillInstructions, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
14
14
  import { SKILL_RESOURCE_TYPE } from "./module.js";
15
+ import { skillAccessPolicyFromTf } from "./access-policy.js";
15
16
  /** Attributes `skillFromTf` understands — anything else is dialect growth, reported loudly. */
16
17
  const KNOWN_SKILL_ATTRS = new Set([
17
18
  "owner_id",
@@ -28,9 +29,6 @@ const KNOWN_SKILL_ATTRS = new Set([
28
29
  "positive_keywords",
29
30
  "negative_keywords",
30
31
  "depends_on",
31
- ]);
32
- /** Dialect attrs with no authoring slot yet — reported by name, skill still pulled. */
33
- const UNAUTHORABLE_SKILL_ATTRS = new Set([
34
32
  "user_ids",
35
33
  "group_ids",
36
34
  ]);
@@ -61,12 +59,7 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
61
59
  for (const key of Object.keys(attrs)) {
62
60
  if (KNOWN_SKILL_ATTRS.has(key))
63
61
  continue;
64
- if (UNAUTHORABLE_SKILL_ATTRS.has(key)) {
65
- ctx.diagnostics.push(`${where}: ${key} has no authoring slot on the terraform path yet; a rebuilt stream will omit it`);
66
- }
67
- else {
68
- ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — the export dialect grew; extend skillFromTf deliberately`);
69
- }
62
+ ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — the export dialect grew; extend skillFromTf deliberately`);
70
63
  }
71
64
  const ownerType = attrs["owner_type"];
72
65
  if (ownerType !== "APP_ASPECT") {
@@ -86,6 +79,7 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
86
79
  }
87
80
  }
88
81
  const status = optionalString(attrs, "status", where, ctx);
82
+ const accessPolicy = skillAccessPolicyFromTf(attrs, ctx);
89
83
  const routingPriority = attrs["routing_priority"];
90
84
  if (routingPriority !== undefined && typeof routingPriority !== "number") {
91
85
  ctx.diagnostics.push(`${where}: routing_priority must be a number; dropped`);
@@ -132,6 +126,7 @@ export function skillFromTf(skillBlock, toolBlocks, appLabel, ctx) {
132
126
  ...((status === "ACTIVE" || status === "INACTIVE") && { status }),
133
127
  ...(properties !== undefined && { properties }),
134
128
  ...(Object.keys(discovery).length > 0 && { discovery }),
129
+ ...(accessPolicy !== undefined && { accessPolicy }),
135
130
  tools,
136
131
  },
137
132
  };
@@ -4,5 +4,7 @@
4
4
  * reference position. Standalone from v1.
5
5
  */
6
6
  export { skill, type SkillConfigured, type SkillDiscoveryOptions, type SkillInputSpec, type SkillInputsOption, type SkillLookupSpec, type SkillLookupsOption, type SkillV2Options, } from "./build.js";
7
+ export { type SkillAccessPolicy, type SkillUserRef } from "./access-policy.js";
8
+ export { userRef } from "../role/build.js";
7
9
  export { serviceAccountRef, type AgentToolRunAs, type ServiceAccountRef, } from "../agent/run-as.js";
8
10
  export { skillAutomation, skillCreateRecord, skillRunAgent, skillSearchRecords, skillSearchTable, skillUpdateRecord, type SkillRecordField, type SkillRecordFieldInput, type SkillRecordRawIdField, type SkillSearchField, type SkillSearchFieldInput, type SkillSearchRawIdField, type SkillToolStatus, type SkillTool, } from "./tools.js";
@@ -4,5 +4,6 @@
4
4
  * reference position. Standalone from v1.
5
5
  */
6
6
  export { skill, } from "./build.js";
7
+ export { userRef } from "../role/build.js";
7
8
  export { serviceAccountRef, } from "../agent/run-as.js";
8
9
  export { skillAutomation, skillCreateRecord, skillRunAgent, skillSearchRecords, skillSearchTable, skillUpdateRecord, } from "./tools.js";
@@ -85,6 +85,7 @@ export const skillModule = {
85
85
  refName: skill.refName,
86
86
  source: printSkillV2(skill, {
87
87
  appRefName: opts.appRefName,
88
+ orgImportPath: opts.orgImportPath,
88
89
  ...(opts.crossOrg !== undefined && { crossOrg: opts.crossOrg }),
89
90
  ...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
90
91
  ...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
@@ -9,8 +9,8 @@
9
9
  * repo — not `pristine-refactor`'s older, generic single-tool-resource
10
10
  * shape): `owner_id`/`owner_type` as the owning app's resource ref +
11
11
  * `"APP_ASPECT"`, `name`/`description`/`instructions`/`status`/`type`/
12
- * `properties`, plus typed discovery/routing fields. Access policy
13
- * (user_ids/group_ids) is not authored yet.
12
+ * `properties`, typed discovery/routing fields, and portable access-policy
13
+ * user/group references.
14
14
  */
15
15
  import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
16
16
  import { type DeployableEntity } from "../../engine/entity.js";
@@ -9,8 +9,8 @@
9
9
  * repo — not `pristine-refactor`'s older, generic single-tool-resource
10
10
  * shape): `owner_id`/`owner_type` as the owning app's resource ref +
11
11
  * `"APP_ASPECT"`, `name`/`description`/`instructions`/`status`/`type`/
12
- * `properties`, plus typed discovery/routing fields. Access policy
13
- * (user_ids/group_ids) is not authored yet.
12
+ * `properties`, typed discovery/routing fields, and portable access-policy
13
+ * user/group references.
14
14
  */
15
15
  import { workspaceAspectKey } from "../../engine/build/context.js";
16
16
  import { EntityTfError } from "../../engine/entity.js";
@@ -20,6 +20,7 @@ import { APP_RESOURCE_TYPE } from "../app/module.js";
20
20
  import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
21
21
  import { analyzeSkillInputCoverage, coverageToolsFromWire, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
22
22
  import { SKILL_RESOURCE_TYPE } from "./module.js";
23
+ import { skillAccessPolicyToTf } from "./access-policy.js";
23
24
  function serviceAccountValue(name, ctx) {
24
25
  const matches = Object.entries(ctx.serviceAccounts ?? {}).filter(([, account]) => `${account.firstName} ${account.lastName}`.trim() === name);
25
26
  if (matches.length > 1) {
@@ -92,6 +93,8 @@ export function skillToTf(entity, ctx) {
92
93
  if (elementum.properties !== undefined) {
93
94
  attrs["properties"] = JSON.stringify(elementum.properties);
94
95
  }
96
+ if (elementum.accessPolicy !== undefined)
97
+ Object.assign(attrs, skillAccessPolicyToTf(elementum.accessPolicy, ctx.orgRefs));
95
98
  const discovery = elementum.discovery;
96
99
  if (discovery?.routingPriority !== undefined)
97
100
  attrs["routing_priority"] = discovery.routingPriority;
@@ -10,6 +10,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
10
10
  import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
11
11
  import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
12
12
  import { fieldRefToTfValue } from "../field/to-tf.js";
13
+ import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
13
14
  import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
14
15
  import { SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
15
16
  function serviceAccountIdValue(token, where, ctx) {
@@ -103,7 +104,7 @@ function targetIdValue(token, ctx) {
103
104
  function foreignTargetFieldRefValue(token, refName, target, ctx) {
104
105
  const fieldName = token.name ?? refName;
105
106
  const ownerLabel = target.foreignTfLabel ?? sanitizeName(target.refName);
106
- const fieldLabel = `${target.kind}_${ownerLabel}_${tsLabelToTfLabel(refName)}`;
107
+ const fieldLabel = foreignFieldDataLabel(target.kind, ownerLabel, fieldName);
107
108
  ctx.foreignFieldRef("elementum_field", fieldLabel, target.value, fieldName);
108
109
  return expr.dataAttr("elementum_field", fieldLabel, ["id"]);
109
110
  }
@@ -6,7 +6,7 @@ import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.j
6
6
  import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
7
7
  import { tableDataminesToTf, } from "../datamine/to-tf.js";
8
8
  import { fieldRefToTfValue } from "../field/to-tf.js";
9
- import { resolveForeignRef } from "../shared/foreign-ref.js";
9
+ import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
10
10
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
11
11
  import { TABLE_RESOURCE_TYPE } from "./module.js";
12
12
  function tableColumnName(column) {
@@ -96,8 +96,8 @@ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspe
96
96
  return resolved;
97
97
  }
98
98
  const parentName = ref.parentName ?? parent;
99
- const owner = resolveForeignRef(kind, { name: parentName }, orgRefs, diagnostics, "table field owner");
100
- const label = sanitizeName(`${parent}_${ref.refName ?? ref.name ?? "field"}`);
99
+ const owner = resolveForeignRef(kind, { name: parentName, namespace: ref.parentNamespace }, orgRefs, diagnostics, "table field owner");
100
+ const label = foreignFieldDataLabel(kind, owner.tfLabel, ref.name ?? ref.refName ?? "field");
101
101
  orgRefs.foreignField("elementum_field", label, owner.value, ref.name ?? ref.refName ?? "");
102
102
  return expr.dataAttr("elementum_field", label, ["id"]);
103
103
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Pull: `elementum_agent_view.layout` → the normalized layout the printer
3
+ * turns back into `agentViews.<key>.layout`. References inside the custom
4
+ * view become typed markers at the per-block id positions; raw platform ids
5
+ * there become `unsafePlatformId(...)`. A layout this cannot represent makes
6
+ * the whole view unmanaged (skipped), never silently dropped: the code owns
7
+ * the layout, so a dropped detail would be cleared on the next apply.
8
+ */
9
+ import { type TfValue } from "../../engine/tf/index.js";
10
+ /** A typed reference inside a pulled custom view. */
11
+ export type AgentViewSpecMarker = {
12
+ readonly __specRef: "app";
13
+ } | {
14
+ readonly __specRef: "field";
15
+ readonly key: string;
16
+ } | {
17
+ readonly __specRef: "unsafe";
18
+ readonly id: string;
19
+ };
20
+ export interface NormalizedAgentViewLayout {
21
+ readonly image?: {
22
+ readonly attachment: string;
23
+ } | {
24
+ readonly url: string;
25
+ };
26
+ readonly header?: string;
27
+ readonly subHeader?: string;
28
+ readonly backgroundColor?: string;
29
+ readonly primaryColor?: string;
30
+ readonly fontFamily?: string;
31
+ /** Plain JSON with `AgentViewSpecMarker` objects at reference positions. */
32
+ readonly customView?: unknown;
33
+ }
34
+ export interface AgentViewLayoutFromTfOptions {
35
+ /** True when the value references the owning app (`elementum_app.<owner>.id`). */
36
+ readonly isOwnApp: (value: TfValue) => boolean;
37
+ /** Resolves a field reference to its bag key, a system field key, or a raw id. */
38
+ readonly fieldKey: (value: TfValue) => string | undefined;
39
+ }
40
+ export type AgentViewLayoutFromTfResult = {
41
+ readonly ok: true;
42
+ readonly layout: NormalizedAgentViewLayout;
43
+ } | {
44
+ readonly ok: false;
45
+ readonly reason: string;
46
+ };
47
+ export declare function agentViewLayoutFromTf(value: TfValue, opts: AgentViewLayoutFromTfOptions): AgentViewLayoutFromTfResult;
48
+ /** Own-app field bag keys a pulled layout references (for hoisting their consts). */
49
+ export declare function collectAgentViewLayoutFieldKeys(layout: NormalizedAgentViewLayout | undefined): string[];