@opencode/server 0.0.0-dev-1360 → 0.0.0-dev-1362

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 (146) hide show
  1. package/dist/api.d.ts +171 -2
  2. package/dist/api.js +5 -5
  3. package/dist/auth.js +1 -1
  4. package/dist/chunks/{auth-ca564221.js → service-status-0dfmev2z.js} +1 -1
  5. package/dist/chunks/{auth-xcshf76p.js → service-status-10r1zt22.js} +7 -8
  6. package/dist/chunks/{auth-29nx48hm.js → service-status-29nx48hm.js} +1 -1
  7. package/dist/chunks/{auth-10sj2tcf.js → service-status-2h3x7256.js} +1 -1
  8. package/dist/chunks/{auth-rgbnpstw.js → service-status-341zm3rs.js} +2 -2
  9. package/dist/chunks/{auth-nvb61mgq.js → service-status-4gs63nyp.js} +4 -4
  10. package/dist/chunks/service-status-4gt38746.js +111 -0
  11. package/dist/chunks/{auth-59yyxpa4.js → service-status-4rg1tmcj.js} +8 -8
  12. package/dist/chunks/{auth-enx9e1dz.js → service-status-4th25279.js} +4 -4
  13. package/dist/chunks/{auth-g23ffrnz.js → service-status-50kbksvb.js} +2 -2
  14. package/dist/chunks/{auth-2p8psxn9.js → service-status-5h6n6h4q.js} +24 -23
  15. package/dist/chunks/{auth-z3e7v67k.js → service-status-5pdfedjd.js} +5 -5
  16. package/dist/chunks/{auth-w9jcwh65.js → service-status-69weg9qz.js} +8 -8
  17. package/dist/chunks/{auth-6pm6ek88.js → service-status-6pm6ek88.js} +1 -1
  18. package/dist/chunks/{auth-br4x4prt.js → service-status-72bf7qt9.js} +3 -3
  19. package/dist/chunks/{auth-tjxfj8xj.js → service-status-7p3x8m34.js} +33 -16
  20. package/dist/chunks/{auth-n2zyxnzr.js → service-status-7tv8nec1.js} +1 -1
  21. package/dist/chunks/{auth-wsvmph03.js → service-status-844nmnmk.js} +2 -2
  22. package/dist/chunks/{auth-8sb6qqpn.js → service-status-8sb6qqpn.js} +1 -1
  23. package/dist/chunks/{auth-whvq72as.js → service-status-8y4d9f30.js} +3 -3
  24. package/dist/chunks/{auth-1z9qd4y2.js → service-status-9vfv9n1y.js} +4 -4
  25. package/dist/chunks/{auth-csnx1nj3.js → service-status-bcs2rr9e.js} +2 -2
  26. package/dist/chunks/{auth-rjhxbsc4.js → service-status-cgcw2b0e.js} +2 -2
  27. package/dist/chunks/{auth-djr0jy89.js → service-status-djr0jy89.js} +1 -1
  28. package/dist/chunks/{auth-0q7s66m2.js → service-status-e6e4kz0w.js} +4 -4
  29. package/dist/chunks/{auth-g4964mny.js → service-status-evw6vf0s.js} +3 -3
  30. package/dist/chunks/{auth-7dkb5ks8.js → service-status-fcw485c9.js} +2 -2
  31. package/dist/chunks/{auth-am27j67f.js → service-status-fegnxd42.js} +1 -1
  32. package/dist/chunks/{auth-ehyp3zqd.js → service-status-fsvp99pe.js} +1 -1
  33. package/dist/chunks/{auth-k74zefsg.js → service-status-ggw25rqf.js} +1 -1
  34. package/dist/chunks/{auth-em7ed65n.js → service-status-gqstb6bx.js} +2 -2
  35. package/dist/chunks/{auth-j4at0y5c.js → service-status-j4at0y5c.js} +1 -1
  36. package/dist/chunks/{auth-8xdajgpr.js → service-status-j605n900.js} +2 -2
  37. package/dist/chunks/{auth-javgytnb.js → service-status-j6y32kmq.js} +2 -2
  38. package/dist/chunks/{auth-8nezxn08.js → service-status-k12h8tw9.js} +1 -1
  39. package/dist/chunks/{auth-f3gr6hfv.js → service-status-kc553r92.js} +2 -2
  40. package/dist/chunks/service-status-mj1ewmp1.js +219 -0
  41. package/dist/chunks/{auth-myqk22k5.js → service-status-myqk22k5.js} +2 -2
  42. package/dist/chunks/{auth-p3bbq7g3.js → service-status-ntf3tw9k.js} +1 -1
  43. package/dist/chunks/{auth-qssmdh31.js → service-status-pp5985xb.js} +4 -4
  44. package/dist/chunks/{auth-8qsq6tbs.js → service-status-qcnb494j.js} +2 -2
  45. package/dist/chunks/{auth-yc92za0p.js → service-status-qgjb3f4w.js} +2 -2
  46. package/dist/chunks/{auth-1aar1z9e.js → service-status-qw2j92v5.js} +5 -5
  47. package/dist/chunks/{auth-0wjm8gvs.js → service-status-r5yb7twv.js} +2 -2
  48. package/dist/chunks/{auth-74nxvsrn.js → service-status-r9w3a44p.js} +7 -4
  49. package/dist/chunks/{auth-s0zgx365.js → service-status-sn8sqewc.js} +2 -2
  50. package/dist/chunks/{auth-t32e1bbt.js → service-status-t32e1bbt.js} +1 -1
  51. package/dist/chunks/{auth-exwy1kbj.js → service-status-tktas153.js} +2 -2
  52. package/dist/chunks/{auth-ka2mtp6f.js → service-status-vyjhrbg0.js} +2 -2
  53. package/dist/chunks/{auth-gaegw7xv.js → service-status-w7n3bfa8.js} +16 -12
  54. package/dist/chunks/{auth-kmwr1xw9.js → service-status-ws2ckpmb.js} +3 -3
  55. package/dist/chunks/{auth-x2qy7jg1.js → service-status-x2qy7jg1.js} +1 -1
  56. package/dist/chunks/service-status-xw05m515.js +49 -0
  57. package/dist/chunks/{auth-2tmcamrc.js → service-status-yvy5qft7.js} +2 -2
  58. package/dist/chunks/{auth-9hynp6rm.js → service-status-z564cb4b.js} +2 -2
  59. package/dist/chunks/{auth-prwd5gwt.js → service-status-zmrq0y42.js} +2 -2
  60. package/dist/chunks/{auth-qq3f8fnn.js → service-status-zs3a96ke.js} +2 -2
  61. package/dist/content-headers.js +1 -1
  62. package/dist/cors.js +1 -1
  63. package/dist/event-feed.d.ts +14 -2
  64. package/dist/event-feed.js +7 -7
  65. package/dist/fetch.d.ts +1 -1
  66. package/dist/fetch.js +65 -63
  67. package/dist/handlers/agent.js +6 -6
  68. package/dist/handlers/artifact.js +3 -3
  69. package/dist/handlers/automation.js +2 -2
  70. package/dist/handlers/blob.js +3 -3
  71. package/dist/handlers/command.js +6 -6
  72. package/dist/handlers/config.js +6 -6
  73. package/dist/handlers/credential.js +7 -7
  74. package/dist/handlers/debug.js +6 -6
  75. package/dist/handlers/event.js +7 -7
  76. package/dist/handlers/experimental/browser-tunnel.js +4 -4
  77. package/dist/handlers/flag.js +6 -6
  78. package/dist/handlers/form.js +6 -6
  79. package/dist/handlers/fs.js +8 -8
  80. package/dist/handlers/generate.js +6 -6
  81. package/dist/handlers/integration.js +6 -6
  82. package/dist/handlers/job.js +2 -2
  83. package/dist/handlers/location.js +6 -6
  84. package/dist/handlers/machine.js +1 -1
  85. package/dist/handlers/mcp.js +8 -8
  86. package/dist/handlers/media.js +2 -2
  87. package/dist/handlers/message.js +7 -7
  88. package/dist/handlers/migration.js +6 -6
  89. package/dist/handlers/model.js +6 -6
  90. package/dist/handlers/permission.js +6 -6
  91. package/dist/handlers/persistent-pty.d.ts +1 -1
  92. package/dist/handlers/persistent-pty.js +20 -18
  93. package/dist/handlers/plugin.js +6 -6
  94. package/dist/handlers/project.js +6 -6
  95. package/dist/handlers/provider.js +6 -6
  96. package/dist/handlers/pty-socket.js +1 -1
  97. package/dist/handlers/pty.js +8 -8
  98. package/dist/handlers/push.js +1 -1
  99. package/dist/handlers/reference.js +6 -6
  100. package/dist/handlers/rpc.js +6 -6
  101. package/dist/handlers/server.js +9 -9
  102. package/dist/handlers/session-error.js +1 -1
  103. package/dist/handlers/session.js +7 -7
  104. package/dist/handlers/shell.js +6 -6
  105. package/dist/handlers/skill.js +6 -6
  106. package/dist/handlers/space.d.ts +54 -0
  107. package/dist/handlers/space.js +7 -0
  108. package/dist/handlers/usage.js +6 -6
  109. package/dist/handlers/vcs.js +6 -6
  110. package/dist/handlers/voice.js +6 -6
  111. package/dist/handlers/websearch.js +6 -6
  112. package/dist/handlers/worktree.js +6 -6
  113. package/dist/handlers.d.ts +2 -1
  114. package/dist/handlers.js +58 -56
  115. package/dist/location.js +4 -4
  116. package/dist/media-uri.js +1 -1
  117. package/dist/middleware/authorization.js +2 -2
  118. package/dist/middleware/defect-response.js +1 -1
  119. package/dist/middleware/form-location.js +3 -3
  120. package/dist/middleware/schema-error.js +1 -1
  121. package/dist/middleware/session-location.js +3 -3
  122. package/dist/pairing.js +5 -5
  123. package/dist/process.js +68 -66
  124. package/dist/range.js +1 -1
  125. package/dist/request-site.js +2 -2
  126. package/dist/request-tracing.js +1 -1
  127. package/dist/routes.d.ts +4 -3
  128. package/dist/routes.js +62 -60
  129. package/dist/server-info.js +3 -3
  130. package/dist/service-status.js +3 -3
  131. package/dist/space-store.d.ts +62 -0
  132. package/dist/space-store.js +16 -0
  133. package/dist/workerd.d.ts +1 -1
  134. package/dist/workerd.js +67 -65
  135. package/package.json +8 -8
  136. package/dist/chunks/auth-ey0z35hy.js +0 -108
  137. /package/dist/chunks/{auth-017ycvbx.js → service-status-017ycvbx.js} +0 -0
  138. /package/dist/chunks/{auth-9rqn6x4v.js → service-status-9rqn6x4v.js} +0 -0
  139. /package/dist/chunks/{auth-bd8755ek.js → service-status-bd8755ek.js} +0 -0
  140. /package/dist/chunks/{auth-n26yr6pw.js → service-status-n26yr6pw.js} +0 -0
  141. /package/dist/chunks/{auth-q187pxxd.js → service-status-q187pxxd.js} +0 -0
  142. /package/dist/chunks/{auth-q4bn6dy8.js → service-status-q4bn6dy8.js} +0 -0
  143. /package/dist/chunks/{auth-qpnw2qd1.js → service-status-qpnw2qd1.js} +0 -0
  144. /package/dist/chunks/{auth-rqgv9x42.js → service-status-rqgv9x42.js} +0 -0
  145. /package/dist/chunks/{auth-xthc02cw.js → service-status-xthc02cw.js} +0 -0
  146. /package/dist/chunks/{auth-yc7nft6q.js → service-status-yc7nft6q.js} +0 -0
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/pairing.ts
6
6
  var exports_pairing = {};
