@opencode/server 0.0.0-dev-1361 → 0.0.0-dev-1363

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 (142) hide show
  1. package/dist/api.js +5 -5
  2. package/dist/auth.js +1 -1
  3. package/dist/chunks/{cors-msvebcy2.js → service-status-286nzxac.js} +8 -8
  4. package/dist/chunks/{cors-29nx48hm.js → service-status-29nx48hm.js} +1 -1
  5. package/dist/chunks/{cors-e6e4kz0w.js → service-status-39nnfjx1.js} +4 -4
  6. package/dist/chunks/{cors-sv3a4xc1.js → service-status-3kn3vtva.js} +13 -13
  7. package/dist/chunks/{cors-5pdfedjd.js → service-status-3te71694.js} +4 -4
  8. package/dist/chunks/{cors-8xdajgpr.js → service-status-3w2mqh28.js} +2 -2
  9. package/dist/chunks/{cors-fa6nnfxm.js → service-status-4z6dd0zp.js} +37 -37
  10. package/dist/chunks/{cors-g23ffrnz.js → service-status-50kbksvb.js} +2 -2
  11. package/dist/chunks/{cors-kmwr1xw9.js → service-status-5ky8bme5.js} +3 -3
  12. package/dist/chunks/{cors-8nezxn08.js → service-status-6anyjjh1.js} +1 -1
  13. package/dist/chunks/{cors-6pm6ek88.js → service-status-6pm6ek88.js} +1 -1
  14. package/dist/chunks/{cors-2tmcamrc.js → service-status-7r996r31.js} +2 -2
  15. package/dist/chunks/{cors-8sb6qqpn.js → service-status-8sb6qqpn.js} +1 -1
  16. package/dist/chunks/{cors-rgbnpstw.js → service-status-8y9zssdg.js} +2 -2
  17. package/dist/chunks/{cors-k74zefsg.js → service-status-ar950k47.js} +1 -1
  18. package/dist/chunks/{cors-br4x4prt.js → service-status-br4x4prt.js} +1 -1
  19. package/dist/chunks/{cors-0wjm8gvs.js → service-status-c6ktqe09.js} +2 -2
  20. package/dist/chunks/{cors-ca564221.js → service-status-ca564221.js} +1 -1
  21. package/dist/chunks/{cors-yc92za0p.js → service-status-cj97w75w.js} +2 -2
  22. package/dist/chunks/{cors-wsvmph03.js → service-status-ddhjwr2w.js} +2 -2
  23. package/dist/chunks/{cors-f3gr6hfv.js → service-status-df03ef4a.js} +2 -2
  24. package/dist/chunks/{cors-6cmsxt3d.js → service-status-dh44mzk7.js} +6 -6
  25. package/dist/chunks/{cors-djr0jy89.js → service-status-djr0jy89.js} +1 -1
  26. package/dist/chunks/{cors-10sj2tcf.js → service-status-eacgzt6w.js} +1 -1
  27. package/dist/chunks/{cors-ehyp3zqd.js → service-status-ehyp3zqd.js} +1 -1
  28. package/dist/chunks/{cors-3cx4ac5j.js → service-status-ek3gas7h.js} +23 -26
  29. package/dist/chunks/{cors-8qsq6tbs.js → service-status-esvnag9e.js} +2 -2
  30. package/dist/chunks/{cors-exwy1kbj.js → service-status-f412ctvv.js} +2 -2
  31. package/dist/chunks/{cors-w6xb5z15.js → service-status-fmkwyf76.js} +91 -68
  32. package/dist/chunks/{cors-3xkwxcke.js → service-status-g9qy0kb1.js} +2 -2
  33. package/dist/chunks/{cors-hb1ty1t1.js → service-status-hhwsfbf5.js} +4 -4
  34. package/dist/chunks/{cors-z5c20bjd.js → service-status-hs3dbf8w.js} +7 -7
  35. package/dist/chunks/{cors-qq3f8fnn.js → service-status-htk4x1jk.js} +2 -2
  36. package/dist/chunks/{cors-j4at0y5c.js → service-status-j4at0y5c.js} +1 -1
  37. package/dist/chunks/{cors-javgytnb.js → service-status-javgytnb.js} +2 -2
  38. package/dist/chunks/{cors-whvq72as.js → service-status-jhs8rzvk.js} +3 -3
  39. package/dist/chunks/{cors-ka2mtp6f.js → service-status-ka2mtp6f.js} +2 -2
  40. package/dist/chunks/{cors-g4964mny.js → service-status-krsfryqp.js} +3 -3
  41. package/dist/chunks/{cors-myqk22k5.js → service-status-myqk22k5.js} +2 -2
  42. package/dist/chunks/{cors-v9t81kwn.js → service-status-mzs0n5xz.js} +8 -8
  43. package/dist/chunks/{cors-csnx1nj3.js → service-status-nfrn9zxf.js} +4 -4
  44. package/dist/chunks/{cors-qssmdh31.js → service-status-nmknd757.js} +4 -4
  45. package/dist/chunks/{cors-enx9e1dz.js → service-status-nrpq6p1a.js} +4 -4
  46. package/dist/chunks/{cors-rjhxbsc4.js → service-status-phgds112.js} +2 -2
  47. package/dist/chunks/{cors-prwd5gwt.js → service-status-r682v2h3.js} +2 -2
  48. package/dist/chunks/{cors-9hynp6rm.js → service-status-r6qsbz4y.js} +2 -2
  49. package/dist/chunks/{cors-7dkb5ks8.js → service-status-rg932pab.js} +2 -2
  50. package/dist/chunks/{cors-t32e1bbt.js → service-status-t32e1bbt.js} +1 -1
  51. package/dist/chunks/{cors-1z9qd4y2.js → service-status-t91ekvs6.js} +4 -4
  52. package/dist/chunks/service-status-v60tcbt5.js +49 -0
  53. package/dist/chunks/{cors-am27j67f.js → service-status-wjh98yw2.js} +1 -1
  54. package/dist/chunks/{cors-x2qy7jg1.js → service-status-x2qy7jg1.js} +1 -1
  55. package/dist/chunks/{cors-s0zgx365.js → service-status-y8sa9sbe.js} +2 -2
  56. package/dist/chunks/{cors-n2zyxnzr.js → service-status-ykr4m3zx.js} +1 -1
  57. package/dist/chunks/{cors-em7ed65n.js → service-status-z0v7xmc8.js} +2 -2
  58. package/dist/chunks/{cors-p3bbq7g3.js → service-status-z80wqx10.js} +2 -2
  59. package/dist/chunks/{cors-nvb61mgq.js → service-status-zgjt1dbn.js} +4 -4
  60. package/dist/content-headers.js +1 -1
  61. package/dist/cors.js +1 -1
  62. package/dist/event-feed.js +5 -5
  63. package/dist/fetch.js +67 -67
  64. package/dist/handlers/agent.js +6 -6
  65. package/dist/handlers/artifact.js +3 -3
  66. package/dist/handlers/automation.js +2 -2
  67. package/dist/handlers/blob.js +3 -3
  68. package/dist/handlers/command.js +6 -6
  69. package/dist/handlers/config.js +6 -6
  70. package/dist/handlers/credential.js +7 -7
  71. package/dist/handlers/debug.js +6 -6
  72. package/dist/handlers/event.js +7 -7
  73. package/dist/handlers/experimental/browser-tunnel.js +4 -4
  74. package/dist/handlers/flag.js +6 -6
  75. package/dist/handlers/form.js +6 -6
  76. package/dist/handlers/fs.js +8 -8
  77. package/dist/handlers/generate.js +6 -6
  78. package/dist/handlers/integration.js +6 -6
  79. package/dist/handlers/job.js +2 -2
  80. package/dist/handlers/location.js +6 -6
  81. package/dist/handlers/machine.js +1 -1
  82. package/dist/handlers/mcp.js +8 -8
  83. package/dist/handlers/media.js +2 -2
  84. package/dist/handlers/message.js +7 -7
  85. package/dist/handlers/migration.js +6 -6
  86. package/dist/handlers/model.js +6 -6
  87. package/dist/handlers/permission.js +6 -6
  88. package/dist/handlers/persistent-pty.d.ts +1 -1
  89. package/dist/handlers/persistent-pty.js +20 -20
  90. package/dist/handlers/plugin.js +6 -6
  91. package/dist/handlers/project.js +6 -6
  92. package/dist/handlers/provider.js +6 -6
  93. package/dist/handlers/pty-socket.js +1 -1
  94. package/dist/handlers/pty.js +8 -8
  95. package/dist/handlers/push.js +1 -1
  96. package/dist/handlers/reference.js +6 -6
  97. package/dist/handlers/rpc.js +6 -6
  98. package/dist/handlers/server.js +9 -9
  99. package/dist/handlers/session-error.js +1 -1
  100. package/dist/handlers/session.js +7 -7
  101. package/dist/handlers/shell.js +6 -6
  102. package/dist/handlers/skill.js +6 -6
  103. package/dist/handlers/space.d.ts +35 -25
  104. package/dist/handlers/space.js +2 -2
  105. package/dist/handlers/usage.js +6 -6
  106. package/dist/handlers/vcs.js +6 -6
  107. package/dist/handlers/voice.js +6 -6
  108. package/dist/handlers/websearch.js +6 -6
  109. package/dist/handlers/worktree.js +6 -6
  110. package/dist/handlers.js +58 -58
  111. package/dist/location.js +2 -2
  112. package/dist/media-uri.js +1 -1
  113. package/dist/middleware/authorization.js +2 -2
  114. package/dist/middleware/defect-response.js +1 -1
  115. package/dist/middleware/form-location.js +3 -3
  116. package/dist/middleware/schema-error.js +1 -1
  117. package/dist/middleware/session-location.js +3 -3
  118. package/dist/pairing.js +5 -5
  119. package/dist/process.js +68 -68
  120. package/dist/range.js +1 -1
  121. package/dist/request-site.js +2 -2
  122. package/dist/request-tracing.js +1 -1
  123. package/dist/routes.d.ts +1 -1
  124. package/dist/routes.js +62 -62
  125. package/dist/server-info.js +3 -3
  126. package/dist/service-status.js +3 -3
  127. package/dist/space-store.d.ts +22 -9
  128. package/dist/space-store.js +5 -5
  129. package/dist/workerd.d.ts +1 -1
  130. package/dist/workerd.js +67 -67
  131. package/package.json +8 -8
  132. package/dist/chunks/cors-5fn432p6.js +0 -44
  133. /package/dist/chunks/{cors-017ycvbx.js → service-status-017ycvbx.js} +0 -0
  134. /package/dist/chunks/{cors-9rqn6x4v.js → service-status-9rqn6x4v.js} +0 -0
  135. /package/dist/chunks/{cors-bd8755ek.js → service-status-bd8755ek.js} +0 -0
  136. /package/dist/chunks/{cors-n26yr6pw.js → service-status-n26yr6pw.js} +0 -0
  137. /package/dist/chunks/{cors-q187pxxd.js → service-status-q187pxxd.js} +0 -0
  138. /package/dist/chunks/{cors-q4bn6dy8.js → service-status-q4bn6dy8.js} +0 -0
  139. /package/dist/chunks/{cors-qpnw2qd1.js → service-status-qpnw2qd1.js} +0 -0
  140. /package/dist/chunks/{cors-rqgv9x42.js → service-status-rqgv9x42.js} +0 -0
  141. /package/dist/chunks/{cors-xthc02cw.js → service-status-xthc02cw.js} +0 -0
  142. /package/dist/chunks/{cors-yc7nft6q.js → service-status-yc7nft6q.js} +0 -0
