feat: implement channel runtime connectors
This commit is contained in:
@ -8,6 +8,12 @@ import type {
|
||||
ChatLogsResponse,
|
||||
BackendTask,
|
||||
ChatMessage,
|
||||
ChannelConfigDetail,
|
||||
ChannelConfigPayload,
|
||||
ChannelConnectorDescriptor,
|
||||
ConnectorSessionResponse,
|
||||
ConnectorSessionStartPayload,
|
||||
ChannelEventRecord,
|
||||
CronJob,
|
||||
FileAttachment,
|
||||
NotificationDetail,
|
||||
@ -638,6 +644,53 @@ export async function updateProviderConfig(
|
||||
});
|
||||
}
|
||||
|
||||
export async function getChannelConfig(channelId: string): Promise<ChannelConfigDetail> {
|
||||
return fetchJSON(`/api/channels/${encodeURIComponent(channelId)}/config`);
|
||||
}
|
||||
|
||||
export async function updateChannelConfig(
|
||||
channelId: string,
|
||||
payload: ChannelConfigPayload
|
||||
): Promise<{ ok: boolean; channel_id: string; restart_required: boolean; channel: ChannelConfigDetail }> {
|
||||
return fetchJSON(`/api/channels/${encodeURIComponent(channelId)}/config`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function listChannelEvents(channelId: string, limit: number = 100): Promise<ChannelEventRecord[]> {
|
||||
return fetchJSON(`/api/channels/${encodeURIComponent(channelId)}/events?limit=${limit}`);
|
||||
}
|
||||
|
||||
export async function listChannelConnectors(): Promise<ChannelConnectorDescriptor[]> {
|
||||
return fetchJSON('/api/channel-connectors');
|
||||
}
|
||||
|
||||
export async function startChannelConnectorSession(
|
||||
payload: ConnectorSessionStartPayload
|
||||
): Promise<ConnectorSessionResponse> {
|
||||
return fetchJSON('/api/channel-connector-sessions', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
kind: payload.kind,
|
||||
displayName: payload.displayName,
|
||||
ownerUserId: payload.ownerUserId,
|
||||
options: payload.options || {},
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export async function getChannelConnectorSession(sessionId: string): Promise<ConnectorSessionResponse> {
|
||||
return fetchJSON(`/api/channel-connector-sessions/${encodeURIComponent(sessionId)}`);
|
||||
}
|
||||
|
||||
export async function restartRuntime(): Promise<{ ok: boolean; restarting: boolean }> {
|
||||
return fetchJSON('/api/runtime/restart', {
|
||||
method: 'POST',
|
||||
timeoutMs: 5000,
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Cron (proxied)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user