@opencode/server 0.0.0-dev-1361 → 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 (141) hide show
  1. package/dist/api.js +5 -5
  2. package/dist/auth.js +1 -1
  3. package/dist/chunks/{cors-ca564221.js → service-status-0dfmev2z.js} +1 -1
  4. package/dist/chunks/{cors-hb1ty1t1.js → service-status-10r1zt22.js} +4 -4
  5. package/dist/chunks/{cors-29nx48hm.js → service-status-29nx48hm.js} +1 -1
  6. package/dist/chunks/{cors-10sj2tcf.js → service-status-2h3x7256.js} +1 -1
  7. package/dist/chunks/{cors-rgbnpstw.js → service-status-341zm3rs.js} +2 -2
  8. package/dist/chunks/{cors-nvb61mgq.js → service-status-4gs63nyp.js} +4 -4
  9. package/dist/chunks/{cors-fa6nnfxm.js → service-status-4gt38746.js} +37 -37
  10. package/dist/chunks/{cors-6cmsxt3d.js → service-status-4rg1tmcj.js} +6 -6
  11. package/dist/chunks/{cors-enx9e1dz.js → service-status-4th25279.js} +4 -4
  12. package/dist/chunks/{cors-g23ffrnz.js → service-status-50kbksvb.js} +2 -2
  13. package/dist/chunks/{cors-3cx4ac5j.js → service-status-5h6n6h4q.js} +20 -23
  14. package/dist/chunks/{cors-5pdfedjd.js → service-status-5pdfedjd.js} +1 -1
  15. package/dist/chunks/{cors-v9t81kwn.js → service-status-69weg9qz.js} +7 -7
  16. package/dist/chunks/{cors-6pm6ek88.js → service-status-6pm6ek88.js} +1 -1
  17. package/dist/chunks/{cors-br4x4prt.js → service-status-72bf7qt9.js} +3 -3
  18. package/dist/chunks/{cors-z5c20bjd.js → service-status-7p3x8m34.js} +7 -7
  19. package/dist/chunks/{cors-n2zyxnzr.js → service-status-7tv8nec1.js} +1 -1
  20. package/dist/chunks/{cors-wsvmph03.js → service-status-844nmnmk.js} +2 -2
  21. package/dist/chunks/{cors-8sb6qqpn.js → service-status-8sb6qqpn.js} +1 -1
  22. package/dist/chunks/{cors-whvq72as.js → service-status-8y4d9f30.js} +3 -3
  23. package/dist/chunks/{cors-1z9qd4y2.js → service-status-9vfv9n1y.js} +4 -4
  24. package/dist/chunks/{cors-csnx1nj3.js → service-status-bcs2rr9e.js} +2 -2
  25. package/dist/chunks/{cors-rjhxbsc4.js → service-status-cgcw2b0e.js} +2 -2
  26. package/dist/chunks/{cors-djr0jy89.js → service-status-djr0jy89.js} +1 -1
  27. package/dist/chunks/{cors-e6e4kz0w.js → service-status-e6e4kz0w.js} +1 -1
  28. package/dist/chunks/{cors-g4964mny.js → service-status-evw6vf0s.js} +3 -3
  29. package/dist/chunks/{cors-7dkb5ks8.js → service-status-fcw485c9.js} +2 -2
  30. package/dist/chunks/{cors-am27j67f.js → service-status-fegnxd42.js} +1 -1
  31. package/dist/chunks/{cors-ehyp3zqd.js → service-status-fsvp99pe.js} +1 -1
  32. package/dist/chunks/{cors-k74zefsg.js → service-status-ggw25rqf.js} +1 -1
  33. package/dist/chunks/{cors-em7ed65n.js → service-status-gqstb6bx.js} +2 -2
  34. package/dist/chunks/{cors-j4at0y5c.js → service-status-j4at0y5c.js} +1 -1
  35. package/dist/chunks/{cors-8xdajgpr.js → service-status-j605n900.js} +2 -2
  36. package/dist/chunks/{cors-javgytnb.js → service-status-j6y32kmq.js} +2 -2
  37. package/dist/chunks/{cors-8nezxn08.js → service-status-k12h8tw9.js} +1 -1
  38. package/dist/chunks/{cors-f3gr6hfv.js → service-status-kc553r92.js} +2 -2
  39. package/dist/chunks/{cors-w6xb5z15.js → service-status-mj1ewmp1.js} +83 -60
  40. package/dist/chunks/{cors-myqk22k5.js → service-status-myqk22k5.js} +2 -2
  41. package/dist/chunks/{cors-p3bbq7g3.js → service-status-ntf3tw9k.js} +1 -1
  42. package/dist/chunks/{cors-qssmdh31.js → service-status-pp5985xb.js} +4 -4
  43. package/dist/chunks/{cors-8qsq6tbs.js → service-status-qcnb494j.js} +2 -2
  44. package/dist/chunks/{cors-yc92za0p.js → service-status-qgjb3f4w.js} +2 -2
  45. package/dist/chunks/{cors-msvebcy2.js → service-status-qw2j92v5.js} +5 -5
  46. package/dist/chunks/{cors-0wjm8gvs.js → service-status-r5yb7twv.js} +2 -2
  47. package/dist/chunks/{cors-3xkwxcke.js → service-status-r9w3a44p.js} +2 -2
  48. package/dist/chunks/{cors-s0zgx365.js → service-status-sn8sqewc.js} +2 -2
  49. package/dist/chunks/{cors-t32e1bbt.js → service-status-t32e1bbt.js} +1 -1
  50. package/dist/chunks/{cors-exwy1kbj.js → service-status-tktas153.js} +2 -2
  51. package/dist/chunks/{cors-ka2mtp6f.js → service-status-vyjhrbg0.js} +2 -2
  52. package/dist/chunks/{cors-sv3a4xc1.js → service-status-w7n3bfa8.js} +13 -13
  53. package/dist/chunks/{cors-kmwr1xw9.js → service-status-ws2ckpmb.js} +3 -3
  54. package/dist/chunks/{cors-x2qy7jg1.js → service-status-x2qy7jg1.js} +1 -1
  55. package/dist/chunks/{cors-5fn432p6.js → service-status-xw05m515.js} +17 -12
  56. package/dist/chunks/{cors-2tmcamrc.js → service-status-yvy5qft7.js} +2 -2
  57. package/dist/chunks/{cors-9hynp6rm.js → service-status-z564cb4b.js} +2 -2
  58. package/dist/chunks/{cors-prwd5gwt.js → service-status-zmrq0y42.js} +2 -2
  59. package/dist/chunks/{cors-qq3f8fnn.js → service-status-zs3a96ke.js} +2 -2
  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 +65 -65
  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 +4 -4
  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 +3 -3
  119. package/dist/process.js +66 -66
  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 +1 -1
  126. package/dist/service-status.js +1 -1
  127. package/dist/space-store.d.ts +22 -9
  128. package/dist/space-store.js +1 -1
  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-017ycvbx.js → service-status-017ycvbx.js} +0 -0
  133. /package/dist/chunks/{cors-9rqn6x4v.js → service-status-9rqn6x4v.js} +0 -0
  134. /package/dist/chunks/{cors-bd8755ek.js → service-status-bd8755ek.js} +0 -0
  135. /package/dist/chunks/{cors-n26yr6pw.js → service-status-n26yr6pw.js} +0 -0
  136. /package/dist/chunks/{cors-q187pxxd.js → service-status-q187pxxd.js} +0 -0
  137. /package/dist/chunks/{cors-q4bn6dy8.js → service-status-q4bn6dy8.js} +0 -0
  138. /package/dist/chunks/{cors-qpnw2qd1.js → service-status-qpnw2qd1.js} +0 -0
  139. /package/dist/chunks/{cors-rqgv9x42.js → service-status-rqgv9x42.js} +0 -0
  140. /package/dist/chunks/{cors-xthc02cw.js → service-status-xthc02cw.js} +0 -0
  141. /package/dist/chunks/{cors-yc7nft6q.js → service-status-yc7nft6q.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CONTENT_SECURITY_POLICY2,
3
3
  disposition2
4
- } from "./cors-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,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/service-status.ts
6
6
  var exports_service_status = {};
