feat: add agent query API (#130)

This commit is contained in:
2026-06-14 16:05:04 +01:00
committed by GitHub
parent 083f6d2695
commit 825f67db13
16 changed files with 2590 additions and 144 deletions

View File

@@ -1,4 +1,10 @@
import { FeedEngine, type FeedItem, type FeedResult, type FeedSource } from "@freya/core"
import {
FeedEngine,
type ActionDefinition,
type FeedItem,
type FeedResult,
type FeedSource,
} from "@freya/core"
import type { FeedEnhancer } from "../enhancement/enhance-feed.ts"
@@ -73,6 +79,21 @@ export class UserSession {
return this.sources.has(sourceId)
}
async listActions(): Promise<
Array<{ sourceId: string; actions: Record<string, ActionDefinition> }>
> {
const result: Array<{ sourceId: string; actions: Record<string, ActionDefinition> }> = []
for (const [sourceId, source] of this.sources) {
result.push({
sourceId,
actions: await source.listActions(),
})
}
return result
}
/**
* Registers a new source in the engine and invalidates all caches.
* Stops and restarts the engine to establish reactive subscriptions.