| import process from 'node:process'; |
|
|
| export const TEMPLATE_AGENT_ID = 'sin-backend'; |
| export const TEMPLATE_AGENT_NAME = 'SIN-Backend'; |
| export const TEMPLATE_AGENT_DESCRIPTION = 'Structural backend implementation and service delivery agent.'; |
| export const TEMPLATE_AGENT_VERSION = '2026.03.09'; |
| export const TEMPLATE_AGENT_DEFAULT_HOST = '127.0.0.1'; |
| export const TEMPLATE_AGENT_DEFAULT_PORT = 47108; |
|
|
| export const TEMPLATE_AGENT_SKILLS = [ |
| { |
| id: 'sin.backend.health', |
| name: 'Health', |
| description: 'Check base agent readiness and identity.', |
| }, |
| { |
| id: 'sin.backend.onboarding.status', |
| name: 'Onboarding Status', |
| description: 'Read persisted onboarding state.', |
| }, |
| { |
| id: 'sin.backend.onboarding.save', |
| name: 'Onboarding Save', |
| description: 'Persist onboarding defaults for future autonomous runs.', |
| }, |
| ] as const; |
|
|
| export function resolveTemplateAgentConfig() { |
| const host = |
| process.env.SIN_BACKEND_HOST?.trim() || |
| (process.env.PORT ? '0.0.0.0' : process.env.HOST?.trim() || TEMPLATE_AGENT_DEFAULT_HOST); |
| const port = parseInteger(process.env.SIN_BACKEND_PORT, parseInteger(process.env.PORT, TEMPLATE_AGENT_DEFAULT_PORT)); |
| const fallbackPublicHost = host === '0.0.0.0' ? '127.0.0.1' : host; |
| const publicBaseUrl = |
| process.env.SIN_BACKEND_PUBLIC_BASE_URL?.trim() || |
| (process.env.SPACE_HOST?.trim() ? `https://${process.env.SPACE_HOST.trim()}` : `http://${fallbackPublicHost}:${port}`); |
| return { host, port, publicBaseUrl: publicBaseUrl.replace(/\/+$/, '') }; |
| } |
|
|
| export function buildAgentCard(baseUrl: string) { |
| const normalizedBaseUrl = baseUrl.replace(/\/+$/, ''); |
| const rpcUrl = `${normalizedBaseUrl}/a2a/v1`; |
| return { |
| name: TEMPLATE_AGENT_NAME, |
| description: TEMPLATE_AGENT_DESCRIPTION, |
| version: TEMPLATE_AGENT_VERSION, |
| documentationUrl: normalizedBaseUrl, |
| url: rpcUrl, |
| capabilities: { streaming: false, pushNotifications: false }, |
| defaultInputModes: ['text/plain', 'application/json'], |
| defaultOutputModes: ['text/plain', 'application/json'], |
| skills: [...TEMPLATE_AGENT_SKILLS], |
| supportedInterfaces: [{ url: rpcUrl, protocolBinding: 'JSONRPC', protocolVersion: '1.0' }], |
| }; |
| } |
|
|
| function parseInteger(input: string | undefined, fallback: number) { |
| const parsed = Number.parseInt(String(input || '').trim(), 10); |
| return Number.isFinite(parsed) ? parsed : fallback; |
| } |
|
|
|
|