@spencerboucher/switchyard-client 0.16.0 → 0.18.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.
@@ -1,11 +1,39 @@
1
- import type { Session, Task, View, ViewClient, Workspace } from "./entities.js";
2
- /** A client counts as open in a view while its last report is younger than this. */
3
- export declare const CLIENT_OPEN_MS: number;
4
- type WorkspaceLookup = Record<string, Pick<Workspace, "projectId">> | Map<string, Pick<Workspace, "projectId">>;
5
- /** Is a session in a view? Archived sessions never are. */
6
- export declare function sessionInView(view: View, s: Pick<Session, "id" | "projectId" | "workspaceId" | "hostId" | "archivedAt">, workspaces: WorkspaceLookup): boolean;
7
- /** Clients that reported recently, sorted by kind then name. */
8
- export declare function openClients(view: View, now?: number): ViewClient[];
1
+ import type { RuntimeState, Session, Surface, Task, View, Workspace } from "./entities.js";
2
+ import type { TrackedIssue } from "./trackers.js";
3
+ /** A surface counts as open while its last report is younger than this. */
4
+ export declare const SURFACE_OPEN_MS: number;
5
+ export declare const LIVE_RUNTIMES: readonly ["starting", "idle", "running", "waiting_input"];
6
+ export declare function isLiveRuntime(r: RuntimeState): boolean;
7
+ type WorkspaceRef = Pick<Workspace, "projectId"> & {
8
+ branch?: string | null;
9
+ };
10
+ export type WorkspaceLookup = Record<string, WorkspaceRef> | Map<string, WorkspaceRef>;
11
+ /** The branches a tracker's issues are worked on: what a tracker's view holds besides live sessions. */
12
+ export interface TrackerScope {
13
+ trackerId: string;
14
+ workspaceIds: Set<string>;
15
+ /** `${projectId}\n${branch}` */
16
+ branches: Set<string>;
17
+ }
18
+ export declare function trackerScope(view: Pick<View, "trackerId">, issues: Iterable<Pick<TrackedIssue, "trackerId" | "projectId" | "workspaceId" | "branch" | "branches">>): TrackerScope | null;
19
+ /** Is this workspace one of the tracker's issue branches (by worktree or branch name)? */
20
+ export declare function scopeHasWorkspace(scope: TrackerScope, ws: {
21
+ id: string;
22
+ projectId: string;
23
+ branch?: string | null;
24
+ }): boolean;
25
+ /** Why a session is in a view: pinned, started in its source, on a tracker's issue, live, or by the filters. */
26
+ export type ViewReason = "pinned" | "client" | "issue" | "live" | "filter";
27
+ type ViewSession = Pick<Session, "id" | "projectId" | "workspaceId" | "hostId" | "archivedAt" | "startedIn" | "runtime">;
28
+ /** Why a session is in a view; null when it is not. See `sessionInView`. */
29
+ export declare function sessionViewReason(view: View, s: ViewSession, workspaces: WorkspaceLookup, scope?: TrackerScope | null): ViewReason | null;
30
+ /**
31
+ * Is a session in a view? Archived sessions never are. In a tracker's view (given its scope):
32
+ * sessions on its issues' branches, and live sessions in its projects.
33
+ */
34
+ export declare function sessionInView(view: View, s: ViewSession, workspaces: WorkspaceLookup, scope?: TrackerScope | null): boolean;
35
+ /** Surfaces showing a view that reported recently, sorted by kind then name. */
36
+ export declare function openSurfaces(surfaces: Surface[], viewId: string, now?: number): Surface[];
9
37
  /** Resolve a view by id, else by case-insensitive name; null if absent or ambiguous. */
10
38
  export declare function findView(views: View[], ref: string): View | null;
11
39
  /** Is a task in a view? By its project, or because its session is pinned. Host filters do not apply to tasks. */
@@ -1,4 +1,4 @@
1
- import type { AttentionItem, Automation, Checkout, Device, EventEnvelope, Host, Interaction, Panel, Profile, Project, Run, Session, SyncState, Task, View, Workspace } from "./protocol/index.js";
1
+ import type { AttentionItem, Automation, Checkout, Device, EventEnvelope, Host, Interaction, Panel, Profile, Project, Run, Session, Surface, SyncState, Task, TrackedIssue, View, Workspace } from "./protocol/index.js";
2
2
  /**
3
3
  * Normalized client state of coordinator entities and its pure reducers: durable events apply
4
4
  * once in `seq` order, a snapshot replaces every entity. Transcripts and stream deltas are not kept.
@@ -30,6 +30,8 @@ export interface ClientState {
30
30
  interactions: ById<Interaction>;
31
31
  panels: ById<Panel>;
32
32
  devices: ById<Device>;
33
+ surfaces: ById<Surface>;
34
+ issues: ById<TrackedIssue>;
33
35
  dispatchPaused: boolean;
34
36
  }
35
37
  export declare function emptyState(): ClientState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spencerboucher/switchyard-client",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Node.js REST and WebSocket SDK for Switchyard",
5
5
  "license": "MIT",
6
6
  "repository": {