@elementumai/edk 0.9.2 → 0.9.5
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.
- package/README.md +34 -26
- package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
- package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
- package/dist-sdk/pull/util.d.ts +1 -1
- package/dist-sdk/pull/util.js +3 -3
- package/dist-sdk/src/catalog/factories.d.ts +49 -10
- package/dist-sdk/src/catalog/factories.js +94 -13
- package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
- package/dist-sdk/src/catalog/from-authoring.js +7 -7
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +62 -4
- package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
- package/dist-sdk/src/catalog/render-helpers.js +1 -1
- package/dist-sdk/src/catalog/render.d.ts +1 -0
- package/dist-sdk/src/catalog/render.js +2 -2
- package/dist-sdk/src/catalog/token.js +11 -4
- package/dist-sdk/src/catalog/types.d.ts +33 -4
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +10 -10
- package/dist-sdk/src/core/index.js +9 -9
- package/dist-sdk/src/core/render-tree.d.ts +1 -1
- package/dist-sdk/src/core/render-tree.js +1 -2
- package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
- package/dist-sdk/src/core/types/ai-provider.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +66 -30
- package/dist-sdk/src/core/types/app.js +2 -2
- package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
- package/dist-sdk/src/core/types/aspect-category.js +4 -4
- package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
- package/dist-sdk/src/core/types/cloud-link.js +3 -3
- package/dist-sdk/src/core/types/display-block.d.ts +2 -2
- package/dist-sdk/src/core/types/display-block.js +2 -2
- package/dist-sdk/src/core/types/group.d.ts +1 -1
- package/dist-sdk/src/core/types/group.js +1 -1
- package/dist-sdk/src/core/types/user.d.ts +1 -1
- package/dist-sdk/src/core/types/user.js +1 -1
- package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
- package/dist-sdk/src/engine/build/context.d.ts +20 -13
- package/dist-sdk/src/engine/entity.d.ts +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/context.js +14 -0
- package/dist-sdk/src/engine/pull/org.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.js +33 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
- package/dist-sdk/src/engine/pull/ref-only.js +204 -0
- package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
- package/dist-sdk/src/engine/tf/expr.js +18 -13
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/model.d.ts +8 -1
- package/dist-sdk/src/engine/tf/model.js +4 -0
- package/dist-sdk/src/engine/tf/parse.js +13 -2
- package/dist-sdk/src/engine/tf/render.js +4 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
- package/dist-sdk/src/entities/access-policy/build.js +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
- package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
- package/dist-sdk/src/entities/agent/build.d.ts +3 -3
- package/dist-sdk/src/entities/agent/build.js +5 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
- package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/from-tf.js +12 -4
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
- package/dist-sdk/src/entities/agent/to-tf.js +56 -8
- package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
- package/dist-sdk/src/entities/agent/tools.js +21 -7
- package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
- package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
- package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
- package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
- package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
- package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
- package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
- package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
- package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
- package/dist-sdk/src/entities/agent-tool/types.js +10 -37
- package/dist-sdk/src/entities/app/build.d.ts +97 -42
- package/dist-sdk/src/entities/app/build.js +25 -14
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
- package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
- package/dist-sdk/src/entities/app/index.d.ts +11 -8
- package/dist-sdk/src/entities/app/index.js +10 -7
- package/dist-sdk/src/entities/app/module.js +2 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +22 -6
- package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/build.js +5 -5
- package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/index.js +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +172 -94
- package/dist-sdk/src/entities/automation/build.js +159 -68
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
- package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
- package/dist-sdk/src/entities/automation/from-tf.js +510 -80
- package/dist-sdk/src/entities/automation/index.d.ts +9 -12
- package/dist-sdk/src/entities/automation/index.js +11 -13
- package/dist-sdk/src/entities/automation/module.js +74 -6
- package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
- package/dist-sdk/src/entities/automation/operators.js +10 -37
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +13 -22
- package/dist-sdk/src/entities/automation/serialize.js +1 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
- package/dist-sdk/src/entities/automation/tasks.js +64 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/to-tf.js +342 -71
- package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
- package/dist-sdk/src/entities/automation/triggers.js +7 -1
- package/dist-sdk/src/entities/automation/types.d.ts +3 -2
- package/dist-sdk/src/entities/automation/types.js +3 -2
- package/dist-sdk/src/entities/chart/build.d.ts +95 -0
- package/dist-sdk/src/entities/chart/build.js +42 -0
- package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
- package/dist-sdk/src/entities/chart/from-tf.js +269 -0
- package/dist-sdk/src/entities/chart/index.d.ts +4 -0
- package/dist-sdk/src/entities/chart/index.js +3 -0
- package/dist-sdk/src/entities/chart/module.d.ts +3 -0
- package/dist-sdk/src/entities/chart/module.js +61 -0
- package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
- package/dist-sdk/src/entities/chart/printer.js +104 -0
- package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
- package/dist-sdk/src/entities/chart/to-tf.js +150 -0
- package/dist-sdk/src/entities/chart/types.d.ts +53 -0
- package/dist-sdk/src/entities/chart/types.js +22 -0
- package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
- package/dist-sdk/src/entities/dashboard/build.js +16 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
- package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
- package/dist-sdk/src/entities/datamine/module.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
- package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
- package/dist-sdk/src/entities/element/build.d.ts +25 -32
- package/dist-sdk/src/entities/element/build.js +15 -32
- package/dist-sdk/src/entities/element/index.d.ts +7 -5
- package/dist-sdk/src/entities/element/index.js +7 -4
- package/dist-sdk/src/entities/element/module.js +7 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/element/to-tf.js +7 -3
- package/dist-sdk/src/entities/field/build.d.ts +51 -24
- package/dist-sdk/src/entities/field/build.js +31 -6
- package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
- package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
- package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
- package/dist-sdk/src/entities/field/calc/date.js +120 -29
- package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
- package/dist-sdk/src/entities/field/calc/index.js +82 -139
- package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
- package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
- package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
- package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
- package/dist-sdk/src/entities/field/calc/text.js +43 -31
- package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
- package/dist-sdk/src/entities/field/calc/types.js +1 -22
- package/dist-sdk/src/entities/field/calc.d.ts +71 -48
- package/dist-sdk/src/entities/field/calc.js +5 -15
- package/dist-sdk/src/entities/field/calculation-types.js +10 -3
- package/dist-sdk/src/entities/field/from-tf.js +156 -10
- package/dist-sdk/src/entities/field/locals.d.ts +11 -3
- package/dist-sdk/src/entities/field/locals.js +15 -2
- package/dist-sdk/src/entities/field/module.js +23 -6
- package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
- package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
- package/dist-sdk/src/entities/field/to-tf.js +293 -35
- package/dist-sdk/src/entities/field/types.d.ts +1 -1
- package/dist-sdk/src/entities/field/types.js +7 -1
- package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
- package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
- package/dist-sdk/src/entities/org/cloud-link.js +4 -5
- package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
- package/dist-sdk/src/entities/org/email-alias.js +12 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/phone-provider.js +4 -7
- package/dist-sdk/src/entities/organization/build.d.ts +214 -2
- package/dist-sdk/src/entities/organization/build.js +145 -4
- package/dist-sdk/src/entities/organization/index.d.ts +1 -1
- package/dist-sdk/src/entities/organization/index.js +1 -1
- package/dist-sdk/src/entities/organization/module.js +4 -1
- package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/organization/to-tf.js +118 -1
- package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/build.js +2 -2
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
- package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
- package/dist-sdk/src/entities/phone-service/index.js +1 -1
- package/dist-sdk/src/entities/phone-service/types.js +1 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
- package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
- package/dist-sdk/src/entities/search-table/build.js +13 -13
- package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
- package/dist-sdk/src/entities/search-table/index.js +2 -2
- package/dist-sdk/src/entities/search-table/printer.js +5 -5
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
- package/dist-sdk/src/entities/shared/context.d.ts +25 -24
- package/dist-sdk/src/entities/shared/context.js +36 -35
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
- package/dist-sdk/src/entities/shared/filters/index.js +11 -4
- package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
- package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
- package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
- package/dist-sdk/src/entities/shared/ref.js +8 -3
- package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
- package/dist-sdk/src/entities/skill/build.d.ts +2 -2
- package/dist-sdk/src/entities/skill/build.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/module.js +2 -2
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +2 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
- package/dist-sdk/src/entities/skill/tools.js +4 -3
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
- package/dist-sdk/src/entities/table/build.d.ts +1 -1
- package/dist-sdk/src/entities/table/build.js +9 -9
- package/dist-sdk/src/entities/table/catalog-render.js +9 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
- package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
- package/dist-sdk/src/entities/table/fields/types.js +1 -1
- package/dist-sdk/src/entities/table/index.d.ts +2 -2
- package/dist-sdk/src/entities/table/index.js +3 -3
- package/dist-sdk/src/entities/table/module.js +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +22 -30
- package/dist-sdk/src/entities/task/build.d.ts +1 -1
- package/dist-sdk/src/entities/task/build.js +5 -5
- package/dist-sdk/src/entities/task/index.d.ts +1 -1
- package/dist-sdk/src/entities/task/index.js +1 -1
- package/dist-sdk/src/entities/view/build.d.ts +46 -0
- package/dist-sdk/src/entities/view/build.js +19 -0
- package/dist-sdk/src/entities/view/from-tf.js +68 -18
- package/dist-sdk/src/entities/view/module.d.ts +6 -13
- package/dist-sdk/src/entities/view/module.js +7 -14
- package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
- package/dist-sdk/src/entities/view/sharing.js +6 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
- package/dist-sdk/src/entities/view/to-tf.js +61 -26
- package/dist-sdk/src/entities/view/types.js +3 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/build.js +8 -8
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/module.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
- package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +9 -7
- package/dist-sdk/src/graph/index.d.ts +5 -1
- package/dist-sdk/src/graph/index.js +4 -1
- package/dist-sdk/src/graph/modules.js +6 -1
- package/dist-sdk/src/graph/types.d.ts +52 -1
- package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
- package/dist-sdk/src/internal/safe-identifier.js +13 -0
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +12 -3
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* the integration harness strips it for fidelity against authored fixtures.
|
|
19
19
|
*/
|
|
20
20
|
import { EntityTfError } from "../../engine/entity.js";
|
|
21
|
-
import { expr, scopedResourceLabel } from "../../engine/tf/index.js";
|
|
21
|
+
import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
22
22
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
23
23
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
24
|
+
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
24
25
|
import { ACCESS_POLICY_RESOURCE_TYPE } from "./types.js";
|
|
25
26
|
function isFieldToken(v) {
|
|
26
27
|
return typeof v === "object" && v !== null && v.__kind === "field";
|
|
@@ -44,7 +45,7 @@ function picklistLiteralToTf(literal, field, ctx) {
|
|
|
44
45
|
: undefined;
|
|
45
46
|
// Non-status/stage picklists: the field's own options-by-label local, keyed
|
|
46
47
|
// by its scoped resource label — same derivation fieldToTf's options pass uses.
|
|
47
|
-
const resolvedLocalName = localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, field?.refName ?? "", ctx.scope)}_options_by_label`;
|
|
48
|
+
const resolvedLocalName = localName ?? `${scopedResourceLabel(ctx.ownerTfLabel, tsLabelToTfLabel(field?.refName ?? ""), ctx.scope)}_options_by_label`;
|
|
48
49
|
return expr.local(resolvedLocalName, [{ index: literal }]);
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
@@ -69,9 +70,18 @@ export function filterToTf(f, where, ctx) {
|
|
|
69
70
|
function isOrgPrincipalRef(v) {
|
|
70
71
|
return typeof v === "object" && v !== null && v.__kind === "orgPrincipalRef";
|
|
71
72
|
}
|
|
73
|
+
function isUserToken(v) {
|
|
74
|
+
return typeof v === "object" && v !== null &&
|
|
75
|
+
v.__kind === "user" &&
|
|
76
|
+
typeof v.email === "string" &&
|
|
77
|
+
v.email !== "";
|
|
78
|
+
}
|
|
72
79
|
function isGroupToken(v) {
|
|
73
80
|
return typeof v === "object" && v !== null && v.__kind === "group";
|
|
74
81
|
}
|
|
82
|
+
function isServiceAccountToken(v) {
|
|
83
|
+
return typeof v === "object" && v !== null && v.__kind === "serviceAccount";
|
|
84
|
+
}
|
|
75
85
|
export function principalListToTf(items, dataType, where, ctx) {
|
|
76
86
|
if (items === undefined || items.length === 0)
|
|
77
87
|
return undefined;
|
|
@@ -86,6 +96,16 @@ export function principalListToTf(items, dataType, where, ctx) {
|
|
|
86
96
|
values.push(expr.dataAttr(item.dataType, item.label, ["id"]));
|
|
87
97
|
}
|
|
88
98
|
}
|
|
99
|
+
else if (dataType === "elementum_user" && isUserToken(item)) {
|
|
100
|
+
if (ctx.orgRefs === undefined) {
|
|
101
|
+
ctx.diagnostics.push(`${where}: userRef requires org context; dropped`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const label = sanitizeName(item.email.split("@", 1)[0] ?? item.email);
|
|
105
|
+
ctx.orgRefs.rawLookup("elementum_user", label, item.email);
|
|
106
|
+
values.push(expr.dataAttr("elementum_user", label, ["id"]));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
89
109
|
else if (dataType === "elementum_group" && isGroupToken(item)) {
|
|
90
110
|
const resolved = ctx.orgRefs?.byTsLabel("groups", item.refName ?? "");
|
|
91
111
|
if (resolved === undefined) {
|
|
@@ -95,7 +115,17 @@ export function principalListToTf(items, dataType, where, ctx) {
|
|
|
95
115
|
values.push(expr.dataAttr("elementum_group", resolved.tfLabel, ["id"]));
|
|
96
116
|
}
|
|
97
117
|
}
|
|
98
|
-
else if (
|
|
118
|
+
else if (dataType === "elementum_service_account" && isServiceAccountToken(item)) {
|
|
119
|
+
if (ctx.appRefName === undefined || ctx.orgRefs === undefined) {
|
|
120
|
+
ctx.diagnostics.push(`${where}: serviceAccount requires an app owner and org context; dropped`);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const value = serviceAccountRefToTf(item, { appRefName: ctx.appRefName, appTfLabel: ctx.ownerTfLabel, appId: ctx.objectId, serviceAccounts: ctx.serviceAccounts, orgRefs: ctx.orgRefs }, where, ctx.diagnostics);
|
|
124
|
+
if (value !== undefined)
|
|
125
|
+
values.push(value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (dataType !== "elementum_service_account" && typeof item === "string") {
|
|
99
129
|
values.push(item);
|
|
100
130
|
}
|
|
101
131
|
else {
|
|
@@ -126,9 +156,9 @@ export function accessPolicyToTf(entry, index, ctx) {
|
|
|
126
156
|
const groupIds = principalListToTf(entry.groupIds, "elementum_group", `${where}.groupIds`, ctx);
|
|
127
157
|
if (groupIds !== undefined)
|
|
128
158
|
attrs["group_ids"] = groupIds;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
159
|
+
const serviceAccountIds = principalListToTf(entry.serviceAccountIds, "elementum_service_account", `${where}.serviceAccountIds`, ctx);
|
|
160
|
+
if (serviceAccountIds !== undefined)
|
|
161
|
+
attrs["service_account_ids"] = serviceAccountIds;
|
|
132
162
|
return {
|
|
133
163
|
block: { kind: "resource", type: ACCESS_POLICY_RESOURCE_TYPE, label, attrs },
|
|
134
164
|
address: `${ACCESS_POLICY_RESOURCE_TYPE}.${label}`,
|
|
@@ -114,7 +114,7 @@ export interface AgentV2Options extends EntityDeployOptions {
|
|
|
114
114
|
/**
|
|
115
115
|
* def()-time validation of run-automation (executeWorkflow) tools against
|
|
116
116
|
* the embedded automation token's trigger/outputs bags — the runtime
|
|
117
|
-
* backstop behind `agentRunAutomation`'s typed inputs (the
|
|
117
|
+
* backstop behind `agentRunAutomation`'s typed inputs (the app
|
|
118
118
|
* handle/namespace pattern: throw with the full story, at def() time).
|
|
119
119
|
*
|
|
120
120
|
* MUST run before `slimTokens` — slimming strips the automation token's
|
|
@@ -128,7 +128,7 @@ export interface AgentV2Options extends EntityDeployOptions {
|
|
|
128
128
|
*/
|
|
129
129
|
export declare function validateAgentTools(agentName: string, tools: readonly AgentTool[]): void;
|
|
130
130
|
/**
|
|
131
|
-
* The configured result of `
|
|
131
|
+
* The configured result of `agent` — its reference surface (`ref()`)
|
|
132
132
|
* and its deployable entity (`def()`). Both take `refName` as a **call-time
|
|
133
133
|
* argument**, not a constructor option — see `AppConfigured` in
|
|
134
134
|
* `src/aspects/build.ts` for why.
|
|
@@ -138,4 +138,4 @@ export interface AgentConfigured {
|
|
|
138
138
|
def(refName: string): DeployableEntity;
|
|
139
139
|
}
|
|
140
140
|
/** Build a v2 agent entity: identity + app from the flat options, exposing `.ref(refName)` and `.def(refName)`. */
|
|
141
|
-
export declare function
|
|
141
|
+
export declare function agent(opts: AgentV2Options): AgentConfigured;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* v2 agent authoring (parallel to v1 `src/agents`, fully standalone so v1 can be
|
|
3
3
|
* deleted wholesale once v2 is validated).
|
|
4
4
|
*
|
|
5
|
-
* `
|
|
5
|
+
* `agent` emits Hydra's `AgentElementumCreateInput` + tools wire shape
|
|
6
6
|
* **minus the owner** (`ownerId`/`ownerType` are injected by the wire client at
|
|
7
7
|
* deploy) and with `CatalogRef` tokens at every reference position — the AI
|
|
8
8
|
* provider connector, skill access, and each tool's aspect/field/table/agent/
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* nothing here reads an `.id`.
|
|
11
11
|
*
|
|
12
12
|
* Identity (handle) comes from the authored key, and the owning app comes from
|
|
13
|
-
* the typed `app` reference, exactly like `
|
|
13
|
+
* the typed `app` reference, exactly like `automation`.
|
|
14
14
|
*/
|
|
15
15
|
import { slimTokens } from "../../catalog/index.js";
|
|
16
16
|
export const agentStartingActionVariableType = {
|
|
@@ -60,7 +60,7 @@ function serializeA2ASkill(s) {
|
|
|
60
60
|
/**
|
|
61
61
|
* def()-time validation of run-automation (executeWorkflow) tools against
|
|
62
62
|
* the embedded automation token's trigger/outputs bags — the runtime
|
|
63
|
-
* backstop behind `agentRunAutomation`'s typed inputs (the
|
|
63
|
+
* backstop behind `agentRunAutomation`'s typed inputs (the app
|
|
64
64
|
* handle/namespace pattern: throw with the full story, at def() time).
|
|
65
65
|
*
|
|
66
66
|
* MUST run before `slimTokens` — slimming strips the automation token's
|
|
@@ -81,7 +81,7 @@ export function validateAgentTools(agentName, tools) {
|
|
|
81
81
|
const auto = inner.automationId;
|
|
82
82
|
const autoName = auto?.refName ?? "";
|
|
83
83
|
const fail = (msg) => {
|
|
84
|
-
throw new Error(`
|
|
84
|
+
throw new Error(`agent "${agentName}": tool "${toolName}" — ${msg}`);
|
|
85
85
|
};
|
|
86
86
|
const trigger = auto?.trigger;
|
|
87
87
|
if (trigger !== undefined && typeof trigger === "object" && Object.keys(trigger).length > 0) {
|
|
@@ -118,7 +118,7 @@ export function validateAgentTools(agentName, tools) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
/** Build a v2 agent entity: identity + app from the flat options, exposing `.ref(refName)` and `.def(refName)`. */
|
|
121
|
-
export function
|
|
121
|
+
export function agent(opts) {
|
|
122
122
|
const elementum = {
|
|
123
123
|
name: opts.name,
|
|
124
124
|
description: opts.description,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* printAgentV2 — pulled agent rendering for the terraform path (M3).
|
|
3
3
|
* Consumes the `NormalizedAgent` that `agentFromTf` produces and emits an
|
|
4
|
-
* `apps/<app>/agents/<refName>.ts` authoring file: `
|
|
4
|
+
* `apps/<app>/agents/<refName>.ts` authoring file: `agent` with the
|
|
5
5
|
* connector as a `catalog.aiProviders.<provider>.models.<model>` token (the
|
|
6
6
|
* generated org-root barrel re-exports `org.aiProviders`, so this file needs
|
|
7
7
|
* no separate relative `org.js` import), tool targets as `catalog` tokens
|
|
@@ -54,5 +54,10 @@ export interface PrintAgentV2Options {
|
|
|
54
54
|
readonly ownerRefName: string;
|
|
55
55
|
readonly tableKey: string;
|
|
56
56
|
}>;
|
|
57
|
+
/** Platform field id → typed catalog identity collected from pulled dependencies. */
|
|
58
|
+
readonly foreignFieldRefsById?: ReadonlyMap<string, {
|
|
59
|
+
readonly ownerRefName: string;
|
|
60
|
+
readonly fieldKey: string;
|
|
61
|
+
}>;
|
|
57
62
|
}
|
|
58
63
|
export declare function printAgentV2(agent: NormalizedAgent, opts: PrintAgentV2Options): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* printAgentV2 — pulled agent rendering for the terraform path (M3).
|
|
3
3
|
* Consumes the `NormalizedAgent` that `agentFromTf` produces and emits an
|
|
4
|
-
* `apps/<app>/agents/<refName>.ts` authoring file: `
|
|
4
|
+
* `apps/<app>/agents/<refName>.ts` authoring file: `agent` with the
|
|
5
5
|
* connector as a `catalog.aiProviders.<provider>.models.<model>` token (the
|
|
6
6
|
* generated org-root barrel re-exports `org.aiProviders`, so this file needs
|
|
7
7
|
* no separate relative `org.js` import), tool targets as `catalog` tokens
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { quote } from "../../../../pull/util.js";
|
|
14
14
|
import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
|
|
15
|
+
import { safeIdentifier } from "../../../internal/safe-identifier.js";
|
|
15
16
|
const TOOL_FACTORY_BY_TYPE_KEY = {
|
|
16
17
|
createRecord: "agentCreateRecord",
|
|
17
18
|
searchAspect: "agentSearchRecords",
|
|
@@ -47,16 +48,20 @@ function printConnectorToken(connectorKey) {
|
|
|
47
48
|
export function printAgentV2(agent, opts) {
|
|
48
49
|
const { appRefName } = opts;
|
|
49
50
|
const crossOrg = opts.crossOrg === true;
|
|
50
|
-
const usesServiceAccountRef = agent.runAs !== undefined && "serviceAccount" in agent.runAs
|
|
51
|
+
const usesServiceAccountRef = (agent.runAs !== undefined && "serviceAccount" in agent.runAs) ||
|
|
52
|
+
agent.tools.some((tool) => tool.runAs !== undefined && "serviceAccount" in tool.runAs);
|
|
51
53
|
const factories = [
|
|
52
54
|
...new Set([
|
|
53
55
|
...agent.tools.map((t) => TOOL_FACTORY_BY_TYPE_KEY[t.typeKey]).filter(Boolean),
|
|
54
56
|
...(usesServiceAccountRef ? ["serviceAccountRef"] : []),
|
|
55
57
|
]),
|
|
56
58
|
].sort();
|
|
57
|
-
const usesUnsafePlatformId = agent.tools.some((tool) =>
|
|
58
|
-
(tool.
|
|
59
|
-
(tool.
|
|
59
|
+
const usesUnsafePlatformId = agent.tools.some((tool) => {
|
|
60
|
+
const targetOwner = searchTableTargetOwnerRefName(tool, appRefName, opts.foreignAppRefNames, opts.foreignElementRefNames);
|
|
61
|
+
return (tool.fields?.some((field) => field.rawFieldId !== undefined) === true ||
|
|
62
|
+
tool.searchTableFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true ||
|
|
63
|
+
tool.returnFields?.some((field) => !searchTableFieldMatchesTarget(field.fieldId, targetOwner, opts.foreignFieldRefsById)) === true);
|
|
64
|
+
});
|
|
60
65
|
const lines = [];
|
|
61
66
|
lines.push("/**");
|
|
62
67
|
lines.push(` * ${agent.name}`);
|
|
@@ -65,7 +70,7 @@ export function printAgentV2(agent, opts) {
|
|
|
65
70
|
lines.push(" * one-shot starting point, not a live-binding view.");
|
|
66
71
|
lines.push(" */");
|
|
67
72
|
lines.push("");
|
|
68
|
-
const agentImports = [...factories, "
|
|
73
|
+
const agentImports = [...factories, "agent"];
|
|
69
74
|
lines.push(`import { ${[...new Set(agentImports)].sort().join(", ")} } from "${sdkPackageSpecifier("agents")}";`);
|
|
70
75
|
if (usesUnsafePlatformId)
|
|
71
76
|
lines.push(`import { unsafePlatformId } from "${sdkPackageSpecifier("core")}";`);
|
|
@@ -74,7 +79,8 @@ export function printAgentV2(agent, opts) {
|
|
|
74
79
|
// org.aiProviders — no separate relative org.js import is needed here.
|
|
75
80
|
lines.push(`import catalog from "@catalog";`);
|
|
76
81
|
lines.push("");
|
|
77
|
-
|
|
82
|
+
const identifier = safeIdentifier(agent.refName, "agent");
|
|
83
|
+
lines.push(`const ${identifier} = agent({`);
|
|
78
84
|
lines.push(` name: ${quote(agent.name)},`);
|
|
79
85
|
lines.push(` app: catalog.${appRefName},`);
|
|
80
86
|
const connectorMatchesDestination = agent.connectorKey !== undefined && (opts.destinationConnectorKeys?.has(agent.connectorKey) ?? false);
|
|
@@ -130,13 +136,13 @@ export function printAgentV2(agent, opts) {
|
|
|
130
136
|
if (agent.tools.length > 0) {
|
|
131
137
|
lines.push(" tools: [");
|
|
132
138
|
for (const tool of agent.tools) {
|
|
133
|
-
lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignSearchTableRefsByName).map((l) => ` ${l}`));
|
|
139
|
+
lines.push(...printTool(tool, appRefName, crossOrg, opts.foreignAppRefNames, opts.foreignElementRefNames, opts.foreignSearchTableRefsByName, opts.foreignFieldRefsById).map((l) => ` ${l}`));
|
|
134
140
|
}
|
|
135
141
|
lines.push(" ],");
|
|
136
142
|
}
|
|
137
143
|
lines.push("});");
|
|
138
144
|
lines.push("");
|
|
139
|
-
lines.push(`export default ${
|
|
145
|
+
lines.push(`export default ${identifier};`);
|
|
140
146
|
lines.push("");
|
|
141
147
|
return lines.join("\n");
|
|
142
148
|
}
|
|
@@ -170,7 +176,7 @@ function printSkillRefToken(ref, appRefName, crossOrg) {
|
|
|
170
176
|
const todo = crossOrg
|
|
171
177
|
? ` // TODO: cross-org clone — "${ref.name}" was resolved in the SOURCE org; verify it exists (with this name) in the destination org`
|
|
172
178
|
: "";
|
|
173
|
-
return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)} },${todo}`;
|
|
179
|
+
return `{ __kind: "skill", refName: ${quote(ref.name)}, name: ${quote(ref.name)}, parent: ${quote(ref.appRefName ?? ref.appName)}, parentName: ${quote(ref.appName)} },${todo}`;
|
|
174
180
|
}
|
|
175
181
|
function printSkillAccess(access, appRefName, crossOrg) {
|
|
176
182
|
const hasPreloaded = access.preloadedSkills !== undefined && access.preloadedSkills.length > 0;
|
|
@@ -262,13 +268,34 @@ function fieldOwnerRef(tool, appRefName, foreignAppRefNames, foreignElementRefNa
|
|
|
262
268
|
? { kind: "catalog", expr: `catalog.${foreignRefName}` }
|
|
263
269
|
: { kind: "raw", entityType: "element", name: tool.target.name };
|
|
264
270
|
}
|
|
265
|
-
|
|
271
|
+
/** Catalog key for the search-table tool's target element/app, when pull resolved it. */
|
|
272
|
+
function searchTableTargetOwnerRefName(tool, appRefName, foreignAppRefNames, foreignElementRefNames) {
|
|
273
|
+
if (tool.target === undefined || tool.target.kind === "self")
|
|
274
|
+
return appRefName;
|
|
275
|
+
if (tool.target.kind === "foreignApp")
|
|
276
|
+
return foreignAppRefNames?.get(tool.target.name);
|
|
277
|
+
if (tool.target.kind === "foreignElement")
|
|
278
|
+
return foreignElementRefNames?.get(tool.target.name);
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Upgrade a search-table field id only when the recursive-pull registry maps it
|
|
283
|
+
* to the tool's own target. A global hit for a different dependency would print
|
|
284
|
+
* `catalog.other.fields.x`, which fails the owner-bound authoring type.
|
|
285
|
+
*/
|
|
286
|
+
function searchTableFieldMatchesTarget(fieldId, targetOwnerRefName, foreignFieldRefsById) {
|
|
287
|
+
const resolved = foreignFieldRefsById?.get(fieldId);
|
|
288
|
+
return resolved !== undefined && targetOwnerRefName !== undefined && resolved.ownerRefName === targetOwnerRefName;
|
|
289
|
+
}
|
|
290
|
+
function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElementRefNames, foreignSearchTableRefsByName, foreignFieldRefsById) {
|
|
266
291
|
const factory = TOOL_FACTORY_BY_TYPE_KEY[tool.typeKey] ?? "agentSearchRecords";
|
|
267
292
|
const lines = [`${factory}({`];
|
|
268
293
|
lines.push(` name: ${quote(tool.name)},`);
|
|
269
294
|
lines.push(` description: ${quote(tool.description)},`);
|
|
270
295
|
if (tool.startMessage !== undefined)
|
|
271
296
|
lines.push(` startMessage: ${quote(tool.startMessage)},`);
|
|
297
|
+
if (tool.runAs !== undefined)
|
|
298
|
+
lines.push(` runAs: ${printRunAs(tool.runAs, appRefName)},`);
|
|
272
299
|
if (tool.typeKey === "executeWorkflow") {
|
|
273
300
|
// Record form (agentRunAutomation v3): keys are the automation's declared
|
|
274
301
|
// parameter/property names; the agent-facing `name:` prints only when it
|
|
@@ -446,6 +473,8 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
446
473
|
parts.push(`description: ${quote(f.description ?? "")}`);
|
|
447
474
|
if (f.required !== undefined)
|
|
448
475
|
parts.push(`required: ${f.required}`);
|
|
476
|
+
if (f.defaultValue !== undefined)
|
|
477
|
+
parts.push(`defaultValue: ${quote(f.defaultValue)}`);
|
|
449
478
|
const todo = isRaw
|
|
450
479
|
? " // TODO: raw platform field id - the field belongs to a foreign/out-of-scope aspect ei can't resolve to a reference"
|
|
451
480
|
: owner.kind === "raw"
|
|
@@ -455,30 +484,51 @@ function printTool(tool, appRefName, crossOrg, foreignAppRefNames, foreignElemen
|
|
|
455
484
|
}
|
|
456
485
|
lines.push(" ],");
|
|
457
486
|
}
|
|
458
|
-
//
|
|
459
|
-
//
|
|
460
|
-
//
|
|
487
|
+
// The provider reads search-table field ids as raw strings. Recursive pull's
|
|
488
|
+
// dependency registry upgrades known ids to typed target-field tokens — but
|
|
489
|
+
// only when the resolved owner matches this tool's target (authoring requires
|
|
490
|
+
// FieldRef<Target["refName"]>; a wrong-owner upgrade fails tsc).
|
|
461
491
|
if (tool.searchTableFields !== undefined && tool.searchTableFields.length > 0) {
|
|
492
|
+
const targetOwner = searchTableTargetOwnerRefName(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
|
|
462
493
|
lines.push(" fields: [");
|
|
463
494
|
for (const f of tool.searchTableFields) {
|
|
464
|
-
const
|
|
495
|
+
const resolved = foreignFieldRefsById?.get(f.fieldId);
|
|
496
|
+
const typed = searchTableFieldMatchesTarget(f.fieldId, targetOwner, foreignFieldRefsById)
|
|
497
|
+
? resolved
|
|
498
|
+
: undefined;
|
|
499
|
+
const parts = typed === undefined
|
|
500
|
+
? [`fieldId: unsafePlatformId(${quote(f.fieldId)})`]
|
|
501
|
+
: [`field: catalog.${typed.ownerRefName}.fields.${typed.fieldKey}`];
|
|
465
502
|
if (f.name !== undefined)
|
|
466
503
|
parts.push(`name: ${quote(f.name)}`);
|
|
467
504
|
if (f.description !== undefined)
|
|
468
505
|
parts.push(`description: ${quote(f.description)}`);
|
|
469
|
-
|
|
506
|
+
const todo = typed === undefined
|
|
507
|
+
? " // TODO: unresolved search-table field id - pull the target element recursively to recover its catalog field"
|
|
508
|
+
: "";
|
|
509
|
+
lines.push(` { ${parts.join(", ")} },${todo}`);
|
|
470
510
|
}
|
|
471
511
|
lines.push(" ],");
|
|
472
512
|
}
|
|
473
513
|
if (tool.returnFields !== undefined && tool.returnFields.length > 0) {
|
|
514
|
+
const targetOwner = searchTableTargetOwnerRefName(tool, appRefName, foreignAppRefNames, foreignElementRefNames);
|
|
474
515
|
lines.push(" returnFields: [");
|
|
475
516
|
for (const f of tool.returnFields) {
|
|
476
|
-
const
|
|
517
|
+
const resolved = foreignFieldRefsById?.get(f.fieldId);
|
|
518
|
+
const typed = searchTableFieldMatchesTarget(f.fieldId, targetOwner, foreignFieldRefsById)
|
|
519
|
+
? resolved
|
|
520
|
+
: undefined;
|
|
521
|
+
const parts = typed === undefined
|
|
522
|
+
? [`fieldId: unsafePlatformId(${quote(f.fieldId)})`]
|
|
523
|
+
: [`field: catalog.${typed.ownerRefName}.fields.${typed.fieldKey}`];
|
|
477
524
|
if (f.name !== undefined)
|
|
478
525
|
parts.push(`name: ${quote(f.name)}`);
|
|
479
526
|
if (f.displayName !== undefined)
|
|
480
527
|
parts.push(`displayName: ${quote(f.displayName)}`);
|
|
481
|
-
|
|
528
|
+
const todo = typed === undefined
|
|
529
|
+
? " // TODO: unresolved search-table field id - pull the target element recursively to recover its catalog field"
|
|
530
|
+
: "";
|
|
531
|
+
lines.push(` { ${parts.join(", ")} },${todo}`);
|
|
482
532
|
}
|
|
483
533
|
lines.push(" ],");
|
|
484
534
|
}
|
|
@@ -14,7 +14,7 @@ import type { AgentAuthentication } from "./build.js";
|
|
|
14
14
|
import type { AgentToolRunAs } from "./tools.js";
|
|
15
15
|
/**
|
|
16
16
|
* A resolved skill reference: this app's own skill (by catalog key), a
|
|
17
|
-
* foreign app's (by name
|
|
17
|
+
* foreign app's (by skill name plus its owning app identity), or a raw platform id the export carries with
|
|
18
18
|
* no way to resolve it further at all — confirmed live: a `skill_ids` entry
|
|
19
19
|
* can be a bare UUID literal with neither a resource ref into this stream
|
|
20
20
|
* nor a `data.elementum_agentic_skill` block backing it anywhere in the export.
|
|
@@ -25,6 +25,8 @@ export type NormalizedSkillRef = {
|
|
|
25
25
|
} | {
|
|
26
26
|
readonly kind: "foreign";
|
|
27
27
|
readonly name: string;
|
|
28
|
+
readonly appName: string;
|
|
29
|
+
readonly appRefName?: string;
|
|
28
30
|
} | {
|
|
29
31
|
readonly kind: "unresolved";
|
|
30
32
|
readonly id: string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import blocks and stay data-side — they never reach printed source.
|
|
8
8
|
*/
|
|
9
9
|
import { EntityTfError } from "../../engine/entity.js";
|
|
10
|
-
import { optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
10
|
+
import { dataRefLabel, optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
11
11
|
import { isTfExpr, isUuid, scopedLabelToBagKey, } from "../../engine/tf/index.js";
|
|
12
12
|
import { a2aSkillFromTf } from "../agent-a2a-skill/from-tf.js";
|
|
13
13
|
import { toolFromTf } from "../agent-tool/from-tf.js";
|
|
@@ -60,7 +60,14 @@ function parseSkillRef(item, where, ownerTfLabel, ctx) {
|
|
|
60
60
|
ctx.diagnostics.push(`${where}: references data.${SKILL_RESOURCE_TYPE}.${item.label} but the stream has no such data block; dropped`);
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
const appDataLabel = dataRefLabel(ctx.dataAttrs?.(SKILL_RESOURCE_TYPE, item.label)?.["app_id"], APP_RESOURCE_TYPE);
|
|
64
|
+
const appName = appDataLabel === undefined ? undefined : ctx.dataName(APP_RESOURCE_TYPE, appDataLabel);
|
|
65
|
+
if (appName === undefined) {
|
|
66
|
+
ctx.diagnostics.push(`${where}: data.${SKILL_RESOURCE_TYPE}.${item.label} has no resolvable app_id owner; dropped`);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const appRefName = ctx.foreignAppRefNames?.get(appName);
|
|
70
|
+
return { kind: "foreign", name, appName, ...(appRefName !== undefined && { appRefName }) };
|
|
64
71
|
}
|
|
65
72
|
// A bare UUID literal with no data block backing it at all - the platform
|
|
66
73
|
// lets skill_ids reference a skill this export can't otherwise name (e.g.
|
|
@@ -76,9 +83,10 @@ function parseSkillRef(item, where, ownerTfLabel, ctx) {
|
|
|
76
83
|
/**
|
|
77
84
|
* `run_as` is a bare string on the wire (`elementum_agent`'s schema: only
|
|
78
85
|
* `"current_user"` is documented; unset means "run as admin/publisher").
|
|
79
|
-
* `
|
|
86
|
+
* `agent`'s `runAs` option takes the opaque object shape shared with
|
|
80
87
|
* agent-tool's `runAs` (`{ currentUser: true }` / `{ publisher: true }` /
|
|
81
|
-
* `{ serviceAccount: { serviceAccount } }`) —
|
|
88
|
+
* `{ serviceAccount: { serviceAccount } }`) — the remaining agent-level
|
|
89
|
+
* portion of board item B28(d) — so the
|
|
82
90
|
* string is translated into that shape for authoring; unrecognized values
|
|
83
91
|
* (not `"current_user"`) are reported and dropped rather than guessed at.
|
|
84
92
|
*/
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* the deploy wire client injects) with `CatalogRef` tokens at every reference
|
|
4
4
|
* position. Standalone from v1.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
7
|
-
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, type AgentExecuteWorkflowInput, type AgentExecuteWorkflowOutput, type RunAutomationInputs, type RunAutomationOptionalInput, type RunAutomationOutput, type RunAutomationOutputs, type RunAutomationRequiredInput, type RunAutomationToolV2, type AgentMcpHeader, type AgentRecordField, type AgentRecordFieldInput, type AgentRecordRawIdField, type AgentSearchField, type AgentSearchFieldInput, type AgentSearchRawIdField, type AgentToolRunAs, type AgentTool, } from "./tools.js";
|
|
6
|
+
export { agent, type A2ASkill, type AgentAuthentication, type AgentV2Options, agentStartingActionVariableType, type AgentStartingAction, type AgentStartingActionVariable, type AgentStartingActionVariableType, type SkillAccess, } from "./build.js";
|
|
7
|
+
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, type AgentExecuteWorkflowInput, type AgentExecuteWorkflowOutput, type RunAutomationInputs, type RunAutomationOptionalInput, type RunAutomationOutput, type RunAutomationOutputs, type RunAutomationRequiredInput, type RunAutomationToolV2, type AgentMcpHeader, type AgentRecordField, type AgentRecordFieldInput, type AgentRecordRawIdField, type AgentSearchField, type AgentSearchFieldInput, type AgentSearchRawIdField, type AgentSearchReturnField, type AgentSearchReturnFieldInput, type AgentSearchRawIdReturnField, type AgentSearchTableField, type AgentSearchTableFieldInput, type AgentSearchTableRawIdField, type SearchTableToolV2, type AgentToolRunAs, type AgentTool, } from "./tools.js";
|
|
8
8
|
export { serviceAccountRef, type ServiceAccountRef } from "./run-as.js";
|
|
9
9
|
export * as filter from "../shared/filters/index.js";
|
|
10
10
|
export { type Filter } from "../shared/filters/types.js";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* the deploy wire client injects) with `CatalogRef` tokens at every reference
|
|
4
4
|
* position. Standalone from v1.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { agent, agentStartingActionVariableType, } from "./build.js";
|
|
7
7
|
export { agentCreateRecord, agentExecuteWorkflow, agentMcp, agentRelateRecord, agentRunAgent, agentRunAutomation, agentSearchRecords, agentSearchTable, agentUpdateRecord, } from "./tools.js";
|
|
8
8
|
export { serviceAccountRef } from "./run-as.js";
|
|
9
9
|
export * as filter from "../shared/filters/index.js";
|
|
@@ -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.foreignFieldRefsById !== undefined && { foreignFieldRefsById: opts.foreignFieldRefsById }),
|
|
104
105
|
...(opts.foreignSearchTableRefsByName !== undefined && {
|
|
105
106
|
foreignSearchTableRefsByName: opts.foreignSearchTableRefsByName,
|
|
106
107
|
}),
|
|
@@ -112,6 +113,7 @@ export const agentModule = {
|
|
|
112
113
|
appTfLabel: ctx.appTfLabel,
|
|
113
114
|
orgRefs: ctx.orgRefs,
|
|
114
115
|
workspaceAspects: ctx.workspaceAspects,
|
|
116
|
+
serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
|
|
115
117
|
diagnostics: ctx.diagnostics,
|
|
116
118
|
...(ctx.siblingEntities !== undefined && { siblingEntities: ctx.siblingEntities }),
|
|
117
119
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent emission (M3, plan §4.3): `agentToTf` consumes the discovered
|
|
3
|
-
* `DeployableEntity` (the `
|
|
3
|
+
* `DeployableEntity` (the `agent` def() payload) and emits
|
|
4
4
|
* `elementum_agent` + one tool resource per implemented tool (the tool pass
|
|
5
5
|
* delegates to `entities/agent-tool/to-tf.ts`) + one `elementum_agent_a2a_skill`
|
|
6
6
|
* per a2aSkills entry (delegates to `entities/agent-a2a-skill/to-tf.ts`,
|
|
@@ -15,15 +15,18 @@
|
|
|
15
15
|
* startingActions, …) degrade through `diagnostics` — reported, never
|
|
16
16
|
* silent (plan §4.3).
|
|
17
17
|
*/
|
|
18
|
-
import type
|
|
18
|
+
import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
19
19
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
20
20
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
21
|
+
import type { AppServiceAccount } from "../service-account/build.js";
|
|
21
22
|
export interface AgentToTfContext {
|
|
22
23
|
/** The owning app's refName (self-target detection) and tfLabel (namespace). */
|
|
23
24
|
readonly appRefName: string;
|
|
24
25
|
readonly appTfLabel: string;
|
|
25
26
|
readonly orgRefs: OrgRefLookup;
|
|
26
27
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
28
|
+
/** Inline service accounts authored on the owning app, keyed by stable bag key. */
|
|
29
|
+
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
27
30
|
/** Degradations land here — reported by the caller, never silent. */
|
|
28
31
|
readonly diagnostics: string[];
|
|
29
32
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent emission (M3, plan §4.3): `agentToTf` consumes the discovered
|
|
3
|
-
* `DeployableEntity` (the `
|
|
3
|
+
* `DeployableEntity` (the `agent` def() payload) and emits
|
|
4
4
|
* `elementum_agent` + one tool resource per implemented tool (the tool pass
|
|
5
5
|
* delegates to `entities/agent-tool/to-tf.ts`) + one `elementum_agent_a2a_skill`
|
|
6
6
|
* per a2aSkills entry (delegates to `entities/agent-a2a-skill/to-tf.ts`,
|
|
@@ -15,16 +15,19 @@
|
|
|
15
15
|
* startingActions, …) degrade through `diagnostics` — reported, never
|
|
16
16
|
* silent (plan §4.3).
|
|
17
17
|
*/
|
|
18
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
18
19
|
import { EntityTfError } from "../../engine/entity.js";
|
|
19
20
|
import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
20
21
|
import { a2aSkillToTf } from "../agent-a2a-skill/to-tf.js";
|
|
21
22
|
import { toolToTf } from "../agent-tool/to-tf.js";
|
|
22
23
|
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
23
24
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
25
|
+
import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
26
|
+
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
24
27
|
import { SKILL_RESOURCE_TYPE } from "../skill/module.js";
|
|
25
28
|
import { AGENT_RESOURCE_TYPE } from "./module.js";
|
|
26
29
|
/**
|
|
27
|
-
* Config knobs `
|
|
30
|
+
* Config knobs `agent` accepts that the terraform dialect does not
|
|
28
31
|
* carry (yet). `runAs`/`agentAuthentication`/`a2aStreaming`/
|
|
29
32
|
* `conversationIdleTimeout` moved out of this list in issue #170,
|
|
30
33
|
* `a2aCreateRecordEnabled` in issue #215 — they're now emitted (see the
|
|
@@ -42,7 +45,8 @@ const UNSUPPORTED_AGENT_KNOBS = [
|
|
|
42
45
|
];
|
|
43
46
|
/**
|
|
44
47
|
* `runAs` authoring is the opaque object shape shared with agent-tool's
|
|
45
|
-
* `runAs` (board item B28(d));
|
|
48
|
+
* `runAs` (the remaining agent-level portion of board item B28(d));
|
|
49
|
+
* `elementum_agent.run_as` on the wire is a
|
|
46
50
|
* bare string and only `"current_user"` is documented for agents (unlike
|
|
47
51
|
* tools, which also accept `"publisher"`/`"service_account"`) — mirrors
|
|
48
52
|
* `parseRunAs` in `from-tf.ts`.
|
|
@@ -73,6 +77,21 @@ function jwtAuthenticationValue(auth) {
|
|
|
73
77
|
}
|
|
74
78
|
return value;
|
|
75
79
|
}
|
|
80
|
+
function serviceAccountValue(name, ctx) {
|
|
81
|
+
const matches = Object.entries(ctx.serviceAccounts ?? {}).filter(([, account]) => `${account.firstName} ${account.lastName}`.trim() === name);
|
|
82
|
+
if (matches.length > 1) {
|
|
83
|
+
throw new EntityTfError(`service account name ${JSON.stringify(name)} is ambiguous in app ${JSON.stringify(ctx.appRefName)}`);
|
|
84
|
+
}
|
|
85
|
+
const local = matches[0];
|
|
86
|
+
if (local !== undefined) {
|
|
87
|
+
return expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(local[0])), ["id"]);
|
|
88
|
+
}
|
|
89
|
+
const label = appScopedResourceLabel(ctx.appTfLabel, sanitizeName(name));
|
|
90
|
+
ctx.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, label, name, {
|
|
91
|
+
app_id: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
|
|
92
|
+
});
|
|
93
|
+
return expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, label, ["id"]);
|
|
94
|
+
}
|
|
76
95
|
function toSortableAgents(entities) {
|
|
77
96
|
const out = [];
|
|
78
97
|
for (const entity of entities) {
|
|
@@ -164,8 +183,29 @@ function skillIdValue(token, ctx) {
|
|
|
164
183
|
return expr.resourceAttr(SKILL_RESOURCE_TYPE, appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(refName)), ["id"]);
|
|
165
184
|
}
|
|
166
185
|
const name = token.name ?? refName;
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
if (name === "") {
|
|
187
|
+
throw new EntityTfError(`agent skillAccess: foreign skill token "${refName}" has no platform name; regenerate the owning app catalog so skillRef({ name }) is retained`);
|
|
188
|
+
}
|
|
189
|
+
if (token.parent === undefined || token.parentName === undefined || token.parentName === "") {
|
|
190
|
+
throw new EntityTfError(`agent skillAccess: foreign skill "${name}" has no owning app identity; use the skill token from its generated app catalog`);
|
|
191
|
+
}
|
|
192
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey("app", token.parent));
|
|
193
|
+
let appId;
|
|
194
|
+
let ownerTfLabel;
|
|
195
|
+
if (sibling !== undefined) {
|
|
196
|
+
ownerTfLabel = sibling.tfLabel;
|
|
197
|
+
appId = expr.resourceAttr(APP_RESOURCE_TYPE, sibling.tfLabel, ["id"]);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
ownerTfLabel = sanitizeName(token.parentName);
|
|
201
|
+
ctx.orgRefs.foreignApp(ownerTfLabel, token.parentName);
|
|
202
|
+
appId = expr.dataAttr(APP_RESOURCE_TYPE, ownerTfLabel, ["id"]);
|
|
203
|
+
}
|
|
204
|
+
// A skill name is only unique within its owning app. Scope the Terraform
|
|
205
|
+
// label too, or same-named skills from two foreign apps would collapse to
|
|
206
|
+
// one data block and both references would silently resolve to its last owner.
|
|
207
|
+
const tfLabel = appScopedResourceLabel(ownerTfLabel, sanitizeName(name));
|
|
208
|
+
ctx.orgRefs.foreignSkill(tfLabel, name, appId);
|
|
169
209
|
return expr.dataAttr(SKILL_RESOURCE_TYPE, tfLabel, ["id"]);
|
|
170
210
|
}
|
|
171
211
|
/** `elementum_agent` + one tool resource per implemented tool, in ei's dialect. */
|
|
@@ -176,7 +216,7 @@ export function agentToTf(entity, ctx) {
|
|
|
176
216
|
const payload = entity.payload;
|
|
177
217
|
const elementum = payload?.agent?.elementum;
|
|
178
218
|
if (payload === null || typeof payload !== "object" || elementum === undefined) {
|
|
179
|
-
throw new EntityTfError(`agent "${entity.refName}" has no agent.elementum payload — was it built with
|
|
219
|
+
throw new EntityTfError(`agent "${entity.refName}" has no agent.elementum payload — was it built with agent?`);
|
|
180
220
|
}
|
|
181
221
|
// The bag key IS the label (the stable naming contract) — the agent's
|
|
182
222
|
// refName comes from its file name, exactly like an app's.
|
|
@@ -245,10 +285,18 @@ export function agentToTf(entity, ctx) {
|
|
|
245
285
|
appRefName: ctx.appRefName,
|
|
246
286
|
appTfLabel: ctx.appTfLabel,
|
|
247
287
|
agentBareTfLabel,
|
|
248
|
-
foreignAppRef: (l, n) => ctx.orgRefs.foreignApp(l, n),
|
|
249
|
-
foreignElementRef: (l, n) => ctx.orgRefs.foreignElement(l, n),
|
|
288
|
+
foreignAppRef: (l, n, ns) => ctx.orgRefs.foreignApp(l, n, ns),
|
|
289
|
+
foreignElementRef: (l, n, ns) => ctx.orgRefs.foreignElement(l, n, ns),
|
|
290
|
+
foreignAutomationRef: (l, n, owner) => {
|
|
291
|
+
const ownerKind = owner.kind === "element" ? "element" : "app";
|
|
292
|
+
const ownerRef = resolveForeignRef(ownerKind, { name: owner.name, namespace: owner.namespace }, ctx.orgRefs, ctx.diagnostics, `agent run-automation owner`);
|
|
293
|
+
ctx.orgRefs.rawLookup("elementum_automation", l, n, {
|
|
294
|
+
app_id: ownerRef.value,
|
|
295
|
+
});
|
|
296
|
+
},
|
|
250
297
|
foreignFieldRef: (t, l, o, n) => ctx.orgRefs.foreignField(t, l, o, n),
|
|
251
298
|
workspaceAspects: ctx.workspaceAspects,
|
|
299
|
+
serviceAccountRef: (_label, serviceAccountName) => serviceAccountValue(serviceAccountName, ctx),
|
|
252
300
|
diagnostics: ctx.diagnostics,
|
|
253
301
|
});
|
|
254
302
|
if (tool !== undefined)
|