@zyro-sec/server 1.0.2 → 1.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 (130) hide show
  1. package/package.json +8 -8
  2. package/script/build.ts +28 -28
  3. package/script/pack.ts +5 -5
  4. package/script/workerd-probe.ts +59 -59
  5. package/src/api.ts +12 -12
  6. package/src/auth.ts +70 -70
  7. package/src/content-headers.ts +32 -32
  8. package/src/cors.ts +34 -34
  9. package/src/event-feed.ts +93 -93
  10. package/src/fetch.ts +67 -67
  11. package/src/handlers/agent.ts +23 -23
  12. package/src/handlers/artifact.ts +242 -242
  13. package/src/handlers/automation.ts +63 -63
  14. package/src/handlers/blob.ts +55 -55
  15. package/src/handlers/command.ts +8 -8
  16. package/src/handlers/config.ts +26 -26
  17. package/src/handlers/credential.ts +87 -87
  18. package/src/handlers/debug.ts +57 -57
  19. package/src/handlers/event.ts +38 -38
  20. package/src/handlers/form.ts +15 -15
  21. package/src/handlers/fs.ts +180 -180
  22. package/src/handlers/generate.ts +117 -117
  23. package/src/handlers/integration.ts +310 -310
  24. package/src/handlers/job.ts +29 -29
  25. package/src/handlers/location.ts +33 -33
  26. package/src/handlers/machine.ts +336 -336
  27. package/src/handlers/mcp.ts +160 -160
  28. package/src/handlers/media.ts +44 -44
  29. package/src/handlers/message.ts +82 -82
  30. package/src/handlers/migration.ts +13 -13
  31. package/src/handlers/model.ts +25 -25
  32. package/src/handlers/permission.ts +131 -131
  33. package/src/handlers/persistent-pty.ts +285 -285
  34. package/src/handlers/plugin.ts +97 -97
  35. package/src/handlers/project.ts +23 -23
  36. package/src/handlers/provider.ts +32 -32
  37. package/src/handlers/pty-socket.ts +47 -47
  38. package/src/handlers/pty.ts +181 -181
  39. package/src/handlers/push.ts +67 -67
  40. package/src/handlers/reference.ts +8 -8
  41. package/src/handlers/rpc.ts +31 -31
  42. package/src/handlers/server.ts +58 -58
  43. package/src/handlers/session-error.ts +47 -47
  44. package/src/handlers/session.ts +722 -722
  45. package/src/handlers/shell.ts +72 -72
  46. package/src/handlers/skill.ts +34 -34
  47. package/src/handlers/usage.ts +23 -23
  48. package/src/handlers/vcs.ts +104 -104
  49. package/src/handlers/voice.ts +50 -50
  50. package/src/handlers/websearch.ts +50 -50
  51. package/src/handlers/worktree.ts +60 -60
  52. package/src/handlers.ts +69 -69
  53. package/src/location.ts +86 -86
  54. package/src/media-uri.ts +13 -13
  55. package/src/middleware/authorization.ts +111 -111
  56. package/src/middleware/defect-response.ts +39 -39
  57. package/src/middleware/form-location.ts +44 -44
  58. package/src/middleware/schema-error.ts +49 -49
  59. package/src/middleware/session-location.ts +30 -30
  60. package/src/options.ts +61 -61
  61. package/src/pairing.ts +36 -36
  62. package/src/process.ts +274 -274
  63. package/src/range.ts +16 -16
  64. package/src/request-site.ts +36 -36
  65. package/src/request-tracing.ts +9 -9
  66. package/src/routes.ts +261 -261
  67. package/src/server-info.ts +41 -41
  68. package/src/service-status.ts +30 -30
  69. package/src/workerd.ts +184 -184
  70. package/test/fixture/mcp-starts.cjs +20 -20
  71. package/test/fixture/routes.ts +37 -37
  72. package/test/fixture/server.ts +20 -20
  73. package/test/fixture/worktree-delegate/index.ts +13 -13
  74. package/test/fixture/worktree-plugin/index.ts +47 -47
  75. package/tsconfig.build.json +15 -15
  76. package/tsconfig.json +11 -11
  77. package/test/artifact.test.ts +0 -224
  78. package/test/auth.test.ts +0 -24
  79. package/test/automation.test.ts +0 -315
  80. package/test/client-mcp.test.ts +0 -369
  81. package/test/codemode-api.test.ts +0 -88
  82. package/test/config.test.ts +0 -104
  83. package/test/cors.test.ts +0 -24
  84. package/test/defect-response.test.ts +0 -83
  85. package/test/event-feed.test.ts +0 -201
  86. package/test/fetch-option.test.ts +0 -104
  87. package/test/fetch.test.ts +0 -698
  88. package/test/flag-channel.test.ts +0 -126
  89. package/test/fs.test.ts +0 -439
  90. package/test/generate.test.ts +0 -132
  91. package/test/handler-policy.test.ts +0 -43
  92. package/test/heap-dump.test.ts +0 -137
  93. package/test/integration-policy.test.ts +0 -93
  94. package/test/job.test.ts +0 -186
  95. package/test/machine-iroh.test.ts +0 -259
  96. package/test/machine-link.test.ts +0 -1234
  97. package/test/machine-routes.test.ts +0 -198
  98. package/test/media.test.ts +0 -343
  99. package/test/message.test.ts +0 -105
  100. package/test/model.test.ts +0 -62
  101. package/test/options.test.ts +0 -42
  102. package/test/permission-saved.test.ts +0 -73
  103. package/test/persistent-pty.test.ts +0 -1007
  104. package/test/process.test.ts +0 -261
  105. package/test/provider.test.ts +0 -88
  106. package/test/pty-socket.property.test.ts +0 -240
  107. package/test/pty-socket.test.ts +0 -89
  108. package/test/pty-transport.test.ts +0 -200
  109. package/test/push-routes.test.ts +0 -157
  110. package/test/request-site.test.ts +0 -71
  111. package/test/request-tracing.test.ts +0 -87
  112. package/test/rpc-handler-errors.test.ts +0 -76
  113. package/test/schema-error.test.ts +0 -68
  114. package/test/service-status.test.ts +0 -34
  115. package/test/session-admit-location.test.ts +0 -92
  116. package/test/session-create.test.ts +0 -65
  117. package/test/session-diff.test.ts +0 -100
  118. package/test/session-form.test.ts +0 -50
  119. package/test/session-import.test.ts +0 -152
  120. package/test/session-instances.test.ts +0 -335
  121. package/test/session-unarchive.test.ts +0 -73
  122. package/test/session-update.test.ts +0 -66
  123. package/test/skill.test.ts +0 -57
  124. package/test/sse-failure.test.ts +0 -71
  125. package/test/usage.test.ts +0 -88
  126. package/test/vcs.test.ts +0 -356
  127. package/test/video-generate.test.ts +0 -131
  128. package/test/voice.test.ts +0 -170
  129. package/test/workerd.test.ts +0 -227
  130. package/test/worktree.test.ts +0 -333
