@red-hat-developer-hub/backstage-plugin-augment-common 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs.js +36 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2095 -0
- package/dist/index.esm.js +7 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/permissions.cjs.js +25 -0
- package/dist/permissions.cjs.js.map +1 -0
- package/dist/permissions.esm.js +21 -0
- package/dist/permissions.esm.js.map +1 -0
- package/dist/templates/workflowTemplates.cjs.js +333 -0
- package/dist/templates/workflowTemplates.cjs.js.map +1 -0
- package/dist/templates/workflowTemplates.esm.js +331 -0
- package/dist/templates/workflowTemplates.esm.js.map +1 -0
- package/dist/types/branding.cjs.js +17 -0
- package/dist/types/branding.cjs.js.map +1 -0
- package/dist/types/branding.esm.js +15 -0
- package/dist/types/branding.esm.js.map +1 -0
- package/dist/types/provider.cjs.js +52 -0
- package/dist/types/provider.cjs.js.map +1 -0
- package/dist/types/provider.esm.js +46 -0
- package/dist/types/provider.esm.js.map +1 -0
- package/dist/types/shared.cjs.js +86 -0
- package/dist/types/shared.cjs.js.map +1 -0
- package/dist/types/shared.esm.js +77 -0
- package/dist/types/shared.esm.js.map +1 -0
- package/dist/types/workflowBuilder.cjs.js +73 -0
- package/dist/types/workflowBuilder.cjs.js.map +1 -0
- package/dist/types/workflowBuilder.esm.js +66 -0
- package/dist/types/workflowBuilder.esm.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.cjs.js","sources":["../../src/types/shared.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Token usage reported by the inference server for a single response turn.\n *\n * Mirrors the OpenAI Responses API `ResponseUsage` object.\n * Llama Stack implements the same schema, so this type is\n * the single source of truth for both frontend and backend.\n *\n * @see https://platform.openai.com/docs/api-reference/responses/object\n * @public\n */\nexport interface ResponseUsage {\n /** Total input tokens (cumulative across all internal agentic calls) */\n input_tokens: number;\n /** Total output tokens (cumulative across all internal agentic calls) */\n output_tokens: number;\n /** Sum of input_tokens + output_tokens (may include internal overhead) */\n total_tokens: number;\n /**\n * Breakdown of input tokens.\n * Present when the server supports prompt caching.\n */\n input_tokens_details?: InputTokensDetails;\n /**\n * Breakdown of output tokens.\n * Llama Stack may return `null` when the model does not emit reasoning tokens.\n */\n output_tokens_details?: OutputTokensDetails | null;\n}\n\n/**\n * Detailed breakdown of input tokens.\n * @public\n */\nexport interface InputTokensDetails {\n /** Tokens retrieved from the KV-cache (no additional compute cost) */\n cached_tokens?: number;\n}\n\n/**\n * Detailed breakdown of output tokens.\n * @public\n */\nexport interface OutputTokensDetails {\n /** Internal chain-of-thought tokens used by reasoning models (e.g. o3, o4-mini) */\n reasoning_tokens?: number;\n}\n\n// =============================================================================\n// Shared Types (used by both frontend and backend)\n// =============================================================================\n\n/**\n * Chat message in a conversation\n * @public\n */\nexport interface ChatMessage {\n role: 'system' | 'user' | 'assistant';\n content: string;\n}\n\n/**\n * Tool call information\n * @public\n */\nexport interface ToolCallInfo {\n id: string;\n name: string;\n serverLabel: string;\n arguments: string;\n output?: string;\n error?: string;\n}\n\n/**\n * RAG source information from file_search_call.results\n * This comes directly from Llama Stack Responses API when include: ['file_search_call.results']\n * @public\n */\nexport interface RAGSource {\n /** Filename or document identifier */\n filename: string;\n /** Relevant text snippet from the document */\n text?: string;\n /** Relevance score (0-1) if provided by the API */\n score?: number;\n /** File ID for reference */\n fileId?: string;\n /** Document title from attributes (for display in citations) */\n title?: string;\n /** Source URL from attributes (for clickable citations) */\n sourceUrl?: string;\n /** Content type from attributes */\n contentType?: string;\n /** Raw attributes object from Llama Stack */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Aggregated evaluation result for a response\n * @public\n */\nexport interface EvaluationResult {\n /** Overall quality score (0-1) */\n overallScore: number;\n /** Individual scores by function */\n scores: Record<string, number>;\n /** Whether the response passed quality threshold */\n passedThreshold: boolean;\n /** Human-readable quality assessment */\n qualityLevel: 'excellent' | 'good' | 'fair' | 'poor';\n /** Timestamp of evaluation */\n evaluatedAt: string;\n /** Error message if evaluation failed */\n error?: string;\n /** True when evaluation was skipped (e.g. not available) rather than run */\n skipped?: boolean;\n}\n\n/**\n * File format enum\n * @public\n */\nexport enum FileFormat {\n YAML = 'yaml',\n PDF = 'pdf',\n TEXT = 'text',\n MARKDOWN = 'markdown',\n JSON = 'json',\n}\n\n/**\n * Information about an uploaded document\n * @public\n */\nexport interface DocumentInfo {\n id: string;\n fileName: string;\n format: FileFormat;\n fileSize: number;\n uploadedAt: string;\n status: 'completed' | 'in_progress' | 'failed' | 'cancelled';\n}\n\n/**\n * Provider status information\n * @public\n */\nexport interface ProviderStatus {\n id: string;\n model: string;\n baseUrl: string;\n connected: boolean;\n error?: string;\n}\n\n/**\n * Vector store status information\n * @public\n */\nexport interface VectorStoreStatus {\n id: string;\n connected: boolean;\n totalDocuments?: number;\n error?: string;\n}\n\n/**\n * MCP server status information\n * @public\n */\nexport interface MCPToolInfo {\n name: string;\n description?: string;\n}\n\n/**\n * @public\n */\nexport interface MCPServerStatus {\n id: string;\n name: string;\n url: string;\n connected: boolean;\n error?: string;\n /** Tools available on this MCP server (populated when connected) */\n tools?: MCPToolInfo[];\n /** Total number of tools (convenience field) */\n toolCount?: number;\n /** Whether this server was defined in YAML (true) or added via admin UI (false) */\n source?: 'yaml' | 'admin';\n}\n\n/**\n * Security mode for Augment\n * @public\n */\nexport type SecurityMode = 'none' | 'plugin-only' | 'full';\n\n/**\n * Combined status for Augment\n * @public\n */\nexport interface AugmentStatus {\n /** Active provider identifier (e.g., 'llamastack', 'googleadk') */\n providerId: string;\n provider: ProviderStatus;\n vectorStore: VectorStoreStatus;\n mcpServers: MCPServerStatus[];\n /** Current security mode: 'none' | 'plugin-only' | 'full' */\n securityMode: SecurityMode;\n timestamp: string;\n /** Whether the plugin is ready to handle requests (AI provider connected) */\n ready: boolean;\n /** Blocking configuration errors that prevent the plugin from working */\n configurationErrors: string[];\n /** Whether the current user has admin privileges */\n isAdmin?: boolean;\n /** Optional capability status — these are not required for basic chat */\n capabilities?: {\n chat: boolean;\n rag: { available: boolean; reason?: string };\n mcpTools: { available: boolean; reason?: string };\n /** Whether this provider supports listing agents for the catalog */\n agentCatalog?: boolean;\n /** Whether the user must select an agent before chatting */\n agentSelection?: boolean;\n /** Whether agents have rich metadata (cards, skills) */\n agentCards?: boolean;\n };\n /** Summary of configured agents (multi-agent only) */\n agents?: Array<{ key: string; name: string; isDefault: boolean }>;\n /** Tool execution mode: 'direct' or 'backend' */\n toolExecutionMode?: 'direct' | 'backend';\n /** Error from last agent graph resolution attempt, if any */\n agentGraphError?: string;\n}\n\n/**\n * Information about an available vector store\n * @public\n */\nexport interface VectorStoreInfo {\n id: string;\n name: string;\n status: string;\n fileCount: number;\n createdAt: number;\n embeddingModel?: string;\n embeddingDimension?: number;\n providerType?: string;\n usageBytes?: number;\n lastActiveAt?: number;\n fileCounts?: {\n completed: number;\n inProgress: number;\n failed: number;\n cancelled: number;\n total: number;\n };\n}\n\n/**\n * Quick prompt configuration\n * @public\n */\nexport interface QuickPrompt {\n title: string;\n description: string;\n prompt: string;\n category: string;\n}\n\n// =============================================================================\n// Workflow Types (Configurable multi-step templates)\n// =============================================================================\n\n/**\n * A single step within a workflow\n * @public\n */\nexport interface WorkflowStep {\n /** Step title shown in UI */\n title: string;\n /** Prompt to send to chat when this step is executed */\n prompt: string;\n /** Optional description for the step */\n description?: string;\n}\n\n/**\n * A workflow template - multi-step guided experience\n * @public\n */\nexport interface Workflow {\n /** Unique identifier */\n id: string;\n /** Display name */\n name: string;\n /** Short description */\n description: string;\n /** Icon name (material icons) */\n icon?: string;\n /** Category for grouping */\n category?: string;\n /** Ordered list of steps */\n steps: WorkflowStep[];\n /** Whether this workflow is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * Quick action - single click prompt\n * @public\n */\nexport interface QuickAction {\n /** Display title */\n title: string;\n /** Short description */\n description?: string;\n /** Prompt to send to chat */\n prompt: string;\n /** Icon name */\n icon?: string;\n /** Category for grouping */\n category?: string;\n /** Whether this action is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * A clickable prompt card within a prompt group on the welcome screen\n * @public\n */\nexport interface PromptCard {\n /** Display title */\n title: string;\n /** Short description */\n description?: string;\n /** Prompt to send to chat */\n prompt: string;\n /** Icon name */\n icon?: string;\n /** Agent to auto-select when this card is clicked (e.g. \"namespace/agentName\") */\n agentId?: string;\n /** Whether this feature is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * Per-agent chat experience configuration set by admins.\n * Controls which agents are visible to end users and how they appear.\n * @public\n */\nexport interface ChatAgentConfig {\n /** Agent identifier: \"namespace/name\" */\n agentId: string;\n /** Whether this agent is published to the end-user catalog (derived from lifecycleStage === 'published') */\n published: boolean;\n /** Whether this agent appears in end-user chat (only applies when published) */\n visible: boolean;\n /** Whether this agent is featured prominently on the welcome screen */\n featured: boolean;\n /** Lifecycle stage: draft → pending → published → archived */\n lifecycleStage?: AgentLifecycleStage;\n /** Pending action when in 'pending' stage (e.g. publish or unpublish) */\n pendingAction?: 'publish' | 'unpublish';\n /** Promotion version — incremented each time the agent is promoted forward */\n version?: number;\n /** ISO timestamp of last promotion */\n promotedAt?: string;\n /** User ref of who last promoted this agent */\n promotedBy?: string;\n /** User ref of who originally created/registered this agent in the lifecycle */\n createdBy?: string;\n /** ISO timestamp of when the agent was first registered in the lifecycle */\n createdAt?: string;\n /** Reason the agent was rejected (set on review → draft demotion, cleared on re-promote) */\n rejectionReason?: string;\n /** User ref of who rejected the agent */\n rejectedBy?: string;\n /** ISO timestamp of when the agent was rejected */\n rejectedAt?: string;\n /** SonataFlow process instance id while awaiting admin approval */\n approvalWorkflowInstanceId?: string;\n /** Display order (lower first) */\n order?: number;\n /** Override display name */\n displayName?: string;\n /** Override description */\n description?: string;\n /** Custom avatar image URL */\n avatarUrl?: string;\n /** Per-agent accent color (hex) */\n accentColor?: string;\n /** Greeting message shown as first bot message on new conversation */\n greeting?: string;\n /** Suggested prompts shown on the agent card and below the input */\n conversationStarters?: string[];\n /** Direct chat endpoint URL for skill agents (e.g. http://agent.ns.svc:8000) */\n chatEndpoint?: string;\n /** K8s namespace where the skill agent is deployed */\n namespace?: string;\n}\n\n/**\n * Per-tool lifecycle configuration set by admins.\n * Controls which tools are published to end users, mirroring the agent lifecycle.\n * @public\n */\nexport interface ChatToolConfig {\n /** Tool identifier: \"namespace/name\" */\n toolId: string;\n /** Whether this tool is published to the end-user catalog (derived from lifecycleStage === 'published') */\n published: boolean;\n /** Whether this tool appears in end-user listings (only applies when published) */\n visible: boolean;\n /** Lifecycle stage: draft → pending → published → archived */\n lifecycleStage?: AgentLifecycleStage;\n /** Promotion version — incremented each time the tool is promoted forward */\n version?: number;\n /** ISO timestamp of last promotion */\n promotedAt?: string;\n /** User ref of who last promoted this tool */\n promotedBy?: string;\n /** User ref of who created this tool */\n createdBy?: string;\n /** ISO timestamp of creation */\n createdAt?: string;\n}\n\n/**\n * A group of related prompts displayed on the welcome screen\n * @public\n */\nexport interface PromptGroup {\n /** Unique identifier */\n id: string;\n /** Display title */\n title: string;\n /** Description of this prompt group */\n description?: string;\n /** Icon name */\n icon?: string;\n /** Theme color (hex) */\n color?: string;\n /** Display order (lower numbers appear first, defaults to array order if not specified) */\n order?: number;\n /** Cards within this prompt group */\n cards: PromptCard[];\n}\n\n// =============================================================================\n// Unified Agent Catalog Types\n// =============================================================================\n\n/**\n * Lifecycle stage of an agent in the promotion pipeline.\n *\n * draft → review → staging → production → retired\n *\n * - **draft**: Under development. Visible only to creator/admin.\n * - **review**: Submitted for admin review. Appears in the Review Queue.\n * - **staging**: Approved, available for internal testing. Not visible to end users.\n * - **published**: Live in the end-user marketplace/catalog.\n * - **archived**: Removed from production, preserved for audit/history.\n * @public\n */\nexport type AgentLifecycleStage =\n | 'draft'\n | 'pending'\n | 'published'\n | 'archived';\n\n/** Human-readable action name for a lifecycle transition. @public */\nexport type AgentLifecycleAction =\n | 'submit'\n | 'approve'\n | 'reject'\n | 'publish'\n | 'unpublish'\n | 'archive'\n | 'reactivate'\n | 'withdraw'\n | 'request-unpublish'\n | 'approve-unpublish'\n | 'reject-unpublish';\n\n/** A single allowed lifecycle transition. @public */\nexport interface AgentLifecycleTransition {\n from: AgentLifecycleStage;\n to: AgentLifecycleStage;\n action: AgentLifecycleAction;\n label: string;\n}\n\n/** Ordered list of lifecycle stages for pipeline display. @public */\nexport const LIFECYCLE_STAGE_ORDER: readonly AgentLifecycleStage[] = [\n 'draft',\n 'pending',\n 'published',\n 'archived',\n] as const;\n\n/** All valid lifecycle transitions with human-readable labels. @public */\nexport const LIFECYCLE_TRANSITIONS: readonly AgentLifecycleTransition[] = [\n {\n from: 'draft',\n to: 'pending',\n action: 'submit',\n label: 'Submit for Review',\n },\n {\n from: 'pending',\n to: 'published',\n action: 'approve',\n label: 'Approve and Publish',\n },\n { from: 'pending', to: 'draft', action: 'reject', label: 'Reject' },\n { from: 'pending', to: 'draft', action: 'withdraw', label: 'Withdraw' },\n {\n from: 'published',\n to: 'pending',\n action: 'request-unpublish',\n label: 'Request Unpublish',\n },\n { from: 'published', to: 'archived', action: 'archive', label: 'Archive' },\n { from: 'archived', to: 'draft', action: 'reactivate', label: 'Reactivate' },\n] as const;\n\n/**\n * Maps old stage names to new ones for backward compatibility.\n * @public\n */\nexport const LEGACY_STAGE_MAP: Record<string, AgentLifecycleStage> = {\n registered: 'pending',\n deployed: 'published',\n review: 'pending',\n staging: 'pending',\n production: 'published',\n retired: 'archived',\n};\n\n/** Returns the valid forward transitions from a given stage. @public */\nexport function getAvailableTransitions(\n stage: AgentLifecycleStage,\n): AgentLifecycleTransition[] {\n return LIFECYCLE_TRANSITIONS.filter(t => t.from === stage);\n}\n\n/** Checks whether a transition from one stage to another is valid. @public */\nexport function isValidTransition(\n from: AgentLifecycleStage,\n to: AgentLifecycleStage,\n): boolean {\n return LIFECYCLE_TRANSITIONS.some(t => t.from === from && t.to === to);\n}\n\n/** Normalizes a legacy stage name to the current stage name. @public */\nexport function normalizeLifecycleStage(\n stage: string | undefined,\n): AgentLifecycleStage {\n if (!stage) return 'draft';\n const trimmed = stage.trim().toLocaleLowerCase('en-US');\n if (!trimmed) return 'draft';\n if (Object.hasOwn(LEGACY_STAGE_MAP, trimmed))\n return LEGACY_STAGE_MAP[trimmed];\n if ((LIFECYCLE_STAGE_ORDER as readonly string[]).includes(trimmed)) {\n return trimmed as AgentLifecycleStage;\n }\n return 'draft';\n}\n\n/**\n * Provider-agnostic representation of a chat agent.\n * Used by the agent catalog/gallery to display agents from any provider\n * (Kagenti, Llama Stack config-driven, or custom).\n * @public\n */\nexport interface ChatAgent {\n /** Unique agent identifier (e.g. \"namespace/name\" for Kagenti, agent key for Llama Stack) */\n id: string;\n /** Display name */\n name: string;\n /** Human-readable description */\n description?: string;\n /** Runtime status (e.g. \"Ready\", \"Pending\", \"config\") */\n status: string;\n /** Whether this is the default/entry agent */\n isDefault?: boolean;\n /** Provider that owns this agent */\n providerType: string;\n /** Conversation starters / example prompts */\n starters?: string[];\n /** Avatar image URL */\n avatarUrl?: string;\n /** Agent creation timestamp */\n createdAt?: string;\n /** Agent framework label (e.g. \"a2a\", \"llamastack\") */\n framework?: string;\n /** Protocol labels (e.g. \"A2A\", \"MCP\") */\n protocols?: string[];\n /** Whether this agent is published to the end-user catalog (derived: lifecycleStage === 'published') */\n published?: boolean;\n /** Origin of this agent: 'kagenti' | 'orchestration' | 'external' */\n source?: string;\n /** Namespace the agent belongs to (for Kagenti agents) */\n namespace?: string;\n /** Current lifecycle stage in the promotion pipeline */\n lifecycleStage?: AgentLifecycleStage;\n /** Pending action when in 'pending' stage (e.g. publish or unpublish) */\n pendingAction?: 'publish' | 'unpublish';\n /** Promotion version (increments each time the agent is promoted) */\n version?: number;\n /** When this agent was last promoted */\n promotedAt?: string;\n /** Who promoted this agent */\n promotedBy?: string;\n /** User ref of who originally created/registered this agent in the lifecycle */\n createdBy?: string;\n /** Reason the agent was rejected (set on review → draft demotion, cleared on re-promote) */\n rejectionReason?: string;\n /** User ref of who rejected the agent */\n rejectedBy?: string;\n /** ISO timestamp of when the agent was rejected */\n rejectedAt?: string;\n /** Role of this agent in the orchestration topology */\n agentRole?: AgentRole;\n /**\n * True when a chatAgents lifecycle entry exists for this agent.\n * False for runtime-only agents (Kagenti/orchestration) not yet in governance.\n */\n governanceRegistered?: boolean;\n /** Direct chat endpoint URL for skill agents (e.g. http://agent.ns.svc:8000) */\n chatEndpoint?: string;\n}\n\n/**\n * Possible roles an agent can have in the orchestration topology.\n * Always auto-derived from connections, never manually set.\n * @public\n */\nexport type AgentRole = 'router' | 'specialist' | 'standalone';\n\n/**\n * Minimal agent shape required for topology-based role derivation.\n * Both frontend form data and backend config objects satisfy this.\n * @public\n */\nexport interface AgentTopologyNode {\n handoffs?: string[];\n asTools?: string[];\n}\n\n/**\n * Derives an agent's role from the multi-agent topology.\n * This is the single source of truth for role derivation across\n * both frontend and backend.\n *\n * Rules:\n * - Has outgoing handoffs or asTools -> 'router'\n * - Is a target of another agent's handoffs or asTools -> 'specialist'\n * - Neither -> 'standalone'\n *\n * @public\n */\nexport function deriveRoleFromTopology(\n agentKey: string,\n allAgents: Record<string, AgentTopologyNode | null | undefined>,\n): AgentRole {\n const agent = allAgents[agentKey];\n if (!agent) return 'standalone';\n\n const hasOutgoing =\n (agent.handoffs && agent.handoffs.length > 0) ||\n (agent.asTools && agent.asTools.length > 0);\n\n if (hasOutgoing) return 'router';\n\n const isTarget = Object.entries(allAgents).some(\n ([k, a]) =>\n k !== agentKey &&\n a !== null &&\n a !== undefined &&\n ((a.handoffs ?? []).includes(agentKey) ||\n (a.asTools ?? []).includes(agentKey)),\n );\n\n if (isTarget) return 'specialist';\n return 'standalone';\n}\n\n// =============================================================================\n// Conversation History Types\n// =============================================================================\n\n/**\n * Conversation summary for UI display.\n * Derived from stored responses.\n * @public\n */\nexport interface ConversationSummary {\n /** Response ID — use to continue this conversation */\n responseId: string;\n /** Preview of the conversation (first user message or assistant response) */\n preview: string;\n /** When the conversation was created */\n createdAt: Date;\n /** Model used */\n model: string;\n /** Status */\n status: 'completed' | 'failed' | 'in_progress';\n /** Llama Stack conversation ID (present for new-style conversations) */\n conversationId?: string;\n /** Previous response ID for chain deduplication */\n previousResponseId?: string;\n}\n\n/**\n * Base response from the chat endpoint, shared between frontend and backend.\n * Frontend extends this with additional fields (filtered, evaluation, etc.).\n * @public\n */\nexport interface ChatResponse {\n role: 'assistant';\n content: string;\n ragContext?: string[];\n /** @deprecated Use ragSources instead */\n filesSearched?: string[];\n ragSources?: RAGSource[];\n toolCalls?: ToolCallInfo[];\n responseId?: string;\n usage?: ResponseUsage;\n /** Name of the agent that produced the final response (multi-agent only) */\n agentName?: string;\n /** Ordered list of agent keys visited during handoffs, e.g. [\"triage\", \"billing\"] */\n handoffPath?: string[];\n /** Present when a backend-executed tool requires HITL approval before execution */\n pendingApproval?: PendingApprovalInfo;\n /** All pending approvals when multiple backend tools need HITL approval */\n pendingApprovals?: PendingApprovalInfo[];\n /** Structured output validation error (G5). Present when the agent's outputSchema validation failed. */\n outputValidationError?: string;\n /** Reasoning/thinking summaries from the model's chain-of-thought. */\n reasoning?: ReasoningSummary[];\n}\n\n/**\n * Summary of model reasoning from chain-of-thought output.\n * @public\n */\nexport interface ReasoningSummary {\n id: string;\n text: string;\n}\n\n/**\n * Information about a single pending HITL approval.\n * @public\n */\nexport interface PendingApprovalInfo {\n approvalRequestId: string;\n toolName: string;\n serverLabel?: string;\n arguments?: string;\n}\n\n/**\n * Result of a document sync operation.\n * @public\n */\nexport interface SyncResult {\n added: number;\n removed: number;\n updated: number;\n failed: number;\n unchanged: number;\n errors: string[];\n}\n\n/**\n * Detailed tool information for the capabilities-aware prompt generator.\n * Used by the frontend capabilities selector to send tool descriptions\n * to the backend so the meta-prompt can reference what each tool does.\n * @public\n */\nexport interface ToolCapabilityInfo {\n name: string;\n description?: string;\n serverLabel?: string;\n}\n\n/**\n * User-selected capabilities to emphasize when generating agent instructions.\n * Sent to the backend so the meta-prompt includes specific tool descriptions\n * and contextual detail about the agent's environment.\n * @public\n */\nexport interface PromptCapabilities {\n tools?: ToolCapabilityInfo[];\n enableWebSearch?: boolean;\n enableCodeInterpreter?: boolean;\n ragEnabled?: boolean;\n vectorStoreNames?: string[];\n safetyEnabled?: boolean;\n safetyShields?: string[];\n}\n"],"names":["FileFormat"],"mappings":";;AA0IO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AALG,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AA4XL,MAAM,qBAAA,GAAwD;AAAA,EACnE,OAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAGO,MAAM,qBAAA,GAA6D;AAAA,EACxE;AAAA,IACE,IAAA,EAAM,O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|
|
|
1
|
+
var FileFormat = /* @__PURE__ */ ((FileFormat2) => {
|
|
2
|
+
FileFormat2["YAML"] = "yaml";
|
|
3
|
+
FileFormat2["PDF"] = "pdf";
|
|
4
|
+
FileFormat2["TEXT"] = "text";
|
|
5
|
+
FileFormat2["MARKDOWN"] = "markdown";
|
|
6
|
+
FileFormat2["JSON"] = "json";
|
|
7
|
+
return FileFormat2;
|
|
8
|
+
})(FileFormat || {});
|
|
9
|
+
const LIFECYCLE_STAGE_ORDER = [
|
|
10
|
+
"draft",
|
|
11
|
+
"pending",
|
|
12
|
+
"published",
|
|
13
|
+
"archived"
|
|
14
|
+
];
|
|
15
|
+
const LIFECYCLE_TRANSITIONS = [
|
|
16
|
+
{
|
|
17
|
+
from: "draft",
|
|
18
|
+
to: "pending",
|
|
19
|
+
action: "submit",
|
|
20
|
+
label: "Submit for Review"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
from: "pending",
|
|
24
|
+
to: "published",
|
|
25
|
+
action: "approve",
|
|
26
|
+
label: "Approve and Publish"
|
|
27
|
+
},
|
|
28
|
+
{ from: "pending", to: "draft", action: "reject", label: "Reject" },
|
|
29
|
+
{ from: "pending", to: "draft", action: "withdraw", label: "Withdraw" },
|
|
30
|
+
{
|
|
31
|
+
from: "published",
|
|
32
|
+
to: "pending",
|
|
33
|
+
action: "request-unpublish",
|
|
34
|
+
label: "Request Unpublish"
|
|
35
|
+
},
|
|
36
|
+
{ from: "published", to: "archived", action: "archive", label: "Archive" },
|
|
37
|
+
{ from: "archived", to: "draft", action: "reactivate", label: "Reactivate" }
|
|
38
|
+
];
|
|
39
|
+
const LEGACY_STAGE_MAP = {
|
|
40
|
+
registered: "pending",
|
|
41
|
+
deployed: "published",
|
|
42
|
+
review: "pending",
|
|
43
|
+
staging: "pending",
|
|
44
|
+
production: "published",
|
|
45
|
+
retired: "archived"
|
|
46
|
+
};
|
|
47
|
+
function getAvailableTransitions(stage) {
|
|
48
|
+
return LIFECYCLE_TRANSITIONS.filter((t) => t.from === stage);
|
|
49
|
+
}
|
|
50
|
+
function isValidTransition(from, to) {
|
|
51
|
+
return LIFECYCLE_TRANSITIONS.some((t) => t.from === from && t.to === to);
|
|
52
|
+
}
|
|
53
|
+
function normalizeLifecycleStage(stage) {
|
|
54
|
+
if (!stage) return "draft";
|
|
55
|
+
const trimmed = stage.trim().toLocaleLowerCase("en-US");
|
|
56
|
+
if (!trimmed) return "draft";
|
|
57
|
+
if (Object.hasOwn(LEGACY_STAGE_MAP, trimmed))
|
|
58
|
+
return LEGACY_STAGE_MAP[trimmed];
|
|
59
|
+
if (LIFECYCLE_STAGE_ORDER.includes(trimmed)) {
|
|
60
|
+
return trimmed;
|
|
61
|
+
}
|
|
62
|
+
return "draft";
|
|
63
|
+
}
|
|
64
|
+
function deriveRoleFromTopology(agentKey, allAgents) {
|
|
65
|
+
const agent = allAgents[agentKey];
|
|
66
|
+
if (!agent) return "standalone";
|
|
67
|
+
const hasOutgoing = agent.handoffs && agent.handoffs.length > 0 || agent.asTools && agent.asTools.length > 0;
|
|
68
|
+
if (hasOutgoing) return "router";
|
|
69
|
+
const isTarget = Object.entries(allAgents).some(
|
|
70
|
+
([k, a]) => k !== agentKey && a !== null && a !== void 0 && ((a.handoffs ?? []).includes(agentKey) || (a.asTools ?? []).includes(agentKey))
|
|
71
|
+
);
|
|
72
|
+
if (isTarget) return "specialist";
|
|
73
|
+
return "standalone";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { FileFormat, LEGACY_STAGE_MAP, LIFECYCLE_STAGE_ORDER, LIFECYCLE_TRANSITIONS, deriveRoleFromTopology, getAvailableTransitions, isValidTransition, normalizeLifecycleStage };
|
|
77
|
+
//# sourceMappingURL=shared.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.esm.js","sources":["../../src/types/shared.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Token usage reported by the inference server for a single response turn.\n *\n * Mirrors the OpenAI Responses API `ResponseUsage` object.\n * Llama Stack implements the same schema, so this type is\n * the single source of truth for both frontend and backend.\n *\n * @see https://platform.openai.com/docs/api-reference/responses/object\n * @public\n */\nexport interface ResponseUsage {\n /** Total input tokens (cumulative across all internal agentic calls) */\n input_tokens: number;\n /** Total output tokens (cumulative across all internal agentic calls) */\n output_tokens: number;\n /** Sum of input_tokens + output_tokens (may include internal overhead) */\n total_tokens: number;\n /**\n * Breakdown of input tokens.\n * Present when the server supports prompt caching.\n */\n input_tokens_details?: InputTokensDetails;\n /**\n * Breakdown of output tokens.\n * Llama Stack may return `null` when the model does not emit reasoning tokens.\n */\n output_tokens_details?: OutputTokensDetails | null;\n}\n\n/**\n * Detailed breakdown of input tokens.\n * @public\n */\nexport interface InputTokensDetails {\n /** Tokens retrieved from the KV-cache (no additional compute cost) */\n cached_tokens?: number;\n}\n\n/**\n * Detailed breakdown of output tokens.\n * @public\n */\nexport interface OutputTokensDetails {\n /** Internal chain-of-thought tokens used by reasoning models (e.g. o3, o4-mini) */\n reasoning_tokens?: number;\n}\n\n// =============================================================================\n// Shared Types (used by both frontend and backend)\n// =============================================================================\n\n/**\n * Chat message in a conversation\n * @public\n */\nexport interface ChatMessage {\n role: 'system' | 'user' | 'assistant';\n content: string;\n}\n\n/**\n * Tool call information\n * @public\n */\nexport interface ToolCallInfo {\n id: string;\n name: string;\n serverLabel: string;\n arguments: string;\n output?: string;\n error?: string;\n}\n\n/**\n * RAG source information from file_search_call.results\n * This comes directly from Llama Stack Responses API when include: ['file_search_call.results']\n * @public\n */\nexport interface RAGSource {\n /** Filename or document identifier */\n filename: string;\n /** Relevant text snippet from the document */\n text?: string;\n /** Relevance score (0-1) if provided by the API */\n score?: number;\n /** File ID for reference */\n fileId?: string;\n /** Document title from attributes (for display in citations) */\n title?: string;\n /** Source URL from attributes (for clickable citations) */\n sourceUrl?: string;\n /** Content type from attributes */\n contentType?: string;\n /** Raw attributes object from Llama Stack */\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Aggregated evaluation result for a response\n * @public\n */\nexport interface EvaluationResult {\n /** Overall quality score (0-1) */\n overallScore: number;\n /** Individual scores by function */\n scores: Record<string, number>;\n /** Whether the response passed quality threshold */\n passedThreshold: boolean;\n /** Human-readable quality assessment */\n qualityLevel: 'excellent' | 'good' | 'fair' | 'poor';\n /** Timestamp of evaluation */\n evaluatedAt: string;\n /** Error message if evaluation failed */\n error?: string;\n /** True when evaluation was skipped (e.g. not available) rather than run */\n skipped?: boolean;\n}\n\n/**\n * File format enum\n * @public\n */\nexport enum FileFormat {\n YAML = 'yaml',\n PDF = 'pdf',\n TEXT = 'text',\n MARKDOWN = 'markdown',\n JSON = 'json',\n}\n\n/**\n * Information about an uploaded document\n * @public\n */\nexport interface DocumentInfo {\n id: string;\n fileName: string;\n format: FileFormat;\n fileSize: number;\n uploadedAt: string;\n status: 'completed' | 'in_progress' | 'failed' | 'cancelled';\n}\n\n/**\n * Provider status information\n * @public\n */\nexport interface ProviderStatus {\n id: string;\n model: string;\n baseUrl: string;\n connected: boolean;\n error?: string;\n}\n\n/**\n * Vector store status information\n * @public\n */\nexport interface VectorStoreStatus {\n id: string;\n connected: boolean;\n totalDocuments?: number;\n error?: string;\n}\n\n/**\n * MCP server status information\n * @public\n */\nexport interface MCPToolInfo {\n name: string;\n description?: string;\n}\n\n/**\n * @public\n */\nexport interface MCPServerStatus {\n id: string;\n name: string;\n url: string;\n connected: boolean;\n error?: string;\n /** Tools available on this MCP server (populated when connected) */\n tools?: MCPToolInfo[];\n /** Total number of tools (convenience field) */\n toolCount?: number;\n /** Whether this server was defined in YAML (true) or added via admin UI (false) */\n source?: 'yaml' | 'admin';\n}\n\n/**\n * Security mode for Augment\n * @public\n */\nexport type SecurityMode = 'none' | 'plugin-only' | 'full';\n\n/**\n * Combined status for Augment\n * @public\n */\nexport interface AugmentStatus {\n /** Active provider identifier (e.g., 'llamastack', 'googleadk') */\n providerId: string;\n provider: ProviderStatus;\n vectorStore: VectorStoreStatus;\n mcpServers: MCPServerStatus[];\n /** Current security mode: 'none' | 'plugin-only' | 'full' */\n securityMode: SecurityMode;\n timestamp: string;\n /** Whether the plugin is ready to handle requests (AI provider connected) */\n ready: boolean;\n /** Blocking configuration errors that prevent the plugin from working */\n configurationErrors: string[];\n /** Whether the current user has admin privileges */\n isAdmin?: boolean;\n /** Optional capability status — these are not required for basic chat */\n capabilities?: {\n chat: boolean;\n rag: { available: boolean; reason?: string };\n mcpTools: { available: boolean; reason?: string };\n /** Whether this provider supports listing agents for the catalog */\n agentCatalog?: boolean;\n /** Whether the user must select an agent before chatting */\n agentSelection?: boolean;\n /** Whether agents have rich metadata (cards, skills) */\n agentCards?: boolean;\n };\n /** Summary of configured agents (multi-agent only) */\n agents?: Array<{ key: string; name: string; isDefault: boolean }>;\n /** Tool execution mode: 'direct' or 'backend' */\n toolExecutionMode?: 'direct' | 'backend';\n /** Error from last agent graph resolution attempt, if any */\n agentGraphError?: string;\n}\n\n/**\n * Information about an available vector store\n * @public\n */\nexport interface VectorStoreInfo {\n id: string;\n name: string;\n status: string;\n fileCount: number;\n createdAt: number;\n embeddingModel?: string;\n embeddingDimension?: number;\n providerType?: string;\n usageBytes?: number;\n lastActiveAt?: number;\n fileCounts?: {\n completed: number;\n inProgress: number;\n failed: number;\n cancelled: number;\n total: number;\n };\n}\n\n/**\n * Quick prompt configuration\n * @public\n */\nexport interface QuickPrompt {\n title: string;\n description: string;\n prompt: string;\n category: string;\n}\n\n// =============================================================================\n// Workflow Types (Configurable multi-step templates)\n// =============================================================================\n\n/**\n * A single step within a workflow\n * @public\n */\nexport interface WorkflowStep {\n /** Step title shown in UI */\n title: string;\n /** Prompt to send to chat when this step is executed */\n prompt: string;\n /** Optional description for the step */\n description?: string;\n}\n\n/**\n * A workflow template - multi-step guided experience\n * @public\n */\nexport interface Workflow {\n /** Unique identifier */\n id: string;\n /** Display name */\n name: string;\n /** Short description */\n description: string;\n /** Icon name (material icons) */\n icon?: string;\n /** Category for grouping */\n category?: string;\n /** Ordered list of steps */\n steps: WorkflowStep[];\n /** Whether this workflow is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * Quick action - single click prompt\n * @public\n */\nexport interface QuickAction {\n /** Display title */\n title: string;\n /** Short description */\n description?: string;\n /** Prompt to send to chat */\n prompt: string;\n /** Icon name */\n icon?: string;\n /** Category for grouping */\n category?: string;\n /** Whether this action is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * A clickable prompt card within a prompt group on the welcome screen\n * @public\n */\nexport interface PromptCard {\n /** Display title */\n title: string;\n /** Short description */\n description?: string;\n /** Prompt to send to chat */\n prompt: string;\n /** Icon name */\n icon?: string;\n /** Agent to auto-select when this card is clicked (e.g. \"namespace/agentName\") */\n agentId?: string;\n /** Whether this feature is coming soon (disabled, non-clickable) */\n comingSoon?: boolean;\n /** Custom coming soon label (defaults to \"Coming Soon\") */\n comingSoonLabel?: string;\n}\n\n/**\n * Per-agent chat experience configuration set by admins.\n * Controls which agents are visible to end users and how they appear.\n * @public\n */\nexport interface ChatAgentConfig {\n /** Agent identifier: \"namespace/name\" */\n agentId: string;\n /** Whether this agent is published to the end-user catalog (derived from lifecycleStage === 'published') */\n published: boolean;\n /** Whether this agent appears in end-user chat (only applies when published) */\n visible: boolean;\n /** Whether this agent is featured prominently on the welcome screen */\n featured: boolean;\n /** Lifecycle stage: draft → pending → published → archived */\n lifecycleStage?: AgentLifecycleStage;\n /** Pending action when in 'pending' stage (e.g. publish or unpublish) */\n pendingAction?: 'publish' | 'unpublish';\n /** Promotion version — incremented each time the agent is promoted forward */\n version?: number;\n /** ISO timestamp of last promotion */\n promotedAt?: string;\n /** User ref of who last promoted this agent */\n promotedBy?: string;\n /** User ref of who originally created/registered this agent in the lifecycle */\n createdBy?: string;\n /** ISO timestamp of when the agent was first registered in the lifecycle */\n createdAt?: string;\n /** Reason the agent was rejected (set on review → draft demotion, cleared on re-promote) */\n rejectionReason?: string;\n /** User ref of who rejected the agent */\n rejectedBy?: string;\n /** ISO timestamp of when the agent was rejected */\n rejectedAt?: string;\n /** SonataFlow process instance id while awaiting admin approval */\n approvalWorkflowInstanceId?: string;\n /** Display order (lower first) */\n order?: number;\n /** Override display name */\n displayName?: string;\n /** Override description */\n description?: string;\n /** Custom avatar image URL */\n avatarUrl?: string;\n /** Per-agent accent color (hex) */\n accentColor?: string;\n /** Greeting message shown as first bot message on new conversation */\n greeting?: string;\n /** Suggested prompts shown on the agent card and below the input */\n conversationStarters?: string[];\n /** Direct chat endpoint URL for skill agents (e.g. http://agent.ns.svc:8000) */\n chatEndpoint?: string;\n /** K8s namespace where the skill agent is deployed */\n namespace?: string;\n}\n\n/**\n * Per-tool lifecycle configuration set by admins.\n * Controls which tools are published to end users, mirroring the agent lifecycle.\n * @public\n */\nexport interface ChatToolConfig {\n /** Tool identifier: \"namespace/name\" */\n toolId: string;\n /** Whether this tool is published to the end-user catalog (derived from lifecycleStage === 'published') */\n published: boolean;\n /** Whether this tool appears in end-user listings (only applies when published) */\n visible: boolean;\n /** Lifecycle stage: draft → pending → published → archived */\n lifecycleStage?: AgentLifecycleStage;\n /** Promotion version — incremented each time the tool is promoted forward */\n version?: number;\n /** ISO timestamp of last promotion */\n promotedAt?: string;\n /** User ref of who last promoted this tool */\n promotedBy?: string;\n /** User ref of who created this tool */\n createdBy?: string;\n /** ISO timestamp of creation */\n createdAt?: string;\n}\n\n/**\n * A group of related prompts displayed on the welcome screen\n * @public\n */\nexport interface PromptGroup {\n /** Unique identifier */\n id: string;\n /** Display title */\n title: string;\n /** Description of this prompt group */\n description?: string;\n /** Icon name */\n icon?: string;\n /** Theme color (hex) */\n color?: string;\n /** Display order (lower numbers appear first, defaults to array order if not specified) */\n order?: number;\n /** Cards within this prompt group */\n cards: PromptCard[];\n}\n\n// =============================================================================\n// Unified Agent Catalog Types\n// =============================================================================\n\n/**\n * Lifecycle stage of an agent in the promotion pipeline.\n *\n * draft → review → staging → production → retired\n *\n * - **draft**: Under development. Visible only to creator/admin.\n * - **review**: Submitted for admin review. Appears in the Review Queue.\n * - **staging**: Approved, available for internal testing. Not visible to end users.\n * - **published**: Live in the end-user marketplace/catalog.\n * - **archived**: Removed from production, preserved for audit/history.\n * @public\n */\nexport type AgentLifecycleStage =\n | 'draft'\n | 'pending'\n | 'published'\n | 'archived';\n\n/** Human-readable action name for a lifecycle transition. @public */\nexport type AgentLifecycleAction =\n | 'submit'\n | 'approve'\n | 'reject'\n | 'publish'\n | 'unpublish'\n | 'archive'\n | 'reactivate'\n | 'withdraw'\n | 'request-unpublish'\n | 'approve-unpublish'\n | 'reject-unpublish';\n\n/** A single allowed lifecycle transition. @public */\nexport interface AgentLifecycleTransition {\n from: AgentLifecycleStage;\n to: AgentLifecycleStage;\n action: AgentLifecycleAction;\n label: string;\n}\n\n/** Ordered list of lifecycle stages for pipeline display. @public */\nexport const LIFECYCLE_STAGE_ORDER: readonly AgentLifecycleStage[] = [\n 'draft',\n 'pending',\n 'published',\n 'archived',\n] as const;\n\n/** All valid lifecycle transitions with human-readable labels. @public */\nexport const LIFECYCLE_TRANSITIONS: readonly AgentLifecycleTransition[] = [\n {\n from: 'draft',\n to: 'pending',\n action: 'submit',\n label: 'Submit for Review',\n },\n {\n from: 'pending',\n to: 'published',\n action: 'approve',\n label: 'Approve and Publish',\n },\n { from: 'pending', to: 'draft', action: 'reject', label: 'Reject' },\n { from: 'pending', to: 'draft', action: 'withdraw', label: 'Withdraw' },\n {\n from: 'published',\n to: 'pending',\n action: 'request-unpublish',\n label: 'Request Unpublish',\n },\n { from: 'published', to: 'archived', action: 'archive', label: 'Archive' },\n { from: 'archived', to: 'draft', action: 'reactivate', label: 'Reactivate' },\n] as const;\n\n/**\n * Maps old stage names to new ones for backward compatibility.\n * @public\n */\nexport const LEGACY_STAGE_MAP: Record<string, AgentLifecycleStage> = {\n registered: 'pending',\n deployed: 'published',\n review: 'pending',\n staging: 'pending',\n production: 'published',\n retired: 'archived',\n};\n\n/** Returns the valid forward transitions from a given stage. @public */\nexport function getAvailableTransitions(\n stage: AgentLifecycleStage,\n): AgentLifecycleTransition[] {\n return LIFECYCLE_TRANSITIONS.filter(t => t.from === stage);\n}\n\n/** Checks whether a transition from one stage to another is valid. @public */\nexport function isValidTransition(\n from: AgentLifecycleStage,\n to: AgentLifecycleStage,\n): boolean {\n return LIFECYCLE_TRANSITIONS.some(t => t.from === from && t.to === to);\n}\n\n/** Normalizes a legacy stage name to the current stage name. @public */\nexport function normalizeLifecycleStage(\n stage: string | undefined,\n): AgentLifecycleStage {\n if (!stage) return 'draft';\n const trimmed = stage.trim().toLocaleLowerCase('en-US');\n if (!trimmed) return 'draft';\n if (Object.hasOwn(LEGACY_STAGE_MAP, trimmed))\n return LEGACY_STAGE_MAP[trimmed];\n if ((LIFECYCLE_STAGE_ORDER as readonly string[]).includes(trimmed)) {\n return trimmed as AgentLifecycleStage;\n }\n return 'draft';\n}\n\n/**\n * Provider-agnostic representation of a chat agent.\n * Used by the agent catalog/gallery to display agents from any provider\n * (Kagenti, Llama Stack config-driven, or custom).\n * @public\n */\nexport interface ChatAgent {\n /** Unique agent identifier (e.g. \"namespace/name\" for Kagenti, agent key for Llama Stack) */\n id: string;\n /** Display name */\n name: string;\n /** Human-readable description */\n description?: string;\n /** Runtime status (e.g. \"Ready\", \"Pending\", \"config\") */\n status: string;\n /** Whether this is the default/entry agent */\n isDefault?: boolean;\n /** Provider that owns this agent */\n providerType: string;\n /** Conversation starters / example prompts */\n starters?: string[];\n /** Avatar image URL */\n avatarUrl?: string;\n /** Agent creation timestamp */\n createdAt?: string;\n /** Agent framework label (e.g. \"a2a\", \"llamastack\") */\n framework?: string;\n /** Protocol labels (e.g. \"A2A\", \"MCP\") */\n protocols?: string[];\n /** Whether this agent is published to the end-user catalog (derived: lifecycleStage === 'published') */\n published?: boolean;\n /** Origin of this agent: 'kagenti' | 'orchestration' | 'external' */\n source?: string;\n /** Namespace the agent belongs to (for Kagenti agents) */\n namespace?: string;\n /** Current lifecycle stage in the promotion pipeline */\n lifecycleStage?: AgentLifecycleStage;\n /** Pending action when in 'pending' stage (e.g. publish or unpublish) */\n pendingAction?: 'publish' | 'unpublish';\n /** Promotion version (increments each time the agent is promoted) */\n version?: number;\n /** When this agent was last promoted */\n promotedAt?: string;\n /** Who promoted this agent */\n promotedBy?: string;\n /** User ref of who originally created/registered this agent in the lifecycle */\n createdBy?: string;\n /** Reason the agent was rejected (set on review → draft demotion, cleared on re-promote) */\n rejectionReason?: string;\n /** User ref of who rejected the agent */\n rejectedBy?: string;\n /** ISO timestamp of when the agent was rejected */\n rejectedAt?: string;\n /** Role of this agent in the orchestration topology */\n agentRole?: AgentRole;\n /**\n * True when a chatAgents lifecycle entry exists for this agent.\n * False for runtime-only agents (Kagenti/orchestration) not yet in governance.\n */\n governanceRegistered?: boolean;\n /** Direct chat endpoint URL for skill agents (e.g. http://agent.ns.svc:8000) */\n chatEndpoint?: string;\n}\n\n/**\n * Possible roles an agent can have in the orchestration topology.\n * Always auto-derived from connections, never manually set.\n * @public\n */\nexport type AgentRole = 'router' | 'specialist' | 'standalone';\n\n/**\n * Minimal agent shape required for topology-based role derivation.\n * Both frontend form data and backend config objects satisfy this.\n * @public\n */\nexport interface AgentTopologyNode {\n handoffs?: string[];\n asTools?: string[];\n}\n\n/**\n * Derives an agent's role from the multi-agent topology.\n * This is the single source of truth for role derivation across\n * both frontend and backend.\n *\n * Rules:\n * - Has outgoing handoffs or asTools -> 'router'\n * - Is a target of another agent's handoffs or asTools -> 'specialist'\n * - Neither -> 'standalone'\n *\n * @public\n */\nexport function deriveRoleFromTopology(\n agentKey: string,\n allAgents: Record<string, AgentTopologyNode | null | undefined>,\n): AgentRole {\n const agent = allAgents[agentKey];\n if (!agent) return 'standalone';\n\n const hasOutgoing =\n (agent.handoffs && agent.handoffs.length > 0) ||\n (agent.asTools && agent.asTools.length > 0);\n\n if (hasOutgoing) return 'router';\n\n const isTarget = Object.entries(allAgents).some(\n ([k, a]) =>\n k !== agentKey &&\n a !== null &&\n a !== undefined &&\n ((a.handoffs ?? []).includes(agentKey) ||\n (a.asTools ?? []).includes(agentKey)),\n );\n\n if (isTarget) return 'specialist';\n return 'standalone';\n}\n\n// =============================================================================\n// Conversation History Types\n// =============================================================================\n\n/**\n * Conversation summary for UI display.\n * Derived from stored responses.\n * @public\n */\nexport interface ConversationSummary {\n /** Response ID — use to continue this conversation */\n responseId: string;\n /** Preview of the conversation (first user message or assistant response) */\n preview: string;\n /** When the conversation was created */\n createdAt: Date;\n /** Model used */\n model: string;\n /** Status */\n status: 'completed' | 'failed' | 'in_progress';\n /** Llama Stack conversation ID (present for new-style conversations) */\n conversationId?: string;\n /** Previous response ID for chain deduplication */\n previousResponseId?: string;\n}\n\n/**\n * Base response from the chat endpoint, shared between frontend and backend.\n * Frontend extends this with additional fields (filtered, evaluation, etc.).\n * @public\n */\nexport interface ChatResponse {\n role: 'assistant';\n content: string;\n ragContext?: string[];\n /** @deprecated Use ragSources instead */\n filesSearched?: string[];\n ragSources?: RAGSource[];\n toolCalls?: ToolCallInfo[];\n responseId?: string;\n usage?: ResponseUsage;\n /** Name of the agent that produced the final response (multi-agent only) */\n agentName?: string;\n /** Ordered list of agent keys visited during handoffs, e.g. [\"triage\", \"billing\"] */\n handoffPath?: string[];\n /** Present when a backend-executed tool requires HITL approval before execution */\n pendingApproval?: PendingApprovalInfo;\n /** All pending approvals when multiple backend tools need HITL approval */\n pendingApprovals?: PendingApprovalInfo[];\n /** Structured output validation error (G5). Present when the agent's outputSchema validation failed. */\n outputValidationError?: string;\n /** Reasoning/thinking summaries from the model's chain-of-thought. */\n reasoning?: ReasoningSummary[];\n}\n\n/**\n * Summary of model reasoning from chain-of-thought output.\n * @public\n */\nexport interface ReasoningSummary {\n id: string;\n text: string;\n}\n\n/**\n * Information about a single pending HITL approval.\n * @public\n */\nexport interface PendingApprovalInfo {\n approvalRequestId: string;\n toolName: string;\n serverLabel?: string;\n arguments?: string;\n}\n\n/**\n * Result of a document sync operation.\n * @public\n */\nexport interface SyncResult {\n added: number;\n removed: number;\n updated: number;\n failed: number;\n unchanged: number;\n errors: string[];\n}\n\n/**\n * Detailed tool information for the capabilities-aware prompt generator.\n * Used by the frontend capabilities selector to send tool descriptions\n * to the backend so the meta-prompt can reference what each tool does.\n * @public\n */\nexport interface ToolCapabilityInfo {\n name: string;\n description?: string;\n serverLabel?: string;\n}\n\n/**\n * User-selected capabilities to emphasize when generating agent instructions.\n * Sent to the backend so the meta-prompt includes specific tool descriptions\n * and contextual detail about the agent's environment.\n * @public\n */\nexport interface PromptCapabilities {\n tools?: ToolCapabilityInfo[];\n enableWebSearch?: boolean;\n enableCodeInterpreter?: boolean;\n ragEnabled?: boolean;\n vectorStoreNames?: string[];\n safetyEnabled?: boolean;\n safetyShields?: string[];\n}\n"],"names":["FileFormat"],"mappings":"AA0IO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AALG,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AA4XL,MAAM,qBAAA,GAAwD;AAAA,EACnE,OAAA;AAAA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C;AAEA,EAAA,IAAI,UAAU,OAAO,YAAA;AACrB,EAAA,OAAO,YAAA;AACT;;;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createDefaultWorkflow(id, name, createdBy) {
|
|
4
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5
|
+
return {
|
|
6
|
+
id,
|
|
7
|
+
name,
|
|
8
|
+
description: "",
|
|
9
|
+
version: 0,
|
|
10
|
+
createdAt: now,
|
|
11
|
+
updatedAt: now,
|
|
12
|
+
createdBy,
|
|
13
|
+
updatedBy: createdBy,
|
|
14
|
+
status: "draft",
|
|
15
|
+
nodes: [
|
|
16
|
+
{
|
|
17
|
+
id: "start-1",
|
|
18
|
+
type: "start",
|
|
19
|
+
position: { x: 50, y: 150 },
|
|
20
|
+
data: { inputDescription: "User message" },
|
|
21
|
+
label: "Start"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "agent-1",
|
|
25
|
+
type: "agent",
|
|
26
|
+
position: { x: 300, y: 140 },
|
|
27
|
+
data: {
|
|
28
|
+
agentKey: "agent-1",
|
|
29
|
+
name: "Agent",
|
|
30
|
+
instructions: "",
|
|
31
|
+
handoffDescription: ""
|
|
32
|
+
},
|
|
33
|
+
label: "Agent"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
edges: [
|
|
37
|
+
{
|
|
38
|
+
id: "edge-start-agent-1",
|
|
39
|
+
source: "start-1",
|
|
40
|
+
target: "agent-1",
|
|
41
|
+
type: "sequence"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
settings: {
|
|
45
|
+
maxTurns: 10,
|
|
46
|
+
conversationPersistence: true,
|
|
47
|
+
tracingEnabled: true
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function isAgentNodeData(data) {
|
|
52
|
+
return "agentKey" in data && "instructions" in data;
|
|
53
|
+
}
|
|
54
|
+
function isToolNodeData(data) {
|
|
55
|
+
return "kind" in data && "label" in data && !("agentKey" in data);
|
|
56
|
+
}
|
|
57
|
+
function isGuardrailNodeData(data) {
|
|
58
|
+
return "guardType" in data && "onFailure" in data;
|
|
59
|
+
}
|
|
60
|
+
function isLogicNodeData(data) {
|
|
61
|
+
return "kind" in data && "condition" in data && !("label" in data);
|
|
62
|
+
}
|
|
63
|
+
function isUserInteractionNodeData(data) {
|
|
64
|
+
return "interactionType" in data && "prompt" in data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
exports.createDefaultWorkflow = createDefaultWorkflow;
|
|
68
|
+
exports.isAgentNodeData = isAgentNodeData;
|
|
69
|
+
exports.isGuardrailNodeData = isGuardrailNodeData;
|
|
70
|
+
exports.isLogicNodeData = isLogicNodeData;
|
|
71
|
+
exports.isToolNodeData = isToolNodeData;
|
|
72
|
+
exports.isUserInteractionNodeData = isUserInteractionNodeData;
|
|
73
|
+
//# sourceMappingURL=workflowBuilder.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowBuilder.cjs.js","sources":["../../src/types/workflowBuilder.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// =============================================================================\n// Workflow Builder Types\n//\n// These types define the serializable workflow definition format used by the\n// visual agent builder canvas. A WorkflowDefinition is a directed graph of\n// nodes (agents, tools, guardrails, logic, etc.) connected by typed edges.\n// At runtime the backend hydrates this definition into live @openai/agents-core\n// Agent / Runner instances for execution against LlamaStack APIs.\n// =============================================================================\n\n/**\n * Status of a workflow in its lifecycle.\n * @public\n */\nexport type WorkflowStatus = 'draft' | 'published' | 'archived';\n\n/**\n * Discriminated node types available in the workflow canvas.\n * @public\n */\nexport type WorkflowNodeType =\n | 'start'\n | 'agent'\n | 'tool'\n | 'guardrail'\n | 'logic'\n | 'user_interaction'\n | 'classify'\n | 'end'\n | 'note'\n | 'transform'\n | 'set_state'\n | 'file_search'\n | 'mcp';\n\n/**\n * Position on the canvas for visual layout.\n * @public\n */\nexport interface NodePosition {\n x: number;\n y: number;\n}\n\n// ---------------------------------------------------------------------------\n// Node Data Payloads\n// ---------------------------------------------------------------------------\n\n/**\n * Data for the Start node -- defines the workflow's input contract.\n * @public\n */\nexport interface StartNodeData {\n inputDescription?: string;\n inputSchema?: Record<string, unknown>;\n}\n\n/**\n * Data for an Agent node -- carries the full agent configuration.\n * @public\n */\nexport interface AgentNodeData {\n agentKey: string;\n name: string;\n instructions: string;\n handoffDescription?: string;\n model?: string;\n mcpServers?: string[];\n enableRAG?: boolean;\n vectorStoreIds?: string[];\n enableWebSearch?: boolean;\n enableCodeInterpreter?: boolean;\n functions?: AgentFunctionDef[];\n toolChoice?: string;\n temperature?: number;\n maxOutputTokens?: number;\n maxToolCalls?: number;\n reasoning?: { effort?: string };\n guardrails?: string[];\n outputSchema?: Record<string, unknown>;\n toolUseBehavior?: string;\n resetToolChoice?: boolean;\n handoffInputFilter?: string;\n handoffInputSchema?: Record<string, unknown>;\n nestHandoffHistory?: boolean;\n truncation?: string;\n promptRef?: {\n id: string;\n version?: number;\n variables?: Record<string, string>;\n };\n enabled?: boolean;\n}\n\n/**\n * A custom function definition attached to an agent.\n * @public\n */\nexport interface AgentFunctionDef {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}\n\n/**\n * Tool type discriminator for ToolNodeData.\n * @public\n */\nexport type ToolNodeKind =\n | 'mcp_server'\n | 'file_search'\n | 'web_search'\n | 'code_interpreter'\n | 'custom_function';\n\n/**\n * Data for a Tool node -- references an external capability.\n * @public\n */\nexport interface ToolNodeData {\n kind: ToolNodeKind;\n label: string;\n mcpServerId?: string;\n mcpToolFilter?: string[];\n vectorStoreIds?: string[];\n functionDef?: AgentFunctionDef;\n requireApproval?: boolean;\n}\n\n/**\n * Data for a Guardrail node -- safety checks on input/output.\n * @public\n */\nexport interface GuardrailNodeData {\n guardType: 'input' | 'output';\n shieldIds?: string[];\n customRules?: GuardrailRule[];\n onFailure: 'block' | 'warn' | 'fallback';\n fallbackMessage?: string;\n}\n\n/**\n * A custom guardrail rule (regex, keyword, or LLM-graded).\n * @public\n */\nexport interface GuardrailRule {\n id: string;\n name: string;\n type: 'regex' | 'keyword_block' | 'llm_grader';\n pattern?: string;\n keywords?: string[];\n graderPrompt?: string;\n}\n\n/**\n * Logic node sub-type.\n * @public\n */\nexport type LogicNodeKind = 'if_else' | 'while_loop' | 'switch';\n\n/**\n * Data for a Logic node -- conditional routing and loops.\n * @public\n */\nexport interface LogicNodeData {\n kind: LogicNodeKind;\n condition: string;\n cases?: Array<{ label: string; condition: string }>;\n maxIterations?: number;\n}\n\n/**\n * Data for a User Interaction node -- HITL approval gates and forms.\n * @public\n */\nexport interface UserInteractionNodeData {\n interactionType: 'approval_gate' | 'form_input' | 'confirmation';\n prompt: string;\n formFields?: UserInteractionField[];\n timeoutSeconds?: number;\n defaultAction?: 'approve' | 'reject' | 'skip';\n}\n\n/**\n * A field in a user interaction form.\n * @public\n */\nexport interface UserInteractionField {\n id: string;\n label: string;\n type: 'text' | 'select' | 'boolean' | 'number';\n required?: boolean;\n options?: string[];\n defaultValue?: string;\n}\n\n/**\n * Data for a Classify node -- routes to different branches based on LLM classification.\n * @public\n */\nexport interface ClassifyNodeData {\n classifications: Array<{ label: string; description: string }>;\n instructions?: string;\n model?: string;\n}\n\n/**\n * Data for an End node -- terminates the workflow execution.\n * @public\n */\nexport interface EndNodeData {\n outputExpression?: string;\n}\n\n/**\n * Data for a Note node -- annotation-only, no execution semantics.\n * @public\n */\nexport interface NoteNodeData {\n text: string;\n}\n\n/**\n * Data for a Transform node -- transforms data between steps using expressions.\n * @public\n */\nexport interface TransformNodeData {\n expression: string;\n outputVariable?: string;\n}\n\n/**\n * Data for a Set State node -- assigns values to workflow state variables.\n * @public\n */\nexport interface SetStateNodeData {\n assignments: Record<string, string>;\n}\n\n/**\n * Data for a File Search node -- configures vector store search.\n * @public\n */\nexport interface FileSearchNodeData {\n vectorStoreIds?: string[];\n maxResults?: number;\n scoreThreshold?: number;\n}\n\n/**\n * Data for an MCP node -- configures a Model Context Protocol server.\n * @public\n */\nexport interface McpNodeData {\n serverUrl: string;\n serverLabel: string;\n requireApproval?: 'always' | 'never' | 'auto';\n allowedTools?: string[];\n headers?: Record<string, string>;\n}\n\n/**\n * Union of all node data payloads, discriminated by the parent node's `type`.\n * @public\n */\nexport type WorkflowNodeData =\n | StartNodeData\n | AgentNodeData\n | ToolNodeData\n | GuardrailNodeData\n | LogicNodeData\n | UserInteractionNodeData\n | ClassifyNodeData\n | EndNodeData\n | NoteNodeData\n | TransformNodeData\n | SetStateNodeData\n | FileSearchNodeData\n | McpNodeData;\n\n// ---------------------------------------------------------------------------\n// Workflow Graph Structure\n// ---------------------------------------------------------------------------\n\n/**\n * A single node in the workflow graph.\n * @public\n */\nexport interface WorkflowNode {\n id: string;\n type: WorkflowNodeType;\n position: NodePosition;\n data: WorkflowNodeData;\n label?: string;\n}\n\n/**\n * Edge type determines the connection semantics.\n * @public\n */\nexport type WorkflowEdgeType =\n | 'handoff'\n | 'tool_binding'\n | 'guardrail_binding'\n | 'sequence'\n | 'conditional';\n\n/**\n * A connection between two nodes in the workflow graph.\n * @public\n */\nexport interface WorkflowEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n type?: WorkflowEdgeType;\n label?: string;\n condition?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Workflow Settings and Metadata\n// ---------------------------------------------------------------------------\n\n/**\n * Global settings that apply to the entire workflow.\n * @public\n */\nexport interface WorkflowSettings {\n maxTurns?: number;\n defaultModel?: string;\n globalGuardrails?: string[];\n conversationPersistence?: boolean;\n tracingEnabled?: boolean;\n timeoutSeconds?: number;\n}\n\n/**\n * A published, immutable version snapshot of a workflow.\n * @public\n */\nexport interface WorkflowVersion {\n version: number;\n publishedAt: string;\n publishedBy: string;\n changelog?: string;\n definition: WorkflowDefinition;\n}\n\n/**\n * The complete workflow definition -- the top-level serializable artifact.\n *\n * This is persisted in the admin config store and exchanged between the\n * frontend canvas editor and the backend hydration engine.\n * @public\n */\nexport interface WorkflowDefinition {\n id: string;\n name: string;\n description: string;\n version: number;\n createdAt: string;\n updatedAt: string;\n createdBy?: string;\n updatedBy?: string;\n status: WorkflowStatus;\n nodes: WorkflowNode[];\n edges: WorkflowEdge[];\n settings: WorkflowSettings;\n tags?: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Workflow Execution Types\n// ---------------------------------------------------------------------------\n\n/**\n * Status of a workflow execution run.\n * @public\n */\nexport type WorkflowRunStatus =\n | 'pending'\n | 'running'\n | 'completed'\n | 'failed'\n | 'interrupted'\n | 'cancelled';\n\n/**\n * A record of a single node's execution within a run.\n * @public\n */\nexport interface NodeExecutionRecord {\n nodeId: string;\n nodeType: WorkflowNodeType;\n nodeName: string;\n startedAt: string;\n completedAt?: string;\n status: 'running' | 'completed' | 'failed' | 'skipped';\n input?: unknown;\n output?: unknown;\n error?: string;\n tokenUsage?: { inputTokens: number; outputTokens: number };\n durationMs?: number;\n}\n\n/**\n * A complete execution trace for a workflow run.\n * @public\n */\nexport interface WorkflowRunTrace {\n runId: string;\n workflowId: string;\n workflowVersion: number;\n status: WorkflowRunStatus;\n startedAt: string;\n completedAt?: string;\n nodeExecutions: NodeExecutionRecord[];\n totalTokenUsage?: { inputTokens: number; outputTokens: number };\n totalDurationMs?: number;\n error?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Evaluation Types\n// ---------------------------------------------------------------------------\n\n/**\n * A single test case for evaluating a workflow.\n * @public\n */\nexport interface WorkflowTestCase {\n id: string;\n name: string;\n input: string;\n expectedOutput?: string;\n expectedAgent?: string;\n criteria?: EvaluationCriterion[];\n tags?: string[];\n}\n\n/**\n * A criterion for grading a workflow run.\n * @public\n */\nexport interface EvaluationCriterion {\n id: string;\n name: string;\n type: 'exact_match' | 'contains' | 'regex' | 'llm_graded' | 'custom';\n weight: number;\n pattern?: string;\n graderPrompt?: string;\n scoringFunction?: string;\n threshold?: number;\n}\n\n/**\n * Result of evaluating a single test case.\n * @public\n */\nexport interface TestCaseResult {\n testCaseId: string;\n passed: boolean;\n score: number;\n actualOutput: string;\n actualAgent?: string;\n criterionResults: Array<{\n criterionId: string;\n passed: boolean;\n score: number;\n details?: string;\n }>;\n trace: WorkflowRunTrace;\n durationMs: number;\n}\n\n/**\n * Result of an evaluation run across multiple test cases.\n * @public\n */\nexport interface WorkflowEvaluationResult {\n evaluationId: string;\n workflowId: string;\n workflowVersion: number;\n ranAt: string;\n ranBy?: string;\n testCaseResults: TestCaseResult[];\n overallScore: number;\n passRate: number;\n totalDurationMs: number;\n}\n\n/**\n * A stored set of test cases for repeatable evaluation.\n * @public\n */\nexport interface WorkflowTestSuite {\n id: string;\n name: string;\n workflowId: string;\n testCases: WorkflowTestCase[];\n createdAt: string;\n updatedAt: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a default empty workflow definition.\n */\nexport function createDefaultWorkflow(\n id: string,\n name: string,\n createdBy?: string,\n): WorkflowDefinition {\n const now = new Date().toISOString();\n return {\n id,\n name,\n description: '',\n version: 0,\n createdAt: now,\n updatedAt: now,\n createdBy,\n updatedBy: createdBy,\n status: 'draft',\n nodes: [\n {\n id: 'start-1',\n type: 'start',\n position: { x: 50, y: 150 },\n data: { inputDescription: 'User message' } as StartNodeData,\n label: 'Start',\n },\n {\n id: 'agent-1',\n type: 'agent',\n position: { x: 300, y: 140 },\n data: {\n agentKey: 'agent-1',\n name: 'Agent',\n instructions: '',\n handoffDescription: '',\n } as AgentNodeData,\n label: 'Agent',\n },\n ],\n edges: [\n {\n id: 'edge-start-agent-1',\n source: 'start-1',\n target: 'agent-1',\n type: 'sequence',\n },\n ],\n settings: {\n maxTurns: 10,\n conversationPersistence: true,\n tracingEnabled: true,\n },\n };\n}\n\n/**\n * Type guard for AgentNodeData.\n */\nexport function isAgentNodeData(data: WorkflowNodeData): data is AgentNodeData {\n return 'agentKey' in data && 'instructions' in data;\n}\n\n/**\n * Type guard for ToolNodeData.\n */\nexport function isToolNodeData(data: WorkflowNodeData): data is ToolNodeData {\n return 'kind' in data && 'label' in data && !('agentKey' in data);\n}\n\n/**\n * Type guard for GuardrailNodeData.\n */\nexport function isGuardrailNodeData(\n data: WorkflowNodeData,\n): data is GuardrailNodeData {\n return 'guardType' in data && 'onFailure' in data;\n}\n\n/**\n * Type guard for LogicNodeData.\n */\nexport function isLogicNodeData(data: WorkflowNodeData): data is LogicNodeData {\n return 'kind' in data && 'condition' in data && !('label' in data);\n}\n\n/**\n * Type guard for UserInteractionNodeData.\n */\nexport function isUserInteractionNodeData(\n data: WorkflowNodeData,\n): data is UserInteractionNodeData {\n return 'interactionType' in data && 'prompt' in data;\n}\n"],"names":[],"mappings":";;AAkhBO,SAAS,qBAAA,CACd,EAAA,EACA,IAAA,EACA,SAAA,EACoB;AACpB,EAAA,MAAM,GAAA,GAAA,iBAAM,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AACnC,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA,EAAa,EAAA;AAAA,IACb,OAAA,EAAS,CAAA;AAAA,IACT,SAAA,EAAW,GAAA;AAAA,IACX,SAAA,EAAW,GAAA;AAAA,IACX,SAAA;AAAA,IACA,SAAA,EAAW,SAAA;AAAA,IACX,MAAA,EAAQ,OAAA;AAAA,IACR,KAAA,EAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,SAAA;AAAA,QACJ,IAAA,EAAM,OAAA;AAAA,QACN,QAAA,EAAU,EAAE,CA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,SAAS,0BACd,IAAA,EACiC;AACjC,EAAA,OAAO,iBAAA,IAAqB,QAAQ,QAAA,IAAY,IAAA;AAClD;;;;;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function createDefaultWorkflow(id, name, createdBy) {
|
|
2
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3
|
+
return {
|
|
4
|
+
id,
|
|
5
|
+
name,
|
|
6
|
+
description: "",
|
|
7
|
+
version: 0,
|
|
8
|
+
createdAt: now,
|
|
9
|
+
updatedAt: now,
|
|
10
|
+
createdBy,
|
|
11
|
+
updatedBy: createdBy,
|
|
12
|
+
status: "draft",
|
|
13
|
+
nodes: [
|
|
14
|
+
{
|
|
15
|
+
id: "start-1",
|
|
16
|
+
type: "start",
|
|
17
|
+
position: { x: 50, y: 150 },
|
|
18
|
+
data: { inputDescription: "User message" },
|
|
19
|
+
label: "Start"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "agent-1",
|
|
23
|
+
type: "agent",
|
|
24
|
+
position: { x: 300, y: 140 },
|
|
25
|
+
data: {
|
|
26
|
+
agentKey: "agent-1",
|
|
27
|
+
name: "Agent",
|
|
28
|
+
instructions: "",
|
|
29
|
+
handoffDescription: ""
|
|
30
|
+
},
|
|
31
|
+
label: "Agent"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
edges: [
|
|
35
|
+
{
|
|
36
|
+
id: "edge-start-agent-1",
|
|
37
|
+
source: "start-1",
|
|
38
|
+
target: "agent-1",
|
|
39
|
+
type: "sequence"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
settings: {
|
|
43
|
+
maxTurns: 10,
|
|
44
|
+
conversationPersistence: true,
|
|
45
|
+
tracingEnabled: true
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function isAgentNodeData(data) {
|
|
50
|
+
return "agentKey" in data && "instructions" in data;
|
|
51
|
+
}
|
|
52
|
+
function isToolNodeData(data) {
|
|
53
|
+
return "kind" in data && "label" in data && !("agentKey" in data);
|
|
54
|
+
}
|
|
55
|
+
function isGuardrailNodeData(data) {
|
|
56
|
+
return "guardType" in data && "onFailure" in data;
|
|
57
|
+
}
|
|
58
|
+
function isLogicNodeData(data) {
|
|
59
|
+
return "kind" in data && "condition" in data && !("label" in data);
|
|
60
|
+
}
|
|
61
|
+
function isUserInteractionNodeData(data) {
|
|
62
|
+
return "interactionType" in data && "prompt" in data;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { createDefaultWorkflow, isAgentNodeData, isGuardrailNodeData, isLogicNodeData, isToolNodeData, isUserInteractionNodeData };
|
|
66
|
+
//# sourceMappingURL=workflowBuilder.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowBuilder.esm.js","sources":["../../src/types/workflowBuilder.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// =============================================================================\n// Workflow Builder Types\n//\n// These types define the serializable workflow definition format used by the\n// visual agent builder canvas. A WorkflowDefinition is a directed graph of\n// nodes (agents, tools, guardrails, logic, etc.) connected by typed edges.\n// At runtime the backend hydrates this definition into live @openai/agents-core\n// Agent / Runner instances for execution against LlamaStack APIs.\n// =============================================================================\n\n/**\n * Status of a workflow in its lifecycle.\n * @public\n */\nexport type WorkflowStatus = 'draft' | 'published' | 'archived';\n\n/**\n * Discriminated node types available in the workflow canvas.\n * @public\n */\nexport type WorkflowNodeType =\n | 'start'\n | 'agent'\n | 'tool'\n | 'guardrail'\n | 'logic'\n | 'user_interaction'\n | 'classify'\n | 'end'\n | 'note'\n | 'transform'\n | 'set_state'\n | 'file_search'\n | 'mcp';\n\n/**\n * Position on the canvas for visual layout.\n * @public\n */\nexport interface NodePosition {\n x: number;\n y: number;\n}\n\n// ---------------------------------------------------------------------------\n// Node Data Payloads\n// ---------------------------------------------------------------------------\n\n/**\n * Data for the Start node -- defines the workflow's input contract.\n * @public\n */\nexport interface StartNodeData {\n inputDescription?: string;\n inputSchema?: Record<string, unknown>;\n}\n\n/**\n * Data for an Agent node -- carries the full agent configuration.\n * @public\n */\nexport interface AgentNodeData {\n agentKey: string;\n name: string;\n instructions: string;\n handoffDescription?: string;\n model?: string;\n mcpServers?: string[];\n enableRAG?: boolean;\n vectorStoreIds?: string[];\n enableWebSearch?: boolean;\n enableCodeInterpreter?: boolean;\n functions?: AgentFunctionDef[];\n toolChoice?: string;\n temperature?: number;\n maxOutputTokens?: number;\n maxToolCalls?: number;\n reasoning?: { effort?: string };\n guardrails?: string[];\n outputSchema?: Record<string, unknown>;\n toolUseBehavior?: string;\n resetToolChoice?: boolean;\n handoffInputFilter?: string;\n handoffInputSchema?: Record<string, unknown>;\n nestHandoffHistory?: boolean;\n truncation?: string;\n promptRef?: {\n id: string;\n version?: number;\n variables?: Record<string, string>;\n };\n enabled?: boolean;\n}\n\n/**\n * A custom function definition attached to an agent.\n * @public\n */\nexport interface AgentFunctionDef {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}\n\n/**\n * Tool type discriminator for ToolNodeData.\n * @public\n */\nexport type ToolNodeKind =\n | 'mcp_server'\n | 'file_search'\n | 'web_search'\n | 'code_interpreter'\n | 'custom_function';\n\n/**\n * Data for a Tool node -- references an external capability.\n * @public\n */\nexport interface ToolNodeData {\n kind: ToolNodeKind;\n label: string;\n mcpServerId?: string;\n mcpToolFilter?: string[];\n vectorStoreIds?: string[];\n functionDef?: AgentFunctionDef;\n requireApproval?: boolean;\n}\n\n/**\n * Data for a Guardrail node -- safety checks on input/output.\n * @public\n */\nexport interface GuardrailNodeData {\n guardType: 'input' | 'output';\n shieldIds?: string[];\n customRules?: GuardrailRule[];\n onFailure: 'block' | 'warn' | 'fallback';\n fallbackMessage?: string;\n}\n\n/**\n * A custom guardrail rule (regex, keyword, or LLM-graded).\n * @public\n */\nexport interface GuardrailRule {\n id: string;\n name: string;\n type: 'regex' | 'keyword_block' | 'llm_grader';\n pattern?: string;\n keywords?: string[];\n graderPrompt?: string;\n}\n\n/**\n * Logic node sub-type.\n * @public\n */\nexport type LogicNodeKind = 'if_else' | 'while_loop' | 'switch';\n\n/**\n * Data for a Logic node -- conditional routing and loops.\n * @public\n */\nexport interface LogicNodeData {\n kind: LogicNodeKind;\n condition: string;\n cases?: Array<{ label: string; condition: string }>;\n maxIterations?: number;\n}\n\n/**\n * Data for a User Interaction node -- HITL approval gates and forms.\n * @public\n */\nexport interface UserInteractionNodeData {\n interactionType: 'approval_gate' | 'form_input' | 'confirmation';\n prompt: string;\n formFields?: UserInteractionField[];\n timeoutSeconds?: number;\n defaultAction?: 'approve' | 'reject' | 'skip';\n}\n\n/**\n * A field in a user interaction form.\n * @public\n */\nexport interface UserInteractionField {\n id: string;\n label: string;\n type: 'text' | 'select' | 'boolean' | 'number';\n required?: boolean;\n options?: string[];\n defaultValue?: string;\n}\n\n/**\n * Data for a Classify node -- routes to different branches based on LLM classification.\n * @public\n */\nexport interface ClassifyNodeData {\n classifications: Array<{ label: string; description: string }>;\n instructions?: string;\n model?: string;\n}\n\n/**\n * Data for an End node -- terminates the workflow execution.\n * @public\n */\nexport interface EndNodeData {\n outputExpression?: string;\n}\n\n/**\n * Data for a Note node -- annotation-only, no execution semantics.\n * @public\n */\nexport interface NoteNodeData {\n text: string;\n}\n\n/**\n * Data for a Transform node -- transforms data between steps using expressions.\n * @public\n */\nexport interface TransformNodeData {\n expression: string;\n outputVariable?: string;\n}\n\n/**\n * Data for a Set State node -- assigns values to workflow state variables.\n * @public\n */\nexport interface SetStateNodeData {\n assignments: Record<string, string>;\n}\n\n/**\n * Data for a File Search node -- configures vector store search.\n * @public\n */\nexport interface FileSearchNodeData {\n vectorStoreIds?: string[];\n maxResults?: number;\n scoreThreshold?: number;\n}\n\n/**\n * Data for an MCP node -- configures a Model Context Protocol server.\n * @public\n */\nexport interface McpNodeData {\n serverUrl: string;\n serverLabel: string;\n requireApproval?: 'always' | 'never' | 'auto';\n allowedTools?: string[];\n headers?: Record<string, string>;\n}\n\n/**\n * Union of all node data payloads, discriminated by the parent node's `type`.\n * @public\n */\nexport type WorkflowNodeData =\n | StartNodeData\n | AgentNodeData\n | ToolNodeData\n | GuardrailNodeData\n | LogicNodeData\n | UserInteractionNodeData\n | ClassifyNodeData\n | EndNodeData\n | NoteNodeData\n | TransformNodeData\n | SetStateNodeData\n | FileSearchNodeData\n | McpNodeData;\n\n// ---------------------------------------------------------------------------\n// Workflow Graph Structure\n// ---------------------------------------------------------------------------\n\n/**\n * A single node in the workflow graph.\n * @public\n */\nexport interface WorkflowNode {\n id: string;\n type: WorkflowNodeType;\n position: NodePosition;\n data: WorkflowNodeData;\n label?: string;\n}\n\n/**\n * Edge type determines the connection semantics.\n * @public\n */\nexport type WorkflowEdgeType =\n | 'handoff'\n | 'tool_binding'\n | 'guardrail_binding'\n | 'sequence'\n | 'conditional';\n\n/**\n * A connection between two nodes in the workflow graph.\n * @public\n */\nexport interface WorkflowEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n type?: WorkflowEdgeType;\n label?: string;\n condition?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Workflow Settings and Metadata\n// ---------------------------------------------------------------------------\n\n/**\n * Global settings that apply to the entire workflow.\n * @public\n */\nexport interface WorkflowSettings {\n maxTurns?: number;\n defaultModel?: string;\n globalGuardrails?: string[];\n conversationPersistence?: boolean;\n tracingEnabled?: boolean;\n timeoutSeconds?: number;\n}\n\n/**\n * A published, immutable version snapshot of a workflow.\n * @public\n */\nexport interface WorkflowVersion {\n version: number;\n publishedAt: string;\n publishedBy: string;\n changelog?: string;\n definition: WorkflowDefinition;\n}\n\n/**\n * The complete workflow definition -- the top-level serializable artifact.\n *\n * This is persisted in the admin config store and exchanged between the\n * frontend canvas editor and the backend hydration engine.\n * @public\n */\nexport interface WorkflowDefinition {\n id: string;\n name: string;\n description: string;\n version: number;\n createdAt: string;\n updatedAt: string;\n createdBy?: string;\n updatedBy?: string;\n status: WorkflowStatus;\n nodes: WorkflowNode[];\n edges: WorkflowEdge[];\n settings: WorkflowSettings;\n tags?: string[];\n}\n\n// ---------------------------------------------------------------------------\n// Workflow Execution Types\n// ---------------------------------------------------------------------------\n\n/**\n * Status of a workflow execution run.\n * @public\n */\nexport type WorkflowRunStatus =\n | 'pending'\n | 'running'\n | 'completed'\n | 'failed'\n | 'interrupted'\n | 'cancelled';\n\n/**\n * A record of a single node's execution within a run.\n * @public\n */\nexport interface NodeExecutionRecord {\n nodeId: string;\n nodeType: WorkflowNodeType;\n nodeName: string;\n startedAt: string;\n completedAt?: string;\n status: 'running' | 'completed' | 'failed' | 'skipped';\n input?: unknown;\n output?: unknown;\n error?: string;\n tokenUsage?: { inputTokens: number; outputTokens: number };\n durationMs?: number;\n}\n\n/**\n * A complete execution trace for a workflow run.\n * @public\n */\nexport interface WorkflowRunTrace {\n runId: string;\n workflowId: string;\n workflowVersion: number;\n status: WorkflowRunStatus;\n startedAt: string;\n completedAt?: string;\n nodeExecutions: NodeExecutionRecord[];\n totalTokenUsage?: { inputTokens: number; outputTokens: number };\n totalDurationMs?: number;\n error?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Evaluation Types\n// ---------------------------------------------------------------------------\n\n/**\n * A single test case for evaluating a workflow.\n * @public\n */\nexport interface WorkflowTestCase {\n id: string;\n name: string;\n input: string;\n expectedOutput?: string;\n expectedAgent?: string;\n criteria?: EvaluationCriterion[];\n tags?: string[];\n}\n\n/**\n * A criterion for grading a workflow run.\n * @public\n */\nexport interface EvaluationCriterion {\n id: string;\n name: string;\n type: 'exact_match' | 'contains' | 'regex' | 'llm_graded' | 'custom';\n weight: number;\n pattern?: string;\n graderPrompt?: string;\n scoringFunction?: string;\n threshold?: number;\n}\n\n/**\n * Result of evaluating a single test case.\n * @public\n */\nexport interface TestCaseResult {\n testCaseId: string;\n passed: boolean;\n score: number;\n actualOutput: string;\n actualAgent?: string;\n criterionResults: Array<{\n criterionId: string;\n passed: boolean;\n score: number;\n details?: string;\n }>;\n trace: WorkflowRunTrace;\n durationMs: number;\n}\n\n/**\n * Result of an evaluation run across multiple test cases.\n * @public\n */\nexport interface WorkflowEvaluationResult {\n evaluationId: string;\n workflowId: string;\n workflowVersion: number;\n ranAt: string;\n ranBy?: string;\n testCaseResults: TestCaseResult[];\n overallScore: number;\n passRate: number;\n totalDurationMs: number;\n}\n\n/**\n * A stored set of test cases for repeatable evaluation.\n * @public\n */\nexport interface WorkflowTestSuite {\n id: string;\n name: string;\n workflowId: string;\n testCases: WorkflowTestCase[];\n createdAt: string;\n updatedAt: string;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a default empty workflow definition.\n */\nexport function createDefaultWorkflow(\n id: string,\n name: string,\n createdBy?: string,\n): WorkflowDefinition {\n const now = new Date().toISOString();\n return {\n id,\n name,\n description: '',\n version: 0,\n createdAt: now,\n updatedAt: now,\n createdBy,\n updatedBy: createdBy,\n status: 'draft',\n nodes: [\n {\n id: 'start-1',\n type: 'start',\n position: { x: 50, y: 150 },\n data: { inputDescription: 'User message' } as StartNodeData,\n label: 'Start',\n },\n {\n id: 'agent-1',\n type: 'agent',\n position: { x: 300, y: 140 },\n data: {\n agentKey: 'agent-1',\n name: 'Agent',\n instructions: '',\n handoffDescription: '',\n } as AgentNodeData,\n label: 'Agent',\n },\n ],\n edges: [\n {\n id: 'edge-start-agent-1',\n source: 'start-1',\n target: 'agent-1',\n type: 'sequence',\n },\n ],\n settings: {\n maxTurns: 10,\n conversationPersistence: true,\n tracingEnabled: true,\n },\n };\n}\n\n/**\n * Type guard for AgentNodeData.\n */\nexport function isAgentNodeData(data: WorkflowNodeData): data is AgentNodeData {\n return 'agentKey' in data && 'instructions' in data;\n}\n\n/**\n * Type guard for ToolNodeData.\n */\nexport function isToolNodeData(data: WorkflowNodeData): data is ToolNodeData {\n return 'kind' in data && 'label' in data && !('agentKey' in data);\n}\n\n/**\n * Type guard for GuardrailNodeData.\n */\nexport function isGuardrailNodeData(\n data: WorkflowNodeData,\n): data is GuardrailNodeData {\n return 'guardType' in data && 'onFailure' in data;\n}\n\n/**\n * Type guard for LogicNodeData.\n */\nexport function isLogicNodeData(data: WorkflowNodeData): data is LogicNodeData {\n return 'kind' in data && 'condition' in data && !('label' in data);\n}\n\n/**\n * Type guard for UserInteractionNodeData.\n */\nexport function isUserInteractionNodeData(\n data: WorkflowNodeData,\n): data is UserInteractionNodeData {\n return 'interactionType' in data && 'prompt' in data;\n}\n"],"names":[],"mappings":"AAkhBO,SAAS,qBAAA,CACd,EAAA,EACA,IAAA,EACA,SAAA,EACoB;AACpB,EAAA,MAAM,GAAA,GAAA,iBAAM,IAAI,IAAA,EAAK,EAAE,WAAA,EAAY;AACnC,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA,EAAa,EAAA;AAAA,IACb,OAAA,EAAS,CAAA;AAAA,IACT,SAAA,EAAW,GAAA;AAAA,IACX,SAAA,EAAW,GAAA;AAAA,IACX,SAAA;AAAA,IACA,SAAA,EAAW,SAAA;AAAA,IACX,MAAA,EAAQ,OAAA;AAAA,IACR,KAAA,EAAO;AAAA,MACL;AAAA,QACE,EAAA,EAAI,SAAA;AAAA,QACJ,IAAA,EAAM,OAAA;AAAA,QACN,QAAA,EAAU,EAAE,CAAA,EAAG,EAAA,EAAI,GAAG,GAAA,EAAI;AAAA,QAC1B,IAAA,EAAM,EAAE,gBAAA,EAAkB,cAAA,EAAe;AAAA,QACzC,KAAA,EAAO;AAAA,OACT;AAAA,MACA;AAAA,QACE,EAAA,EAAI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": "@red-hat-developer-hub/backstage-plugin-augment-common",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"main": "dist/index.cjs.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"description": "Common types and permissions for Augment plugin",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"module": "dist/index.esm.js",
|
|
12
|
+
"types": "dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"backstage": {
|
|
15
|
+
"role": "common-library",
|
|
16
|
+
"pluginId": "augment",
|
|
17
|
+
"pluginPackage": "@red-hat-developer-hub/backstage-plugin-augment-common",
|
|
18
|
+
"pluginPackages": [
|
|
19
|
+
"@red-hat-developer-hub/backstage-plugin-augment",
|
|
20
|
+
"@red-hat-developer-hub/backstage-plugin-augment-backend",
|
|
21
|
+
"@red-hat-developer-hub/backstage-plugin-augment-common"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/redhat-developer/rhdh-plugins",
|
|
27
|
+
"directory": "workspaces/augment/plugins/augment-common"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"backstage",
|
|
31
|
+
"plugin",
|
|
32
|
+
"agentic",
|
|
33
|
+
"ai",
|
|
34
|
+
"chat"
|
|
35
|
+
],
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "backstage-cli package build",
|
|
39
|
+
"clean": "backstage-cli package clean",
|
|
40
|
+
"lint": "backstage-cli package lint",
|
|
41
|
+
"postpack": "backstage-cli package postpack",
|
|
42
|
+
"prepack": "backstage-cli package prepack",
|
|
43
|
+
"test": "backstage-cli package test --passWithNoTests --coverage",
|
|
44
|
+
"tsc": "tsc"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@backstage/plugin-permission-common": "^0.9.2"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@backstage/cli": "^0.34.5"
|
|
54
|
+
},
|
|
55
|
+
"typesVersions": {
|
|
56
|
+
"*": {
|
|
57
|
+
"package.json": [
|
|
58
|
+
"package.json"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"module": "dist/index.esm.js"
|
|
63
|
+
}
|