7
7
  __export(exports_pairing, {
8
8
  ServerPairing: () => exports_pairing,
9
- Service: () => Service3,
10
- node: () => node2
9
+ Service: () => Service4,
10
+ node: () => node3
11
11
  });
12
12
  import { Cache, Context, Duration, Effect, Layer } from "effect";
13
13
  import { makeGlobalNode } from "@opencode/util/effect/app-node";
14
14
  import { randomBytes } from "node:crypto";
15
15
  var TTL = Duration.minutes(5);
16
16
 
17
- class Service3 extends Context.Service()("@opencode/ServerPairing") {
17
+ class Service4 extends Context.Service()("@opencode/ServerPairing") {
18
18
  }
19
19
  var noLookup = () => Effect.die(new Error("ServerPairing cache must be used via set/invalidateWhen, never get"));
20
- var layer = Layer.effect(Service3, Effect.gen(function* () {
20
+ var layer = Layer.effect(Service4, Effect.gen(function* () {
21
21
  const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
22
- return Service3.of({
22
+ return Service4.of({
23
23
  issue: Effect.fn("ServerPairing.issue")(function* () {
24
24
  const code = randomBytes(16).toString("base64url");
25
25
  yield* Cache.set(cache, code, true);
@@ -30,6 +30,6 @@ var layer = Layer.effect(Service3, Effect.gen(function* () {
30
30
  })
31
31
  });
32
32
  }));
33
- var node2 = makeGlobalNode({ service: Service3, layer, deps: [] });
33
+ var node3 = makeGlobalNode({ service: Service4, layer, deps: [] });
34
34
 
35
- export { Service3, node2, exports_pairing };
35
+ export { Service4, node3, exports_pairing };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./auth-rqgv9x42.js";
3
+ } from "./service-status-rqgv9x42.js";
4
4
 
5
5
  // src/handlers/automation.ts
6
6
  import { Automation } from "@opencode/core/automation";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./auth-rqgv9x42.js";
3
+ } from "./service-status-rqgv9x42.js";
4
4
 
5
5
  // src/location.ts
6
6
  import { FileSystem } from "@opencode/core/filesystem";
@@ -51,7 +51,7 @@ function decode(input) {
51
51
  return input;
52
52
  }
53
53
  }
54
- var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
54
+ var layer3 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
55
55
  const locations = yield* LocationServiceMap.Service;
56
56
  return LocationMiddleware2.of((effect) => Effect.gen(function* () {
57
57
  const request = yield* HttpServerRequest.HttpServerRequest;
@@ -59,4 +59,4 @@ var layer4 = Layer.effect(LocationMiddleware2, Effect.gen(function* () {
59
59
  }));
60
60
  }));
61
61
 
62
- export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2, layer4 };
62
+ export { LocationMiddleware2, locationErrors2, response2, sessionInfo2, requestRef2, layer3 };
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/event-feed.ts
6
6
  var exports_event_feed = {};
7
7
  __export(exports_event_feed, {
8
8
  EncodingError: () => EncodingError2,
9
9
  EventFeed: () => exports_event_feed,
10
- Service: () => Service4,
10
+ Service: () => Service5,
11
11
  SubscriberCapacity: () => SubscriberCapacity2,
12
12
  SubscriberOverflowError: () => SubscriberOverflowError2,
13
13
  frame: () => frame2,
14
- layer: () => layer3,
15
- make: () => make3
14
+ layer: () => layer4,
15
+ make: () => make4
16
16
  });
17
17
  import { Bus } from "@opencode/core/bus";
18
18
  import { Event } from "@opencode/schema/event";
19
19
  import { isOpenCodeEvent } from "@opencode/protocol/groups/event";
20
- import { Cause, Context, Effect, Layer, Queue, Schema, Stream } from "effect";
20
+ import { Cause, Context, Effect, Exit, Layer, Queue, Schema, Scope, Stream } from "effect";
21
21
  var SubscriberCapacity2 = 4096;
22
22
 
23
23
  class SubscriberOverflowError2 extends Schema.TaggedError()("EventFeed.SubscriberOverflow", { capacity: Schema.Int }) {
@@ -30,14 +30,14 @@ class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
30
30
  }) {
31
31
  }
32
32
 
33
- class Service4 extends Context.Service()("@opencode/server/EventFeed") {
33
+ class Service5 extends Context.Service()("@opencode/server/EventFeed") {
34
34
  }
35
35
  function frame2(event) {
36
36
  return `data: ${JSON.stringify(event)}
37
37
 
38
38
  `;
39
39
  }
40
- var make3 = Effect.fn("EventFeed.make")(function* (observe, options) {
40
+ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
41
41
  const capacity = options?.capacity ?? SubscriberCapacity2;
42
42
  const render = options?.encode ?? frame2;
43
43
  const subscribers = new Map;
@@ -47,6 +47,12 @@ var make3 = Effect.fn("EventFeed.make")(function* (observe, options) {
47
47
  for (const subscriber of current)
48
48
  Queue.failCauseUnsafe(subscriber, Cause.fail(error));
49
49
  });
50
+ const offer = (subscriber, encoded) => {
51
+ if (Queue.offerUnsafe(subscriber, encoded))
52
+ return;
53
+ subscribers.delete(subscriber);
54
+ Queue.failCauseUnsafe(subscriber, Cause.fail(new SubscriberOverflowError2({ capacity })));
55
+ };
50
56
  const publish = Effect.fnUntraced(function* (event) {
51
57
  if (!isOpenCodeEvent(event))
52
58
  return;
@@ -64,21 +70,32 @@ var make3 = Effect.fn("EventFeed.make")(function* (observe, options) {
64
70
  }).pipe(Effect.andThen(fail(error)), Effect.as(undefined))));
65
71
  if (encoded === undefined)
66
72
  return;
67
- if (Queue.offerUnsafe(subscriber, encoded))
68
- continue;
69
- subscribers.delete(subscriber);
70
- Queue.failCauseUnsafe(subscriber, Cause.fail(new SubscriberOverflowError2({ capacity })));
73
+ offer(subscriber, encoded);
71
74
  }
72
75
  });
73
76
  const unsubscribe = yield* observe(publish);
74
77
  yield* Effect.addFinalizer(() => unsubscribe);
75
- return Service4.of({
76
- subscribe: (types) => Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.set(queue, types?.length ? new Set(types) : undefined)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
78
+ return Service5.of({
79
+ subscribe: (types) => Effect.gen(function* () {
80
+ const queue = yield* Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.set(queue, types?.length ? new Set(types) : undefined)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid));
81
+ const id = crypto.randomUUID();
82
+ const send = (event) => Effect.suspend(() => {
83
+ if (!subscribers.has(queue))
84
+ return Effect.void;
85
+ return Effect.try(() => render(event)).pipe(Effect.flatMap((encoded) => Effect.sync(() => offer(queue, encoded))), Effect.catchCause((cause) => Effect.logError("Failed to encode extension event", { type: event.type, cause })));
86
+ });
87
+ const scope = yield* Scope.Scope;
88
+ yield* Effect.forEach(options?.extensions ?? [], (extension) => Effect.gen(function* () {
89
+ const child = yield* Scope.fork(scope);
90
+ yield* extension.open(id, send).pipe(Scope.provide(child), Effect.catchCause((cause) => Effect.logError("Event stream extension failed", { cause }).pipe(Effect.andThen(Scope.close(child, Exit.void)))));
91
+ }), { discard: true });
92
+ return { id, events: Stream.fromQueue(queue) };
93
+ })
77
94
  });
78
95
  });
79
- var layer3 = Layer.effect(Service4, Effect.gen(function* () {
96
+ var layer4 = (...extensions) => Layer.effect(Service5, Effect.gen(function* () {
80
97
  const bus = yield* Bus.Service;
81
- return yield* make3(bus.listen);
98
+ return yield* make4(bus.listen, { extensions: yield* Effect.all(extensions) });
82
99
  }));
83
100
 
84
- export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make3, layer3, exports_event_feed };
101
+ export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service5, frame2, make4, layer4, exports_event_feed };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
 
5
5
  // src/handlers/worktree.ts
6
6
  import { Git } from "@opencode/core/git";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/usage.ts
9
9
  import { UsageLimits } from "@opencode/core/usage-limits";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/range.ts
6
6
  var exports_range = {};
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  LocationMiddleware2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  FormLocationMiddleware2
6
- } from "./auth-ca564221.js";
6
+ } from "./service-status-0dfmev2z.js";
7
7
  import {
8
8
  SessionLocationMiddleware2
9
- } from "./auth-ehyp3zqd.js";
9
+ } from "./service-status-fsvp99pe.js";
10
10
 