@@ -1,72 +1,72 @@
1
- import { Shell } from "@zyro-sec/core/shell"
2
- import { Location } from "@zyro-sec/core/location"
3
- import { Effect } from "effect"
4
- import { HttpApiBuilder, HttpApiSchema } from "effect/http-api"
5
- import { ShellNotFoundError } from "@zyro-sec/protocol/errors"
6
- import { Api } from "../api"
7
- import { response } from "../location"
8
-
9
- export const ShellHandler = HttpApiBuilder.group(Api, "server.shell", (handlers) =>
10
- Effect.gen(function* () {
11
- return handlers
12
- .handle(
13
- "shell.list",
14
- Effect.fn(function* () {
15
- const shell = yield* Shell.Service
16
- return yield* response(shell.list())
17
- }),
18
- )
19
- .handle(
20
- "shell.create",
21
- Effect.fn(function* (ctx) {
22
- const shell = yield* Shell.Service
23
- const location = yield* Location.Service
24
- return yield* response(
25
- shell.create({ ...ctx.payload, cwd: ctx.payload.cwd || location.directory }).pipe(Effect.orDie),
26
- )
27
- }),
28
- )
29
- .handle(
30
- "shell.get",
31
- Effect.fn(function* (ctx) {
32
- const shell = yield* Shell.Service
33
- return yield* response(
34
- shell
35
- .get(ctx.params.id)
36
- .pipe(
37
- Effect.catchTag(
38
- "Shell.NotFoundError",
39
- () =>
40
- new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }),
41
- ),
42
- ),
43
- )
44
- }),
45
- )
46
- .handle(
47
- "shell.output",
48
- Effect.fn(function* (ctx) {
49
- const shell = yield* Shell.Service
50
- return yield* response(
51
- shell
52
- .output(ctx.params.id, { cursor: ctx.query.cursor, limit: ctx.query.limit })
53
- .pipe(
54
- Effect.catchTag(
55
- "Shell.NotFoundError",
56
- () =>
57
- new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }),
58
- ),
59
- ),
60
- )
61
- }),
62
- )
63
- .handle(
64
- "shell.remove",
65
- Effect.fn(function* (ctx) {
66
- const shell = yield* Shell.Service
67
- yield* shell.remove(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => Effect.void))
68
- return HttpApiSchema.NoContent.make()
69
- }),
70
- )
71
- }),
72
- )
1
+ import { Shell } from "@zyro-sec/core/shell"
2
+ import { Location } from "@zyro-sec/core/location"
3
+ import { Effect } from "effect"
4
+ import { HttpApiBuilder, HttpApiSchema } from "effect/http-api"
5
+ import { ShellNotFoundError } from "@zyro-sec/protocol/errors"
6
+ import { Api } from "../api"
7
+ import { response } from "../location"
8
+
9
+ export const ShellHandler = HttpApiBuilder.group(Api, "server.shell", (handlers) =>
10
+ Effect.gen(function* () {
11
+ return handlers
12
+ .handle(
13
+ "shell.list",
14
+ Effect.fn(function* () {
15
+ const shell = yield* Shell.Service
16
+ return yield* response(shell.list())
17
+ }),
18
+ )
19
+ .handle(
20
+ "shell.create",
21
+ Effect.fn(function* (ctx) {
22
+ const shell = yield* Shell.Service
23
+ const location = yield* Location.Service
24
+ return yield* response(
25
+ shell.create({ ...ctx.payload, cwd: ctx.payload.cwd || location.directory }).pipe(Effect.orDie),
26
+ )
27
+ }),
28
+ )
29
+ .handle(
30
+ "shell.get",
31
+ Effect.fn(function* (ctx) {
32
+ const shell = yield* Shell.Service
33
+ return yield* response(
34
+ shell
35
+ .get(ctx.params.id)
36
+ .pipe(
37
+ Effect.catchTag(
38
+ "Shell.NotFoundError",
39
+ () =>
40
+ new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }),
41
+ ),
42
+ ),
43
+ )
44
+ }),
45
+ )
46
+ .handle(
47
+ "shell.output",
48
+ Effect.fn(function* (ctx) {
49
+ const shell = yield* Shell.Service
50
+ return yield* response(
51
+ shell
52
+ .output(ctx.params.id, { cursor: ctx.query.cursor, limit: ctx.query.limit })
53
+ .pipe(
54
+ Effect.catchTag(
55
+ "Shell.NotFoundError",
56
+ () =>
57
+ new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }),
58
+ ),
59
+ ),
60
+ )
61
+ }),
62
+ )
63
+ .handle(
64
+ "shell.remove",
65
+ Effect.fn(function* (ctx) {
66
+ const shell = yield* Shell.Service
67
+ yield* shell.remove(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => Effect.void))
68
+ return HttpApiSchema.NoContent.make()
69
+ }),
70
+ )
71
+ }),
72
+ )
@@ -1,34 +1,34 @@
1
- import { Skill } from "@zyro-sec/core/skill"
2
- import { FileNotFoundError, SkillLoadError, SkillNotFoundError } from "@zyro-sec/protocol/errors"
3
- import { Effect } from "effect"
4
- import { HttpApiBuilder } from "effect/http-api"
5
- import { Api } from "../api"
6
- import { response } from "../location"
7
-
8
- export const SkillHandler = HttpApiBuilder.group(Api, "server.skill", (handlers) =>
9
- handlers
10
- .handle("skill.list", () => response(Skill.Service.use((skill) => skill.list())))
11
- .handle("skill.file", (ctx) =>
12
- Effect.gen(function* () {
13
- const skills = yield* Skill.Service
14
- // The path after /api/experimental/skill/<id>/file/.
15
- const raw = new URL(ctx.request.url, "http://localhost").pathname.split("/").slice(6).join("/")
16
- const file = yield* Effect.try({
17
- try: () => decodeURIComponent(raw),
18
- catch: () => new FileNotFoundError({ path: raw, message: `File not found: ${raw}` }),
19
- })
20
- return yield* skills.read(ctx.params.skillID, file).pipe(
21
- Effect.catchTags({
22
- "Skill.NotFoundError": (error) =>
23
- Effect.fail(
24
- new SkillNotFoundError({ skill: ctx.params.skillID, message: `Skill not found: ${error.skill}` }),
25
- ),
26
- "Skill.FileNotFoundError": (error) =>
27
- Effect.fail(new FileNotFoundError({ path: error.file, message: `File not found: ${error.file}` })),
28
- "Skill.LoadError": (error) =>
29
- Effect.fail(new SkillLoadError({ skill: ctx.params.skillID, message: error.message })),
30
- }),
31
- )
32
- }),
33
- ),
34
- )
1
+ import { Skill } from "@zyro-sec/core/skill"
2
+ import { FileNotFoundError, SkillLoadError, SkillNotFoundError } from "@zyro-sec/protocol/errors"
3
+ import { Effect } from "effect"
4
+ import { HttpApiBuilder } from "effect/http-api"
5
+ import { Api } from "../api"
6
+ import { response } from "../location"
7
+
8
+ export const SkillHandler = HttpApiBuilder.group(Api, "server.skill", (handlers) =>
9
+ handlers
10
+ .handle("skill.list", () => response(Skill.Service.use((skill) => skill.list())))
11
+ .handle("skill.file", (ctx) =>
12
+ Effect.gen(function* () {
13
+ const skills = yield* Skill.Service
14
+ // The path after /api/experimental/skill/<id>/file/.
15
+ const raw = new URL(ctx.request.url, "http://localhost").pathname.split("/").slice(6).join("/")
16
+ const file = yield* Effect.try({
17
+ try: () => decodeURIComponent(raw),
18
+ catch: () => new FileNotFoundError({ path: raw, message: `File not found: ${raw}` }),
19
+ })
20
+ return yield* skills.read(ctx.params.skillID, file).pipe(
21
+ Effect.catchTags({
22
+ "Skill.NotFoundError": (error) =>
23
+ Effect.fail(
24
+ new SkillNotFoundError({ skill: ctx.params.skillID, message: `Skill not found: ${error.skill}` }),
25
+ ),
26
+ "Skill.FileNotFoundError": (error) =>
27
+ Effect.fail(new FileNotFoundError({ path: error.file, message: `File not found: ${error.file}` })),
28
+ "Skill.LoadError": (error) =>
29
+ Effect.fail(new SkillLoadError({ skill: ctx.params.skillID, message: error.message })),
30
+ }),
31
+ )
32
+ }),
33
+ ),
34
+ )
@@ -1,23 +1,23 @@
1
- import { UsageLimits } from "@zyro-sec/core/usage-limits"
2
- import { ServiceUnavailableError } from "@zyro-sec/protocol/errors"
3
- import { Effect } from "effect"
4
- import { HttpApiBuilder } from "effect/http-api"
5
- import { Api } from "../api"
6
- import { response } from "../location"
7
-
8
- export const UsageHandler = HttpApiBuilder.group(Api, "server.usage", (handlers) =>
9
- Effect.gen(function* () {
10
- return handlers.handle(
11
- "usage.limits",
12
- Effect.fn("server.usage.limits")(function* () {
13
- const limits = yield* UsageLimits.Service
14
- return yield* response(
15
- limits.get().pipe(
16
- Effect.map((info) => info ?? null),
17
- Effect.mapError((error) => new ServiceUnavailableError({ message: error.message, service: "opencode" })),
18
- ),
19
- )
20
- }),
21
- )
22
- }),
23
- )
1
+ import { UsageLimits } from "@zyro-sec/core/usage-limits"
2
+ import { ServiceUnavailableError } from "@zyro-sec/protocol/errors"
3
+ import { Effect } from "effect"
4
+ import { HttpApiBuilder } from "effect/http-api"
5
+ import { Api } from "../api"
6
+ import { response } from "../location"
7
+
8
+ export const UsageHandler = HttpApiBuilder.group(Api, "server.usage", (handlers) =>
9
+ Effect.gen(function* () {
10
+ return handlers.handle(
11
+ "usage.limits",
12
+ Effect.fn("server.usage.limits")(function* () {
13
+ const limits = yield* UsageLimits.Service
14
+ return yield* response(
15
+ limits.get().pipe(
16
+ Effect.map((info) => info ?? null),
17
+ Effect.mapError((error) => new ServiceUnavailableError({ message: error.message, service: "opencode" })),
18
+ ),
19
+ )
20
+ }),
21
+ )
22
+ }),
23
+ )
@@ -1,104 +1,104 @@
1
- import { Vcs } from "@zyro-sec/core/vcs"
2
- import { Project } from "@zyro-sec/core/project"
3
- import { Worktree } from "@zyro-sec/core/worktree"
4
- import { Bus } from "@zyro-sec/core/bus"
5
- import { Location } from "@zyro-sec/core/location"
6
- import { LocationServiceMap } from "@zyro-sec/core/location-services"
7
- import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "@zyro-sec/protocol/errors"
8
- import { VcsInitNotSupportedError } from "@zyro-sec/protocol/groups/vcs"
9
- import { Effect } from "effect"
10
- import { HttpApiBuilder, HttpApiSchema } from "effect/http-api"
11
- import { Api } from "../api"
12
- import { response } from "../location"
13
-
14
- export const VcsHandler = HttpApiBuilder.group(Api, "server.vcs", (handlers) =>
15
- Effect.gen(function* () {
16
- const project = yield* Project.Service
17
- const bus = yield* Bus.Service
18
- const locations = yield* LocationServiceMap.Service
19
- return handlers
20
- .handle("vcs.init", (ctx) =>
21
- Effect.gen(function* () {
22
- const location = yield* Location.Service
23
- const directory = location.project.directory
24
- const providerID = ctx.query.provider ?? "git"
25
- const vcs = yield* Vcs.Service
26
- yield* vcs.initialize(providerID).pipe(
27
- Effect.mapError((error) => {
28
- if (error.kind === "missing")
29
- return new InvalidRequestError({ message: "Project directory does not exist", field: "location" })
30
- if (error.kind === "conflict")
31
- return new ConflictError({ message: "Project already has version control", resource: directory })
32
- if (error.kind === "unknown")
33
- return new InvalidRequestError({
34
- message: "Unknown VCS provider",
35
- field: "provider",
36
- })
37
- if (error.kind === "unsupported")
38
- return new VcsInitNotSupportedError({
39
- providerID,
40
- message: "VCS provider does not support initialization",
41
- })
42
- return new ServiceUnavailableError({ service: providerID, message: "VCS initialization failed" })
43
- }),
44
- )
45
- const resolved = yield* project.resolve(directory)
46
- if (!resolved.vcs)
47
- return yield* new ServiceUnavailableError({ service: providerID, message: "VCS initialization failed" })
48
- yield* locations.invalidate(
49
- Location.Ref.make({ directory: location.directory, workspaceID: location.workspaceID }),
50
- )
51
- yield* bus.publish(Worktree.Event.Updated, { projectID: resolved.id })
52
- return HttpApiSchema.NoContent.make()
53
- }),
54
- )
55
- .handle("vcs.get", () =>
56
- response(
57
- Effect.gen(function* () {
58
- const vcs = yield* Vcs.Service
59
- return yield* vcs.info()
60
- }),
61
- ),
62
- )
63
- .handle("vcs.base", () =>
64
- response(
65
- Effect.gen(function* () {
66
- const vcs = yield* Vcs.Service
67
- return yield* vcs
68
- .base()
69
- .pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })))
70
- }),
71
- ),
72
- )
73
- .handle("vcs.status", () =>
74
- response(
75
- Effect.gen(function* () {
76
- const vcs = yield* Vcs.Service
77
- return yield* vcs.status()
78
- }),
79
- ),
80
- )
81
- .handle("vcs.branch.list", (ctx) =>
82
- response(
83
- Effect.gen(function* () {
84
- const vcs = yield* Vcs.Service
85
- return yield* vcs.branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) })
86
- }),
87
- ),
88
- )
89
- .handle("vcs.diff", (ctx) =>
90
- response(
91
- Effect.gen(function* () {
92
- const vcs = yield* Vcs.Service
93
- return yield* vcs
94
- .diff(ctx.query.mode, {
95
- context: ctx.query.context,
96
- base: ctx.query.base,
97
- untracked: ctx.query.untracked,
98
- })
99
- .pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })))
100
- }),
101
- ),
102
- )
103
- }),
104
- )
1
+ import { Vcs } from "@zyro-sec/core/vcs"
2
+ import { Project } from "@zyro-sec/core/project"
3
+ import { Worktree } from "@zyro-sec/core/worktree"
4
+ import { Bus } from "@zyro-sec/core/bus"
5
+ import { Location } from "@zyro-sec/core/location"
6
+ import { LocationServiceMap } from "@zyro-sec/core/location-services"
7
+ import { ConflictError, InvalidRequestError, ServiceUnavailableError } from "@zyro-sec/protocol/errors"
8
+ import { VcsInitNotSupportedError } from "@zyro-sec/protocol/groups/vcs"
9
+ import { Effect } from "effect"
10
+ import { HttpApiBuilder, HttpApiSchema } from "effect/http-api"
11
+ import { Api } from "../api"
12
+ import { response } from "../location"
13
+
14
+ export const VcsHandler = HttpApiBuilder.group(Api, "server.vcs", (handlers) =>
15
+ Effect.gen(function* () {
16
+ const project = yield* Project.Service
17
+ const bus = yield* Bus.Service
18
+ const locations = yield* LocationServiceMap.Service
19
+ return handlers
20
+ .handle("vcs.init", (ctx) =>
21
+ Effect.gen(function* () {
22
+ const location = yield* Location.Service
23
+ const directory = location.project.directory
24
+ const providerID = ctx.query.provider ?? "git"
25
+ const vcs = yield* Vcs.Service
26
+ yield* vcs.initialize(providerID).pipe(
27
+ Effect.mapError((error) => {
28
+ if (error.kind === "missing")
29
+ return new InvalidRequestError({ message: "Project directory does not exist", field: "location" })
30
+ if (error.kind === "conflict")
31
+ return new ConflictError({ message: "Project already has version control", resource: directory })
32
+ if (error.kind === "unknown")
33
+ return new InvalidRequestError({
34
+ message: "Unknown VCS provider",
35
+ field: "provider",
36
+ })
37
+ if (error.kind === "unsupported")
38
+ return new VcsInitNotSupportedError({
39
+ providerID,
40
+ message: "VCS provider does not support initialization",
41
+ })
42
+ return new ServiceUnavailableError({ service: providerID, message: "VCS initialization failed" })
43
+ }),
44
+ )
45
+ const resolved = yield* project.resolve(directory)
46
+ if (!resolved.vcs)
47
+ return yield* new ServiceUnavailableError({ service: providerID, message: "VCS initialization failed" })
48
+ yield* locations.invalidate(
49
+ Location.Ref.make({ directory: location.directory, workspaceID: location.workspaceID }),
50
+ )
51
+ yield* bus.publish(Worktree.Event.Updated, { projectID: resolved.id })
52
+ return HttpApiSchema.NoContent.make()
53
+ }),
54
+ )
55
+ .handle("vcs.get", () =>
56
+ response(
57
+ Effect.gen(function* () {
58
+ const vcs = yield* Vcs.Service
59
+ return yield* vcs.info()
60
+ }),
61
+ ),
62
+ )
63
+ .handle("vcs.base", () =>
64
+ response(
65
+ Effect.gen(function* () {
66
+ const vcs = yield* Vcs.Service
67
+ return yield* vcs
68
+ .base()
69
+ .pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })))
70
+ }),
71
+ ),
72
+ )
73
+ .handle("vcs.status", () =>
74
+ response(
75
+ Effect.gen(function* () {
76
+ const vcs = yield* Vcs.Service
77
+ return yield* vcs.status()
78
+ }),
79
+ ),
80
+ )
81
+ .handle("vcs.branch.list", (ctx) =>
82
+ response(
83
+ Effect.gen(function* () {
84
+ const vcs = yield* Vcs.Service
85
+ return yield* vcs.branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) })
86
+ }),
87
+ ),
88
+ )
89
+ .handle("vcs.diff", (ctx) =>
90
+ response(
91
+ Effect.gen(function* () {
92
+ const vcs = yield* Vcs.Service
93
+ return yield* vcs
94
+ .diff(ctx.query.mode, {
95
+ context: ctx.query.context,
96
+ base: ctx.query.base,
97
+ untracked: ctx.query.untracked,
98
+ })
99
+ .pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })))
100
+ }),
101
+ ),
102
+ )
103
+ }),
104
+ )
@@ -1,50 +1,50 @@
1
- import { Location } from "@zyro-sec/core/location"
2
- import { LocationServiceMap } from "@zyro-sec/core/location-services"
3
- import { AbsolutePath } from "@zyro-sec/core/schema"
4
- import { Voice } from "@zyro-sec/core/voice"
5
- import { InvalidRequestError, ServiceUnavailableError } from "@zyro-sec/protocol/errors"
6
- import { Global } from "@zyro-sec/util/global"
7
- import { Effect } from "effect"
8
- import { HttpApiBuilder } from "effect/http-api"
9
- import { Api } from "../api"
10
- import { locationErrors } from "../location"
11
-
12
- export const VoiceHandler = HttpApiBuilder.group(Api, "server.voice", (handlers) =>
13
- Effect.gen(function* () {
14
- const global = yield* Global.Service
15
- const locations = yield* LocationServiceMap.Service
16
- const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }))
17
- return handlers
18
- .handle(
19
- "voice.models",
20
- Effect.fn("server.voice.models")(
21
- function* () {
22
- const voice = yield* Voice.Service
23
- return { data: yield* voice.models() }
24
- },
25
- Effect.provide(services),
26
- locationErrors,
27
- ),
28
- )
29
- .handle(
30
- "voice.session",
31
- Effect.fn("server.voice.session")(
32
- function* (request) {
33
- const voice = yield* Voice.Service
34
- const transport = yield* voice
35
- .session(request.payload)
36
- .pipe(
37
- Effect.mapError((error) =>
38
- error._tag === "Voice.InvalidRequestError"
39
- ? new InvalidRequestError({ message: error.message })
40
- : new ServiceUnavailableError({ message: error.message, service: error.service }),
41
- ),
42
- )
43
- return { data: { transport } }
44
- },
45
- Effect.provide(services),
46
- locationErrors,
47
- ),
48
- )
49
- }),
50
- )
1
+ import { Location } from "@zyro-sec/core/location"
2
+ import { LocationServiceMap } from "@zyro-sec/core/location-services"
3
+ import { AbsolutePath } from "@zyro-sec/core/schema"
4
+ import { Voice } from "@zyro-sec/core/voice"
5
+ import { InvalidRequestError, ServiceUnavailableError } from "@zyro-sec/protocol/errors"
6
+ import { Global } from "@zyro-sec/util/global"
7
+ import { Effect } from "effect"
8
+ import { HttpApiBuilder } from "effect/http-api"
9
+ import { Api } from "../api"
10
+ import { locationErrors } from "../location"
11
+
12
+ export const VoiceHandler = HttpApiBuilder.group(Api, "server.voice", (handlers) =>
13
+ Effect.gen(function* () {
14
+ const global = yield* Global.Service
15
+ const locations = yield* LocationServiceMap.Service
16
+ const services = locations.get(Location.Ref.make({ directory: AbsolutePath.make(global.config) }))
17
+ return handlers
18
+ .handle(
19
+ "voice.models",
20
+ Effect.fn("server.voice.models")(
21
+ function* () {
22
+ const voice = yield* Voice.Service
23
+ return { data: yield* voice.models() }
24
+ },
25
+ Effect.provide(services),
26
+ locationErrors,
27
+ ),
28
+ )
29
+ .handle(
30
+ "voice.session",
31
+ Effect.fn("server.voice.session")(
32
+ function* (request) {
33
+ const voice = yield* Voice.Service
34
+ const transport = yield* voice
35
+ .session(request.payload)
36
+ .pipe(
37
+ Effect.mapError((error) =>
38
+ error._tag === "Voice.InvalidRequestError"
39
+ ? new InvalidRequestError({ message: error.message })
40
+ : new ServiceUnavailableError({ message: error.message, service: error.service }),
41
+ ),
42
+ )
43
+ return { data: { transport } }
44
+ },
45
+ Effect.provide(services),
46
+ locationErrors,
47
+ ),
48
+ )
49
+ }),
50
+ )