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

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 (144) 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-0wjm8gvs.js → cors-0wjm8gvs.js} +2 -2
  5. package/dist/chunks/{auth-10sj2tcf.js → cors-10sj2tcf.js} +1 -1
  6. package/dist/chunks/{auth-1z9qd4y2.js → cors-1z9qd4y2.js} +4 -4
  7. package/dist/chunks/{auth-29nx48hm.js → cors-29nx48hm.js} +1 -1
  8. package/dist/chunks/{auth-2tmcamrc.js → cors-2tmcamrc.js} +2 -2
  9. package/dist/chunks/{auth-2p8psxn9.js → cors-3cx4ac5j.js} +17 -13
  10. package/dist/chunks/{auth-74nxvsrn.js → cors-3xkwxcke.js} +7 -4
  11. package/dist/chunks/cors-5fn432p6.js +44 -0
  12. package/dist/chunks/{auth-z3e7v67k.js → cors-5pdfedjd.js} +5 -5
  13. package/dist/chunks/{auth-59yyxpa4.js → cors-6cmsxt3d.js} +8 -8
  14. package/dist/chunks/{auth-6pm6ek88.js → cors-6pm6ek88.js} +1 -1
  15. package/dist/chunks/{auth-7dkb5ks8.js → cors-7dkb5ks8.js} +2 -2
  16. package/dist/chunks/{auth-8nezxn08.js → cors-8nezxn08.js} +1 -1
  17. package/dist/chunks/{auth-8qsq6tbs.js → cors-8qsq6tbs.js} +2 -2
  18. package/dist/chunks/{auth-8sb6qqpn.js → cors-8sb6qqpn.js} +1 -1
  19. package/dist/chunks/{auth-8xdajgpr.js → cors-8xdajgpr.js} +2 -2
  20. package/dist/chunks/{auth-9hynp6rm.js → cors-9hynp6rm.js} +2 -2
  21. package/dist/chunks/{auth-am27j67f.js → cors-am27j67f.js} +1 -1
  22. package/dist/chunks/{auth-br4x4prt.js → cors-br4x4prt.js} +1 -1
  23. package/dist/chunks/{auth-ca564221.js → cors-ca564221.js} +1 -1
  24. package/dist/chunks/{auth-csnx1nj3.js → cors-csnx1nj3.js} +2 -2
  25. package/dist/chunks/{auth-djr0jy89.js → cors-djr0jy89.js} +1 -1
  26. package/dist/chunks/{auth-0q7s66m2.js → cors-e6e4kz0w.js} +4 -4
  27. package/dist/chunks/{auth-ehyp3zqd.js → cors-ehyp3zqd.js} +1 -1
  28. package/dist/chunks/{auth-em7ed65n.js → cors-em7ed65n.js} +2 -2
  29. package/dist/chunks/{auth-enx9e1dz.js → cors-enx9e1dz.js} +4 -4
  30. package/dist/chunks/{auth-exwy1kbj.js → cors-exwy1kbj.js} +2 -2
  31. package/dist/chunks/{auth-f3gr6hfv.js → cors-f3gr6hfv.js} +2 -2
  32. package/dist/chunks/{auth-ey0z35hy.js → cors-fa6nnfxm.js} +38 -35
  33. package/dist/chunks/{auth-g23ffrnz.js → cors-g23ffrnz.js} +2 -2
  34. package/dist/chunks/{auth-g4964mny.js → cors-g4964mny.js} +3 -3
  35. package/dist/chunks/{auth-xcshf76p.js → cors-hb1ty1t1.js} +5 -6
  36. package/dist/chunks/{auth-j4at0y5c.js → cors-j4at0y5c.js} +1 -1
  37. package/dist/chunks/{auth-javgytnb.js → cors-javgytnb.js} +2 -2
  38. package/dist/chunks/{auth-k74zefsg.js → cors-k74zefsg.js} +1 -1
  39. package/dist/chunks/{auth-ka2mtp6f.js → cors-ka2mtp6f.js} +2 -2
  40. package/dist/chunks/{auth-kmwr1xw9.js → cors-kmwr1xw9.js} +3 -3
  41. package/dist/chunks/{auth-1aar1z9e.js → cors-msvebcy2.js} +5 -5
  42. package/dist/chunks/{auth-myqk22k5.js → cors-myqk22k5.js} +2 -2
  43. package/dist/chunks/{auth-n2zyxnzr.js → cors-n2zyxnzr.js} +1 -1
  44. package/dist/chunks/{auth-nvb61mgq.js → cors-nvb61mgq.js} +4 -4
  45. package/dist/chunks/{auth-p3bbq7g3.js → cors-p3bbq7g3.js} +1 -1
  46. package/dist/chunks/{auth-prwd5gwt.js → cors-prwd5gwt.js} +2 -2
  47. package/dist/chunks/{auth-qq3f8fnn.js → cors-qq3f8fnn.js} +2 -2
  48. package/dist/chunks/{auth-qssmdh31.js → cors-qssmdh31.js} +4 -4
  49. package/dist/chunks/{auth-rgbnpstw.js → cors-rgbnpstw.js} +2 -2
  50. package/dist/chunks/{auth-rjhxbsc4.js → cors-rjhxbsc4.js} +2 -2
  51. package/dist/chunks/{auth-s0zgx365.js → cors-s0zgx365.js} +2 -2
  52. package/dist/chunks/{auth-gaegw7xv.js → cors-sv3a4xc1.js} +16 -12
  53. package/dist/chunks/{auth-t32e1bbt.js → cors-t32e1bbt.js} +1 -1
  54. package/dist/chunks/{auth-w9jcwh65.js → cors-v9t81kwn.js} +8 -8
  55. package/dist/chunks/cors-w6xb5z15.js +196 -0
  56. package/dist/chunks/{auth-whvq72as.js → cors-whvq72as.js} +3 -3
  57. package/dist/chunks/{auth-wsvmph03.js → cors-wsvmph03.js} +2 -2
  58. package/dist/chunks/{auth-x2qy7jg1.js → cors-x2qy7jg1.js} +1 -1
  59. package/dist/chunks/{auth-yc92za0p.js → cors-yc92za0p.js} +2 -2
  60. package/dist/chunks/{auth-tjxfj8xj.js → cors-z5c20bjd.js} +29 -12
  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 +3 -3
  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 +44 -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 +2 -2
  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 +3 -2
  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 +49 -0
  132. package/dist/space-store.js +16 -0
  133. package/dist/workerd.js +66 -64
  134. package/package.json +8 -8
  135. /package/dist/chunks/{auth-017ycvbx.js → cors-017ycvbx.js} +0 -0
  136. /package/dist/chunks/{auth-9rqn6x4v.js → cors-9rqn6x4v.js} +0 -0
  137. /package/dist/chunks/{auth-bd8755ek.js → cors-bd8755ek.js} +0 -0
  138. /package/dist/chunks/{auth-n26yr6pw.js → cors-n26yr6pw.js} +0 -0
  139. /package/dist/chunks/{auth-q187pxxd.js → cors-q187pxxd.js} +0 -0
  140. /package/dist/chunks/{auth-q4bn6dy8.js → cors-q4bn6dy8.js} +0 -0
  141. /package/dist/chunks/{auth-qpnw2qd1.js → cors-qpnw2qd1.js} +0 -0
  142. /package/dist/chunks/{auth-rqgv9x42.js → cors-rqgv9x42.js} +0 -0
  143. /package/dist/chunks/{auth-xthc02cw.js → cors-xthc02cw.js} +0 -0
  144. /package/dist/chunks/{auth-yc7nft6q.js → cors-yc7nft6q.js} +0 -0
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./cors-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: () => Service5,
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 Service5 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(Service5, Effect.gen(function* () {
21
21
  const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
22
- return Service3.of({
22
+ return Service5.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: Service5, layer, deps: [] });
34
34
 
35
- export { Service3, node2, exports_pairing };
35
+ export { Service5, node3, exports_pairing };
@@ -0,0 +1,196 @@
1
+ import {
2
+ __export
3
+ } from "./cors-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) => Effect.suspend(() => {
34
+ const since = (deletes.get(space) ?? PurgeInterval2 - 1) + 1;
35
+ if (since < PurgeInterval2)
36
+ return Effect.sync(() => deletes.set(space, since));
37
+ 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
+ });
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
+ const streams = new Map;
48
+ const deliver = (stream, change) => Effect.suspend(() => {
49
+ const subscription = stream.spaces.get(change.data.space);
50
+ if (!subscription)
51
+ return Effect.void;
52
+ if (subscription.pending) {
53
+ subscription.pending.push(change);
54
+ return Effect.void;
55
+ }
56
+ return change.data.revision > subscription.covered ? stream.send(change) : Effect.void;
57
+ });
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",
76
+ space,
77
+ epoch,
78
+ revision,
79
+ entries: entries(kept),
80
+ deleted: deleted(kept),
81
+ cursor: `${epoch}.${revision}`,
82
+ next: rows.length > BatchSize2 ? `${epoch}.${revision}` : undefined
83
+ };
84
+ return page;
85
+ });
86
+ const catchUp = (space, cursor) => Effect.gen(function* () {
87
+ const position = parse(epoch, cursor);
88
+ const created = yield* Clock.currentTimeMillis;
89
+ const resync = {
90
+ covered: 0,
91
+ 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;
98
+ 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))
101
+ };
102
+ });
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 })))));
109
+ }),
110
+ get epoch() {
111
+ return epoch;
112
+ },
113
+ resetEpoch: Effect.fn("SpaceStore.resetEpoch")(function* () {
114
+ epoch = yield* SpaceRows.resetEpoch(db);
115
+ })(),
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
+ }),
127
+ attach: (id, send) => Effect.acquireRelease(Effect.sync(() => streams.set(id, { send, spaces: new Map })), () => Effect.sync(() => streams.delete(id))).pipe(Effect.asVoid),
128
+ subscribe: Effect.fn("SpaceStore.subscribe")(function* (id, requests) {
129
+ const stream = streams.get(id);
130
+ if (!stream)
131
+ return false;
132
+ const subscriptions = requests.map((request) => {
133
+ const subscription = { covered: 0, pending: [] };
134
+ stream.spaces.set(request.space, subscription);
135
+ return { request, subscription };
136
+ });
137
+ yield* Effect.forEach(subscriptions, ({ request, subscription }) => Effect.gen(function* () {
138
+ const current = () => stream.spaces.get(request.space) === subscription;
139
+ const first = yield* catchUp(request.space, request.cursor);
140
+ if (!subscription.pending)
141
+ return;
142
+ subscription.covered = first.covered;
143
+ for (const event of first.events)
144
+ if (current())
145
+ yield* stream.send(event);
146
+ for (let change = subscription.pending.shift();change && current(); change = subscription.pending.shift())
147
+ if (change.data.revision > subscription.covered)
148
+ yield* stream.send(change);
149
+ subscription.pending = undefined;
150
+ }), { discard: true }).pipe(Effect.ensuring(Effect.sync(() => {
151
+ for (const { request, subscription } of subscriptions)
152
+ if (subscription.pending && stream.spaces.get(request.space) === subscription)
153
+ stream.spaces.delete(request.space);
154
+ })));
155
+ return true;
156
+ }),
157
+ unsubscribe: (id, spaces) => Effect.sync(() => {
158
+ const stream = streams.get(id);
159
+ for (const space of spaces)
160
+ stream?.spaces.delete(space);
161
+ return stream !== undefined;
162
+ }),
163
+ listen: (listener) => Effect.sync(() => {
164
+ listeners.push(listener);
165
+ return Effect.sync(() => {
166
+ const index = listeners.indexOf(listener);
167
+ if (index >= 0)
168
+ listeners.splice(index, 1);
169
+ });
170
+ })
171
+ });
172
+ }));
173
+ var node2 = makeGlobalNode({ service: Service2, layer, deps: [Database.node] });
174
+ var extension2 = Effect.gen(function* () {
175
+ const store = yield* Service2;
176
+ return { open: (stream, send) => store.attach(stream, send) };
177
+ });
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 };
180
+ }
181
+ function entries(rows) {
182
+ return rows.flatMap((row) => row.value === null ? [] : [{ key: row.key, value: row.value }]);
183
+ }
184
+ function deleted(rows) {
185
+ return rows.flatMap((row) => row.value === null ? [row.key] : []);
186
+ }
187
+ function parse(epoch, cursor) {
188
+ if (!cursor.startsWith(`${epoch}.`))
189
+ return;
190
+ const parts = cursor.slice(epoch.length + 1).split(".");
191
+ if (parts.length > 2 || !parts.every((part) => /^\d+$/u.test(part) && Number.isSafeInteger(Number(part))))
192
+ return;
193
+ return { since: Number(parts[0]), head: parts[1] === undefined ? undefined : Number(parts[1]) };
194
+ }
195
+
196
+ export { BatchSize2, PurgeInterval2, Service2, node2, extension2, exports_space_store };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  LocationMiddleware2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./cors-br4x4prt.js";
4
4
  import {
5
5
  FormLocationMiddleware2
6
- } from "./auth-ca564221.js";
6
+ } from "./cors-ca564221.js";
7
7
  import {
8
8
  SessionLocationMiddleware2
9
- } from "./auth-ehyp3zqd.js";
9
+ } from "./cors-ehyp3zqd.js";
10
10
 
