@neurocode-ai/server 1.18.8

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/src/routes.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { Database } from "@neurocode-ai/core/database/database"
2
+ import { LayerNode } from "@neurocode-ai/core/effect/layer-node"
3
+ import { httpClient } from "@neurocode-ai/core/effect/app-node-platform"
4
+ import { AppNodeBuilder } from "@neurocode-ai/core/effect/app-node-builder"
5
+ import { EventV2 } from "@neurocode-ai/core/event"
6
+ import { Credential } from "@neurocode-ai/core/credential"
7
+ import { PermissionSaved } from "@neurocode-ai/core/permission/saved"
8
+ import { PtyTicket } from "@neurocode-ai/core/pty/ticket"
9
+ import { SessionV2 } from "@neurocode-ai/core/session"
10
+ import { SessionExecution } from "@neurocode-ai/core/session/execution"
11
+ import { LocationServiceMap } from "@neurocode-ai/core/location-service-map"
12
+ import { SessionExecutionLocal } from "@neurocode-ai/core/session/execution/local"
13
+ import { ToolOutputStore } from "@neurocode-ai/core/tool-output-store"
14
+ import { HttpRouter, HttpServer } from "effect/unstable/http"
15
+ import { HttpApiBuilder } from "effect/unstable/httpapi"
16
+ import { Layer, Option } from "effect"
17
+ import { Api } from "./api"
18
+ import { ServerAuth } from "./auth"
19
+ import { handlers } from "./handlers"
20
+ import { authorizationLayer } from "./middleware/authorization"
21
+ import { schemaErrorLayer } from "./middleware/schema-error"
22
+ import { PtyEnvironment } from "./pty-environment"
23
+ import { layer as locationLayer } from "./location"
24
+ import { sessionLocationLayer } from "./middleware/session-location"
25
+
26
+ const applicationServices = LayerNode.group([
27
+ Database.node,
28
+ EventV2.node,
29
+ httpClient,
30
+ ToolOutputStore.cleanupNode,
31
+ SessionV2.node,
32
+ PermissionSaved.node,
33
+ PtyTicket.node,
34
+ Credential.node,
35
+ PtyEnvironment.node,
36
+ LocationServiceMap.node,
37
+ ])
38
+
39
+ export function createRoutes(password?: string) {
40
+ return makeRoutes(
41
+ password
42
+ ? ServerAuth.Config.configLayer({ username: "opencode", password: Option.some(password) })
43
+ : ServerAuth.Config.layer,
44
+ )
45
+ }
46
+
47
+ export function createEmbeddedRoutes() {
48
+ return makeRoutes(ServerAuth.Config.configLayer({ username: "opencode", password: Option.none() }))
49
+ }
50
+
51
+ function makeRoutes<AuthError, AuthServices>(auth: Layer.Layer<ServerAuth.Config, AuthError, AuthServices>) {
52
+ const serviceLayer = AppNodeBuilder.build(applicationServices, [[SessionExecution.node, SessionExecutionLocal.node]])
53
+
54
+ return HttpApiBuilder.layer(Api, { openapiPath: "/openapi.json" }).pipe(
55
+ Layer.provide(handlers),
56
+ Layer.provide(sessionLocationLayer),
57
+ Layer.provide(locationLayer),
58
+ Layer.provide(authorizationLayer),
59
+ Layer.provide(schemaErrorLayer),
60
+ Layer.provide(auth),
61
+ Layer.provide(serviceLayer),
62
+ )
63
+ }
64
+
65
+ export const routes = createRoutes()
66
+
67
+ export const webHandler = () =>
68
+ HttpRouter.toWebHandler(routes.pipe(Layer.provide(HttpServer.layerServices)), { disableLogger: true })
package/sst-env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /* This file is auto-generated by SST. Do not edit. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /* deno-fmt-ignore-file */
5
+ /* biome-ignore-all lint: auto-generated */
6
+
7
+ /// <reference path="../../sst-env.d.ts" />
8
+
9
+ import "sst"
10
+ export {}
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "@tsconfig/bun/tsconfig.json",
4
+ "compilerOptions": {
5
+ "lib": ["ESNext", "DOM", "DOM.Iterable"],
6
+ "noUncheckedIndexedAccess": false
7
+ }
8
+ }