@elementumai/edk 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +11 -7
  2. package/dist-sdk/src/catalog/token.js +2 -1
  3. package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
  4. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  5. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  6. package/dist-sdk/src/engine/coverage-gaps.js +3 -0
  7. package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
  8. package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
  9. package/dist-sdk/src/engine/ei/run.d.ts +22 -0
  10. package/dist-sdk/src/engine/ei/run.js +99 -18
  11. package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
  12. package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
  13. package/dist-sdk/src/engine/ei/state.d.ts +1 -1
  14. package/dist-sdk/src/engine/ei/state.js +17 -4
  15. package/dist-sdk/src/engine/progress.d.ts +3 -1
  16. package/dist-sdk/src/engine/progress.js +7 -3
  17. package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
  18. package/dist-sdk/src/engine/pull/authored-address.js +180 -29
  19. package/dist-sdk/src/engine/pull/context.d.ts +52 -7
  20. package/dist-sdk/src/engine/pull/context.js +7 -4
  21. package/dist-sdk/src/engine/tf/index.d.ts +3 -2
  22. package/dist-sdk/src/engine/tf/index.js +3 -2
  23. package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
  24. package/dist-sdk/src/engine/tf/labels.js +50 -0
  25. package/dist-sdk/src/engine/tf/model.d.ts +2 -0
  26. package/dist-sdk/src/engine/tf/model.js +26 -0
  27. package/dist-sdk/src/engine/tf/scan.d.ts +22 -0
  28. package/dist-sdk/src/engine/tf/scan.js +123 -0
  29. package/dist-sdk/src/engine/validation.d.ts +2 -0
  30. package/dist-sdk/src/engine/workspace/loader.d.ts +8 -0
  31. package/dist-sdk/src/engine/workspace/loader.js +20 -0
  32. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +17 -0
  33. package/dist-sdk/src/entities/access-policy/from-tf.js +52 -24
  34. package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
  35. package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
  36. package/dist-sdk/src/entities/access-policy/module.js +5 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
  39. package/dist-sdk/src/entities/agent/build.js +7 -5
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
  41. package/dist-sdk/src/entities/agent/from-tf.js +13 -3
  42. package/dist-sdk/src/entities/agent/to-tf.d.ts +13 -11
  43. package/dist-sdk/src/entities/agent/to-tf.js +28 -17
  44. package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
  45. package/dist-sdk/src/entities/agent/tools.js +6 -2
  46. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  47. package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -2
  48. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
  49. package/dist-sdk/src/entities/agent-tool/to-tf.js +65 -3
  50. package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
  51. package/dist-sdk/src/entities/agent-tool/types.js +13 -9
  52. package/dist-sdk/src/entities/app/build.d.ts +11 -0
  53. package/dist-sdk/src/entities/app/build.js +1 -0
  54. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +11 -7
  55. package/dist-sdk/src/entities/app/from-tf.js +19 -9
  56. package/dist-sdk/src/entities/app/to-tf.js +6 -4
  57. package/dist-sdk/src/entities/automation/build.d.ts +2 -7
  58. package/dist-sdk/src/entities/automation/build.js +55 -16
  59. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
  60. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -11
  61. package/dist-sdk/src/entities/automation/from-tf.d.ts +23 -1
  62. package/dist-sdk/src/entities/automation/from-tf.js +456 -34
  63. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  64. package/dist-sdk/src/entities/automation/module.d.ts +22 -2
  65. package/dist-sdk/src/entities/automation/module.js +273 -58
  66. package/dist-sdk/src/entities/automation/output-field-types.d.ts +8 -0
  67. package/dist-sdk/src/entities/automation/output-field-types.js +20 -0
  68. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +24 -2
  69. package/dist-sdk/src/entities/automation/output-key-wire-name.js +72 -3
  70. package/dist-sdk/src/entities/automation/run-target.d.ts +59 -0
  71. package/dist-sdk/src/entities/automation/run-target.js +99 -0
  72. package/dist-sdk/src/entities/automation/script-code.d.ts +9 -0
  73. package/dist-sdk/src/entities/automation/script-code.js +24 -3
  74. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +16 -0
  75. package/dist-sdk/src/entities/automation/task-output-labels.js +49 -0
  76. package/dist-sdk/src/entities/automation/tasks.d.ts +20 -8
  77. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -3
  78. package/dist-sdk/src/entities/automation/to-tf.js +171 -58
  79. package/dist-sdk/src/entities/automation/triggers.d.ts +22 -3
  80. package/dist-sdk/src/entities/automation/triggers.js +40 -0
  81. package/dist-sdk/src/entities/automation/types.d.ts +21 -0
  82. package/dist-sdk/src/entities/automation/types.js +26 -0
  83. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
  84. package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
  85. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  86. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +7 -2
  87. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  88. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +65 -19
  89. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
  90. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
  91. package/dist-sdk/src/entities/element/build.d.ts +10 -0
  92. package/dist-sdk/src/entities/element/build.js +1 -0
  93. package/dist-sdk/src/entities/element/from-tf.js +16 -9
  94. package/dist-sdk/src/entities/element/to-tf.js +6 -4
  95. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  96. package/dist-sdk/src/entities/field/from-tf.js +79 -1
  97. package/dist-sdk/src/entities/field/module.js +7 -0
  98. package/dist-sdk/src/entities/field/to-tf.d.ts +30 -1
  99. package/dist-sdk/src/entities/field/to-tf.js +51 -0
  100. package/dist-sdk/src/entities/file-reader/module.js +3 -3
  101. package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
  102. package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
  103. package/dist-sdk/src/entities/file-reader/types.js +7 -0
  104. package/dist-sdk/src/entities/org/group.d.ts +1 -0
  105. package/dist-sdk/src/entities/org/group.js +2 -1
  106. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
  107. package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
  108. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
  109. package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
  110. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
  111. package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
  112. package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
  113. package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
  114. package/dist-sdk/src/entities/role/from-tf.js +24 -7
  115. package/dist-sdk/src/entities/role/to-tf.js +25 -7
  116. package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
  117. package/dist-sdk/src/entities/service-account/module.js +15 -0
  118. package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
  119. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  120. package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
  121. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
  122. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
  123. package/dist-sdk/src/entities/skill/from-tf.js +10 -3
  124. package/dist-sdk/src/entities/skill/module.js +44 -2
  125. package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
  126. package/dist-sdk/src/entities/skill/to-tf.js +23 -14
  127. package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
  128. package/dist-sdk/src/entities/skill/tools.js +6 -2
  129. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  130. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  131. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
  132. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +10 -2
  133. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +18 -4
  134. package/dist-sdk/src/entities/view/custom-view-validate.js +6 -5
  135. package/dist-sdk/src/entities/view/from-tf.d.ts +68 -0
  136. package/dist-sdk/src/entities/view/from-tf.js +503 -25
  137. package/dist-sdk/src/entities/view/module.js +15 -0
  138. package/dist-sdk/src/entities/view/portable.d.ts +11 -0
  139. package/dist-sdk/src/entities/view/portable.js +47 -0
  140. package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
  141. package/dist-sdk/src/entities/view/to-tf.js +25 -7
  142. package/dist-sdk/src/entities/view/types.js +1 -1
  143. package/dist-sdk/src/entities/widget/build.d.ts +4 -3
  144. package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
  145. package/dist-sdk/src/entities/widget/from-tf.js +100 -3
  146. package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
  147. package/dist-sdk/src/entities/widget/to-tf.js +77 -14
  148. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +27 -8
  149. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  150. package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
  151. package/dist-sdk/src/graph/field-resource-types.js +11 -0
  152. package/dist-sdk/src/graph/index.d.ts +28 -3
  153. package/dist-sdk/src/graph/index.js +12 -2
  154. package/dist-sdk/src/graph/types.d.ts +164 -5
  155. package/package.json +1 -1
