overmux 0.0.2 → 0.0.4

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 (72) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/auth/.vite/manifest.json +2 -2
  3. package/dist/auth/assets/{index-Bx8JhwVi.css → index-BM9gETvx.css} +1 -1
  4. package/dist/auth/assets/{index-CHIE7qYj.js → index-DabAfcs1.js} +1 -1
  5. package/dist/auth/index.html +2 -2
  6. package/dist/bin.js +430 -18
  7. package/dist/bin.js.map +1 -1
  8. package/dist/docs/200-getting-started/100-install-and-run-overmux.md +1 -2
  9. package/dist/docs/300-fundamentals/100-project-structure.md +20 -0
  10. package/dist/docs/300-fundamentals/300-theming.md +51 -0
  11. package/dist/docs/400-reference/100-configuration.md +20 -0
  12. package/dist/docs/400-reference/200-server-api.md +18 -0
  13. package/dist/docs/400-reference/300-client-api.md +36 -0
  14. package/dist/docs/400-reference/400-cli/050-init.md +17 -0
  15. package/dist/docs/400-reference/400-cli/350-instance.md +24 -0
  16. package/dist/exports/client.d.ts +33 -3
  17. package/dist/exports/client.d.ts.map +1 -1
  18. package/dist/exports/client.js +123 -14
  19. package/dist/exports/client.js.map +1 -1
  20. package/dist/exports/{index-D3_Dpy_T.d.ts → index-DS70rKzo.d.ts} +14 -2
  21. package/dist/exports/index-DS70rKzo.d.ts.map +1 -0
  22. package/dist/exports/index.d.ts +2 -2
  23. package/dist/exports/index.js +1 -1
  24. package/dist/exports/index.js.map +1 -1
  25. package/dist/exports/{notifications-kDp16bU_.js → notifications-av0FK0yZ.js} +7 -2
  26. package/dist/exports/{notifications-kDp16bU_.js.map → notifications-av0FK0yZ.js.map} +1 -1
  27. package/dist/exports/server.d.ts.map +1 -1
  28. package/dist/exports/server.js +52 -10
  29. package/dist/exports/server.js.map +1 -1
  30. package/dist/internal/server/coordinator/server-child.js +110 -46
  31. package/dist/internal/server/coordinator/server-child.js.map +1 -1
  32. package/docs/200-getting-started/100-install-and-run-overmux.md +1 -2
  33. package/docs/300-fundamentals/100-project-structure.md +20 -0
  34. package/docs/300-fundamentals/300-theming.md +51 -0
  35. package/docs/400-reference/100-configuration.md +20 -0
  36. package/docs/400-reference/200-server-api.md +18 -0
  37. package/docs/400-reference/300-client-api.md +36 -0
  38. package/docs/400-reference/400-cli/050-init.md +17 -0
  39. package/docs/400-reference/400-cli/350-instance.md +24 -0
  40. package/package.json +2 -2
  41. package/src/internal/cli/app.ts +7 -1
  42. package/src/internal/cli/commands/init-template.ts +146 -0
  43. package/src/internal/cli/commands/init.ts +267 -0
  44. package/src/internal/cli/commands/instance.ts +58 -0
  45. package/src/internal/cli/commands/integration.ts +15 -0
  46. package/src/internal/cli/commands/zellij-install.ts +96 -0
  47. package/src/internal/cli/parse-port.ts +2 -1
  48. package/src/internal/client/auth/auth-shell.css +17 -1
  49. package/src/internal/client/auth/auth-shell.tsx +2 -11
  50. package/src/internal/client/auth/login-code-input.tsx +140 -0
  51. package/src/internal/client/browser-api.ts +17 -3
  52. package/src/internal/client/clipboard.ts +22 -0
  53. package/src/internal/client/host/desktop-host.ts +15 -0
  54. package/src/internal/client/host/environment.ts +67 -0
  55. package/src/internal/client/host/instance-forwarding.ts +21 -0
  56. package/src/internal/client/host/notification-forwarding.ts +1 -10
  57. package/src/internal/client/host/overmux-host.tsx +8 -0
  58. package/src/internal/client/overmux-react.ts +24 -2
  59. package/src/internal/client/websocket.ts +48 -20
  60. package/src/internal/server/auth/instance-control.ts +24 -3
  61. package/src/internal/server/runtime/create-runtime.ts +12 -1
  62. package/src/internal/server/runtime/runtime-instance.ts +46 -0
  63. package/src/internal/server/runtime/runtime-resources.ts +3 -0
  64. package/src/internal/server/server-startup-options.ts +9 -4
  65. package/src/internal/server/start-application-server.ts +20 -12
  66. package/src/internal/server/websocket-server.ts +7 -0
  67. package/src/internal/shared/index.ts +2 -0
  68. package/src/internal/shared/protocol.ts +10 -1
  69. package/src/public/client.ts +5 -0
  70. package/src/public/config.ts +7 -0
  71. package/src/public/index.ts +2 -0
  72. package/dist/exports/index-D3_Dpy_T.d.ts.map +0 -1
