fix: open ai workspace console in ops
This commit is contained in:
@@ -50,6 +50,64 @@ export type TAIWorkspaceExecutorInput = {
|
||||
status?: TAIWorkspaceExecutorStatus;
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThread = {
|
||||
id: string;
|
||||
title: string;
|
||||
originSurface: "engine" | "ops" | "global" | string;
|
||||
activeContext?: Record<string, any>;
|
||||
enabledToolPacks?: string[];
|
||||
linkedArtifacts?: Record<string, any>[];
|
||||
selectedExecutorId?: string | null;
|
||||
lifecycleState?: "active" | "archived" | string;
|
||||
metadata?: Record<string, any>;
|
||||
createdAt?: string | null;
|
||||
updatedAt?: string | null;
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadMessageRole = "system" | "user" | "assistant" | "tool";
|
||||
|
||||
export type TAIWorkspaceThreadMessage = {
|
||||
id: string;
|
||||
threadId: string;
|
||||
sequence?: number;
|
||||
role: TAIWorkspaceThreadMessageRole;
|
||||
content: string;
|
||||
payload?: Record<string, any>;
|
||||
createdAt?: string | null;
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadListResponse = {
|
||||
ok: boolean;
|
||||
threads: TAIWorkspaceThread[];
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadResponse = {
|
||||
ok: boolean;
|
||||
thread: TAIWorkspaceThread;
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadMessagesResponse = {
|
||||
ok: boolean;
|
||||
threadId: string;
|
||||
messages: TAIWorkspaceThreadMessage[];
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadMessageResponse = {
|
||||
ok: boolean;
|
||||
message: TAIWorkspaceThreadMessage;
|
||||
};
|
||||
|
||||
export type TAIWorkspaceThreadInput = {
|
||||
title: string;
|
||||
originSurface?: "engine" | "ops" | "global";
|
||||
activeContext?: Record<string, any>;
|
||||
enabledToolPacks?: string[];
|
||||
linkedArtifacts?: Record<string, any>[];
|
||||
selectedExecutorId?: string | null;
|
||||
lifecycleState?: "active" | "archived";
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
export class WorkspaceAIWorkspaceService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
@@ -63,10 +121,15 @@ export class WorkspaceAIWorkspaceService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async createExecutor(workspaceSlug: string, input: TAIWorkspaceExecutorInput): Promise<TAIWorkspaceExecutorListResponse> {
|
||||
await this.post(`/api/workspaces/${workspaceSlug}/ai-workspace/executors/`, { ...input, select: true }).catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
async createExecutor(
|
||||
workspaceSlug: string,
|
||||
input: TAIWorkspaceExecutorInput
|
||||
): Promise<TAIWorkspaceExecutorListResponse> {
|
||||
await this.post(`/api/workspaces/${workspaceSlug}/ai-workspace/executors/`, { ...input, select: true }).catch(
|
||||
(error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
}
|
||||
);
|
||||
return this.listExecutors(workspaceSlug);
|
||||
}
|
||||
|
||||
@@ -101,4 +164,68 @@ export class WorkspaceAIWorkspaceService extends APIService {
|
||||
if (port) params.set("port", port);
|
||||
return `${API_BASE_URL}/api/workspaces/${workspaceSlug}/ai-workspace/executors/${executorId}/agent/windows.ps1?${params.toString()}`;
|
||||
}
|
||||
|
||||
async listThreads(
|
||||
workspaceSlug: string,
|
||||
options: { surface?: "ops" | "engine" | "global"; limit?: number } = {}
|
||||
): Promise<TAIWorkspaceThreadListResponse> {
|
||||
const params = new URLSearchParams();
|
||||
params.set("surface", options.surface || "ops");
|
||||
params.set("limit", String(options.limit || 100));
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/ai-workspace/threads/?${params.toString()}`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
}
|
||||
|
||||
async createThread(workspaceSlug: string, input: TAIWorkspaceThreadInput): Promise<TAIWorkspaceThreadResponse> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/ai-workspace/threads/`, {
|
||||
originSurface: "ops",
|
||||
enabledToolPacks: ["ops"],
|
||||
...input,
|
||||
})
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
}
|
||||
|
||||
async updateThread(
|
||||
workspaceSlug: string,
|
||||
threadId: string,
|
||||
input: Partial<TAIWorkspaceThreadInput>
|
||||
): Promise<TAIWorkspaceThreadResponse> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/ai-workspace/threads/${threadId}/`, input)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
}
|
||||
|
||||
async listThreadMessages(
|
||||
workspaceSlug: string,
|
||||
threadId: string,
|
||||
options: { limit?: number } = {}
|
||||
): Promise<TAIWorkspaceThreadMessagesResponse> {
|
||||
const params = new URLSearchParams();
|
||||
params.set("limit", String(options.limit || 200));
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/ai-workspace/threads/${threadId}/messages/?${params.toString()}`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
}
|
||||
|
||||
async createThreadMessage(
|
||||
workspaceSlug: string,
|
||||
threadId: string,
|
||||
input: { role: TAIWorkspaceThreadMessageRole; content: string; payload?: Record<string, any> }
|
||||
): Promise<TAIWorkspaceThreadMessageResponse> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/ai-workspace/threads/${threadId}/messages/`, input)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data ?? error;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user