feat(agent): align investigation reports and selected context
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { bindSessionCredential, releaseSessionCredential, requestWithSessionCredential } from "./credential-refresh.js";
|
||||
import { taskReportSchema } from "./investigation-report.js";
|
||||
export { taskReportSchema } from "./investigation-report.js";
|
||||
import { z } from "zod";
|
||||
|
||||
import { config } from "../config.js";
|
||||
@@ -63,6 +65,10 @@ const agentTaskContextSchema = z.object({
|
||||
permissions: z.record(z.boolean()),
|
||||
}).passthrough(),
|
||||
approved_data_scopes: z.array(taskDataSourceSchema),
|
||||
selected_report: z.object({
|
||||
revision: z.number().int().positive(), execution_generation: z.number().int().positive().nullish(),
|
||||
report: z.unknown(),
|
||||
}).passthrough().nullish(),
|
||||
});
|
||||
|
||||
const receivedEvidenceSchema = z.object({
|
||||
@@ -103,15 +109,6 @@ export const taskEvidenceSchema = z.object({
|
||||
observed_at: z.string().datetime({ offset: true }),
|
||||
});
|
||||
|
||||
export const taskReportSchema = z.object({
|
||||
title: z.string().trim().min(1).max(160),
|
||||
current_conclusion: z.string().trim().min(1).max(4000),
|
||||
conclusion_boundary: z.string().trim().min(1).max(2000),
|
||||
evidence_refs: z.array(z.string().trim().min(1).max(128)).max(100).default([]),
|
||||
recommendations: z.array(z.string().trim().min(1).max(1000)).max(30).default([]),
|
||||
pending_items: z.array(z.string().trim().min(1).max(500)).max(20).default([]),
|
||||
});
|
||||
|
||||
export const operationalTaskDataQuerySchema = z.object({
|
||||
source: taskDataSourceSchema,
|
||||
device_ids: z.array(z.string().trim().min(1).max(160)).max(20).optional(),
|
||||
@@ -203,8 +200,9 @@ export const clearOperationalTaskLease = (runtimeSessionId: string) => {
|
||||
export class OperationalTaskClient {
|
||||
constructor(private readonly baseUrl = config.TJWATER_SERVER_BASE_URL) {}
|
||||
|
||||
async getAgentContext(runtimeSessionId: string, taskId: string) {
|
||||
const raw = await this.request(runtimeSessionId, `/api/v1/operational-tasks/${encodeURIComponent(taskId)}/agent-context`, {
|
||||
async getAgentContext(runtimeSessionId: string, taskId: string, reportRevision?: number) {
|
||||
const query = reportRevision == null ? "" : `?report_revision=${reportRevision}`;
|
||||
const raw = await this.request(runtimeSessionId, `/api/v1/operational-tasks/${encodeURIComponent(taskId)}/agent-context${query}`, {
|
||||
method: "GET",
|
||||
});
|
||||
const result = agentTaskContextSchema.parse(raw);
|
||||
|
||||
Reference in New Issue
Block a user