feat(p7): /v1/ai REST + kernel-client AI methods + @insignia/iios-ai-web SDK
Task 7.5: AiController exposes POST /v1/ai/jobs, GET /v1/ai/artifacts(+/:id), POST accept/reject (session-auth). kernel-client RestClient gains runAiJob/ listArtifacts/getArtifact/acceptArtifact/rejectArtifact + AiArtifact/AiClaim/ AiEvidenceLink/AiModelRun types. New @insignia/iios-ai-web (AiProvider, useRunJob, useAiProposals, useArtifact). Boundary allowlist: ai-web -> contracts + kernel-client (fails on ai-web->service). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { IngestInteractionRequest } from '@insignia/iios-contracts';
|
||||
import type { Message, InboxItem, InboxState, Ticket, TicketState, CallbackRequest, RouteBinding, RouteDecision } from './types';
|
||||
import type { Message, InboxItem, InboxState, Ticket, TicketState, CallbackRequest, RouteBinding, RouteDecision, AiArtifact, AiJobResult } from './types';
|
||||
|
||||
export interface RestConfig {
|
||||
serviceUrl: string;
|
||||
@@ -124,6 +124,31 @@ export class RestClient {
|
||||
return this.post<RouteDecision>(`/v1/routes/decisions/${id}/deny`, {});
|
||||
}
|
||||
|
||||
// ─── AI proposal layer (P7) ───────────────────────────────────
|
||||
async runAiJob(input: { interactionId: string; jobType: 'CLASSIFY' | 'SUMMARIZE' | 'EXTRACT' }): Promise<AiJobResult> {
|
||||
return this.post<AiJobResult>('/v1/ai/jobs', input);
|
||||
}
|
||||
async listArtifacts(opts?: { interactionId?: string; status?: string }): Promise<AiArtifact[]> {
|
||||
const q = new URLSearchParams();
|
||||
if (opts?.interactionId) q.set('interactionId', opts.interactionId);
|
||||
if (opts?.status) q.set('status', opts.status);
|
||||
const qs = q.toString();
|
||||
const r = await fetch(this.url(`/v1/ai/artifacts${qs ? `?${qs}` : ''}`), { headers: this.headers() });
|
||||
if (!r.ok) throw new Error(`listArtifacts ${r.status}`);
|
||||
return (await r.json()) as AiArtifact[];
|
||||
}
|
||||
async getArtifact(id: string): Promise<AiArtifact> {
|
||||
const r = await fetch(this.url(`/v1/ai/artifacts/${id}`), { headers: this.headers() });
|
||||
if (!r.ok) throw new Error(`getArtifact ${r.status}`);
|
||||
return (await r.json()) as AiArtifact;
|
||||
}
|
||||
async acceptArtifact(id: string): Promise<AiArtifact> {
|
||||
return this.post<AiArtifact>(`/v1/ai/artifacts/${id}/accept`, {});
|
||||
}
|
||||
async rejectArtifact(id: string): Promise<AiArtifact> {
|
||||
return this.post<AiArtifact>(`/v1/ai/artifacts/${id}/reject`, {});
|
||||
}
|
||||
|
||||
private async post<T>(path: string, body: unknown): Promise<T> {
|
||||
const r = await fetch(this.url(path), { method: 'POST', headers: this.headers(), body: JSON.stringify(body) });
|
||||
if (!r.ok) throw new Error(`POST ${path} ${r.status}`);
|
||||
|
||||
Reference in New Issue
Block a user