@@ -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-8y4d9f30.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
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-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 "./cors-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 "./cors-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 "./cors-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 "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-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 "./cors-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 "./cors-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
  import {
5
5
  requireConnectable2
6
- } from "./cors-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 "./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-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 "./cors-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 "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/shell.ts
9
9
  import { Shell } from "@opencode/core/shell";
@@ -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/space-store.ts
6
6
  var exports_space_store = {};
@@ -30,20 +30,14 @@ var layer = Layer.effect(Service2, Effect.gen(function* () {
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
105
  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 })))));
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;
@@ -175,8 +188,18 @@ var extension2 = Effect.gen(function* () {
175
188
  const store = yield* Service2;
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 }]);
@@ -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,6 +1,6 @@
1
1
  import {
2
2
  Api2
3
- } from "./cors-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
 
5
5
  // src/handlers/location.ts
6
6
  import { Location } from "@opencode/core/location";
@@ -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-72bf7qt9.js";
11
11
  import {
12
12
  Api2
13
- } from "./cors-whvq72as.js";
13
+ } from "./service-status-8y4d9f30.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";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.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-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/provider.ts
9
9
  import { Provider } from "@opencode/core/provider";
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  isAllowedCorsOrigin2
3
- } from "./cors-q4bn6dy8.js";
3
+ } from "./service-status-q4bn6dy8.js";
4
4
  import {
5
5
  middleware2
6
- } from "./cors-myqk22k5.js";
6
+ } from "./service-status-myqk22k5.js";
7
7
  import {
8
8
  withoutParentSpan2
9
- } from "./cors-yc7nft6q.js";
9
+ } from "./service-status-yc7nft6q.js";
10
10
  import {
11
11
  createRoutes2
12
- } from "./cors-3cx4ac5j.js";
12
+ } from "./service-status-5h6n6h4q.js";
13
13
  import {
14
14
  __export
15
- } from "./cors-9rqn6x4v.js";
15
+ } from "./service-status-9rqn6x4v.js";
16
16
 
