@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/package.json +24 -0
- package/src/api.ts +8 -0
- package/src/auth.ts +63 -0
- package/src/cors.ts +34 -0
- package/src/handlers/agent.ts +13 -0
- package/src/handlers/command.ts +8 -0
- package/src/handlers/credential.ts +22 -0
- package/src/handlers/event.ts +52 -0
- package/src/handlers/fs.ts +39 -0
- package/src/handlers/health.ts +7 -0
- package/src/handlers/integration.ts +104 -0
- package/src/handlers/location.ts +18 -0
- package/src/handlers/message.ts +81 -0
- package/src/handlers/model.ts +17 -0
- package/src/handlers/permission.ts +98 -0
- package/src/handlers/project-copy.ts +68 -0
- package/src/handlers/provider.ts +32 -0
- package/src/handlers/pty.ts +223 -0
- package/src/handlers/question.ts +62 -0
- package/src/handlers/reference.ts +8 -0
- package/src/handlers/session.ts +385 -0
- package/src/handlers/skill.ts +8 -0
- package/src/handlers.ts +40 -0
- package/src/location.ts +60 -0
- package/src/middleware/authorization.ts +58 -0
- package/src/middleware/schema-error.ts +20 -0
- package/src/middleware/session-location.ts +67 -0
- package/src/pty-environment.ts +19 -0
- package/src/routes.ts +68 -0
- package/sst-env.d.ts +10 -0
- package/tsconfig.json +8 -0
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