Files
united-workforce/packages/workflow-protocol/src/schemas.ts
T
xiaomo b0ef9c55a9 feat: moderator recognizes $SUSPEND as pseudo-role target
- Add GraphPseudoRole type ($END | $SUSPEND) to workflow-protocol
- Add 'suspended' to ThreadStatus
- evaluate() returns EvaluateSuspendResult for $SUSPEND targets
- Thread show/list derive suspended status from moderator evaluation
- validate-semantic treats $SUSPEND like $END (valid target, no outgoing edges)
- Tests: routing to $SUSPEND, mustache rendering, thread status display

Closes #588
2026-06-02 04:39:29 +00:00

97 lines
2.4 KiB
TypeScript

import type { JSONSchema } from "@ocas/core";
const ROLE_DEFINITION: JSONSchema = {
type: "object",
required: ["description", "goal", "capabilities", "procedure", "output", "frontmatter"],
properties: {
description: { type: "string" },
goal: { type: "string" },
capabilities: { type: "array", items: { type: "string" } },
procedure: { type: "string" },
output: { type: "string" },
frontmatter: { type: "string", format: "ocas_ref" },
},
additionalProperties: false,
};
const TARGET: JSONSchema = {
type: "object",
required: ["role", "prompt"],
properties: {
role: { type: "string", description: "Role name or pseudo-role ($END, $SUSPEND)" },
prompt: { type: "string" },
location: {
anyOf: [{ type: "string" }, { type: "null" }],
},
},
additionalProperties: false,
};
export const WORKFLOW_SCHEMA: JSONSchema = {
title: "Workflow",
type: "object",
required: ["name", "description", "roles", "graph"],
properties: {
name: { type: "string" },
description: { type: "string" },
roles: {
type: "object",
additionalProperties: ROLE_DEFINITION,
},
graph: {
type: "object",
additionalProperties: {
type: "object",
additionalProperties: TARGET,
},
},
},
additionalProperties: false,
};
export const START_NODE_SCHEMA: JSONSchema = {
title: "StartNode",
type: "object",
required: ["workflow", "prompt", "cwd"],
properties: {
workflow: { type: "string", format: "ocas_ref" },
prompt: { type: "string" },
cwd: { type: "string" },
},
additionalProperties: false,
};
export const STEP_NODE_SCHEMA: JSONSchema = {
title: "StepNode",
type: "object",
required: [
"start",
"prev",
"role",
"output",
"detail",
"agent",
"startedAtMs",
"completedAtMs",
"cwd",
],
properties: {
start: { type: "string", format: "ocas_ref" },
prev: {
anyOf: [{ type: "string", format: "ocas_ref" }, { type: "null" }],
},
role: { type: "string" },
output: { type: "string", format: "ocas_ref" },
detail: { type: "string", format: "ocas_ref" },
agent: { type: "string" },
edgePrompt: { type: "string" },
startedAtMs: { type: "integer" },
completedAtMs: { type: "integer" },
cwd: { type: "string" },
assembledPrompt: {
anyOf: [{ type: "string", format: "ocas_ref" }, { type: "null" }],
},
},
additionalProperties: false,
};