@@ -1,42 +1,42 @@
1
1
  import {
2
2
  layer4
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  formLocationLayer2
6
- } from "./cors-ca564221.js";
6
+ } from "./service-status-ca564221.js";
7
7
  import {
8
8
  sessionLocationLayer2
9
- } from "./cors-ehyp3zqd.js";
9
+ } from "./service-status-ehyp3zqd.js";
10
10
  import {
11
11
  Api2
12
- } from "./cors-whvq72as.js";
12
+ } from "./service-status-jhs8rzvk.js";
13
13
  import {
14
14
  Config2
15
- } from "./cors-j4at0y5c.js";
15
+ } from "./service-status-j4at0y5c.js";
16
16
  import {
17
- node2
18
- } from "./cors-w6xb5z15.js";
17
+ node3
18
+ } from "./service-status-fmkwyf76.js";
19
19
  import {
20
20
  CorsConfig2
21
- } from "./cors-q4bn6dy8.js";
21
+ } from "./service-status-q4bn6dy8.js";
22
22
  import {
23
- layer2
24
- } from "./cors-5pdfedjd.js";
23
+ layer3
24
+ } from "./service-status-3te71694.js";
25
25
  import {
26
- node3
27
- } from "./cors-v9t81kwn.js";
26
+ node2
27
+ } from "./service-status-mzs0n5xz.js";
28
28
  import {
29
29
  handlers2
30
- } from "./cors-fa6nnfxm.js";
30
+ } from "./service-status-4z6dd0zp.js";
31
31
  import {
32
32
  authorizationLayer2
33
- } from "./cors-29nx48hm.js";
33
+ } from "./service-status-29nx48hm.js";
34
34
  import {
35
35
  schemaErrorLayer2
36
- } from "./cors-bd8755ek.js";
36
+ } from "./service-status-bd8755ek.js";
37
37
  import {
38
38
  defectResponseLayer2
39
- } from "./cors-n26yr6pw.js";
39
+ } from "./service-status-n26yr6pw.js";
40
40
 
