repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
The Living OS cockpit
stars
latest
clone command
git clone gitlawb://did:key:z6Mku78K...XywC/living-os-cockp...git clone gitlawb://did:key:z6Mku78K.../living-os-cockp...59751530feat: surface worker supervisor health in live work8h ago| #1 | import { NextRequest, NextResponse } from 'next/server'; |
| #2 | import { authErrorResponse, CANONICAL_KING_ID, getUserContext } from '@/lib/user-context'; |
| #3 | import { executeToolCall } from '@/lib/agentic-tools'; |
| #4 | |
| #5 | export const runtime = 'nodejs'; |
| #6 | export const maxDuration = 900; |
| #7 | |
| #8 | function cleanGoal(value: unknown) { |
| #9 | return String(value ?? '').replace(/\s+/g, ' ').trim(); |
| #10 | } |
| #11 | |
| #12 | export async function POST(req: NextRequest) { |
| #13 | try { |
| #14 | const ctx = await getUserContext(); |
| #15 | if (ctx.canonicalMemberId !== CANONICAL_KING_ID) { |
| #16 | return NextResponse.json({ ok: false, error: 'admin_required' }, { status: 403 }); |
| #17 | } |
| #18 | const body = await req.json().catch(() => ({})); |
| #19 | const goal = cleanGoal(body.goal); |
| #20 | if (!goal) { |
| #21 | return NextResponse.json({ ok: false, error: 'goal_required' }, { status: 400 }); |
| #22 | } |
| #23 | const result = await executeToolCall(ctx, { |
| #24 | tool: 'delegation_harness', |
| #25 | parameters: { goal }, |
| #26 | requiresConfirmation: false, |
| #27 | reason: 'Operator submitted a direct task from the Living.OS body surface.', |
| #28 | }); |
| #29 | return NextResponse.json({ |
| #30 | ok: Boolean(result?.result?.ok ?? result?.ok ?? true), |
| #31 | summary: result?.result?.summary || 'Delegation harness accepted the task and opened the next approval gate.', |
| #32 | result, |
| #33 | }); |
| #34 | } catch (error) { |
| #35 | try { |
| #36 | return authErrorResponse(error); |
| #37 | } catch { |
| #38 | return NextResponse.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, { status: 500 }); |
| #39 | } |
| #40 | } |
| #41 | } |
| #42 |