@@ -18,5 +18,5 @@ export * as filter from "../shared/filters/index.js";
18
18
  export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type ForEachScope, type LoopScope, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
19
19
  export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
20
20
  export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
21
- export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type RequiredSecret, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type BulkUpdateFieldsOptions, type BulkUpdateFieldsOutput, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type StaticGroupRecipient, type StaticUserRecipient, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationDynamicReferenceOptions, type RunAutomationOptions, type RunAutomationStaticOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserGroupSearchOptions, type UserGroupSearchOutput, type UserGroupShape, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
21
+ export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, requiredSecret, assignGroup, assignUser, assignmentEngine, bulkExcel, bulkUpdateFields, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApiRequestOutputs, type ApiResponseType, type ApprovalChainOptions, type RequiredSecret, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type BulkUpdateFieldsOptions, type BulkUpdateFieldsOutput, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type StaticGroupRecipient, type StaticUserRecipient, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationDynamicReferenceOptions, type RunAutomationOptions, type RunAutomationStaticOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserGroupSearchOptions, type UserGroupSearchOutput, type UserGroupShape, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
22
22
  export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
@@ -1,8 +1,28 @@
1
1
  /** The automation entity's registry entry (see src/graph/). */
2
2
  import { type TfBlock } from "../../engine/tf/index.js";
3
3
  import { type EntityKindModule } from "../../graph/types.js";
4
- /** The named WARN for an automation pull could not extract (edk#1054, edk#1480). */
5
- export declare function droppedAutomationGap(autoBlock: TfBlock, autoLabel: string, reason: string): string;
4
+ /**
5
+ * The named WARN for an automation pull could not extract (edk#1054,
6
+ * edk#1480): what was skipped, why, what that means and what to do next
7
+ * (#1877). A released automation's authored file is archived
8
+ * (`quarantineOwnFiles`, #1858): the automation stale-file sweep is off while
9
+ * any automation is skipped, so a released file left in place would still
10
+ * build and the next plan would create a duplicate. The file is kept instead
11
+ * when a resource that stays in source still references the automation
12
+ * (`keptFor`): agent and skill run-automation tools, dynamic-layout buttons
13
+ * and their inputs, and other kept automations can only name an automation
14
+ * in source, so archiving would break build. A widget can (#1901). An automation pull skips without releasing keeps its state and
15
+ * its existing source file, so the next plan builds that older file against
16
+ * the live automation.
17
+ */
18
+ export declare function droppedAutomationGap(autoBlock: TfBlock, autoLabel: string, gap: {
19
+ readonly why: string;
20
+ readonly released: boolean;
21
+ readonly nextStep: string;
22
+ readonly keptFor?: readonly string[];
23
+ /** The file waits for state (#2054): see `ReleasedAutomation.settleByState`. */
24
+ readonly settleByState?: boolean;
25
+ }): string;
6
26
  export declare const automationModule: EntityKindModule;
