opencode-codeops 2.2.1 → 2.3.0

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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Type declarations for the CodeOps Discovery listener.
3
+ *
4
+ * The listener is plain JavaScript so `node --test` can exercise it directly;
5
+ * these declarations give the TypeScript plugin entry point typed access.
6
+ */
7
+
8
+ import type { DiscoveryStore } from "./discovery-store.mjs"
9
+
10
+ /** The result of starting the listener. */
11
+ export interface ListeningResult {
12
+ url: string
13
+ fallback: boolean
14
+ }
15
+
16
+ /** The delivery outcome a registered project reports. */
17
+ export type DeliveryOutcome = "woken" | "pending" | "failed"
18
+
19
+ /** Options shared by runtime creation and lookup. */
20
+ export interface DiscoveryRuntimeOptions {
21
+ store: DiscoveryStore
22
+ assetsDir: string
23
+ version: string
24
+ port?: number
25
+ log?: (message: string) => void
26
+ }
27
+
28
+ /** The process-wide Discovery runtime. */
29
+ export interface DiscoveryRuntime {
30
+ /** Start the listener on demand; concurrent calls share one attempt. */
31
+ ensureListening(): Promise<ListeningResult | null>
32
+ /** Register one project's delivery callback; returns an identity-checked unregister. */
33
+ registerProject(
34
+ directory: string,
35
+ slug: string,
36
+ deliver: (planSlug: string) => Promise<DeliveryOutcome>
37
+ ): () => void
38
+ /** True when an open page shows this plan. */
39
+ hasViewer(projectSlug: string, planSlug: string): boolean
40
+ /** Broadcast one live event to the plan's open pages. */
41
+ notify(
42
+ projectSlug: string,
43
+ planSlug: string,
44
+ event: "changed" | "delivered",
45
+ data: Record<string, unknown>
46
+ ): void
47
+ /** End streams, close connections, and stop when no project remains. */
48
+ closeIfIdle(): Promise<void>
49
+ /** The absolute page URL, or null before the listener starts. */
50
+ planUrl(projectSlug: string, planSlug: string): string | null
51
+ /** The one store every handler uses. */
52
+ readonly store: DiscoveryStore
53
+ }
54
+
55
+ /** Resolve the listener port from the environment. */
56
+ export declare function resolvePort(env?: Record<string, string | undefined>): number
57
+
58
+ /** Create a runtime, installing it in the process-wide slot when empty. */
59
+ export declare function createDiscoveryRuntime(options: DiscoveryRuntimeOptions): DiscoveryRuntime
60
+
61
+ /** The process-wide runtime, created on first use. */
62
+ export declare function getDiscoveryRuntime(options: DiscoveryRuntimeOptions): DiscoveryRuntime