11
11
  // src/api.ts
12
12
  import { makeDefaultApi } from "@opencode/protocol/api";
@@ -2,18 +2,18 @@ import {
2
2
  locationErrors2,
3
3
  response2,
4
4
  requestRef2
5
- } from "./auth-br4x4prt.js";
5
+ } from "./service-status-72bf7qt9.js";
6
6
  import {
7
7
  Api2
8
- } from "./auth-whvq72as.js";
8
+ } from "./service-status-8y4d9f30.js";
9
9
  import {
10
10
  CorsConfig2,
11
11
  isAllowedRequestOrigin2
12
- } from "./auth-q4bn6dy8.js";
12
+ } from "./service-status-q4bn6dy8.js";
13
13
  import {
14
14
  runPtySocket2,
15
15
  holdLocation2
16
- } from "./auth-q187pxxd.js";
16
+ } from "./service-status-q187pxxd.js";
17
17
 
18
18
  // src/handlers/pty.ts
19
19
  import { Pty } from "@opencode/core/pty";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  requestRef2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/debug.ts
9
9
  import { LocationServiceMap } from "@opencode/core/location-service-map";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  locationErrors2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/voice.ts
9
9
  import { Location } from "@opencode/core/location";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CONTENT_SECURITY_POLICY2,
3
3
  disposition2
