opencode-model-router 2.4.0 → 2.5.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,154 @@
1
+ /**
2
+ * #90 P1.3 (amendment A2): the subset of the OpenCode v2 TUI plugin context the status plugin reads, typed
3
+ * structurally so the shipped code imports no host package. Shapes copied from `@opencode/plugin/tui` `Context`,
4
+ * `SlotMap`, `SlotClaim`, `Data` and `UI` (v2.0.24 `packages/plugin/src/tui/context.ts`, unchanged through 2.0.26).
5
+ *
6
+ * Every member is optional: the plugin feature-detects each one at runtime, and a missing member turns off what needs
7
+ * it (never a throw). No imports and no runtime code on purpose.
8
+ */
9
+
10
+ /** `SlotMap["prompt.footer.status"]` (`PromptFooterInput`): `sessionID` is absent on the home/new-session prompt. */
11
+ export interface PromptFooterInput {
12
+ readonly sessionID?: string;
13
+ readonly mode?: "normal" | "shell";
14
+ readonly showDetails?: boolean;
15
+ }
16
+
17
+ /** `SlotMap["session.composer.top"]`: rendered in root and child session views. */
18
+ export interface ComposerTopInput {
19
+ readonly sessionID: string;
20
+ }
21
+
22
+ /**
23
+ * The `SlotClaim`s the plugin makes (placement `append`). The host calls `render` once, untracked, with reactive
24
+ * props; it returns a host element (`JSX.Element` on the host side).
25
+ */
26
+ export type HostSlotClaim =
27
+ | { readonly append: "prompt.footer.status"; readonly render: (input: PromptFooterInput) => unknown }
28
+ | { readonly append: "session.composer.top"; readonly render: (input: ComposerTopInput) => unknown };
29
+
30
+ /** `Model.Ref`. */
31
+ export interface HostModelRef {
32
+ readonly id: string;
33
+ readonly providerID: string;
34
+ readonly variant?: string;
35
+ }
36
+
37
+ /** Epoch milliseconds, or an Effect `DateTime.Utc`. */
38
+ export type HostTime = number | { readonly epochMilliseconds: number };
39
+
40
+ /** The read subset of `SessionInfo`. */
41
+ export interface HostSession {
42
+ readonly id: string;
43
+ readonly parentID?: string;
44
+ readonly agent?: string;
45
+ readonly title?: string;
46
+ readonly model?: HostModelRef;
47
+ readonly time?: { readonly created?: HostTime | null };
48
+ /** `LocationRef`: passed as is to the rpc call options and to `data.location.model.list`. */
49
+ readonly location?: unknown;
50
+ }
51
+
52
+ /** The read subset of `SessionMessageInfo` (tagged by `type`; assistant messages carry `agent` and `model`). */
53
+ export interface HostMessage {
54
+ readonly id: string;
55
+ readonly type?: string;
56
+ readonly role?: string;
57
+ readonly agent?: string;
58
+ readonly model?: HostModelRef;
59
+ readonly time?: { readonly created?: HostTime | null };
60
+ }
61
+
62
+ /** The read subset of an entry of `data.location.model.list()`. */
63
+ export interface HostModelInfo {
64
+ readonly id: string;
65
+ readonly providerID: string;
66
+ readonly name?: string;
67
+ readonly variants?: ReadonlyArray<{ readonly id: string }>;
68
+ }
69
+
70
+ export type HostSessionStatus = "idle" | "running";
71
+
72
+ /** `Data` (reactive when read in a Solid computation). */
73
+ export interface HostData {
74
+ readonly session?: {
75
+ get?(sessionID: string): HostSession | undefined;
76
+ family?(sessionID: string): readonly string[];
77
+ status?(sessionID: string): HostSessionStatus;
78
+ readonly message?: {
79
+ list?(sessionID: string): readonly HostMessage[];
80
+ sync?(sessionID: string): Promise<void>;
81
+ };
82
+ };
83
+ readonly location?: {
84
+ readonly model?: {
85
+ /** Undefined while the location's list is not loaded. */
86
+ list?(location?: unknown): readonly HostModelInfo[] | undefined;
87
+ sync?(location?: unknown): Promise<void>;
88
+ };
89
+ };
90
+ }
91
+
92
+ export type HostToastVariant = "info" | "success" | "warning" | "error";
93
+
94
+ /** `Toast`. */
95
+ export interface HostToast {
96
+ show?(options: {
97
+ readonly title?: string;
98
+ readonly message: string;
99
+ readonly variant?: HostToastVariant;
100
+ readonly duration?: number;
101
+ }): void;
102
+ }
103
+
104
+ /** `ui.model.current()`: the prompt's selected model; `variant` is absent for the model default. */
105
+ export interface HostCurrentModel {
106
+ readonly providerID: string;
107
+ readonly modelID: string;
108
+ readonly variant?: string;
109
+ }
110
+
111
+ /** `UI`. `slot` returns its dispose function. */
112
+ export interface HostUI {
113
+ readonly toast?: HostToast;
114
+ readonly model?: {
115
+ current?(): HostCurrentModel | undefined;
116
+ };
117
+ readonly slot?: (claim: HostSlotClaim) => unknown;
118
+ }
119
+
120
+ /** A plugin rpc definition, as passed to `client.rpc(definition)`. */
121
+ export interface HostRpcDefinition {
122
+ readonly id: string;
123
+ readonly methods: object;
124
+ readonly events: object;
125
+ }
126
+
127
+ /** `OpenCodeClient`: `rpc(definition)` returns a client with one method per definition method. */
128
+ export interface HostClient {
129
+ rpc?(definition: HostRpcDefinition): unknown;
130
+ }
131
+
132
+ export type HostResizeListener = (...args: unknown[]) => void;
133
+
134
+ /** `CliRenderer` (an event emitter): its width in columns and its `resize` event. */
135
+ export interface HostRenderer {
136
+ readonly width?: number;
137
+ on?(event: "resize", listener: HostResizeListener): unknown;
138
+ off?(event: "resize", listener: HostResizeListener): unknown;
139
+ }
140
+
141
+ /** `ResolvedTheme`: only the muted text colour is read. */
142
+ export interface HostTheme {
143
+ readonly textMuted?: unknown;
144
+ }
145
+
146
+ /** `Context` (the TUI plugin `setup` argument). `options` is whatever the user configured. */
147
+ export interface HostContext {
148
+ readonly options?: unknown;
149
+ readonly renderer?: HostRenderer;
150
+ readonly client?: HostClient;
151
+ readonly data?: HostData;
152
+ readonly theme?: HostTheme;
153
+ readonly ui?: HostUI;
154
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * #90 P1.3 (amendment A2): the three `@opentui/solid` reconciler primitives the TUI entry uses, declared locally so the
3
+ * repository needs neither `@opentui/solid` nor `@opentui/core` installed. At runtime the host serves the module (its
4
+ * runtime plugin answers the bare import); nothing here is bundled.
5
+ *
6
+ * Mirrors `@opentui/solid@0.5.14` `src/reconciler.d.ts` (the `solid-js/universal` renderer functions), with the
7
+ * `BaseRenderable` node type simplified to `unknown`.
8
+ */
9
+ declare module "@opentui/solid" {
10
+ /** Creates a host element (`"box"`, `"text"`, …). */
11
+ export function createElement(tag: string): unknown;
12
+ /** Inserts a value or a reactive accessor (string, node or array of nodes) as the children of `parent`. */
13
+ export function insert(parent: unknown, accessor: unknown, marker?: unknown, initial?: unknown): unknown;
14
+ /** Sets one property of a host element; returns `value`. */
15
+ export function setProp<T>(node: unknown, name: string, value: T, prev?: T): T;
16
+ }