@zyraxon-ai/server 19.0.3 → 19.0.5
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/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +8 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +26 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +36 -0
- package/dist/auth.js.map +1 -0
- package/dist/cors.d.ts +8 -0
- package/dist/cors.d.ts.map +1 -0
- package/dist/cors.js +36 -0
- package/dist/cors.js.map +1 -0
- package/dist/handlers/agent.d.ts +2 -0
- package/dist/handlers/agent.d.ts.map +1 -0
- package/dist/handlers/agent.js +9 -0
- package/dist/handlers/agent.js.map +1 -0
- package/dist/handlers/command.d.ts +2 -0
- package/dist/handlers/command.d.ts.map +1 -0
- package/dist/handlers/command.js +6 -0
- package/dist/handlers/command.js.map +1 -0
- package/dist/handlers/credential.d.ts +2 -0
- package/dist/handlers/credential.d.ts.map +1 -0
- package/dist/handlers/credential.js +14 -0
- package/dist/handlers/credential.js.map +1 -0
- package/dist/handlers/event.d.ts +2 -0
- package/dist/handlers/event.d.ts.map +1 -0
- package/dist/handlers/event.js +41 -0
- package/dist/handlers/event.js.map +1 -0
- package/dist/handlers/fs.d.ts +2 -0
- package/dist/handlers/fs.d.ts.map +1 -0
- package/dist/handlers/fs.js +25 -0
- package/dist/handlers/fs.js.map +1 -0
- package/dist/handlers/health.d.ts +2 -0
- package/dist/handlers/health.d.ts.map +1 -0
- package/dist/handlers/health.js +5 -0
- package/dist/handlers/health.js.map +1 -0
- package/dist/handlers/integration.d.ts +2 -0
- package/dist/handlers/integration.d.ts.map +1 -0
- package/dist/handlers/integration.js +61 -0
- package/dist/handlers/integration.js.map +1 -0
- package/dist/handlers/location.d.ts +2 -0
- package/dist/handlers/location.d.ts.map +1 -0
- package/dist/handlers/location.js +13 -0
- package/dist/handlers/location.js.map +1 -0
- package/dist/handlers/message.d.ts +2 -0
- package/dist/handlers/message.d.ts.map +1 -0
- package/dist/handlers/message.js +57 -0
- package/dist/handlers/message.js.map +1 -0
- package/dist/handlers/model.d.ts +2 -0
- package/dist/handlers/model.d.ts.map +1 -0
- package/dist/handlers/model.js +12 -0
- package/dist/handlers/model.js.map +1 -0
- package/dist/handlers/permission.d.ts +2 -0
- package/dist/handlers/permission.d.ts.map +1 -0
- package/dist/handlers/permission.js +70 -0
- package/dist/handlers/permission.js.map +1 -0
- package/dist/handlers/project-copy.d.ts +2 -0
- package/dist/handlers/project-copy.d.ts.map +1 -0
- package/dist/handlers/project-copy.js +42 -0
- package/dist/handlers/project-copy.js.map +1 -0
- package/dist/handlers/provider.d.ts +2 -0
- package/dist/handlers/provider.d.ts.map +1 -0
- package/dist/handlers/provider.js +24 -0
- package/dist/handlers/provider.js.map +1 -0
- package/dist/handlers/pty.d.ts +2 -0
- package/dist/handlers/pty.d.ts.map +1 -0
- package/dist/handlers/pty.js +142 -0
- package/dist/handlers/pty.js.map +1 -0
- package/dist/handlers/question.d.ts +2 -0
- package/dist/handlers/question.d.ts.map +1 -0
- package/dist/handlers/question.js +39 -0
- package/dist/handlers/question.js.map +1 -0
- package/dist/handlers/reference.d.ts +2 -0
- package/dist/handlers/reference.d.ts.map +1 -0
- package/dist/handlers/reference.js +6 -0
- package/dist/handlers/reference.js.map +1 -0
- package/dist/handlers/session.d.ts +2 -0
- package/dist/handlers/session.d.ts.map +1 -0
- package/dist/handlers/session.js +206 -0
- package/dist/handlers/session.js.map +1 -0
- package/dist/handlers/skill.d.ts +2 -0
- package/dist/handlers/skill.d.ts.map +1 -0
- package/dist/handlers/skill.js +6 -0
- package/dist/handlers/skill.js.map +1 -0
- package/dist/handlers.d.ts +3 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +21 -0
- package/dist/handlers.js.map +1 -0
- package/dist/location.d.ts +21 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +48 -0
- package/dist/location.js.map +1 -0
- package/dist/middleware/authorization.d.ts +6 -0
- package/dist/middleware/authorization.d.ts.map +1 -0
- package/dist/middleware/authorization.js +51 -0
- package/dist/middleware/authorization.js.map +1 -0
- package/dist/middleware/schema-error.d.ts +4 -0
- package/dist/middleware/schema-error.d.ts.map +1 -0
- package/dist/middleware/schema-error.js +16 -0
- package/dist/middleware/schema-error.js.map +1 -0
- package/dist/middleware/session-location.d.ts +16 -0
- package/dist/middleware/session-location.d.ts.map +1 -0
- package/dist/middleware/session-location.js +44 -0
- package/dist/middleware/session-location.js.map +1 -0
- package/dist/pty-environment.d.ts +14 -0
- package/dist/pty-environment.d.ts.map +1 -0
- package/dist/pty-environment.js +10 -0
- package/dist/pty-environment.js.map +1 -0
- package/dist/routes.d.ts +9 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +51 -0
- package/dist/routes.js.map +1 -0
- package/package.json +14 -10
- package/src/api.ts +0 -8
- package/src/auth.ts +0 -63
- package/src/cors.ts +0 -34
- package/src/handlers/agent.ts +0 -13
- package/src/handlers/command.ts +0 -8
- package/src/handlers/credential.ts +0 -22
- package/src/handlers/event.ts +0 -52
- package/src/handlers/fs.ts +0 -39
- package/src/handlers/health.ts +0 -7
- package/src/handlers/integration.ts +0 -104
- package/src/handlers/location.ts +0 -18
- package/src/handlers/message.ts +0 -81
- package/src/handlers/model.ts +0 -17
- package/src/handlers/permission.ts +0 -98
- package/src/handlers/project-copy.ts +0 -68
- package/src/handlers/provider.ts +0 -32
- package/src/handlers/pty.ts +0 -223
- package/src/handlers/question.ts +0 -62
- package/src/handlers/reference.ts +0 -8
- package/src/handlers/session.ts +0 -385
- package/src/handlers/skill.ts +0 -8
- package/src/handlers.ts +0 -40
- package/src/location.ts +0 -60
- package/src/middleware/authorization.ts +0 -58
- package/src/middleware/schema-error.ts +0 -20
- package/src/middleware/session-location.ts +0 -67
- package/src/pty-environment.ts +0 -19
- package/src/routes.ts +0 -68
- package/sst-env.d.ts +0 -10
- package/tsconfig.json +0 -8
package/src/handlers.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Layer } from "effect"
|
|
2
|
-
import { MessageHandler } from "./handlers/message"
|
|
3
|
-
import { ModelHandler } from "./handlers/model"
|
|
4
|
-
import { ProviderHandler } from "./handlers/provider"
|
|
5
|
-
import { SessionHandler } from "./handlers/session"
|
|
6
|
-
import { PermissionHandler } from "./handlers/permission"
|
|
7
|
-
import { FileSystemHandler } from "./handlers/fs"
|
|
8
|
-
import { CommandHandler } from "./handlers/command"
|
|
9
|
-
import { SkillHandler } from "./handlers/skill"
|
|
10
|
-
import { EventHandler } from "./handlers/event"
|
|
11
|
-
import { AgentHandler } from "./handlers/agent"
|
|
12
|
-
import { HealthHandler } from "./handlers/health"
|
|
13
|
-
import { PtyHandler } from "./handlers/pty"
|
|
14
|
-
import { QuestionHandler } from "./handlers/question"
|
|
15
|
-
import { ReferenceHandler } from "./handlers/reference"
|
|
16
|
-
import { LocationHandler } from "./handlers/location"
|
|
17
|
-
import { IntegrationHandler } from "./handlers/integration"
|
|
18
|
-
import { CredentialHandler } from "./handlers/credential"
|
|
19
|
-
import { ProjectCopyHandler } from "./handlers/project-copy"
|
|
20
|
-
|
|
21
|
-
export const handlers = Layer.mergeAll(
|
|
22
|
-
HealthHandler,
|
|
23
|
-
LocationHandler,
|
|
24
|
-
AgentHandler,
|
|
25
|
-
SessionHandler,
|
|
26
|
-
MessageHandler,
|
|
27
|
-
ModelHandler,
|
|
28
|
-
ProviderHandler,
|
|
29
|
-
IntegrationHandler,
|
|
30
|
-
CredentialHandler,
|
|
31
|
-
PermissionHandler,
|
|
32
|
-
FileSystemHandler,
|
|
33
|
-
CommandHandler,
|
|
34
|
-
SkillHandler,
|
|
35
|
-
EventHandler,
|
|
36
|
-
PtyHandler,
|
|
37
|
-
QuestionHandler,
|
|
38
|
-
ReferenceHandler,
|
|
39
|
-
ProjectCopyHandler,
|
|
40
|
-
)
|
package/src/location.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Location } from "@zyraxon-ai/core/location"
|
|
2
|
-
import { LocationServiceMap } from "@zyraxon-ai/core/location-services"
|
|
3
|
-
import { AbsolutePath } from "@zyraxon-ai/core/schema"
|
|
4
|
-
import { WorkspaceV2 } from "@zyraxon-ai/core/workspace"
|
|
5
|
-
import { Effect, Layer } from "effect"
|
|
6
|
-
import { HttpServerRequest } from "effect/unstable/http"
|
|
7
|
-
import { HttpApiMiddleware } from "effect/unstable/httpapi"
|
|
8
|
-
|
|
9
|
-
export type LocationServices = Layer.Success<ReturnType<(typeof LocationServiceMap.Service)["get"]>>
|
|
10
|
-
|
|
11
|
-
export class LocationMiddleware extends HttpApiMiddleware.Service<LocationMiddleware, { provides: LocationServices }>()(
|
|
12
|
-
"@zyraxon/HttpApiLocation",
|
|
13
|
-
) {}
|
|
14
|
-
|
|
15
|
-
export function response<A, E, R>(data: Effect.Effect<A, E, R>) {
|
|
16
|
-
return Effect.gen(function* () {
|
|
17
|
-
const location = yield* Location.Service
|
|
18
|
-
return {
|
|
19
|
-
location: new Location.Info({
|
|
20
|
-
directory: location.directory,
|
|
21
|
-
workspaceID: location.workspaceID,
|
|
22
|
-
project: location.project,
|
|
23
|
-
}),
|
|
24
|
-
data: yield* data,
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function ref(request: HttpServerRequest.HttpServerRequest): Location.Ref {
|
|
30
|
-
const query = new URL(request.url, "http://localhost").searchParams
|
|
31
|
-
const workspaceID = query.get("location[workspace]") || request.headers["x-zyraxon-workspace"]
|
|
32
|
-
const directory =
|
|
33
|
-
query.get("location[directory]") ||
|
|
34
|
-
(request.headers["x-zyraxon-directory"] ? decode(request.headers["x-zyraxon-directory"]) : process.cwd())
|
|
35
|
-
return Location.Ref.make({
|
|
36
|
-
directory: AbsolutePath.make(directory),
|
|
37
|
-
workspaceID: workspaceID ? WorkspaceV2.ID.make(workspaceID) : undefined,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function decode(input: string) {
|
|
42
|
-
try {
|
|
43
|
-
return decodeURIComponent(input)
|
|
44
|
-
} catch {
|
|
45
|
-
return input
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const layer = Layer.effect(
|
|
50
|
-
LocationMiddleware,
|
|
51
|
-
Effect.gen(function* () {
|
|
52
|
-
const locations = yield* LocationServiceMap.Service
|
|
53
|
-
return LocationMiddleware.of((effect) =>
|
|
54
|
-
Effect.gen(function* () {
|
|
55
|
-
const request = yield* HttpServerRequest.HttpServerRequest
|
|
56
|
-
return yield* effect.pipe(Effect.provide(locations.get(ref(request))))
|
|
57
|
-
}),
|
|
58
|
-
)
|
|
59
|
-
}),
|
|
60
|
-
)
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ServerAuth } from "../auth"
|
|
2
|
-
import { UnauthorizedError } from "@zyraxon-ai/protocol/errors"
|
|
3
|
-
import { Authorization } from "@zyraxon-ai/protocol/middleware/authorization"
|
|
4
|
-
export { Authorization } from "@zyraxon-ai/protocol/middleware/authorization"
|
|
5
|
-
import { hasPtyConnectTicketURL } from "@zyraxon-ai/protocol/groups/pty"
|
|
6
|
-
import { Effect, Encoding, Layer, Redacted } from "effect"
|
|
7
|
-
import { HttpEffect, HttpServerRequest, HttpServerResponse } from "effect/unstable/http"
|
|
8
|
-
|
|
9
|
-
const AUTH_TOKEN_QUERY = "auth_token"
|
|
10
|
-
const WWW_AUTHENTICATE = 'Basic realm="Secure Area"'
|
|
11
|
-
|
|
12
|
-
function emptyCredential() {
|
|
13
|
-
return { username: "", password: Redacted.make("") }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function decodeCredential(input: string) {
|
|
17
|
-
return Effect.fromResult(Encoding.decodeBase64String(input)).pipe(
|
|
18
|
-
Effect.match({
|
|
19
|
-
onFailure: emptyCredential,
|
|
20
|
-
onSuccess: (header) => {
|
|
21
|
-
const separator = header.indexOf(":")
|
|
22
|
-
if (separator === -1) return emptyCredential()
|
|
23
|
-
return { username: header.slice(0, separator), password: Redacted.make(header.slice(separator + 1)) }
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function credentialFromRequest(request: HttpServerRequest.HttpServerRequest) {
|
|
30
|
-
const url = new URL(request.url, "http://localhost")
|
|
31
|
-
const token = url.searchParams.get(AUTH_TOKEN_QUERY)
|
|
32
|
-
if (token) return decodeCredential(token)
|
|
33
|
-
const match = /^Basic\s+(.+)$/i.exec(request.headers.authorization ?? "")
|
|
34
|
-
if (match) return decodeCredential(match[1])
|
|
35
|
-
return Effect.succeed(emptyCredential())
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const authorizationLayer = Layer.effect(
|
|
39
|
-
Authorization,
|
|
40
|
-
Effect.gen(function* () {
|
|
41
|
-
const config = yield* ServerAuth.Config
|
|
42
|
-
if (!ServerAuth.required(config)) return Authorization.of((effect) => effect)
|
|
43
|
-
return Authorization.of((effect) =>
|
|
44
|
-
Effect.gen(function* () {
|
|
45
|
-
const request = yield* HttpServerRequest.HttpServerRequest
|
|
46
|
-
// Browsers cannot set headers on WebSocket upgrades, so a ticketed PTY connect skips
|
|
47
|
-
// credential checks here; the connect handler consumes and validates the ticket.
|
|
48
|
-
if (hasPtyConnectTicketURL(new URL(request.url, "http://localhost"))) return yield* effect
|
|
49
|
-
const credential = yield* credentialFromRequest(request)
|
|
50
|
-
if (ServerAuth.authorized(credential, config)) return yield* effect
|
|
51
|
-
yield* HttpEffect.appendPreResponseHandler((_request, response) =>
|
|
52
|
-
Effect.succeed(HttpServerResponse.setHeader(response, "www-authenticate", WWW_AUTHENTICATE)),
|
|
53
|
-
)
|
|
54
|
-
return yield* new UnauthorizedError({ message: "Authentication required" })
|
|
55
|
-
}),
|
|
56
|
-
)
|
|
57
|
-
}),
|
|
58
|
-
)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect"
|
|
2
|
-
import { HttpApiMiddleware } from "effect/unstable/httpapi"
|
|
3
|
-
import { InvalidRequestError } from "@zyraxon-ai/protocol/errors"
|
|
4
|
-
import { SchemaErrorMiddleware } from "@zyraxon-ai/protocol/middleware/schema-error"
|
|
5
|
-
export { SchemaErrorMiddleware } from "@zyraxon-ai/protocol/middleware/schema-error"
|
|
6
|
-
|
|
7
|
-
const REASON_LIMIT = 1024
|
|
8
|
-
|
|
9
|
-
function truncateReason(reason: string) {
|
|
10
|
-
if (reason.length <= REASON_LIMIT) return reason
|
|
11
|
-
return reason.slice(0, REASON_LIMIT) + `... (${reason.length - REASON_LIMIT} more chars)`
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const schemaErrorLayer = HttpApiMiddleware.layerSchemaErrorTransform(SchemaErrorMiddleware, (error) => {
|
|
15
|
-
const reason = truncateReason(error.cause.message)
|
|
16
|
-
return Effect.logWarning("schema rejection").pipe(
|
|
17
|
-
Effect.annotateLogs({ kind: error.kind, reason }),
|
|
18
|
-
Effect.andThen(Effect.fail(new InvalidRequestError({ message: reason, kind: error.kind }))),
|
|
19
|
-
)
|
|
20
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Database } from "@zyraxon-ai/core/database/database"
|
|
2
|
-
import { LocationServiceMap } from "@zyraxon-ai/core/location-services"
|
|
3
|
-
import { Location } from "@zyraxon-ai/core/location"
|
|
4
|
-
import { AbsolutePath } from "@zyraxon-ai/core/schema"
|
|
5
|
-
import { SessionV2 } from "@zyraxon-ai/core/session"
|
|
6
|
-
import { SessionTable } from "@zyraxon-ai/core/session/sql"
|
|
7
|
-
import { WorkspaceV2 } from "@zyraxon-ai/core/workspace"
|
|
8
|
-
import { eq } from "drizzle-orm"
|
|
9
|
-
import { Effect, Layer, Schema } from "effect"
|
|
10
|
-
import { HttpRouter } from "effect/unstable/http"
|
|
11
|
-
import { HttpApiMiddleware } from "effect/unstable/httpapi"
|
|
12
|
-
import { InvalidRequestError, SessionNotFoundError } from "@zyraxon-ai/protocol/errors"
|
|
13
|
-
import type { LocationServices } from "../location"
|
|
14
|
-
|
|
15
|
-
export class SessionLocationMiddleware extends HttpApiMiddleware.Service<
|
|
16
|
-
SessionLocationMiddleware,
|
|
17
|
-
{ provides: LocationServices }
|
|
18
|
-
>()("@zyraxon/HttpApiSessionLocation", {
|
|
19
|
-
error: [InvalidRequestError, SessionNotFoundError],
|
|
20
|
-
}) {}
|
|
21
|
-
|
|
22
|
-
const decodeSessionID = Schema.decodeUnknownEffect(SessionV2.ID)
|
|
23
|
-
|
|
24
|
-
export const sessionLocationLayer = Layer.effect(
|
|
25
|
-
SessionLocationMiddleware,
|
|
26
|
-
Effect.gen(function* () {
|
|
27
|
-
const { db } = yield* Database.Service
|
|
28
|
-
const locations = yield* LocationServiceMap.Service
|
|
29
|
-
|
|
30
|
-
return SessionLocationMiddleware.of((effect) =>
|
|
31
|
-
Effect.gen(function* () {
|
|
32
|
-
const route = yield* HttpRouter.RouteContext
|
|
33
|
-
const sessionID = yield* decodeSessionID(route.params.sessionID).pipe(
|
|
34
|
-
Effect.mapError(
|
|
35
|
-
() =>
|
|
36
|
-
new InvalidRequestError({
|
|
37
|
-
message: "Invalid session ID",
|
|
38
|
-
field: "sessionID",
|
|
39
|
-
}),
|
|
40
|
-
),
|
|
41
|
-
)
|
|
42
|
-
const row = yield* db
|
|
43
|
-
.select({ directory: SessionTable.directory, workspaceID: SessionTable.workspace_id })
|
|
44
|
-
.from(SessionTable)
|
|
45
|
-
.where(eq(SessionTable.id, sessionID))
|
|
46
|
-
.get()
|
|
47
|
-
.pipe(Effect.orDie)
|
|
48
|
-
if (!row)
|
|
49
|
-
return yield* new SessionNotFoundError({
|
|
50
|
-
sessionID,
|
|
51
|
-
message: `Session not found: ${sessionID}`,
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return yield* effect.pipe(
|
|
55
|
-
Effect.provide(
|
|
56
|
-
locations.get(
|
|
57
|
-
Location.Ref.make({
|
|
58
|
-
directory: AbsolutePath.make(row.directory),
|
|
59
|
-
workspaceID: row.workspaceID ? WorkspaceV2.ID.make(row.workspaceID) : undefined,
|
|
60
|
-
}),
|
|
61
|
-
),
|
|
62
|
-
),
|
|
63
|
-
)
|
|
64
|
-
}),
|
|
65
|
-
)
|
|
66
|
-
}),
|
|
67
|
-
)
|
package/src/pty-environment.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export * as PtyEnvironment from "./pty-environment"
|
|
2
|
-
|
|
3
|
-
import { Context, Effect, Layer } from "effect"
|
|
4
|
-
import { makeGlobalNode } from "@zyraxon-ai/core/effect/app-node"
|
|
5
|
-
|
|
6
|
-
export interface Interface {
|
|
7
|
-
readonly get: (input: { directory: string; cwd: string }) => Effect.Effect<Record<string, string>>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class Service extends Context.Service<Service, Interface>()("@zyraxon/ServerPtyEnvironment") {}
|
|
11
|
-
|
|
12
|
-
export const layer = Layer.succeed(
|
|
13
|
-
Service,
|
|
14
|
-
Service.of({
|
|
15
|
-
get: () => Effect.succeed({}),
|
|
16
|
-
}),
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export const node = makeGlobalNode({ service: Service, layer, deps: [] })
|
package/src/routes.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Database } from "@zyraxon-ai/core/database/database"
|
|
2
|
-
import { LayerNode } from "@zyraxon-ai/core/effect/layer-node"
|
|
3
|
-
import { httpClient } from "@zyraxon-ai/core/effect/app-node-platform"
|
|
4
|
-
import { AppNodeBuilder } from "@zyraxon-ai/core/effect/app-node-builder"
|
|
5
|
-
import { EventV2 } from "@zyraxon-ai/core/event"
|
|
6
|
-
import { Credential } from "@zyraxon-ai/core/credential"
|
|
7
|
-
import { PermissionSaved } from "@zyraxon-ai/core/permission/saved"
|
|
8
|
-
import { PtyTicket } from "@zyraxon-ai/core/pty/ticket"
|
|
9
|
-
import { SessionV2 } from "@zyraxon-ai/core/session"
|
|
10
|
-
import { SessionExecution } from "@zyraxon-ai/core/session/execution"
|
|
11
|
-
import { LocationServiceMap } from "@zyraxon-ai/core/location-service-map"
|
|
12
|
-
import { SessionExecutionLocal } from "@zyraxon-ai/core/session/execution/local"
|
|
13
|
-
import { ToolOutputStore } from "@zyraxon-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: "zyraxon", password: Option.some(password) })
|
|
43
|
-
: ServerAuth.Config.layer,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function createEmbeddedRoutes() {
|
|
48
|
-
return makeRoutes(ServerAuth.Config.configLayer({ username: "zyraxon", 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
DELETED