4
- } from "./auth-t32e1bbt.js";
4
+ } from "./service-status-t32e1bbt.js";
5
5
 
6
6
  // src/handlers/media.ts
7
7
  import { Database } from "@opencode/core/database/database";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/service-status.ts
6
6
  var exports_service_status = {};
7
7
  __export(exports_service_status, {
8
8
  Status: () => exports_service_status,
9
- make: () => make4
9
+ make: () => make3
10
10
  });
11
11
  import { Effect, Ref } from "effect";
12
- var make4 = Effect.fnUntraced(function* (options = {}) {
12
+ var make3 = Effect.fnUntraced(function* (options = {}) {
13
13
  const current = yield* Ref.make(options.initial ?? { type: "starting" });
14
14
  const beginStopping = Ref.update(current, (status) => status.type === "stopping" ? status : { type: "stopping" });
15
15
  return {
@@ -20,4 +20,4 @@ var make4 = Effect.fnUntraced(function* (options = {}) {
20
20
  };
21
21
  });
22
22
 
23
- export { make4, exports_service_status };
23
+ export { make3, exports_service_status };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  missingSession2,
3
3
  failedMessageDecode2
4
- } from "./auth-rqgv9x42.js";
4
+ } from "./service-status-rqgv9x42.js";
5
5
  import {
6
6
  Api2
7
- } from "./auth-whvq72as.js";
7
+ } from "./service-status-8y4d9f30.js";
8
8
  import {
9
9
  wantsMediaRefs2
10
- } from "./auth-xthc02cw.js";
10
+ } from "./service-status-xthc02cw.js";
11
11
 
