overmux 0.0.1 → 0.0.2

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.
Files changed (193) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +7 -0
  3. package/dist/auth/.vite/manifest.json +11 -0
  4. package/dist/auth/assets/index-Bx8JhwVi.css +1 -0
  5. package/dist/auth/assets/index-CHIE7qYj.js +72 -0
  6. package/dist/auth/index.html +14 -0
  7. package/dist/bin.js +4504 -7870
  8. package/dist/bin.js.map +1 -0
  9. package/dist/docs/000-index.md +21 -0
  10. package/dist/docs/100-introduction/100-what-is-overmux.md +7 -0
  11. package/dist/docs/100-introduction/200-how-overmux-works.md +7 -0
  12. package/dist/docs/100-introduction/300-why-overmux.md +22 -0
  13. package/dist/docs/200-getting-started/100-install-and-run-overmux.md +51 -0
  14. package/dist/docs/200-getting-started/200-install-overmux-desktop.md +41 -0
  15. package/dist/docs/200-getting-started/300-install-overmux-pwa.mdx +92 -0
  16. package/dist/docs/200-getting-started/400-secure-with-https/100-choose-an-https-setup.md +14 -0
  17. package/dist/docs/200-getting-started/400-secure-with-https/200-tailscale-serve.md +44 -0
  18. package/dist/docs/200-getting-started/400-secure-with-https/300-cloudflare-tunnel.md +59 -0
  19. package/dist/docs/200-getting-started/400-secure-with-https/400-self-hosted-reverse-proxy.md +32 -0
  20. package/dist/docs/300-fundamentals/100-project-structure.md +3 -0
  21. package/dist/docs/300-fundamentals/200-configuration.md +3 -0
  22. package/dist/docs/300-fundamentals/300-theming.md +3 -0
  23. package/dist/docs/300-fundamentals/400-server.md +3 -0
  24. package/dist/docs/300-fundamentals/500-client.md +3 -0
  25. package/dist/docs/300-fundamentals/600-operations.md +3 -0
  26. package/dist/docs/300-fundamentals/700-resources.md +3 -0
  27. package/dist/docs/300-fundamentals/800-streams.md +3 -0
  28. package/dist/docs/300-fundamentals/900-authentication-and-security.md +3 -0
  29. package/dist/docs/400-reference/100-configuration.md +3 -0
  30. package/dist/docs/400-reference/200-server-api.md +3 -0
  31. package/dist/docs/400-reference/300-client-api.md +3 -0
  32. package/dist/docs/400-reference/400-cli/100-serve.md +33 -0
  33. package/dist/docs/400-reference/400-cli/200-auth.md +52 -0
  34. package/dist/docs/400-reference/400-cli/300-call.md +28 -0
  35. package/dist/docs/400-reference/400-cli/400-check.md +20 -0
  36. package/dist/docs/400-reference/400-cli/500-ai-context.md +102 -0
  37. package/dist/docs/400-reference/400-cli/600-docs.md +23 -0
  38. package/dist/docs/400-reference/400-cli/700-desktop.md +35 -0
  39. package/dist/docs/500-hosted-pages.md +31 -0
  40. package/dist/exports/client.d.ts +237 -0
  41. package/dist/exports/client.d.ts.map +1 -0
  42. package/dist/exports/client.js +1643 -0
  43. package/dist/exports/client.js.map +1 -0
  44. package/dist/exports/index-D3_Dpy_T.d.ts +155 -0
  45. package/dist/exports/index-D3_Dpy_T.d.ts.map +1 -0
  46. package/dist/exports/index.d.ts +2 -0
  47. package/dist/exports/index.js +49 -0
  48. package/dist/exports/index.js.map +1 -0
  49. package/dist/exports/notifications-kDp16bU_.js +56 -0
  50. package/dist/exports/notifications-kDp16bU_.js.map +1 -0
  51. package/dist/exports/server.d.ts +63 -0
  52. package/dist/exports/server.d.ts.map +1 -0
  53. package/dist/exports/server.js +1120 -0
  54. package/dist/exports/server.js.map +1 -0
  55. package/dist/exports/style.css +368 -0
  56. package/dist/internal/server/coordinator/server-child.d.ts +1 -0
  57. package/dist/internal/server/coordinator/server-child.js +3299 -0
  58. package/dist/internal/server/coordinator/server-child.js.map +1 -0
  59. package/docs/000-index.md +21 -0
  60. package/docs/100-introduction/100-what-is-overmux.md +7 -0
  61. package/docs/100-introduction/200-how-overmux-works.md +7 -0
  62. package/docs/100-introduction/300-why-overmux.md +22 -0
  63. package/docs/200-getting-started/100-install-and-run-overmux.md +51 -0
  64. package/docs/200-getting-started/200-install-overmux-desktop.md +41 -0
  65. package/docs/200-getting-started/300-install-overmux-pwa.mdx +92 -0
  66. package/docs/200-getting-started/400-secure-with-https/100-choose-an-https-setup.md +14 -0
  67. package/docs/200-getting-started/400-secure-with-https/200-tailscale-serve.md +44 -0
  68. package/docs/200-getting-started/400-secure-with-https/300-cloudflare-tunnel.md +59 -0
  69. package/docs/200-getting-started/400-secure-with-https/400-self-hosted-reverse-proxy.md +32 -0
  70. package/docs/300-fundamentals/100-project-structure.md +3 -0
  71. package/docs/300-fundamentals/200-configuration.md +3 -0
  72. package/docs/300-fundamentals/300-theming.md +3 -0
  73. package/docs/300-fundamentals/400-server.md +3 -0
  74. package/docs/300-fundamentals/500-client.md +3 -0
  75. package/docs/300-fundamentals/600-operations.md +3 -0
  76. package/docs/300-fundamentals/700-resources.md +3 -0
  77. package/docs/300-fundamentals/800-streams.md +3 -0
  78. package/docs/300-fundamentals/900-authentication-and-security.md +3 -0
  79. package/docs/400-reference/100-configuration.md +3 -0
  80. package/docs/400-reference/200-server-api.md +3 -0
  81. package/docs/400-reference/300-client-api.md +3 -0
  82. package/docs/400-reference/400-cli/100-serve.md +33 -0
  83. package/docs/400-reference/400-cli/200-auth.md +52 -0
  84. package/docs/400-reference/400-cli/300-call.md +28 -0
  85. package/docs/400-reference/400-cli/400-check.md +20 -0
  86. package/docs/400-reference/400-cli/500-ai-context.md +102 -0
  87. package/docs/400-reference/400-cli/600-docs.md +23 -0
  88. package/docs/400-reference/400-cli/700-desktop.md +35 -0
  89. package/docs/500-hosted-pages.md +31 -0
  90. package/package.json +59 -18
  91. package/src/internal/cli/app.ts +72 -0
  92. package/src/internal/cli/bin.ts +3 -0
  93. package/src/internal/cli/commands/ai.ts +44 -0
  94. package/src/internal/cli/commands/auth.ts +195 -0
  95. package/src/internal/cli/commands/call.ts +128 -0
  96. package/src/internal/cli/commands/check.ts +48 -0
  97. package/src/internal/cli/commands/desktop-installer.ts +446 -0
  98. package/src/internal/cli/commands/desktop-release.ts +190 -0
  99. package/src/internal/cli/commands/desktop.ts +47 -0
  100. package/src/internal/cli/commands/docs.ts +34 -0
  101. package/src/internal/cli/commands/serve.ts +322 -0
  102. package/src/internal/cli/environment.ts +54 -0
  103. package/src/internal/cli/login.ts +46 -0
  104. package/src/internal/cli/managed-vite.ts +267 -0
  105. package/src/internal/cli/parse-port.ts +8 -0
  106. package/src/internal/client/auth/auth-api.ts +53 -0
  107. package/src/internal/client/auth/auth-shell.css +74 -0
  108. package/src/internal/client/auth/auth-shell.tsx +167 -0
  109. package/src/internal/client/auth/entry.tsx +26 -0
  110. package/src/internal/client/auth/index.html +13 -0
  111. package/src/internal/client/background-notifications.ts +194 -0
  112. package/src/internal/client/browser-api.ts +97 -0
  113. package/src/internal/client/client-definition.ts +184 -0
  114. package/src/internal/client/commands.tsx +260 -0
  115. package/src/internal/client/host/browser-log-forwarding.ts +149 -0
  116. package/src/internal/client/host/hosted-pages/browser-notification-settings.tsx +118 -0
  117. package/src/internal/client/host/hosted-pages/hosted-page.css +87 -0
  118. package/src/internal/client/host/hosted-pages/hosted-page.tsx +9 -0
  119. package/src/internal/client/host/hosted-pages/logout-page.tsx +75 -0
  120. package/src/internal/client/host/hosted-pages/settings-page.tsx +45 -0
  121. package/src/internal/client/host/notification-forwarding.ts +22 -0
  122. package/src/internal/client/host/overmux-host.tsx +200 -0
  123. package/src/internal/client/host/recovery-screen.css +75 -0
  124. package/src/internal/client/host/recovery-screen.tsx +17 -0
  125. package/src/internal/client/host/update-popover.css +82 -0
  126. package/src/internal/client/host/update-popover.tsx +166 -0
  127. package/src/internal/client/index.ts +45 -0
  128. package/src/internal/client/overmux-react.ts +283 -0
  129. package/src/internal/client/shortcuts.tsx +373 -0
  130. package/src/internal/client/theme-scope.css +114 -0
  131. package/src/internal/client/theme-scope.tsx +107 -0
  132. package/src/internal/client/transport.ts +69 -0
  133. package/src/internal/client/websocket.ts +441 -0
  134. package/src/internal/server/auth/auth-http.ts +414 -0
  135. package/src/internal/server/auth/auth-service.ts +627 -0
  136. package/src/internal/server/auth/auth-shell-http.ts +90 -0
  137. package/src/internal/server/auth/instance-control.ts +381 -0
  138. package/src/internal/server/check-overmux.ts +364 -0
  139. package/src/internal/server/coordinator/ipc-protocol.ts +44 -0
  140. package/src/internal/server/coordinator/server-child.ts +108 -0
  141. package/src/internal/server/coordinator/server-coordinator.ts +262 -0
  142. package/src/internal/server/coordinator/update-watcher.ts +54 -0
  143. package/src/internal/server/http/authenticated-http-app-test-helper.ts +45 -0
  144. package/src/internal/server/http/background-notification-handlers.ts +83 -0
  145. package/src/internal/server/http/control-handlers.ts +44 -0
  146. package/src/internal/server/http/create-http-app.ts +53 -0
  147. package/src/internal/server/http/development-web-backend.ts +83 -0
  148. package/src/internal/server/http/operation-handler.ts +93 -0
  149. package/src/internal/server/http/request-logging.ts +34 -0
  150. package/src/internal/server/http/routes.ts +241 -0
  151. package/src/internal/server/http/runtime-manifest-handler.ts +12 -0
  152. package/src/internal/server/index.ts +16 -0
  153. package/src/internal/server/notifications/background-notification-payload.ts +74 -0
  154. package/src/internal/server/notifications/background-notification-service.ts +139 -0
  155. package/src/internal/server/notifications/background-notification-store.ts +162 -0
  156. package/src/internal/server/notifications/notification-service.ts +70 -0
  157. package/src/internal/server/notifications/private-json-file.ts +84 -0
  158. package/src/internal/server/paths.ts +13 -0
  159. package/src/internal/server/rate-limiter.ts +58 -0
  160. package/src/internal/server/runtime/create-runtime.ts +87 -0
  161. package/src/internal/server/runtime/resource-dependency-graph.ts +128 -0
  162. package/src/internal/server/runtime/runtime-lifecycle.ts +95 -0
  163. package/src/internal/server/runtime/runtime-operations.ts +78 -0
  164. package/src/internal/server/runtime/runtime-resources.ts +201 -0
  165. package/src/internal/server/runtime/runtime-streams.ts +130 -0
  166. package/src/internal/server/server-logger.ts +110 -0
  167. package/src/internal/server/server-startup-options.ts +51 -0
  168. package/src/internal/server/start-application-server.ts +412 -0
  169. package/src/internal/server/start-overmux-server.ts +26 -0
  170. package/src/internal/server/test-port.ts +23 -0
  171. package/src/internal/server/vite-websocket-proxy.ts +201 -0
  172. package/src/internal/server/websocket-connection.ts +586 -0
  173. package/src/internal/server/websocket-limits.ts +2 -0
  174. package/src/internal/server/websocket-server.ts +311 -0
  175. package/src/internal/shared/background-notifications.ts +37 -0
  176. package/src/internal/shared/index.ts +2 -0
  177. package/src/internal/shared/protocol.ts +317 -0
  178. package/src/internal/shared/routes.ts +3 -0
  179. package/src/public/ai-context.ts +44 -0
  180. package/src/public/client.ts +53 -0
  181. package/src/public/config.ts +287 -0
  182. package/src/public/contracts.ts +55 -0
  183. package/src/public/index.ts +57 -0
  184. package/src/public/notifications.ts +10 -0
  185. package/src/public/server.ts +16 -0
  186. package/dist/public/core.ts +0 -119
  187. package/dist/public/protocol.ts +0 -51
  188. package/dist/public/terminal.ts +0 -23
  189. package/dist/web/assets/index-DC___IUw.css +0 -2
  190. package/dist/web/assets/index-DF9Cptse.js +0 -74
  191. package/dist/web/assets/terminal-component-BrP-ENHg.css +0 -1
  192. package/dist/web/assets/terminal-component-DyLEbMrx.js +0 -36
  193. package/dist/web/index.html +0 -14