@@ -16,6 +16,10 @@ declare const notificationSchema: z.ZodObject<{
16
16
  title: z.ZodString;
17
17
  }, z.core.$strict>;
18
18
  type Notification = z.infer<typeof notificationSchema>;
19
+ type InstanceIdentity = {
20
+ instanceId: string;
21
+ deepLinkPrefix: string;
22
+ };
19
23
  type AiContextSnippetDefinition = readonly AiContextSnippet[];
20
24
  declare const coreAiContextSnippets: readonly ["package-source"];
21
25
  declare const defaultAiContextSnippets: readonly ["package-source", "tech-stack-recommendations"];
@@ -39,7 +43,12 @@ type StreamContract<TInput extends z.ZodType = z.ZodType, TClientMessage extends
39
43
  };
40
44
  declare const defineStreamContract: <TInput extends z.ZodType, TClientMessage extends z.ZodType, TServerMessage extends z.ZodType>(contract: StreamContract<TInput, TClientMessage, TServerMessage>) => StreamContract<TInput, TClientMessage, TServerMessage>;
41
45
  type RuntimeDisposer = () => Promise<void> | void;
46
+ type InstanceContext = {
47
+ getInstanceId: () => string;
48
+ getDeepLinkPrefix: () => string;
49
+ };
42
50
  type HandlerContext = {
51
+ instance: InstanceContext;
43
52
  invalidate: (contract: ResourceContract, input?: unknown) => void;
44
53
  signal: AbortSignal;
45
54
  };
@@ -133,6 +142,9 @@ type OvermuxConfigDefinition<TServer extends ConfigDefinition = ConfigDefinition
133
142
  aiContextSnippets?: AiContextSnippetDefinition;
134
143
  auth: AuthConfigDefinition;
135
144
  debug?: boolean;
145
+ instanceId?: string | ((context: {
146
+ port: number;
147
+ }) => string);
136
148
  server: TServer;
137
149
  vite?: string;
138
150
  };
@@ -151,5 +163,5 @@ declare const defineOvermuxServer: <const TContracts extends ResourceContracts =
151
163
  streams?: TStreams;
152
164
  }) => ConfigDefinition<ConfiguredResources<TContracts, TDependencies>, TStreams, TOperations>;
153
165
  declare const defineOvermuxConfig: <const TServer extends ConfigDefinition>(definition: OvermuxConfigDefinition<TServer>) => OvermuxConfigDefinition<TServer>;