12
12
  // src/handlers/message.ts
13
13
  import { SessionMessage } from "@opencode/core/session/message";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/reference.ts
9
9
  import { Reference } from "@opencode/core/reference";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
 
5
5
  // src/handlers/config.ts
6
6
  import { Config } from "@opencode/core/config";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  locationErrors2,
3
3
  sessionInfo2
4
- } from "./auth-br4x4prt.js";
4
+ } from "./service-status-72bf7qt9.js";
5
5
 
6
6
  // src/middleware/session-location.ts
7
7
  import { Instance } from "@opencode/core/instance/service";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
 
5
5
  // src/handlers/rpc.ts
6
6
  import { Rpc } from "@opencode/core/rpc";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/plugin.ts
9
9
  import { Plugin } from "@opencode/core/plugin";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/auth.ts
6
6
  var exports_auth = {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
  import {
5
5
  requireConnectable2
6
- } from "./auth-2tmcamrc.js";
6
+ } from "./service-status-yvy5qft7.js";
7
7
 
8
8
  // src/handlers/credential.ts
9
9
  import { Credential } from "@opencode/core/credential";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./auth-rqgv9x42.js";
3
+ } from "./service-status-rqgv9x42.js";
4
4
  import {
5
5
  locationErrors2,
6
6
  response2,
7
7
  requestRef2
8
- } from "./auth-br4x4prt.js";
8
+ } from "./service-status-72bf7qt9.js";
9
9
 
