@agimon-ai/po-logsink 0.0.1-alpha.21 → 0.0.1-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const e=require("./logSinkConfig-iZDMjdoX.cjs"),t=require("./LogStorageService-CXPURYrQ.cjs"),n=require("./container-DufPbECW.cjs"),r=require("./node-RhDg5vME.cjs"),i=require("./stdio-B8ly6H4C.cjs");let a=require("zod"),o=require("node:fs"),s=require("node:fs/promises");s=e.a(s,1);let c=require("node:path");c=e.a(c,1);let l=require("node:child_process"),u=require("node:util"),d=require("node:url"),f=require("@agimon-ai/foundation-port-registry"),p=require("@agimon-ai/foundation-process-registry"),m=require("commander"),h=require("@hono/node-server"),g=require("node:crypto"),_=require("hono"),v=require("hono-rate-limiter"),y=require("hono/cors"),b=require("hono/html"),x=require("hono/jsx/jsx-runtime");var S=`0.0.1-alpha.21`;const C=a.z.object({service:a.z.string().optional(),level:a.z.string().optional(),traceId:a.z.string().optional(),search:a.z.string().optional(),limit:a.z.coerce.number().min(1).max(1e3).default(25),offset:a.z.coerce.number().min(0).default(0)}),w=a.z.object({groupBy:a.z.enum([`session`,`workflow-run`,`workflow-name`,`job`,`step`,`agent`,`model`,`provider`]).optional(),startTime:a.z.string().optional(),endTime:a.z.string().optional(),period:a.z.enum([`day`,`week`,`month`,`all`]).optional(),bucket:a.z.enum([`hour`,`day`,`week`,`month`]).optional(),sessionId:a.z.string().optional(),workflowRunId:a.z.string().optional(),workflowName:a.z.string().optional(),jobName:a.z.string().optional(),stepName:a.z.string().optional(),agentName:a.z.string().optional(),service:a.z.array(a.z.string()).optional(),model:a.z.array(a.z.string()).optional(),provider:a.z.array(a.z.string()).optional(),limit:a.z.coerce.number().min(1).max(500).optional(),sort:a.z.enum([`last-seen`,`total-tokens`,`issues`]).optional(),toolLimit:a.z.coerce.number().min(1).max(500).optional(),toolSort:a.z.enum([`p90-total-tokens`,`avg-total-tokens`,`invocations`]).optional()});function T(e,t){let n=e.req.queries(t)??[],r=e.req.query(t),i=(n.length>0?n:r?[r]:[]).flatMap(e=>e.split(`,`)).map(e=>e.trim()).filter(e=>e.length>0);return i.length>0?i:void 0}function ee(e){let n=new _.Hono,r=e.get(t.u.LogQueryService),i=e.get(t.u.LogSearchService),a=e.get(t.u.LogMetricsService);return n.get(`/logs`,async e=>{try{let{service:t,level:n,traceId:a,search:o,limit:s,offset:c}=C.parse({service:e.req.query(`service`),level:e.req.query(`level`),traceId:e.req.query(`traceId`),search:e.req.query(`search`),limit:e.req.query(`limit`),offset:e.req.query(`offset`)}),l,u=0;if(o){let e={};t&&(e.service=t),n&&(e.level=n);let r=await i.searchLogsPaginated(o,{...e,offset:c},s);l=r.results,u=r.total}else{let e=n?n.split(`,`):[`info`,`warn`,`error`,`fatal`],i=await r.queryLogs({level:e,service:t||void 0,traceId:a||void 0,limit:s,offset:c});l=i.logs,u=i.total}return e.json({logs:l,total:u,hasMore:c+s<u})}catch(t){return console.error(`Failed to query logs:`,t),e.json({error:`Failed to query logs`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/services`,async e=>{try{let t=await r.getActiveServices();return e.json({services:t,total:t.length})}catch(t){return console.error(`Failed to get services:`,t),e.json({error:`Failed to get services`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/stats`,async e=>{try{let t=await r.getStatistics(),n=t.reduce((e,t)=>e+t.count,0),i=t.filter(e=>e.level===`error`||e.level===`fatal`).reduce((e,t)=>e+t.count,0),a=new Set(t.map(e=>e.service)).size;return e.json({totalLogs:n,errors:i,services:a,breakdown:t})}catch(t){return console.error(`Failed to get statistics:`,t),e.json({error:`Failed to get statistics`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/metrics`,async e=>{try{let t=w.parse({groupBy:e.req.query(`groupBy`),startTime:e.req.query(`startTime`),endTime:e.req.query(`endTime`),period:e.req.query(`period`),bucket:e.req.query(`bucket`),sessionId:e.req.query(`sessionId`),workflowRunId:e.req.query(`workflowRunId`),workflowName:e.req.query(`workflowName`),jobName:e.req.query(`jobName`),stepName:e.req.query(`stepName`),agentName:e.req.query(`agentName`),service:T(e,`service`),model:T(e,`model`),provider:T(e,`provider`),limit:e.req.query(`limit`),sort:e.req.query(`sort`),toolLimit:e.req.query(`toolLimit`),toolSort:e.req.query(`toolSort`)}),n=await a.getMetrics({sessionId:t.sessionId,workflowRunId:t.workflowRunId,workflowName:t.workflowName,jobName:t.jobName,stepName:t.stepName,agentName:t.agentName,service:t.service,model:t.model,provider:t.provider,startTime:t.startTime?new Date(t.startTime):void 0,endTime:t.endTime?new Date(t.endTime):void 0},{groupBy:t.groupBy,sort:t.sort,toolSort:t.toolSort,limit:t.limit,toolLimit:t.toolLimit,period:t.period,bucket:t.bucket});return e.json(n)}catch(t){return console.error(`Failed to get metrics:`,t),e.json({error:`Failed to get metrics`,message:t instanceof Error?t.message:String(t)},500)}}),n}function te(e){return e.toLocaleString(`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}const E=`controls-section`,D=`input-field`,O=`table-container`,k=`log-table`,A=`compact-table`,ne=`level-trace`,re=`level-debug`,ie=`level-info`,ae=`level-warn`,oe=`level-error`,se=`level-fatal`,ce=`stats-container`,j=`stat-card`,le=`trace-link`,ue=`timestamp-cell`,de=`service-cell`,fe=`pagination-btn`,pe=`log-entry-group`,me=`metadata-row`,he=`message-row`,ge=`message-full-cell`;function _e(e){let t=e.toLowerCase();return t===`trace`?ne:t===`debug`?re:t===`info`?ie:t===`warn`?ae:t===`error`?oe:t===`fatal`?se:``}function ve(e){if(!e||typeof e!=`object`)return null;let t=e,n={};for(let[e,r]of Object.entries(t))e!==`trace.id`&&e!==`span.id`&&(n[e]=r);return Object.keys(n).length>0?n:null}function ye({logs:e}){return/* @__PURE__ */ (0,x.jsx)(`div`,{class:O,children:/* @__PURE__ */ (0,x.jsxs)(`table`,{class:k,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Timestamp`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Level`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Service`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Trace ID`})]})}),e.map(e=>{let t=ve(e.metadata);return/* @__PURE__ */ (0,x.jsxs)(`tbody`,{class:pe,children:[/* @__PURE__ */ (0,x.jsxs)(`tr`,{class:me,children:[/* @__PURE__ */ (0,x.jsx)(`td`,{class:ue,children:te(e.timestamp)}),/* @__PURE__ */ (0,x.jsx)(`td`,{class:_e(e.level),children:e.level.toUpperCase()}),/* @__PURE__ */ (0,x.jsx)(`td`,{class:de,children:e.service}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.traceId?/* @__PURE__ */ (0,x.jsxs)(`span`,{class:le,onclick:`dashboard.filterByTrace('${e.traceId}')`,children:[e.traceId.slice(0,8),`...`]}):/* @__PURE__ */ (0,x.jsx)(`span`,{children:`-`})})]}),/* @__PURE__ */ (0,x.jsx)(`tr`,{class:he,children:/* @__PURE__ */ (0,x.jsxs)(`td`,{colspan:4,class:ge,children:[/* @__PURE__ */ (0,x.jsx)(`div`,{children:e.message}),t&&/* @__PURE__ */ (0,x.jsx)(`pre`,{class:`attributes-cell`,children:JSON.stringify(t,null,2)})]})})]},e.id)})]})})}function M(e){return Math.round(e).toLocaleString()}function be(e){return`${e.toFixed(1)}%`}function xe(e){return e?e.toISOString():`-`}function Se({metrics:e}){return/* @__PURE__ */ (0,x.jsxs)(`section`,{class:`metrics-section`,children:[/* @__PURE__ */ (0,x.jsx)(`div`,{class:`section-header`,children:/* @__PURE__ */ (0,x.jsx)(`h2`,{children:`Workflow Metrics`})}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:E,children:[/* @__PURE__ */ (0,x.jsx)(`input`,{id:`metrics-model-filter`,class:D,type:`text`,placeholder:`Model`}),/* @__PURE__ */ (0,x.jsx)(`input`,{id:`metrics-provider-filter`,class:D,type:`text`,placeholder:`Provider`}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,class:`btn`,onclick:`dashboard.fetchMetrics()`,children:`Apply Metrics Filters`})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{id:`metrics-summary`,class:ce,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Workflow Runs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-group-count`,class:`value`,children:e.totals.groupCount.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Failed Runs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-failed-groups`,class:`value`,children:e.totals.failedGroups.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Total Tokens`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-total-tokens`,class:`value`,children:M(e.totals.totalTokens)})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Token Coverage`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-token-coverage`,class:`value`,children:be(e.totals.tokenCoveragePercent)})]})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`metrics-grid`,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:O,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Top Workflow Runs`}),/* @__PURE__ */ (0,x.jsxs)(`table`,{class:A,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Workflow`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Last Seen`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Tokens`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Issues`})]})}),/* @__PURE__ */ (0,x.jsx)(`tbody`,{id:`workflow-metrics-body`,children:e.groups.slice(0,10).map(e=>/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.key}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:xe(e.lastSeen)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.totalTokens)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.issueCount.toLocaleString()})]}))})]})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:O,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Top Tools By Token Use`}),/* @__PURE__ */ (0,x.jsxs)(`table`,{class:A,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Tool`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Invocations`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Call p90`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Output p90`})]})}),/* @__PURE__ */ (0,x.jsx)(`tbody`,{id:`tool-metrics-body`,children:e.tools.rows.slice(0,10).map(e=>/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.toolName}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.invocationCount.toLocaleString()}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.toolCallTurn.p90TotalTokens)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.toolOutputImpact.p90TotalTokens)})]}))})]})]})]})]})}function Ce(){return/* @__PURE__ */ (0,x.jsx)(`input`,{id:`search-input`,type:`text`,class:D,placeholder:`Search logs...`,oninput:`dashboard.handleSearchInput(event)`})}function we({services:e}){return/* @__PURE__ */ (0,x.jsxs)(`select`,{id:`service-select`,class:`select-field`,onchange:`dashboard.handleServiceChange(event)`,children:[/* @__PURE__ */ (0,x.jsx)(`option`,{value:``,children:`All Services`}),e.map(e=>/* @__PURE__ */ (0,x.jsx)(`option`,{value:e,children:e},e))]})}function Te({stats:e}){return/* @__PURE__ */ (0,x.jsxs)(`div`,{class:ce,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Total Logs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.totalLogs.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Errors`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.errors.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Services`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.services})]})]})}function Ee({initialLogs:e,services:t,stats:n,metrics:r}){return/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`dashboard-container`,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`dashboard-header`,children:[/* @__PURE__ */ (0,x.jsx)(`h1`,{children:`Log Dashboard`}),/* @__PURE__ */ (0,x.jsx)(`p`,{children:`Real-time log streaming with auto-refresh (3 seconds)`})]}),/* @__PURE__ */ (0,x.jsx)(Te,{stats:n}),/* @__PURE__ */ (0,x.jsx)(Se,{metrics:r}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:E,children:[/* @__PURE__ */ (0,x.jsx)(Ce,{}),/* @__PURE__ */ (0,x.jsx)(we,{services:t}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`refresh-btn`,class:`btn`,onclick:`dashboard.manualRefresh()`,children:`Refresh Now`})]}),/* @__PURE__ */ (0,x.jsx)(ye,{logs:e}),/* @__PURE__ */ (0,x.jsxs)(`div`,{id:`pagination-controls`,class:`pagination-container`,children:[/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`prev-btn`,class:fe,onclick:`dashboard.prevPage()`,disabled:!0,children:`Previous`}),/* @__PURE__ */ (0,x.jsx)(`span`,{id:`page-info`,class:`page-info`,children:`Page 1`}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`next-btn`,class:fe,onclick:`dashboard.nextPage()`,children:`Next`})]}),/* @__PURE__ */ (0,x.jsx)(`script`,{children:(0,b.raw)(`
|
|
2
|
+
const e=require("./logSinkConfig-iZDMjdoX.cjs"),t=require("./LogStorageService-CXPURYrQ.cjs"),n=require("./container-DufPbECW.cjs"),r=require("./node-RhDg5vME.cjs"),i=require("./stdio-B8ly6H4C.cjs");let a=require("zod"),o=require("node:fs"),s=require("node:fs/promises");s=e.a(s,1);let c=require("node:path");c=e.a(c,1);let l=require("node:child_process"),u=require("node:util"),d=require("node:url"),f=require("@agimon-ai/foundation-port-registry"),p=require("@agimon-ai/foundation-process-registry"),m=require("commander"),h=require("@hono/node-server"),g=require("node:crypto"),_=require("hono"),v=require("hono-rate-limiter"),y=require("hono/cors"),b=require("hono/html"),x=require("hono/jsx/jsx-runtime");var S=`0.0.1-alpha.23`;const C=a.z.object({service:a.z.string().optional(),level:a.z.string().optional(),traceId:a.z.string().optional(),search:a.z.string().optional(),limit:a.z.coerce.number().min(1).max(1e3).default(25),offset:a.z.coerce.number().min(0).default(0)}),w=a.z.object({groupBy:a.z.enum([`session`,`workflow-run`,`workflow-name`,`job`,`step`,`agent`,`model`,`provider`]).optional(),startTime:a.z.string().optional(),endTime:a.z.string().optional(),period:a.z.enum([`day`,`week`,`month`,`all`]).optional(),bucket:a.z.enum([`hour`,`day`,`week`,`month`]).optional(),sessionId:a.z.string().optional(),workflowRunId:a.z.string().optional(),workflowName:a.z.string().optional(),jobName:a.z.string().optional(),stepName:a.z.string().optional(),agentName:a.z.string().optional(),service:a.z.array(a.z.string()).optional(),model:a.z.array(a.z.string()).optional(),provider:a.z.array(a.z.string()).optional(),limit:a.z.coerce.number().min(1).max(500).optional(),sort:a.z.enum([`last-seen`,`total-tokens`,`issues`]).optional(),toolLimit:a.z.coerce.number().min(1).max(500).optional(),toolSort:a.z.enum([`p90-total-tokens`,`avg-total-tokens`,`invocations`]).optional()});function T(e,t){let n=e.req.queries(t)??[],r=e.req.query(t),i=(n.length>0?n:r?[r]:[]).flatMap(e=>e.split(`,`)).map(e=>e.trim()).filter(e=>e.length>0);return i.length>0?i:void 0}function ee(e){let n=new _.Hono,r=e.get(t.u.LogQueryService),i=e.get(t.u.LogSearchService),a=e.get(t.u.LogMetricsService);return n.get(`/logs`,async e=>{try{let{service:t,level:n,traceId:a,search:o,limit:s,offset:c}=C.parse({service:e.req.query(`service`),level:e.req.query(`level`),traceId:e.req.query(`traceId`),search:e.req.query(`search`),limit:e.req.query(`limit`),offset:e.req.query(`offset`)}),l,u=0;if(o){let e={};t&&(e.service=t),n&&(e.level=n);let r=await i.searchLogsPaginated(o,{...e,offset:c},s);l=r.results,u=r.total}else{let e=n?n.split(`,`):[`info`,`warn`,`error`,`fatal`],i=await r.queryLogs({level:e,service:t||void 0,traceId:a||void 0,limit:s,offset:c});l=i.logs,u=i.total}return e.json({logs:l,total:u,hasMore:c+s<u})}catch(t){return console.error(`Failed to query logs:`,t),e.json({error:`Failed to query logs`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/services`,async e=>{try{let t=await r.getActiveServices();return e.json({services:t,total:t.length})}catch(t){return console.error(`Failed to get services:`,t),e.json({error:`Failed to get services`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/stats`,async e=>{try{let t=await r.getStatistics(),n=t.reduce((e,t)=>e+t.count,0),i=t.filter(e=>e.level===`error`||e.level===`fatal`).reduce((e,t)=>e+t.count,0),a=new Set(t.map(e=>e.service)).size;return e.json({totalLogs:n,errors:i,services:a,breakdown:t})}catch(t){return console.error(`Failed to get statistics:`,t),e.json({error:`Failed to get statistics`,message:t instanceof Error?t.message:String(t)},500)}}),n.get(`/metrics`,async e=>{try{let t=w.parse({groupBy:e.req.query(`groupBy`),startTime:e.req.query(`startTime`),endTime:e.req.query(`endTime`),period:e.req.query(`period`),bucket:e.req.query(`bucket`),sessionId:e.req.query(`sessionId`),workflowRunId:e.req.query(`workflowRunId`),workflowName:e.req.query(`workflowName`),jobName:e.req.query(`jobName`),stepName:e.req.query(`stepName`),agentName:e.req.query(`agentName`),service:T(e,`service`),model:T(e,`model`),provider:T(e,`provider`),limit:e.req.query(`limit`),sort:e.req.query(`sort`),toolLimit:e.req.query(`toolLimit`),toolSort:e.req.query(`toolSort`)}),n=await a.getMetrics({sessionId:t.sessionId,workflowRunId:t.workflowRunId,workflowName:t.workflowName,jobName:t.jobName,stepName:t.stepName,agentName:t.agentName,service:t.service,model:t.model,provider:t.provider,startTime:t.startTime?new Date(t.startTime):void 0,endTime:t.endTime?new Date(t.endTime):void 0},{groupBy:t.groupBy,sort:t.sort,toolSort:t.toolSort,limit:t.limit,toolLimit:t.toolLimit,period:t.period,bucket:t.bucket});return e.json(n)}catch(t){return console.error(`Failed to get metrics:`,t),e.json({error:`Failed to get metrics`,message:t instanceof Error?t.message:String(t)},500)}}),n}function te(e){return e.toLocaleString(`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}const E=`controls-section`,D=`input-field`,O=`table-container`,k=`log-table`,A=`compact-table`,ne=`level-trace`,re=`level-debug`,ie=`level-info`,ae=`level-warn`,oe=`level-error`,se=`level-fatal`,ce=`stats-container`,j=`stat-card`,le=`trace-link`,ue=`timestamp-cell`,de=`service-cell`,fe=`pagination-btn`,pe=`log-entry-group`,me=`metadata-row`,he=`message-row`,ge=`message-full-cell`;function _e(e){let t=e.toLowerCase();return t===`trace`?ne:t===`debug`?re:t===`info`?ie:t===`warn`?ae:t===`error`?oe:t===`fatal`?se:``}function ve(e){if(!e||typeof e!=`object`)return null;let t=e,n={};for(let[e,r]of Object.entries(t))e!==`trace.id`&&e!==`span.id`&&(n[e]=r);return Object.keys(n).length>0?n:null}function ye({logs:e}){return/* @__PURE__ */ (0,x.jsx)(`div`,{class:O,children:/* @__PURE__ */ (0,x.jsxs)(`table`,{class:k,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Timestamp`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Level`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Service`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Trace ID`})]})}),e.map(e=>{let t=ve(e.metadata);return/* @__PURE__ */ (0,x.jsxs)(`tbody`,{class:pe,children:[/* @__PURE__ */ (0,x.jsxs)(`tr`,{class:me,children:[/* @__PURE__ */ (0,x.jsx)(`td`,{class:ue,children:te(e.timestamp)}),/* @__PURE__ */ (0,x.jsx)(`td`,{class:_e(e.level),children:e.level.toUpperCase()}),/* @__PURE__ */ (0,x.jsx)(`td`,{class:de,children:e.service}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.traceId?/* @__PURE__ */ (0,x.jsxs)(`span`,{class:le,onclick:`dashboard.filterByTrace('${e.traceId}')`,children:[e.traceId.slice(0,8),`...`]}):/* @__PURE__ */ (0,x.jsx)(`span`,{children:`-`})})]}),/* @__PURE__ */ (0,x.jsx)(`tr`,{class:he,children:/* @__PURE__ */ (0,x.jsxs)(`td`,{colspan:4,class:ge,children:[/* @__PURE__ */ (0,x.jsx)(`div`,{children:e.message}),t&&/* @__PURE__ */ (0,x.jsx)(`pre`,{class:`attributes-cell`,children:JSON.stringify(t,null,2)})]})})]},e.id)})]})})}function M(e){return Math.round(e).toLocaleString()}function be(e){return`${e.toFixed(1)}%`}function xe(e){return e?e.toISOString():`-`}function Se({metrics:e}){return/* @__PURE__ */ (0,x.jsxs)(`section`,{class:`metrics-section`,children:[/* @__PURE__ */ (0,x.jsx)(`div`,{class:`section-header`,children:/* @__PURE__ */ (0,x.jsx)(`h2`,{children:`Workflow Metrics`})}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:E,children:[/* @__PURE__ */ (0,x.jsx)(`input`,{id:`metrics-model-filter`,class:D,type:`text`,placeholder:`Model`}),/* @__PURE__ */ (0,x.jsx)(`input`,{id:`metrics-provider-filter`,class:D,type:`text`,placeholder:`Provider`}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,class:`btn`,onclick:`dashboard.fetchMetrics()`,children:`Apply Metrics Filters`})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{id:`metrics-summary`,class:ce,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Workflow Runs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-group-count`,class:`value`,children:e.totals.groupCount.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Failed Runs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-failed-groups`,class:`value`,children:e.totals.failedGroups.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Total Tokens`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-total-tokens`,class:`value`,children:M(e.totals.totalTokens)})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Token Coverage`}),/* @__PURE__ */ (0,x.jsx)(`div`,{id:`metrics-token-coverage`,class:`value`,children:be(e.totals.tokenCoveragePercent)})]})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`metrics-grid`,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:O,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Top Workflow Runs`}),/* @__PURE__ */ (0,x.jsxs)(`table`,{class:A,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Workflow`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Last Seen`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Tokens`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Issues`})]})}),/* @__PURE__ */ (0,x.jsx)(`tbody`,{id:`workflow-metrics-body`,children:e.groups.slice(0,10).map(e=>/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.key}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:xe(e.lastSeen)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.totalTokens)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.issueCount.toLocaleString()})]}))})]})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:O,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Top Tools By Token Use`}),/* @__PURE__ */ (0,x.jsxs)(`table`,{class:A,children:[/* @__PURE__ */ (0,x.jsx)(`thead`,{children:/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Tool`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Invocations`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Call p90`}),/* @__PURE__ */ (0,x.jsx)(`th`,{children:`Output p90`})]})}),/* @__PURE__ */ (0,x.jsx)(`tbody`,{id:`tool-metrics-body`,children:e.tools.rows.slice(0,10).map(e=>/* @__PURE__ */ (0,x.jsxs)(`tr`,{children:[/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.toolName}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:e.invocationCount.toLocaleString()}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.toolCallTurn.p90TotalTokens)}),/* @__PURE__ */ (0,x.jsx)(`td`,{children:M(e.toolOutputImpact.p90TotalTokens)})]}))})]})]})]})]})}function Ce(){return/* @__PURE__ */ (0,x.jsx)(`input`,{id:`search-input`,type:`text`,class:D,placeholder:`Search logs...`,oninput:`dashboard.handleSearchInput(event)`})}function we({services:e}){return/* @__PURE__ */ (0,x.jsxs)(`select`,{id:`service-select`,class:`select-field`,onchange:`dashboard.handleServiceChange(event)`,children:[/* @__PURE__ */ (0,x.jsx)(`option`,{value:``,children:`All Services`}),e.map(e=>/* @__PURE__ */ (0,x.jsx)(`option`,{value:e,children:e},e))]})}function Te({stats:e}){return/* @__PURE__ */ (0,x.jsxs)(`div`,{class:ce,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Total Logs`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.totalLogs.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Errors`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.errors.toLocaleString()})]}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:j,children:[/* @__PURE__ */ (0,x.jsx)(`h3`,{children:`Services`}),/* @__PURE__ */ (0,x.jsx)(`div`,{class:`value`,children:e.services})]})]})}function Ee({initialLogs:e,services:t,stats:n,metrics:r}){return/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`dashboard-container`,children:[/* @__PURE__ */ (0,x.jsxs)(`div`,{class:`dashboard-header`,children:[/* @__PURE__ */ (0,x.jsx)(`h1`,{children:`Log Dashboard`}),/* @__PURE__ */ (0,x.jsx)(`p`,{children:`Real-time log streaming with auto-refresh (3 seconds)`})]}),/* @__PURE__ */ (0,x.jsx)(Te,{stats:n}),/* @__PURE__ */ (0,x.jsx)(Se,{metrics:r}),/* @__PURE__ */ (0,x.jsxs)(`div`,{class:E,children:[/* @__PURE__ */ (0,x.jsx)(Ce,{}),/* @__PURE__ */ (0,x.jsx)(we,{services:t}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`refresh-btn`,class:`btn`,onclick:`dashboard.manualRefresh()`,children:`Refresh Now`})]}),/* @__PURE__ */ (0,x.jsx)(ye,{logs:e}),/* @__PURE__ */ (0,x.jsxs)(`div`,{id:`pagination-controls`,class:`pagination-container`,children:[/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`prev-btn`,class:fe,onclick:`dashboard.prevPage()`,disabled:!0,children:`Previous`}),/* @__PURE__ */ (0,x.jsx)(`span`,{id:`page-info`,class:`page-info`,children:`Page 1`}),/* @__PURE__ */ (0,x.jsx)(`button`,{type:`button`,id:`next-btn`,class:fe,onclick:`dashboard.nextPage()`,children:`Next`})]}),/* @__PURE__ */ (0,x.jsx)(`script`,{children:(0,b.raw)(`
|
|
3
3
|
class DashboardManager {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.filters = {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as e,o as t,u as n}from"./LogStorageService-FUtAkl3y.mjs";import{i as r,n as i,r as a,t as o}from"./container-DATXzAs6.mjs";import{i as s,n as c,r as l}from"./logSinkConfig-BnOw8fWp.mjs";import{d as u}from"./node-BHLaIwwU.mjs";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./stdio-DVTvHUla.mjs";import{z as y}from"zod";import{readFileSync as b}from"node:fs";import*as x from"node:fs/promises";import ee,{dirname as S,join as te}from"node:path";import{execFile as ne}from"node:child_process";import{promisify as C}from"node:util";import{fileURLToPath as re}from"node:url";import{DEFAULT_PORT_RANGE as w,PortRegistryService as ie}from"@agimon-ai/foundation-port-registry";import{createProcessLease as T,createProcessRegistryService as ae,resolveSiblingRegistryPath as E}from"@agimon-ai/foundation-process-registry";import{Command as D,InvalidArgumentError as O}from"commander";import{serve as oe}from"@hono/node-server";import{createHash as se}from"node:crypto";import{Hono as ce}from"hono";import{rateLimiter as le}from"hono-rate-limiter";import{cors as ue}from"hono/cors";import{raw as de}from"hono/html";import{jsx as k,jsxs as A}from"hono/jsx/jsx-runtime";var fe=`0.0.1-alpha.21`;const pe=y.object({service:y.string().optional(),level:y.string().optional(),traceId:y.string().optional(),search:y.string().optional(),limit:y.coerce.number().min(1).max(1e3).default(25),offset:y.coerce.number().min(0).default(0)}),me=y.object({groupBy:y.enum([`session`,`workflow-run`,`workflow-name`,`job`,`step`,`agent`,`model`,`provider`]).optional(),startTime:y.string().optional(),endTime:y.string().optional(),period:y.enum([`day`,`week`,`month`,`all`]).optional(),bucket:y.enum([`hour`,`day`,`week`,`month`]).optional(),sessionId:y.string().optional(),workflowRunId:y.string().optional(),workflowName:y.string().optional(),jobName:y.string().optional(),stepName:y.string().optional(),agentName:y.string().optional(),service:y.array(y.string()).optional(),model:y.array(y.string()).optional(),provider:y.array(y.string()).optional(),limit:y.coerce.number().min(1).max(500).optional(),sort:y.enum([`last-seen`,`total-tokens`,`issues`]).optional(),toolLimit:y.coerce.number().min(1).max(500).optional(),toolSort:y.enum([`p90-total-tokens`,`avg-total-tokens`,`invocations`]).optional()});function j(e,t){let n=e.req.queries(t)??[],r=e.req.query(t),i=(n.length>0?n:r?[r]:[]).flatMap(e=>e.split(`,`)).map(e=>e.trim()).filter(e=>e.length>0);return i.length>0?i:void 0}function he(e){let t=new ce,r=e.get(n.LogQueryService),i=e.get(n.LogSearchService),a=e.get(n.LogMetricsService);return t.get(`/logs`,async e=>{try{let{service:t,level:n,traceId:a,search:o,limit:s,offset:c}=pe.parse({service:e.req.query(`service`),level:e.req.query(`level`),traceId:e.req.query(`traceId`),search:e.req.query(`search`),limit:e.req.query(`limit`),offset:e.req.query(`offset`)}),l,u=0;if(o){let e={};t&&(e.service=t),n&&(e.level=n);let r=await i.searchLogsPaginated(o,{...e,offset:c},s);l=r.results,u=r.total}else{let e=n?n.split(`,`):[`info`,`warn`,`error`,`fatal`],i=await r.queryLogs({level:e,service:t||void 0,traceId:a||void 0,limit:s,offset:c});l=i.logs,u=i.total}return e.json({logs:l,total:u,hasMore:c+s<u})}catch(t){return console.error(`Failed to query logs:`,t),e.json({error:`Failed to query logs`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/services`,async e=>{try{let t=await r.getActiveServices();return e.json({services:t,total:t.length})}catch(t){return console.error(`Failed to get services:`,t),e.json({error:`Failed to get services`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/stats`,async e=>{try{let t=await r.getStatistics(),n=t.reduce((e,t)=>e+t.count,0),i=t.filter(e=>e.level===`error`||e.level===`fatal`).reduce((e,t)=>e+t.count,0),a=new Set(t.map(e=>e.service)).size;return e.json({totalLogs:n,errors:i,services:a,breakdown:t})}catch(t){return console.error(`Failed to get statistics:`,t),e.json({error:`Failed to get statistics`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/metrics`,async e=>{try{let t=me.parse({groupBy:e.req.query(`groupBy`),startTime:e.req.query(`startTime`),endTime:e.req.query(`endTime`),period:e.req.query(`period`),bucket:e.req.query(`bucket`),sessionId:e.req.query(`sessionId`),workflowRunId:e.req.query(`workflowRunId`),workflowName:e.req.query(`workflowName`),jobName:e.req.query(`jobName`),stepName:e.req.query(`stepName`),agentName:e.req.query(`agentName`),service:j(e,`service`),model:j(e,`model`),provider:j(e,`provider`),limit:e.req.query(`limit`),sort:e.req.query(`sort`),toolLimit:e.req.query(`toolLimit`),toolSort:e.req.query(`toolSort`)}),n=await a.getMetrics({sessionId:t.sessionId,workflowRunId:t.workflowRunId,workflowName:t.workflowName,jobName:t.jobName,stepName:t.stepName,agentName:t.agentName,service:t.service,model:t.model,provider:t.provider,startTime:t.startTime?new Date(t.startTime):void 0,endTime:t.endTime?new Date(t.endTime):void 0},{groupBy:t.groupBy,sort:t.sort,toolSort:t.toolSort,limit:t.limit,toolLimit:t.toolLimit,period:t.period,bucket:t.bucket});return e.json(n)}catch(t){return console.error(`Failed to get metrics:`,t),e.json({error:`Failed to get metrics`,message:t instanceof Error?t.message:String(t)},500)}}),t}function ge(e){return e.toLocaleString(`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}const _e=`controls-section`,M=`input-field`,N=`table-container`,ve=`log-table`,ye=`compact-table`,be=`level-trace`,xe=`level-debug`,Se=`level-info`,Ce=`level-warn`,we=`level-error`,Te=`level-fatal`,Ee=`stats-container`,P=`stat-card`,De=`trace-link`,Oe=`timestamp-cell`,ke=`service-cell`,Ae=`pagination-btn`,je=`log-entry-group`,Me=`metadata-row`,Ne=`message-row`,Pe=`message-full-cell`;function Fe(e){let t=e.toLowerCase();return t===`trace`?be:t===`debug`?xe:t===`info`?Se:t===`warn`?Ce:t===`error`?we:t===`fatal`?Te:``}function Ie(e){if(!e||typeof e!=`object`)return null;let t=e,n={};for(let[e,r]of Object.entries(t))e!==`trace.id`&&e!==`span.id`&&(n[e]=r);return Object.keys(n).length>0?n:null}function Le({logs:e}){return/* @__PURE__ */ k(`div`,{class:N,children:/* @__PURE__ */ A(`table`,{class:ve,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Timestamp`}),/* @__PURE__ */ k(`th`,{children:`Level`}),/* @__PURE__ */ k(`th`,{children:`Service`}),/* @__PURE__ */ k(`th`,{children:`Trace ID`})]})}),e.map(e=>{let t=Ie(e.metadata);return/* @__PURE__ */ A(`tbody`,{class:je,children:[/* @__PURE__ */ A(`tr`,{class:Me,children:[/* @__PURE__ */ k(`td`,{class:Oe,children:ge(e.timestamp)}),/* @__PURE__ */ k(`td`,{class:Fe(e.level),children:e.level.toUpperCase()}),/* @__PURE__ */ k(`td`,{class:ke,children:e.service}),/* @__PURE__ */ k(`td`,{children:e.traceId?/* @__PURE__ */ A(`span`,{class:De,onclick:`dashboard.filterByTrace('${e.traceId}')`,children:[e.traceId.slice(0,8),`...`]}):/* @__PURE__ */ k(`span`,{children:`-`})})]}),/* @__PURE__ */ k(`tr`,{class:Ne,children:/* @__PURE__ */ A(`td`,{colspan:4,class:Pe,children:[/* @__PURE__ */ k(`div`,{children:e.message}),t&&/* @__PURE__ */ k(`pre`,{class:`attributes-cell`,children:JSON.stringify(t,null,2)})]})})]},e.id)})]})})}function F(e){return Math.round(e).toLocaleString()}function Re(e){return`${e.toFixed(1)}%`}function ze(e){return e?e.toISOString():`-`}function Be({metrics:e}){return/* @__PURE__ */ A(`section`,{class:`metrics-section`,children:[/* @__PURE__ */ k(`div`,{class:`section-header`,children:/* @__PURE__ */ k(`h2`,{children:`Workflow Metrics`})}),/* @__PURE__ */ A(`div`,{class:_e,children:[/* @__PURE__ */ k(`input`,{id:`metrics-model-filter`,class:M,type:`text`,placeholder:`Model`}),/* @__PURE__ */ k(`input`,{id:`metrics-provider-filter`,class:M,type:`text`,placeholder:`Provider`}),/* @__PURE__ */ k(`button`,{type:`button`,class:`btn`,onclick:`dashboard.fetchMetrics()`,children:`Apply Metrics Filters`})]}),/* @__PURE__ */ A(`div`,{id:`metrics-summary`,class:Ee,children:[/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Workflow Runs`}),/* @__PURE__ */ k(`div`,{id:`metrics-group-count`,class:`value`,children:e.totals.groupCount.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Failed Runs`}),/* @__PURE__ */ k(`div`,{id:`metrics-failed-groups`,class:`value`,children:e.totals.failedGroups.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Total Tokens`}),/* @__PURE__ */ k(`div`,{id:`metrics-total-tokens`,class:`value`,children:F(e.totals.totalTokens)})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Token Coverage`}),/* @__PURE__ */ k(`div`,{id:`metrics-token-coverage`,class:`value`,children:Re(e.totals.tokenCoveragePercent)})]})]}),/* @__PURE__ */ A(`div`,{class:`metrics-grid`,children:[/* @__PURE__ */ A(`div`,{class:N,children:[/* @__PURE__ */ k(`h3`,{children:`Top Workflow Runs`}),/* @__PURE__ */ A(`table`,{class:ye,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Workflow`}),/* @__PURE__ */ k(`th`,{children:`Last Seen`}),/* @__PURE__ */ k(`th`,{children:`Tokens`}),/* @__PURE__ */ k(`th`,{children:`Issues`})]})}),/* @__PURE__ */ k(`tbody`,{id:`workflow-metrics-body`,children:e.groups.slice(0,10).map(e=>/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`td`,{children:e.key}),/* @__PURE__ */ k(`td`,{children:ze(e.lastSeen)}),/* @__PURE__ */ k(`td`,{children:F(e.totalTokens)}),/* @__PURE__ */ k(`td`,{children:e.issueCount.toLocaleString()})]}))})]})]}),/* @__PURE__ */ A(`div`,{class:N,children:[/* @__PURE__ */ k(`h3`,{children:`Top Tools By Token Use`}),/* @__PURE__ */ A(`table`,{class:ye,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Tool`}),/* @__PURE__ */ k(`th`,{children:`Invocations`}),/* @__PURE__ */ k(`th`,{children:`Call p90`}),/* @__PURE__ */ k(`th`,{children:`Output p90`})]})}),/* @__PURE__ */ k(`tbody`,{id:`tool-metrics-body`,children:e.tools.rows.slice(0,10).map(e=>/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`td`,{children:e.toolName}),/* @__PURE__ */ k(`td`,{children:e.invocationCount.toLocaleString()}),/* @__PURE__ */ k(`td`,{children:F(e.toolCallTurn.p90TotalTokens)}),/* @__PURE__ */ k(`td`,{children:F(e.toolOutputImpact.p90TotalTokens)})]}))})]})]})]})]})}function Ve(){return/* @__PURE__ */ k(`input`,{id:`search-input`,type:`text`,class:M,placeholder:`Search logs...`,oninput:`dashboard.handleSearchInput(event)`})}function He({services:e}){return/* @__PURE__ */ A(`select`,{id:`service-select`,class:`select-field`,onchange:`dashboard.handleServiceChange(event)`,children:[/* @__PURE__ */ k(`option`,{value:``,children:`All Services`}),e.map(e=>/* @__PURE__ */ k(`option`,{value:e,children:e},e))]})}function Ue({stats:e}){return/* @__PURE__ */ A(`div`,{class:Ee,children:[/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Total Logs`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.totalLogs.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Errors`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.errors.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Services`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.services})]})]})}function We({initialLogs:e,services:t,stats:n,metrics:r}){return/* @__PURE__ */ A(`div`,{class:`dashboard-container`,children:[/* @__PURE__ */ A(`div`,{class:`dashboard-header`,children:[/* @__PURE__ */ k(`h1`,{children:`Log Dashboard`}),/* @__PURE__ */ k(`p`,{children:`Real-time log streaming with auto-refresh (3 seconds)`})]}),/* @__PURE__ */ k(Ue,{stats:n}),/* @__PURE__ */ k(Be,{metrics:r}),/* @__PURE__ */ A(`div`,{class:_e,children:[/* @__PURE__ */ k(Ve,{}),/* @__PURE__ */ k(He,{services:t}),/* @__PURE__ */ k(`button`,{type:`button`,id:`refresh-btn`,class:`btn`,onclick:`dashboard.manualRefresh()`,children:`Refresh Now`})]}),/* @__PURE__ */ k(Le,{logs:e}),/* @__PURE__ */ A(`div`,{id:`pagination-controls`,class:`pagination-container`,children:[/* @__PURE__ */ k(`button`,{type:`button`,id:`prev-btn`,class:Ae,onclick:`dashboard.prevPage()`,disabled:!0,children:`Previous`}),/* @__PURE__ */ k(`span`,{id:`page-info`,class:`page-info`,children:`Page 1`}),/* @__PURE__ */ k(`button`,{type:`button`,id:`next-btn`,class:Ae,onclick:`dashboard.nextPage()`,children:`Next`})]}),/* @__PURE__ */ k(`script`,{children:de(`
|
|
2
|
+
import{a as e,o as t,u as n}from"./LogStorageService-FUtAkl3y.mjs";import{i as r,n as i,r as a,t as o}from"./container-DATXzAs6.mjs";import{i as s,n as c,r as l}from"./logSinkConfig-BnOw8fWp.mjs";import{d as u}from"./node-BHLaIwwU.mjs";import{a as d,c as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./stdio-DVTvHUla.mjs";import{z as y}from"zod";import{readFileSync as b}from"node:fs";import*as x from"node:fs/promises";import ee,{dirname as S,join as te}from"node:path";import{execFile as ne}from"node:child_process";import{promisify as C}from"node:util";import{fileURLToPath as re}from"node:url";import{DEFAULT_PORT_RANGE as w,PortRegistryService as ie}from"@agimon-ai/foundation-port-registry";import{createProcessLease as T,createProcessRegistryService as ae,resolveSiblingRegistryPath as E}from"@agimon-ai/foundation-process-registry";import{Command as D,InvalidArgumentError as O}from"commander";import{serve as oe}from"@hono/node-server";import{createHash as se}from"node:crypto";import{Hono as ce}from"hono";import{rateLimiter as le}from"hono-rate-limiter";import{cors as ue}from"hono/cors";import{raw as de}from"hono/html";import{jsx as k,jsxs as A}from"hono/jsx/jsx-runtime";var fe=`0.0.1-alpha.23`;const pe=y.object({service:y.string().optional(),level:y.string().optional(),traceId:y.string().optional(),search:y.string().optional(),limit:y.coerce.number().min(1).max(1e3).default(25),offset:y.coerce.number().min(0).default(0)}),me=y.object({groupBy:y.enum([`session`,`workflow-run`,`workflow-name`,`job`,`step`,`agent`,`model`,`provider`]).optional(),startTime:y.string().optional(),endTime:y.string().optional(),period:y.enum([`day`,`week`,`month`,`all`]).optional(),bucket:y.enum([`hour`,`day`,`week`,`month`]).optional(),sessionId:y.string().optional(),workflowRunId:y.string().optional(),workflowName:y.string().optional(),jobName:y.string().optional(),stepName:y.string().optional(),agentName:y.string().optional(),service:y.array(y.string()).optional(),model:y.array(y.string()).optional(),provider:y.array(y.string()).optional(),limit:y.coerce.number().min(1).max(500).optional(),sort:y.enum([`last-seen`,`total-tokens`,`issues`]).optional(),toolLimit:y.coerce.number().min(1).max(500).optional(),toolSort:y.enum([`p90-total-tokens`,`avg-total-tokens`,`invocations`]).optional()});function j(e,t){let n=e.req.queries(t)??[],r=e.req.query(t),i=(n.length>0?n:r?[r]:[]).flatMap(e=>e.split(`,`)).map(e=>e.trim()).filter(e=>e.length>0);return i.length>0?i:void 0}function he(e){let t=new ce,r=e.get(n.LogQueryService),i=e.get(n.LogSearchService),a=e.get(n.LogMetricsService);return t.get(`/logs`,async e=>{try{let{service:t,level:n,traceId:a,search:o,limit:s,offset:c}=pe.parse({service:e.req.query(`service`),level:e.req.query(`level`),traceId:e.req.query(`traceId`),search:e.req.query(`search`),limit:e.req.query(`limit`),offset:e.req.query(`offset`)}),l,u=0;if(o){let e={};t&&(e.service=t),n&&(e.level=n);let r=await i.searchLogsPaginated(o,{...e,offset:c},s);l=r.results,u=r.total}else{let e=n?n.split(`,`):[`info`,`warn`,`error`,`fatal`],i=await r.queryLogs({level:e,service:t||void 0,traceId:a||void 0,limit:s,offset:c});l=i.logs,u=i.total}return e.json({logs:l,total:u,hasMore:c+s<u})}catch(t){return console.error(`Failed to query logs:`,t),e.json({error:`Failed to query logs`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/services`,async e=>{try{let t=await r.getActiveServices();return e.json({services:t,total:t.length})}catch(t){return console.error(`Failed to get services:`,t),e.json({error:`Failed to get services`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/stats`,async e=>{try{let t=await r.getStatistics(),n=t.reduce((e,t)=>e+t.count,0),i=t.filter(e=>e.level===`error`||e.level===`fatal`).reduce((e,t)=>e+t.count,0),a=new Set(t.map(e=>e.service)).size;return e.json({totalLogs:n,errors:i,services:a,breakdown:t})}catch(t){return console.error(`Failed to get statistics:`,t),e.json({error:`Failed to get statistics`,message:t instanceof Error?t.message:String(t)},500)}}),t.get(`/metrics`,async e=>{try{let t=me.parse({groupBy:e.req.query(`groupBy`),startTime:e.req.query(`startTime`),endTime:e.req.query(`endTime`),period:e.req.query(`period`),bucket:e.req.query(`bucket`),sessionId:e.req.query(`sessionId`),workflowRunId:e.req.query(`workflowRunId`),workflowName:e.req.query(`workflowName`),jobName:e.req.query(`jobName`),stepName:e.req.query(`stepName`),agentName:e.req.query(`agentName`),service:j(e,`service`),model:j(e,`model`),provider:j(e,`provider`),limit:e.req.query(`limit`),sort:e.req.query(`sort`),toolLimit:e.req.query(`toolLimit`),toolSort:e.req.query(`toolSort`)}),n=await a.getMetrics({sessionId:t.sessionId,workflowRunId:t.workflowRunId,workflowName:t.workflowName,jobName:t.jobName,stepName:t.stepName,agentName:t.agentName,service:t.service,model:t.model,provider:t.provider,startTime:t.startTime?new Date(t.startTime):void 0,endTime:t.endTime?new Date(t.endTime):void 0},{groupBy:t.groupBy,sort:t.sort,toolSort:t.toolSort,limit:t.limit,toolLimit:t.toolLimit,period:t.period,bucket:t.bucket});return e.json(n)}catch(t){return console.error(`Failed to get metrics:`,t),e.json({error:`Failed to get metrics`,message:t instanceof Error?t.message:String(t)},500)}}),t}function ge(e){return e.toLocaleString(`en-US`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}const _e=`controls-section`,M=`input-field`,N=`table-container`,ve=`log-table`,ye=`compact-table`,be=`level-trace`,xe=`level-debug`,Se=`level-info`,Ce=`level-warn`,we=`level-error`,Te=`level-fatal`,Ee=`stats-container`,P=`stat-card`,De=`trace-link`,Oe=`timestamp-cell`,ke=`service-cell`,Ae=`pagination-btn`,je=`log-entry-group`,Me=`metadata-row`,Ne=`message-row`,Pe=`message-full-cell`;function Fe(e){let t=e.toLowerCase();return t===`trace`?be:t===`debug`?xe:t===`info`?Se:t===`warn`?Ce:t===`error`?we:t===`fatal`?Te:``}function Ie(e){if(!e||typeof e!=`object`)return null;let t=e,n={};for(let[e,r]of Object.entries(t))e!==`trace.id`&&e!==`span.id`&&(n[e]=r);return Object.keys(n).length>0?n:null}function Le({logs:e}){return/* @__PURE__ */ k(`div`,{class:N,children:/* @__PURE__ */ A(`table`,{class:ve,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Timestamp`}),/* @__PURE__ */ k(`th`,{children:`Level`}),/* @__PURE__ */ k(`th`,{children:`Service`}),/* @__PURE__ */ k(`th`,{children:`Trace ID`})]})}),e.map(e=>{let t=Ie(e.metadata);return/* @__PURE__ */ A(`tbody`,{class:je,children:[/* @__PURE__ */ A(`tr`,{class:Me,children:[/* @__PURE__ */ k(`td`,{class:Oe,children:ge(e.timestamp)}),/* @__PURE__ */ k(`td`,{class:Fe(e.level),children:e.level.toUpperCase()}),/* @__PURE__ */ k(`td`,{class:ke,children:e.service}),/* @__PURE__ */ k(`td`,{children:e.traceId?/* @__PURE__ */ A(`span`,{class:De,onclick:`dashboard.filterByTrace('${e.traceId}')`,children:[e.traceId.slice(0,8),`...`]}):/* @__PURE__ */ k(`span`,{children:`-`})})]}),/* @__PURE__ */ k(`tr`,{class:Ne,children:/* @__PURE__ */ A(`td`,{colspan:4,class:Pe,children:[/* @__PURE__ */ k(`div`,{children:e.message}),t&&/* @__PURE__ */ k(`pre`,{class:`attributes-cell`,children:JSON.stringify(t,null,2)})]})})]},e.id)})]})})}function F(e){return Math.round(e).toLocaleString()}function Re(e){return`${e.toFixed(1)}%`}function ze(e){return e?e.toISOString():`-`}function Be({metrics:e}){return/* @__PURE__ */ A(`section`,{class:`metrics-section`,children:[/* @__PURE__ */ k(`div`,{class:`section-header`,children:/* @__PURE__ */ k(`h2`,{children:`Workflow Metrics`})}),/* @__PURE__ */ A(`div`,{class:_e,children:[/* @__PURE__ */ k(`input`,{id:`metrics-model-filter`,class:M,type:`text`,placeholder:`Model`}),/* @__PURE__ */ k(`input`,{id:`metrics-provider-filter`,class:M,type:`text`,placeholder:`Provider`}),/* @__PURE__ */ k(`button`,{type:`button`,class:`btn`,onclick:`dashboard.fetchMetrics()`,children:`Apply Metrics Filters`})]}),/* @__PURE__ */ A(`div`,{id:`metrics-summary`,class:Ee,children:[/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Workflow Runs`}),/* @__PURE__ */ k(`div`,{id:`metrics-group-count`,class:`value`,children:e.totals.groupCount.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Failed Runs`}),/* @__PURE__ */ k(`div`,{id:`metrics-failed-groups`,class:`value`,children:e.totals.failedGroups.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Total Tokens`}),/* @__PURE__ */ k(`div`,{id:`metrics-total-tokens`,class:`value`,children:F(e.totals.totalTokens)})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Token Coverage`}),/* @__PURE__ */ k(`div`,{id:`metrics-token-coverage`,class:`value`,children:Re(e.totals.tokenCoveragePercent)})]})]}),/* @__PURE__ */ A(`div`,{class:`metrics-grid`,children:[/* @__PURE__ */ A(`div`,{class:N,children:[/* @__PURE__ */ k(`h3`,{children:`Top Workflow Runs`}),/* @__PURE__ */ A(`table`,{class:ye,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Workflow`}),/* @__PURE__ */ k(`th`,{children:`Last Seen`}),/* @__PURE__ */ k(`th`,{children:`Tokens`}),/* @__PURE__ */ k(`th`,{children:`Issues`})]})}),/* @__PURE__ */ k(`tbody`,{id:`workflow-metrics-body`,children:e.groups.slice(0,10).map(e=>/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`td`,{children:e.key}),/* @__PURE__ */ k(`td`,{children:ze(e.lastSeen)}),/* @__PURE__ */ k(`td`,{children:F(e.totalTokens)}),/* @__PURE__ */ k(`td`,{children:e.issueCount.toLocaleString()})]}))})]})]}),/* @__PURE__ */ A(`div`,{class:N,children:[/* @__PURE__ */ k(`h3`,{children:`Top Tools By Token Use`}),/* @__PURE__ */ A(`table`,{class:ye,children:[/* @__PURE__ */ k(`thead`,{children:/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`th`,{children:`Tool`}),/* @__PURE__ */ k(`th`,{children:`Invocations`}),/* @__PURE__ */ k(`th`,{children:`Call p90`}),/* @__PURE__ */ k(`th`,{children:`Output p90`})]})}),/* @__PURE__ */ k(`tbody`,{id:`tool-metrics-body`,children:e.tools.rows.slice(0,10).map(e=>/* @__PURE__ */ A(`tr`,{children:[/* @__PURE__ */ k(`td`,{children:e.toolName}),/* @__PURE__ */ k(`td`,{children:e.invocationCount.toLocaleString()}),/* @__PURE__ */ k(`td`,{children:F(e.toolCallTurn.p90TotalTokens)}),/* @__PURE__ */ k(`td`,{children:F(e.toolOutputImpact.p90TotalTokens)})]}))})]})]})]})]})}function Ve(){return/* @__PURE__ */ k(`input`,{id:`search-input`,type:`text`,class:M,placeholder:`Search logs...`,oninput:`dashboard.handleSearchInput(event)`})}function He({services:e}){return/* @__PURE__ */ A(`select`,{id:`service-select`,class:`select-field`,onchange:`dashboard.handleServiceChange(event)`,children:[/* @__PURE__ */ k(`option`,{value:``,children:`All Services`}),e.map(e=>/* @__PURE__ */ k(`option`,{value:e,children:e},e))]})}function Ue({stats:e}){return/* @__PURE__ */ A(`div`,{class:Ee,children:[/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Total Logs`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.totalLogs.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Errors`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.errors.toLocaleString()})]}),/* @__PURE__ */ A(`div`,{class:P,children:[/* @__PURE__ */ k(`h3`,{children:`Services`}),/* @__PURE__ */ k(`div`,{class:`value`,children:e.services})]})]})}function We({initialLogs:e,services:t,stats:n,metrics:r}){return/* @__PURE__ */ A(`div`,{class:`dashboard-container`,children:[/* @__PURE__ */ A(`div`,{class:`dashboard-header`,children:[/* @__PURE__ */ k(`h1`,{children:`Log Dashboard`}),/* @__PURE__ */ k(`p`,{children:`Real-time log streaming with auto-refresh (3 seconds)`})]}),/* @__PURE__ */ k(Ue,{stats:n}),/* @__PURE__ */ k(Be,{metrics:r}),/* @__PURE__ */ A(`div`,{class:_e,children:[/* @__PURE__ */ k(Ve,{}),/* @__PURE__ */ k(He,{services:t}),/* @__PURE__ */ k(`button`,{type:`button`,id:`refresh-btn`,class:`btn`,onclick:`dashboard.manualRefresh()`,children:`Refresh Now`})]}),/* @__PURE__ */ k(Le,{logs:e}),/* @__PURE__ */ A(`div`,{id:`pagination-controls`,class:`pagination-container`,children:[/* @__PURE__ */ k(`button`,{type:`button`,id:`prev-btn`,class:Ae,onclick:`dashboard.prevPage()`,disabled:!0,children:`Previous`}),/* @__PURE__ */ k(`span`,{id:`page-info`,class:`page-info`,children:`Page 1`}),/* @__PURE__ */ k(`button`,{type:`button`,id:`next-btn`,class:Ae,onclick:`dashboard.nextPage()`,children:`Next`})]}),/* @__PURE__ */ k(`script`,{children:de(`
|
|
3
3
|
class DashboardManager {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.filters = {
|