@elementumai/edk 0.9.2 → 0.9.6
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
|
@@ -52,33 +52,44 @@ export interface AgentSearchRawIdField {
|
|
|
52
52
|
readonly description: string;
|
|
53
53
|
}
|
|
54
54
|
export type AgentSearchFieldInput<Target extends ToolTarget = ToolTarget> = AgentSearchField<Target> | AgentSearchRawIdField;
|
|
55
|
+
/** A typed target field exposed through a search-table tool's newer fields dialect. */
|
|
56
|
+
export interface AgentSearchTableField<Target extends ElementCatalogRef = ElementCatalogRef> {
|
|
57
|
+
readonly field: FieldRef<Target["refName"]>;
|
|
58
|
+
readonly name?: string;
|
|
59
|
+
readonly description?: string;
|
|
60
|
+
}
|
|
55
61
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* live, searchTable's fields describe columns of the search table's own
|
|
60
|
-
* schema, not app/element fields, so there's no `elementum_*_field`
|
|
61
|
-
* resource to reference (same raw-id convention as
|
|
62
|
-
* `TableRecordsSearchOptions.table`).
|
|
62
|
+
* Pull-fidelity fallback when a non-recursive export cannot map a search-table
|
|
63
|
+
* field id to the target element's catalog. Recursive pull upgrades known ids
|
|
64
|
+
* to {@link AgentSearchTableField}.
|
|
63
65
|
*/
|
|
64
|
-
export interface
|
|
66
|
+
export interface AgentSearchTableRawIdField {
|
|
65
67
|
readonly fieldId: UnsafePlatformId;
|
|
66
68
|
readonly name?: string;
|
|
67
69
|
readonly description?: string;
|
|
68
70
|
}
|
|
71
|
+
export type AgentSearchTableFieldInput<Target extends ElementCatalogRef = ElementCatalogRef> = AgentSearchTableField<Target> | AgentSearchTableRawIdField;
|
|
69
72
|
/**
|
|
70
73
|
* A field exposed to a searchTable tool's legacy `return_fields` wire shape
|
|
71
74
|
* (field_id/name/display_name, no description) — the dialect most existing
|
|
72
75
|
* elementum_agent_ai_search_tool resources still use; the provider is
|
|
73
76
|
* deprecating it in favor of the same shape as {@link AgentSearchTableField},
|
|
74
77
|
* but both are live on the platform today (see `agentSearchTable`'s doc
|
|
75
|
-
* comment).
|
|
78
|
+
* comment). Recursive pull resolves the same target-owned field identity as
|
|
79
|
+
* the newer dialect.
|
|
76
80
|
*/
|
|
77
|
-
export interface AgentSearchReturnField {
|
|
81
|
+
export interface AgentSearchReturnField<Target extends ElementCatalogRef = ElementCatalogRef> {
|
|
82
|
+
readonly field: FieldRef<Target["refName"]>;
|
|
83
|
+
readonly name?: string;
|
|
84
|
+
readonly displayName?: string;
|
|
85
|
+
}
|
|
86
|
+
/** Raw-id fallback for an unresolved legacy return_fields entry. */
|
|
87
|
+
export interface AgentSearchRawIdReturnField {
|
|
78
88
|
readonly fieldId: UnsafePlatformId;
|
|
79
89
|
readonly name?: string;
|
|
80
90
|
readonly displayName?: string;
|
|
81
91
|
}
|
|
92
|
+
export type AgentSearchReturnFieldInput<Target extends ElementCatalogRef = ElementCatalogRef> = AgentSearchReturnField<Target> | AgentSearchRawIdReturnField;
|
|
82
93
|
/** A field the agent can populate/modify via a create/update record tool. */
|
|
83
94
|
export interface AgentRecordField<Target extends ToolTarget = ToolTarget> {
|
|
84
95
|
readonly field: FieldRef<Target["refName"]>;
|
|
@@ -99,6 +110,7 @@ export interface AgentRecordRawIdField {
|
|
|
99
110
|
/** Required by the provider on every tool field. */
|
|
100
111
|
readonly description: string;
|
|
101
112
|
readonly required?: boolean;
|
|
113
|
+
readonly defaultValue?: string;
|
|
102
114
|
}
|
|
103
115
|
export type AgentRecordFieldInput<Target extends ToolTarget = ToolTarget> = AgentRecordField<Target> | AgentRecordRawIdField;
|
|
104
116
|
/** Input-parameter mapping for an execute-workflow tool. */
|
|
@@ -137,29 +149,32 @@ export type SearchRecordsToolOptions<Target extends ToolTarget = ToolTarget> = C
|
|
|
137
149
|
};
|
|
138
150
|
export declare function agentSearchRecords<Target extends ToolTarget>(opts: SearchRecordsToolOptions<Target>): AgentTool;
|
|
139
151
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* (unlike searchAspect) — a search table tool doesn't always need a live
|
|
146
|
-
* record target. `fields`/`returnFields` are mutually exclusive: most
|
|
152
|
+
* A search-table tool takes the owning element, its typed SearchTableRef, and
|
|
153
|
+
* typed fields from that same element. The provider exports the field ids as
|
|
154
|
+
* strings, but recursive pull maps known ids back to those catalog fields;
|
|
155
|
+
* unresolved non-recursive exports retain an explicit raw-id fallback.
|
|
156
|
+
* `fields`/`returnFields` are mutually exclusive: most
|
|
147
157
|
* existing tools use the legacy `return_fields` wire shape (`returnFields`,
|
|
148
158
|
* field_id/name/displayName), which the provider is deprecating in favor of
|
|
149
159
|
* the same shape searchAspect already uses (`fields`, field_id/name/
|
|
150
160
|
* description) — both are live on the platform today, so both round-trip.
|
|
151
161
|
*/
|
|
152
162
|
/** A search-table tool targets the ELEMENT that owns the search table — never an app. */
|
|
163
|
+
type SearchTableFieldDialect<Target extends ElementCatalogRef> = {
|
|
164
|
+
/** Newer field shape — mutually exclusive with `returnFields`. */
|
|
165
|
+
readonly fields?: readonly AgentSearchTableFieldInput<Target>[];
|
|
166
|
+
readonly returnFields?: never;
|
|
167
|
+
} | {
|
|
168
|
+
readonly fields?: never;
|
|
169
|
+
/** Legacy field shape — mutually exclusive with `fields`. */
|
|
170
|
+
readonly returnFields?: readonly AgentSearchReturnFieldInput<Target>[];
|
|
171
|
+
};
|
|
153
172
|
export type SearchTableToolV2<Target extends ElementCatalogRef = ElementCatalogRef> = CommonToolOptions & TargetOption<Target> & {
|
|
154
173
|
readonly table: SearchTableRef;
|
|
155
174
|
readonly queryDescription: string;
|
|
156
|
-
/** searchTable's newer field shape — mutually exclusive with `returnFields`. */
|
|
157
|
-
readonly fields?: readonly AgentSearchTableField[];
|
|
158
|
-
/** searchTable's legacy field shape — mutually exclusive with `fields`. */
|
|
159
|
-
readonly returnFields?: readonly AgentSearchReturnField[];
|
|
160
175
|
readonly filter?: Filter;
|
|
161
176
|
readonly limit?: number;
|
|
162
|
-
}
|
|
177
|
+
} & SearchTableFieldDialect<Target>;
|
|
163
178
|
export declare function agentSearchTable<Target extends ElementCatalogRef = ElementCatalogRef>(opts: SearchTableToolV2<Target>): AgentTool;
|
|
164
179
|
export type CreateRecordToolV2<Target extends ToolTarget = ToolTarget> = CommonToolOptions & TargetOption<Target> & {
|
|
165
180
|
readonly fields?: readonly AgentRecordFieldInput<Target>[];
|
|
@@ -272,7 +287,7 @@ export type RunAutomationToolV2<A extends AutomationCatalogRef> = CommonToolOpti
|
|
|
272
287
|
* parameter / output property names, every REQUIRED parameter must be
|
|
273
288
|
* mapped (a non-optional key), and a required parameter's input must set
|
|
274
289
|
* `required: true`. The agent-facing name defaults to the record key;
|
|
275
|
-
* override with `name:`. `
|
|
290
|
+
* override with `name:`. `agent().def()` re-validates at runtime.
|
|
276
291
|
*
|
|
277
292
|
* Reference tokens are synthesized from the record keys alone — the factory
|
|
278
293
|
* never dereferences `automation.trigger`/`outputs`, so agent files load
|
|
@@ -15,7 +15,7 @@ function serializeRunAs(runAs) {
|
|
|
15
15
|
*/
|
|
16
16
|
const EXECUTE_WORKFLOW_TIMEOUT = "PT10M";
|
|
17
17
|
function common(opts) {
|
|
18
|
-
// Authoring-layer name check (mirrors
|
|
18
|
+
// Authoring-layer name check (mirrors app's handle/namespace guards).
|
|
19
19
|
// Every tool factory routes through here, so this is the single enforcement
|
|
20
20
|
// point — the tf passes never re-check.
|
|
21
21
|
if (!isValidToolName(opts.name)) {
|
|
@@ -52,15 +52,29 @@ function searchFieldToken(f) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function searchTableFieldToken(f) {
|
|
55
|
+
if ("fieldId" in f) {
|
|
56
|
+
return {
|
|
57
|
+
fieldId: f.fieldId.value,
|
|
58
|
+
...(f.name !== undefined ? { name: f.name } : {}),
|
|
59
|
+
...(f.description !== undefined ? { description: f.description } : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
55
62
|
return {
|
|
56
|
-
fieldId: f.
|
|
63
|
+
fieldId: f.field,
|
|
57
64
|
...(f.name !== undefined ? { name: f.name } : {}),
|
|
58
65
|
...(f.description !== undefined ? { description: f.description } : {}),
|
|
59
66
|
};
|
|
60
67
|
}
|
|
61
68
|
function returnFieldToken(f) {
|
|
69
|
+
if ("fieldId" in f) {
|
|
70
|
+
return {
|
|
71
|
+
fieldId: f.fieldId.value,
|
|
72
|
+
...(f.name !== undefined ? { name: f.name } : {}),
|
|
73
|
+
...(f.displayName !== undefined ? { displayName: f.displayName } : {}),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
62
76
|
return {
|
|
63
|
-
fieldId: f.
|
|
77
|
+
fieldId: f.field,
|
|
64
78
|
...(f.name !== undefined ? { name: f.name } : {}),
|
|
65
79
|
...(f.displayName !== undefined ? { displayName: f.displayName } : {}),
|
|
66
80
|
};
|
|
@@ -73,6 +87,7 @@ function recordFieldToken(f) {
|
|
|
73
87
|
...(f.name !== undefined ? { name: f.name } : {}),
|
|
74
88
|
description: f.description,
|
|
75
89
|
...(f.required !== undefined ? { required: f.required } : {}),
|
|
90
|
+
...(f.defaultValue !== undefined ? { defaultValue: f.defaultValue } : {}),
|
|
76
91
|
};
|
|
77
92
|
}
|
|
78
93
|
// Provider requires `name` on every tool field — default to the field's
|
|
@@ -107,9 +122,8 @@ export function agentSearchTable(opts) {
|
|
|
107
122
|
aspectId: targetOf(opts),
|
|
108
123
|
searchTableId: opts.table,
|
|
109
124
|
queryDescription: opts.queryDescription,
|
|
110
|
-
// Distinct
|
|
111
|
-
//
|
|
112
|
-
// raw platform ids instead, see AgentSearchTableField's comment.
|
|
125
|
+
// Distinct internal keys preserve the provider's newer `fields` and
|
|
126
|
+
// legacy `return_fields` dialects while both carry typed FieldRefs.
|
|
113
127
|
...(opts.fields !== undefined ? { searchTableFields: opts.fields.map(searchTableFieldToken) } : {}),
|
|
114
128
|
...(opts.returnFields !== undefined ? { returnFields: opts.returnFields.map(returnFieldToken) } : {}),
|
|
115
129
|
...(opts.filter !== undefined ? { filter: opts.filter } : {}),
|
|
@@ -185,7 +199,7 @@ export function agentExecuteWorkflow(opts) {
|
|
|
185
199
|
* parameter / output property names, every REQUIRED parameter must be
|
|
186
200
|
* mapped (a non-optional key), and a required parameter's input must set
|
|
187
201
|
* `required: true`. The agent-facing name defaults to the record key;
|
|
188
|
-
* override with `name:`. `
|
|
202
|
+
* override with `name:`. `agent().def()` re-validates at runtime.
|
|
189
203
|
*
|
|
190
204
|
* Reference tokens are synthesized from the record keys alone — the factory
|
|
191
205
|
* never dereferences `automation.trigger`/`outputs`, so agent files load
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type AgentEvaluationRef, type AiServiceRef, type AppCatalogRef } from "../../catalog/index.js";
|
|
2
|
+
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
|
+
export interface AgentEvaluationOptions<AppRefName extends string = string> extends EntityDeployOptions {
|
|
4
|
+
/** The app whose scenarios may use this evaluation rubric. */
|
|
5
|
+
readonly app: AppCatalogRef<AppRefName>;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
/** Instructions given to the evaluator model when scoring a scenario result. */
|
|
8
|
+
readonly prompt: string;
|
|
9
|
+
/** A pulled organization AI-service token. */
|
|
10
|
+
readonly connector: AiServiceRef;
|
|
11
|
+
/** Minimum score required to pass. The product supports values from 0 through 4. */
|
|
12
|
+
readonly passingThreshold: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentEvaluationConfigured {
|
|
15
|
+
ref(refName: string): AgentEvaluationRef;
|
|
16
|
+
def(refName: string): DeployableEntity;
|
|
17
|
+
}
|
|
18
|
+
/** Define an app-owned rubric used to evaluate agent scenario responses. */
|
|
19
|
+
export declare function agentEvaluation<const AppRefName extends string>(opts: AgentEvaluationOptions<AppRefName>): AgentEvaluationConfigured;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { slimTokens, } from "../../catalog/index.js";
|
|
2
|
+
function validateAgentEvaluation(refName, opts) {
|
|
3
|
+
const fail = (message) => {
|
|
4
|
+
throw new Error(`agentEvaluation "${refName}": ${message}`);
|
|
5
|
+
};
|
|
6
|
+
if (opts.app.__kind !== "app")
|
|
7
|
+
fail("app must be an app catalog ref");
|
|
8
|
+
if (opts.name.trim() === "")
|
|
9
|
+
fail("name must not be empty");
|
|
10
|
+
if (opts.prompt.trim() === "")
|
|
11
|
+
fail("prompt must not be empty");
|
|
12
|
+
if (opts.connector.__kind !== "connector")
|
|
13
|
+
fail("connector must be a pulled AI-service token");
|
|
14
|
+
if (!Number.isFinite(opts.passingThreshold) || opts.passingThreshold < 0 || opts.passingThreshold > 4) {
|
|
15
|
+
fail("passingThreshold must be a finite number from 0 through 4");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Define an app-owned rubric used to evaluate agent scenario responses. */
|
|
19
|
+
export function agentEvaluation(opts) {
|
|
20
|
+
return {
|
|
21
|
+
ref(refName) {
|
|
22
|
+
return { __kind: "agent-evaluation", refName, name: opts.name, parent: opts.app.refName };
|
|
23
|
+
},
|
|
24
|
+
def(refName) {
|
|
25
|
+
validateAgentEvaluation(refName, opts);
|
|
26
|
+
return {
|
|
27
|
+
kind: "agent-evaluation",
|
|
28
|
+
parent: opts.app.refName,
|
|
29
|
+
refName,
|
|
30
|
+
payload: slimTokens({
|
|
31
|
+
app: opts.app,
|
|
32
|
+
name: opts.name,
|
|
33
|
+
prompt: opts.prompt,
|
|
34
|
+
connector: opts.connector,
|
|
35
|
+
passingThreshold: opts.passingThreshold,
|
|
36
|
+
}),
|
|
37
|
+
...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { quote } from "../../../../pull/util.js";
|
|
2
|
+
import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
|
|
3
|
+
import { safeIdentifier } from "../../../internal/safe-identifier.js";
|
|
4
|
+
export function printAgentEvaluation(evaluation, opts) {
|
|
5
|
+
const [providerKey, modelKey] = evaluation.connectorKey.split(".");
|
|
6
|
+
const connector = providerKey !== undefined && modelKey !== undefined
|
|
7
|
+
? `catalog.aiProviders.${providerKey}.models.${modelKey}`
|
|
8
|
+
: `{ __kind: "connector", refName: "TODO_CONNECTOR", name: "TODO_CONNECTOR", parent: "TODO_PROVIDER" } /* TODO: unresolved connector ${quote(evaluation.connectorKey)} */`;
|
|
9
|
+
const identifier = safeIdentifier(evaluation.refName, "agentEvaluation");
|
|
10
|
+
return [
|
|
11
|
+
"/**",
|
|
12
|
+
" * Auto-generated by EDK (v2 pull). Hand-edit freely; the generator is a",
|
|
13
|
+
" * one-shot starting point, not a live-binding view.",
|
|
14
|
+
" */",
|
|
15
|
+
"",
|
|
16
|
+
`import { agentEvaluation } from ${quote(sdkPackageSpecifier("app"))};`,
|
|
17
|
+
'import catalog from "@catalog";',
|
|
18
|
+
"",
|
|
19
|
+
`const ${identifier} = agentEvaluation({`,
|
|
20
|
+
` app: catalog.${opts.appRefName},`,
|
|
21
|
+
` name: ${quote(evaluation.name)},`,
|
|
22
|
+
` prompt: ${quote(evaluation.prompt)},`,
|
|
23
|
+
` connector: ${connector},`,
|
|
24
|
+
` passingThreshold: ${evaluation.passingThreshold},`,
|
|
25
|
+
"});",
|
|
26
|
+
"",
|
|
27
|
+
`export default ${identifier};`,
|
|
28
|
+
"",
|
|
29
|
+
].join("\n");
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
export interface NormalizedAgentEvaluation {
|
|
4
|
+
readonly refName: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly prompt: string;
|
|
7
|
+
readonly connectorKey: string;
|
|
8
|
+
readonly passingThreshold: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function agentEvaluationFromTf(block: TfBlock, opts: {
|
|
11
|
+
readonly appLabel: string;
|
|
12
|
+
}, ctx: FromTfContext): NormalizedAgentEvaluation | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { dataRefLabel, resourceRefLabel, } from "../../engine/pull/context.js";
|
|
2
|
+
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
3
|
+
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
4
|
+
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
5
|
+
const KNOWN_ATTRS = new Set([
|
|
6
|
+
"app_id",
|
|
7
|
+
"name",
|
|
8
|
+
"prompt",
|
|
9
|
+
"ai_provider_connector_id",
|
|
10
|
+
"passing_threshold",
|
|
11
|
+
]);
|
|
12
|
+
export function agentEvaluationFromTf(block, opts, ctx) {
|
|
13
|
+
const label = block.label ?? "";
|
|
14
|
+
const where = `agent evaluation "${label}"`;
|
|
15
|
+
for (const key of Object.keys(block.attrs)) {
|
|
16
|
+
if (!KNOWN_ATTRS.has(key)) {
|
|
17
|
+
ctx.diagnostics.push(`${where}: unhandled attribute "${key}" — extend agentEvaluationFromTf deliberately`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (resourceRefLabel(block.attrs["app_id"], APP_RESOURCE_TYPE) !== opts.appLabel) {
|
|
21
|
+
ctx.diagnostics.push(`${where}: app_id does not reference ${APP_RESOURCE_TYPE}.${opts.appLabel}; skipped`);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const connectorLabel = dataRefLabel(block.attrs["ai_provider_connector_id"], "elementum_ai_provider_connector");
|
|
25
|
+
const connectorKey = connectorLabel === undefined
|
|
26
|
+
? undefined
|
|
27
|
+
: connectorIdentityFromTf("elementum_ai_provider_connector", connectorLabel, ctx).catalogKey;
|
|
28
|
+
if (connectorLabel === undefined || connectorKey === undefined) {
|
|
29
|
+
ctx.diagnostics.push(`${where}: ai_provider_connector_id is not a resolvable AI-service data reference; skipped`);
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const name = block.attrs["name"];
|
|
33
|
+
const prompt = block.attrs["prompt"];
|
|
34
|
+
const passingThreshold = block.attrs["passing_threshold"];
|
|
35
|
+
if (typeof name !== "string" || typeof prompt !== "string" || typeof passingThreshold !== "number") {
|
|
36
|
+
ctx.diagnostics.push(`${where}: name, prompt, and passing_threshold must be literal values; skipped`);
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
refName: scopedLabelToBagKey(opts.appLabel, label, "app"),
|
|
41
|
+
name,
|
|
42
|
+
prompt,
|
|
43
|
+
connectorKey,
|
|
44
|
+
passingThreshold,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { agentEvaluation, type AgentEvaluationConfigured, type AgentEvaluationOptions, } from "./build.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { agentEvaluation, } from "./build.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { bareFactoryEntry } from "../../catalog/render-helpers.js";
|
|
2
|
+
import { NO_CANVAS } from "../../graph/types.js";
|
|
3
|
+
import { printAgentEvaluation } from "./deserializer/print-agent-evaluation.js";
|
|
4
|
+
import { agentEvaluationFromTf } from "./from-tf.js";
|
|
5
|
+
import { agentEvaluationToTf } from "./to-tf.js";
|
|
6
|
+
export const AGENT_EVALUATION_RESOURCE_TYPE = "elementum_agent_evaluation";
|
|
7
|
+
function stubRef(refName, parent) {
|
|
8
|
+
return { __kind: "agent-evaluation", refName, name: refName, parent };
|
|
9
|
+
}
|
|
10
|
+
function refFromAuthoring(args) {
|
|
11
|
+
const configured = args.defaultExport;
|
|
12
|
+
return typeof configured?.ref === "function" ? configured.ref(args.refName) : undefined;
|
|
13
|
+
}
|
|
14
|
+
export const agentEvaluationModule = {
|
|
15
|
+
kind: "agent-evaluation",
|
|
16
|
+
stream: { role: "streamMember" },
|
|
17
|
+
authoring: { unit: "ownFile", bag: "evaluations" },
|
|
18
|
+
parents: [{ parent: "app", child: "agent-evaluation" }],
|
|
19
|
+
resource: { shape: "single", resourceType: AGENT_EVALUATION_RESOURCE_TYPE, adoptable: true },
|
|
20
|
+
data: { participates: false },
|
|
21
|
+
lifecycle: {
|
|
22
|
+
participates: true,
|
|
23
|
+
extractOwnFile: (ownBlocks, _stream, ctx) => {
|
|
24
|
+
const items = [];
|
|
25
|
+
for (const block of ownBlocks) {
|
|
26
|
+
const evaluation = agentEvaluationFromTf(block, { appLabel: ctx.appTfLabel }, ctx);
|
|
27
|
+
if (evaluation !== undefined)
|
|
28
|
+
items.push(evaluation);
|
|
29
|
+
}
|
|
30
|
+
return { items, skipped: [], diagnostics: [] };
|
|
31
|
+
},
|
|
32
|
+
printOwnFile: (item, opts) => {
|
|
33
|
+
const evaluation = item;
|
|
34
|
+
return {
|
|
35
|
+
refName: evaluation.refName,
|
|
36
|
+
source: printAgentEvaluation(evaluation, { appRefName: opts.appRefName }),
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
toTf: (entity, ctx) => agentEvaluationToTf(entity, {
|
|
40
|
+
appRefName: ctx.appRefName,
|
|
41
|
+
appTfLabel: ctx.appTfLabel,
|
|
42
|
+
orgRefs: ctx.orgRefs,
|
|
43
|
+
diagnostics: ctx.diagnostics,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
canvas: NO_CANVAS,
|
|
47
|
+
catalog: {
|
|
48
|
+
participates: true,
|
|
49
|
+
refKind: "agent-evaluation",
|
|
50
|
+
catalogBag: "evaluations",
|
|
51
|
+
renderOrder: 64,
|
|
52
|
+
catalogRoot: "app",
|
|
53
|
+
factoryName: "agentEvaluationRef",
|
|
54
|
+
renderEntry: ({ keyName, baseIndent }) => bareFactoryEntry("agentEvaluationRef", keyName, baseIndent),
|
|
55
|
+
stubRef,
|
|
56
|
+
refFromAuthoring,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
2
|
+
import { type DeployableEntity } from "../../engine/entity.js";
|
|
3
|
+
import { type TfBlock } from "../../engine/tf/index.js";
|
|
4
|
+
export declare function agentEvaluationToTf(entity: DeployableEntity, opts: {
|
|
5
|
+
readonly appRefName: string;
|
|
6
|
+
readonly appTfLabel: string;
|
|
7
|
+
readonly orgRefs: OrgRefLookup;
|
|
8
|
+
readonly diagnostics: string[];
|
|
9
|
+
}): {
|
|
10
|
+
readonly blocks: readonly TfBlock[];
|
|
11
|
+
readonly address: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { expr, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
|
+
import { APP_RESOURCE_TYPE } from "../app/module.js";
|
|
4
|
+
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
5
|
+
import { AGENT_EVALUATION_RESOURCE_TYPE } from "./module.js";
|
|
6
|
+
export function agentEvaluationToTf(entity, opts) {
|
|
7
|
+
if (entity.kind !== "agent-evaluation") {
|
|
8
|
+
throw new EntityTfError(`agentEvaluationToTf expects kind "agent-evaluation"; got "${entity.kind}"`);
|
|
9
|
+
}
|
|
10
|
+
const evaluation = entity.payload;
|
|
11
|
+
if (evaluation === null || evaluation.app?.refName !== opts.appRefName) {
|
|
12
|
+
throw new EntityTfError(`agent evaluation "${entity.refName}" does not reference owning app "${opts.appRefName}"`);
|
|
13
|
+
}
|
|
14
|
+
const connectorKey = evaluation.connector?.parent !== undefined
|
|
15
|
+
? `${evaluation.connector.parent}.${evaluation.connector.refName ?? ""}`
|
|
16
|
+
: evaluation.connector?.refName ?? "";
|
|
17
|
+
const connector = opts.orgRefs.byTsLabel(CONNECTOR_ORG_BAG, connectorKey);
|
|
18
|
+
if (connector === undefined) {
|
|
19
|
+
throw new EntityTfError(`agent evaluation "${entity.refName}": connector token "${connectorKey}" is not in the org catalog — re-run \`elementum pull org --data-only\``);
|
|
20
|
+
}
|
|
21
|
+
const label = scopedResourceLabel(opts.appTfLabel, tsLabelToTfLabel(entity.refName), "app");
|
|
22
|
+
const block = {
|
|
23
|
+
kind: "resource",
|
|
24
|
+
type: AGENT_EVALUATION_RESOURCE_TYPE,
|
|
25
|
+
label,
|
|
26
|
+
attrs: {
|
|
27
|
+
app_id: expr.resourceAttr(APP_RESOURCE_TYPE, opts.appTfLabel, ["id"]),
|
|
28
|
+
name: evaluation.name ?? "",
|
|
29
|
+
prompt: evaluation.prompt ?? "",
|
|
30
|
+
ai_provider_connector_id: expr.dataAttr("elementum_ai_provider_connector", connector.tfLabel, ["id"]),
|
|
31
|
+
passing_threshold: evaluation.passingThreshold ?? 0,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return { blocks: [block], address: `${AGENT_EVALUATION_RESOURCE_TYPE}.${label}` };
|
|
35
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
8
8
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
9
|
+
import type { AgentToolRunAs } from "../agent/tools.js";
|
|
9
10
|
export interface NormalizedToolField {
|
|
10
11
|
/** The field's bag key in the TARGET aspect's `fields: {}` (bijective image of its label). Mutually exclusive with `rawFieldId`. */
|
|
11
12
|
readonly key?: string;
|
|
@@ -20,14 +21,13 @@ export interface NormalizedToolField {
|
|
|
20
21
|
readonly name?: string;
|
|
21
22
|
readonly description?: string;
|
|
22
23
|
readonly required?: boolean;
|
|
24
|
+
readonly defaultValue?: string;
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
|
-
* searchTable's own field shapes.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* schema, not app/element fields, so there's no `elementum_*_field` resource
|
|
30
|
-
* (and therefore no catalog bag key) to resolve them to.
|
|
27
|
+
* searchTable's own field shapes. The provider export carries field_id as a
|
|
28
|
+
* raw string (confirmed live across the captured resources), so this pass
|
|
29
|
+
* preserves it. Recursive app pull resolves known ids through its dependency
|
|
30
|
+
* field registry before printing authored source.
|
|
31
31
|
*/
|
|
32
32
|
export interface NormalizedSearchTableField {
|
|
33
33
|
readonly fieldId: string;
|
|
@@ -73,9 +73,10 @@ export interface NormalizedAgentTool {
|
|
|
73
73
|
readonly name: string;
|
|
74
74
|
readonly description: string;
|
|
75
75
|
readonly startMessage?: string;
|
|
76
|
+
readonly runAs?: AgentToolRunAs;
|
|
76
77
|
/** absent for executeWorkflow — its target is an automation, not an aspect. searchTable's target is also optional. */
|
|
77
78
|
readonly target?: NormalizedToolTarget;
|
|
78
|
-
/** createRecord/searchAspect/updateRecord only
|
|
79
|
+
/** createRecord/searchAspect/updateRecord only; searchTable ids are upgraded later by recursive pull. */
|
|
79
80
|
readonly fields?: readonly NormalizedToolField[];
|
|
80
81
|
/** searchTable's newer field shape (field_id/name/description) — mutually exclusive with `returnFields`. */
|
|
81
82
|
readonly searchTableFields?: readonly NormalizedSearchTableField[];
|
|
@@ -5,10 +5,49 @@
|
|
|
5
5
|
* agent or app resource types.
|
|
6
6
|
*/
|
|
7
7
|
import { EntityTfError } from "../../engine/entity.js";
|
|
8
|
-
import { optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
8
|
+
import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
9
|
import { isTfExpr, scopedLabelToBagKey, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
10
10
|
import { resolveToolFieldKey } from "../shared/tool-field-ref.js";
|
|
11
11
|
import { KNOWN_TOOL_ATTRS, TOOL_SUB_TYPE_BY_RESOURCE } from "./types.js";
|
|
12
|
+
function runAsFromTf(attrs, owner, where, ctx) {
|
|
13
|
+
const value = optionalString(attrs, "run_as", where, ctx);
|
|
14
|
+
if (value === "current_user")
|
|
15
|
+
return { currentUser: true };
|
|
16
|
+
if (value === "publisher")
|
|
17
|
+
return { publisher: true };
|
|
18
|
+
if (value === "service_account") {
|
|
19
|
+
const dataLabel = dataRefLabel(attrs["service_account_id"], "elementum_service_account");
|
|
20
|
+
if (dataLabel !== undefined) {
|
|
21
|
+
const name = ctx.dataName("elementum_service_account", dataLabel);
|
|
22
|
+
if (name !== undefined && name !== "") {
|
|
23
|
+
return { serviceAccount: { __kind: "serviceAccount", appRefName: owner.appLabel, name } };
|
|
24
|
+
}
|
|
25
|
+
ctx.diagnostics.push(`${where}: service_account_id references data.elementum_service_account.${dataLabel}, but the stream has no matching named data block; dropped`);
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const resourceLabel = resourceRefLabel(attrs["service_account_id"], "elementum_service_account");
|
|
29
|
+
const imported = typeof attrs["service_account_id"] === "string"
|
|
30
|
+
? ctx.importedResource?.(attrs["service_account_id"])
|
|
31
|
+
: undefined;
|
|
32
|
+
const account = resourceLabel !== undefined
|
|
33
|
+
? ctx.resourceByAddress?.(`elementum_service_account.${resourceLabel}`)
|
|
34
|
+
: imported?.type === "elementum_service_account" ? imported : undefined;
|
|
35
|
+
const explicitName = account?.attrs["name"];
|
|
36
|
+
const firstName = account?.attrs["first_name"];
|
|
37
|
+
const lastName = account?.attrs["last_name"];
|
|
38
|
+
const name = typeof explicitName === "string" && explicitName !== ""
|
|
39
|
+
? explicitName
|
|
40
|
+
: typeof firstName === "string" && typeof lastName === "string" ? `${firstName} ${lastName}` : undefined;
|
|
41
|
+
if (name !== undefined) {
|
|
42
|
+
return { serviceAccount: { __kind: "serviceAccount", appRefName: owner.appLabel, name } };
|
|
43
|
+
}
|
|
44
|
+
ctx.diagnostics.push(`${where}: service_account_id is not a named data.elementum_service_account reference; use a serviceAccountRef({ app, name }); dropped`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (value !== undefined)
|
|
48
|
+
ctx.diagnostics.push(`${where}: unsupported run_as ${JSON.stringify(value)}; dropped`);
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
12
51
|
/**
|
|
13
52
|
* One tool block → its normalized shape; undefined = skipped with a
|
|
14
53
|
* diagnostic (unimplemented sub-type, wrong owner, unresolvable target).
|
|
@@ -46,10 +85,12 @@ export function toolFromTf(block, owner, ctx) {
|
|
|
46
85
|
return executeWorkflowFromTf(block, name, where, owner, ctx);
|
|
47
86
|
}
|
|
48
87
|
const startMessage = optionalString(attrs, "start_message", where, ctx);
|
|
88
|
+
const runAs = runAsFromTf(attrs, owner, where, ctx);
|
|
49
89
|
const common = {
|
|
50
90
|
name,
|
|
51
91
|
description: optionalString(attrs, "description", where, ctx) ?? "",
|
|
52
92
|
...(startMessage !== undefined && { startMessage }),
|
|
93
|
+
...(runAs !== undefined && { runAs }),
|
|
53
94
|
};
|
|
54
95
|
if (subType.typeKey === "runAgent") {
|
|
55
96
|
const targetLabel = resourceRefLabel(attrs["target_agent_id"], "elementum_agent");
|
|
@@ -173,6 +214,7 @@ export function toolFromTf(block, owner, ctx) {
|
|
|
173
214
|
...(typeof rec["name"] === "string" && { name: rec["name"] }),
|
|
174
215
|
...(typeof rec["description"] === "string" && { description: rec["description"] }),
|
|
175
216
|
...(typeof rec["required"] === "boolean" && { required: rec["required"] }),
|
|
217
|
+
...(typeof rec["default_value"] === "string" && { defaultValue: rec["default_value"] }),
|
|
176
218
|
});
|
|
177
219
|
}
|
|
178
220
|
if (fields.length === 0)
|
|
@@ -182,11 +224,9 @@ export function toolFromTf(block, owner, ctx) {
|
|
|
182
224
|
else if (rawFields !== undefined) {
|
|
183
225
|
ctx.diagnostics.push(`${where}: fields is not a list; dropped`);
|
|
184
226
|
}
|
|
185
|
-
// searchTable
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
// there's no elementum_*_field resource (and no catalog bag key) to
|
|
189
|
-
// resolve them to.
|
|
227
|
+
// The provider export normalizes searchTable field_id to a raw platform id.
|
|
228
|
+
// Preserve it here; the recursive pull printer can upgrade known ids using
|
|
229
|
+
// the target element's dependency field registry.
|
|
190
230
|
let returnFields;
|
|
191
231
|
const rawReturnFields = attrs["return_fields"];
|
|
192
232
|
if (Array.isArray(rawReturnFields)) {
|
|
@@ -343,11 +383,13 @@ function executeWorkflowFromTf(block, name, where, owner, ctx) {
|
|
|
343
383
|
});
|
|
344
384
|
}
|
|
345
385
|
const startMessage = optionalString(attrs, "start_message", where, ctx);
|
|
386
|
+
const runAs = runAsFromTf(attrs, owner, where, ctx);
|
|
346
387
|
return {
|
|
347
388
|
typeKey: "executeWorkflow",
|
|
348
389
|
name,
|
|
349
390
|
description: optionalString(attrs, "description", where, ctx) ?? "",
|
|
350
391
|
...(startMessage !== undefined && { startMessage }),
|
|
392
|
+
...(runAs !== undefined && { runAs }),
|
|
351
393
|
automationKey: scopedLabelToBagKey(owner.ownerTfLabel, autoLabel),
|
|
352
394
|
...(inputs.length > 0 && { inputs }),
|
|
353
395
|
...(outputs.length > 0 && { outputs }),
|
|
@@ -21,13 +21,21 @@ export interface ToolToTfContext {
|
|
|
21
21
|
/** The owning agent's bare tfLabel (before apps_ prefix). */
|
|
22
22
|
readonly agentBareTfLabel: string;
|
|
23
23
|
/** Records a foreign-app data lookup for data.tf; returns its tfLabel. */
|
|
24
|
-
foreignAppRef(tfLabel: string, name: string): void;
|
|
24
|
+
foreignAppRef(tfLabel: string, name: string, namespace?: string): void;
|
|
25
25
|
/** Records a foreign-ELEMENT data lookup for data.tf (board issue #42). */
|
|
26
|
-
foreignElementRef(tfLabel: string, name: string): void;
|
|
26
|
+
foreignElementRef(tfLabel: string, name: string, namespace?: string): void;
|
|
27
|
+
foreignAutomationRef?(tfLabel: string, name: string, owner: {
|
|
28
|
+
readonly kind: "app" | "element";
|
|
29
|
+
readonly refName: string;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly namespace?: string;
|
|
32
|
+
}): void;
|
|
27
33
|
/** Records a `data.elementum_field` lookup for a field owned by a foreign app/element. */
|
|
28
34
|
foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string): void;
|
|
29
35
|
/** App/element roots authored in this same workspace. */
|
|
30
36
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
37
|
+
/** Records an app-scoped service-account lookup by name. */
|
|
38
|
+
serviceAccountRef?(tfLabel: string, name: string): TfValue | void;
|
|
31
39
|
/** Degradations land here — reported by the caller, never silent. */
|
|
32
40
|
readonly diagnostics: string[];
|
|
33
41
|
}
|