sync: Workflows P2 features from private repo

- 5 bundled workflows (prep, research, connect, integrate, survey)
- quickLink tool for fast edge creation
- queryDimensionNodes tool for dimension queries
- Workflow orchestration tools (list, get, edit)
- Dimension awareness with active dimension tracking
- Unified Workflows tab in Agent Panel
- MCP server updates for workflow execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
“BeeRad”
2026-01-11 18:54:34 +11:00
co-authored by Claude Opus 4.5
parent 3951d9daf4
commit f9271aeeb4
24 changed files with 2842 additions and 153 deletions
+51
View File
@@ -8,6 +8,14 @@ import { buildAutoContextBlock } from '@/services/context/autoContext';
export interface NodeContext {
nodes: Node[];
activeNodeId: number | null;
activeDimension?: string | null;
}
export interface DimensionContext {
name: string;
description: string | null;
isPriority: boolean;
nodeCount: number;
}
export interface ContextBuilderOptions {
@@ -151,6 +159,40 @@ export function buildFocusedNodesBlock(
return contextString;
}
/**
* Fetches dimension context from API or database
*/
async function fetchDimensionContext(dimensionName: string): Promise<DimensionContext | null> {
try {
// In server context, we can call the API internally or query directly
const response = await fetch(`${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/api/dimensions/${encodeURIComponent(dimensionName)}/context`);
if (!response.ok) return null;
const data = await response.json();
return data.success ? data.data : null;
} catch (error) {
console.warn('Failed to fetch dimension context:', error);
return null;
}
}
/**
* Builds the dimension context block for the system prompt
*/
function buildDimensionContextBlock(dimension: DimensionContext | null): string {
if (!dimension) return '';
return `
=== ACTIVE DIMENSION ===
Dimension: "${dimension.name}"
Description: ${dimension.description || 'No description'}
Node Count: ${dimension.nodeCount} nodes
Priority: ${dimension.isPriority ? 'Yes (locked)' : 'No'}
Note: Use queryDimensionNodes tool to retrieve actual nodes in this dimension.
===================================
`;
}
/**
* Builds system prompt as cacheable blocks (Anthropic prompt caching)
*/
@@ -212,6 +254,15 @@ export async function buildSystemPromptBlocks(
});
}
// Add dimension context if an active dimension is provided
if (nodeContext.activeDimension) {
const dimensionContext = await fetchDimensionContext(nodeContext.activeDimension);
const dimensionBlock = buildDimensionContextBlock(dimensionContext);
if (dimensionBlock.trim().length > 0) {
blocks.push({ type: 'text', text: dimensionBlock });
}
}
const focusBlock = buildFocusedNodesBlock(nodeContext, options);
blocks.push({ type: 'text', text: focusBlock });