7
27
  /** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
8
28
  export declare function onDemandFilterRefName(name: string): string;
@@ -8,12 +8,13 @@ function elementOwnerHandle(payload) {
8
8
  }
9
9
  import { renderAutomationCatalogEntry } from "./catalog-render.js";
10
10
  import { hasUnresolvedForEachItem, preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
11
- import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnresolvedForeignServiceAccountError, UnsupportedMultiTriggerError } from "./from-tf.js";
11
+ import { automationFromTf, automationOwnedAddresses, ForEachItemOutsideLoopError, UnresolvedForeignServiceAccountError, UnresolvedTaskFilterRefError, UnsupportedMultiTriggerError } from "./from-tf.js";
12
12
  import { scriptFileRefs } from "./script-code.js";
13
13
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
14
- import { TASK_OUTPUT_REFERENCE_NAMES } from "./task-output-labels.js";
14
+ import { taskOutputReferences, USER_SEARCH_OUTPUT_REFERENCES } from "./task-output-labels.js";
15
15
  import { automationToTf } from "./to-tf.js";
16
16
  import { approvalChainLostStage } from "../approval-chain/from-tf.js";
17
+ import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
17
18
  import { stageHandleIndexFromTfStages } from "../app/stage-keys.js";
18
19
  import { ALL_AUTOMATION_SUB_TYPES, AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
19
20
  const AUTOMATION_MEMBER_TYPES = new Set([
@@ -120,17 +121,58 @@ function registerForeignObjectIdDeps(doc, automationLabel, ctx) {
120
121
  }
121
122
  }
122
123
  }
123
- /** The named WARN for an automation pull could not extract (edk#1054, edk#1480). */
124
- export function droppedAutomationGap(autoBlock, autoLabel, reason) {
124
+ /**
125
+ * The named WARN for an automation pull could not extract (edk#1054,
126
+ * edk#1480): what was skipped, why, what that means and what to do next
127
+ * (#1877). A released automation's authored file is archived
128
+ * (`quarantineOwnFiles`, #1858): the automation stale-file sweep is off while
129
+ * any automation is skipped, so a released file left in place would still
130
+ * build and the next plan would create a duplicate. The file is kept instead
131
+ * when a resource that stays in source still references the automation
132
+ * (`keptFor`): agent and skill run-automation tools, dynamic-layout buttons
133
+ * and their inputs, and other kept automations can only name an automation
134
+ * in source, so archiving would break build. A widget can (#1901). An automation pull skips without releasing keeps its state and
135
+ * its existing source file, so the next plan builds that older file against
136
+ * the live automation.
137
+ */
138
+ export function droppedAutomationGap(autoBlock, autoLabel, gap) {
125
139
  const name = autoBlock.attrs["name"];
126
140
  const display = typeof name === "string" && name !== "" ? name : autoLabel;
127
141
  return typedCoverageGap({
128
142
  kind: "skipped",
129
143
  entity: `automation ${JSON.stringify(display)} (${autoLabel})`,
130
- detail: `not pulled, skipped: ${reason}`,
131
- consequence: "it is not written to source or adopted; it keeps running on the platform unmanaged",
144
+ detail: `skipped, not written to source: ${gap.why}`,
145
+ consequence: gap.released && gap.keptFor !== undefined
146
+ ? `it is not adopted, and adoption releases it from state if this workspace managed it, so it keeps running on the platform unmanaged. Pull keeps its authored file, if there is one, because ${gap.keptFor.join(", ")} still name${gap.keptFor.length === 1 ? "s" : ""} it in source, and agent and skill tools, dynamic-layout buttons and other automations cannot name a platform id instead, so moving the file would break build. While that file exists the next plan creates a second copy of the automation: review the plan before applying, and remove those references and the file to stop it. ${gap.nextStep}`
147
+ : gap.released && gap.settleByState === true
148
+ ? `it is not adopted; adoption releases it from state if this workspace managed it, and once state no longer manages it pull moves its authored file, if there is one, to .edk-state/pull-backups so the next plan neither destroys it nor creates a duplicate. Until a pull releases it (under --no-adopt, or when adoption stops before releasing it), its file and state stay as they were and this workspace still manages it. Once a pull releases it, it keeps running on the platform unmanaged and its file is archived; do not restore that file. ${gap.nextStep}`
149
+ : gap.released
150
+ ? `it is not adopted; adoption releases it from state if this workspace managed it, and pull moves its authored file, if there is one, to .edk-state/pull-backups so the next plan does not create a duplicate. It keeps running on the platform unmanaged; do not restore that file. ${gap.nextStep}`
151
+ : `it is not adopted. If this workspace already manages it, its state and its existing source file are kept as they were, so the next plan compares that older source with the live automation: it can undo edits made in the platform, or delete the automation if its source file is gone. Review the plan before applying. ${gap.nextStep}`,
132
152
  });
133
153
  }
154
+ const FIX_IN_PLATFORM = "To manage it with the EDK, change what the reason names in the platform, then pull again.";
155
+ const FIX_OR_REPORT = "If you can change what the reason names in the platform, do so and pull again; otherwise report it as an EDK bug.";
156
+ /**
157
+ * Addresses of the stream's resources that stay in source (`inSource`) and
158
+ * reference any of `owned` by source name. A widget does not count: with its
159
+ * automation out of source, build points it at the live automation through a
160
+ * display-name lookup (#1901), so archiving is safe.
161
+ */
162
+ function externalReferrers(stream, owned, inSource) {
163
+ const ownedSet = new Set(owned);
164
+ const referrers = [];
165
+ for (const block of stream.allBlocks) {
166
+ if (block.kind !== "resource" || block.type === undefined || block.label === undefined)
167
+ continue;
168
+ const address = `${block.type}.${block.label}`;
169
+ if (ownedSet.has(address) || block.type === "elementum_widget" || !inSource(address))
170
+ continue;
171
+ if (referenceIn(block.attrs, ownedSet) !== undefined)
172
+ referrers.push(address);
173
+ }
174
+ return referrers;
175
+ }
134
176
  /** Addresses of the stream's approval processes that pull leaves unmanaged because their stage lost its only handle (#1136). */
135
177
  function lostStageApprovalChains(stream, ctx) {
136
178
  const lost = new Set();
@@ -147,37 +189,38 @@ function lostStageApprovalChains(stream, ctx) {
147
189
  }
148
190
  return lost;
149
191
  }
150
- /** The first of `chains` that any block at `owned` references, if any. */
151
- function referencedLostChain(stream, owned, chains) {
152
- const ownedSet = new Set(owned);
153
- const visit = (value) => {
154
- if (Array.isArray(value)) {
155
- for (const item of value) {
156
- const hit = visit(item);
157
- if (hit !== undefined)
158
- return hit;
159
- }
160
- return undefined;
161
- }
162
- if (value === null || typeof value !== "object")
163
- return undefined;
164
- const record = value;
165
- if (record["$expr"] === "resource-attr" && typeof record["type"] === "string" && typeof record["label"] === "string") {
166
- const address = `${record["type"]}.${record["label"]}`;
167
- if (chains.has(address))
168
- return address;
169
- }
170
- for (const item of Object.values(record)) {
171
- const hit = visit(item);
192
+ /** The first of `targets` that `value` references, if any. */
193
+ function referenceIn(value, targets) {
194
+ if (Array.isArray(value)) {
195
+ for (const item of value) {
196
+ const hit = referenceIn(item, targets);
172
197
  if (hit !== undefined)
173
198
  return hit;
174
199
  }
175
200
  return undefined;
176
- };
201
+ }
202
+ if (value === null || typeof value !== "object")
203
+ return undefined;
204
+ const record = value;
205
+ if (record["$expr"] === "resource-attr" && typeof record["type"] === "string" && typeof record["label"] === "string") {
206
+ const address = `${record["type"]}.${record["label"]}`;
207
+ if (targets.has(address))
208
+ return address;
209
+ }
210
+ for (const item of Object.values(record)) {
211
+ const hit = referenceIn(item, targets);
212
+ if (hit !== undefined)
213
+ return hit;
214
+ }
215
+ return undefined;
216
+ }
217
+ /** The first of `targets` that any block at `owned` references, if any. */
218
+ function referencedAddress(stream, owned, targets) {
219
+ const ownedSet = new Set(owned);
177
220
  for (const block of stream.allBlocks) {
178
221
  if (block.type === undefined || block.label === undefined || !ownedSet.has(`${block.type}.${block.label}`))
179
222
  continue;
180
- const hit = visit(block.attrs);
223
+ const hit = referenceIn(block.attrs, targets);
181
224
  if (hit !== undefined)
182
225
  return hit;
183
226
  }
@@ -187,9 +230,25 @@ function extractAutomations(ownBlocks, stream, ctx) {
187
230
  const items = [];
188
231
  const skipped = [];
189
232
  const releaseIfManaged = [];
190
- const quarantineOwnFiles = [];
191
233
  const diagnostics = [];
234
+ const validations = [];
192
235
  const adoptionAddressAliases = [];
236
+ const extractedAutomations = [];
237
+ const released = [];
238
+ // Which file each skipped automation's resources come from (#1877).
239
+ const skippedOwnFiles = [];
240
+ const skip = (owned, refName) => {
241
+ skipped.push(...owned);
242
+ skippedOwnFiles.push({ refName, addresses: owned });
243
+ };
244
+ const settledByState = new Set();
245
+ const release = (entry) => {
246
+ releaseIfManaged.push(...entry.owned);
247
+ released.push(entry);
248
+ if (entry.settleByState === true)
249
+ for (const address of entry.owned)
250
+ settledByState.add(address);
251
+ };
193
252
  const lostChains = lostStageApprovalChains(stream, ctx);
194
253
  for (const autoBlock of ownBlocks) {
195
254
  const autoLabel = autoBlock.label ?? "";
@@ -203,35 +262,34 @@ function extractAutomations(ownBlocks, stream, ctx) {
203
262
  // automation with a warning and release an earlier adoption of it.
204
263
  if (lostChains.size > 0) {
205
264
  const owned = automationOwnedAddresses(doc, autoLabel);
206
- const chain = referencedLostChain(stream, owned, lostChains);
265
+ const chain = referencedAddress(stream, owned, lostChains);
207
266
  if (chain !== undefined) {
208
- skipped.push(...owned);
209
- releaseIfManaged.push(...owned);
210
- diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, `it references ${chain}, which is left unmanaged because its stage has no handle of its own (#1136)`));
267
+ skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
268
+ release({
269
+ autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
270
+ why: `it uses ${chain}, which pull leaves unmanaged because its stage has no handle of its own (#1136)`,
271
+ nextStep: "To manage it with the EDK, give that stage its own handle in the platform, then pull again.",
272
+ });
211
273
  continue;
212
274
  }
213
275
  }
214
276
  try {
215
- const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName, ctx.serviceAccountsById);
277
+ const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName, ctx.serviceAccountsById, ctx.foreignFileReaderRefsById);
216
278
  // edk#1646 / #1858: adopt when a rebuilt ctx ref matches provider Read.
217
279
  // Otherwise the automation stays platform-managed. Releasing its state
218
280
  // also archives the authored file, so the next plan does not create a
219
281
  // second copy of the live automation.
220
282
  if (extracted.stringifiedValueReferences === true) {
221
283
  const owned = automationOwnedAddresses(doc, autoLabel);
222
- skipped.push(...owned);
223
- releaseIfManaged.push(...owned);
224
- quarantineOwnFiles.push({ kind: "automation", refName: extracted.refName });
225
- diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, "the export embeds a stringified ValueReference that source cannot rebuild to match provider Read (edk#1646). It stays platform-managed, and its authored file is archived so the next plan does not create a duplicate."));
284
+ skip(owned, extracted.refName);
285
+ release({
286
+ autoBlock, autoLabel, owned, refName: extracted.refName,
287
+ why: "its export embeds a value reference as text that source cannot rebuild exactly (edk#1646)",
288
+ nextStep: "Keep editing it in the platform.",
289
+ });
226
290
  continue;
227
291
  }
228
- // Keep automationFromTf's label-derived refName — agent/skill tools store
229
- // the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
230
- // only) made missing-automation diagnostics false-positive on every real
231
- // extract (issue #395 / PR #417 review).
232
- items.push({ ...extracted.ast, refName: extracted.refName });
233
- adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
234
- diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
292
+ extractedAutomations.push({ autoBlock, autoLabel, owned: automationOwnedAddresses(doc, autoLabel), extracted });
235
293
  }
236
294
  catch (err) {
237
295
  // Report the automation's FULL graph (trigger/tasks/branches/publish),
@@ -240,27 +298,150 @@ function extractAutomations(ownBlocks, stream, ctx) {
240
298
  // never wrote this automation to source) can't reproduce them, so
241
299
  // `plan` shows them as destroy-on-apply. See automationOwnedAddresses.
242
300
  const owned = automationOwnedAddresses(doc, autoLabel);
243
- skipped.push(...owned);
301
+ // A filter on a task id that is not this automation's (#2054) fails the
302
+ // pull, the same way source generation used to, now naming what the id
303
+ // points to. Skipping it with a warning would hide that (#1974). It is
304
+ // also released: an earlier pull may have written its file (which
305
+ // still builds into the old `unresolved task filter ref` error) and
306
+ // adopted it, so archive the file and drop the state binding together,
307
+ // or the next plan would destroy the live automation.
308
+ if (err instanceof UnresolvedTaskFilterRefError) {
309
+ const name = autoBlock.attrs["name"];
310
+ validations.push({
311
+ severity: "fatal",
312
+ address: `${autoBlock.type}.${autoLabel}`,
313
+ name: typeof name === "string" && name !== "" ? name : autoLabel,
314
+ ownerKind: "automation",
315
+ message: err.message,
316
+ code: "unresolved-task-filter-ref",
317
+ });
318
+ skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
319
+ release({
320
+ autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
321
+ why: `pull could not turn its export into source: ${err.message}`,
322
+ nextStep: FIX_IN_PLATFORM,
323
+ reportedAsFatal: true,
324
+ settleByState: true,
325
+ });
326
+ continue;
327
+ }
328
+ skip(owned, scopedLabelToBagKey(ctx.appTfLabel, autoLabel));
244
329
  // No authored form can manage these, so release an earlier adoption
245
330
  // rather than let the next apply destroy the live automation:
246
331
  // sibling-loop item refs (#1320) and multi-trigger (#1785 / #39).
247
332
  // Soft diagnostic, not a validation fatal — the rest of the app must
248
333
  // still adopt and plan clean while these stay platform-managed only.
249
- if (err instanceof ForEachItemOutsideLoopError ||
334
+ const released = err instanceof ForEachItemOutsideLoopError ||
250
335
  err instanceof UnsupportedMultiTriggerError ||
251
- err instanceof UnresolvedForeignServiceAccountError) {
252
- releaseIfManaged.push(...owned);
336
+ err instanceof UnresolvedForeignServiceAccountError;
337
+ // edk#1480: name the dropped automation and say what that means, as a
338
+ // typed gap so it counts (and fails --strict-coverage) by itself.
339
+ const why = `pull could not turn its export into source: ${err instanceof Error ? err.message : String(err)}`;
340
+ if (released) {
341
+ release({
342
+ autoBlock, autoLabel, owned, refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel), why,
343
+ nextStep: err instanceof UnresolvedForeignServiceAccountError
344
+ ? "Pull the app that owns the service account (the reason names it), then pull this app again."
345
+ : FIX_IN_PLATFORM,
346
+ });
347
+ }
348
+ else {
349
+ diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, { why, released: false, nextStep: FIX_OR_REPORT }));
350
+ }
351
+ }
352
+ }
353
+ // An automation that runs a skipped automation (or reads its trigger's
354
+ // parameter ids) would print a ref to an automation source never gets, and
355
+ // its export would keep a reference to a resource adoption strips. Skip it
356
+ // too, transitively, and release it only when its target was released.
357
+ const kept = new Set(extractedAutomations);
358
+ for (let cascaded = true; cascaded;) {
359
+ cascaded = false;
360
+ const skippedAddresses = new Set(skipped);
361
+ const releasedAddresses = new Set(releaseIfManaged);
362
+ for (const entry of kept) {
363
+ const target = referencedAddress(stream, entry.owned, skippedAddresses);
364
+ if (target === undefined)
365
+ continue;
366
+ kept.delete(entry);
367
+ cascaded = true;
368
+ skip(entry.owned, entry.extracted.refName);
369
+ const gap = {
370
+ why: `it uses ${target}, which pull skipped, so its reference would point at nothing`,
371
+ nextStep: `Fix ${target} first (see its own warning), then pull again.`,
372
+ };
373
+ if (releasedAddresses.has(target)) {
374
+ release({
375
+ autoBlock: entry.autoBlock, autoLabel: entry.autoLabel, owned: entry.owned, refName: entry.extracted.refName, ...gap,
376
+ // Released only because its target was: settle it the same way (#2054).
377
+ ...(settledByState.has(target) && { settleByState: true }),
378
+ });
379
+ }
380
+ else {
381
+ diagnostics.push(droppedAutomationGap(entry.autoBlock, entry.autoLabel, { ...gap, released: false }));
253
382
  }
254
- if (err instanceof UnresolvedForeignServiceAccountError) {
383
+ }
384
+ }
385
+ // Archive a released automation's file only when nothing that stays in
386
+ // source still references it (#1877): agent and skill run-automation
387
+ // tools, dynamic-layout buttons and other automations can only name an
388
+ // automation in source, so archiving under them would break build. Keep
389
+ // the file then, and say so. What stays in source is known only after
390
+ // every own-file child of the stream is extracted, so stream root decides
391
+ // it and calls back. A kept file is source too: what it references must
392
+ // stay (an automation a kept automation runs is kept as well), so iterate
393
+ // to a fixed point.
394
+ const settleAfterExtract = released.length === 0 ? undefined : (inSource) => {
395
+ const releasedOwned = new Set(released.flatMap((entry) => entry.owned));
396
+ const archived = new Set(released);
397
+ const archivedOwned = () => new Set([...archived].flatMap((entry) => entry.owned));
398
+ // A released automation's file is source exactly while it is kept.
399
+ const sourceGiven = (gone) => (address) => releasedOwned.has(address) ? !gone.has(address) : inSource(address);
400
+ for (let changed = true; changed;) {
401
+ changed = false;
402
+ const isSource = sourceGiven(archivedOwned());
403
+ for (const entry of [...archived]) {
404
+ if (externalReferrers(stream, entry.owned, isSource).length === 0)
405
+ continue;
406
+ archived.delete(entry);
407
+ changed = true;
408
+ }
409
+ }
410
+ const isSource = sourceGiven(archivedOwned());
411
+ const quarantineOwnFiles = [];
412
+ const settled = [];
413
+ for (const entry of released) {
414
+ const keptFor = archived.has(entry) ? [] : externalReferrers(stream, entry.owned, isSource);
415
+ if (keptFor.length === 0) {
255
416
  quarantineOwnFiles.push({
256
417
  kind: "automation",
257
- refName: scopedLabelToBagKey(ctx.appTfLabel, autoLabel),
418
+ refName: entry.refName,
419
+ // Adoption still runs on a fatal pull and is what releases it, so
420
+ // its file goes only once state no longer binds any of these;
421
+ // otherwise the next plan would destroy the live automation (#2054).
422
+ ...(entry.settleByState === true && { afterRelease: entry.owned }),
258
423
  });
259
424
  }
260
- // edk#1480: name the dropped automation and say what that means, as a
261
- // typed gap so it counts (and fails --strict-coverage) by itself.
262
- diagnostics.push(droppedAutomationGap(autoBlock, autoLabel, err instanceof Error ? err.message : String(err)));
425
+ if (entry.reportedAsFatal === true && keptFor.length === 0)
426
+ continue;
427
+ settled.push(droppedAutomationGap(entry.autoBlock, entry.autoLabel, {
428
+ why: entry.why,
429
+ released: true,
430
+ nextStep: entry.nextStep,
431
+ ...(keptFor.length > 0 && { keptFor }),
432
+ ...(entry.settleByState === true && { settleByState: true }),
433
+ }));
263
434
  }
435
+ return { quarantineOwnFiles, diagnostics: settled };
436
+ };
437
+ for (const { autoLabel, extracted } of kept) {
438
+ // Keep automationFromTf's label-derived refName — agent/skill tools store
439
+ // the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
440
+ // only) made missing-automation diagnostics false-positive on every real
441
+ // extract (issue #395 / PR #417 review).
442
+ items.push({ ...extracted.ast, refName: extracted.refName });
443
+ adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
444
+ diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
264
445
  }
265
446
  // A trigger, task, or publish with no automation resource is not in any
266
447
  // skeleton's graph. extractAutomations never sees it, and its resource type
@@ -294,7 +475,12 @@ function extractAutomations(ownBlocks, stream, ctx) {
294
475
  consequence: "it is not written to source or adopted; it keeps running on the platform unmanaged",
295
476
  }));