17
17
  // src/fetch.ts
18
18
  var exports_fetch = {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/vcs.ts
9
9
  import { Vcs } from "@opencode/core/vcs";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/skill.ts
9
9
  import { Skill } from "@opencode/core/skill";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/model.ts
9
9
  import { Model } from "@opencode/core/model";
@@ -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/content-headers.ts
6
6
  var exports_content_headers = {};
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./cors-br4x4prt.js";
3
+ } from "./service-status-72bf7qt9.js";
4
4
  import {
5
5
  Api2
6
- } from "./cors-whvq72as.js";
6
+ } from "./service-status-8y4d9f30.js";
7
7
 
8
8
  // src/handlers/agent.ts
9
9
  import { Agent } from "@opencode/core/agent";
@@ -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-72bf7qt9.js";
9
9
 
10
10
  // src/handlers/experimental/browser-tunnel.ts
11
11
  import { NodeHttpServerRequest } from "@effect/platform-node";
@@ -1,41 +1,41 @@
1
1
  import {
2
2
  Api2
3
- } from "./cors-whvq72as.js";
3
+ } from "./service-status-8y4d9f30.js";
4
4
  import {
5
5
  CorsConfig2,
6
6
  isAllowedRequestOrigin2
7
- } from "./cors-q4bn6dy8.js";
7
+ } from "./service-status-q4bn6dy8.js";
8
8
  import {
9
9
  makeArtifact2
10
- } from "./cors-javgytnb.js";
10
+ } from "./service-status-j6y32kmq.js";
11
11
  import {
12
12
  makeBlobGet2
13
- } from "./cors-g23ffrnz.js";
13
+ } from "./service-status-50kbksvb.js";
14
14
  import {
15
15
  makeBrowserTunnel2
16
- } from "./cors-ka2mtp6f.js";
16
+ } from "./service-status-vyjhrbg0.js";
17
17
  import {
18
18
  makeAutomation2
19
- } from "./cors-6pm6ek88.js";
19
+ } from "./service-status-6pm6ek88.js";
20
20
  import {
21
21
  makeJob2
22
- } from "./cors-x2qy7jg1.js";
22
+ } from "./service-status-x2qy7jg1.js";
23
23
  import {
24
24
  makeMachineLink2,
25
25
  makeMachine2
26
- } from "./cors-017ycvbx.js";
26
+ } from "./service-status-017ycvbx.js";
27
27
  import {
28
28
  makeMediaGet2
29
- } from "./cors-djr0jy89.js";
29
+ } from "./service-status-djr0jy89.js";
30
30
  import {
31
31
  makePush2
32
- } from "./cors-qpnw2qd1.js";
32
+ } from "./service-status-qpnw2qd1.js";
33
33
  import {
34
34
  makeSpace2
35
- } from "./cors-5fn432p6.js";
35
+ } from "./service-status-xw05m515.js";
36
36
  import {
37
37
  runPtySocket2
38
- } from "./cors-q187pxxd.js";
38
+ } from "./service-status-q187pxxd.js";
39
39
 
