feat(tasks): enforce dynamic execution plans
This commit is contained in:
@@ -151,6 +151,12 @@ export const humanTaskEvidenceCommandSchema = z.object({
|
||||
export type TaskEvidence = z.infer<typeof taskEvidenceSchema>;
|
||||
export type TaskReport = z.infer<typeof taskReportSchema>;
|
||||
export type OperationalTaskDataQuery = z.infer<typeof operationalTaskDataQuerySchema>;
|
||||
export const expressAccessRequestSchema = z.object({
|
||||
requestId: z.string().uuid(),
|
||||
nodeId: z.string().min(1),
|
||||
scopes: z.array(taskDataSourceSchema).min(1).max(7),
|
||||
reason: z.string().min(1),
|
||||
});
|
||||
export type HumanTaskEvidenceCommand = z.infer<typeof humanTaskEvidenceCommandSchema>;
|
||||
|
||||
export type OperationalTaskContext = Record<string, unknown>;
|
||||
@@ -354,6 +360,18 @@ export class OperationalTaskClient {
|
||||
return { evidence, snapshot };
|
||||
}
|
||||
|
||||
async requestDataAccess(runtimeSessionId: string, taskId: string, input: {
|
||||
requestId: string; sourceSessionId: string; nodeId: string; scopes: OperationalTaskDataQuery["source"][]; reason: string;
|
||||
}) {
|
||||
return this.request(runtimeSessionId, `/api/v1/operational-tasks/${encodeURIComponent(taskId)}/access-requests`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
request_id: input.requestId, source_session_id: input.sourceSessionId,
|
||||
node_id: input.nodeId, scopes: input.scopes, reason: input.reason,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
async proposeAction(runtimeSessionId: string, taskId: string, input: ProposedTaskAction) {
|
||||
const result = await this.request(runtimeSessionId, `/api/v1/operational-tasks/${encodeURIComponent(taskId)}/actions`, {
|
||||
method: "POST",
|
||||
@@ -475,7 +493,7 @@ const toServerPlan = (input: Record<string, unknown>) => {
|
||||
const nodes = Array.isArray(input.nodes) ? input.nodes : [];
|
||||
const edges = Array.isArray(input.edges) ? input.edges : [];
|
||||
return {
|
||||
schema: "execution-plan@1",
|
||||
schema: input.schema === "execution-plan@2" ? "execution-plan@2" : "execution-plan@1",
|
||||
title: input.title,
|
||||
reason: input.reason,
|
||||
nodes: nodes.map((value) => {
|
||||
@@ -488,6 +506,12 @@ const toServerPlan = (input: Record<string, unknown>) => {
|
||||
detail: node.detail,
|
||||
evidence_refs: Array.isArray(node.evidence) ? node.evidence : [],
|
||||
action_refs: Array.isArray(node.action_refs) ? node.action_refs : [],
|
||||
...(input.schema === "execution-plan@2" ? {
|
||||
kind: node.kind,
|
||||
selected_edge_id: node.selected_edge_id ?? null,
|
||||
gate_ref: node.gate_ref ?? null,
|
||||
revisits_node_id: node.revisits_node_id ?? null,
|
||||
} : {}),
|
||||
};
|
||||
}),
|
||||
edges: edges.map((value) => {
|
||||
@@ -496,6 +520,7 @@ const toServerPlan = (input: Record<string, unknown>) => {
|
||||
from: edge.from,
|
||||
to: edge.to,
|
||||
...(typeof edge.label === "string" && edge.label.trim() ? { condition: edge.label } : {}),
|
||||
...(input.schema === "execution-plan@2" ? { id: edge.id } : {}),
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user