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:
co-authored by
Claude Opus 4.5
parent
3951d9daf4
commit
f9271aeeb4
@@ -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 });
|
||||
|
||||
|
||||
@@ -1,20 +1,68 @@
|
||||
import { INTEGRATE_WORKFLOW_INSTRUCTIONS } from '@/config/workflows/integrate';
|
||||
import { PREP_WORKFLOW_INSTRUCTIONS } from '@/config/workflows/prep';
|
||||
import { RESEARCH_WORKFLOW_INSTRUCTIONS } from '@/config/workflows/research';
|
||||
import { CONNECT_WORKFLOW_INSTRUCTIONS } from '@/config/workflows/connect';
|
||||
import { SURVEY_WORKFLOW_INSTRUCTIONS } from '@/config/workflows/survey';
|
||||
import type { WorkflowDefinition } from './types';
|
||||
import { listUserWorkflows, loadUserWorkflow } from './workflowFileService';
|
||||
|
||||
// Bundled default workflows (always available as fallback)
|
||||
const BUNDLED_WORKFLOWS: Record<string, WorkflowDefinition> = {
|
||||
'integrate': {
|
||||
'prep': {
|
||||
id: 1,
|
||||
key: 'prep',
|
||||
displayName: 'Prep',
|
||||
description: 'Quick summary to decide if content is worth deeper engagement',
|
||||
instructions: PREP_WORKFLOW_INSTRUCTIONS,
|
||||
enabled: true,
|
||||
requiresFocusedNode: true,
|
||||
primaryActor: 'oracle',
|
||||
expectedOutcome: 'Brief section appended with what/gist/why it matters',
|
||||
},
|
||||
'research': {
|
||||
id: 2,
|
||||
key: 'research',
|
||||
displayName: 'Research',
|
||||
description: 'Background research on topic, person, or concept',
|
||||
instructions: RESEARCH_WORKFLOW_INSTRUCTIONS,
|
||||
enabled: true,
|
||||
requiresFocusedNode: true,
|
||||
primaryActor: 'oracle',
|
||||
expectedOutcome: 'Research notes appended with background and key findings',
|
||||
},
|
||||
'connect': {
|
||||
id: 3,
|
||||
key: 'connect',
|
||||
displayName: 'Connect',
|
||||
description: 'Find and create edges to related nodes',
|
||||
instructions: CONNECT_WORKFLOW_INSTRUCTIONS,
|
||||
enabled: true,
|
||||
requiresFocusedNode: true,
|
||||
primaryActor: 'oracle',
|
||||
expectedOutcome: '3-5 edges created to related nodes',
|
||||
},
|
||||
'integrate': {
|
||||
id: 4,
|
||||
key: 'integrate',
|
||||
displayName: 'Integrate',
|
||||
description: 'Deep analysis and connection-building for focused node',
|
||||
description: 'Full analysis, connection discovery, and documentation',
|
||||
instructions: INTEGRATE_WORKFLOW_INSTRUCTIONS,
|
||||
enabled: true,
|
||||
requiresFocusedNode: true,
|
||||
primaryActor: 'oracle',
|
||||
expectedOutcome: 'Focused node updated with insights; 3-5 high-value edges created',
|
||||
}
|
||||
expectedOutcome: 'Integration analysis appended; 3-5 edges created',
|
||||
},
|
||||
'survey': {
|
||||
id: 5,
|
||||
key: 'survey',
|
||||
displayName: 'Survey',
|
||||
description: 'Analyze dimension patterns, themes, and gaps',
|
||||
instructions: SURVEY_WORKFLOW_INSTRUCTIONS,
|
||||
enabled: true,
|
||||
requiresFocusedNode: false, // Requires active dimension, not focused node
|
||||
primaryActor: 'oracle',
|
||||
expectedOutcome: 'Dimension description updated with survey findings',
|
||||
},
|
||||
};
|
||||
|
||||
// Set of bundled workflow keys (for UI to know which can be "reset to default")
|
||||
|
||||
Reference in New Issue
Block a user