10
10
  // src/handlers/artifact.ts
11
11
  import { Artifact } from "@opencode/core/artifact";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./auth-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
 
5
5
  // src/handlers/project.ts
6
6
  import { Project } from "@opencode/core/project";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/shell.ts
9
9
  import { Shell } from "@opencode/core/shell";
@@ -0,0 +1,219 @@
1
+ import {
2
+ __export
3
+ } from "./service-status-9rqn6x4v.js";
4
+
5
+ // src/space-store.ts
6
+ var exports_space_store = {};
7
+ __export(exports_space_store, {
8
+ BatchSize: () => BatchSize2,
9
+ PurgeInterval: () => PurgeInterval2,
10
+ Service: () => Service2,
11
+ SpaceStore: () => exports_space_store,
12
+ extension: () => extension2,
13
+ node: () => node2
14
+ });
15
+ import { SpaceRows } from "@opencode/core/space";
16
+ import { Database } from "@opencode/core/database/database";
17
+ import { KeyedMutex } from "@opencode/core/effect/keyed-mutex";
18
+ import { Space } from "@opencode/schema/space";
19
+ import { Event } from "@opencode/schema/event";
20
+ import { makeGlobalNode } from "@opencode/util/effect/app-node";
21
+ import { Clock, Context, Effect, Layer } from "effect";
22
+ var BatchSize2 = 500;
23
+ var PurgeInterval2 = 64;
24
+
25
+ class Service2 extends Context.Service()("@opencode/server/SpaceStore") {
26
+ }
27
+ var layer = Layer.effect(Service2, Effect.gen(function* () {
28
+ const db = (yield* Database.Service).db;
29
+ let epoch = yield* SpaceRows.epoch(db).pipe(Effect.catchCause((cause) => Effect.logWarning("Could not read the space epoch", { cause }).pipe(Effect.as(crypto.randomUUID()))));
30
+ const listeners = new Array;
31
+ const locks = KeyedMutex.makeUnsafe();
32
+ const deletes = new Map;
33
+ const tombstoned = (space, count) => Effect.suspend(() => {
34
+ if (count === 0)
35
+ return Effect.void;
36
+ const since = (deletes.get(space) ?? PurgeInterval2 - 1) + count;
37
+ if (since < PurgeInterval2)
38
+ return Effect.sync(() => deletes.set(space, since));
39
+ return SpaceRows.purge(db, space).pipe(Effect.andThen(Effect.sync(() => deletes.set(space, 0))), Effect.catchCause((cause) => Effect.logWarning("Could not purge space tombstones", { space, cause })));
40
+ });
41
+ const streams = new Map;
42
+ const deliver = (stream, change) => Effect.suspend(() => {
43
+ const subscription = stream.spaces.get(change.data.space);
44
+ if (!subscription)
45
+ return Effect.void;
46
+ if (subscription.pending) {
47
+ subscription.pending.push(change);
48
+ return Effect.void;
49
+ }
50
+ return change.data.revision > subscription.covered ? stream.send(change) : Effect.void;
51
+ });
52
+ const page = (space, cursor, limit) => Effect.gen(function* () {
53
+ const position = cursor === undefined ? undefined : parse(epoch, cursor);
54
+ const from = position?.head === undefined ? position ? { type: "delta", since: position.since, snapshot: true } : { type: "snapshot", since: 0 } : position.since > position.head ? { type: "snapshot", since: 0 } : { type: "snapshot", since: position.since, until: position.head };
55
+ const read = yield* SpaceRows.read(db, space, from, limit + 1);
56
+ const more = read.rows.length > limit;
57
+ const kept = read.rows.slice(0, limit);
58
+ if (read.continued && from.type === "delta") {
59
+ const revision = kept.at(-1)?.revision ?? from.since;
60
+ const delta = {
61
+ type: "delta",
62
+ space,
63
+ epoch,
64
+ revision,
65
+ entries: entries(kept),
66
+ deleted: deleted(kept),
67
+ cursor: `${epoch}.${revision}`,
68
+ next: more ? `${epoch}.${revision}` : undefined
69
+ };
70
+ return delta;
71
+ }
72
+ const since = read.continued ? from.since : 0;
73
+ const until = read.continued && from.type === "snapshot" ? from.until ?? read.head : read.head;
74
+ const revision = more ? kept.at(-1)?.revision ?? since : until;
75
+ const snapshot = {
76
+ type: "snapshot",
77
+ space,
78
+ epoch,
79
+ revision,
80
+ entries: entries(kept),
81
+ cursor: `${epoch}.${revision}`,
82
+ next: more ? `${epoch}.${revision}.${until}` : read.head > until ? `${epoch}.${until}` : undefined
83
+ };
84
+ return snapshot;
85
+ });
86
+ const catchUp = (space, cursor, budget) => Effect.gen(function* () {
87
+ const position = parse(epoch, cursor);
88
+ const created = yield* Clock.currentTimeMillis;
89
+ const resync = (read) => ({
90
+ covered: 0,
91
+ read,
92
+ events: [{ id: Event.ID.create(), created, type: Space.Event.Resync.type, data: { space } }]
93
+ });
94
+ if (budget === 0 || !position || position.head !== undefined)
95
+ return resync(0);
96
+ const read = yield* SpaceRows.read(db, space, { type: "delta", since: position.since, snapshot: false }, budget + 1);
97
+ if (!read.continued || read.rows.length > budget)
98
+ return resync(read.rows.length);
99
+ return {
100
+ covered: read.rows.at(-1)?.revision ?? position.since,
101
+ read: read.rows.length,
102
+ events: read.rows.map((row) => change(space, row, created))
103
+ };
104
+ });
105
+ return Service2.of({
106
+ write: Effect.fn("SpaceStore.write")(function* (changes) {
107
+ return yield* [...new Set(changes.map((change) => change.space))].toSorted().reduceRight((effect, space) => locks.withLock(space)(effect), Effect.uninterruptible(Effect.gen(function* () {
108
+ const result = yield* SpaceRows.write(db, changes);
109
+ const tombstones = Map.groupBy(result.written.filter((row) => row.value === null), (row) => row.space);
110
+ yield* Effect.forEach(tombstones, ([space, rows]) => tombstoned(space, rows.length), { discard: true });
111
+ const created = yield* Clock.currentTimeMillis;
112
+ for (const row of result.written) {
113
+ const committed = change(row.space, row, created);
114
+ yield* Effect.forEach(listeners, (listener) => listener(committed), { discard: true });
115
+ yield* Effect.forEach(streams.values(), (stream) => deliver(stream, committed), { discard: true });
116
+ }
117
+ return result.heads.map((head) => ({ ...head, cursor: `${epoch}.${head.revision}` }));
118
+ })));
119
+ }),
120
+ get epoch() {
121
+ return epoch;
122
+ },
123
+ resetEpoch: Effect.fn("SpaceStore.resetEpoch")(function* () {
124
+ epoch = yield* SpaceRows.resetEpoch(db);
125
+ })(),
126
+ sync: Effect.fn("SpaceStore.sync")(function* (requests) {
127
+ const pages = new Array;
128
+ let budget = BatchSize2;
129
+ for (const request of requests) {
130
+ if (budget === 0)
131
+ break;
132
+ const next = yield* page(request.space, request.cursor, budget);
133
+ budget -= next.entries.length + (next.type === "delta" ? next.deleted.length : 0);
134
+ pages.push(next);
135
+ }
136
+ return pages;
137
+ }),
138
+ attach: (id, send) => Effect.acquireRelease(Effect.sync(() => streams.set(id, { send, spaces: new Map })), () => Effect.sync(() => streams.delete(id))).pipe(Effect.asVoid),
139
+ subscribe: Effect.fn("SpaceStore.subscribe")(function* (id, requests) {
140
+ const stream = streams.get(id);
141
+ if (!stream)
142
+ return false;
143
+ const subscriptions = requests.map((request) => {
144
+ const subscription = { covered: 0, pending: [] };
145
+ stream.spaces.set(request.space, subscription);
146
+ return { request, subscription };
147
+ });
148
+ let budget = BatchSize2;
149
+ yield* Effect.forEach(subscriptions, ({ request, subscription }) => Effect.gen(function* () {
150
+ const current = () => stream.spaces.get(request.space) === subscription;
151
+ const first = yield* catchUp(request.space, request.cursor, budget);
152
+ budget = Math.max(0, budget - first.read);
153
+ if (!subscription.pending)
154
+ return;
155
+ subscription.covered = first.covered;
156
+ for (const event of first.events)
157
+ if (current())
158
+ yield* stream.send(event);
159
+ for (let change = subscription.pending.shift();change && current(); change = subscription.pending.shift())
160
+ if (change.data.revision > subscription.covered)
161
+ yield* stream.send(change);
162
+ subscription.pending = undefined;
163
+ }), { discard: true }).pipe(Effect.ensuring(Effect.sync(() => {
164
+ for (const { request, subscription } of subscriptions)
165
+ if (subscription.pending && stream.spaces.get(request.space) === subscription)
166
+ stream.spaces.delete(request.space);
167
+ })));
168
+ return true;
169
+ }),
170
+ unsubscribe: (id, spaces) => Effect.sync(() => {
171
+ const stream = streams.get(id);
172
+ for (const space of spaces)
173
+ stream?.spaces.delete(space);
174
+ return stream !== undefined;
175
+ }),
176
+ listen: (listener) => Effect.sync(() => {
177
+ listeners.push(listener);
178
+ return Effect.sync(() => {
179
+ const index = listeners.indexOf(listener);
180
+ if (index >= 0)
181
+ listeners.splice(index, 1);
182
+ });
183
+ })
184
+ });
185
+ }));
186
+ var node2 = makeGlobalNode({ service: Service2, layer, deps: [Database.node] });
187
+ var extension2 = Effect.gen(function* () {
188
+ const store = yield* Service2;
189
+ return { open: (stream, send) => store.attach(stream, send) };
190
+ });
191
+ function change(space, row, created) {
192
+ return row.value === null ? {
193
+ id: Event.ID.create(),
194
+ created,
195
+ type: Space.Event.Deleted.type,
196
+ data: { space, key: row.key, revision: row.revision }
197
+ } : {
198
+ id: Event.ID.create(),
199
+ created,
200
+ type: Space.Event.Updated.type,
201
+ data: { space, key: row.key, value: row.value, revision: row.revision }
202
+ };
203
+ }
204
+ function entries(rows) {
205
+ return rows.flatMap((row) => row.value === null ? [] : [{ key: row.key, value: row.value }]);
206
+ }
207
+ function deleted(rows) {
208
+ return rows.flatMap((row) => row.value === null ? [row.key] : []);
209
+ }
210
+ function parse(epoch, cursor) {
211
+ if (!cursor.startsWith(`${epoch}.`))
212
+ return;
213
+ const parts = cursor.slice(epoch.length + 1).split(".");
214
+ if (parts.length > 2 || !parts.every((part) => /^\d+$/u.test(part) && Number.isSafeInteger(Number(part))))
215
+ return;
216
+ return { since: Number(parts[0]), head: parts[1] === undefined ? undefined : Number(parts[1]) };
217
+ }
218
+
219
+ export { BatchSize2, PurgeInterval2, Service2, node2, extension2, exports_space_store };