Astreus

スケジュールされたワークフロー

Astreusのドキュメントでスケジュールされたワークフローについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

シンプルなスケジュール文字列と依存関係管理により、時間ベースの自動化ワークフローを構築します。

クイックスタート

完全なサンプルをクローンする

最も簡単な始め方は、完全なサンプルリポジトリをクローンすることです。

git clone https://github.com/astreus-ai/examples
cd examples/scheduled-workflows
npm install

またはパッケージのみをインストール

ゼロから構築したい場合は次のようにします。

npm install @astreus-ai/astreus

環境設定

# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db
NODE_ENV=development

クイックテストの例(秒単位)

import { Agent, Graph } from '@astreus-ai/astreus';

const agent = await Agent.create({
  name: 'ContentAgent',
  model: 'gpt-4o',
  systemPrompt: 'You are a content creation specialist.'
});

const graph = new Graph({
  name: 'Quick Test Pipeline',
  description: 'Test automated workflow with seconds interval',
  maxConcurrency: 2
}, agent);

// Run after 5 seconds
const researchNode = graph.addTaskNode({
  name: 'Content Research',
  prompt: 'Research trending topics in AI and technology. Find 3-5 compelling topics for blog content.',
  schedule: 'after:5s'
});

// Run after 10 seconds
const creationNode = graph.addTaskNode({
  name: 'Content Creation',
  prompt: 'Based on the research findings, create a short blog post summary on one of the trending topics.',
  schedule: 'after:10s',
  dependsOn: ['Content Research']
});

// Run after 15 seconds
const seoNode = graph.addTaskNode({
  name: 'SEO Optimization',
  prompt: 'Optimize the blog post for SEO: add meta description and keywords.',
  schedule: 'after:15s',
  dependsOn: ['Content Creation']
});

// Run after 20 seconds
const publishNode = graph.addTaskNode({
  name: 'Content Publishing',
  prompt: 'Create a social media post for the optimized content.',
  schedule: 'after:20s',
  dependsOn: ['SEO Optimization']
});

console.log('Starting scheduled workflow test...');
console.log('Tasks will run at:');
console.log('- Research: 5 seconds from now');
console.log('- Creation: 10 seconds from now');
console.log('- SEO: 15 seconds from now');
console.log('- Publishing: 20 seconds from now\n');

// Run the graph and get results
const result = await graph.run();

// Display execution results
console.log('\n=== Workflow Execution Results ===');
console.log('Success:', result.success);
console.log(`Completed: ${result.completedNodes} tasks`);
console.log(`Failed: ${result.failedNodes} tasks`);
console.log(`Duration: ${result.duration}ms`);

// Display each task result
if (result.results) {
  console.log('\n=== Task Results ===');
  for (const [nodeId, nodeResult] of Object.entries(result.results)) {
    console.log(`\n[${nodeId}]:`);
    console.log(nodeResult);
  }
}

// Check for errors
if (result.errors && Object.keys(result.errors).length > 0) {
  console.log('\n=== Errors ===');
  for (const [nodeId, error] of Object.entries(result.errors)) {
    console.log(`[${nodeId}]: ${error}`);
  }
}

console.log('\n✅ Scheduled workflow test completed!');

デイリーコンテンツパイプライン(本番運用)

実際の日次スケジュールを使った本番運用の場合は次のようになります。

// Schedule format examples:
// 'daily@06:00' - Every day at 6 AM
// 'weekly@monday@09:00' - Every Monday at 9 AM  
// 'monthly@15@10:00' - 15th of every month at 10 AM
// 'after:5s' - After 5 seconds (for testing)
// 'after:2h' - After 2 hours
// 'every:30m' - Every 30 minutes

const researchNode = graph.addTaskNode({
  name: 'Content Research',
  prompt: 'Research trending topics in AI and technology.',
  schedule: 'daily@06:00'
});

サンプルの実行

リポジトリをクローンした場合は次を実行します。

npm run dev

ゼロから構築した場合は、上記のコードを含むindex.tsファイルを作成し、次を実行します。

npx tsx index.ts

リポジトリ

完全なサンプルはGitHubで公開されています: examples/scheduled-workflows

最終更新日: 2026年7月6日

このセクション内

最初のエージェント

Astreusのドキュメントで最初のエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

メモリを使ったエージェント

Astreusのドキュメントでメモリを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

ナレッジを使ったエージェント

Astreusのドキュメントでナレッジを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。

ビジョンを使ったエージェント

Astreusのドキュメントでビジョンを使ったエージェントについて学び、エージェントシステムを構築するためのセットアップの手引き、APIのパターン、実践的な例を確認しましょう。 信頼性の高いAstreusエージェントシステムを構築するために必要なセットアップのパターン、API、実践的な例を学びましょう。