154
- export { parseJsonValue as A, notificationSchema as B, ContractInputArguments as C, defineStreamContract as D, defineResourceContract as E, defaultAiContextSnippets as F, techStackRecommendationsSnippet as G, overmuxSettingsPath as H, AiContextSnippet as I, Notification as L, AiContextSnippetDefinition as M, composeAiContext as N, jsonValueSchema as O, coreAiContextSnippets as P, createOvermuxSettingsPath as R, defineStreamHandler as S, StreamContract as T, packageSourceSnippet as U, overmuxLogoutPath as V, resolveOvermuxReturnTo as W, StreamSession as _, HandlerContext as a, defineOvermuxConfig as b, OvermuxConfigDefinition as c, OvermuxServerStreams as d, QueryResourceDefinition as f, StreamHandlerDefinition as g, ServerConfigDefinition as h, DerivedResourceDefinition as i, Notifications as j, noInputSchema as k, OvermuxServerOperations as l, RuntimeDisposer as m, AuthDuration as n, OperationContext as o, ResourceDefinition as p, ConfigDefinition as r, OperationDefinition as s, AuthConfigDefinition as t, OvermuxServerResources as u, SubscriptionResourceDefinition as v, ResourceContract as w, defineOvermuxServer as x, defineOperation as y, notificationLinkSchema as z };
155
- //# sourceMappingURL=index-D3_Dpy_T.d.ts.map
166
+ export { noInputSchema as A, createOvermuxSettingsPath as B, defineStreamHandler as C, defineResourceContract as D, StreamContract as E, coreAiContextSnippets as F, packageSourceSnippet as G, notificationSchema as H, defaultAiContextSnippets as I, resolveOvermuxReturnTo as K, AiContextSnippet as L, Notifications as M, AiContextSnippetDefinition as N, defineStreamContract as O, composeAiContext as P, InstanceIdentity as R, defineOvermuxServer as S, ResourceContract as T, overmuxLogoutPath as U, notificationLinkSchema as V, overmuxSettingsPath as W, StreamHandlerDefinition as _, HandlerContext as a, defineOperation as b, OperationDefinition as c, OvermuxServerResources as d, OvermuxServerStreams as f, ServerConfigDefinition as g, RuntimeDisposer as h, DerivedResourceDefinition as i, parseJsonValue as j, jsonValueSchema as k, OvermuxConfigDefinition as l, ResourceDefinition as m, AuthDuration as n, InstanceContext as o, QueryResourceDefinition as p, techStackRecommendationsSnippet as q, ConfigDefinition as r, OperationContext as s, AuthConfigDefinition as t, OvermuxServerOperations as u, StreamSession as v, ContractInputArguments as w, defineOvermuxConfig as x, SubscriptionResourceDefinition as y, Notification as z };
167
+ //# sourceMappingURL=index-DS70rKzo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DS70rKzo.d.ts","names":[],"sources":["../../../shared/dist/index.d.ts","../../src/public/ai-context.ts","../../src/public/notifications.ts","../../src/public/contracts.ts","../../src/public/config.ts"],"mappings":";;;cAEc;cACA;cACA;KACT,2BAA2B;;;cAGlB;cACA;cACA,yBAAyB;cACzB,4BAA4B;;;cAG5B,wBAAwB,EAAE,mBAAmB,EAAE,WAAW,EAAE;cAC5D,oBAAoB,EAAE;EAClC,MAAM,EAAE,YAAY,EAAE;EACtB,MAAM,EAAE,YAAY,EAAE;IACpB,MAAM,EAAE,mBAAmB,EAAE,WAAW,EAAE;KACzC,EAAE,KAAK;EACV,OAAO,EAAE;GACR,EAAE,KAAK;KACL,eAAe,EAAE,aAAa;KAI9B;EACH;EACA;;;;KCjBU,sCAAsC;cAErC;cAGA;cAoBA,mBAAoB,UAAU;;;KC7B/B;EACV,OAAO,cAAc,iBAAiB;;;;cCN3B,eAAa,EAAA;cAEb,iBAAiB,EAAE;cAWnB,iBAAkB,GAAG,OAAO,MAAI;KAGjC,uBAAuB,eAAe,EAAE,6BAChC,EAAE,MAAM,WACrB,QAAQ,QAAQ,EAAE,MAAM,wBACxB,OAAO,EAAE,MAAM;KAEV,iBACV,eAAe,EAAE,UAAU,EAAE,SAC7B,gBAAgB,EAAE,UAAU,EAAE;EAE9B,OAAO;EACP,QAAQ;;cAGG,yBACX,eAAe,EAAE,SACjB,gBAAgB,EAAE,SAElB,UAAU,iBAAiB,QAAQ,aAClC,iBAAiB,QAAQ;KAEhB,eACV,eAAe,EAAE,UAAU,EAAE,SAC7B,uBAAuB,EAAE,UAAU,EAAE,SACrC,uBAAuB,EAAE,UAAU,EAAE;EAErC,eAAe;EACf,OAAO;EACP,eAAe;;cAGJ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BAAkB,YAAY,QAAQ,cAAc;KAK3D,oBACH,mBAAmB,mBACnB,oBAEC,aAAa,aAAa,mBAAmB,YAAY,eAAe,UACvE,iBAAiB;KAET;KAEA;EACV;EACA;EACA,4BAA4B;EAC5B;;KAGU;EACV;EACA;EACA;EACA;EACA;;KAGG,oBAAoB,SACvB,eAAe,wBAAwB,YAAY,YAAY;KAG5D,uBAAuB,SAC1B,eAAe,oBAAoB,YAAY;KAGrC,iBACV,mBAAmB,SAAS,2BAA2B,SACrD,eAAe,sBAEjB,iBAAiB,oBAAoB,mBACrC,oBAAoB,uBAAuB;EAE3C,aAAa;EACb,WAAW;EACX,UAAU;;KAGA,wBACV,gBAAgB,mBAAmB,oBACjC;EACF,oBAAoB;EACpB,MAAM;EACN;EACA,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,oBAAoB,2BAC1B;EACA,aAAa;EACb,WAAW,oBAAoB,YAAY;EAC3C,UAAU;MACR,iBACF,oBAAoB,YAAY,gBAChC,UACA;cAGW,4BAA6B,gBAAgB,kBACxD,YAAY,wBAAwB,aACnC,wBAAwB"}
@@ -1,2 +1,2 @@
1
- import { A as parseJsonValue, B as notificationSchema, C as ContractInputArguments, D as defineStreamContract, E as defineResourceContract, F as defaultAiContextSnippets, G as techStackRecommendationsSnippet, H as overmuxSettingsPath, I as AiContextSnippet, L as Notification, M as AiContextSnippetDefinition, N as composeAiContext, O as jsonValueSchema, P as coreAiContextSnippets, R as createOvermuxSettingsPath, S as defineStreamHandler, T as StreamContract, U as packageSourceSnippet, V as overmuxLogoutPath, W as resolveOvermuxReturnTo, _ as StreamSession, a as HandlerContext, b as defineOvermuxConfig, c as OvermuxConfigDefinition, d as OvermuxServerStreams, f as QueryResourceDefinition, g as StreamHandlerDefinition, h as ServerConfigDefinition, i as DerivedResourceDefinition, j as Notifications, k as noInputSchema, l as OvermuxServerOperations, m as RuntimeDisposer, n as AuthDuration, o as OperationContext, p as ResourceDefinition, r as ConfigDefinition, s as OperationDefinition, t as AuthConfigDefinition, u as OvermuxServerResources, v as SubscriptionResourceDefinition, w as ResourceContract, x as defineOvermuxServer, y as defineOperation, z as notificationLinkSchema } from "./index-D3_Dpy_T.js";
2
- export { type AiContextSnippet, type AiContextSnippetDefinition, type AuthConfigDefinition, type AuthDuration, type ConfigDefinition, type ContractInputArguments, type DerivedResourceDefinition, type HandlerContext, 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 noInputSchema, B as createOvermuxSettingsPath, C as defineStreamHandler, D as defineResourceContract, E as StreamContract, F as coreAiContextSnippets, G as packageSourceSnippet, H as notificationSchema, I as defaultAiContextSnippets, K as resolveOvermuxReturnTo, L as AiContextSnippet, M as Notifications, N as AiContextSnippetDefinition, O as defineStreamContract, P as composeAiContext, R as InstanceIdentity, S as defineOvermuxServer, T as ResourceContract, U as overmuxLogoutPath, V as notificationLinkSchema, W as overmuxSettingsPath, _ as StreamHandlerDefinition, a as HandlerContext, b as defineOperation, c as OperationDefinition, d as OvermuxServerResources, f as OvermuxServerStreams, g as ServerConfigDefinition, h as RuntimeDisposer, i as DerivedResourceDefinition, j as parseJsonValue, k as jsonValueSchema, l as OvermuxConfigDefinition, m as ResourceDefinition, n as AuthDuration, o as InstanceContext, p as QueryResourceDefinition, q as techStackRecommendationsSnippet, r as ConfigDefinition, s as OperationContext, t as AuthConfigDefinition, u as OvermuxServerOperations, v as StreamSession, w as ContractInputArguments, x as defineOvermuxConfig, y as SubscriptionResourceDefinition, z as Notification } from "./index-DS70rKzo.js";
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,4 +1,4 @@
1
- import { a as overmuxSettingsPath, c as techStackRecommendationsSnippet, i as overmuxLogoutPath, n as notificationLinkSchema, o as packageSourceSnippet, r as notificationSchema, s as resolveOvermuxReturnTo, t as createOvermuxSettingsPath } from "./notifications-kDp16bU_.js";
1
+ import { a as notificationSchema, c as packageSourceSnippet, i as notificationLinkSchema, l as resolveOvermuxReturnTo, n as createOvermuxSettingsPath, o as overmuxLogoutPath, s as overmuxSettingsPath, u as techStackRecommendationsSnippet } from "./notifications-av0FK0yZ.js";
2
2
  import { z } from "zod";