11
11
  // src/api.ts
12
12
  import { makeDefaultApi } from "@opencode/protocol/api";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./cors-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./cors-whvq72as.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
  missingSession2
3
- } from "./auth-rqgv9x42.js";
3
+ } from "./cors-rqgv9x42.js";
4
4
 
5
5
  // src/handlers/job.ts
6
6
  import { Job } from "@opencode/core/job";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  response2
3
- } from "./auth-br4x4prt.js";
3
+ } from "./cors-br4x4prt.js";
4
4
  import {
5
5
  Api2
6
- } from "./auth-whvq72as.js";
6
+ } from "./cors-whvq72as.js";
7
7
 
8
8
  // src/handlers/provider.ts
9
9
  import { Provider } from "@opencode/core/provider";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./auth-9rqn6x4v.js";
3
+ } from "./cors-9rqn6x4v.js";
4
4
 
5
5
  // src/event-feed.ts
6
6
  var exports_event_feed = {};
@@ -12,12 +12,12 @@ __export(exports_event_feed, {
12
12
  SubscriberOverflowError: () => SubscriberOverflowError2,
13
13
  frame: () => frame2,
14
14
  layer: () => layer3,
15
- make: () => make3
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 }) {
@@ -37,7 +37,7 @@ function frame2(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
78
  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))
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 layer3 = (...extensions) => Layer.effect(Service4, 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, Service4, frame2, make4, layer3, exports_event_feed };
@@ -3,7 +3,7 @@ import {
3
3
  download2,
4
4
  disposition2,
5
5
  exports_content_headers
6
- } from "./chunks/auth-t32e1bbt.js";
6
+ } from "./chunks/cors-t32e1bbt.js";
7
7
  export {
8
8
  CONTENT_SECURITY_POLICY2 as CONTENT_SECURITY_POLICY,
9
9
  exports_content_headers as ContentHeaders,
package/dist/cors.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  CorsConfig2,
3
3
  isAllowedCorsOrigin2,
4
4
  isAllowedRequestOrigin2
5
- } from "./chunks/auth-q4bn6dy8.js";
5
+ } from "./chunks/cors-q4bn6dy8.js";
6
6
  export {
7
7
  CorsConfig2 as CorsConfig,
8
8
  isAllowedCorsOrigin2 as isAllowedCorsOrigin,
@@ -19,7 +19,18 @@ export declare class EncodingError extends EncodingError_base {
19
19
  }
20
20
  export type Error = SubscriberOverflowError | EncodingError;
21
21
  export interface Interface {
22
- readonly subscribe: (types?: ReadonlyArray<string>) => Effect.Effect<Stream.Stream<string, Error>, never, Scope.Scope>;
22
+ /** Opens a stream of encoded events, with the random ID that addresses it, e.g. to subscribe it to more events. */
23
+ readonly subscribe: (types?: ReadonlyArray<string>) => Effect.Effect<{
24
+ readonly id: string;
25
+ readonly events: Stream.Stream<string, Error>;
26
+ }, never, Scope.Scope>;
27
+ }
28
+ /**
29
+ * Adds events from outside the bus. `open` runs once for each stream, with its ID and a `send` that reaches that
30
+ * stream, whatever its `types`, until the stream closes along with the scope `open` gets.
31
+ */
32
+ export interface Extension {
33
+ readonly open: (stream: string, send: (event: OpenCodeEvent) => Effect.Effect<void>) => Effect.Effect<void, never, Scope.Scope>;
23
34
  }
24
35
  declare const Service_base: Context.ServiceClass<Service, "@opencode/server/EventFeed", Interface>;
25
36
  export declare class Service extends Service_base {
@@ -28,5 +39,6 @@ export declare function frame(event: OpenCodeEvent): string;
28
39
  export declare const make: (observe: (subscriber: Bus.Subscriber) => Effect.Effect<Bus.Unsubscribe>, options?: {
29
40
  readonly capacity?: number;
30
41
  readonly encode?: (event: OpenCodeEvent) => string;
42
+ readonly extensions?: ReadonlyArray<Extension>;
31
43
  } | undefined) => Effect.Effect<Interface, never, Scope.Scope>;
32
- export declare const layer: Layer.Layer<Service, never, Bus.Service>;
44
+ export declare const layer: <R>(...extensions: ReadonlyArray<Effect.Effect<Extension, never, R>>) => Layer.Layer<Service, never, Bus.Service | Exclude<R, Scope.Scope>>;
@@ -4,10 +4,10 @@ import {
4
4
  EncodingError2,
5
5
  Service4,
6
6
  frame2,
7
- make3,
7
+ make4,
8
8
  layer3,
9
9
  exports_event_feed
10
- } from "./chunks/auth-tjxfj8xj.js";
10
+ } from "./chunks/cors-z5c20bjd.js";
11
11
  export {
12
12
  EncodingError2 as EncodingError,
13
13
  exports_event_feed as EventFeed,
@@ -16,5 +16,5 @@ export {
16
16
  SubscriberOverflowError2 as SubscriberOverflowError,
17
17
  frame2 as frame,
18
18
  layer3 as layer,
19
- make3 as make
19
+ make4 as make
20
20
  };
package/dist/fetch.d.ts CHANGED
@@ -63,7 +63,7 @@ export declare const makeWithContext: (options?: {
63
63
  } | undefined;
64
64
  } | undefined, boot?: BootOptions | undefined) => Effect.Effect<{
65
65
  handler: (request: Request, context?: Context.Context<never> | undefined) => Promise<globalThis.Response>;
66
- context: Context.Context<import("@opencode/core/shell").Daemon | import("effect/http/HttpClient").HttpClient | HttpRouter.HttpRouter | import("@opencode/util/fs-util").FSUtil.Service | import("@opencode/util/global").Service | import("@opencode/core/database/database").Service | import("@opencode/core/app").Service | import("@opencode/core/credential").Service | import("@opencode/core/kv").Service | import("@opencode/core/wellknown").Service | import("@opencode/core/session/instruction-entry").Service | import("@opencode/core/job").Service | import("@opencode/core/machine/identity").Service | import("@opencode/core/machine/machines").Service | import("@opencode/core/workspace").Service | import("@opencode/core/permission/saved").Service | import("@opencode/core/codemode/api").Service | import("@opencode/core/location-service-map").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/session").Service | import("@opencode/core/automation").Service | import("@opencode/core/worktree").Service | import("@opencode/core/blob-store").Service | import("@opencode/core/session/search-build").Service | import("@opencode/core/video-generation").Service | import("@opencode/core/experimental/browser-tunnel").Service | import("@opencode/core/plugin/sdk").Service | import("@opencode/core/plugin/update").Service | import("@opencode/core/instance").Service | import("@opencode/core/bus").Service | import("@opencode/core/project").Service | SessionRestart.Service | import("@opencode/core/pty/ticket").Service | import("@opencode/core/session/transfer").Service | import("@opencode/core/location-activity").Service | import("@opencode/core/push/list").Service | import("@opencode/core/push/sender").Service | import("@opencode/core/filesystem/file-watch").Service | import("./pairing").Service>;
66
+ context: Context.Context<import("@opencode/core/shell").Daemon | import("effect/http/HttpClient").HttpClient | HttpRouter.HttpRouter | import("@opencode/util/fs-util").FSUtil.Service | import("@opencode/util/global").Service | import("@opencode/core/database/database").Service | import("@opencode/core/app").Service | import("@opencode/core/credential").Service | import("@opencode/core/kv").Service | import("@opencode/core/wellknown").Service | import("@opencode/core/session/instruction-entry").Service | import("@opencode/core/job").Service | import("@opencode/core/machine/identity").Service | import("@opencode/core/machine/machines").Service | import("@opencode/core/workspace").Service | import("@opencode/core/permission/saved").Service | import("@opencode/core/codemode/api").Service | import("@opencode/core/location-service-map").Service | import("@opencode/core/persistent-pty/index").Service | import("@opencode/core/session").Service | import("@opencode/core/automation").Service | import("@opencode/core/worktree").Service | import("@opencode/core/blob-store").Service | import("@opencode/core/session/search-build").Service | import("@opencode/core/video-generation").Service | import("@opencode/core/experimental/browser-tunnel").Service | import("@opencode/core/plugin/sdk").Service | import("@opencode/core/plugin/update").Service | import("@opencode/core/instance").Service | import("@opencode/core/bus").Service | import("@opencode/core/project").Service | SessionRestart.Service | import("@opencode/core/pty/ticket").Service | import("@opencode/core/session/transfer").Service | import("@opencode/core/location-activity").Service | import("@opencode/core/push/list").Service | import("@opencode/core/push/sender").Service | import("@opencode/core/filesystem/file-watch").Service | import("./space-store").Service | import("./pairing").Service>;
67
67
  }, Error, import("effect/Scope").Scope>;
68
68
  /**
69
69
  * Builds a web-standard fetch handler — `(request: Request) => Promise<Response>` — serving the
package/dist/fetch.js CHANGED
@@ -2,69 +2,71 @@ import {
2
2
  makeWithContext2,
3
3
  make2,
4
4
  exports_fetch
5
- } from "./chunks/auth-1aar1z9e.js";
6
- import"./chunks/auth-myqk22k5.js";
7
- import"./chunks/auth-2p8psxn9.js";
8
- import"./chunks/auth-bd8755ek.js";
9
- import"./chunks/auth-29nx48hm.js";
10
- import"./chunks/auth-n26yr6pw.js";
11
- import"./chunks/auth-yc7nft6q.js";
12
- import"./chunks/auth-ey0z35hy.js";
13
- import"./chunks/auth-9hynp6rm.js";
14
- import"./chunks/auth-kmwr1xw9.js";
15
- import"./chunks/auth-qssmdh31.js";
16
- import"./chunks/auth-g4964mny.js";
17
- import"./chunks/auth-prwd5gwt.js";
18
- import"./chunks/auth-xcshf76p.js";
19
- import"./chunks/auth-n2zyxnzr.js";
20
- import"./chunks/auth-gaegw7xv.js";
21
- import"./chunks/auth-ka2mtp6f.js";
22
- import"./chunks/auth-017ycvbx.js";
23
- import"./chunks/auth-g23ffrnz.js";
24
- import"./chunks/auth-x2qy7jg1.js";
25
- import"./chunks/auth-em7ed65n.js";
26
- import"./chunks/auth-djr0jy89.js";
27
- import"./chunks/auth-7dkb5ks8.js";
28
- import"./chunks/auth-10sj2tcf.js";
29
- import"./chunks/auth-am27j67f.js";
30
- import"./chunks/auth-0wjm8gvs.js";
31
- import"./chunks/auth-8xdajgpr.js";
32
- import"./chunks/auth-2tmcamrc.js";
33
- import"./chunks/auth-59yyxpa4.js";
34
- import"./chunks/auth-rgbnpstw.js";
35
- import"./chunks/auth-p3bbq7g3.js";
36
- import"./chunks/auth-rjhxbsc4.js";
37
- import"./chunks/auth-exwy1kbj.js";
38
- import"./chunks/auth-s0zgx365.js";
39
- import"./chunks/auth-8nezxn08.js";
40
- import"./chunks/auth-f3gr6hfv.js";
41
- import"./chunks/auth-6pm6ek88.js";
42
- import"./chunks/auth-javgytnb.js";
43
- import"./chunks/auth-qq3f8fnn.js";
44
- import"./chunks/auth-1z9qd4y2.js";
45
- import"./chunks/auth-csnx1nj3.js";
46
- import"./chunks/auth-74nxvsrn.js";
47
- import"./chunks/auth-8qsq6tbs.js";
48
- import"./chunks/auth-wsvmph03.js";
49
- import"./chunks/auth-yc92za0p.js";
50
- import"./chunks/auth-qpnw2qd1.js";
51
- import"./chunks/auth-enx9e1dz.js";
52
- import"./chunks/auth-q187pxxd.js";
53
- import"./chunks/auth-k74zefsg.js";
54
- import"./chunks/auth-nvb61mgq.js";
55
- import"./chunks/auth-z3e7v67k.js";
56
- import"./chunks/auth-8sb6qqpn.js";
57
- import"./chunks/auth-t32e1bbt.js";
58
- import"./chunks/auth-w9jcwh65.js";
59
- import"./chunks/auth-q4bn6dy8.js";
60
- import"./chunks/auth-xthc02cw.js";
61
- import"./chunks/auth-tjxfj8xj.js";
62
- import"./chunks/auth-j4at0y5c.js";
63
- import"./chunks/auth-whvq72as.js";
64
- import"./chunks/auth-ehyp3zqd.js";
65
- import"./chunks/auth-ca564221.js";
66
- import"./chunks/auth-br4x4prt.js";
67
- import"./chunks/auth-rqgv9x42.js";
5
+ } from "./chunks/cors-msvebcy2.js";
6
+ import"./chunks/cors-yc7nft6q.js";
7
+ import"./chunks/cors-myqk22k5.js";
8
+ import"./chunks/cors-3cx4ac5j.js";
9
+ import"./chunks/cors-n26yr6pw.js";
10
+ import"./chunks/cors-29nx48hm.js";
11
+ import"./chunks/cors-bd8755ek.js";
12
+ import"./chunks/cors-fa6nnfxm.js";
13
+ import"./chunks/cors-p3bbq7g3.js";
14
+ import"./chunks/cors-0wjm8gvs.js";
15
+ import"./chunks/cors-8qsq6tbs.js";
16
+ import"./chunks/cors-k74zefsg.js";
17
+ import"./chunks/cors-qq3f8fnn.js";
18
+ import"./chunks/cors-8nezxn08.js";
19
+ import"./chunks/cors-qssmdh31.js";
20
+ import"./chunks/cors-kmwr1xw9.js";
21
+ import"./chunks/cors-n2zyxnzr.js";
22
+ import"./chunks/cors-prwd5gwt.js";
23
+ import"./chunks/cors-10sj2tcf.js";
24
+ import"./chunks/cors-1z9qd4y2.js";
25
+ import"./chunks/cors-nvb61mgq.js";
26
+ import"./chunks/cors-csnx1nj3.js";
27
+ import"./chunks/cors-7dkb5ks8.js";
28
+ import"./chunks/cors-enx9e1dz.js";
29
+ import"./chunks/cors-rgbnpstw.js";
30
+ import"./chunks/cors-3xkwxcke.js";
31
+ import"./chunks/cors-wsvmph03.js";
32
+ import"./chunks/cors-6cmsxt3d.js";
33
+ import"./chunks/cors-em7ed65n.js";
34
+ import"./chunks/cors-9hynp6rm.js";
35
+ import"./chunks/cors-f3gr6hfv.js";
36
+ import"./chunks/cors-s0zgx365.js";
37
+ import"./chunks/cors-am27j67f.js";
38
+ import"./chunks/cors-g4964mny.js";
39
+ import"./chunks/cors-sv3a4xc1.js";
40
+ import"./chunks/cors-qpnw2qd1.js";
41
+ import"./chunks/cors-g23ffrnz.js";
42
+ import"./chunks/cors-ka2mtp6f.js";
43
+ import"./chunks/cors-6pm6ek88.js";
44
+ import"./chunks/cors-javgytnb.js";
45
+ import"./chunks/cors-5fn432p6.js";
46
+ import"./chunks/cors-017ycvbx.js";
47
+ import"./chunks/cors-hb1ty1t1.js";
48
+ import"./chunks/cors-q187pxxd.js";
49
+ import"./chunks/cors-exwy1kbj.js";
50
+ import"./chunks/cors-x2qy7jg1.js";
51
+ import"./chunks/cors-rjhxbsc4.js";
52
+ import"./chunks/cors-djr0jy89.js";
53
+ import"./chunks/cors-yc92za0p.js";
54
+ import"./chunks/cors-8xdajgpr.js";
55
+ import"./chunks/cors-2tmcamrc.js";
56
+ import"./chunks/cors-w6xb5z15.js";
57
+ import"./chunks/cors-xthc02cw.js";
58
+ import"./chunks/cors-5pdfedjd.js";
59
+ import"./chunks/cors-z5c20bjd.js";
60
+ import"./chunks/cors-j4at0y5c.js";
61
+ import"./chunks/cors-8sb6qqpn.js";
62
+ import"./chunks/cors-q4bn6dy8.js";
63
+ import"./chunks/cors-t32e1bbt.js";
64
+ import"./chunks/cors-v9t81kwn.js";
65
+ import"./chunks/cors-whvq72as.js";
66
+ import"./chunks/cors-ehyp3zqd.js";
67
+ import"./chunks/cors-ca564221.js";
68
+ import"./chunks/cors-br4x4prt.js";
69
+ import"./chunks/cors-rqgv9x42.js";
68
70
  export {
69
71
  exports_fetch as ServerFetch,
70
72
  make2 as make,
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  AgentHandler2
3
- } from "../chunks/auth-exwy1kbj.js";
4
- import"../chunks/auth-whvq72as.js";
5
- import"../chunks/auth-ehyp3zqd.js";
6
- import"../chunks/auth-ca564221.js";
7
- import"../chunks/auth-br4x4prt.js";
8
- import"../chunks/auth-rqgv9x42.js";
3
+ } from "../chunks/cors-exwy1kbj.js";
4
+ import"../chunks/cors-whvq72as.js";
5
+ import"../chunks/cors-ehyp3zqd.js";
6
+ import"../chunks/cors-ca564221.js";
7
+ import"../chunks/cors-br4x4prt.js";
8
+ import"../chunks/cors-rqgv9x42.js";
9
9
  export {
10
10
  AgentHandler2 as AgentHandler
11
11
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  makeArtifact2
3
- } from "../chunks/auth-javgytnb.js";
4
- import"../chunks/auth-br4x4prt.js";
5
- import"../chunks/auth-rqgv9x42.js";
3
+ } from "../chunks/cors-javgytnb.js";
4
+ import"../chunks/cors-br4x4prt.js";
5
+ import"../chunks/cors-rqgv9x42.js";
6
6
  export {
7
7
  makeArtifact2 as makeArtifact
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  makeAutomation2
3
- } from "../chunks/auth-6pm6ek88.js";
4
- import"../chunks/auth-rqgv9x42.js";
3
+ } from "../chunks/cors-6pm6ek88.js";
4
+ import"../chunks/cors-rqgv9x42.js";
5
5
  export {
6
6
  makeAutomation2 as makeAutomation
7
7
  };