refactor(api): split MindSpace agent jobs client
This commit is contained in:
+8
-79
@@ -18,7 +18,6 @@ import type {
|
||||
LlmConnectionTestResult,
|
||||
RechargeOrder,
|
||||
Message,
|
||||
MindSpaceAgentJob,
|
||||
MindSpaceQuota,
|
||||
PlazaCategory,
|
||||
PlazaPostBrief,
|
||||
@@ -54,7 +53,6 @@ import {
|
||||
resetUnauthorizedGuard,
|
||||
sanitizeSessionEvent,
|
||||
} from './core';
|
||||
import type { MindSpaceListPage } from './mindspace-pages';
|
||||
export { ApiError, resetUnauthorizedGuard, setUnauthorizedHandler } from './core';
|
||||
export {
|
||||
buildMindSpaceConversationPackageManifestDownloadUrl,
|
||||
@@ -69,6 +67,14 @@ export {
|
||||
runMindSpaceCleanup,
|
||||
uploadMindSpaceAsset,
|
||||
} from './mindspace-assets';
|
||||
export {
|
||||
cancelMindSpaceAgentJob,
|
||||
createMindSpaceAgentJob,
|
||||
getMindSpaceAgentJob,
|
||||
listMindSpaceAgentJobs,
|
||||
retryMindSpaceAgentJob,
|
||||
runMindSpaceAgentJob,
|
||||
} from './mindspace-agent-jobs';
|
||||
export {
|
||||
bindMindSpacePageLiveEdit,
|
||||
closeMindSpacePageEditSession,
|
||||
@@ -642,83 +648,6 @@ export async function publishPageToPlaza(input: {
|
||||
return result.data.post;
|
||||
}
|
||||
|
||||
export async function createMindSpaceAgentJob(input: {
|
||||
jobType: string;
|
||||
instruction: string;
|
||||
allowedAssetIds: string[];
|
||||
outputType?: 'page_draft' | 'html_page' | 'markdown';
|
||||
outputCategoryId?: string;
|
||||
idempotencyKey?: string;
|
||||
locale?: string;
|
||||
timezone?: string;
|
||||
capabilities?: {
|
||||
network?: boolean;
|
||||
shell?: boolean;
|
||||
createPage?: boolean;
|
||||
};
|
||||
}): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>('/mindspace/v1/agent/jobs', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
job_type: input.jobType,
|
||||
instruction: input.instruction,
|
||||
allowed_asset_ids: input.allowedAssetIds,
|
||||
output_type: input.outputType ?? 'page_draft',
|
||||
output_category_id: input.outputCategoryId,
|
||||
idempotency_key: input.idempotencyKey,
|
||||
locale: input.locale,
|
||||
timezone: input.timezone,
|
||||
capabilities: input.capabilities,
|
||||
}),
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function getMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}`,
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function listMindSpaceAgentJobs(options?: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}): Promise<{ items: MindSpaceAgentJob[]; page: MindSpaceListPage }> {
|
||||
const limit = options?.limit ?? 10;
|
||||
const offset = options?.offset ?? 0;
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob[]; page?: MindSpaceListPage }>(
|
||||
`/mindspace/v1/agent/jobs?limit=${encodeURIComponent(String(limit))}&offset=${encodeURIComponent(String(offset))}`,
|
||||
);
|
||||
return { items: result.data, page: result.page ?? {} };
|
||||
}
|
||||
|
||||
export async function runMindSpaceAgentJob(
|
||||
jobId: string,
|
||||
): Promise<{ started: boolean; jobId: string }> {
|
||||
const result = await apiFetch<{ data: { started: boolean; jobId: string } }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/run`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function cancelMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/cancel`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function retryMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/retry`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function getAdminDashboardSummary(): Promise<AdminDashboardSummary> {
|
||||
const result = await portalFetch<{ summary: AdminDashboardSummary }>('/admin-api/summary');
|
||||
return result.summary;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import type { MindSpaceAgentJob } from '../types';
|
||||
import { apiFetch } from './core';
|
||||
import type { MindSpaceListPage } from './mindspace-pages';
|
||||
|
||||
export async function createMindSpaceAgentJob(input: {
|
||||
jobType: string;
|
||||
instruction: string;
|
||||
allowedAssetIds: string[];
|
||||
outputType?: 'page_draft' | 'html_page' | 'markdown';
|
||||
outputCategoryId?: string;
|
||||
idempotencyKey?: string;
|
||||
locale?: string;
|
||||
timezone?: string;
|
||||
capabilities?: {
|
||||
network?: boolean;
|
||||
shell?: boolean;
|
||||
createPage?: boolean;
|
||||
};
|
||||
}): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>('/mindspace/v1/agent/jobs', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
job_type: input.jobType,
|
||||
instruction: input.instruction,
|
||||
allowed_asset_ids: input.allowedAssetIds,
|
||||
output_type: input.outputType ?? 'page_draft',
|
||||
output_category_id: input.outputCategoryId,
|
||||
idempotency_key: input.idempotencyKey,
|
||||
locale: input.locale,
|
||||
timezone: input.timezone,
|
||||
capabilities: input.capabilities,
|
||||
}),
|
||||
});
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function getMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}`,
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function listMindSpaceAgentJobs(options?: {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}): Promise<{ items: MindSpaceAgentJob[]; page: MindSpaceListPage }> {
|
||||
const limit = options?.limit ?? 10;
|
||||
const offset = options?.offset ?? 0;
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob[]; page?: MindSpaceListPage }>(
|
||||
`/mindspace/v1/agent/jobs?limit=${encodeURIComponent(String(limit))}&offset=${encodeURIComponent(String(offset))}`,
|
||||
);
|
||||
return { items: result.data, page: result.page ?? {} };
|
||||
}
|
||||
|
||||
export async function runMindSpaceAgentJob(
|
||||
jobId: string,
|
||||
): Promise<{ started: boolean; jobId: string }> {
|
||||
const result = await apiFetch<{ data: { started: boolean; jobId: string } }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/run`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function cancelMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/cancel`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
|
||||
export async function retryMindSpaceAgentJob(jobId: string): Promise<MindSpaceAgentJob> {
|
||||
const result = await apiFetch<{ data: MindSpaceAgentJob }>(
|
||||
`/mindspace/v1/agent/jobs/${encodeURIComponent(jobId)}/retry`,
|
||||
{ method: 'POST', body: JSON.stringify({}) },
|
||||
);
|
||||
return result.data;
|
||||
}
|
||||
Reference in New Issue
Block a user