wip: first run of implementation
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import type { ProtocolResponseEnvelope } from '../types/electron';
|
||||
|
||||
export interface ChatService {
|
||||
createConversation: (title?: string, model?: string) => Promise<{ id: string } | null | undefined>;
|
||||
sendMessage: (
|
||||
conversationId: string,
|
||||
message: string,
|
||||
metadata?: SendMessageMetadata,
|
||||
) => Promise<{ success: boolean; message?: string; error?: string } | null | undefined>;
|
||||
) => Promise<{ success: boolean; message?: string; envelope?: ProtocolResponseEnvelope; protocolVersion?: '2.0'; traceId?: string; warnings?: string[]; error?: string } | null | undefined>;
|
||||
}
|
||||
|
||||
export interface SendMessageMetadata {
|
||||
@@ -27,6 +29,10 @@ export interface SendConversationMessageInput {
|
||||
export interface SendConversationMessageResult {
|
||||
success: boolean;
|
||||
message: string;
|
||||
envelope?: ProtocolResponseEnvelope;
|
||||
protocolVersion?: '2.0';
|
||||
traceId?: string;
|
||||
warnings?: string[];
|
||||
error?: string;
|
||||
}
|
||||
|
||||
@@ -69,5 +75,9 @@ export async function sendConversationMessage(
|
||||
return {
|
||||
success: true,
|
||||
message: result.message || '',
|
||||
envelope: result.envelope,
|
||||
protocolVersion: result.protocolVersion,
|
||||
traceId: result.traceId,
|
||||
warnings: result.warnings,
|
||||
};
|
||||
}
|
||||
|
||||
38
src/renderer/navigation/protocolNeedsInput.ts
Normal file
38
src/renderer/navigation/protocolNeedsInput.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { ProtocolNeedsInputField, ProtocolResponseEnvelope } from '../types/electron';
|
||||
import type { AssistantPanelElement } from './assistantPanelSpec';
|
||||
|
||||
function toFormField(field: ProtocolNeedsInputField): {
|
||||
key: string;
|
||||
label: string;
|
||||
inputType: 'text' | 'textarea' | 'select' | 'checkbox' | 'date' | 'number';
|
||||
placeholder?: string;
|
||||
defaultValue?: string | number | boolean;
|
||||
options?: Array<{ label: string; value: string }>;
|
||||
required?: boolean;
|
||||
} {
|
||||
return {
|
||||
key: field.key,
|
||||
label: field.label,
|
||||
inputType: field.inputType,
|
||||
placeholder: field.placeholder,
|
||||
defaultValue: field.defaultValue,
|
||||
options: field.options,
|
||||
required: field.required,
|
||||
};
|
||||
}
|
||||
|
||||
export function toClarificationElements(
|
||||
needsInput: ProtocolResponseEnvelope['needsInput'],
|
||||
): AssistantPanelElement[] {
|
||||
if (!needsInput.required || needsInput.fields.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [{
|
||||
type: 'form',
|
||||
formId: 'agui-needs-input',
|
||||
submitLabel: needsInput.fields[0].label,
|
||||
action: 'submitNeedsInput',
|
||||
fields: needsInput.fields.map(toFormField),
|
||||
}];
|
||||
}
|
||||
Reference in New Issue
Block a user