delqhi/sin-github-issues
0
1import process from 'node:process';2 3export const TEMPLATE_AGENT_ID = 'sin-github-issues';4export const TEMPLATE_AGENT_NAME = 'SIN-GitHub-Issues';5export const TEMPLATE_AGENT_DESCRIPTION = 'CEO Elite GitHub Operations Architect — orchestrates Projects V2, Issues, Wikis, Discussions, Gists, Security audits, PR Reviews, and public Showcase Ledger logging.';6export const TEMPLATE_AGENT_VERSION = '2026.03.22';7export const TEMPLATE_AGENT_DEFAULT_HOST = '127.0.0.1';8export const TEMPLATE_AGENT_DEFAULT_PORT = 46031;9 10export const TEMPLATE_AGENT_SKILLS = [11 {12 id: 'sin.github.health',13 name: 'Health',14 description: 'Check 2026 Elite GitHub Operations Architect readiness, model, and capabilities.',15 },16 {17 id: 'sin.github.app.routing.status',18 name: 'GitHub App Routing Status',19 description: 'Inspect the configured multi-app GitHub routing table, route paths, and secret readiness without exposing credentials.',20 },21 {22 id: 'sin.github.webhook.route',23 name: 'GitHub Webhook Route',24 description: 'Route GitHub webhook payloads to the correct SIN coder agent using installation.app_id, route path, and signature verification.',25 },26 {27 id: 'sin.github.issue.comment.as_app',28 name: 'Issue Comment As App',29 description: 'Generate the correct GitHub App JWT and installation token, then post an issue or PR comment as the matched bot identity.',30 },31 {32 id: 'sin.github.project.orchestrate',33 name: 'Project Orchestrate',34 description: 'Create and manage GitHub Projects V2 boards, link issues, and assign items.',35 },36 {37 id: 'sin.github.issue.manage',38 name: 'Issue Manage',39 description: 'Create, update, label, assign, milestone-link, or close GitHub issues and Epics.',40 },41 {42 id: 'sin.github.wiki.sync',43 name: 'Wiki Sync',44 description: 'Synchronize repository Wiki pages with project documentation updates.',45 },46 {47 id: 'sin.github.discussion.start',48 name: 'Discussion Start',49 description: 'Start or manage GitHub Discussions for architecture debates and design decisions.',50 },51 {52 id: 'sin.github.gist.publish',53 name: 'Gist Publish',54 description: 'Upload long logs, code snippets, or configs to GitHub Gists and return the URL.',55 },56 {57 id: 'sin.github.security.audit',58 name: 'Security Audit',59 description: 'Audit Dependabot alerts, configure CodeQL, and review active security advisories.',60 },61 {62 id: 'sin.github.pr.review',63 name: 'PR Review',64 description: 'Review Pull Requests for architectural compliance, security, performance, and test coverage. Auto-approve and merge if 100% pass.',65 },66 {67 id: 'sin.github.issue.pool.enqueue',68 name: 'Issue Pool Enqueue',69 description: 'Insert GitHub issue metadata into `sin_issues_pool` for Hermes/Team-Coding dispatch.',70 },71 {72 id: 'sin.github.ledger.log',73 name: 'Ledger Log',74 description: 'Publish an agent activity log or achievement to the public Delqhi/OpenSIN-Ledger showcase repository.',75 },76] as const;77 78export function resolveTemplateAgentConfig() {79 const host =80 process.env.SIN_GITHUB_ISSUES_HOST?.trim() ||81 (process.env.PORT ? '0.0.0.0' : process.env.HOST?.trim() || TEMPLATE_AGENT_DEFAULT_HOST);82 const port = parseInteger(process.env.SIN_GITHUB_ISSUES_PORT, parseInteger(process.env.PORT, TEMPLATE_AGENT_DEFAULT_PORT));83 const fallbackPublicHost = host === '0.0.0.0' ? '127.0.0.1' : host;84 const publicBaseUrl =85 process.env.SIN_GITHUB_ISSUES_PUBLIC_BASE_URL?.trim() ||86 (process.env.SPACE_HOST?.trim() ? `https://${process.env.SPACE_HOST.trim()}` : `http://${fallbackPublicHost}:${port}`);87 return { host, port, publicBaseUrl: publicBaseUrl.replace(/\/+$/, '') };88}89 90export function buildAgentCard(baseUrl: string) {91 const normalizedBaseUrl = baseUrl.replace(/\/+$/, '');92 const rpcUrl = `${normalizedBaseUrl}/a2a/v1`;93 return {94 name: TEMPLATE_AGENT_NAME,95 description: TEMPLATE_AGENT_DESCRIPTION,96 version: TEMPLATE_AGENT_VERSION,97 documentationUrl: normalizedBaseUrl,98 url: rpcUrl,99 capabilities: { streaming: false, pushNotifications: false },100 defaultInputModes: ['text/plain', 'application/json'],101 defaultOutputModes: ['text/plain', 'application/json'],102 skills: [...TEMPLATE_AGENT_SKILLS],103 supportedInterfaces: [{ url: rpcUrl, protocolBinding: 'JSONRPC', protocolVersion: '1.0' }],104 };105}106 107function parseInteger(input: string | undefined, fallback: number) {108 const parsed = Number.parseInt(String(input || '').trim(), 10);109 return Number.isFinite(parsed) ? parsed : fallback;110}111 