40
40
  // src/handlers/persistent-pty.ts
41
41
  import { PersistentPty } from "@opencode/core/persistent-pty";
@@ -69,7 +69,7 @@ var PersistentPtyHandler2 = HttpApiBuilder.group(Api2, "server.experimental", (h
69
69
  const machineLink = yield* makeMachineLink2;
70
70
  const browserTunnel = yield* makeBrowserTunnel2;
71
71
  const push = yield* makePush2;
72
- return handlers.handleRaw("media.get", (ctx) => mediaGet(ctx.params.hash, ctx.request)).handleRaw("blob.get", (ctx) => blobGet(ctx.params.id, ctx.request)).handleRaw("browser.tunnel", (ctx) => browserTunnel(ctx.request)).handle("job.list", (ctx) => job.list(ctx.query)).handle("job.cancel", (ctx) => job.cancel(ctx.params.id)).handleRaw("machine.link", (ctx) => machineLink(ctx.request)).handle("machine.list", () => machine.list()).handle("machine.add", (ctx) => machine.add(ctx.payload)).handle("machine.remove", (ctx) => machine.remove(ctx.params.name)).handle("push.get", () => push.get()).handle("push.device.register", (ctx) => push.register(ctx.params.deviceID, ctx.payload)).handle("push.device.remove", (ctx) => push.remove(ctx.params.deviceID)).handle("push.device.update", (ctx) => push.update(ctx.params.deviceID, ctx.payload)).handle("push.device.session.set", (ctx) => push.setDeviceBell(ctx.params.deviceID, ctx.params.sessionID, ctx.payload)).handle("push.device.session.remove", (ctx) => push.removeDeviceBell(ctx.params.deviceID, ctx.params.sessionID)).handle("push.session.set", (ctx) => push.setSessionBell(ctx.params.sessionID, ctx.payload)).handle("push.session.remove", (ctx) => push.removeSessionBell(ctx.params.sessionID)).handle("push.settings.set", (ctx) => push.setSettings(ctx.payload)).handle("space.set", (ctx) => space.set(ctx.params.space, ctx.params.key, ctx.payload.value)).handle("space.delete", (ctx) => space.remove(ctx.params.space, ctx.params.key)).handle("space.sync", (ctx) => space.sync(ctx.params.space, ctx.query.cursor)).handle("space.subscribe", (ctx) => space.subscribe(ctx.payload)).handle("space.unsubscribe", (ctx) => space.unsubscribe(ctx.payload)).handle("space.reset", () => space.reset()).handle("artifacts.providers", (ctx) => artifact.providers(ctx.query, ctx.request)).handle("artifacts.list", (ctx) => artifact.list(ctx.query, ctx.request)).handle("artifacts.create", (ctx) => artifact.create(ctx.query, ctx.payload, ctx.request)).handle("artifacts.get", (ctx) => artifact.get(ctx.params.artifactID, ctx.query, ctx.request)).handle("artifacts.update", (ctx) => artifact.update(ctx.params.artifactID, ctx.query, ctx.payload, ctx.request)).handle("artifacts.delete", (ctx) => artifact.remove(ctx.params.artifactID, ctx.query, ctx.request)).handleRaw("artifacts.view", (ctx) => artifact.view(ctx.params.artifactID, ctx.query, ctx.request)).handle("automation.create", (ctx) => automation.create(ctx.payload)).handle("automation.list", (ctx) => automation.list(ctx.query)).handle("automation.get", (ctx) => automation.get(ctx.params.automationID)).handle("automation.pause", (ctx) => automation.pause(ctx.params.automationID)).handle("automation.resume", (ctx) => automation.resume(ctx.params.automationID)).handle("automation.delete", (ctx) => automation.remove(ctx.params.automationID)).handle("persistentPty.read", Effect.fn(function* (ctx) {
72
+ return handlers.handleRaw("media.get", (ctx) => mediaGet(ctx.params.hash, ctx.request)).handleRaw("blob.get", (ctx) => blobGet(ctx.params.id, ctx.request)).handleRaw("browser.tunnel", (ctx) => browserTunnel(ctx.request)).handle("job.list", (ctx) => job.list(ctx.query)).handle("job.cancel", (ctx) => job.cancel(ctx.params.id)).handleRaw("machine.link", (ctx) => machineLink(ctx.request)).handle("machine.list", () => machine.list()).handle("machine.add", (ctx) => machine.add(ctx.payload)).handle("machine.remove", (ctx) => machine.remove(ctx.params.name)).handle("push.get", () => push.get()).handle("push.device.register", (ctx) => push.register(ctx.params.deviceID, ctx.payload)).handle("push.device.remove", (ctx) => push.remove(ctx.params.deviceID)).handle("push.device.update", (ctx) => push.update(ctx.params.deviceID, ctx.payload)).handle("push.device.session.set", (ctx) => push.setDeviceBell(ctx.params.deviceID, ctx.params.sessionID, ctx.payload)).handle("push.device.session.remove", (ctx) => push.removeDeviceBell(ctx.params.deviceID, ctx.params.sessionID)).handle("push.session.set", (ctx) => push.setSessionBell(ctx.params.sessionID, ctx.payload)).handle("push.session.remove", (ctx) => push.removeSessionBell(ctx.params.sessionID)).handle("push.settings.set", (ctx) => push.setSettings(ctx.payload)).handle("space.write", (ctx) => space.write(ctx.payload.changes)).handle("space.sync", (ctx) => space.sync(ctx.payload.spaces)).handle("space.subscribe", (ctx) => space.subscribe(ctx.payload)).handle("space.unsubscribe", (ctx) => space.unsubscribe(ctx.payload)).handle("space.reset", () => space.reset()).handle("artifacts.providers", (ctx) => artifact.providers(ctx.query, ctx.request)).handle("artifacts.list", (ctx) => artifact.list(ctx.query, ctx.request)).handle("artifacts.create", (ctx) => artifact.create(ctx.query, ctx.payload, ctx.request)).handle("artifacts.get", (ctx) => artifact.get(ctx.params.artifactID, ctx.query, ctx.request)).handle("artifacts.update", (ctx) => artifact.update(ctx.params.artifactID, ctx.query, ctx.payload, ctx.request)).handle("artifacts.delete", (ctx) => artifact.remove(ctx.params.artifactID, ctx.query, ctx.request)).handleRaw("artifacts.view", (ctx) => artifact.view(ctx.params.artifactID, ctx.query, ctx.request)).handle("automation.create", (ctx) => automation.create(ctx.payload)).handle("automation.list", (ctx) => automation.list(ctx.query)).handle("automation.get", (ctx) => automation.get(ctx.params.automationID)).handle("automation.pause", (ctx) => automation.pause(ctx.params.automationID)).handle("automation.resume", (ctx) => automation.resume(ctx.params.automationID)).handle("automation.delete", (ctx) => automation.remove(ctx.params.automationID)).handle("persistentPty.read", Effect.fn(function* (ctx) {
73
73
  return { data: yield* pty.read(ctx.params.sessionID, ctx.query.lines).pipe(mapUnavailable) };
74
74
  })).handle("persistentPty.list", Effect.fn(function* (ctx) {
75
75
  return { data: yield* pty.list(ctx.params.sessionID).pipe(mapUnavailable) };
@@ -1,14 +1,14 @@
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
  sessionInfo2
8
- } from "./cors-br4x4prt.js";
8
+ } from "./service-status-72bf7qt9.js";
9
9
  import {
10
10
  Api2
11
- } from "./cors-whvq72as.js";
11
+ } from "./service-status-8y4d9f30.js";
12
12
 
13
13
  // src/handlers/permission.ts
14
14
  import { Instance } from "@opencode/core/instance/service";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  missingSession2
3
- } from "./cors-rqgv9x42.js";
3
+ } from "./service-status-rqgv9x42.js";
4
4
 
5
5
  // src/handlers/job.ts
6
6
  import { Job } from "@opencode/core/job";