3
3
  //#region src/public/ai-context.ts
4
4
  const coreAiContextSnippets = [packageSourceSnippet];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/public/ai-context.ts","../../src/public/config.ts","../../src/public/contracts.ts"],"sourcesContent":["import {\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n} from \"@overmux/shared\";\n\nexport {\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n};\nexport type AiContextSnippetDefinition = readonly AiContextSnippet[];\n\nexport const coreAiContextSnippets = [\n packageSourceSnippet,\n] as const satisfies AiContextSnippetDefinition;\nexport const defaultAiContextSnippets = [\n ...coreAiContextSnippets,\n techStackRecommendationsSnippet,\n] as const satisfies AiContextSnippetDefinition;\n\nconst packageSourceSnippetContent = `Overmux ships with documentation and TypeScript source.\n\nRun \\`overmux docs\\` to find the installed documentation and source for the overmux cli.\n\nE.g. \\`node_modules/overmux\\` and \\`node_modules/@overmux/xterm\\`.\n\nInspect these files so guidance matches the versions used by the application.`;\n\nconst 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.`;\n\nconst aiContextContentBySnippet: Record<AiContextSnippet, string> = {\n [packageSourceSnippet]: packageSourceSnippetContent,\n [techStackRecommendationsSnippet]: techStackRecommendationsSnippetContent,\n};\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 HandlerContext = {\n invalidate: (contract: ResourceContract, input?: unknown) => void;\n signal: AbortSignal;\n};\n\nexport type OperationContext = HandlerContext & {\n notifications: Notifications;\n};\n\nexport type OperationDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n> = {\n handle: (\n input: z.output<TInput>,\n context: OperationContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n input: TInput;\n output: TOutput;\n};\n\nexport const defineOperation = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n>({\n handle,\n input,\n output,\n}: {\n handle: OperationDefinition<TInput, TOutput>[\"handle\"];\n input: TInput;\n output?: TOutput;\n}): OperationDefinition<TInput, TOutput> => ({\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> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"query\";\n read: (\n input: z.output<TInput>,\n context: HandlerContext,\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> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"subscription\";\n read: QueryResourceDefinition<TInput, TOutput>[\"read\"];\n subscribe: (\n input: z.output<TInput>,\n invalidate: () => void,\n context: HandlerContext,\n ) => 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<AnyZodType, AnyZodType>\n | SubscriptionResourceDefinition<AnyZodType, AnyZodType>\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: HandlerContext & {\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 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<TContract extends ResourceContract<AnyZodType, AnyZodType>> = {\n contract: TContract;\n} & Omit<\n QueryResourceDefinition<TContract[\"input\"], TContract[\"output\"]>,\n \"contract\"\n>;\n\ntype SubscriptionFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n> = { contract: TContract } & Omit<\n SubscriptionResourceDefinition<TContract[\"input\"], TContract[\"output\"]>,\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]>\n | SubscriptionFor<TContracts[TId]>\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?: \"never\" | AuthDuration;\n trustedProxyPeer?: string;\n};\n\nexport type ServerConfigDefinition = {\n host?: string;\n logFile?: 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<string, OperationDefinition<AnyZodType, AnyZodType>>\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 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 TOperations extends OperationDefinitions = {},\n>(definition: {\n operations?: TOperations;\n resources: ConfiguredResources<TContracts, TDependencies>;\n streams?: TStreams;\n}): ConfigDefinition<\n ConfiguredResources<TContracts, TDependencies>,\n TStreams,\n TOperations\n> => definition;\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":";;;AAaA,MAAa,wBAAwB,CACnC,oBACF;AACA,MAAa,2BAA2B,CACtC,GAAG,uBACH,+BACF;AAEA,MAAM,8BAA8B;;;;;;;AAQpC,MAAM,yCAAyC;AAE/C,MAAM,4BAA8D;EACjE,uBAAuB;EACvB,kCAAkC;AACrC;AAEA,MAAa,oBAAoB,aAC/B,SAAS,WAAW,IAChB,KACA,GAAG,SACA,KACE,YAAY,MAAM,QAAQ,MAAM,0BAA0B,UAC7D,CAAC,CACA,KAAK,MAAM,EAAE;;;ACdtB,MAAa,mBAGX,EACA,QACA,OACA,cAK2C;CAC3C;CACA;CACA,QAAS,UAAU,EAAE,KAAK;AAC5B;AAuEA,MAAa,uBAKX,UACA,UACqE;CACrE;CACA;AACF;AAgJA,MAAa,uBAKX,eAQG;AAEL,MAAa,uBACX,eACqC;;;AC5RvC,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":["../../src/public/ai-context.ts","../../src/public/config.ts","../../src/public/contracts.ts"],"sourcesContent":["import {\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n} from \"@overmux/shared\";\n\nexport {\n packageSourceSnippet,\n techStackRecommendationsSnippet,\n type AiContextSnippet,\n};\nexport type AiContextSnippetDefinition = readonly AiContextSnippet[];\n\nexport const coreAiContextSnippets = [\n packageSourceSnippet,\n] as const satisfies AiContextSnippetDefinition;\nexport const defaultAiContextSnippets = [\n ...coreAiContextSnippets,\n techStackRecommendationsSnippet,\n] as const satisfies AiContextSnippetDefinition;\n\nconst packageSourceSnippetContent = `Overmux ships with documentation and TypeScript source.\n\nRun \\`overmux docs\\` to find the installed documentation and source for the overmux cli.\n\nE.g. \\`node_modules/overmux\\` and \\`node_modules/@overmux/xterm\\`.\n\nInspect these files so guidance matches the versions used by the application.`;\n\nconst 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.`;\n\nconst aiContextContentBySnippet: Record<AiContextSnippet, string> = {\n [packageSourceSnippet]: packageSourceSnippetContent,\n [techStackRecommendationsSnippet]: techStackRecommendationsSnippetContent,\n};\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\nexport type HandlerContext = {\n instance: InstanceContext;\n invalidate: (contract: ResourceContract, input?: unknown) => void;\n signal: AbortSignal;\n};\n\nexport type OperationContext = HandlerContext & {\n notifications: Notifications;\n};\n\nexport type OperationDefinition<\n TInput extends z.ZodType = z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n> = {\n handle: (\n input: z.output<TInput>,\n context: OperationContext,\n ) => Promise<z.input<NoInfer<TOutput>>> | z.input<NoInfer<TOutput>>;\n input: TInput;\n output: TOutput;\n};\n\nexport const defineOperation = <\n TInput extends z.ZodType,\n TOutput extends z.ZodType = z.ZodVoid,\n>({\n handle,\n input,\n output,\n}: {\n handle: OperationDefinition<TInput, TOutput>[\"handle\"];\n input: TInput;\n output?: TOutput;\n}): OperationDefinition<TInput, TOutput> => ({\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> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"query\";\n read: (\n input: z.output<TInput>,\n context: HandlerContext,\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> = {\n contract: ResourceContract<TInput, TOutput>;\n kind: \"subscription\";\n read: QueryResourceDefinition<TInput, TOutput>[\"read\"];\n subscribe: (\n input: z.output<TInput>,\n invalidate: () => void,\n context: HandlerContext,\n ) => 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<AnyZodType, AnyZodType>\n | SubscriptionResourceDefinition<AnyZodType, AnyZodType>\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: HandlerContext & {\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 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<TContract extends ResourceContract<AnyZodType, AnyZodType>> = {\n contract: TContract;\n} & Omit<\n QueryResourceDefinition<TContract[\"input\"], TContract[\"output\"]>,\n \"contract\"\n>;\n\ntype SubscriptionFor<\n TContract extends ResourceContract<AnyZodType, AnyZodType>,\n> = { contract: TContract } & Omit<\n SubscriptionResourceDefinition<TContract[\"input\"], TContract[\"output\"]>,\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]>\n | SubscriptionFor<TContracts[TId]>\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?: \"never\" | AuthDuration;\n trustedProxyPeer?: string;\n};\n\nexport type ServerConfigDefinition = {\n host?: string;\n logFile?: 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<string, OperationDefinition<AnyZodType, AnyZodType>>\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 TOperations extends OperationDefinitions = {},\n>(definition: {\n operations?: TOperations;\n resources: ConfiguredResources<TContracts, TDependencies>;\n streams?: TStreams;\n}): ConfigDefinition<\n ConfiguredResources<TContracts, TDependencies>,\n TStreams,\n TOperations\n> => definition;\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":";;;AAaA,MAAa,wBAAwB,CACnC,oBACF;AACA,MAAa,2BAA2B,CACtC,GAAG,uBACH,+BACF;AAEA,MAAM,8BAA8B;;;;;;;AAQpC,MAAM,yCAAyC;AAE/C,MAAM,4BAA8D;EACjE,uBAAuB;EACvB,kCAAkC;AACrC;AAEA,MAAa,oBAAoB,aAC/B,SAAS,WAAW,IAChB,KACA,GAAG,SACA,KACE,YAAY,MAAM,QAAQ,MAAM,0BAA0B,UAC7D,CAAC,CACA,KAAK,MAAM,EAAE;;;ACRtB,MAAa,mBAGX,EACA,QACA,OACA,cAK2C;CAC3C;CACA;CACA,QAAS,UAAU,EAAE,KAAK;AAC5B;AAuEA,MAAa,uBAKX,UACA,UACqE;CACrE;CACA;AACF;AAiJA,MAAa,uBAKX,eAQG;AAEL,MAAa,uBACX,eACqC;;;ACnSvC,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"}