41
41
  // src/routes.ts
42
42
  import { Database } from "@opencode/core/database/database";
@@ -120,8 +120,8 @@ var applicationServiceNodes = [
120
120
  BrowserTunnelGateway.node,
121
121
  Credential.node,
122
122
  WellKnown.node,
123
- node3,
124
123
  node2,
124
+ node3,
125
125
  LocationServiceMap.node,
126
126
  LocationActivity.node,
127
127
  SessionRestart.node,
@@ -191,14 +191,11 @@ function makeRoutes(password, options, serviceURLs, overrides, instances) {
191
191
  }
192
192
  }))
193
193
  ];
194
- const build = (overrides) => {
195
- const replacements = [
196
- ...standard,
197
- ...instances ? [Instance.node.replace(instances(() => replacements))] : [],
198
- ...overrides
199
- ];
200
- return AppNodeBuilder.build(applicationServices, replacements);
201
- };
194
+ const build = (overrides) => AppNodeBuilder.build(applicationServices, [
195
+ ...standard,
196
+ ...instances ? [Instance.node.replace(instances)] : [],
197
+ ...overrides
198
+ ]);
202
199
  const serviceLayer = options.simulation ? Layer.unwrap(Effect.gen(function* () {
203
200
  const { simulationReplacements } = yield* Effect.promise(() => import("@opencode/simulation/backend"));
204
201
  const simulation = yield* simulationReplacements({ version: App.make(options.app).version });
@@ -206,7 +203,7 @@ function makeRoutes(password, options, serviceURLs, overrides, instances) {
206
203
  })) : build(overrides);
207
204
  return serviceLayer.pipe(Layer.flatMap((context) => {
208
205
  const services = Layer.succeedContext(context);
209
- const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer2(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
206
+ const requestServices = Layer.merge(Layer.succeedContext(Context.pick(Database.Service, Credential.Service, PermissionSaved.Service, PluginUpdate.Service, Project.Service, WellKnown.Service)(context)), layer3(serviceURLs, Context.get(context, Global.Service).tmp, options.app));
210
207
  const api = HttpApiBuilder.layer(Api2, { openapiPath: "/openapi.json" }).pipe(Layer.provide(handlers2.pipe(Layer.provide(services), Layer.provide(Layer.succeed(CorsConfig2, options)))), Layer.provide(formLocationLayer2), Layer.provide(sessionLocationLayer2), Layer.provide(layer4), Layer.provide(authorizationLayer2), Layer.provide(schemaErrorLayer2), Layer.provide(auth), HttpRouter.provideRequest(requestServices), Layer.merge(defectResponseLayer2), Layer.provideMerge(services), Layer.provideMerge(HttpRouter.layer), Layer.tap((context) => Effect.sync(() => {
211
208
  internal = Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpEffect.toWebHandlerWith(context));
212
209
  })));
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-jhs8rzvk.js";
7
7
 
8
8
  // src/handlers/form.ts
9
9
  import { Form } from "@opencode/core/form";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-jhs8rzvk.js";
7
7
 
8
8
  // src/handlers/agent.ts
9
9
  import { Agent } from "@opencode/core/agent";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  __export
3
- } from "./cors-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/space-store.ts
6
6
  var exports_space_store = {};
7
7
  __export(exports_space_store, {
8
8
  BatchSize: () => BatchSize2,
9
9
  PurgeInterval: () => PurgeInterval2,
10
- Service: () => Service2,
10
+ Service: () => Service5,
11
11
  SpaceStore: () => exports_space_store,
12
12
  extension: () => extension2,
13
- node: () => node2
13
+ node: () => node3
14
14
  });
15
15
  import { SpaceRows } from "@opencode/core/space";
16
16
  import { Database } from "@opencode/core/database/database";
@@ -22,28 +22,22 @@ import { Clock, Context, Effect, Layer } from "effect";
22
22
  var BatchSize2 = 500;
23
23
  var PurgeInterval2 = 64;
24
24
 
25
- class Service2 extends Context.Service()("@opencode/server/SpaceStore") {
25
+ class Service5 extends Context.Service()("@opencode/server/SpaceStore") {
26
26
  }
27
- var layer = Layer.effect(Service2, Effect.gen(function* () {
27
+ var layer = Layer.effect(Service5, Effect.gen(function* () {
28
28
  const db = (yield* Database.Service).db;
29
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
30
  const listeners = new Array;
31
31
  const locks = KeyedMutex.makeUnsafe();
32
32
  const deletes = new Map;
33
- const tombstoned = (space) => Effect.suspend(() => {
34
- const since = (deletes.get(space) ?? PurgeInterval2 - 1) + 1;
33
+ const tombstoned = (space, count) => Effect.suspend(() => {
34
+ if (count === 0)
35
+ return Effect.void;
36
+ const since = (deletes.get(space) ?? PurgeInterval2 - 1) + count;
35
37
  if (since < PurgeInterval2)
36
38
  return Effect.sync(() => deletes.set(space, since));
37
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 })));
38
40
  });
39
- const commit = (space, write) => locks.withLock(space)(Effect.uninterruptible(Effect.gen(function* () {
40
- const data = yield* write;
41
- if (!data)
42
- return;
43
- const committed = change(data, yield* Clock.currentTimeMillis);
44
- yield* Effect.forEach(listeners, (listener) => listener(committed), { discard: true });
45
- yield* Effect.forEach(streams.values(), (stream) => deliver(stream, committed), { discard: true });
46
- })));
47
41
  const streams = new Map;
48
42
  const deliver = (stream, change) => Effect.suspend(() => {
49
43
  const subscription = stream.spaces.get(change.data.space);
@@ -55,57 +49,73 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
55
49
  }
56
50
  return change.data.revision > subscription.covered ? stream.send(change) : Effect.void;
57
51
  });
58
- const snapshot = (space, since, head) => Effect.gen(function* () {
59
- const rows = yield* SpaceRows.live(db, space, since, head, BatchSize2 + 1);
60
- const more = rows.length > BatchSize2;
61
- const kept = rows.slice(0, BatchSize2);
62
- const revision = more ? kept.at(-1)?.revision ?? head : head;
63
- const next = more ? `${epoch}.${revision}.${head}` : (yield* SpaceRows.changes(db, space, head, 1)).length ? `${epoch}.${head}` : undefined;
64
- const data = { space, epoch, revision, entries: entries(kept), cursor: `${epoch}.${revision}`, next };
65
- const page = since === 0 ? { type: "snapshot", ...data } : { type: "delta", ...data, deleted: [] };
66
- return page;
67
- });
68
- const delta = (space, since, head) => Effect.gen(function* () {
69
- const rows = yield* SpaceRows.changes(db, space, since, BatchSize2 + 1);
70
- if ((yield* SpaceRows.floor(db, space)) > since)
71
- return yield* snapshot(space, 0, head);
72
- const kept = rows.slice(0, BatchSize2);
73
- const revision = kept.at(-1)?.revision ?? since;
74
- const page = {
75
- type: "delta",
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",
76
77
  space,
77
78
  epoch,
78
79
  revision,
79
80
  entries: entries(kept),
80
- deleted: deleted(kept),
81
81
  cursor: `${epoch}.${revision}`,
82
- next: rows.length > BatchSize2 ? `${epoch}.${revision}` : undefined
82
+ next: more ? `${epoch}.${revision}.${until}` : read.head > until ? `${epoch}.${until}` : undefined
83
83
  };
84
- return page;
84
+ return snapshot;
85
85
  });
86
- const catchUp = (space, cursor) => Effect.gen(function* () {
86
+ const catchUp = (space, cursor, budget) => Effect.gen(function* () {
87
87
  const position = parse(epoch, cursor);
88
88
  const created = yield* Clock.currentTimeMillis;
89
- const resync = {
89
+ const resync = (read) => ({
90
90
  covered: 0,
91
+ read,
91
92
  events: [{ id: Event.ID.create(), created, type: Space.Event.Resync.type, data: { space } }]
92
- };
93
- if (!position || position.head !== undefined || position.since > (yield* SpaceRows.head(db, space)))
94
- return resync;
95
- const rows = yield* SpaceRows.changes(db, space, position.since, BatchSize2 + 1);
96
- if (rows.length > BatchSize2 || (yield* SpaceRows.floor(db, space)) > position.since)
97
- return resync;
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);
98
99
  return {
99
- covered: rows.at(-1)?.revision ?? position.since,
100
- events: rows.map((row) => change(row.value === null ? { space, key: row.key, revision: row.revision } : { space, key: row.key, value: row.value, revision: row.revision }, created))
100
+ covered: read.rows.at(-1)?.revision ?? position.since,
101
+ read: read.rows.length,
102
+ events: read.rows.map((row) => change(space, row, created))
101
103
  };
102
104
  });
103
- return Service2.of({
104
- set: Effect.fn("SpaceStore.set")(function* (space, key, value) {
105
- yield* commit(space, SpaceRows.set(db, space, key, value).pipe(Effect.map((revision) => ({ space, key, value, revision }))));
106
- }),
107
- remove: Effect.fn("SpaceStore.remove")(function* (space, key) {
108
- yield* commit(space, SpaceRows.remove(db, space, key).pipe(Effect.flatMap((revision) => revision === undefined ? Effect.undefined : tombstoned(space).pipe(Effect.as({ space, key, revision })))));
105
+ return Service5.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
+ })));
109
119
  }),
110
120
  get epoch() {
111
121
  return epoch;
@@ -113,16 +123,17 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
113
123
  resetEpoch: Effect.fn("SpaceStore.resetEpoch")(function* () {
114
124
  epoch = yield* SpaceRows.resetEpoch(db);
115
125
  })(),
116
- sync: Effect.fn("SpaceStore.sync")(function* (space, cursor) {
117
- const head = yield* SpaceRows.head(db, space);
118
- const position = cursor === undefined ? undefined : parse(epoch, cursor);
119
- if (!position || position.since > head)
120
- return yield* snapshot(space, 0, head);
121
- if (position.head === undefined)
122
- return yield* delta(space, position.since, head);
123
- if (position.head > head || position.since > position.head)
124
- return yield* snapshot(space, 0, head);
125
- return yield* snapshot(space, position.since, position.head);
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;
126
137
  }),
127
138
  attach: (id, send) => Effect.acquireRelease(Effect.sync(() => streams.set(id, { send, spaces: new Map })), () => Effect.sync(() => streams.delete(id))).pipe(Effect.asVoid),
128
139
  subscribe: Effect.fn("SpaceStore.subscribe")(function* (id, requests) {
@@ -134,9 +145,11 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
134
145
  stream.spaces.set(request.space, subscription);
135
146
  return { request, subscription };
136
147
  });
148
+ let budget = BatchSize2;
137
149
  yield* Effect.forEach(subscriptions, ({ request, subscription }) => Effect.gen(function* () {
138
150
  const current = () => stream.spaces.get(request.space) === subscription;
139
- const first = yield* catchUp(request.space, request.cursor);
151
+ const first = yield* catchUp(request.space, request.cursor, budget);
152
+ budget = Math.max(0, budget - first.read);
140
153
  if (!subscription.pending)
141
154
  return;
142
155
  subscription.covered = first.covered;
@@ -170,13 +183,23 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
170
183
  })
171
184
  });
172
185
  }));
173
- var node2 = makeGlobalNode({ service: Service2, layer, deps: [Database.node] });
186
+ var node3 = makeGlobalNode({ service: Service5, layer, deps: [Database.node] });
174
187
  var extension2 = Effect.gen(function* () {
175
- const store = yield* Service2;
188
+ const store = yield* Service5;
176
189
  return { open: (stream, send) => store.attach(stream, send) };
177
190
  });
178
- function change(data, created) {
179
- return "value" in data ? { id: Event.ID.create(), created, type: Space.Event.Updated.type, data } : { id: Event.ID.create(), created, type: Space.Event.Deleted.type, data };
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
+ };
180
203
  }
181
204
  function entries(rows) {
182
205
  return rows.flatMap((row) => row.value === null ? [] : [{ key: row.key, value: row.value }]);
@@ -193,4 +216,4 @@ function parse(epoch, cursor) {
193
216
  return { since: Number(parts[0]), head: parts[1] === undefined ? undefined : Number(parts[1]) };
194
217
  }
195
218
 
196
- export { BatchSize2, PurgeInterval2, Service2, node2, extension2, exports_space_store };
219
+ export { BatchSize2, PurgeInterval2, Service5, node3, extension2, exports_space_store };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-jhs8rzvk.js";
7
7
 
8
8
  // src/handlers/skill.ts
9
9
  import { Skill } from "@opencode/core/skill";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Api2
3
- } from "./cors-whvq72as.js";
3
+ } from "./service-status-jhs8rzvk.js";
4
4
  import {
5
- Service4,
5
+ Service2,
6
6
  frame2
7
- } from "./cors-z5c20bjd.js";
7
+ } from "./service-status-hs3dbf8w.js";
8
8
 
9
9
  // src/handlers/event.ts
10
10
  import { Event } from "@opencode/schema/event";
@@ -12,7 +12,7 @@ import { Effect, Stream } from "effect";
12
12
  import { HttpServerResponse } from "effect/http";
13
13
  import { HttpApiBuilder } from "effect/http-api";
14
14
  var EventHandler2 = HttpApiBuilder.group(Api2, "server.event", (handlers) => Effect.gen(function* () {
15
- const feed = yield* Service4;
15
+ const feed = yield* Service2;
16
16
  return handlers.handleRaw("event.subscribe", (ctx) => Effect.gen(function* () {
17
17
  const output = Stream.unwrap(feed.subscribe(ctx.query.types).pipe(Effect.map((subscription) => Stream.make(frame2({
18
18
  id: Event.ID.create(),
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  __export
3
- } from "./cors-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: () => Service2,
11
11
  SubscriberCapacity: () => SubscriberCapacity2,
12
12
  SubscriberOverflowError: () => SubscriberOverflowError2,
13
13
  frame: () => frame2,
14
- layer: () => layer3,
14
+ layer: () => layer2,
15
15
  make: () => make4
16
16
  });
17
17
  import { Bus } from "@opencode/core/bus";
@@ -30,7 +30,7 @@ class EncodingError2 extends Schema.TaggedError()("EventFeed.EncodingError", {
30
30
  }) {
31
31
  }
32
32
 
33
- class Service4 extends Context.Service()("@opencode/server/EventFeed") {
33
+ class Service2 extends Context.Service()("@opencode/server/EventFeed") {
34
34
  }
35
35
  function frame2(event) {
36
36
  return `data: ${JSON.stringify(event)}
@@ -75,7 +75,7 @@ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
75
75
  });
76
76
  const unsubscribe = yield* observe(publish);
77
77
  yield* Effect.addFinalizer(() => unsubscribe);
78
- return Service4.of({
78
+ return Service2.of({
79
79
  subscribe: (types) => Effect.gen(function* () {
80
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
81
  const id = crypto.randomUUID();
@@ -93,9 +93,9 @@ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
93
93
  })
94
94
  });
95
95
  });
96
- var layer3 = (...extensions) => Layer.effect(Service4, Effect.gen(function* () {
96
+ var layer2 = (...extensions) => Layer.effect(Service2, Effect.gen(function* () {
97
97
  const bus = yield* Bus.Service;
98
98
  return yield* make4(bus.listen, { extensions: yield* Effect.all(extensions) });
99
99
  }));
100
100
 
101
- export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service4, frame2, make4, layer3, exports_event_feed };
101
+ export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service2, frame2, make4, layer2, exports_event_feed };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-jhs8rzvk.js";
7
7
 
8
8
  // src/handlers/websearch.ts
9
9
  import { WebSearch } from "@opencode/core/websearch";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./cors-9rqn6x4v.js";
3
+ } from "./service-status-9rqn6x4v.js";
4
4
 
5
5
  // src/auth.ts
6
6
  var exports_auth = {};
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./cors-rqgv9x42.js";
3
+ } from "./service-status-rqgv9x42.js";
4
4
  import {
5
5
  locationErrors2,
6
6
  response2,
7
7
  requestRef2
8
- } from "./cors-br4x4prt.js";
8
+ } from "./service-status-br4x4prt.js";
9
9
 
10
10
  // src/handlers/artifact.ts
11
11
  import { Artifact } from "@opencode/core/artifact";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  LocationMiddleware2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  FormLocationMiddleware2
6
- } from "./cors-ca564221.js";
6
+ } from "./service-status-ca564221.js";
7
7
  import {
8
8
  SessionLocationMiddleware2
9
- } from "./cors-ehyp3zqd.js";
9
+ } from "./service-status-ehyp3zqd.js";
10
10
 
11
11
  // src/api.ts
12
12
  import { makeDefaultApi } from "@opencode/protocol/api";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  CorsConfig2,
3
3
  isAllowedRequestOrigin2
4
- } from "./cors-q4bn6dy8.js";
4
+ } from "./service-status-q4bn6dy8.js";
5
5
  import {
6
6
  locationErrors2,
7
7
  requestRef2
8
- } from "./cors-br4x4prt.js";
8
+ } from "./service-status-br4x4prt.js";
9
9
 
10
10
  // src/handlers/experimental/browser-tunnel.ts
11
11
  import { NodeHttpServerRequest } from "@effect/platform-node";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  missingSession2,
3
3
  failedMessageDecode2
4
- } from "./cors-rqgv9x42.js";
4
+ } from "./service-status-rqgv9x42.js";
5
5
  import {
6
6
  Api2
7
- } from "./cors-whvq72as.js";
7
+ } from "./service-status-jhs8rzvk.js";
8
8
  import {
9
9
  wantsMediaRefs2
10
- } from "./cors-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
  isAllowedRequestOrigin2
3
- } from "./cors-q4bn6dy8.js";
3
+ } from "./service-status-q4bn6dy8.js";
4
4
  import {
5
5
  __export
6
- } from "./cors-9rqn6x4v.js";
6
+ } from "./service-status-9rqn6x4v.js";
7
7
 
8
8
  // src/request-site.ts
9
9
  var exports_request_site = {};
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  __export
3
- } from "./cors-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: () => Service5,
10
- node: () => node3
9
+ Service: () => Service4,
10
+ node: () => node2
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 Service5 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(Service5, 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 Service5.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(Service5, Effect.gen(function* () {
30
30
  })
31
31
  });
32
32
  }));
33
- var node3 = makeGlobalNode({ service: Service5, layer, deps: [] });
33
+ var node2 = makeGlobalNode({ service: Service4, layer, deps: [] });
34
34
 
35
- export { Service5, node3, exports_pairing };
35
+ export { Service4, node2, exports_pairing };
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  requestRef2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-jhs8rzvk.js";
7
7
 
8
8
  // src/handlers/debug.ts
9
9
  import { LocationServiceMap } from "@opencode/core/location-service-map";
10
10
  import { InvalidRequestError, UnknownError } from "@opencode/protocol/errors";
11
11
  import { Global } from "@opencode/util/global";
12
12
  import { HeapSnapshot } from "@opencode/util/heap-snapshot";
13
- import { Effect, Option, RcMap } from "effect";
13
+ import { Effect, Option } from "effect";
14
14
  import { HttpApiBuilder } from "effect/http-api";
15
15
  import path from "node:path";
16
16
  var DebugHandler2 = HttpApiBuilder.group(Api2, "server.debug", (handlers) => Effect.gen(function* () {
@@ -28,7 +28,7 @@ var DebugHandler2 = HttpApiBuilder.group(Api2, "server.debug", (handlers) => Eff
28
28
  }));
29
29
  })).handle("debug.location", Effect.fn(function* () {
30
30
  const locations = Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service));
31
- return Array.from(yield* RcMap.keys(locations.rcMap));
31
+ return yield* locations.keys;
32
32
  })).handle("debug.location.evict", Effect.fn(function* (ctx) {
33
33
  const locations = Option.getOrThrow(yield* Effect.serviceOption(LocationServiceMap.Service));
34
34
  yield* locations.invalidate(requestRef2(ctx.request));
@@ -4,16 +4,16 @@ import {
4
4
  missingMessage2,
5
5
  failedMessageDecode2,
6
6
  failedSnapshot2
7
- } from "./cors-rqgv9x42.js";
7
+ } from "./service-status-rqgv9x42.js";
8
8
  import {
9
9
  locationErrors2
10
- } from "./cors-br4x4prt.js";
10
+ } from "./service-status-br4x4prt.js";
11
11
  import {
12
12
  Api2
13
- } from "./cors-whvq72as.js";
13
+ } from "./service-status-jhs8rzvk.js";
14
14
  import {
15
15
  wantsMediaRefs2
16
- } from "./cors-xthc02cw.js";
16
+ } from "./service-status-xthc02cw.js";
17
17
 
18
18
  // src/handlers/session.ts
19
19
  import { Instance } from "@opencode/core/instance/service";