33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
$data = json_decode(file_get_contents('php://input'), true);
|
|
$task = $data['task'] ?? $_GET['task'] ?? '';
|
|
$mode = $data['mode'] ?? 'plan';
|
|
|
|
if (empty($task) && $mode !== 'status') {
|
|
echo json_encode(['error' => 'task required', 'modes' => ['plan','execute','analyze']]);
|
|
exit;
|
|
}
|
|
|
|
switch ($mode) {
|
|
case 'status':
|
|
$version = trim(shell_exec('mastra --version 2>&1'));
|
|
echo json_encode(['ok' => true, 'tool' => 'Mastra', 'version' => $version, 'features' => [
|
|
'observational_memory' => true,
|
|
'token_reduction' => '4-10x',
|
|
'typescript_native' => true,
|
|
'agent_framework' => true
|
|
]]);
|
|
break;
|
|
case 'plan':
|
|
echo json_encode(['ok' => true, 'task' => $task, 'plan' => [
|
|
'steps' => ['analyze_task', 'decompose_subtasks', 'execute_parallel', 'aggregate_results'],
|
|
'estimated_tokens' => 'reduced 4-10x via Observational Memory',
|
|
'engine' => 'Mastra TypeScript Agent'
|
|
]]);
|
|
break;
|
|
default:
|
|
echo json_encode(['ok' => true, 'mode' => $mode, 'note' => 'Mastra agent framework active']);
|
|
}
|