@agimon-ai/po-log 0.0.0-alpha.150 → 0.0.0-alpha.151

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.
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
  //#endregion
27
27
  const require_metricsSource = require("../metricsSource-CF3cp-sf.cjs");
28
- const require_metricsStore = require("../metricsStore-BuCMM2ny.cjs");
28
+ const require_metricsStore = require("../metricsStore-nGI-c5NH.cjs");
29
29
  let _agimon_ai_po_logsink = require("@agimon-ai/po-logsink");
30
30
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
31
31
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
@@ -1063,6 +1063,12 @@ var apiRoutes_default = (0, _agimon_ai_po_core_web.defineApiRoutes)({
1063
1063
  query: [METRICS_QUERY_PARAMS.focus],
1064
1064
  response: (0, _agimon_ai_po_core_web.apiResponse)()
1065
1065
  },
1066
+ /** The resources the host meters for its own account. Empty on a host that meters none. */
1067
+ usage: {
1068
+ method: "GET",
1069
+ path: "/usage",
1070
+ response: (0, _agimon_ai_po_core_web.apiResponse)()
1071
+ },
1066
1072
  /**
1067
1073
  * OTLP/JSON logs from clients that run no collector of their own, such as the
1068
1074
  * native app. Forwarded unchanged to the sink, which validates and redacts.
@@ -1287,6 +1293,14 @@ function createLogHubApi(options = {}) {
1287
1293
  return context.json(unavailable);
1288
1294
  }
1289
1295
  });
1296
+ app.get(apiRoutes_default.usage.path, async (context) => {
1297
+ try {
1298
+ const rows = await options.usage?.()?.read() ?? [];
1299
+ return context.json({ rows });
1300
+ } catch (error) {
1301
+ return context.json({ error: error instanceof Error ? error.message : "The usage read failed." }, 502);
1302
+ }
1303
+ });
1290
1304
  /**
1291
1305
  * Logs from clients with no collector of their own. The sink validates,
1292
1306
  * redacts and rate-limits OTLP itself, so this only bounds the size and
@@ -1320,7 +1334,7 @@ function createLogHubApi(options = {}) {
1320
1334
  * The package's API for a host. `metrics` resolves the store the host bound, if any, so a host that keeps its
1321
1335
  * own metrics answers from them and every other host keeps answering from the log sink.
1322
1336
  */
1323
- function createLogApi(metrics) {
1337
+ function createLogApi(metrics, usage) {
1324
1338
  return {
1325
1339
  basePath: "log",
1326
1340
  start(context) {
@@ -1333,7 +1347,8 @@ function createLogApi(metrics) {
1333
1347
  const app = createLogHubApi({
1334
1348
  source,
1335
1349
  env,
1336
- ...metrics === void 0 ? {} : { metrics }
1350
+ ...metrics === void 0 ? {} : { metrics },
1351
+ ...usage === void 0 ? {} : { usage }
1337
1352
  });
1338
1353
  return {
1339
1354
  fetch: (request) => app.fetch(request),
@@ -1345,7 +1360,7 @@ function createLogApi(metrics) {
1345
1360
  //#endregion
1346
1361
  //#region src/extensions/(backend)/api/log/route.server.ts
1347
1362
  /** The store is resolved per request: a host that keeps its own metrics binds it after this API mounts. */
1348
- var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({ context }) => createLogApi(() => (0, _agimon_ai_po_core_serverPlugin.readPoServerScope)(context)?.resolve(require_metricsStore.PO_LOG_METRICS_CONTRACT)));
1363
+ var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({ context }) => createLogApi(() => (0, _agimon_ai_po_core_serverPlugin.readPoServerScope)(context)?.resolve(require_metricsStore.PO_LOG_METRICS_CONTRACT), () => (0, _agimon_ai_po_core_serverPlugin.readPoServerScope)(context)?.resolve(require_metricsStore.PO_LOG_HOST_USAGE_CONTRACT)));
1349
1364
  //#endregion
1350
1365
  //#region src/extensions/workspaces/sessions/(backend)/command/log-metrics.server.ts
1351
1366
  var log_metrics_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerCommand)((context) => context.root.commands[0]);