296
477
  }
297
- return { items, skipped, releaseIfManaged, quarantineOwnFiles, diagnostics, adoptionAddressAliases };
478
+ return {
479
+ items, skipped, releaseIfManaged, diagnostics, adoptionAddressAliases,
480
+ ...(validations.length > 0 && { validations }),
481
+ ...(skippedOwnFiles.length > 0 && { skippedOwnFiles }),
482
+ ...(settleAfterExtract !== undefined && { settleAfterExtract }),
483
+ };
298
484
  }
299
485
  export const automationModule = {
300
486
  kind: "automation",
@@ -385,6 +571,7 @@ export const automationModule = {
385
571
  fieldMetadata: ctx.fieldMetadata ?? new Map(),
386
572
  ...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
387
573
  ...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
574
+ ...(ctx.authoredAspectKeys !== undefined ? { authoredAspectKeys: ctx.authoredAspectKeys } : {}),
388
575
  ...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
389
576
  orgRefs: ctx.orgRefs,
390
577
  workspaceAspects: ctx.workspaceAspects,
@@ -415,7 +602,29 @@ export const automationModule = {
415
602
  ownerType: "elementum_on_demand_trigger",
416
603
  ownerReference: "automation",
417
604
  }],
418
- taskOutputReferenceNames: TASK_OUTPUT_REFERENCE_NAMES,
605
+ taskOutputReferences: {
606
+ ...taskOutputReferences(),
607
+ elementum_user_search_task: USER_SEARCH_OUTPUT_REFERENCES,
608
+ },
609
+ // An on-demand parameter used as a script input: the build writes the
610
+ // envelope with the platform's normalized name (#1525), the export the
611
+ // trigger's refs read that holds it. A create-record value the trigger's
612
+ // refs cannot name: the build writes jsonencode, the export its string.
613
+ // An on-demand trigger's refs hold each declared parameter's reference
614
+ // under the parameter's name, computed from `parameters`, plus the
615
+ // trigger's system references (Environment, Manager, Triggered By's Id,
616
+ // ...). The build writes an envelope only for a declared parameter, so
617
+ // only those keys are read from state.
618
+ stateEvaluatedMaps: [{
619
+ resourceType: "elementum_on_demand_trigger",
620
+ attribute: "refs",
621
+ computedFrom: ["parameters"],
622
+ keyedBy: { listAttribute: "parameters", nameAttribute: "name" },
623
+ }],
624
+ renderedJsonencodeAttributes: [
625
+ { resourceType: "elementum_execute_script_task", attribute: "inputs" },
626
+ { resourceType: "elementum_create_record_task", attribute: "fields" },
627
+ ],
419
628
  recordFieldOutputKeys: [{ nameAttribute: "name", ownerAttribute: "object_id" }],
420
629
  computedReferenceMaps: [{
421
630
  resourceType: "elementum_on_demand_trigger",
@@ -438,6 +647,12 @@ export const automationModule = {
438
647
  "elementum_update_field_task",
439
648
  "elementum_bulk_update_fields_task",
440
649
  ].map((resourceType) => ({ resourceType, attribute: "fields", fieldAttribute: "field_id", valueAttribute: "value" })),
650
+ // Another app's file reader (edk#2007).
651
+ stateBoundReferences: [{
652
+ resourceType: "elementum_file_reader_task",
653
+ attribute: "file_reader_id",
654
+ referenceTypes: IMPLEMENTED_FILE_READER_RESOURCE_TYPES,
655
+ }],
441
656
  },
442
657
  };
443
658
  /** The provider's `normalizeOnDemandFilterRefName`, which computes `filter_refs` at plan time. */
@@ -10,6 +10,14 @@
10
10
  * dependency-free like `output-key-wire-name.ts` so importing it from
11
11
  * either side can never introduce a cycle.
12
12
  */
13
+ /**
14
+ * True when the schema's only top-level property is a TEXT list (a format-less
15
+ * or EMAIL/UUID4 string array). The runtime then also fills
16
+ * `stringArrayResult` with it (#1725 live repro). DATE/DATETIME and object
17
+ * arrays don't count, and an unwrapped `{ properties }` root is no schema, as
18
+ * in build's `declaredScriptResultProperties`.
19
+ */
20
+ export declare function scriptSchemaIsSingleStringArray(schema: unknown): boolean;
13
21
  /** Map executeScript output_schema properties to refs keys (`result.<name>`). */
14
22
  export declare function outputFieldTypesFromScriptSchema(schema: unknown): Map<string, {
15
23
  fieldType: string;
@@ -27,6 +27,26 @@ function stringFormatFieldType(format) {
27
27
  return format;
28
28
  return "TEXT";
29
29
  }
30
+ /**
31
+ * True when the schema's only top-level property is a TEXT list (a format-less
32
+ * or EMAIL/UUID4 string array). The runtime then also fills
33
+ * `stringArrayResult` with it (#1725 live repro). DATE/DATETIME and object
34
+ * arrays don't count, and an unwrapped `{ properties }` root is no schema, as
35
+ * in build's `declaredScriptResultProperties`.
36
+ */
37
+ export function scriptSchemaIsSingleStringArray(schema) {
38
+ if (!isObject(schema) || !isObject(schema.object))
39
+ return false;
40
+ const properties = schema.object.properties;
41
+ if (!Array.isArray(properties) || properties.length !== 1 || !isObject(properties[0]))
42
+ return false;
43
+ const array = properties[0].array;
44
+ if (!isObject(array) || !isObject(array.item) || !("string" in array.item))
45
+ return false;
46
+ const declared = [...(outputFieldTypesFromScriptSchema(schema) ?? [])].filter(([key]) => key.startsWith("result."));
47
+ const type = declared.length === 1 ? declared[0][1] : undefined;
48
+ return type?.kind === "array" && type.fieldType === "TEXT";
49
+ }
30
50
  /** Map executeScript output_schema properties to refs keys (`result.<name>`). */
31
51
  export function outputFieldTypesFromScriptSchema(schema) {
32
52
  if (!isObject(schema))
@@ -45,6 +45,8 @@ export declare const OUTPUT_KEY_CANONICAL: Readonly<Record<string, string>>;
45
45
  * onto `.output` too and rebuild it as `refs["text"]`.
46
46
  */
47
47
  export declare function matchesOutputWireKey(segment: string, wireKey: string): boolean;
48
+ /** refs-map key for one AI completion task output, or undefined when `name` is not one. */
49
+ export declare function aiCompletionRefsIndex(resourceType: string, name: string): string | undefined;
48
50
  /**
49
51
  * apiRequest task outputs in authoring use camelCase segments (`statusCode`,
50
52
  * `file.content`, …) but the provider refs map uses display labels — confirmed
@@ -53,15 +55,35 @@ export declare function matchesOutputWireKey(segment: string, wireKey: string):
53
55
  export declare const API_TASK_REF_WIRE_NAMES: Readonly<Record<string, string>>;
54
56
  /** Inverse of {@link API_TASK_REF_WIRE_NAMES} for export jsonencode envelopes. */
55
57
  export declare const API_TASK_REF_AUTHORING_NAMES: Readonly<Record<string, string>>;
58
+ /**
59
+ * refs-map key for one apiRequest output, given the task's `response_type`.
60
+ * A JSON task exposes only {@link API_TASK_JSON_REF_WIRE_NAMES}: an accessor
61
+ * or an already-rewritten key resolves, anything else is undefined so build
62
+ * fails instead of indexing a key the provider doesn't have. FILE and CUSTOM
63
+ * keep the {@link API_TASK_REF_WIRE_NAMES} mapping, passing unknown names
64
+ * through.
65
+ */
66
+ export declare function apiTaskRefsIndex(responseType: string | undefined, name: string): string | undefined;
67
+ /**
68
+ * Contract name a workflow output of one apiRequest output carries. On a JSON
69
+ * task only `response` / `textResponse` / `statusCode` (or their refs keys)
70
+ * resolve; anything else is undefined so build fails. FILE and CUSTOM pass
71
+ * the name through unchanged.
72
+ */
73
+ export declare function apiTaskCanonicalOutputName(responseType: string | undefined, name: string): string | undefined;
74
+ /** The refs-map keys a JSON apiRequest exposes, for build errors. */
75
+ export declare function apiTaskJsonRefsKeys(): readonly string[];
56
76
  /**
57
77
  * Resolve a single `elementum_api_task` refs[] wire label (e.g. "File",
58
78
  * "Content Type") to its authoring path segments (e.g. ["file"], ["file",
59
- * "contentType"]) via {@link API_TASK_REF_AUTHORING_NAMES} — some authoring
79
+ * "contentType"]) via {@link API_TASK_REF_AUTHORING_NAMES}, plus
80
+ * {@link API_TASK_JSON_REF_WIRE_NAMES} for a JSON task (absent
81
+ * `response_type` is the provider default, JSON) — some authoring
60
82
  * names are dotted (`file.content`) since they nest under the `file` output.
61
83
  * Returns undefined for a wire label with no known authoring counterpart so
62
84
  * callers can fall back to the generic segment mapping.
63
85
  */
64
- export declare function apiTaskRefAuthoringPath(wireSegment: string): string[] | undefined;
86
+ export declare function apiTaskRefAuthoringPath(wireSegment: string, responseType?: string): string[] | undefined;
65
87
  /**
66
88
  * executeScript contract outputs whose authoring name is not the refs-map key.
67
89
  *