overmux 0.0.10 → 0.0.12
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.
- package/CHANGELOG.md +22 -0
- package/dist/bin.js +145 -58
- package/dist/bin.js.map +1 -1
- package/dist/docs/400-reference/200-configuration.md +54 -4
- package/dist/docs/400-reference/500-server/000-index.md +4 -0
- package/dist/docs/400-reference/500-server/100-resources.md +5 -0
- package/dist/docs/400-reference/500-server/200-operations.md +1 -0
- package/dist/docs/400-reference/500-server/300-streams.md +7 -1
- package/dist/docs/400-reference/500-server/400-notifications.md +4 -0
- package/dist/docs/400-reference/500-server/500-api.md +26 -5
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +55 -14
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/{index-Dk11nKIv.d.ts → index-C-8Kzrnc.d.ts} +23 -8
- package/dist/exports/index-C-8Kzrnc.d.ts.map +1 -0
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/index.js +1 -1
- package/dist/exports/index.js.map +1 -1
- package/dist/exports/{notifications-BFAD3QQl.js → notifications-BBKvKZgI.js} +8 -2
- package/dist/exports/{notifications-BFAD3QQl.js.map → notifications-BBKvKZgI.js.map} +1 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +8 -2
- package/dist/exports/server.js.map +1 -1
- package/dist/internal/server/coordinator/server-child.js +616 -883
- package/dist/internal/server/coordinator/server-child.js.map +1 -1
- package/dist/internal/server/worker-entry.d.ts +1 -0
- package/dist/internal/server/worker-entry.js +728 -0
- package/dist/internal/server/worker-entry.js.map +1 -0
- package/dist/push/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/push/badge.png +0 -0
- package/dist/push/icon.png +0 -0
- package/dist/push/sw.js +88 -0
- package/dist/push/sw.js.map +1 -0
- package/dist/worker-protocol-hXs4FXCH.js +638 -0
- package/dist/worker-protocol-hXs4FXCH.js.map +1 -0
- package/docs/400-reference/200-configuration.md +54 -4
- package/docs/400-reference/500-server/000-index.md +4 -0
- package/docs/400-reference/500-server/100-resources.md +5 -0
- package/docs/400-reference/500-server/200-operations.md +1 -0
- package/docs/400-reference/500-server/300-streams.md +7 -1
- package/docs/400-reference/500-server/400-notifications.md +4 -0
- package/docs/400-reference/500-server/500-api.md +26 -5
- package/package.json +4 -3
- package/src/internal/client/background-notifications.ts +3 -1
- package/src/internal/client/host/hosted-pages/browser-notification-settings.tsx +8 -3
- package/src/internal/client/host/overmux-host.tsx +4 -8
- package/src/internal/client/push-assets/badge.png +0 -0
- package/src/internal/client/push-assets/icon.png +0 -0
- package/src/internal/client/push-service-worker.ts +118 -0
- package/src/internal/client/register-push-worker.ts +63 -0
- package/src/internal/server/coordinator/ipc-protocol.ts +2 -1
- package/src/internal/server/http/operation-handler.ts +3 -0
- package/src/internal/server/http/request-logging.ts +1 -1
- package/src/internal/server/http/routes.ts +47 -2
- package/src/internal/server/protocol-error.ts +19 -0
- package/src/internal/server/runtime/create-runtime.ts +11 -5
- package/src/internal/server/runtime/handler-logger.ts +54 -0
- package/src/internal/server/runtime/runtime-operations.ts +23 -5
- package/src/internal/server/runtime/runtime-resources.ts +158 -88
- package/src/internal/server/runtime/runtime-streams.ts +24 -8
- package/src/internal/server/runtime/worker-capabilities.ts +67 -0
- package/src/internal/server/runtime/worker-connection.ts +549 -0
- package/src/internal/server/runtime/worker-protocol.ts +173 -0
- package/src/internal/server/runtime/worker-runtime.ts +214 -0
- package/src/internal/server/server-logger.ts +25 -37
- package/src/internal/server/server-startup-options.ts +7 -6
- package/src/internal/server/start-application-server.ts +22 -18
- package/src/internal/server/start-overmux-server.ts +2 -2
- package/src/internal/server/websocket-connection.ts +97 -32
- package/src/internal/server/websocket-server.ts +5 -1
- package/src/internal/server/worker-entry.ts +504 -0
- package/src/internal/shared/protocol.ts +3 -3
- package/src/internal/shared/routes.ts +2 -0
- package/src/public/config.ts +15 -23
- package/src/public/handler-logger.ts +7 -0
- package/src/public/index.ts +3 -1
- package/dist/exports/index-Dk11nKIv.d.ts.map +0 -1
|
@@ -16,6 +16,13 @@ type InstanceIdentity = {
|
|
|
16
16
|
instanceId: string;
|
|
17
17
|
deepLinkPrefix: string;
|
|
18
18
|
};
|
|
19
|
+
declare const logLevelSchema: z.ZodEnum<{
|
|
20
|
+
debug: "debug";
|
|
21
|
+
info: "info";
|
|
22
|
+
warn: "warn";
|
|
23
|
+
error: "error";
|
|
24
|
+
}>;
|
|
25
|
+
type LogLevel = z.infer<typeof logLevelSchema>;
|
|
19
26
|
declare const packageSourceSnippet: "package-source";
|
|
20
27
|
declare const techStackRecommendationsSnippet: "tech-stack-recommendations";
|
|
21
28
|
declare const aiContextSnippets: readonly ["package-source", "tech-stack-recommendations"];
|
|
@@ -24,6 +31,12 @@ type AiContextSnippetDefinition = readonly AiContextSnippet[];
|
|
|
24
31
|
declare const coreAiContextSnippets: readonly ["package-source"];
|
|
25
32
|
declare const defaultAiContextSnippets: readonly ["package-source", "tech-stack-recommendations"];
|
|
26
33
|
declare const composeAiContext: (snippets: AiContextSnippetDefinition) => string;
|
|
34
|
+
type HandlerLogger = {
|
|
35
|
+
debug: (event: string, details?: Record<string, unknown>) => void;
|
|
36
|
+
info: (event: string, details?: Record<string, unknown>) => void;
|
|
37
|
+
warn: (event: string, details?: Record<string, unknown>) => void;
|
|
38
|
+
error: (event: string, details?: Record<string, unknown>) => void;
|
|
39
|
+
};
|
|
27
40
|
type Notifications = {
|
|
28
41
|
send: (notification: Notification) => Promise<void>;
|
|
29
42
|
};
|
|
@@ -51,9 +64,11 @@ type ResourceInputMap = Readonly<Record<string, unknown>>;
|
|
|
51
64
|
type InvalidationArguments<TInputs extends ResourceInputMap> = { [TId in keyof TInputs & string]: [resourceId: TId, input?: TInputs[TId]]; }[keyof TInputs & string];
|
|
52
65
|
type HandlerContext<TInputs extends ResourceInputMap = {}> = {
|
|
53
66
|
instance: InstanceContext;
|
|
67
|
+
logger: HandlerLogger;
|
|
54
68
|
invalidate: (...args: InvalidationArguments<TInputs>) => void;
|
|
55
69
|
signal: AbortSignal;
|
|
56
70
|
};
|
|
71
|
+
type StreamContext = Pick<HandlerContext, "instance" | "signal" | "logger">;
|
|
57
72
|
type OperationContext<TInputs extends ResourceInputMap = {}> = HandlerContext<TInputs> & {
|
|
58
73
|
notifications: Notifications;
|
|
59
74
|
};
|
|
@@ -90,14 +105,14 @@ type StreamSession<TClientMessage = unknown> = {
|
|
|
90
105
|
dispose?: RuntimeDisposer;
|
|
91
106
|
onMessage?: (message: TClientMessage) => Promise<void> | void;
|
|
92
107
|
};
|
|
93
|
-
type StreamHandlerDefinition<TInput extends z.ZodType = z.ZodType, TClientMessage extends z.ZodType = z.ZodType, TServerMessage extends z.ZodType = z.ZodType
|
|
108
|
+
type StreamHandlerDefinition<TInput extends z.ZodType = z.ZodType, TClientMessage extends z.ZodType = z.ZodType, TServerMessage extends z.ZodType = z.ZodType> = {
|
|
94
109
|
contract: StreamContract<TInput, TClientMessage, TServerMessage>;
|
|
95
|
-
open: (input: z.output<TInput>, context:
|
|
110
|
+
open: (input: z.output<TInput>, context: StreamContext & {
|
|
96
111
|
emit: (message: z.input<NoInfer<TServerMessage>>) => void;
|
|
97
112
|
fail: (cause: unknown) => void;
|
|
98
113
|
}) => Promise<StreamSession<z.output<TClientMessage>>> | StreamSession<z.output<TClientMessage>>;
|
|
99
114
|
};
|
|
100
|
-
declare const defineStreamHandler: <TInput extends z.ZodType, TClientMessage extends z.ZodType, TServerMessage extends z.ZodType
|
|
115
|
+
declare const defineStreamHandler: <TInput extends z.ZodType, TClientMessage extends z.ZodType, TServerMessage extends z.ZodType>(contract: StreamContract<TInput, TClientMessage, TServerMessage>, open: StreamHandlerDefinition<TInput, TClientMessage, TServerMessage>["open"]) => StreamHandlerDefinition<TInput, TClientMessage, TServerMessage>;
|
|
101
116
|
type ResourceContracts = Record<string, ResourceContract<AnyZodType, AnyZodType>>;
|
|
102
117
|
type ResourceInputs<TContracts extends ResourceContracts> = { [TId in keyof TContracts]: z.input<TContracts[TId]["input"]>; };
|
|
103
118
|
type DependencyOutputs<TContracts extends ResourceContracts, TDependencies extends Record<string, unknown>> = { [TName in keyof TDependencies]: TDependencies[TName] extends keyof TContracts ? z.output<TContracts[TDependencies[TName]]["output"]> : never; };
|
|
@@ -133,7 +148,7 @@ type ServerConfigDefinition = {
|
|
|
133
148
|
productionWebAssetsDir?: string;
|
|
134
149
|
watch?: boolean;
|
|
135
150
|
};
|
|
136
|
-
type StreamDefinitions
|
|
151
|
+
type StreamDefinitions = Readonly<Record<string, StreamHandlerDefinition<AnyZodType, AnyZodType, AnyZodType>>>;
|
|
137
152
|
type OperationDefinitions = Readonly<Record<string, OperationDefinition<AnyZodType, AnyZodType, OperationContext<ResourceInputMap>>>>;
|
|
138
153
|
type OperationInputs = Record<string, AnyZodType>;
|
|
139
154
|
type OperationOutputSchema<TOutputs, TId extends PropertyKey> = TId extends keyof TOutputs ? TOutputs[TId] extends z.ZodType ? TOutputs[TId] : z.ZodVoid : z.ZodVoid;
|
|
@@ -155,7 +170,7 @@ type ConfigDefinition<TResources extends Readonly<Record<string, unknown>> = Rea
|
|
|
155
170
|
type OvermuxConfigDefinition<TServer extends ConfigDefinition = ConfigDefinition> = ServerConfigDefinition & {
|
|
156
171
|
aiContextSnippets?: AiContextSnippetDefinition;
|
|
157
172
|
auth: AuthConfigDefinition;
|
|
158
|
-
|
|
173
|
+
logLevel?: LogLevel;
|
|
159
174
|
instanceId?: string | ((context: {
|
|
160
175
|
port: number;
|
|
161
176
|
}) => string);
|
|
@@ -174,8 +189,8 @@ type OvermuxServerOperations<TServer> = TServer extends {
|
|
|
174
189
|
declare const defineOvermuxServer: <const TContracts extends ResourceContracts = {}, const TDependencies = {}, const TStreams extends StreamDefinitions = {}, const TInputs extends OperationInputs = {}, const TOutputs = {}>(definition: {
|
|
175
190
|
operations?: ConfiguredOperations<TInputs, TOutputs, NoInfer<TContracts>>;
|
|
176
191
|
resources: ConfiguredResources<TContracts, TDependencies>;
|
|
177
|
-
streams?: TStreams & StreamDefinitions
|
|
192
|
+
streams?: TStreams & StreamDefinitions;
|
|
178
193
|
}) => ConfigDefinition<ConfiguredResources<TContracts, TDependencies>, TStreams, NormalizedOperations<TInputs, TOutputs, TContracts>>;
|
|
179
194
|
declare const defineOvermuxConfig: <const TServer extends ConfigDefinition>(definition: OvermuxConfigDefinition<TServer>) => OvermuxConfigDefinition<TServer>;
|
|
180
|
-
export {
|
|
181
|
-
//# sourceMappingURL=index-
|
|
195
|
+
export { jsonValueSchema as A, packageSourceSnippet as B, defineOvermuxServer as C, StreamContract as D, ResourceContract as E, composeAiContext as F, createOvermuxSettingsPath as G, InstanceIdentity as H, AiContextSnippet as I, overmuxLogoutPath as J, notificationLinkSchema as K, AiContextSnippetDefinition as L, parseJsonValue as M, Notifications as N, defineResourceContract as O, HandlerLogger as P, coreAiContextSnippets as R, defineOvermuxConfig as S, ContractInputArguments as T, LogLevel as U, techStackRecommendationsSnippet as V, Notification as W, resolveOvermuxReturnTo as X, overmuxSettingsPath as Y, StreamContext as _, HandlerContext as a, SubscriptionResourceDefinition as b, OperationDefinition as c, OvermuxServerResources as d, OvermuxServerStreams as f, ServerConfigDefinition as g, RuntimeDisposer as h, DerivedResourceDefinition as i, noInputSchema as j, defineStreamContract as k, OvermuxConfigDefinition as l, ResourceDefinition as m, AuthDuration as n, InstanceContext as o, QueryResourceDefinition as p, notificationSchema as q, ConfigDefinition as r, OperationContext as s, AuthConfigDefinition as t, OvermuxServerOperations as u, StreamHandlerDefinition as v, defineStreamHandler as w, defineOperation as x, StreamSession as y, defaultAiContextSnippets as z };
|
|
196
|
+
//# sourceMappingURL=index-C-8Kzrnc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C-8Kzrnc.d.ts","names":[],"sources":["../../../shared/dist/index.d.ts","../../../ai-context/dist/index.d.ts","../../src/public/ai-context.ts","../../src/public/handler-logger.ts","../../src/public/notif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;;KAGA,wBACV,gBAAgB,mBAAmB,oBACjC;EACF,oBAAoB;EACpB,MAAM;EACN,WAAW;EACX,wBAAwB;IAAW;;EACnC,QAAQ;EACR;;KAGU,uBAAuB,WAAW;EAC5C,iBAAiB;IAEf;KAGQ,qBAAqB,WAAW;EAC1C,gBAAgB;IAEd,YAAY;KAGJ,wBAAwB,WAAW;EAC7C,mBAAmB;IAEjB,YAAY;cAGH,4BACL,mBAAmB,8BACnB,0BACA,iBAAiB,8BACjB,gBAAgB,4BAChB,eACN;EACA,aAAa,qBAAqB,SAAS,UAAU,QAAQ;EAC7D,WAAW,oBAAoB,YAAY;EAC3C,UAAU,WAAW;MACnB,iBACF,oBAAoB,YAAY,gBAChC,UACA,qBAAqB,SAAS,UAAU;cAM7B,4BAA6B,gBAAgB,kBACxD,YAAY,wBAAwB,aACnC,wBAAwB"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type AiContextSnippet, type AiContextSnippetDefinition, type AuthConfigDefinition, type AuthDuration, type ConfigDefinition, type ContractInputArguments, type DerivedResourceDefinition, type HandlerContext, type InstanceContext, type InstanceIdentity, type Notification, type Notifications, type OperationContext, type OperationDefinition, type OvermuxConfigDefinition, type OvermuxServerOperations, type OvermuxServerResources, type OvermuxServerStreams, type QueryResourceDefinition, type ResourceContract, type ResourceDefinition, type RuntimeDisposer, type ServerConfigDefinition, type StreamContract, type StreamHandlerDefinition, type StreamSession, type SubscriptionResourceDefinition, composeAiContext, coreAiContextSnippets, createOvermuxSettingsPath, defaultAiContextSnippets, defineOperation, defineOvermuxConfig, defineOvermuxServer, defineResourceContract, defineStreamContract, defineStreamHandler, jsonValueSchema, noInputSchema, notificationLinkSchema, notificationSchema, overmuxLogoutPath, overmuxSettingsPath, packageSourceSnippet, parseJsonValue, resolveOvermuxReturnTo, techStackRecommendationsSnippet };
|
|
1
|
+
import { A as jsonValueSchema, B as packageSourceSnippet, C as defineOvermuxServer, D as StreamContract, E as ResourceContract, F as composeAiContext, G as createOvermuxSettingsPath, H as InstanceIdentity, I as AiContextSnippet, J as overmuxLogoutPath, K as notificationLinkSchema, L as AiContextSnippetDefinition, M as parseJsonValue, N as Notifications, O as defineResourceContract, P as HandlerLogger, R as coreAiContextSnippets, S as defineOvermuxConfig, T as ContractInputArguments, U as LogLevel, V as techStackRecommendationsSnippet, W as Notification, X as resolveOvermuxReturnTo, Y as overmuxSettingsPath, _ as StreamContext, a as HandlerContext, b as SubscriptionResourceDefinition, c as OperationDefinition, d as OvermuxServerResources, f as OvermuxServerStreams, g as ServerConfigDefinition, h as RuntimeDisposer, i as DerivedResourceDefinition, j as noInputSchema, k as defineStreamContract, l as OvermuxConfigDefinition, m as ResourceDefinition, n as AuthDuration, o as InstanceContext, p as QueryResourceDefinition, q as notificationSchema, r as ConfigDefinition, s as OperationContext, t as AuthConfigDefinition, u as OvermuxServerOperations, v as StreamHandlerDefinition, w as defineStreamHandler, x as defineOperation, y as StreamSession, z as defaultAiContextSnippets } from "./index-C-8Kzrnc.js";
|
|
2
|
+
export { type AiContextSnippet, type AiContextSnippetDefinition, type AuthConfigDefinition, type AuthDuration, type ConfigDefinition, type ContractInputArguments, type DerivedResourceDefinition, type HandlerContext, type HandlerLogger, type InstanceContext, type InstanceIdentity, type LogLevel, type Notification, type Notifications, type OperationContext, type OperationDefinition, type OvermuxConfigDefinition, type OvermuxServerOperations, type OvermuxServerResources, type OvermuxServerStreams, type QueryResourceDefinition, type ResourceContract, type ResourceDefinition, type RuntimeDisposer, type ServerConfigDefinition, type StreamContext, type StreamContract, type StreamHandlerDefinition, type StreamSession, type SubscriptionResourceDefinition, composeAiContext, coreAiContextSnippets, createOvermuxSettingsPath, defaultAiContextSnippets, defineOperation, defineOvermuxConfig, defineOvermuxServer, defineResourceContract, defineStreamContract, defineStreamHandler, jsonValueSchema, noInputSchema, notificationLinkSchema, notificationSchema, overmuxLogoutPath, overmuxSettingsPath, packageSourceSnippet, parseJsonValue, resolveOvermuxReturnTo, techStackRecommendationsSnippet };
|
package/dist/exports/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as notificationLinkSchema, c as overmuxSettingsPath, n as createOvermuxSettingsPath, o as notificationSchema, s as overmuxLogoutPath, u as resolveOvermuxReturnTo } from "./notifications-BBKvKZgI.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region ../ai-context/dist/index.js
|
|
4
4
|
const packageSourceSnippet = "package-source";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../ai-context/dist/index.js","../../src/public/ai-context.ts","../../src/public/config.ts","../../src/public/contracts.ts"],"sourcesContent":["//#region src/index.ts\nconst packageSourceSnippet = \"package-source\";\nconst techStackRecommendationsSnippet = \"tech-stack-recommendations\";\nconst aiContextSnippets = [packageSourceSnippet, techStackRecommendationsSnippet];\nconst coreAiContextSnippets = [packageSourceSnippet];\nconst defaultAiContextSnippets = [...coreAiContextSnippets, techStackRecommendationsSnippet];\nconst packageSourceSnippetContent = `Overmux ships with documentation and TypeScript source.\n\nRun \\`overmux docs path\\` to find the installed documentation directory for the Overmux CLI. This prints a documentation directory, not source paths.\n\nInspect TypeScript source in installed packages, e.g. \\`node_modules/overmux/src\\` and \\`node_modules/@overmux/xterm/src\\`.\n\nInspect these files so guidance matches the versions used by the application.`;\nconst techStackRecommendationsSnippetContent = `Prefer pnpm as the package manager, TanStack Router for routing, shadcn/ui for UI components, and Zod for schemas and runtime validation. For custom Git diff views, prefer @pierre/diffs (https://diffs.com/). Follow the application's established stack when it already differs.`;\nconst aiContextContentBySnippet = {\n\t[packageSourceSnippet]: packageSourceSnippetContent,\n\t[techStackRecommendationsSnippet]: techStackRecommendationsSnippetContent\n};\n//#endregion\nexport { aiContextContentBySnippet, aiContextSnippets, coreAiContextSnippets, defaultAiContextSnippets, packageSourceSnippet, techStackRecommendationsSnippet };\n\n//# sourceMappingURL=index.js.map","import {\n aiContextContentBySnippet,\n type AiContextSnippetDefinition,\n} from \"@overmux/ai-context\";\n\nexport {\n coreAiContextSnippets,\n defaultAiContextSnippets,\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n type AiContextSnippetDefinition,\n} from \"@overmux/ai-context\";\n\nexport const composeAiContext = (snippets: AiContextSnippetDefinition) =>\n snippets.length === 0\n ? \"\"\n : `${snippets\n .map(\n (snippet) => `## ${snippet}\\n\\n${aiContextContentBySnippet[snippet]}`,\n )\n .join(\"\\n\\n\")}\\n`;\n","import { z } from \"zod\";\n\nimport type { AiContextSnippetDefinition } from \"./ai-context\";\nimport type { Notifications } from \"./notifications\";\nimport type { ResourceContract, StreamContract } from \"./contracts\";\n\nexport type RuntimeDisposer = () => Promise<void> | void;\n\nexport type InstanceContext = {\n getInstanceId: () => string;\n getDeepLinkPrefix: () => string;\n};\n\ntype ResourceInputMap = Readonly<Record<string, unknown>>;\n\n// Keep IDs paired with their raw inputs when checking calls and reusable handlers.\ntype InvalidationArguments<TInputs extends ResourceInputMap> = {\n [TId in keyof TInputs & string]: [resourceId: TId, input?: TInputs[TId]];\n}[keyof TInputs & string];\n\nexport type HandlerContext<TInputs extends ResourceInputMap = {}> = {\n instance: InstanceContext;\n invalidate: (...args: InvalidationArguments<TInputs>) => void;\n signal: AbortSignal;\n};\n\nexport type OperationContext<TInputs extends ResourceInputMap = {}> =\n HandlerContext<TInputs> & {\n notifications: Notifications;\n };\n\nexport type OperationDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n TContext = OperationContext,\n> = {\n handle: (\n input: z.output<TInput>,\n context: TContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n input: TInput;\n output: TOutput;\n};\n\n// Infer schemas from this definition, not a surrounding operation map's broad constraint.\nexport const defineOperation = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n TContext = OperationContext,\n>({\n handle,\n input,\n output,\n}: {\n handle: OperationDefinition<TInput, TOutput, TContext>[\"handle\"];\n input: TInput;\n output?: TOutput;\n}): OperationDefinition<NoInfer<TInput>, NoInfer<TOutput>, TContext> => ({\n handle,\n input,\n output: (output ?? z.void()) as TOutput,\n});\n\nexport type QueryResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TContext = HandlerContext,\n> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"query\";\n read: (\n input: z.output<TInput>,\n context: TContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n};\n\nexport type SubscriptionResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TContext = HandlerContext,\n> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"subscription\";\n read: QueryResourceDefinition<TInput, TOutput, TContext>[\"read\"];\n subscribe: (\n input: z.output<TInput>,\n invalidate: () => void,\n context: TContext,\n ) => RuntimeDisposer | Promise<RuntimeDisposer>;\n};\n\nexport type DerivedResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TDependencies extends Readonly<Record<string, string>> = Readonly<\n Record<string, string>\n >,\n TDependencyOutputs = Readonly<Record<string, unknown>>,\n> = {\n combine: (dependencies: TDependencyOutputs) => z.input<NoInfer<TOutput>>;\n contract: ResourceContract<TInput, TOutput>;\n dependencies: TDependencies;\n kind: \"derived\";\n};\n\ntype AnyZodType = z.ZodType<any, any, any>;\n\nexport type ResourceDefinition =\n | QueryResourceDefinition<\n AnyZodType,\n AnyZodType,\n HandlerContext<ResourceInputMap>\n >\n | SubscriptionResourceDefinition<\n AnyZodType,\n AnyZodType,\n HandlerContext<ResourceInputMap>\n >\n | DerivedResourceDefinition<AnyZodType, AnyZodType, any, any>;\n\nexport type StreamSession<TClientMessage = unknown> = {\n dispose?: RuntimeDisposer;\n onMessage?: (message: TClientMessage) => Promise<void> | void;\n};\n\nexport type StreamHandlerDefinition<\n TInput extends z.ZodType = z.ZodType,\n TClientMessage extends z.ZodType = z.ZodType,\n TServerMessage extends z.ZodType = z.ZodType,\n TContext = HandlerContext,\n> = {\n contract: StreamContract<TInput, TClientMessage, TServerMessage>;\n open: (\n input: z.output<TInput>,\n context: TContext & {\n emit: (message: z.input<NoInfer<TServerMessage>>) => void;\n fail: (cause: unknown) => void;\n },\n ) =>\n | Promise<StreamSession<z.output<TClientMessage>>>\n | StreamSession<z.output<TClientMessage>>;\n};\n\nexport const defineStreamHandler = <\n TInput extends z.ZodType,\n TClientMessage extends z.ZodType,\n TServerMessage extends z.ZodType,\n TContext = HandlerContext,\n>(\n contract: StreamContract<TInput, TClientMessage, TServerMessage>,\n open: StreamHandlerDefinition<\n TInput,\n TClientMessage,\n TServerMessage,\n TContext\n >[\"open\"],\n): StreamHandlerDefinition<\n TInput,\n TClientMessage,\n TServerMessage,\n TContext\n> => ({\n contract,\n open,\n});\n\ntype ResourceContracts = Record<\n string,\n ResourceContract<AnyZodType, AnyZodType>\n>;\n\ntype ResourceInputs<TContracts extends ResourceContracts> = {\n [TId in keyof TContracts]: z.input<TContracts[TId][\"input\"]>;\n};\n\ntype DependencyOutputs<\n TContracts extends ResourceContracts,\n TDependencies extends Record<string, unknown>,\n> = {\n [TName in keyof TDependencies]: TDependencies[TName] extends keyof TContracts\n ? z.output<TContracts[TDependencies[TName]][\"output\"]>\n : never;\n};\n\ntype DependencySource<TDependencies> = {\n [TId in keyof TDependencies]: TDependencies[TId] extends Record<\n string,\n string\n >\n ? { dependencies: TDependencies[TId] }\n : { dependencies?: never };\n};\n\ntype QueryFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TContracts extends ResourceContracts,\n> = {\n contract: TContract;\n} & Omit<\n QueryResourceDefinition<\n TContract[\"input\"],\n TContract[\"output\"],\n HandlerContext<ResourceInputs<NoInfer<TContracts>>>\n >,\n \"contract\"\n>;\n\ntype SubscriptionFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TContracts extends ResourceContracts,\n> = { contract: TContract } & Omit<\n SubscriptionResourceDefinition<\n TContract[\"input\"],\n TContract[\"output\"],\n HandlerContext<ResourceInputs<NoInfer<TContracts>>>\n >,\n \"contract\"\n>;\n\ntype DerivedFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TDependencies extends Record<string, string>,\n TDependencyOutputs,\n> = {\n combine: (\n dependencies: TDependencyOutputs,\n ) => z.input<NoInfer<TContract[\"output\"]>>;\n contract: TContract;\n dependencies: TDependencies;\n kind: \"derived\";\n};\n\ntype ConfiguredResource<\n TContracts extends ResourceContracts,\n TDependencies,\n TId extends keyof TContracts,\n> =\n | QueryFor<TContracts[TId], TContracts>\n | SubscriptionFor<TContracts[TId], TContracts>\n | (TId extends keyof TDependencies\n ? TDependencies[TId] extends Record<\n string,\n Exclude<keyof TContracts, TId> & string\n >\n ? DerivedFor<\n TContracts[TId],\n TDependencies[TId],\n DependencyOutputs<TContracts, NoInfer<TDependencies[TId]>>\n >\n : never\n : never);\n\ntype ConfiguredResources<\n TContracts extends ResourceContracts,\n TDependencies,\n> = {\n [TId in keyof TContracts]: ConfiguredResource<TContracts, TDependencies, TId>;\n} & DependencySource<TDependencies>;\n\nexport type AuthDuration = `${number}${\"m\" | \"h\" | \"d\"}`;\n\nexport type AuthConfigDefinition = {\n mode: \"cli-login\";\n origins?: string[];\n sessionLifetime?: \"forever\" | AuthDuration;\n trustedProxyPeer?: string;\n};\n\nexport type ServerConfigDefinition = {\n host?: string;\n port?: number;\n productionWebAssetsDir?: string;\n watch?: boolean;\n};\n\ntype StreamDefinitions<TContext = HandlerContext<ResourceInputMap>> = Readonly<\n Record<\n string,\n StreamHandlerDefinition<AnyZodType, AnyZodType, AnyZodType, TContext>\n >\n>;\n\ntype OperationDefinitions = Readonly<\n Record<\n string,\n OperationDefinition<\n AnyZodType,\n AnyZodType,\n OperationContext<ResourceInputMap>\n >\n >\n>;\n\ntype OperationInputs = Record<string, AnyZodType>;\n\ntype OperationOutputSchema<\n TOutputs,\n TId extends PropertyKey,\n> = TId extends keyof TOutputs\n ? TOutputs[TId] extends z.ZodType\n ? TOutputs[TId]\n : z.ZodVoid\n : z.ZodVoid;\n\ntype ConfiguredOperations<\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n> = {\n [TId in keyof TInputs]: {\n input: TInputs[TId];\n output?: OperationOutputSchema<TOutputs, TId>;\n handle: OperationDefinition<\n TInputs[TId],\n OperationOutputSchema<TOutputs, TId>,\n OperationContext<ResourceInputs<TContracts>>\n >[\"handle\"];\n };\n} & {\n [TId in keyof TOutputs]: TOutputs[TId] extends z.ZodType\n ? { output: TOutputs[TId] }\n : { output?: never };\n};\n\ntype NormalizedOperations<\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n> = {\n [TId in keyof TInputs]: OperationDefinition<\n TInputs[TId],\n OperationOutputSchema<TOutputs, TId>,\n OperationContext<ResourceInputs<TContracts>>\n >;\n};\n\nconst normalizeOperations = <\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n>(\n operations: ConfiguredOperations<TInputs, TOutputs, TContracts> | undefined,\n): NormalizedOperations<TInputs, TOutputs, TContracts> | undefined => {\n if (operations === undefined) {\n return undefined;\n }\n // Preserve every key and handler; only absent output schemas become ZodVoid.\n return Object.fromEntries(\n Object.entries(operations).map(([id, definition]) => [\n id,\n { ...definition, output: definition.output ?? z.void() },\n ]),\n ) as NormalizedOperations<TInputs, TOutputs, TContracts>;\n};\n\nexport type ConfigDefinition<\n TResources extends Readonly<Record<string, unknown>> = Readonly<\n Record<string, ResourceDefinition>\n >,\n TStreams extends StreamDefinitions = StreamDefinitions,\n TOperations extends OperationDefinitions = OperationDefinitions,\n> = {\n operations?: TOperations;\n resources: TResources;\n streams?: TStreams;\n};\n\nexport type OvermuxConfigDefinition<\n TServer extends ConfigDefinition = ConfigDefinition,\n> = ServerConfigDefinition & {\n aiContextSnippets?: AiContextSnippetDefinition;\n auth: AuthConfigDefinition;\n debug?: boolean;\n instanceId?: string | ((context: { port: number }) => string);\n server: TServer;\n vite?: string;\n};\n\nexport type OvermuxServerResources<TServer> = TServer extends {\n resources: infer TResources;\n}\n ? TResources\n : never;\n\nexport type OvermuxServerStreams<TServer> = TServer extends {\n streams?: infer TStreams;\n}\n ? NonNullable<TStreams>\n : never;\n\nexport type OvermuxServerOperations<TServer> = TServer extends {\n operations?: infer TOperations;\n}\n ? NonNullable<TOperations>\n : never;\n\nexport const defineOvermuxServer = <\n const TContracts extends ResourceContracts = {},\n const TDependencies = {},\n const TStreams extends StreamDefinitions = {},\n const TInputs extends OperationInputs = {},\n const TOutputs = {},\n>(definition: {\n operations?: ConfiguredOperations<TInputs, TOutputs, NoInfer<TContracts>>;\n resources: ConfiguredResources<TContracts, TDependencies>;\n streams?: TStreams &\n StreamDefinitions<HandlerContext<ResourceInputs<NoInfer<TContracts>>>>;\n}): ConfigDefinition<\n ConfiguredResources<TContracts, TDependencies>,\n TStreams,\n NormalizedOperations<TInputs, TOutputs, TContracts>\n> => ({\n ...definition,\n operations: normalizeOperations(definition.operations),\n});\n\nexport const defineOvermuxConfig = <const TServer extends ConfigDefinition>(\n definition: OvermuxConfigDefinition<TServer>,\n): OvermuxConfigDefinition<TServer> => definition;\n","import { z } from \"zod\";\n\nexport const noInputSchema = z.void();\n\nexport const jsonValueSchema: z.ZodType<unknown> = z.lazy(() =>\n z.union([\n z.string(),\n z.number().finite(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n);\n\nexport const parseJsonValue = <T>(value: T): T =>\n jsonValueSchema.parse(value) as T;\n\nexport type ContractInputArguments<TInput extends z.ZodType> =\n undefined extends z.input<TInput>\n ? [input?: Exclude<z.input<TInput>, undefined>]\n : [input: z.input<TInput>];\n\nexport type ResourceContract<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n> = {\n input: TInput;\n output: TOutput;\n};\n\nexport const defineResourceContract = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType,\n>(\n contract: ResourceContract<TInput, TOutput>,\n): ResourceContract<TInput, TOutput> => contract;\n\nexport type StreamContract<\n TInput extends z.ZodType = z.ZodType,\n TClientMessage extends z.ZodType = z.ZodType,\n TServerMessage extends z.ZodType = z.ZodType,\n> = {\n clientMessage: TClientMessage;\n input: TInput;\n serverMessage: TServerMessage;\n};\n\nexport const defineStreamContract = <\n TInput extends z.ZodType,\n TClientMessage extends z.ZodType,\n TServerMessage extends z.ZodType,\n>(\n contract: StreamContract<TInput, TClientMessage, TServerMessage>,\n): StreamContract<TInput, TClientMessage, TServerMessage> => contract;\n"],"mappings":";;;AACA,MAAM,uBAAuB;AAC7B,MAAM,kCAAkC;AAExC,MAAM,wBAAwB,CAAC,oBAAoB;AACnD,MAAM,2BAA2B,CAAC,GAAG,uBAAuB,+BAA+B;AAC3F,MAAM,8BAA8B;;;;;;;AAOpC,MAAM,yCAAyC;AAC/C,MAAM,4BAA4B;EAChC,uBAAuB;EACvB,kCAAkC;AACpC;;;ACHA,MAAa,oBAAoB,aAC/B,SAAS,WAAW,IAChB,KACA,GAAG,SACA,KACE,YAAY,MAAM,QAAQ,MAAM,0BAA0B,UAC7D,CAAC,CACA,KAAK,MAAM,EAAE;;;ACwBtB,MAAa,mBAIX,EACA,QACA,OACA,cAKuE;CACvE;CACA;CACA,QAAS,UAAU,EAAE,KAAK;AAC5B;AAkFA,MAAa,uBAMX,UACA,UAWI;CACJ;CACA;AACF;AA4KA,MAAM,uBAKJ,eACoE;CACpE,IAAI,eAAe,KAAA,GACjB;CAGF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,gBAAgB,CACnD,IACA;EAAE,GAAG;EAAY,QAAQ,WAAW,UAAU,EAAE,KAAK;CAAE,CACzD,CAAC,CACH;AACF;AA2CA,MAAa,uBAMX,gBASI;CACJ,GAAG;CACH,YAAY,oBAAoB,WAAW,UAAU;AACvD;AAEA,MAAa,uBACX,eACqC;;;AChavC,MAAa,gBAAgB,EAAE,KAAK;AAEpC,MAAa,kBAAsC,EAAE,WACnD,EAAE,MAAM;CACN,EAAE,OAAO;CACT,EAAE,OAAO,CAAC,CAAC,OAAO;CAClB,EAAE,QAAQ;CACV,EAAE,KAAK;CACP,EAAE,MAAM,eAAe;CACvB,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;AACtC,CAAC,CACH;AAEA,MAAa,kBAAqB,UAChC,gBAAgB,MAAM,KAAK;AAe7B,MAAa,0BAIX,aACsC;AAYxC,MAAa,wBAKX,aAC2D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../ai-context/dist/index.js","../../src/public/ai-context.ts","../../src/public/config.ts","../../src/public/contracts.ts"],"sourcesContent":["//#region src/index.ts\nconst packageSourceSnippet = \"package-source\";\nconst techStackRecommendationsSnippet = \"tech-stack-recommendations\";\nconst aiContextSnippets = [packageSourceSnippet, techStackRecommendationsSnippet];\nconst coreAiContextSnippets = [packageSourceSnippet];\nconst defaultAiContextSnippets = [...coreAiContextSnippets, techStackRecommendationsSnippet];\nconst packageSourceSnippetContent = `Overmux ships with documentation and TypeScript source.\n\nRun \\`overmux docs path\\` to find the installed documentation directory for the Overmux CLI. This prints a documentation directory, not source paths.\n\nInspect TypeScript source in installed packages, e.g. \\`node_modules/overmux/src\\` and \\`node_modules/@overmux/xterm/src\\`.\n\nInspect these files so guidance matches the versions used by the application.`;\nconst techStackRecommendationsSnippetContent = `Prefer pnpm as the package manager, TanStack Router for routing, shadcn/ui for UI components, and Zod for schemas and runtime validation. For custom Git diff views, prefer @pierre/diffs (https://diffs.com/). Follow the application's established stack when it already differs.`;\nconst aiContextContentBySnippet = {\n\t[packageSourceSnippet]: packageSourceSnippetContent,\n\t[techStackRecommendationsSnippet]: techStackRecommendationsSnippetContent\n};\n//#endregion\nexport { aiContextContentBySnippet, aiContextSnippets, coreAiContextSnippets, defaultAiContextSnippets, packageSourceSnippet, techStackRecommendationsSnippet };\n\n//# sourceMappingURL=index.js.map","import {\n aiContextContentBySnippet,\n type AiContextSnippetDefinition,\n} from \"@overmux/ai-context\";\n\nexport {\n coreAiContextSnippets,\n defaultAiContextSnippets,\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n type AiContextSnippetDefinition,\n} from \"@overmux/ai-context\";\n\nexport const composeAiContext = (snippets: AiContextSnippetDefinition) =>\n snippets.length === 0\n ? \"\"\n : `${snippets\n .map(\n (snippet) => `## ${snippet}\\n\\n${aiContextContentBySnippet[snippet]}`,\n )\n .join(\"\\n\\n\")}\\n`;\n","import { z } from \"zod\";\nimport type { LogLevel } from \"@overmux/shared\";\n\nimport type { AiContextSnippetDefinition } from \"./ai-context\";\nimport type { HandlerLogger } from \"./handler-logger\";\nimport type { Notifications } from \"./notifications\";\nimport type { ResourceContract, StreamContract } from \"./contracts\";\n\nexport type RuntimeDisposer = () => Promise<void> | void;\n\nexport type InstanceContext = {\n getInstanceId: () => string;\n getDeepLinkPrefix: () => string;\n};\n\ntype ResourceInputMap = Readonly<Record<string, unknown>>;\n\n// Keep IDs paired with their raw inputs when checking calls and reusable handlers.\ntype InvalidationArguments<TInputs extends ResourceInputMap> = {\n [TId in keyof TInputs & string]: [resourceId: TId, input?: TInputs[TId]];\n}[keyof TInputs & string];\n\nexport type HandlerContext<TInputs extends ResourceInputMap = {}> = {\n instance: InstanceContext;\n logger: HandlerLogger;\n invalidate: (...args: InvalidationArguments<TInputs>) => void;\n signal: AbortSignal;\n};\n\nexport type StreamContext = Pick<\n HandlerContext,\n \"instance\" | \"signal\" | \"logger\"\n>;\n\nexport type OperationContext<TInputs extends ResourceInputMap = {}> =\n HandlerContext<TInputs> & {\n notifications: Notifications;\n };\n\nexport type OperationDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n TContext = OperationContext,\n> = {\n handle: (\n input: z.output<TInput>,\n context: TContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n input: TInput;\n output: TOutput;\n};\n\n// Infer schemas from this definition, not a surrounding operation map's broad constraint.\nexport const defineOperation = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n TContext = OperationContext,\n>({\n handle,\n input,\n output,\n}: {\n handle: OperationDefinition<TInput, TOutput, TContext>[\"handle\"];\n input: TInput;\n output?: TOutput;\n}): OperationDefinition<NoInfer<TInput>, NoInfer<TOutput>, TContext> => ({\n handle,\n input,\n output: (output ?? z.void()) as TOutput,\n});\n\nexport type QueryResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TContext = HandlerContext,\n> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"query\";\n read: (\n input: z.output<TInput>,\n context: TContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n};\n\nexport type SubscriptionResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TContext = HandlerContext,\n> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"subscription\";\n read: QueryResourceDefinition<TInput, TOutput, TContext>[\"read\"];\n subscribe: (\n input: z.output<TInput>,\n invalidate: () => void,\n context: TContext,\n ) => RuntimeDisposer | Promise<RuntimeDisposer>;\n};\n\nexport type DerivedResourceDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n TDependencies extends Readonly<Record<string, string>> = Readonly<\n Record<string, string>\n >,\n TDependencyOutputs = Readonly<Record<string, unknown>>,\n> = {\n combine: (dependencies: TDependencyOutputs) => z.input<NoInfer<TOutput>>;\n contract: ResourceContract<TInput, TOutput>;\n dependencies: TDependencies;\n kind: \"derived\";\n};\n\ntype AnyZodType = z.ZodType<any, any, any>;\n\nexport type ResourceDefinition =\n | QueryResourceDefinition<\n AnyZodType,\n AnyZodType,\n HandlerContext<ResourceInputMap>\n >\n | SubscriptionResourceDefinition<\n AnyZodType,\n AnyZodType,\n HandlerContext<ResourceInputMap>\n >\n | DerivedResourceDefinition<AnyZodType, AnyZodType, any, any>;\n\nexport type StreamSession<TClientMessage = unknown> = {\n dispose?: RuntimeDisposer;\n onMessage?: (message: TClientMessage) => Promise<void> | void;\n};\n\nexport type StreamHandlerDefinition<\n TInput extends z.ZodType = z.ZodType,\n TClientMessage extends z.ZodType = z.ZodType,\n TServerMessage extends z.ZodType = z.ZodType,\n> = {\n contract: StreamContract<TInput, TClientMessage, TServerMessage>;\n open: (\n input: z.output<TInput>,\n context: StreamContext & {\n emit: (message: z.input<NoInfer<TServerMessage>>) => void;\n fail: (cause: unknown) => void;\n },\n ) =>\n | Promise<StreamSession<z.output<TClientMessage>>>\n | StreamSession<z.output<TClientMessage>>;\n};\n\nexport const defineStreamHandler = <\n TInput extends z.ZodType,\n TClientMessage extends z.ZodType,\n TServerMessage extends z.ZodType,\n>(\n contract: StreamContract<TInput, TClientMessage, TServerMessage>,\n open: StreamHandlerDefinition<TInput, TClientMessage, TServerMessage>[\"open\"],\n): StreamHandlerDefinition<TInput, TClientMessage, TServerMessage> => ({\n contract,\n open,\n});\n\ntype ResourceContracts = Record<\n string,\n ResourceContract<AnyZodType, AnyZodType>\n>;\n\ntype ResourceInputs<TContracts extends ResourceContracts> = {\n [TId in keyof TContracts]: z.input<TContracts[TId][\"input\"]>;\n};\n\ntype DependencyOutputs<\n TContracts extends ResourceContracts,\n TDependencies extends Record<string, unknown>,\n> = {\n [TName in keyof TDependencies]: TDependencies[TName] extends keyof TContracts\n ? z.output<TContracts[TDependencies[TName]][\"output\"]>\n : never;\n};\n\ntype DependencySource<TDependencies> = {\n [TId in keyof TDependencies]: TDependencies[TId] extends Record<\n string,\n string\n >\n ? { dependencies: TDependencies[TId] }\n : { dependencies?: never };\n};\n\ntype QueryFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TContracts extends ResourceContracts,\n> = {\n contract: TContract;\n} & Omit<\n QueryResourceDefinition<\n TContract[\"input\"],\n TContract[\"output\"],\n HandlerContext<ResourceInputs<NoInfer<TContracts>>>\n >,\n \"contract\"\n>;\n\ntype SubscriptionFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TContracts extends ResourceContracts,\n> = { contract: TContract } & Omit<\n SubscriptionResourceDefinition<\n TContract[\"input\"],\n TContract[\"output\"],\n HandlerContext<ResourceInputs<NoInfer<TContracts>>>\n >,\n \"contract\"\n>;\n\ntype DerivedFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n TDependencies extends Record<string, string>,\n TDependencyOutputs,\n> = {\n combine: (\n dependencies: TDependencyOutputs,\n ) => z.input<NoInfer<TContract[\"output\"]>>;\n contract: TContract;\n dependencies: TDependencies;\n kind: \"derived\";\n};\n\ntype ConfiguredResource<\n TContracts extends ResourceContracts,\n TDependencies,\n TId extends keyof TContracts,\n> =\n | QueryFor<TContracts[TId], TContracts>\n | SubscriptionFor<TContracts[TId], TContracts>\n | (TId extends keyof TDependencies\n ? TDependencies[TId] extends Record<\n string,\n Exclude<keyof TContracts, TId> & string\n >\n ? DerivedFor<\n TContracts[TId],\n TDependencies[TId],\n DependencyOutputs<TContracts, NoInfer<TDependencies[TId]>>\n >\n : never\n : never);\n\ntype ConfiguredResources<\n TContracts extends ResourceContracts,\n TDependencies,\n> = {\n [TId in keyof TContracts]: ConfiguredResource<TContracts, TDependencies, TId>;\n} & DependencySource<TDependencies>;\n\nexport type AuthDuration = `${number}${\"m\" | \"h\" | \"d\"}`;\n\nexport type AuthConfigDefinition = {\n mode: \"cli-login\";\n origins?: string[];\n sessionLifetime?: \"forever\" | AuthDuration;\n trustedProxyPeer?: string;\n};\n\nexport type ServerConfigDefinition = {\n host?: string;\n port?: number;\n productionWebAssetsDir?: string;\n watch?: boolean;\n};\n\ntype StreamDefinitions = Readonly<\n Record<string, StreamHandlerDefinition<AnyZodType, AnyZodType, AnyZodType>>\n>;\n\ntype OperationDefinitions = Readonly<\n Record<\n string,\n OperationDefinition<\n AnyZodType,\n AnyZodType,\n OperationContext<ResourceInputMap>\n >\n >\n>;\n\ntype OperationInputs = Record<string, AnyZodType>;\n\ntype OperationOutputSchema<\n TOutputs,\n TId extends PropertyKey,\n> = TId extends keyof TOutputs\n ? TOutputs[TId] extends z.ZodType\n ? TOutputs[TId]\n : z.ZodVoid\n : z.ZodVoid;\n\ntype ConfiguredOperations<\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n> = {\n [TId in keyof TInputs]: {\n input: TInputs[TId];\n output?: OperationOutputSchema<TOutputs, TId>;\n handle: OperationDefinition<\n TInputs[TId],\n OperationOutputSchema<TOutputs, TId>,\n OperationContext<ResourceInputs<TContracts>>\n >[\"handle\"];\n };\n} & {\n [TId in keyof TOutputs]: TOutputs[TId] extends z.ZodType\n ? { output: TOutputs[TId] }\n : { output?: never };\n};\n\ntype NormalizedOperations<\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n> = {\n [TId in keyof TInputs]: OperationDefinition<\n TInputs[TId],\n OperationOutputSchema<TOutputs, TId>,\n OperationContext<ResourceInputs<TContracts>>\n >;\n};\n\nconst normalizeOperations = <\n TInputs extends OperationInputs,\n TOutputs,\n TContracts extends ResourceContracts,\n>(\n operations: ConfiguredOperations<TInputs, TOutputs, TContracts> | undefined,\n): NormalizedOperations<TInputs, TOutputs, TContracts> | undefined => {\n if (operations === undefined) {\n return undefined;\n }\n // Preserve every key and handler; only absent output schemas become ZodVoid.\n return Object.fromEntries(\n Object.entries(operations).map(([id, definition]) => [\n id,\n { ...definition, output: definition.output ?? z.void() },\n ]),\n ) as NormalizedOperations<TInputs, TOutputs, TContracts>;\n};\n\nexport type ConfigDefinition<\n TResources extends Readonly<Record<string, unknown>> = Readonly<\n Record<string, ResourceDefinition>\n >,\n TStreams extends StreamDefinitions = StreamDefinitions,\n TOperations extends OperationDefinitions = OperationDefinitions,\n> = {\n operations?: TOperations;\n resources: TResources;\n streams?: TStreams;\n};\n\nexport type OvermuxConfigDefinition<\n TServer extends ConfigDefinition = ConfigDefinition,\n> = ServerConfigDefinition & {\n aiContextSnippets?: AiContextSnippetDefinition;\n auth: AuthConfigDefinition;\n logLevel?: LogLevel;\n instanceId?: string | ((context: { port: number }) => string);\n server: TServer;\n vite?: string;\n};\n\nexport type OvermuxServerResources<TServer> = TServer extends {\n resources: infer TResources;\n}\n ? TResources\n : never;\n\nexport type OvermuxServerStreams<TServer> = TServer extends {\n streams?: infer TStreams;\n}\n ? NonNullable<TStreams>\n : never;\n\nexport type OvermuxServerOperations<TServer> = TServer extends {\n operations?: infer TOperations;\n}\n ? NonNullable<TOperations>\n : never;\n\nexport const defineOvermuxServer = <\n const TContracts extends ResourceContracts = {},\n const TDependencies = {},\n const TStreams extends StreamDefinitions = {},\n const TInputs extends OperationInputs = {},\n const TOutputs = {},\n>(definition: {\n operations?: ConfiguredOperations<TInputs, TOutputs, NoInfer<TContracts>>;\n resources: ConfiguredResources<TContracts, TDependencies>;\n streams?: TStreams & StreamDefinitions;\n}): ConfigDefinition<\n ConfiguredResources<TContracts, TDependencies>,\n TStreams,\n NormalizedOperations<TInputs, TOutputs, TContracts>\n> => ({\n ...definition,\n operations: normalizeOperations(definition.operations),\n});\n\nexport const defineOvermuxConfig = <const TServer extends ConfigDefinition>(\n definition: OvermuxConfigDefinition<TServer>,\n): OvermuxConfigDefinition<TServer> => definition;\n","import { z } from \"zod\";\n\nexport const noInputSchema = z.void();\n\nexport const jsonValueSchema: z.ZodType<unknown> = z.lazy(() =>\n z.union([\n z.string(),\n z.number().finite(),\n z.boolean(),\n z.null(),\n z.array(jsonValueSchema),\n z.record(z.string(), jsonValueSchema),\n ]),\n);\n\nexport const parseJsonValue = <T>(value: T): T =>\n jsonValueSchema.parse(value) as T;\n\nexport type ContractInputArguments<TInput extends z.ZodType> =\n undefined extends z.input<TInput>\n ? [input?: Exclude<z.input<TInput>, undefined>]\n : [input: z.input<TInput>];\n\nexport type ResourceContract<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodType,\n> = {\n input: TInput;\n output: TOutput;\n};\n\nexport const defineResourceContract = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType,\n>(\n contract: ResourceContract<TInput, TOutput>,\n): ResourceContract<TInput, TOutput> => contract;\n\nexport type StreamContract<\n TInput extends z.ZodType = z.ZodType,\n TClientMessage extends z.ZodType = z.ZodType,\n TServerMessage extends z.ZodType = z.ZodType,\n> = {\n clientMessage: TClientMessage;\n input: TInput;\n serverMessage: TServerMessage;\n};\n\nexport const defineStreamContract = <\n TInput extends z.ZodType,\n TClientMessage extends z.ZodType,\n TServerMessage extends z.ZodType,\n>(\n contract: StreamContract<TInput, TClientMessage, TServerMessage>,\n): StreamContract<TInput, TClientMessage, TServerMessage> => contract;\n"],"mappings":";;;AACA,MAAM,uBAAuB;AAC7B,MAAM,kCAAkC;AAExC,MAAM,wBAAwB,CAAC,oBAAoB;AACnD,MAAM,2BAA2B,CAAC,GAAG,uBAAuB,+BAA+B;AAC3F,MAAM,8BAA8B;;;;;;;AAOpC,MAAM,yCAAyC;AAC/C,MAAM,4BAA4B;EAChC,uBAAuB;EACvB,kCAAkC;AACpC;;;ACHA,MAAa,oBAAoB,aAC/B,SAAS,WAAW,IAChB,KACA,GAAG,SACA,KACE,YAAY,MAAM,QAAQ,MAAM,0BAA0B,UAC7D,CAAC,CACA,KAAK,MAAM,EAAE;;;ACgCtB,MAAa,mBAIX,EACA,QACA,OACA,cAKuE;CACvE;CACA;CACA,QAAS,UAAU,EAAE,KAAK;AAC5B;AAiFA,MAAa,uBAKX,UACA,UACqE;CACrE;CACA;AACF;AAyKA,MAAM,uBAKJ,eACoE;CACpE,IAAI,eAAe,KAAA,GACjB;CAGF,OAAO,OAAO,YACZ,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,gBAAgB,CACnD,IACA;EAAE,GAAG;EAAY,QAAQ,WAAW,UAAU,EAAE,KAAK;CAAE,CACzD,CAAC,CACH;AACF;AA2CA,MAAa,uBAMX,gBAQI;CACJ,GAAG;CACH,YAAY,oBAAoB,WAAW,UAAU;AACvD;AAEA,MAAa,uBACX,eACqC;;;ACxZvC,MAAa,gBAAgB,EAAE,KAAK;AAEpC,MAAa,kBAAsC,EAAE,WACnD,EAAE,MAAM;CACN,EAAE,OAAO;CACT,EAAE,OAAO,CAAC,CAAC,OAAO;CAClB,EAAE,QAAQ;CACV,EAAE,KAAK;CACP,EAAE,MAAM,eAAe;CACvB,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;AACtC,CAAC,CACH;AAEA,MAAa,kBAAqB,UAChC,gBAAgB,MAAM,KAAK;AAe7B,MAAa,0BAIX,aACsC;AAYxC,MAAa,wBAKX,aAC2D"}
|
|
@@ -80,7 +80,13 @@ const parseDeepLink = (input) => {
|
|
|
80
80
|
route
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
|
+
const logLevelSchema = z.enum([
|
|
84
|
+
"debug",
|
|
85
|
+
"info",
|
|
86
|
+
"warn",
|
|
87
|
+
"error"
|
|
88
|
+
]);
|
|
83
89
|
//#endregion
|
|
84
|
-
export {
|
|
90
|
+
export { notificationLinkSchema as a, overmuxSettingsPath as c, logLevelSchema as i, parseDeepLink as l, createOvermuxSettingsPath as n, notificationSchema as o, instanceIdSchema as r, overmuxLogoutPath as s, createInstanceIdentity as t, resolveOvermuxReturnTo as u };
|
|
85
91
|
|
|
86
|
-
//# sourceMappingURL=notifications-
|
|
92
|
+
//# sourceMappingURL=notifications-BBKvKZgI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications-
|
|
1
|
+
{"version":3,"file":"notifications-BBKvKZgI.js","names":[],"sources":["../../../shared/dist/index.js"],"sourcesContent":["import { z } from \"zod\";\n//#region src/hosted-routes.ts\nconst overmuxSettingsPath = \"/_overmux/settings\";\nconst overmuxLogoutPath = \"/_overmux/logout\";\nconst reservedPathPrefixes = [\n\t\"/_overmux\",\n\t\"/api\",\n\t\"/login\"\n];\nconst returnToBase = \"https://overmux.invalid\";\nconst isReservedPath = (pathname) => reservedPathPrefixes.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`));\nconst resolveOvermuxReturnTo = (candidate) => {\n\tif (!candidate?.startsWith(\"/\") || candidate.startsWith(\"//\")) return \"/\";\n\ttry {\n\t\tconst url = new URL(candidate, returnToBase);\n\t\tconst decodedPathname = decodeURIComponent(url.pathname);\n\t\tif (url.origin !== returnToBase || isReservedPath(decodedPathname)) return \"/\";\n\t\treturn `${url.pathname}${url.search}${url.hash}`;\n\t} catch {\n\t\treturn \"/\";\n\t}\n};\nconst createOvermuxSettingsPath = (returnTo) => {\n\tconst safeReturnTo = resolveOvermuxReturnTo(returnTo);\n\tif (safeReturnTo === \"/\") return overmuxSettingsPath;\n\tconst search = new URLSearchParams({ returnTo: safeReturnTo });\n\treturn `${overmuxSettingsPath}?${search.toString()}`;\n};\n//#endregion\n//#region src/notifications.ts\nconst safeRelativeNotificationLink = (link) => {\n\tlet decoded;\n\ttry {\n\t\tdecoded = decodeURIComponent(link);\n\t} catch {\n\t\treturn false;\n\t}\n\treturn !decoded.startsWith(\"//\") && !decoded.includes(\"\\\\\") && ![...decoded].some((character) => {\n\t\tconst codePoint = character.codePointAt(0) ?? 0;\n\t\treturn codePoint < 32 || codePoint === 127;\n\t});\n};\nconst notificationLinkSchema = z.union([z.string().max(4096).startsWith(\"/\").refine(safeRelativeNotificationLink), z.string().max(4096).url().refine((link) => {\n\tif (!URL.canParse(link)) return false;\n\tconst url = new URL(link);\n\treturn [\"http:\", \"https:\"].includes(url.protocol) && !url.username && !url.password;\n})]);\nconst notificationSchema = z.object({\n\tbody: z.string().max(4096).optional(),\n\topen: z.object({ link: notificationLinkSchema }).strict().optional(),\n\ttitle: z.string().min(1).max(4096)\n}).strict();\n//#endregion\n//#region src/instance.ts\nconst instanceIdSchema = z.string().max(253).regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?![\\s\\S])/, \"Expected a lowercase instance ID with only ASCII letters, digits, internal dots and hyphens\");\nconst createInstanceIdentity = (instanceId) => ({\n\tinstanceId: instanceIdSchema.parse(instanceId),\n\tdeepLinkPrefix: `overmux://${instanceId}`\n});\n//#endregion\n//#region src/deep-links.ts\nvar UrlPolicyError = class extends Error {};\nconst validateDeepLinkPath = (input) => {\n\tlet decoded;\n\ttry {\n\t\tdecoded = decodeURIComponent(input);\n\t} catch {\n\t\tthrow new UrlPolicyError(\"Deep link path must be a safe relative path.\");\n\t}\n\tconst hasControlCharacter = [...decoded].some((character) => {\n\t\tconst codePoint = character.codePointAt(0) ?? 0;\n\t\treturn codePoint < 32 || codePoint === 127;\n\t});\n\tif (!input.startsWith(\"/\") || decoded.startsWith(\"//\") || decoded.includes(\"\\\\\") || hasControlCharacter) throw new UrlPolicyError(\"Deep link path must be a safe relative path.\");\n\treturn input;\n};\nconst parseDeepLink = (input) => {\n\tconst match = /^overmux:\\/\\/([^/?#]+)(.*)$/i.exec(input);\n\tconst identity = instanceIdSchema.safeParse(match?.[1]);\n\tif (!match || !identity.success || /\\s/.test(input)) throw new UrlPolicyError(\"Deep link must contain a canonical Overmux instance ID.\");\n\tconst suffix = match[2];\n\tconst route = validateDeepLinkPath(suffix.startsWith(\"/\") ? suffix : `/${suffix}`);\n\tif (route.split(/[?#]/, 1)[0].split(\"/\").some((segment) => /^\\.{1,2}$/.test(decodeURIComponent(segment)))) throw new UrlPolicyError(\"Deep link path cannot contain dot segments.\");\n\treturn {\n\t\tinstanceId: identity.data,\n\t\troute\n\t};\n};\n//#endregion\n//#region src/log-level.ts\nconst logLevelSchema = z.enum([\n\t\"debug\",\n\t\"info\",\n\t\"warn\",\n\t\"error\"\n]);\n//#endregion\nexport { UrlPolicyError, createInstanceIdentity, createOvermuxSettingsPath, instanceIdSchema, logLevelSchema, notificationLinkSchema, notificationSchema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IAAI,eAAe,8CAA8C;CAChL,OAAO;AACR;AACA,MAAM,iBAAiB,UAAU;CAChC,MAAM,QAAQ,+BAA+B,KAAK,KAAK;CACvD,MAAM,WAAW,iBAAiB,UAAU,QAAQ,EAAE;CACtD,IAAI,CAAC,SAAS,CAAC,SAAS,WAAW,KAAK,KAAK,KAAK,GAAG,MAAM,IAAI,eAAe,yDAAyD;CACvI,MAAM,SAAS,MAAM;CACrB,MAAM,QAAQ,qBAAqB,OAAO,WAAW,GAAG,IAAI,SAAS,IAAI,QAAQ;CACjF,IAAI,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,YAAY,YAAY,KAAK,mBAAmB,OAAO,CAAC,CAAC,GAAG,MAAM,IAAI,eAAe,6CAA6C;CACjL,OAAO;EACN,YAAY,SAAS;EACrB;CACD;AACD;AAGA,MAAM,iBAAiB,EAAE,KAAK;CAC7B;CACA;CACA;CACA;AACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../shared/dist/node/index.d.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../shared/dist/node/index.d.ts"],"mappings":";;;;KAuMK;EACH,cAAc,OAAO;EACrB;EACA;EACA;EACA;EACA;EACA;;KAEG;EACH;EACA;EACA;EACA;EACA;;cAEY,oBAAoB,aAAa,SAAS,cAAc,eAAe,aAAa,eAAe,iBAAiB,2BAA2B"}
|
package/dist/exports/server.js
CHANGED
|
@@ -21,6 +21,12 @@ const durationToMilliseconds = (duration) => {
|
|
|
21
21
|
};
|
|
22
22
|
const aiContextSnippets = ["package-source", "tech-stack-recommendations"];
|
|
23
23
|
const instanceIdSchema = z.string().max(253).regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?![\s\S])/, "Expected a lowercase instance ID with only ASCII letters, digits, internal dots and hyphens");
|
|
24
|
+
const logLevelSchema = z.enum([
|
|
25
|
+
"debug",
|
|
26
|
+
"info",
|
|
27
|
+
"warn",
|
|
28
|
+
"error"
|
|
29
|
+
]);
|
|
24
30
|
const zodTypeSchema = z.custom((value) => value instanceof z.ZodType, "Expected a Zod schema");
|
|
25
31
|
const functionSchema = z.custom((value) => typeof value === "function", "Expected a function");
|
|
26
32
|
const contractRuntimeSchema = z.object({
|
|
@@ -86,11 +92,11 @@ const serverDefinitionRuntimeSchema = z.object({
|
|
|
86
92
|
serverConfigRuntimeSchema.extend({
|
|
87
93
|
aiContextSnippets: z.array(z.enum(aiContextSnippets)).optional(),
|
|
88
94
|
auth: authConfigRuntimeSchema,
|
|
89
|
-
|
|
95
|
+
logLevel: logLevelSchema.optional(),
|
|
90
96
|
instanceId: z.union([instanceIdSchema, z.custom((value) => typeof value === "function", "Expected an instance ID or a function of the bound port")]).optional(),
|
|
91
97
|
server: serverDefinitionRuntimeSchema,
|
|
92
98
|
vite: z.string().min(1).optional()
|
|
93
|
-
});
|
|
99
|
+
}).strict();
|
|
94
100
|
const xdgDirectory = (configured, fallback) => configured && isAbsolute(configured) ? configured : fallback;
|
|
95
101
|
const overmuxDirectory = (root) => join(root, "overmux");
|
|
96
102
|
const getOvermuxPaths = ({ environment = process.env, homeDir = homedir(), xdgCacheHome = environment.XDG_CACHE_HOME, xdgConfigHome = environment.XDG_CONFIG_HOME, xdgDataHome = environment.XDG_DATA_HOME, xdgRuntimeDir = environment.XDG_RUNTIME_DIR, xdgStateHome = environment.XDG_STATE_HOME } = {}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":[],"sources":["../../../shared/dist/node/index.js"],"sourcesContent":["import { realpath } from \"node:fs/promises\";\nimport { isIP } from \"node:net\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { createJiti } from \"jiti\";\nimport { z } from \"zod\";\nimport { homedir } from \"node:os\";\n//#region ../lib/dist/index.js\nconst durationPattern = /^([1-9]\\d*)(ms|s|m|h|d)$/;\nconst millisecondsByUnit = {\n\td: 1440 * 60 * 1e3,\n\th: 3600 * 1e3,\n\tm: 60 * 1e3,\n\tms: 1,\n\ts: 1e3\n};\nconst durationToMilliseconds = (duration) => {\n\tconst match = durationPattern.exec(duration);\n\tif (!match) return;\n\tconst unit = match[2];\n\tconst milliseconds = Number(match[1]) * millisecondsByUnit[unit];\n\treturn Number.isSafeInteger(milliseconds) ? milliseconds : void 0;\n};\nconst aiContextSnippets = [\"package-source\", \"tech-stack-recommendations\"];\n//#endregion\n//#region src/instance.ts\nconst instanceIdSchema = z.string().max(253).regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?![\\s\\S])/, \"Expected a lowercase instance ID with only ASCII letters, digits, internal dots and hyphens\");\n//#endregion\n//#region src/node/config.ts\nconst zodTypeSchema = z.custom((value) => value instanceof z.ZodType, \"Expected a Zod schema\");\nconst functionSchema = z.custom((value) => typeof value === \"function\", \"Expected a function\");\nconst contractRuntimeSchema = z.object({\n\tinput: zodTypeSchema,\n\toutput: zodTypeSchema\n});\nconst operationRuntimeSchema = z.object({\n\thandle: functionSchema,\n\tinput: zodTypeSchema,\n\toutput: zodTypeSchema\n});\nconst streamHandlerRuntimeSchema = z.object({\n\tcontract: z.object({\n\t\tclientMessage: zodTypeSchema,\n\t\tinput: zodTypeSchema,\n\t\tserverMessage: zodTypeSchema\n\t}),\n\topen: functionSchema\n});\nconst resourceDefinitionRuntimeSchema = z.discriminatedUnion(\"kind\", [\n\tz.object({\n\t\tcontract: contractRuntimeSchema,\n\t\tkind: z.literal(\"query\"),\n\t\tread: functionSchema\n\t}),\n\tz.object({\n\t\tcontract: contractRuntimeSchema,\n\t\tkind: z.literal(\"subscription\"),\n\t\tread: functionSchema,\n\t\tsubscribe: functionSchema\n\t}),\n\tz.object({\n\t\tcombine: functionSchema,\n\t\tcontract: contractRuntimeSchema,\n\t\tdependencies: z.record(z.string(), z.string()),\n\t\tkind: z.literal(\"derived\")\n\t})\n]);\nconst authDurationSchema = z.string().regex(/^[1-9]\\d*[mhd]$/, \"Expected a positive duration such as 30d\").refine((value) => durationToMilliseconds(value) !== void 0, \"Duration is too large\");\nconst isLoopbackHostname = (hostname) => hostname === \"localhost\" || hostname === \"[::1]\" || /^127(?:\\.\\d{1,3}){3}$/.test(hostname);\nconst exactOriginSchema = z.url().refine((value) => new URL(value).origin === value, \"Expected an origin\").refine((value) => {\n\tconst url = new URL(value);\n\treturn url.protocol === \"https:\" || url.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n}, \"Non-loopback Overmux origins must use HTTPS\");\nconst loopbackPeerSchema = z.string().refine((value) => isIP(value) !== 0 && (value === \"::1\" || value.startsWith(\"127.\")), \"Expected a loopback IP address\");\nconst authConfigRuntimeSchema = z.object({\n\tmode: z.literal(\"cli-login\"),\n\torigins: z.array(exactOriginSchema).min(1).refine((origins) => new Set(origins).size === origins.length, \"Expected unique origins\").optional(),\n\tsessionLifetime: z.union([z.literal(\"forever\"), authDurationSchema]).default(\"forever\"),\n\ttrustedProxyPeer: loopbackPeerSchema.optional()\n}).strict();\nconst serverConfigRuntimeSchema = z.object({\n\thost: z.string().min(1).optional(),\n\tport: z.number().int().min(1).max(65535).optional(),\n\tproductionWebAssetsDir: z.string().min(1).optional(),\n\twatch: z.boolean().optional()\n});\nconst serverDefinitionRuntimeSchema = z.object({\n\toperations: z.record(z.string(), operationRuntimeSchema).optional(),\n\tresources: z.record(z.string(), resourceDefinitionRuntimeSchema),\n\tstreams: z.record(z.string(), streamHandlerRuntimeSchema).optional()\n});\nconst configDefinitionRuntimeSchema = serverConfigRuntimeSchema.extend({\n\taiContextSnippets: z.array(z.enum(aiContextSnippets)).optional(),\n\tauth: authConfigRuntimeSchema,\n\tdebug: z.boolean().optional(),\n\tinstanceId: z.union([instanceIdSchema, z.custom((value) => typeof value === \"function\", \"Expected an instance ID or a function of the bound port\")]).optional(),\n\tserver: serverDefinitionRuntimeSchema,\n\tvite: z.string().min(1).optional()\n});\nconst resolveLogicalPath = async (path) => {\n\tconst logicalPath = resolve(path);\n\treturn {\n\t\tlogicalPath,\n\t\trealPath: await realpath(logicalPath)\n\t};\n};\nconst resolveOvermuxConfigPaths = async (configPath) => {\n\tconst { logicalPath, realPath } = await resolveLogicalPath(configPath);\n\treturn {\n\t\tlogicalApplicationRoot: dirname(logicalPath),\n\t\tlogicalConfigPath: logicalPath,\n\t\trealApplicationRoot: dirname(realPath),\n\t\trealConfigPath: realPath\n\t};\n};\nconst unwrapDefaultExport = (module) => {\n\tif (typeof module === \"object\" && module !== null && \"default\" in module) return module.default;\n\treturn module;\n};\nconst loadOvermuxConfig = async ({ aliases = {}, configPath }) => {\n\tconst paths = await resolveOvermuxConfigPaths(configPath);\n\tconst module = await createJiti(paths.logicalConfigPath, {\n\t\talias: aliases,\n\t\tfsCache: true,\n\t\tjsx: {\n\t\t\timportSource: \"react\",\n\t\t\truntime: \"automatic\"\n\t\t},\n\t\tmoduleCache: false,\n\t\tsourceMaps: true,\n\t\ttsconfigPaths: true\n\t}).import(paths.logicalConfigPath);\n\treturn {\n\t\tconfig: configDefinitionRuntimeSchema.parse(unwrapDefaultExport(module)),\n\t\tpaths\n\t};\n};\n//#endregion\n//#region src/node/paths.ts\nconst xdgDirectory = (configured, fallback) => configured && isAbsolute(configured) ? configured : fallback;\nconst overmuxDirectory = (root) => join(root, \"overmux\");\nconst getOvermuxPaths = ({ environment = process.env, homeDir = homedir(), xdgCacheHome = environment.XDG_CACHE_HOME, xdgConfigHome = environment.XDG_CONFIG_HOME, xdgDataHome = environment.XDG_DATA_HOME, xdgRuntimeDir = environment.XDG_RUNTIME_DIR, xdgStateHome = environment.XDG_STATE_HOME } = {}) => {\n\tif (!isAbsolute(homeDir)) throw new TypeError(\"The home directory must be absolute.\");\n\tconst runtimeDir = xdgRuntimeDir && isAbsolute(xdgRuntimeDir) ? overmuxDirectory(xdgRuntimeDir) : void 0;\n\treturn {\n\t\tcacheDir: overmuxDirectory(xdgDirectory(xdgCacheHome, join(homeDir, \".cache\"))),\n\t\tconfigDir: overmuxDirectory(xdgDirectory(xdgConfigHome, join(homeDir, \".config\"))),\n\t\tdataDir: overmuxDirectory(xdgDirectory(xdgDataHome, join(homeDir, \".local\", \"share\"))),\n\t\t...runtimeDir ? { runtimeDir } : {},\n\t\tstateDir: overmuxDirectory(xdgDirectory(xdgStateHome, join(homeDir, \".local\", \"state\")))\n\t};\n};\n//#endregion\nexport { authConfigRuntimeSchema, authDurationSchema, configDefinitionRuntimeSchema, getOvermuxPaths, loadOvermuxConfig, resolveLogicalPath, resolveOvermuxConfigPaths, serverConfigRuntimeSchema, serverDefinitionRuntimeSchema };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;;;;;AAOA,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;CAC1B,GAAG,OAAO,KAAK;CACf,GAAG,OAAO;CACV,GAAG,KAAK;CACR,IAAI;CACJ,GAAG;AACJ;AACA,MAAM,0BAA0B,aAAa;CAC5C,MAAM,QAAQ,gBAAgB,KAAK,QAAQ;CAC3C,IAAI,CAAC,OAAO;CACZ,MAAM,OAAO,MAAM;CACnB,MAAM,eAAe,OAAO,MAAM,EAAE,IAAI,mBAAmB;CAC3D,OAAO,OAAO,cAAc,YAAY,IAAI,eAAe,KAAK;AACjE;AACA,MAAM,oBAAoB,CAAC,kBAAkB,4BAA4B;AAGzE,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,+CAA+C,6FAA6F;AAG/L,MAAM,gBAAgB,EAAE,QAAQ,UAAU,iBAAiB,EAAE,SAAS,uBAAuB;AAC7F,MAAM,iBAAiB,EAAE,QAAQ,UAAU,OAAO,UAAU,YAAY,qBAAqB;AAC7F,MAAM,wBAAwB,EAAE,OAAO;CACtC,OAAO;CACP,QAAQ;AACT,CAAC;AACD,MAAM,yBAAyB,EAAE,OAAO;CACvC,QAAQ;CACR,OAAO;CACP,QAAQ;AACT,CAAC;AACD,MAAM,6BAA6B,EA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,MAAM,SAAS;AACvD,MAAM,mBAAmB,EAAE,cAAc,QAAQ,KAAK,UAAU,QAAQ,GAAG,eAAe,YAAY,gBAAgB,gBAAgB,YAAY,iBAAiB,cAAc,YAAY,eAAe,gBAAgB,YAAY,iBAAiB,eAAe,YAAY,mBAAmB,CAAC,MAAM;CAC7S,IAAI,CAAC,WAAW,OAAO,GAAG,MAAM,IAAI,UAAU,sCAAsC;CACpF,MAAM,aAAa,iBAAiB,WAAW,aAAa,IAAI,iBAAiB,aAAa,IAAI,KAAK;CACvG,OAAO;EACN,UAAU,iBAAiB,aAAa,cAAc,KAAK,SAAS,QAAQ,CAAC,CAAC;EAC9E,WAAW,iBAAiB,aAAa,eAAe,KAAK,SAAS,SAAS,CAAC,CAAC;EACjF,SAAS,iBAAiB,aAAa,aAAa,KAAK,SAAS,UAAU,OAAO,CAAC,CAAC;EACrF,GAAG,aAAa,EAAE,WAAW,IAAI,CAAC;EAClC,UAAU,iBAAiB,aAAa,cAAc,KAAK,SAAS,UAAU,OAAO,CAAC,CAAC;CACxF;AACD"}
|
|
1
|
+
{"version":3,"file":"server.js","names":[],"sources":["../../../shared/dist/node/index.js"],"sourcesContent":["import { realpath } from \"node:fs/promises\";\nimport { isIP } from \"node:net\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { createJiti } from \"jiti\";\nimport { z } from \"zod\";\nimport { homedir } from \"node:os\";\n//#region ../lib/dist/index.js\nconst durationPattern = /^([1-9]\\d*)(ms|s|m|h|d)$/;\nconst millisecondsByUnit = {\n\td: 1440 * 60 * 1e3,\n\th: 3600 * 1e3,\n\tm: 60 * 1e3,\n\tms: 1,\n\ts: 1e3\n};\nconst durationToMilliseconds = (duration) => {\n\tconst match = durationPattern.exec(duration);\n\tif (!match) return;\n\tconst unit = match[2];\n\tconst milliseconds = Number(match[1]) * millisecondsByUnit[unit];\n\treturn Number.isSafeInteger(milliseconds) ? milliseconds : void 0;\n};\nconst aiContextSnippets = [\"package-source\", \"tech-stack-recommendations\"];\n//#endregion\n//#region src/instance.ts\nconst instanceIdSchema = z.string().max(253).regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?![\\s\\S])/, \"Expected a lowercase instance ID with only ASCII letters, digits, internal dots and hyphens\");\n//#endregion\n//#region src/log-level.ts\nconst logLevelSchema = z.enum([\n\t\"debug\",\n\t\"info\",\n\t\"warn\",\n\t\"error\"\n]);\n//#endregion\n//#region src/node/config.ts\nconst zodTypeSchema = z.custom((value) => value instanceof z.ZodType, \"Expected a Zod schema\");\nconst functionSchema = z.custom((value) => typeof value === \"function\", \"Expected a function\");\nconst contractRuntimeSchema = z.object({\n\tinput: zodTypeSchema,\n\toutput: zodTypeSchema\n});\nconst operationRuntimeSchema = z.object({\n\thandle: functionSchema,\n\tinput: zodTypeSchema,\n\toutput: zodTypeSchema\n});\nconst streamHandlerRuntimeSchema = z.object({\n\tcontract: z.object({\n\t\tclientMessage: zodTypeSchema,\n\t\tinput: zodTypeSchema,\n\t\tserverMessage: zodTypeSchema\n\t}),\n\topen: functionSchema\n});\nconst resourceDefinitionRuntimeSchema = z.discriminatedUnion(\"kind\", [\n\tz.object({\n\t\tcontract: contractRuntimeSchema,\n\t\tkind: z.literal(\"query\"),\n\t\tread: functionSchema\n\t}),\n\tz.object({\n\t\tcontract: contractRuntimeSchema,\n\t\tkind: z.literal(\"subscription\"),\n\t\tread: functionSchema,\n\t\tsubscribe: functionSchema\n\t}),\n\tz.object({\n\t\tcombine: functionSchema,\n\t\tcontract: contractRuntimeSchema,\n\t\tdependencies: z.record(z.string(), z.string()),\n\t\tkind: z.literal(\"derived\")\n\t})\n]);\nconst authDurationSchema = z.string().regex(/^[1-9]\\d*[mhd]$/, \"Expected a positive duration such as 30d\").refine((value) => durationToMilliseconds(value) !== void 0, \"Duration is too large\");\nconst isLoopbackHostname = (hostname) => hostname === \"localhost\" || hostname === \"[::1]\" || /^127(?:\\.\\d{1,3}){3}$/.test(hostname);\nconst exactOriginSchema = z.url().refine((value) => new URL(value).origin === value, \"Expected an origin\").refine((value) => {\n\tconst url = new URL(value);\n\treturn url.protocol === \"https:\" || url.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n}, \"Non-loopback Overmux origins must use HTTPS\");\nconst loopbackPeerSchema = z.string().refine((value) => isIP(value) !== 0 && (value === \"::1\" || value.startsWith(\"127.\")), \"Expected a loopback IP address\");\nconst authConfigRuntimeSchema = z.object({\n\tmode: z.literal(\"cli-login\"),\n\torigins: z.array(exactOriginSchema).min(1).refine((origins) => new Set(origins).size === origins.length, \"Expected unique origins\").optional(),\n\tsessionLifetime: z.union([z.literal(\"forever\"), authDurationSchema]).default(\"forever\"),\n\ttrustedProxyPeer: loopbackPeerSchema.optional()\n}).strict();\nconst serverConfigRuntimeSchema = z.object({\n\thost: z.string().min(1).optional(),\n\tport: z.number().int().min(1).max(65535).optional(),\n\tproductionWebAssetsDir: z.string().min(1).optional(),\n\twatch: z.boolean().optional()\n});\nconst serverDefinitionRuntimeSchema = z.object({\n\toperations: z.record(z.string(), operationRuntimeSchema).optional(),\n\tresources: z.record(z.string(), resourceDefinitionRuntimeSchema),\n\tstreams: z.record(z.string(), streamHandlerRuntimeSchema).optional()\n});\nconst configDefinitionRuntimeSchema = serverConfigRuntimeSchema.extend({\n\taiContextSnippets: z.array(z.enum(aiContextSnippets)).optional(),\n\tauth: authConfigRuntimeSchema,\n\tlogLevel: logLevelSchema.optional(),\n\tinstanceId: z.union([instanceIdSchema, z.custom((value) => typeof value === \"function\", \"Expected an instance ID or a function of the bound port\")]).optional(),\n\tserver: serverDefinitionRuntimeSchema,\n\tvite: z.string().min(1).optional()\n}).strict();\nconst resolveLogicalPath = async (path) => {\n\tconst logicalPath = resolve(path);\n\treturn {\n\t\tlogicalPath,\n\t\trealPath: await realpath(logicalPath)\n\t};\n};\nconst resolveOvermuxConfigPaths = async (configPath) => {\n\tconst { logicalPath, realPath } = await resolveLogicalPath(configPath);\n\treturn {\n\t\tlogicalApplicationRoot: dirname(logicalPath),\n\t\tlogicalConfigPath: logicalPath,\n\t\trealApplicationRoot: dirname(realPath),\n\t\trealConfigPath: realPath\n\t};\n};\nconst unwrapDefaultExport = (module) => {\n\tif (typeof module === \"object\" && module !== null && \"default\" in module) return module.default;\n\treturn module;\n};\nconst loadOvermuxConfig = async ({ aliases = {}, configPath }) => {\n\tconst paths = await resolveOvermuxConfigPaths(configPath);\n\tconst module = await createJiti(paths.logicalConfigPath, {\n\t\talias: aliases,\n\t\tfsCache: true,\n\t\tjsx: {\n\t\t\timportSource: \"react\",\n\t\t\truntime: \"automatic\"\n\t\t},\n\t\tmoduleCache: false,\n\t\tsourceMaps: true,\n\t\ttsconfigPaths: true\n\t}).import(paths.logicalConfigPath);\n\treturn {\n\t\tconfig: configDefinitionRuntimeSchema.parse(unwrapDefaultExport(module)),\n\t\tpaths\n\t};\n};\n//#endregion\n//#region src/node/paths.ts\nconst xdgDirectory = (configured, fallback) => configured && isAbsolute(configured) ? configured : fallback;\nconst overmuxDirectory = (root) => join(root, \"overmux\");\nconst getOvermuxPaths = ({ environment = process.env, homeDir = homedir(), xdgCacheHome = environment.XDG_CACHE_HOME, xdgConfigHome = environment.XDG_CONFIG_HOME, xdgDataHome = environment.XDG_DATA_HOME, xdgRuntimeDir = environment.XDG_RUNTIME_DIR, xdgStateHome = environment.XDG_STATE_HOME } = {}) => {\n\tif (!isAbsolute(homeDir)) throw new TypeError(\"The home directory must be absolute.\");\n\tconst runtimeDir = xdgRuntimeDir && isAbsolute(xdgRuntimeDir) ? overmuxDirectory(xdgRuntimeDir) : void 0;\n\treturn {\n\t\tcacheDir: overmuxDirectory(xdgDirectory(xdgCacheHome, join(homeDir, \".cache\"))),\n\t\tconfigDir: overmuxDirectory(xdgDirectory(xdgConfigHome, join(homeDir, \".config\"))),\n\t\tdataDir: overmuxDirectory(xdgDirectory(xdgDataHome, join(homeDir, \".local\", \"share\"))),\n\t\t...runtimeDir ? { runtimeDir } : {},\n\t\tstateDir: overmuxDirectory(xdgDirectory(xdgStateHome, join(homeDir, \".local\", \"state\")))\n\t};\n};\n//#endregion\nexport { authConfigRuntimeSchema, authDurationSchema, configDefinitionRuntimeSchema, getOvermuxPaths, loadOvermuxConfig, resolveLogicalPath, resolveOvermuxConfigPaths, serverConfigRuntimeSchema, serverDefinitionRuntimeSchema };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;;;;;AAOA,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;CAC1B,GAAG,OAAO,KAAK;CACf,GAAG,OAAO;CACV,GAAG,KAAK;CACR,IAAI;CACJ,GAAG;AACJ;AACA,MAAM,0BAA0B,aAAa;CAC5C,MAAM,QAAQ,gBAAgB,KAAK,QAAQ;CAC3C,IAAI,CAAC,OAAO;CACZ,MAAM,OAAO,MAAM;CACnB,MAAM,eAAe,OAAO,MAAM,EAAE,IAAI,mBAAmB;CAC3D,OAAO,OAAO,cAAc,YAAY,IAAI,eAAe,KAAK;AACjE;AACA,MAAM,oBAAoB,CAAC,kBAAkB,4BAA4B;AAGzE,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,+CAA+C,6FAA6F;AAG/L,MAAM,iBAAiB,EAAE,KAAK;CAC7B;CACA;CACA;CACA;AACD,CAAC;AAGD,MAAM,gBAAgB,EAAE,QAAQ,UAAU,iBAAiB,EAAE,SAAS,uBAAuB;AAC7F,MAAM,iBAAiB,EAAE,QAAQ,UAAU,OAAO,UAAU,YAAY,qBAAqB;AAC7F,MAAM,wBAAwB,EAAE,OAAO;CACtC,OAAO;CACP,QAAQ;AACT,CAAC;AACD,MAAM,yBAAyB,EAAE,OAAO;CACvC,QAAQ;CACR,OAAO;CACP,QAAQ;AACT,CAAC;AACD,MAAM,6BAA6B,EAAE,OAAO;CAC3C,UAAU,EAAE,OAAO;EAClB,eAAe;EACf,OAAO;EACP,eAAe;CAChB,CAAC;CACD,MAAM;AACP,CAAC;AACD,MAAM,kCAAkC,EAAE,mBAAmB,QAAQ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