@@ -0,0 +1,44 @@
1
+ import {
2
+ packageSourceSnippet,
3
+ techStackRecommendationsSnippet,
4
+ type AiContextSnippet,
5
+ } from "@overmux/shared";
6
+
7
+ export {
8
+ packageSourceSnippet,
9
+ techStackRecommendationsSnippet,
10
+ type AiContextSnippet,
11
+ };
12
+ export type AiContextSnippetDefinition = readonly AiContextSnippet[];
13
+
14
+ export const coreAiContextSnippets = [
15
+ packageSourceSnippet,
16
+ ] as const satisfies AiContextSnippetDefinition;
17
+ export const defaultAiContextSnippets = [
18
+ ...coreAiContextSnippets,
19
+ techStackRecommendationsSnippet,
20
+ ] as const satisfies AiContextSnippetDefinition;
21
+
22
+ const packageSourceSnippetContent = `Overmux ships with documentation and TypeScript source.
23
+
24
+ Run \`overmux docs\` to find the installed documentation and source for the overmux cli.
25
+
26
+ E.g. \`node_modules/overmux\` and \`node_modules/@overmux/xterm\`.
27
+
28
+ Inspect these files so guidance matches the versions used by the application.`;
29
+
30
+ const techStackRecommendationsSnippetContent = `Prefer pnpm as the package manager, TanStack Router for routing, shadcn/ui for UI components, and Zod for schemas and runtime validation. Follow the application's established stack when it already differs.`;
31
+
32
+ const aiContextContentBySnippet: Record<AiContextSnippet, string> = {
33
+ [packageSourceSnippet]: packageSourceSnippetContent,
34
+ [techStackRecommendationsSnippet]: techStackRecommendationsSnippetContent,
35
+ };
36
+
37
+ export const composeAiContext = (snippets: AiContextSnippetDefinition) =>
38
+ snippets.length === 0
39
+ ? ""
40
+ : `${snippets
41
+ .map(
42
+ (snippet) => `## ${snippet}\n\n${aiContextContentBySnippet[snippet]}`,
43
+ )
44
+ .join("\n\n")}\n`;
@@ -0,0 +1,53 @@
1
+ export {
2
+ disableBackgroundNotifications,
3
+ enableBackgroundNotifications,
4
+ } from "../internal/client/background-notifications";
5
+ export type { OvermuxServerApi } from "../internal/client/browser-api";
6
+ export {
7
+ createOvermuxHooks,
8
+ type ResourceResult,
9
+ type StreamResult,
10
+ } from "../internal/client/overmux-react";
11
+ export { OvermuxHost } from "../internal/client/host/overmux-host";
12
+ export {
13
+ OvermuxPortal,
14
+ OvermuxThemeScope,
15
+ } from "../internal/client/theme-scope";
16
+ export type {
17
+ OvermuxContrast,
18
+ OvermuxExternalPortalContainer,
19
+ OvermuxPortalProps,
20
+ OvermuxScheme,
21
+ OvermuxThemeScopeProps,
22
+ OvermuxStyle,
23
+ OvermuxThemeToken,
24
+ } from "../internal/client/theme-scope";
25
+ export {
26
+ chordPrefixSchema,
27
+ commandBindingSchema,
28
+ defineCommandRegistry,
29
+ defineOvermuxClient,
30
+ formatKeyBinding,
31
+ formatShortcutBinding,
32
+ keyBindingSchema,
33
+ matchesKeyBinding,
34
+ shortcutBindingSchema,
35
+ } from "../internal/client/client-definition";
36
+ export {
37
+ skipToken,
38
+ useCommand,
39
+ useCommands,
40
+ } from "../internal/client/commands";
41
+ export { useShortcutInputTarget } from "../internal/client/shortcuts";
42
+ export type {
43
+ ChordPrefix,
44
+ CommandBinding,
45
+ CommandHandle,
46
+ ConditionalShortcutBinding,
47
+ KeyBinding,
48
+ KeySequence,
49
+ OvermuxClientAppearance,
50
+ ShortcutBinding,
51
+ } from "../internal/client/client-definition";
52
+ export type { CommandEntry, SkipToken } from "../internal/client/commands";
53
+ export type { ShortcutInputTarget } from "../internal/client/shortcuts";
@@ -0,0 +1,287 @@
1
+ import { z } from "zod";
2
+
3
+ import type { AiContextSnippetDefinition } from "./ai-context";
4
+ import type { Notifications } from "./notifications";
5
+ import type { ResourceContract, StreamContract } from "./contracts";
6
+
7
+ export type RuntimeDisposer = () => Promise<void> | void;
8
+
9
+ export type HandlerContext = {
10
+ invalidate: (contract: ResourceContract, input?: unknown) => void;
11
+ signal: AbortSignal;
12
+ };
13
+
14
+ export type OperationContext = HandlerContext & {
15
+ notifications: Notifications;
16
+ };
17
+
18
+ export type OperationDefinition<
19
+ TInput extends z.ZodType = z.ZodType,
20
+ TOutput extends z.ZodType = z.ZodVoid,
21
+ > = {
22
+ handle: (
23
+ input: z.output<TInput>,
24
+ context: OperationContext,
25
+ ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;
26
+ input: TInput;
27
+ output: TOutput;
28
+ };
29
+
30
+ export const defineOperation = <
31
+ TInput extends z.ZodType,
32
+ TOutput extends z.ZodType = z.ZodVoid,
33
+ >({
34
+ handle,
35
+ input,
36
+ output,
37
+ }: {
38
+ handle: OperationDefinition<TInput, TOutput>["handle"];
39
+ input: TInput;
40
+ output?: TOutput;
41
+ }): OperationDefinition<TInput, TOutput> => ({
42
+ handle,
43
+ input,
44
+ output: (output ?? z.void()) as TOutput,
45
+ });
46
+
47
+ export type QueryResourceDefinition<
48
+ TInput extends z.ZodType = z.ZodType,
49
+ TOutput extends z.ZodType = z.ZodType,
50
+ > = {
51
+ contract: ResourceContract<TInput, TOutput>;
52
+ kind: "query";
53
+ read: (
54
+ input: z.output<TInput>,
55
+ context: HandlerContext,
56
+ ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;
57
+ };
58
+
59
+ export type SubscriptionResourceDefinition<
60
+ TInput extends z.ZodType = z.ZodType,
61
+ TOutput extends z.ZodType = z.ZodType,
62
+ > = {
63
+ contract: ResourceContract<TInput, TOutput>;
64
+ kind: "subscription";
65
+ read: QueryResourceDefinition<TInput, TOutput>["read"];
66
+ subscribe: (
67
+ input: z.output<TInput>,
68
+ invalidate: () => void,
69
+ context: HandlerContext,
70
+ ) => RuntimeDisposer;
71
+ };
72
+
73
+ export type DerivedResourceDefinition<
74
+ TInput extends z.ZodType = z.ZodType,
75
+ TOutput extends z.ZodType = z.ZodType,
76
+ TDependencies extends Readonly<Record<string, string>> = Readonly<
77
+ Record<string, string>
78
+ >,
79
+ TDependencyOutputs = Readonly<Record<string, unknown>>,
80
+ > = {
81
+ combine: (dependencies: TDependencyOutputs) => z.input<NoInfer<TOutput>>;
82
+ contract: ResourceContract<TInput, TOutput>;
83
+ dependencies: TDependencies;
84
+ kind: "derived";
85
+ };
86
+
87
+ type AnyZodType = z.ZodType<any, any, any>;
88
+
89
+ export type ResourceDefinition =
90
+ | QueryResourceDefinition<AnyZodType, AnyZodType>
91
+ | SubscriptionResourceDefinition<AnyZodType, AnyZodType>
92
+ | DerivedResourceDefinition<AnyZodType, AnyZodType, any, any>;
93
+
94
+ export type StreamSession<TClientMessage = unknown> = {
95
+ dispose?: RuntimeDisposer;
96
+ onMessage?: (message: TClientMessage) => Promise<void> | void;
97
+ };
98
+
99
+ export type StreamHandlerDefinition<
100
+ TInput extends z.ZodType = z.ZodType,
101
+ TClientMessage extends z.ZodType = z.ZodType,
102
+ TServerMessage extends z.ZodType = z.ZodType,
103
+ > = {
104
+ contract: StreamContract<TInput, TClientMessage, TServerMessage>;
105
+ open: (
106
+ input: z.output<TInput>,
107
+ context: HandlerContext & {
108
+ emit: (message: z.input<NoInfer<TServerMessage>>) => void;
109
+ fail: (cause: unknown) => void;
110
+ },
111
+ ) =>
112
+ | Promise<StreamSession<z.output<TClientMessage>>>
113
+ | StreamSession<z.output<TClientMessage>>;
114
+ };
115
+
116
+ export const defineStreamHandler = <
117
+ TInput extends z.ZodType,
118
+ TClientMessage extends z.ZodType,
119
+ TServerMessage extends z.ZodType,
120
+ >(
121
+ contract: StreamContract<TInput, TClientMessage, TServerMessage>,
122
+ open: StreamHandlerDefinition<TInput, TClientMessage, TServerMessage>["open"],
123
+ ): StreamHandlerDefinition<TInput, TClientMessage, TServerMessage> => ({
124
+ contract,
125
+ open,
126
+ });
127
+
128
+ type ResourceContracts = Record<
129
+ string,
130
+ ResourceContract<AnyZodType, AnyZodType>
131
+ >;
132
+
133
+ type DependencyOutputs<
134
+ TContracts extends ResourceContracts,
135
+ TDependencies extends Record<string, unknown>,
136
+ > = {
137
+ [TName in keyof TDependencies]: TDependencies[TName] extends keyof TContracts
138
+ ? z.output<TContracts[TDependencies[TName]]["output"]>
139
+ : never;
140
+ };
141
+
142
+ type DependencySource<TDependencies> = {
143
+ [TId in keyof TDependencies]: TDependencies[TId] extends Record<
144
+ string,
145
+ string
146
+ >
147
+ ? { dependencies: TDependencies[TId] }
148
+ : { dependencies?: never };
149
+ };
150
+
151
+ type QueryFor<TContract extends ResourceContract<AnyZodType, AnyZodType>> = {
152
+ contract: TContract;
153
+ } & Omit<
154
+ QueryResourceDefinition<TContract["input"], TContract["output"]>,
155
+ "contract"
156
+ >;
157
+
158
+ type SubscriptionFor<
159
+ TContract extends ResourceContract<AnyZodType, AnyZodType>,
160
+ > = { contract: TContract } & Omit<
161
+ SubscriptionResourceDefinition<TContract["input"], TContract["output"]>,
162
+ "contract"
163
+ >;
164
+
165
+ type DerivedFor<
166
+ TContract extends ResourceContract<AnyZodType, AnyZodType>,
167
+ TDependencies extends Record<string, string>,
168
+ TDependencyOutputs,
169
+ > = {
170
+ combine: (
171
+ dependencies: TDependencyOutputs,
172
+ ) => z.input<NoInfer<TContract["output"]>>;
173
+ contract: TContract;
174
+ dependencies: TDependencies;
175
+ kind: "derived";
176
+ };
177
+
178
+ type ConfiguredResource<
179
+ TContracts extends ResourceContracts,
180
+ TDependencies,
181
+ TId extends keyof TContracts,
182
+ > =
183
+ | QueryFor<TContracts[TId]>
184
+ | SubscriptionFor<TContracts[TId]>
185
+ | (TId extends keyof TDependencies
186
+ ? TDependencies[TId] extends Record<
187
+ string,
188
+ Exclude<keyof TContracts, TId> & string
189
+ >
190
+ ? DerivedFor<
191
+ TContracts[TId],
192
+ TDependencies[TId],
193
+ DependencyOutputs<TContracts, NoInfer<TDependencies[TId]>>
194
+ >
195
+ : never
196
+ : never);
197
+
198
+ type ConfiguredResources<
199
+ TContracts extends ResourceContracts,
200
+ TDependencies,
201
+ > = {
202
+ [TId in keyof TContracts]: ConfiguredResource<TContracts, TDependencies, TId>;
203
+ } & DependencySource<TDependencies>;
204
+
205
+ export type AuthDuration = `${number}${"m" | "h" | "d"}`;
206
+
207
+ export type AuthConfigDefinition = {
208
+ mode: "cli-login";
209
+ origins?: string[];
210
+ sessionLifetime?: "never" | AuthDuration;
211
+ trustedProxyPeer?: string;
212
+ };
213
+
214
+ export type ServerConfigDefinition = {
215
+ host?: string;
216
+ logFile?: string;
217
+ port?: number;
218
+ productionWebAssetsDir?: string;
219
+ watch?: boolean;
220
+ };
221
+
222
+ type StreamDefinitions = Readonly<
223
+ Record<string, StreamHandlerDefinition<AnyZodType, AnyZodType, AnyZodType>>
224
+ >;
225
+
226
+ type OperationDefinitions = Readonly<
227
+ Record<string, OperationDefinition<AnyZodType, AnyZodType>>
228
+ >;
229
+
230
+ export type ConfigDefinition<
231
+ TResources extends Readonly<Record<string, unknown>> = Readonly<
232
+ Record<string, ResourceDefinition>
233
+ >,
234
+ TStreams extends StreamDefinitions = StreamDefinitions,
235
+ TOperations extends OperationDefinitions = OperationDefinitions,
236
+ > = {
237
+ operations?: TOperations;
238
+ resources: TResources;
239
+ streams?: TStreams;
240
+ };
241
+
242
+ export type OvermuxConfigDefinition<
243
+ TServer extends ConfigDefinition = ConfigDefinition,
244
+ > = ServerConfigDefinition & {
245
+ aiContextSnippets?: AiContextSnippetDefinition;
246
+ auth: AuthConfigDefinition;
247
+ debug?: boolean;
248
+ server: TServer;
249
+ vite?: string;
250
+ };
251
+
252
+ export type OvermuxServerResources<TServer> = TServer extends {
253
+ resources: infer TResources;
254
+ }
255
+ ? TResources
256
+ : never;
257
+
258
+ export type OvermuxServerStreams<TServer> = TServer extends {
259
+ streams?: infer TStreams;
260
+ }
261
+ ? NonNullable<TStreams>
262
+ : never;
263
+
264
+ export type OvermuxServerOperations<TServer> = TServer extends {
265
+ operations?: infer TOperations;
266
+ }
267
+ ? NonNullable<TOperations>
268
+ : never;
269
+
270
+ export const defineOvermuxServer = <
271
+ const TContracts extends ResourceContracts = {},
272
+ const TDependencies = {},
273
+ const TStreams extends StreamDefinitions = {},
274
+ const TOperations extends OperationDefinitions = {},
275
+ >(definition: {
276
+ operations?: TOperations;
277
+ resources: ConfiguredResources<TContracts, TDependencies>;
278
+ streams?: TStreams;
279
+ }): ConfigDefinition<
280
+ ConfiguredResources<TContracts, TDependencies>,
281
+ TStreams,
282
+ TOperations
283
+ > => definition;
284
+
285
+ export const defineOvermuxConfig = <const TServer extends ConfigDefinition>(
286
+ definition: OvermuxConfigDefinition<TServer>,
287
+ ): OvermuxConfigDefinition<TServer> => definition;
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+
3
+ export const noInputSchema = z.void();
4
+
5
+ export const jsonValueSchema: z.ZodType<unknown> = z.lazy(() =>
6
+ z.union([
7
+ z.string(),
8
+ z.number().finite(),
9
+ z.boolean(),
10
+ z.null(),
11
+ z.array(jsonValueSchema),
12
+ z.record(z.string(), jsonValueSchema),
13
+ ]),
14
+ );
15
+
16
+ export const parseJsonValue = <T>(value: T): T =>
17
+ jsonValueSchema.parse(value) as T;
18
+
19
+ export type ContractInputArguments<TInput extends z.ZodType> =
20
+ undefined extends z.input<TInput>
21
+ ? [input?: Exclude<z.input<TInput>, undefined>]
22
+ : [input: z.input<TInput>];
23
+
24
+ export type ResourceContract<
25
+ TInput extends z.ZodType = z.ZodType,
26
+ TOutput extends z.ZodType = z.ZodType,
27
+ > = {
28
+ input: TInput;
29
+ output: TOutput;
30
+ };
31
+
32
+ export const defineResourceContract = <
33
+ TInput extends z.ZodType,
34
+ TOutput extends z.ZodType,
35
+ >(
36
+ contract: ResourceContract<TInput, TOutput>,
37
+ ): ResourceContract<TInput, TOutput> => contract;
38
+
39
+ export type StreamContract<
40
+ TInput extends z.ZodType = z.ZodType,
41
+ TClientMessage extends z.ZodType = z.ZodType,
42
+ TServerMessage extends z.ZodType = z.ZodType,
43
+ > = {
44
+ clientMessage: TClientMessage;
45
+ input: TInput;
46
+ serverMessage: TServerMessage;
47
+ };
48
+
49
+ export const defineStreamContract = <
50
+ TInput extends z.ZodType,
51
+ TClientMessage extends z.ZodType,
52
+ TServerMessage extends z.ZodType,
53
+ >(
54
+ contract: StreamContract<TInput, TClientMessage, TServerMessage>,
55
+ ): StreamContract<TInput, TClientMessage, TServerMessage> => contract;
@@ -0,0 +1,57 @@
1
+ export {
2
+ composeAiContext,
3
+ coreAiContextSnippets,
4
+ defaultAiContextSnippets,
5
+ packageSourceSnippet,
6
+ techStackRecommendationsSnippet,
7
+ } from "./ai-context";
8
+ export type {
9
+ AiContextSnippet,
10
+ AiContextSnippetDefinition,
11
+ } from "./ai-context";
12
+ export {
13
+ defineOperation,
14
+ defineOvermuxConfig,
15
+ defineOvermuxServer,
16
+ defineStreamHandler,
17
+ } from "./config";
18
+ export type {
19
+ AuthConfigDefinition,
20
+ AuthDuration,
21
+ ConfigDefinition,
22
+ DerivedResourceDefinition,
23
+ HandlerContext,
24
+ OperationContext,
25
+ OperationDefinition,
26
+ OvermuxConfigDefinition,
27
+ OvermuxServerOperations,
28
+ OvermuxServerResources,
29
+ OvermuxServerStreams,
30
+ QueryResourceDefinition,
31
+ ResourceDefinition,
32
+ RuntimeDisposer,
33
+ ServerConfigDefinition,
34
+ StreamHandlerDefinition,
35
+ StreamSession,
36
+ SubscriptionResourceDefinition,
37
+ } from "./config";
38
+ export {
39
+ defineResourceContract,
40
+ defineStreamContract,
41
+ jsonValueSchema,
42
+ noInputSchema,
43
+ parseJsonValue,
44
+ } from "./contracts";
45
+ export type {
46
+ ContractInputArguments,
47
+ ResourceContract,
48
+ StreamContract,
49
+ } from "./contracts";
50
+ export { notificationLinkSchema, notificationSchema } from "./notifications";
51
+ export type { Notification, Notifications } from "./notifications";
52
+ export {
53
+ createOvermuxSettingsPath,
54
+ overmuxLogoutPath,
55
+ overmuxSettingsPath,
56
+ resolveOvermuxReturnTo,
57
+ } from "@overmux/shared";
@@ -0,0 +1,10 @@
1
+ // Defines notifications shared by operation handlers and delivery transports.
2
+ // Keeping validation here gives every delivery path one public contract.
3
+ import type { Notification } from "@overmux/shared";
4
+
5
+ export { notificationLinkSchema, notificationSchema } from "@overmux/shared";
6
+ export type { Notification } from "@overmux/shared";
7
+
8
+ export type Notifications = {
9
+ send: (notification: Notification) => Promise<void>;
10
+ };
@@ -0,0 +1,16 @@
1
+ export {
2
+ checkOvermux,
3
+ type CheckDiagnostic,
4
+ type CheckOvermuxOptions,
5
+ type CheckResult,
6
+ } from "../internal/server/check-overmux";
7
+ export {
8
+ getOvermuxPaths,
9
+ type GetOvermuxPathsOptions,
10
+ type OvermuxPaths,
11
+ } from "../internal/server/paths";
12
+ export {
13
+ startOvermuxServer,
14
+ type OvermuxServer,
15
+ type OvermuxServerOptions,
16
+ } from "../internal/server/start-overmux-server";
@@ -1,119 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const paneRefSchema = z.object({
4
- muxId: z.string().min(1),
5
- target: z.string().min(1),
6
- });
7
-
8
- export type PaneRef = z.infer<typeof paneRefSchema>;
9
-
10
- export const clientComponentRefSchema = z.object({
11
- kind: z.literal("client-component"),
12
- moduleId: z.string().min(1),
13
- });
14
-
15
- export type ClientComponentRef = z.infer<typeof clientComponentRefSchema>;
16
-
17
- export const clientComponent = (moduleId: string): ClientComponentRef =>
18
- clientComponentRefSchema.parse({ kind: "client-component", moduleId });
19
-
20
- export type TabTypeDefinition<
21
- TType extends string = string,
22
- TSchema extends z.ZodType = z.ZodType,
23
- > = {
24
- component: ClientComponentRef;
25
- data: TSchema;
26
- type: TType;
27
- };
28
-
29
- export const defineTabType = <
30
- const TType extends string,
31
- TSchema extends z.ZodType,
32
- >(
33
- definition: TabTypeDefinition<TType, TSchema>,
34
- ) => definition;
35
-
36
- type ConfiguredTab<TTabTypes extends readonly TabTypeDefinition[]> = {
37
- [TIndex in keyof TTabTypes]: TTabTypes[TIndex] extends TabTypeDefinition<
38
- infer TType,
39
- infer TSchema
40
- >
41
- ? {
42
- data: z.input<TSchema>;
43
- id: string;
44
- title: string;
45
- type: TType;
46
- }
47
- : never;
48
- }[number];
49
-
50
- export type SidebarEntry<
51
- TTabTypes extends readonly TabTypeDefinition[] = readonly TabTypeDefinition[],
52
- > = {
53
- id: string;
54
- status?: string;
55
- subtitle?: string;
56
- tabs: Array<ConfiguredTab<TTabTypes>>;
57
- title: string;
58
- };
59
-
60
- export type SidebarContext = {
61
- invalidate: () => void;
62
- };
63
-
64
- export type ConfigDefinition<
65
- TTabTypes extends readonly TabTypeDefinition[] = readonly TabTypeDefinition[],
66
- > = {
67
- muxes?: Record<string, unknown>;
68
- sidebar: (
69
- context: SidebarContext,
70
- ) => Promise<Array<SidebarEntry<TTabTypes>>> | Array<SidebarEntry<TTabTypes>>;
71
- tabTypes: TTabTypes;
72
- };
73
-
74
- export const defineConfig = <
75
- const TTabTypes extends readonly TabTypeDefinition[],
76
- >(
77
- definition: ConfigDefinition<TTabTypes>,
78
- ) => definition;
79
-
80
- const isZodSchema = (value: unknown): value is z.ZodType =>
81
- typeof value === "object" &&
82
- value !== null &&
83
- "safeParse" in value &&
84
- typeof value.safeParse === "function";
85
-
86
- const sidebarFunctionSchema = z.custom<ConfigDefinition["sidebar"]>(
87
- (value) => typeof value === "function",
88
- "Expected a sidebar function",
89
- );
90
-
91
- export const tabTypeDefinitionRuntimeSchema = z.object({
92
- component: clientComponentRefSchema,
93
- data: z.custom<z.ZodType>(isZodSchema, "Expected a Zod schema"),
94
- type: z.string().min(1),
95
- });
96
-
97
- export const configDefinitionRuntimeSchema = z
98
- .object({
99
- muxes: z.record(z.string(), z.unknown()).optional(),
100
- sidebar: sidebarFunctionSchema,
101
- tabTypes: z.array(tabTypeDefinitionRuntimeSchema),
102
- })
103
- .superRefine(({ tabTypes }, context) => {
104
- const seen = new Set<string>();
105
- tabTypes.forEach(({ type }, index) => {
106
- if (seen.has(type)) {
107
- context.addIssue({
108
- code: "custom",
109
- message: `Duplicate tab type: ${type}`,
110
- path: ["tabTypes", index, "type"],
111
- });
112
- }
113
- seen.add(type);
114
- });
115
- });
116
-
117
- export type RuntimeConfigDefinition = z.infer<
118
- typeof configDefinitionRuntimeSchema
119
- >;
@@ -1,51 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const protocolVersion = 1 as const;
4
-
5
- export const clientComponentManifestEntrySchema = z.object({
6
- id: z.string().min(1),
7
- type: z.string().min(1),
8
- });
9
-
10
- export const sidebarTabSnapshotSchema = z.object({
11
- data: z.unknown(),
12
- id: z.string().min(1),
13
- title: z.string().min(1),
14
- type: z.string().min(1),
15
- });
16
-
17
- export const sidebarEntrySnapshotSchema = z.object({
18
- id: z.string().min(1),
19
- status: z.string().optional(),
20
- subtitle: z.string().optional(),
21
- tabs: z.array(sidebarTabSnapshotSchema),
22
- title: z.string().min(1),
23
- });
24
-
25
- export const bootstrapResponseSchema = z.object({
26
- generation: z.number().int().positive(),
27
- protocolVersion: z.literal(protocolVersion),
28
- sidebar: z.array(sidebarEntrySnapshotSchema),
29
- tabTypes: z.array(clientComponentManifestEntrySchema),
30
- });
31
-
32
- export const runtimePublishedEventSchema = z.object({
33
- generation: z.number().int().positive(),
34
- type: z.literal("runtime-published"),
35
- });
36
-
37
- export const runtimeErrorEventSchema = z.object({
38
- generation: z.number().int().nonnegative(),
39
- message: z.string(),
40
- type: z.literal("runtime-error"),
41
- });
42
-
43
- export const runtimeEventSchema = z.discriminatedUnion("type", [
44
- runtimePublishedEventSchema,
45
- runtimeErrorEventSchema,
46
- ]);
47
-
48
- export type BootstrapResponse = z.infer<typeof bootstrapResponseSchema>;
49
- export type RuntimeEvent = z.infer<typeof runtimeEventSchema>;
50
- export type SidebarEntrySnapshot = z.infer<typeof sidebarEntrySnapshotSchema>;
51
- export type SidebarTabSnapshot = z.infer<typeof sidebarTabSnapshotSchema>;