@@ -50,7 +50,12 @@ const notificationSchema = z.object({
50
50
  open: z.object({ link: notificationLinkSchema }).strict().optional(),
51
51
  title: z.string().min(1).max(4096)
52
52
  }).strict();
53
+ 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");
54
+ const createInstanceIdentity = (instanceId) => ({
55
+ instanceId: instanceIdSchema.parse(instanceId),
56
+ deepLinkPrefix: `overmux://${instanceId}`
57
+ });
53
58
  //#endregion
54
- export { overmuxSettingsPath as a, techStackRecommendationsSnippet as c, overmuxLogoutPath as i, notificationLinkSchema as n, packageSourceSnippet as o, notificationSchema as r, resolveOvermuxReturnTo as s, createOvermuxSettingsPath as t };
59
+ export { notificationSchema as a, packageSourceSnippet as c, notificationLinkSchema as i, resolveOvermuxReturnTo as l, createOvermuxSettingsPath as n, overmuxLogoutPath as o, instanceIdSchema as r, overmuxSettingsPath as s, createInstanceIdentity as t, techStackRecommendationsSnippet as u };
55
60
 
56
- //# sourceMappingURL=notifications-kDp16bU_.js.map
61
+ //# sourceMappingURL=notifications-av0FK0yZ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notifications-kDp16bU_.js","names":[],"sources":["../../../shared/dist/index.js"],"sourcesContent":["import { z } from \"zod\";\n//#region src/ai-context.ts\nconst packageSourceSnippet = \"package-source\";\nconst techStackRecommendationsSnippet = \"tech-stack-recommendations\";\nconst aiContextSnippets = [packageSourceSnippet, techStackRecommendationsSnippet];\n//#endregion\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\nexport { aiContextSnippets, createOvermuxSettingsPath, notificationLinkSchema, notificationSchema, overmuxLogoutPath, overmuxSettingsPath, packageSourceSnippet, resolveOvermuxReturnTo, techStackRecommendationsSnippet };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;AAEA,MAAM,uBAAuB;AAC7B,MAAM,kCA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AAC,IAAI,CAAC,CAAC,QAAQ,SAAS;CAC9J,IAAI,CAAC,IAAI,SAAS,IAAI,GAAG,OAAO;CAChC,MAAM,MAAM,IAAI,IAAI,IAAI;CACxB,OAAO,CAAC,SAAS,QAAQ,CAAC,CAAC,SAAS,IAAI,QAAQ,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI;AAC5E,CAAC,CAAC,CAAC;AACH,MAAM,qBAAqB,EAAE,OAAO;CACnC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS;CACpC,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;CACnE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;AAClC,CAAC,CAAC,CAAC,OAAO"}
1
+ {"version":3,"file":"notifications-av0FK0yZ.js","names":[],"sources":["../../../shared/dist/index.js"],"sourcesContent":["import { z } from \"zod\";\n//#region src/ai-context.ts\nconst packageSourceSnippet = \"package-source\";\nconst techStackRecommendationsSnippet = \"tech-stack-recommendations\";\nconst aiContextSnippets = [packageSourceSnippet, techStackRecommendationsSnippet];\n//#endregion\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\nexport { aiContextSnippets, createInstanceIdentity, createOvermuxSettingsPath, instanceIdSchema, notificationLinkSchema, notificationSchema, overmuxLogoutPath, overmuxSettingsPath, packageSourceSnippet, resolveOvermuxReturnTo, techStackRecommendationsSnippet };\n\n//# sourceMappingURL=index.js.map"],"mappings":";;AAEA,MAA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C,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,SAAS;CAC9J,IAAI,CAAC,IAAI,SAAS,IAAI,GAAG,OAAO;CAChC,MAAM,MAAM,IAAI,IAAI,IAAI;CACxB,OAAO,CAAC,SAAS,QAAQ,CAAC,CAAC,SAAS,IAAI,QAAQ,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI;AAC5E,CAAC,CAAC,CAAC;AACH,MAAM,qBAAqB,EAAE,OAAO;CACnC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS;CACpC,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS;CACnE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;AAClC,CAAC,CAAC,CAAC,OAAO;AAGV,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,+CAA+C,6FAA6F;AAC/L,MAAM,0BAA0B,gBAAgB;CAC/C,YAAY,iBAAiB,MAAM,UAAU;CAC7C,gBAAgB,aAAa;AAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","names":[],"sources":["../../src/internal/server/check-overmux.ts","../../../shared/dist/node/index.d.ts","../../src/public/config.ts","../../src/internal/server/start-overmux-server.ts"],"mappings":";;KAOY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,aAAa;EACb;EACA;;KAGU;EACV,UAAU;EACV;EACA,cAAc;EACd;;cAyRW,eACX,SAAS,wBACR,QAAQ;;;;;KC5HN;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;;;KCSjJ;EACV;EACA;EACA;EACA;EACA;;;;KCrNU,uBAAuB;EACjC,gBAAgB;EAChB;EACA;EACA;;KAGU;EACV;EACA,aAAa;EACb;EACA;;cAGW,qBACX,SAAS,yBACR,QAAQ"}
1
+ {"version":3,"file":"server.d.ts","names":[],"sources":["../../src/internal/server/check-overmux.ts","../../../shared/dist/node/index.d.ts","../../src/public/config.ts","../../src/internal/server/start-overmux-server.ts"],"mappings":";;KAOY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,aAAa;EACb;EACA;;KAGU;EACV,UAAU;EACV;EACA,cAAc;EACd;;cAyRW,eACX,SAAS,wBACR,QAAQ;;;;;KCpHN;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;;;KCOjJ;EACV;EACA;EACA;EACA;EACA;;;;KC3NU,uBAAuB;EACjC,gBAAgB;EAChB;EACA;EACA;;KAGU;EACV;EACA,aAAa;EACb;EACA;;cAGW,qBACX,SAAS,yBACR,QAAQ"}
@@ -3,7 +3,7 @@ import { isIP } from "node:net";
3
3
  import { dirname, isAbsolute, join, resolve } from "node:path";
