@atolis-hq/wake 0.4.89 → 0.4.90

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.
@@ -1,6 +1,7 @@
1
1
  import type { EventJournal } from '@atolis-hq/eventing';
2
2
  import { type ReportWindowId } from '../kernel/index.js';
3
- export declare function createAnalyticsReports(journal: EventJournal, now: () => string): {
3
+ import type { ResourceRepositoryIdentityResolver } from '../resources/index.js';
4
+ export declare function createAnalyticsReports(journal: EventJournal, now: () => string, resolveIdentity?: ResourceRepositoryIdentityResolver): {
4
5
  catalogue: () => {
5
6
  id: string;
6
7
  title: string;
@@ -1,11 +1,12 @@
1
1
  import { createRunBreakdownReport, createRunDurationReport, createRunOutcomesReport, createRunUsageReport, queryRunAnalytics, } from '../execution/index.js';
2
2
  import { reportWindow } from '../kernel/index.js';
3
3
  import { createWorkThroughputReport, queryWorkCompletionSummary } from '../orchestration/index.js';
4
+ import { createRunRepositoryLookup } from './run-repository-lookup.js';
4
5
  import { sampledMeta } from './surface-api-metadata.js';
5
- export function createAnalyticsReports(journal, now) {
6
+ export function createAnalyticsReports(journal, now, resolveIdentity) {
6
7
  const definitions = [
7
8
  createRunOutcomesReport(journal),
8
- createRunBreakdownReport(journal),
9
+ createRunBreakdownReport(journal, createRunRepositoryLookup(journal, resolveIdentity)),
9
10
  createRunUsageReport(journal),
10
11
  createWorkThroughputReport(journal),
11
12
  createRunDurationReport(journal),
@@ -80,7 +80,9 @@ export interface CompositionRoot {
80
80
  readonly runnerPipeline: RunnerPipeline;
81
81
  readonly requestImmediatePoll: (adapter: string) => void;
82
82
  readonly resolveResourceLink: ResourceLinkResolver;
83
+ readonly resolveResourceRepositoryIdentity: (externalKey: Parameters<ResourceLinkResolver>[0]) => string | undefined;
83
84
  }
85
+ export declare function resolveResourceRepositoryIdentity(externalKey: Parameters<ResourceLinkResolver>[0]): string | undefined;
84
86
  export declare function createDiagnosticRoot(wakeRoot: string): Promise<{
85
87
  providers: readonly ProviderInstance[];
86
88
  providerFailures: readonly ProviderCompositionFailure[];
@@ -4,7 +4,7 @@ import { ArtifactContextService, FileArtifactMcpSessionStore, FileArtifactStore,
4
4
  import { DispatchPolicy, createActivationScheduler, createActivationSchedulerSubscriber, createControlPlaneService, createDurableRunnerIneligibility, createRunnerControlService, } from '../control-plane/index.js';
5
5
  import { createConversationService } from '../conversations/index.js';
6
6
  import { ExecutionCancellationReason, GitWorkspaceProvider, RecoveryService, TranscriptStore, createExecutionService, createLocalProcessInspector, createRunnerMemoryProfileDecorator, } from '../execution/index.js';
7
- import { createGitHubAgentContextReader, gitHubProviderDefinition, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
7
+ import { createGitHubAgentContextReader, gitHubProviderDefinition, gitHubRepositoryIdentity, resolveGitHubResourceUrl, } from '../integrations/github/index.js';
8
8
  import { SystemClock, UlidIdGenerator } from '../kernel/index.js';
9
9
  import { compileWorkflow, createAgentActivityClassifier, createOrchestrationService, } from '../orchestration/index.js';
10
10
  import { createResourceLookup, createResourceService, resourceId, } from '../resources/index.js';
@@ -24,6 +24,9 @@ import { createRunnerRegistry } from './runner-registry.js';
24
24
  import { createTranscriptRetention } from './transcript-retention.js';
25
25
  import { ProcessorTriggerCheckpointStore } from './trigger-checkpoint-store.js';
26
26
  import { createUpdateMaintenanceLease, } from './update-maintenance-lease.js';
27
+ export function resolveResourceRepositoryIdentity(externalKey) {
28
+ return externalKey.adapter === 'github' ? gitHubRepositoryIdentity(externalKey.key) : undefined;
29
+ }
27
30
  const resourceLinkResolvers = {
28
31
  github: resolveGitHubResourceUrl,
29
32
  };
@@ -272,6 +275,7 @@ export async function createCompositionRoot(wakeRoot, options = {}) {
272
275
  processorRuntime,
273
276
  advanceOnce,
274
277
  resolveResourceLink,
278
+ resolveResourceRepositoryIdentity,
275
279
  ...runtime,
276
280
  };
277
281
  }
@@ -0,0 +1,4 @@
1
+ import { type EventJournal } from '@atolis-hq/eventing';
2
+ import type { RunRepositoryLookup } from '../execution/index.js';
3
+ import { type ResourceRepositoryIdentityResolver } from '../resources/index.js';
4
+ export declare function createRunRepositoryLookup(journal: EventJournal, resolveIdentity?: ResourceRepositoryIdentityResolver): RunRepositoryLookup;
@@ -0,0 +1,59 @@
1
+ import { scanJournal, yieldScan } from '@atolis-hq/eventing';
2
+ import { OrchestrationEventType, selectWorkflowOrchestrationEvent, } from '../orchestration/index.js';
3
+ import { BuiltInResourceKind, repositoryCandidate, resourceCorrelationProjection, resourceProjection, selectResourceEvent, } from '../resources/index.js';
4
+ export function createRunRepositoryLookup(journal, resolveIdentity) {
5
+ return async (query) => {
6
+ const workByWorkflow = new Map();
7
+ const resources = new Map();
8
+ const correlations = new Map();
9
+ for await (const event of scanJournal(journal, query.signal)) {
10
+ const workflow = selectWorkflowOrchestrationEvent(event);
11
+ if (workflow?.event.eventType === OrchestrationEventType.InstanceStarted)
12
+ workByWorkflow.set(workflow.stream.id, workflow.event.payload.workItemId);
13
+ const resource = selectResourceEvent(event);
14
+ if (resource === null)
15
+ continue;
16
+ const id = resource.stream.id;
17
+ resources.set(id, resourceProjection.project(resources.get(id) ?? null, event));
18
+ correlations.set(id, resourceCorrelationProjection.project(correlations.get(id) ?? [], event));
19
+ }
20
+ const byWork = await groupCandidates(resources, correlations, query.signal);
21
+ let processed = 0;
22
+ const identities = new Map();
23
+ for (const [work, candidates] of byWork) {
24
+ if (processed++ % 100 === 0)
25
+ await yieldScan(query.signal);
26
+ identities.set(work, candidateIdentity(candidates, resolveIdentity));
27
+ }
28
+ return (run) => {
29
+ const work = workByWorkflow.get(run.workflowInstanceId);
30
+ return work === undefined ? undefined : identities.get(work);
31
+ };
32
+ };
33
+ }
34
+ async function groupCandidates(resources, correlations, signal) {
35
+ const byWork = new Map();
36
+ let processed = 0;
37
+ for (const [id, links] of correlations) {
38
+ if (processed++ % 100 === 0)
39
+ await yieldScan(signal);
40
+ signal?.throwIfAborted();
41
+ const resource = resources.get(id);
42
+ if (resource == null)
43
+ continue;
44
+ for (const link of links) {
45
+ const candidates = byWork.get(link.workItemId) ?? [];
46
+ candidates.push(resource);
47
+ byWork.set(link.workItemId, candidates);
48
+ }
49
+ }
50
+ return byWork;
51
+ }
52
+ function candidateIdentity(candidates, resolveIdentity) {
53
+ const resource = repositoryCandidate(candidates);
54
+ if (resource === undefined)
55
+ return undefined;
56
+ if (resource.kind === BuiltInResourceKind.Repository)
57
+ return resource.externalKey.key || undefined;
58
+ return resolveIdentity?.(resource.externalKey);
59
+ }
@@ -190,7 +190,7 @@ async function recentEvents(journal, beforeGlobalPosition, limit, include) {
190
190
  }
191
191
  function createObservabilityApplications(root, now) {
192
192
  return {
193
- reports: createAnalyticsReports(root.journal, now),
193
+ reports: createAnalyticsReports(root.journal, now, root.resolveResourceRepositoryIdentity),
194
194
  async metrics(query = { days: 7 }) {
195
195
  const collectedAt = now();
196
196
  const stored = await root.projections.read(analyticsProjection.name, 'global');
@@ -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.89";
127
+ export const wakeVersion = "v0.4.90";
128
128
  /** The registry-installable version used by packaged sandbox images. */
129
129
  export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
@@ -0,0 +1,10 @@
1
+ import { type DurationReport, type ReportDescriptor, type ReportQuery, type TimeSeriesReport } from '../../kernel/index.js';
2
+ import type { RunView } from '../contracts/views.js';
3
+ export declare function collectDurations(query: ReportQuery, buckets: TimeSeriesReport['buckets'], dimensions: readonly {
4
+ readonly id: string;
5
+ readonly title: string;
6
+ readonly value: (run: RunView) => string | undefined;
7
+ }[], durationDescriptor: ReportDescriptor): {
8
+ add(run: RunView, bucketIndex: number): void;
9
+ report(): Promise<DurationReport>;
10
+ };
@@ -0,0 +1,70 @@
1
+ import { yieldScan } from '@atolis-hq/eventing';
2
+ import { median, } from '../../kernel/index.js';
3
+ import { RunReportValue } from '../contracts/run-report-value.js';
4
+ function runDuration(run) {
5
+ if (run.finishedAt === undefined)
6
+ return null;
7
+ const duration = Date.parse(run.finishedAt) - Date.parse(run.startedAt);
8
+ return Number.isFinite(duration) && duration >= 0 ? duration : null;
9
+ }
10
+ export function collectDurations(query, buckets, dimensions, durationDescriptor) {
11
+ const durations = [];
12
+ const durationBuckets = buckets.map(() => []);
13
+ const durationGroups = dimensions.slice(0, 2).map(() => new Map());
14
+ return {
15
+ add(run, bucketIndex) {
16
+ const duration = runDuration(run);
17
+ if (duration !== null) {
18
+ durations.push(duration);
19
+ durationBuckets[bucketIndex].push(duration);
20
+ dimensions.slice(0, 2).forEach((dimension, index) => {
21
+ const value = dimension.value(run) ?? RunReportValue.Unknown;
22
+ const groups = durationGroups[index];
23
+ const values = groups.get(value) ?? [];
24
+ values.push(duration);
25
+ groups.set(value, values);
26
+ });
27
+ }
28
+ },
29
+ async report() {
30
+ const statistics = async (values) => {
31
+ let sum = 0;
32
+ for (const [index, value] of values.entries()) {
33
+ if (index % 1024 === 0)
34
+ await yieldScan(query.signal);
35
+ sum += value;
36
+ }
37
+ return {
38
+ count: values.length,
39
+ medianMs: await median(values, () => yieldScan(query.signal)),
40
+ averageMs: values.length === 0 ? null : sum / values.length,
41
+ };
42
+ };
43
+ const groups = [];
44
+ for (const [index, dimension] of dimensions.slice(0, 2).entries()) {
45
+ const rows = [];
46
+ for (const [value, values] of durationGroups[index]) {
47
+ await yieldScan(query.signal);
48
+ rows.push({ value, ...(await statistics(values)) });
49
+ }
50
+ rows.sort((a, b) => b.count - a.count || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0));
51
+ groups.push({ id: dimension.id, title: dimension.title, rows });
52
+ }
53
+ const durationSeries = [];
54
+ for (const [index, bucket] of buckets.entries()) {
55
+ durationSeries.push({
56
+ from: bucket.from,
57
+ to: bucket.to,
58
+ ...(await statistics(durationBuckets[index])),
59
+ });
60
+ }
61
+ return {
62
+ report: durationDescriptor,
63
+ window: query.window,
64
+ statistics: await statistics(durations),
65
+ groups,
66
+ buckets: durationSeries,
67
+ };
68
+ },
69
+ };
70
+ }
@@ -18,11 +18,12 @@ export declare const RunReportDimension: {
18
18
  readonly Stage: "run-stage";
19
19
  readonly Runner: "run-runner";
20
20
  readonly Model: "run-model";
21
+ readonly Repository: "run-repository";
22
+ readonly RunnerPool: "run-runner-pool";
21
23
  };
22
- export declare const RunReportValue: {
23
- readonly Unknown: "unknown";
24
- };
25
- export declare function createRunBreakdownReport(journal: EventJournal): ReportDefinition;
24
+ export { RunReportValue } from '../contracts/run-report-value.js';
25
+ export type RunRepositoryLookup = (query: ReportQuery) => Promise<(run: RunView) => string | undefined>;
26
+ export declare function createRunBreakdownReport(journal: EventJournal, repositories?: RunRepositoryLookup): ReportDefinition;
26
27
  export declare const RunReportOutcome: {
27
28
  readonly Completed: "completed";
28
29
  readonly Blocked: "blocked";
@@ -42,7 +43,7 @@ export interface RunSummary {
42
43
  }
43
44
  export declare function runReportOutcome(run: RunView): RunReportOutcome;
44
45
  export declare function createRunOutcomesReport(journal: EventJournal): ReportDefinition;
45
- export declare function queryRunAnalytics(journal: EventJournal, query: ReportQuery): Promise<{
46
+ export declare function queryRunAnalytics(journal: EventJournal, query: ReportQuery, repositories?: RunRepositoryLookup): Promise<{
46
47
  duration: DurationReport;
47
48
  report: TimeSeriesReport;
48
49
  breakdown: BreakdownReport;
@@ -1,10 +1,12 @@
1
1
  import { scanJournal, yieldScan } from '@atolis-hq/eventing';
2
2
  import { ActivityOutcomeKind } from '../../activities/index.js';
3
- import { defineClosedVocabulary, median, } from '../../kernel/index.js';
3
+ import { defineClosedVocabulary, } from '../../kernel/index.js';
4
4
  import { selectRunExecutionEvent } from '../contracts/events.js';
5
+ import { RunReportValue } from '../contracts/run-report-value.js';
5
6
  import { agentTokenUsage } from '../contracts/runner.js';
6
7
  import { RunStatus } from '../contracts/vocabulary.js';
7
8
  import { foldRunEvent } from '../domain/run.js';
9
+ import { collectDurations } from './run-duration.js';
8
10
  export const RunReportId = defineClosedVocabulary({
9
11
  Duration: 'run-duration',
10
12
  Outcomes: 'run-outcomes-over-time',
@@ -38,19 +40,31 @@ export const RunReportDimension = defineClosedVocabulary({
38
40
  Stage: 'run-stage',
39
41
  Runner: 'run-runner',
40
42
  Model: 'run-model',
43
+ Repository: 'run-repository',
44
+ RunnerPool: 'run-runner-pool',
41
45
  });
42
- export const RunReportValue = defineClosedVocabulary({ Unknown: 'unknown' });
46
+ export { RunReportValue } from '../contracts/run-report-value.js';
43
47
  const dimensions = [
44
48
  { id: RunReportDimension.Action, title: 'Action', value: (run) => run.activity },
45
49
  { id: RunReportDimension.Stage, title: 'Stage', value: (run) => run.stage },
46
50
  { id: RunReportDimension.Runner, title: 'Runner', value: (run) => run.runner?.name },
47
51
  { id: RunReportDimension.Model, title: 'Model', value: (run) => run.runner?.model },
52
+ {
53
+ id: RunReportDimension.Repository,
54
+ title: 'Repository',
55
+ value: (_run) => undefined,
56
+ },
57
+ {
58
+ id: RunReportDimension.RunnerPool,
59
+ title: 'Runner pool',
60
+ value: (run) => run.runner?.pool,
61
+ },
48
62
  ];
49
- export function createRunBreakdownReport(journal) {
63
+ export function createRunBreakdownReport(journal, repositories) {
50
64
  return {
51
65
  id: RunReportId.Breakdown,
52
66
  title: 'Run breakdowns by dimension',
53
- query: async (query) => (await queryRunAnalytics(journal, query)).breakdown,
67
+ query: async (query) => (await queryRunAnalytics(journal, query, repositories)).breakdown,
54
68
  };
55
69
  }
56
70
  export const RunReportOutcome = defineClosedVocabulary({
@@ -93,7 +107,8 @@ export function createRunOutcomesReport(journal) {
93
107
  query: async (query) => (await queryRunAnalytics(journal, query)).report,
94
108
  };
95
109
  }
96
- export async function queryRunAnalytics(journal, query) {
110
+ export async function queryRunAnalytics(journal, query, repositories) {
111
+ const repositoryForRun = await repositories?.(query);
97
112
  const from = Date.parse(query.window.from);
98
113
  const to = Date.parse(query.window.to);
99
114
  const first = Math.floor(from / query.window.bucketMs) * query.window.bucketMs;
@@ -104,7 +119,7 @@ export async function queryRunAnalytics(journal, query) {
104
119
  values: { [RunUsageMeasure.Tokens]: 0, [RunUsageMeasure.CostUsd]: 0 },
105
120
  }));
106
121
  const totals = Object.fromEntries(series.map(({ id }) => [id, 0]));
107
- const durationData = collectDurations(query, buckets);
122
+ const durationData = collectDurations(query, buckets, dimensions, durationDescriptor);
108
123
  const counts = dimensions.map(() => new Map());
109
124
  let runs = 0, totalTokens = 0, totalCostUsd = 0, processed = 0;
110
125
  for (const run of (await readRuns(journal, query)).values()) {
@@ -117,11 +132,7 @@ export async function queryRunAnalytics(journal, query) {
117
132
  totals[outcome]++;
118
133
  buckets[Math.floor((start - first) / query.window.bucketMs)].values[outcome]++;
119
134
  runs++;
120
- dimensions.forEach((dimension, index) => {
121
- const value = dimension.value(run) ?? RunReportValue.Unknown;
122
- const groups = counts[index];
123
- groups.set(value, (groups.get(value) ?? 0) + 1);
124
- });
135
+ countDimensions(run, counts, repositoryForRun);
125
136
  const usage = agentTokenUsage(run.agent?.metadata);
126
137
  const tokens = finiteOrZero(usage.tokens);
127
138
  const cost = finiteOrZero(usage.costUsd);
@@ -165,12 +176,6 @@ export async function queryRunAnalytics(journal, query) {
165
176
  function finiteOrZero(value) {
166
177
  return Number.isFinite(value) ? value : 0;
167
178
  }
168
- function runDuration(run) {
169
- if (run.finishedAt === undefined)
170
- return null;
171
- const duration = Date.parse(run.finishedAt) - Date.parse(run.startedAt);
172
- return Number.isFinite(duration) && duration >= 0 ? duration : null;
173
- }
174
179
  async function readRuns(journal, query) {
175
180
  const grouped = new Map();
176
181
  for await (const event of scanJournal(journal, query.signal)) {
@@ -205,64 +210,12 @@ function outcomeBuckets(first, to, bucketMs) {
205
210
  });
206
211
  return buckets;
207
212
  }
208
- function collectDurations(query, buckets) {
209
- const durations = [];
210
- const durationBuckets = buckets.map(() => []);
211
- const durationGroups = dimensions.slice(0, 2).map(() => new Map());
212
- return {
213
- add(run, bucketIndex) {
214
- const duration = runDuration(run);
215
- if (duration !== null) {
216
- durations.push(duration);
217
- durationBuckets[bucketIndex].push(duration);
218
- dimensions.slice(0, 2).forEach((dimension, index) => {
219
- const value = dimension.value(run) ?? RunReportValue.Unknown;
220
- const groups = durationGroups[index];
221
- const values = groups.get(value) ?? [];
222
- values.push(duration);
223
- groups.set(value, values);
224
- });
225
- }
226
- },
227
- async report() {
228
- const statistics = async (values) => {
229
- let sum = 0;
230
- for (const [index, value] of values.entries()) {
231
- if (index % 1024 === 0)
232
- await yieldScan(query.signal);
233
- sum += value;
234
- }
235
- return {
236
- count: values.length,
237
- medianMs: await median(values, () => yieldScan(query.signal)),
238
- averageMs: values.length === 0 ? null : sum / values.length,
239
- };
240
- };
241
- const groups = [];
242
- for (const [index, dimension] of dimensions.slice(0, 2).entries()) {
243
- const rows = [];
244
- for (const [value, values] of durationGroups[index]) {
245
- await yieldScan(query.signal);
246
- rows.push({ value, ...(await statistics(values)) });
247
- }
248
- rows.sort((a, b) => b.count - a.count || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0));
249
- groups.push({ id: dimension.id, title: dimension.title, rows });
250
- }
251
- const durationSeries = [];
252
- for (const [index, bucket] of buckets.entries()) {
253
- durationSeries.push({
254
- from: bucket.from,
255
- to: bucket.to,
256
- ...(await statistics(durationBuckets[index])),
257
- });
258
- }
259
- return {
260
- report: durationDescriptor,
261
- window: query.window,
262
- statistics: await statistics(durations),
263
- groups,
264
- buckets: durationSeries,
265
- };
266
- },
267
- };
213
+ function countDimensions(run, counts, repositoryForRun) {
214
+ dimensions.forEach((dimension, index) => {
215
+ const value = (dimension.id === RunReportDimension.Repository
216
+ ? repositoryForRun?.(run)
217
+ : dimension.value(run)) ?? RunReportValue.Unknown;
218
+ const groups = counts[index];
219
+ groups.set(value, (groups.get(value) ?? 0) + 1);
220
+ });
268
221
  }
@@ -0,0 +1,3 @@
1
+ export declare const RunReportValue: {
2
+ readonly Unknown: "unknown";
3
+ };
@@ -0,0 +1,2 @@
1
+ import { defineClosedVocabulary } from '../../kernel/index.js';
2
+ export const RunReportValue = defineClosedVocabulary({ Unknown: 'unknown' });
@@ -5,4 +5,6 @@ interface GitHubResourceLocator {
5
5
  }
6
6
  export declare function formatGitHubResourceKey(locator: GitHubResourceLocator): string;
7
7
  export declare function parseGitHubResourceKey(key: string): GitHubResourceLocator;
8
+ /** Resolve only provider-owned issue/PR keys; malformed historical keys remain unknown. */
9
+ export declare function gitHubRepositoryIdentity(key: string): string | undefined;
8
10
  export {};
@@ -17,3 +17,13 @@ export function parseGitHubResourceKey(key) {
17
17
  throw new Error(`Invalid GitHub resource key: ${key}: ${parsed.error.issues.map((issue) => issue.message).join('; ')}`, { cause: parsed.error });
18
18
  return { owner: matched[1], repo: matched[2], number: parsed.data };
19
19
  }
20
+ /** Resolve only provider-owned issue/PR keys; malformed historical keys remain unknown. */
21
+ export function gitHubRepositoryIdentity(key) {
22
+ try {
23
+ const locator = parseGitHubResourceKey(key);
24
+ return `${locator.owner}/${locator.repo}`;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
@@ -34,3 +34,4 @@ export * from './infrastructure/source.js';
34
34
  export * from './infrastructure/webhook.js';
35
35
  export * from './infrastructure/webhook-state.js';
36
36
  export * from './provider.js';
37
+ export { gitHubRepositoryIdentity } from './contracts/external-key.js';
@@ -34,3 +34,4 @@ export * from './infrastructure/source.js';
34
34
  export * from './infrastructure/webhook.js';
35
35
  export * from './infrastructure/webhook-state.js';
36
36
  export * from './provider.js';
37
+ export { gitHubRepositoryIdentity } from './contracts/external-key.js';
@@ -33,3 +33,4 @@ export interface ResourceCorrelationView {
33
33
  readonly provenance: ResourceCorrelationProvenance;
34
34
  readonly establishedByEventId: string;
35
35
  }
36
+ export type ResourceRepositoryIdentityResolver = (externalKey: ExternalResourceKey) => string | undefined;
@@ -0,0 +1,3 @@
1
+ import type { ResourceView } from '../contracts/views.js';
2
+ /** Match workspace kind precedence, with stable identity ordering within a kind. */
3
+ export declare function repositoryCandidate(resources: readonly ResourceView[]): ResourceView | undefined;
@@ -0,0 +1,13 @@
1
+ import { BuiltInResourceKind } from '../contracts/vocabulary.js';
2
+ /** Match workspace kind precedence, with stable identity ordering within a kind. */
3
+ export function repositoryCandidate(resources) {
4
+ const kinds = [
5
+ BuiltInResourceKind.Repository,
6
+ BuiltInResourceKind.PullRequest,
7
+ BuiltInResourceKind.Issue,
8
+ ];
9
+ return resources
10
+ .filter((resource) => kinds.includes(resource.kind))
11
+ .sort((a, b) => kinds.indexOf(a.kind) - kinds.indexOf(b.kind) ||
12
+ (a.resourceId < b.resourceId ? -1 : a.resourceId > b.resourceId ? 1 : 0))[0];
13
+ }
@@ -13,3 +13,4 @@ export * from './contracts/views.js';
13
13
  export * from './contracts/vocabulary.js';
14
14
  export * from './domain/correlation.js';
15
15
  export * from './domain/resource.js';
16
+ export * from './domain/repository-candidate.js';
@@ -13,3 +13,4 @@ export * from './contracts/views.js';
13
13
  export * from './contracts/vocabulary.js';
14
14
  export * from './domain/correlation.js';
15
15
  export * from './domain/resource.js';
16
+ export * from './domain/repository-candidate.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.4.89",
3
+ "version": "0.4.90",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {