Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Router, Request, Response } from 'express';
|
|
import { createIntent, getIntent, executeIntent } from '../eo/execution-orchestrator.js';
|
|
import type { IntentRequest } from '../intent/types.js';
|
|
|
|
const router: Router = Router();
|
|
|
|
router.post('/v1/intents', (req: Request, res: Response) => {
|
|
try {
|
|
const body = req.body as IntentRequest;
|
|
const intent = createIntent(body);
|
|
res.status(201).json({
|
|
intent_id: intent.intent_id,
|
|
status: intent.status,
|
|
planned_steps: intent.planned_steps,
|
|
});
|
|
} catch (e) {
|
|
res.status(400).json({ error: e instanceof Error ? e.message : 'Bad request' });
|
|
}
|
|
});
|
|
|
|
router.post('/v1/intents/:intentId/execute', async (req: Request, res: Response) => {
|
|
try {
|
|
const { intentId } = req.params;
|
|
const execution = await executeIntent(intentId);
|
|
res.status(202).json({
|
|
execution_id: execution.execution_id,
|
|
submitted_txs: execution.submitted_txs,
|
|
});
|
|
} catch (e) {
|
|
res.status(400).json({ error: e instanceof Error ? e.message : 'Execute failed' });
|
|
}
|
|
});
|
|
|
|
router.get('/v1/intents/:intentId', (req: Request, res: Response) => {
|
|
const intent = getIntent(req.params.intentId);
|
|
if (!intent) return res.status(404).json({ error: 'Intent not found' });
|
|
res.json(intent);
|
|
});
|
|
|
|
export default router;
|