4
4
  import { createJiti } from "jiti";
5
5
  import { ZodError, z } from "zod";
6
- import { homedir } from "node:os";
6
+ import { homedir, hostname } from "node:os";
7
7
  import ts from "typescript";
8
8
  import { isDeepStrictEqual } from "node:util";
9
9
  import { fork } from "node:child_process";
@@ -26,6 +26,7 @@ const durationToMilliseconds = (duration) => {
26
26
  return Number.isSafeInteger(milliseconds) ? milliseconds : void 0;
27
27
  };
28
28
  const aiContextSnippets = ["package-source", "tech-stack-recommendations"];
29
+ const instanceIdSchema$1 = 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");
29
30
  const zodTypeSchema = z.custom((value) => value instanceof z.ZodType, "Expected a Zod schema");
30
31
  const functionSchema = z.custom((value) => typeof value === "function", "Expected a function");
31
32
  const contractRuntimeSchema = z.object({
@@ -93,6 +94,7 @@ const configDefinitionRuntimeSchema = serverConfigRuntimeSchema.extend({
93
94
  aiContextSnippets: z.array(z.enum(aiContextSnippets)).optional(),
94
95
  auth: authConfigRuntimeSchema,
95
96
  debug: z.boolean().optional(),
97
+ instanceId: z.union([instanceIdSchema$1, z.custom((value) => typeof value === "function", "Expected an instance ID or a function of the bound port")]).optional(),
96
98
  server: serverDefinitionRuntimeSchema,
97
99
  vite: z.string().min(1).optional()
98
100
  });
@@ -185,10 +187,15 @@ const notificationSchema = z.object({
185
187
  open: z.object({ link: notificationLinkSchema }).strict().optional(),
186
188
  title: z.string().min(1).max(4096)
187
189
  }).strict();
190
+ 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");
191
+ const createInstanceIdentity = (instanceId) => ({
192
+ instanceId: instanceIdSchema.parse(instanceId),
193
+ deepLinkPrefix: `overmux://${instanceId}`
194
+ });
188
195
  z.object({
189
196
  debug: z.boolean(),
190
197
  operations: z.array(z.string().min(1)),
191
- protocolVersion: z.literal(9),
198
+ protocolVersion: z.literal(10),
192
199
  resources: z.array(z.string().min(1)),
193
200
  streams: z.array(z.string().min(1))
194
201
  });
@@ -294,7 +301,12 @@ const protocolErrorMessageSchema = z.object({
294
301
  subscriptionId: operationIdSchema.optional(),
295
302
  type: z.literal("error")
296
303
  });
304
+ const serverInfoMessageSchema = z.object({
305
+ type: z.literal("server-info"),
306
+ instanceId: instanceIdSchema
307
+ }).strict();
297
308
  z.discriminatedUnion("type", [
309
+ serverInfoMessageSchema,
298
310
  resourceResultMessageSchema,
299
311
  resourceInvalidatedMessageSchema,
300
312
  streamOpenedMessageSchema,
@@ -306,6 +318,30 @@ z.discriminatedUnion("type", [
306
318
  notificationEventSchema
307
319
  ]);
308
320
  //#endregion
321
+ //#region src/internal/server/runtime/runtime-instance.ts
322
+ const createRuntimeInstance = (configured) => {
323
+ let identity;
324
+ const get = () => {
325
+ if (!identity) throw new Error("Overmux instance identity is not ready");
326
+ return identity;
327
+ };
328
+ return {
329
+ context: {
330
+ getInstanceId: () => get().instanceId,
331
+ getDeepLinkPrefix: () => get().deepLinkPrefix
332
+ },
333
+ establish: (port) => {
334
+ if (identity) throw new Error("Overmux instance identity is already established");
335
+ try {
336
+ identity = createInstanceIdentity(typeof configured === "function" ? configured({ port }) : configured ?? `${hostname()}-${port}`);
337
+ } catch (cause) {
338
+ throw new Error("Invalid Overmux instance ID; configure instanceId with a canonical lowercase ID", { cause });
339
+ }
340
+ return identity;
341
+ }
342
+ };
343
+ };
344
+ //#endregion
309
345
  //#region src/internal/server/runtime/runtime-lifecycle.ts
310
346
  const asError = (cause) => cause instanceof Error ? cause : new Error(String(cause));
311
347
  const disposeAll = async (disposers) => {
@@ -472,7 +508,7 @@ const getInvalidatedResourceIds = (graph, resourceId) => {
472
508
  };
473
509
  //#endregion
474
510
  //#region src/internal/server/runtime/runtime-resources.ts
475
- const createRuntimeResources = ({ definitions, lifecycle }) => {
511
+ const createRuntimeResources = ({ definitions, instance, lifecycle }) => {
476
512
  const graph = createResourceDependencyGraph(definitions);
477
513
  const invalidationListeners = /* @__PURE__ */ new Set();
478
514
  const contracts = /* @__PURE__ */ new Map();
@@ -497,6 +533,7 @@ const createRuntimeResources = ({ definitions, lifecycle }) => {
497
533
  });
498
534
  };
499
535
  const context = (signal) => ({
536
+ instance,
500
537
  invalidate,
501
538
  signal: lifecycle.requestSignal(signal)
502
539
  });
@@ -631,9 +668,11 @@ const createRuntimeStreams = ({ context, definitions, lifecycle }) => {
631
668
  //#region src/internal/server/runtime/create-runtime.ts
632
669
  const createRuntime = async ({ config, debug = false, notifications = { send: async () => void 0 }, signal }) => {
633
670
  const lifecycle = createRuntimeLifecycle(signal);
671
+ const instance = createRuntimeInstance(config.instanceId);
634
672
  try {
635
673
  const resources = createRuntimeResources({
636
674
  definitions: config.server.resources ?? {},
675
+ instance: instance.context,
637
676
  lifecycle
638
677
  });
639
678
  const context = resources.context;
@@ -649,14 +688,17 @@ const createRuntime = async ({ config, debug = false, notifications = { send: as
649
688
  });
650
689
  lifecycle.signal.throwIfAborted();
651
690
  lifecycle.completePreparation();
691
+ const manifest = {
692
+ debug,
693
+ operations: [...operations.names],
694
+ protocolVersion: 10,
695
+ resources: [...resources.names],
696
+ streams: [...streams.names]
697
+ };
652
698
  return {
653
- manifest: {
654
- debug,
655
- operations: [...operations.names],
656
- protocolVersion: 9,
657
- resources: [...resources.names],
658
- streams: [...streams.names]
659
- },
699
+ instance: instance.context,
700
+ establishInstance: instance.establish,
701
+ manifest,
660
702
  dispose: lifecycle.dispose,
661
703
  getOperation: operations.get,
662
704
  getResource: resources.get,