@elementumai/edk 0.9.16 → 0.9.17
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.
|
@@ -2703,6 +2703,21 @@ function taskArgs(block, factory, ctx, fieldMappingDiagnostics) {
|
|
|
2703
2703
|
args.outputType = typeof value === "string" ? value.toLowerCase() : decodeValue(value, ctx);
|
|
2704
2704
|
continue;
|
|
2705
2705
|
}
|
|
2706
|
+
if (attr === "attachments" && factory === "aiAgent") {
|
|
2707
|
+
if (!Array.isArray(value))
|
|
2708
|
+
throw new EntityTfError(`${block.type}.${block.label}: attachments must be an array`);
|
|
2709
|
+
args.attachments = value.map((item) => {
|
|
2710
|
+
if (!isObject(item))
|
|
2711
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid AI agent attachment`);
|
|
2712
|
+
const present = ["file", "attachment", "record"].filter((key) => item[key] !== undefined);
|
|
2713
|
+
if (present.length !== 1) {
|
|
2714
|
+
throw new EntityTfError(`${block.type}.${block.label}: AI agent attachment must set exactly one of file, attachment, or record`);
|
|
2715
|
+
}
|
|
2716
|
+
const key = present[0];
|
|
2717
|
+
return { [key]: decodeValue(item[key], ctx) };
|
|
2718
|
+
});
|
|
2719
|
+
continue;
|
|
2720
|
+
}
|
|
2706
2721
|
if (attr === "json_fields" && factory === "aiAgent") {
|
|
2707
2722
|
const outputType = block.attrs.output_type;
|
|
2708
2723
|
if (typeof outputType !== "string" || outputType.toLowerCase() !== "json")
|
|
@@ -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 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, assignGroup, assignUser, assignmentEngine, bulkExcel, 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 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 ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, 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 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 RunAutomationOptions, 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 UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
|
|
21
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, 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 ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, 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 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 RunAutomationOptions, 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 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";
|
|
@@ -203,6 +203,24 @@ export type AiAgentOutput<S extends Record<string, AiAgentOutputField> | undefin
|
|
|
203
203
|
} : {
|
|
204
204
|
readonly result: string;
|
|
205
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* One file handed to an AI agent. Set exactly one:
|
|
208
|
+
* `file` is a file from an earlier task, `attachment` is one attachment field,
|
|
209
|
+
* and `record` is every file on a record.
|
|
210
|
+
*/
|
|
211
|
+
export type AiAgentAttachment = {
|
|
212
|
+
readonly file: ValueOrRef<unknown>;
|
|
213
|
+
readonly attachment?: never;
|
|
214
|
+
readonly record?: never;
|
|
215
|
+
} | {
|
|
216
|
+
readonly attachment: ValueOrRef<unknown>;
|
|
217
|
+
readonly file?: never;
|
|
218
|
+
readonly record?: never;
|
|
219
|
+
} | {
|
|
220
|
+
readonly record: ValueOrRef<unknown>;
|
|
221
|
+
readonly file?: never;
|
|
222
|
+
readonly attachment?: never;
|
|
223
|
+
};
|
|
206
224
|
export interface AiAgentOptions<S extends Record<string, AiAgentOutputField> | undefined = Record<string, AiAgentOutputField> | undefined> {
|
|
207
225
|
readonly agent: AgentRef;
|
|
208
226
|
readonly prompt: ValueOrRef<unknown>;
|
|
@@ -212,6 +230,8 @@ export interface AiAgentOptions<S extends Record<string, AiAgentOutputField> | u
|
|
|
212
230
|
readonly schema?: S;
|
|
213
231
|
/** Optional connector override. */
|
|
214
232
|
readonly connector?: ConnectorRef;
|
|
233
|
+
/** Files the agent reads while it runs. */
|
|
234
|
+
readonly attachments?: readonly AiAgentAttachment[];
|
|
215
235
|
}
|
|
216
236
|
export declare function aiAgent<const S extends Record<string, AiAgentOutputField> | undefined = undefined>(opts: AiAgentOptions<S>): ActionDef<AiAgentOutput<S>>;
|
|
217
237
|
export interface VariableDecl {
|
|
@@ -135,6 +135,14 @@ export function postComment(opts) {
|
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
+
function serializeAiAgentAttachment(attachment) {
|
|
139
|
+
const present = ["file", "attachment", "record"].filter((key) => attachment[key] !== undefined);
|
|
140
|
+
if (present.length !== 1) {
|
|
141
|
+
throw new Error("aiAgent attachment must set exactly one of file, attachment, or record.");
|
|
142
|
+
}
|
|
143
|
+
const key = present[0];
|
|
144
|
+
return { [key]: serializeValueOrRef(attachment[key]) };
|
|
145
|
+
}
|
|
138
146
|
export function aiAgent(opts) {
|
|
139
147
|
if (opts.outputType === "json" && (opts.schema === undefined || Object.keys(opts.schema).length === 0)) {
|
|
140
148
|
throw new Error('aiAgent with outputType "json" requires at least one field in schema.');
|
|
@@ -156,6 +164,9 @@ export function aiAgent(opts) {
|
|
|
156
164
|
}
|
|
157
165
|
: {}),
|
|
158
166
|
...(opts.connector !== undefined ? { aiProviderConnectorId: opts.connector } : {}),
|
|
167
|
+
...(opts.attachments !== undefined
|
|
168
|
+
? { attachments: opts.attachments.map(serializeAiAgentAttachment) }
|
|
169
|
+
: {}),
|
|
159
170
|
},
|
|
160
171
|
};
|
|
161
172
|
}
|
package/package.json
CHANGED