@atolis-hq/wake 0.4.59 → 0.4.60

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.
@@ -6,7 +6,7 @@ export declare function createAnalyticsReports(journal: EventJournal, now: () =>
6
6
  title: string;
7
7
  }[];
8
8
  report(id: string, windowId: ReportWindowId, signal?: AbortSignal): Promise<{
9
- data: import("../kernel/index.js").TimeSeriesReport;
9
+ data: import("../kernel/index.js").AnalyticsReport;
10
10
  meta: import("../surfaces/index.js").ResponseMeta;
11
11
  }>;
12
12
  summary(windowId: ReportWindowId, signal?: AbortSignal): Promise<{
@@ -1,9 +1,12 @@
1
- import { createRunOutcomesReport, queryRunAnalytics } from '../execution/index.js';
1
+ import { createRunBreakdownReport, createRunOutcomesReport, queryRunAnalytics, } from '../execution/index.js';
2
2
  import { reportWindow } from '../kernel/index.js';
3
3
  import { queryWorkCompletionSummary } from '../orchestration/index.js';
4
4
  import { sampledMeta } from './surface-api-metadata.js';
5
5
  export function createAnalyticsReports(journal, now) {
6
- const definitions = [createRunOutcomesReport(journal)];
6
+ const definitions = [
7
+ createRunOutcomesReport(journal),
8
+ createRunBreakdownReport(journal),
9
+ ];
7
10
  return {
8
11
  catalogue: () => definitions.map(({ id, title }) => ({ id, title })),
9
12
  async report(id, windowId, signal) {
@@ -124,6 +124,6 @@ export function resolveWakeVersion(options = {}) {
124
124
  return `g${headHash.slice(0, 7)}`;
125
125
  return '0.1.0-dev';
126
126
  }
127
- export const wakeVersion = "v0.4.59";
127
+ export const wakeVersion = "v0.4.60";
128
128
  /** The registry-installable version used by packaged sandbox images. */
129
129
  export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
@@ -1,9 +1,20 @@
1
1
  import { type EventJournal } from '@atolis-hq/eventing';
2
- import { type ReportDefinition, type ReportQuery, type TimeSeriesReport, type ValueOf } from '../../kernel/index.js';
2
+ import { type BreakdownReport, type ReportDefinition, type ReportQuery, type TimeSeriesReport, type ValueOf } from '../../kernel/index.js';
3
3
  import type { RunView } from '../contracts/views.js';
4
4
  export declare const RunReportId: {
5
5
  readonly Outcomes: "run-outcomes-over-time";
6
+ readonly Breakdown: "run-breakdowns-by-dimension";
6
7
  };
8
+ export declare const RunReportDimension: {
9
+ readonly Action: "run-action";
10
+ readonly Stage: "run-stage";
11
+ readonly Runner: "run-runner";
12
+ readonly Model: "run-model";
13
+ };
14
+ export declare const RunReportValue: {
15
+ readonly Unknown: "unknown";
16
+ };
17
+ export declare function createRunBreakdownReport(journal: EventJournal): ReportDefinition;
7
18
  export declare const RunReportOutcome: {
8
19
  readonly Completed: "completed";
9
20
  readonly Blocked: "blocked";
@@ -25,5 +36,6 @@ export declare function runReportOutcome(run: RunView): RunReportOutcome;
25
36
  export declare function createRunOutcomesReport(journal: EventJournal): ReportDefinition;
26
37
  export declare function queryRunAnalytics(journal: EventJournal, query: ReportQuery): Promise<{
27
38
  report: TimeSeriesReport;
39
+ breakdown: BreakdownReport;
28
40
  summary: RunSummary;
29
41
  }>;
@@ -5,7 +5,30 @@ import { selectRunExecutionEvent } from '../contracts/events.js';
5
5
  import { agentTokenUsage } from '../contracts/runner.js';
6
6
  import { RunStatus } from '../contracts/vocabulary.js';
7
7
  import { foldRunEvent } from '../domain/run.js';
8
- export const RunReportId = defineClosedVocabulary({ Outcomes: 'run-outcomes-over-time' });
8
+ export const RunReportId = defineClosedVocabulary({
9
+ Outcomes: 'run-outcomes-over-time',
10
+ Breakdown: 'run-breakdowns-by-dimension',
11
+ });
12
+ export const RunReportDimension = defineClosedVocabulary({
13
+ Action: 'run-action',
14
+ Stage: 'run-stage',
15
+ Runner: 'run-runner',
16
+ Model: 'run-model',
17
+ });
18
+ export const RunReportValue = defineClosedVocabulary({ Unknown: 'unknown' });
19
+ const dimensions = [
20
+ { id: RunReportDimension.Action, title: 'Action', value: (run) => run.activity },
21
+ { id: RunReportDimension.Stage, title: 'Stage', value: (run) => run.stage },
22
+ { id: RunReportDimension.Runner, title: 'Runner', value: (run) => run.runner?.name },
23
+ { id: RunReportDimension.Model, title: 'Model', value: (run) => run.runner?.model },
24
+ ];
25
+ export function createRunBreakdownReport(journal) {
26
+ return {
27
+ id: RunReportId.Breakdown,
28
+ title: 'Run breakdowns by dimension',
29
+ query: async (query) => (await queryRunAnalytics(journal, query)).breakdown,
30
+ };
31
+ }
9
32
  export const RunReportOutcome = defineClosedVocabulary({
10
33
  Completed: 'completed',
11
34
  Blocked: 'blocked',
@@ -67,6 +90,7 @@ export async function queryRunAnalytics(journal, query) {
67
90
  });
68
91
  const totals = zero();
69
92
  const durations = [];
93
+ const counts = dimensions.map(() => new Map());
70
94
  let runs = 0, totalTokens = 0, totalCostUsd = 0, processed = 0;
71
95
  for (const run of grouped.values()) {
72
96
  if (processed++ % 100 === 0)
@@ -78,6 +102,11 @@ export async function queryRunAnalytics(journal, query) {
78
102
  totals[outcome]++;
79
103
  buckets[Math.floor((start - first) / query.window.bucketMs)].values[outcome]++;
80
104
  runs++;
105
+ dimensions.forEach((dimension, index) => {
106
+ const value = dimension.value(run) ?? RunReportValue.Unknown;
107
+ const groups = counts[index];
108
+ groups.set(value, (groups.get(value) ?? 0) + 1);
109
+ });
81
110
  const usage = agentTokenUsage(run.agent?.metadata);
82
111
  totalTokens += finiteOrZero(usage.tokens);
83
112
  totalCostUsd += finiteOrZero(usage.costUsd);
@@ -94,6 +123,18 @@ export async function queryRunAnalytics(journal, query) {
94
123
  totals,
95
124
  buckets,
96
125
  },
126
+ breakdown: {
127
+ report: { id: RunReportId.Breakdown, title: 'Run breakdowns by dimension' },
128
+ window: query.window,
129
+ total: runs,
130
+ dimensions: dimensions.map(({ id, title }, index) => ({
131
+ id,
132
+ title,
133
+ rows: [...counts[index].entries()]
134
+ .sort(([a, ac], [b, bc]) => bc - ac || (a < b ? -1 : a > b ? 1 : 0))
135
+ .map(([value, count]) => ({ value, count, share: count / runs })),
136
+ })),
137
+ },
97
138
  summary: {
98
139
  runs,
99
140
  completed: totals[RunReportOutcome.Completed],
@@ -31,8 +31,21 @@ export interface TimeSeriesReport {
31
31
  readonly values: Readonly<Record<string, number>>;
32
32
  }[];
33
33
  }
34
+ export interface BreakdownReport {
35
+ readonly report: ReportDescriptor;
36
+ readonly window: ReportWindow;
37
+ readonly total: number;
38
+ readonly dimensions: readonly (ReportDescriptor & {
39
+ readonly rows: readonly {
40
+ readonly value: string;
41
+ readonly count: number;
42
+ readonly share: number;
43
+ }[];
44
+ })[];
45
+ }
46
+ export type AnalyticsReport = TimeSeriesReport | BreakdownReport;
34
47
  export interface ReportDefinition extends ReportDescriptor {
35
- query(query: ReportQuery): Promise<TimeSeriesReport>;
48
+ query(query: ReportQuery): Promise<AnalyticsReport>;
36
49
  }
37
50
  export declare function reportWindow(id: ReportWindowId, now: string): ReportWindow;
38
51
  /** Exact median with bounded sorting/merging work between caller-supplied pauses. */
@@ -10,7 +10,7 @@ export interface MetricsResponse {
10
10
  readonly values: Readonly<Record<string, number>>;
11
11
  }
12
12
  export { ReportWindowId } from '../../../kernel/index.js';
13
- export type { ReportWindowId as AnalyticsReportWindowId, ReportDescriptor, ReportWindow, TimeSeriesReport, } from '../../../kernel/index.js';
13
+ export type { AnalyticsReport, ReportWindowId as AnalyticsReportWindowId, BreakdownReport, ReportDescriptor, ReportWindow, TimeSeriesReport, } from '../../../kernel/index.js';
14
14
  export interface AnalyticsSummaryResponse {
15
15
  readonly window: ReportWindow;
16
16
  readonly runs: number;
@@ -1,5 +1,5 @@
1
1
  import type { RunStatus } from '../../../execution/index.js';
2
- import type { ReportDescriptor, ReportWindowId, TimeSeriesReport } from '../../../kernel/index.js';
2
+ import type { AnalyticsReport, ReportDescriptor, ReportWindowId } from '../../../kernel/index.js';
3
3
  import type { ApiCommandResult, AuditEventResponse, BoardCardResponse, BoardResponse, CommandsResponse, ConfigurationResponse, ControlPlaneStatusResponse, ConversationMessageRequest, HealthResponse, MetricsResponse, ResourceItemResponse, ResourceResponse, ResponseMeta, RunnerResponse, RunResponse, RunTranscriptResponse, StatusResponse, WebhookSetupResponse, WorkDetailResponse, WorkflowDiagramsResponse, WorkflowInstanceResponse, WorkItemResponse, WorkItemTranscriptResponse } from '../contracts/index.js';
4
4
  import type { AnalyticsSummaryResponse } from '../contracts/observability.js';
5
5
  export interface CollectionQuery {
@@ -94,7 +94,7 @@ export interface ApiApplications {
94
94
  readonly observability: {
95
95
  readonly reports?: {
96
96
  catalogue(): readonly ReportDescriptor[];
97
- report(id: string, window: ReportWindowId, signal?: AbortSignal): Promise<ApiResourceResult<TimeSeriesReport>>;
97
+ report(id: string, window: ReportWindowId, signal?: AbortSignal): Promise<ApiResourceResult<AnalyticsReport>>;
98
98
  summary(window: ReportWindowId, signal?: AbortSignal): Promise<ApiResourceResult<AnalyticsSummaryResponse>>;
99
99
  };
100
100
  metrics(query?: {