Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lib/entities/ai-action-invocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const AiActionOutputFormat = {
RichText: 'RichText',
Markdown: 'Markdown',
PlainText: 'PlainText',
Suggestion: 'Suggestion',
} as const

export type AiActionOutputFormatType =
Expand All @@ -30,8 +31,25 @@ export type AiActionInvocationMetadata = {
}[]
}

export type AiActionMarkdownBlock = {
type: 'MarkdownBlock'
text: string
}

export type AiActionSuggestionBlock = {
type: 'SuggestionBlock'
format: 'Text'
fieldId: string
original: string
suggested: string
reason?: string
confidence: number
}

export type AiActionSuggestionContentBlock = AiActionMarkdownBlock | AiActionSuggestionBlock

export interface InvocationResult {
content: string | RichTextDocument
content: string | RichTextDocument | AiActionSuggestionContentBlock[]
type: InvocationResultType
metadata: AiActionInvocationMetadata
}
Expand All @@ -50,7 +68,7 @@ export type AiActionInvocationProps = {
}

export type AiActionInvocationType = {
outputFormat: 'RichText' | 'Markdown' | 'PlainText'
outputFormat: AiActionOutputFormatType
variables?: Array<
| {
value: string
Expand Down
38 changes: 26 additions & 12 deletions lib/entities/ai-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type AiActionInvocation,
} from './ai-action-invocation'

export type VariableType =
export type AiActionVariableType =
| 'ResourceLink'
| 'Text'
| 'StandardInput'
Expand All @@ -18,33 +18,47 @@ export type VariableType =
| 'Reference'
| 'SmartContext'

export type ReferenceVariableConfiguration = {
export type AiActionReferenceVariableConfiguration = {
allowedEntities: Array<'Entry'>
}

export type VariableConfiguration =
export type AiActionVariableConfiguration =
| {
strict: boolean
in: Array<string>
}
| ReferenceVariableConfiguration
| AiActionReferenceVariableConfiguration

export type Variable = {
configuration?: VariableConfiguration
export type AiActionVariable = {
configuration?: AiActionVariableConfiguration
description?: string
name?: string
type: VariableType
type: AiActionVariableType
id: string
}

export type Instruction = {
variables: Array<Variable>
export const AiActionScope = {
Entry: 'Entry',
EntryField: 'EntryField',
} as const
export type AiActionScopeType = (typeof AiActionScope)[keyof typeof AiActionScope]

export const AiActionOutputType = {
Transform: 'Transform',
Suggestion: 'Suggestion',
} as const
export type AiActionOutputTypeType = (typeof AiActionOutputType)[keyof typeof AiActionOutputType]

export type AiActionInstruction = {
variables: Array<AiActionVariable>
template: string
}

export type Configuration = {
export type AiActionConfiguration = {
modelType: string
modelTemperature: number
scope?: AiActionScopeType
Copy link
Contributor

@cemreyuksel cemreyuksel Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to make these parameters required once we release. We can discuss.

outputType?: AiActionOutputTypeType
}

export type AiActionTestCase =
Expand Down Expand Up @@ -83,8 +97,8 @@ export type AiActionProps = {
}
name: string
description: string
configuration: Configuration
instruction: Instruction
configuration: AiActionConfiguration
instruction: AiActionInstruction
testCases?: Array<AiActionTestCase>
}

Expand Down