@opencode/server 2.0.24 → 2.0.26
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.
- package/dist/api.js +5 -5
- package/dist/auth.js +1 -1
- package/dist/chunks/{event-feed-pvrbm2ca.js → fetch-053p7hbt.js} +6 -6
- package/dist/chunks/{event-feed-x6486bry.js → fetch-0chp8crd.js} +7 -7
- package/dist/chunks/{event-feed-q4y3mw2d.js → fetch-0y03q8mn.js} +2 -2
- package/dist/chunks/{event-feed-pg3sqc69.js → fetch-1kbkbftd.js} +3 -3
- package/dist/chunks/{event-feed-qcy0p5fz.js → fetch-1w9kp1gg.js} +2 -2
- package/dist/chunks/{event-feed-swb5yrqf.js → fetch-4qyjttng.js} +2 -2
- package/dist/chunks/{event-feed-d0efjmp3.js → fetch-54sczv30.js} +7 -7
- package/dist/chunks/{event-feed-xsrtpxyd.js → fetch-5w24ch67.js} +4 -4
- package/dist/chunks/{event-feed-hqjvw1vc.js → fetch-6fr0a7bp.js} +13 -13
- package/dist/chunks/{event-feed-mz8smzxk.js → fetch-78n975k2.js} +6 -6
- package/dist/chunks/{event-feed-bptmkrac.js → fetch-80mhd8t7.js} +2 -2
- package/dist/chunks/{event-feed-zhqf1t9m.js → fetch-8c9kbrtm.js} +1 -1
- package/dist/chunks/{event-feed-acgs9zzk.js → fetch-acgs9zzk.js} +1 -1
- package/dist/chunks/{event-feed-2vy10eeh.js → fetch-agftk6b6.js} +2 -2
- package/dist/chunks/{event-feed-anm12x33.js → fetch-anm12x33.js} +1 -1
- package/dist/chunks/{event-feed-f90y8hv1.js → fetch-b44t4qeg.js} +62 -51
- package/dist/chunks/{event-feed-0b1t2b2s.js → fetch-bvp1r88z.js} +2 -2
- package/dist/chunks/{event-feed-s4aja1df.js → fetch-c6kb7fmf.js} +11 -6
- package/dist/chunks/{event-feed-m9wzfeff.js → fetch-cm271yqe.js} +2 -2
- package/dist/chunks/{event-feed-30gqa6y8.js → fetch-cy7y42ks.js} +3 -3
- package/dist/chunks/{event-feed-d00srfh1.js → fetch-d00srfh1.js} +1 -1
- package/dist/chunks/{event-feed-5fmydwgy.js → fetch-dy0yben3.js} +1 -1
- package/dist/chunks/{event-feed-j54drd5e.js → fetch-eekrj6qv.js} +1 -1
- package/dist/chunks/{event-feed-nvmdgpqv.js → fetch-g9rgg5ys.js} +2 -2
- package/dist/chunks/{event-feed-fsrvj92d.js → fetch-gj6tv0s4.js} +2 -2
- package/dist/chunks/{event-feed-gtkdacvk.js → fetch-gtkdacvk.js} +1 -1
- package/dist/chunks/{event-feed-6sgwm4gr.js → fetch-hajt4q09.js} +16 -2
- package/dist/chunks/{event-feed-3c937re8.js → fetch-j3pdvhe2.js} +2 -2
- package/dist/chunks/{event-feed-ep84ha6r.js → fetch-jxc39wgw.js} +3 -3
- package/dist/chunks/{event-feed-0nvjg055.js → fetch-kzj5eept.js} +33 -33
- package/dist/chunks/{event-feed-ppd3f187.js → fetch-m4fq9qce.js} +4 -4
- package/dist/chunks/{event-feed-w8db1rkr.js → fetch-m6xk774d.js} +2 -2
- package/dist/chunks/{event-feed-da5stqtt.js → fetch-mjepr257.js} +1 -1
- package/dist/chunks/{event-feed-wv5twc2g.js → fetch-n1svm92q.js} +7 -7
- package/dist/chunks/{event-feed-nxdx74sv.js → fetch-nxdx74sv.js} +1 -1
- package/dist/chunks/fetch-q9rkrfm7.js +106 -0
- package/dist/chunks/{event-feed-jskw5q1g.js → fetch-r5bb0n1s.js} +1 -1
- package/dist/chunks/{event-feed-387sf4vs.js → fetch-rhnwnf76.js} +1 -1
- package/dist/chunks/{event-feed-ccfecbt4.js → fetch-rwwc81rq.js} +1 -1
- package/dist/chunks/{event-feed-k4rfktze.js → fetch-t1n0m4wb.js} +7 -8
- package/dist/chunks/{event-feed-n7kafg5g.js → fetch-t70dy8sr.js} +2 -2
- package/dist/chunks/{event-feed-62qjgyra.js → fetch-w1fepcwh.js} +2 -2
- package/dist/chunks/{event-feed-mpbfcr4e.js → fetch-wb43dd8f.js} +2 -2
- package/dist/chunks/{event-feed-srcrrwjk.js → fetch-zhympcbw.js} +2 -2
- package/dist/cors.js +1 -1
- package/dist/event-feed.js +5 -5
- package/dist/fetch.js +49 -49
- package/dist/handlers/agent.js +6 -6
- package/dist/handlers/command.js +6 -6
- package/dist/handlers/config.js +6 -6
- package/dist/handlers/credential.js +6 -6
- package/dist/handlers/debug.js +6 -6
- package/dist/handlers/event.js +7 -7
- package/dist/handlers/form.js +6 -6
- package/dist/handlers/fs.js +6 -6
- package/dist/handlers/generate.js +6 -6
- package/dist/handlers/integration.d.ts +1 -1
- package/dist/handlers/integration.js +6 -6
- package/dist/handlers/location.js +6 -6
- package/dist/handlers/mcp.js +6 -6
- package/dist/handlers/message.js +6 -6
- package/dist/handlers/migration.js +6 -6
- package/dist/handlers/model.js +6 -6
- package/dist/handlers/permission.js +6 -6
- package/dist/handlers/persistent-pty.js +8 -8
- package/dist/handlers/plugin.js +6 -6
- package/dist/handlers/project.js +6 -6
- package/dist/handlers/provider.js +6 -6
- package/dist/handlers/pty-socket.js +1 -1
- package/dist/handlers/pty.d.ts +2 -1
- package/dist/handlers/pty.js +9 -9
- package/dist/handlers/reference.js +6 -6
- package/dist/handlers/rpc.js +6 -6
- package/dist/handlers/server.js +9 -9
- package/dist/handlers/session-error.js +1 -1
- package/dist/handlers/session.js +6 -6
- package/dist/handlers/shell.js +6 -6
- package/dist/handlers/skill.js +6 -6
- package/dist/handlers/vcs.js +6 -6
- package/dist/handlers/websearch.js +6 -6
- package/dist/handlers/worktree.js +6 -6
- package/dist/handlers.js +43 -43
- package/dist/location.js +2 -2
- package/dist/middleware/authorization.js +2 -2
- package/dist/middleware/form-location.js +3 -3
- package/dist/middleware/schema-error.js +1 -1
- package/dist/middleware/session-location.js +3 -3
- package/dist/pairing.js +3 -3
- package/dist/process.d.ts +1 -1
- package/dist/process.js +54 -53
- package/dist/pty-environment.js +5 -5
- package/dist/request-tracing.js +1 -1
- package/dist/routes.js +46 -46
- package/dist/server-info.js +1 -1
- package/dist/service-status.js +3 -3
- package/dist/workerd.js +50 -50
- package/package.json +8 -9
- package/dist/chunks/event-feed-jhsx8jtg.js +0 -34
- /package/dist/chunks/{event-feed-9rqn6x4v.js → fetch-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{event-feed-hezj1jdf.js → fetch-hezj1jdf.js} +0 -0
- /package/dist/chunks/{event-feed-q4bn6dy8.js → fetch-q4bn6dy8.js} +0 -0
- /package/dist/chunks/{event-feed-smaf4a18.js → fetch-smaf4a18.js} +0 -0
- /package/dist/chunks/{event-feed-t8yzmczr.js → fetch-t8yzmczr.js} +0 -0
- /package/dist/chunks/{event-feed-yc7nft6q.js → fetch-yc7nft6q.js} +0 -0
package/dist/api.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./chunks/
|
|
4
|
-
import"./chunks/
|
|
5
|
-
import"./chunks/
|
|
6
|
-
import"./chunks/
|
|
7
|
-
import"./chunks/
|
|
3
|
+
} from "./chunks/fetch-jxc39wgw.js";
|
|
4
|
+
import"./chunks/fetch-nxdx74sv.js";
|
|
5
|
+
import"./chunks/fetch-d00srfh1.js";
|
|
6
|
+
import"./chunks/fetch-acgs9zzk.js";
|
|
7
|
+
import"./chunks/fetch-smaf4a18.js";
|
|
8
8
|
export {
|
|
9
9
|
Api2 as Api
|
|
10
10
|
};
|
package/dist/auth.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAllowedCorsOrigin2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-q4bn6dy8.js";
|
|
4
4
|
import {
|
|
5
5
|
createRoutes2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-6fr0a7bp.js";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-9rqn6x4v.js";
|
|
10
10
|
|
|
11
11
|
// src/fetch.ts
|
|
12
12
|
var exports_fetch = {};
|
|
13
13
|
__export(exports_fetch, {
|
|
14
14
|
ServerFetch: () => exports_fetch,
|
|
15
|
-
make: () =>
|
|
15
|
+
make: () => make2
|
|
16
16
|
});
|
|
17
17
|
import { Context, Effect, Layer } from "effect";
|
|
18
18
|
import { HttpEffect, HttpMiddleware, HttpRouter, HttpServer } from "effect/unstable/http";
|
|
19
19
|
import { SessionRestart } from "@opencode/core/session/execution/restart";
|
|
20
|
-
var
|
|
20
|
+
var make2 = Effect.fn("ServerFetch.make")(function* (options = {}, boot = {}) {
|
|
21
21
|
const context = yield* Layer.build(createRoutes2(options, () => [], boot.overrides ?? []).pipe(Layer.provide(HttpServer.layerServices)));
|
|
22
22
|
yield* Effect.forkDetach(Context.get(context, SessionRestart.Service).resumeSuspendedSessions);
|
|
23
23
|
return Context.get(context, HttpRouter.HttpRouter).asHttpEffect().pipe(HttpMiddleware.cors({ allowedOrigins: (origin) => isAllowedCorsOrigin2(origin, options), maxAge: 86400 }), HttpEffect.toWebHandlerWith(context));
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export {
|
|
26
|
+
export { make2, exports_fetch };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-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: () =>
|
|
9
|
+
Service: () => Service3,
|
|
10
10
|
node: () => node2
|
|
11
11
|
});
|
|
12
12
|
import { Cache, Context, Duration, Effect, Layer } from "effect";
|
|
@@ -14,12 +14,12 @@ 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
|
|
17
|
+
class Service3 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(
|
|
20
|
+
var layer = Layer.effect(Service3, Effect.gen(function* () {
|
|
21
21
|
const cache = yield* Cache.make({ capacity: 1000, lookup: noLookup, timeToLive: TTL });
|
|
22
|
-
return
|
|
22
|
+
return Service3.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(Service4, Effect.gen(function* () {
|
|
|
30
30
|
})
|
|
31
31
|
});
|
|
32
32
|
}));
|
|
33
|
-
var node2 = makeGlobalNode({ service:
|
|
33
|
+
var node2 = makeGlobalNode({ service: Service3, layer, deps: [] });
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { Service3, node2, exports_pairing };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-smaf4a18.js";
|
|
4
4
|
import {
|
|
5
5
|
locationErrors2,
|
|
6
6
|
response2,
|
|
7
7
|
sessionInfo2
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./fetch-acgs9zzk.js";
|
|
9
9
|
import {
|
|
10
10
|
Api2
|
|
11
|
-
} from "./
|
|
11
|
+
} from "./fetch-jxc39wgw.js";
|
|
12
12
|
|
|
13
13
|
// src/handlers/permission.ts
|
|
14
14
|
import { Instance } from "@opencode/core/instance/service";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-acgs9zzk.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-jxc39wgw.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/provider.ts
|
|
9
9
|
import { Provider } from "@opencode/core/provider";
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-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: () =>
|
|
10
|
+
Service: () => Service5,
|
|
11
11
|
SubscriberCapacity: () => SubscriberCapacity2,
|
|
12
12
|
SubscriberOverflowError: () => SubscriberOverflowError2,
|
|
13
13
|
frame: () => frame2,
|
|
14
|
-
layer: () =>
|
|
14
|
+
layer: () => layer5,
|
|
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
|
|
33
|
+
class Service5 extends Context.Service()("@opencode/server/EventFeed") {
|
|
34
34
|
}
|
|
35
35
|
function frame2(event) {
|
|
36
36
|
return `data: ${JSON.stringify(event)}
|
|
@@ -71,13 +71,13 @@ var make4 = Effect.fn("EventFeed.make")(function* (observe, options) {
|
|
|
71
71
|
});
|
|
72
72
|
const unsubscribe = yield* observe(publish);
|
|
73
73
|
yield* Effect.addFinalizer(() => unsubscribe);
|
|
74
|
-
return
|
|
74
|
+
return Service5.of({
|
|
75
75
|
subscribe: Effect.acquireRelease(Queue.dropping(capacity).pipe(Effect.tap((queue) => Effect.sync(() => subscribers.add(queue)))), (queue) => Effect.sync(() => subscribers.delete(queue)).pipe(Effect.andThen(Queue.shutdown(queue)), Effect.asVoid)).pipe(Effect.map(Stream.fromQueue))
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
|
-
var
|
|
78
|
+
var layer5 = Layer.effect(Service5, Effect.gen(function* () {
|
|
79
79
|
const bus = yield* Bus.Service;
|
|
80
80
|
return yield* make4(bus.listen);
|
|
81
81
|
}));
|
|
82
82
|
|
|
83
|
-
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2,
|
|
83
|
+
export { SubscriberCapacity2, SubscriberOverflowError2, EncodingError2, Service5, frame2, make4, layer5, exports_event_feed };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/service-status.ts
|
|
6
6
|
var exports_service_status = {};
|
|
7
7
|
__export(exports_service_status, {
|
|
8
8
|
Status: () => exports_service_status,
|
|
9
|
-
make: () =>
|
|
9
|
+
make: () => make3
|
|
10
10
|
});
|
|
11
11
|
import { Effect, Ref } from "effect";
|
|
12
|
-
var
|
|
12
|
+
var make3 = Effect.fnUntraced(function* (options = {}) {
|
|
13
13
|
const current = yield* Ref.make(options.initial ?? { type: "starting" });
|
|
14
14
|
const beginStopping = Ref.update(current, (status) => status.type === "stopping" ? status : { type: "stopping" });
|
|
15
15
|
return {
|
|
@@ -20,4 +20,4 @@ var make2 = Effect.fnUntraced(function* (options = {}) {
|
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export {
|
|
23
|
+
export { make3, exports_service_status };
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
layer3
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-acgs9zzk.js";
|
|
4
4
|
import {
|
|
5
5
|
formLocationLayer2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-d00srfh1.js";
|
|
7
7
|
import {
|
|
8
8
|
sessionLocationLayer2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-nxdx74sv.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./fetch-jxc39wgw.js";
|
|
13
13
|
import {
|
|
14
14
|
Config2
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./fetch-anm12x33.js";
|
|
16
16
|
import {
|
|
17
17
|
CorsConfig2
|
|
18
|
-
} from "./
|
|
18
|
+
} from "./fetch-q4bn6dy8.js";
|
|
19
19
|
import {
|
|
20
20
|
layer2
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./fetch-c6kb7fmf.js";
|
|
22
22
|
import {
|
|
23
23
|
node2
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./fetch-0chp8crd.js";
|
|
25
25
|
import {
|
|
26
26
|
node3
|
|
27
|
-
} from "./
|
|
27
|
+
} from "./fetch-n1svm92q.js";
|
|
28
28
|
import {
|
|
29
29
|
handlers2
|
|
30
|
-
} from "./
|
|
30
|
+
} from "./fetch-kzj5eept.js";
|
|
31
31
|
import {
|
|
32
32
|
authorizationLayer2
|
|
33
|
-
} from "./
|
|
33
|
+
} from "./fetch-gtkdacvk.js";
|
|
34
34
|
import {
|
|
35
35
|
schemaErrorLayer2
|
|
36
|
-
} from "./
|
|
36
|
+
} from "./fetch-t8yzmczr.js";
|
|
37
37
|
|
|
38
38
|
// src/routes.ts
|
|
39
39
|
import { Database } from "@opencode/core/database/database";
|
|
@@ -124,7 +124,7 @@ function makeRoutes(auth, options, serviceURLs, overrides, instances) {
|
|
|
124
124
|
ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
|
|
125
125
|
Mcp.node.replace(Mcp.configured({
|
|
126
126
|
clientInfo: {
|
|
127
|
-
name:
|
|
127
|
+
name: "opencode",
|
|
128
128
|
version: options.app?.version ?? "unknown"
|
|
129
129
|
}
|
|
130
130
|
}))
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Api2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-jxc39wgw.js";
|
|
4
4
|
import {
|
|
5
5
|
SESSION_TTL_SECONDS2,
|
|
6
6
|
Config2,
|
|
7
7
|
issueSession2,
|
|
8
8
|
sessionCookieName2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-anm12x33.js";
|
|
10
10
|
import {
|
|
11
11
|
Service2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./fetch-c6kb7fmf.js";
|
|
13
13
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./
|
|
14
|
+
Service3
|
|
15
|
+
} from "./fetch-0chp8crd.js";
|
|
16
16
|
|
|
17
17
|
// src/handlers/server.ts
|
|
18
18
|
import { Duration, Effect } from "effect";
|
|
@@ -21,7 +21,7 @@ import { HttpApiBuilder } from "effect/unstable/httpapi";
|
|
|
21
21
|
import { PersistentPty } from "@opencode/core/persistent-pty";
|
|
22
22
|
import { UnauthorizedError } from "@opencode/protocol/errors";
|
|
23
23
|
var ServerHandler2 = HttpApiBuilder.group(Api2, "server.server", (handlers) => Effect.gen(function* () {
|
|
24
|
-
const pairing = yield*
|
|
24
|
+
const pairing = yield* Service3;
|
|
25
25
|
const auth = yield* Config2;
|
|
26
26
|
return handlers.handle("server.info", () => Effect.gen(function* () {
|
|
27
27
|
const info = yield* Service2;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
response2
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-acgs9zzk.js";
|
|
4
4
|
import {
|
|
5
5
|
Api2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-jxc39wgw.js";
|
|
7
7
|
|
|
8
8
|
// src/handlers/websearch.ts
|
|
9
9
|
import { WebSearch } from "@opencode/core/websearch";
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
locationErrors2,
|
|
3
|
+
response2,
|
|
4
|
+
requestRef2
|
|
5
|
+
} from "./fetch-acgs9zzk.js";
|
|
4
6
|
import {
|
|
5
7
|
Api2
|
|
6
|
-
} from "./
|
|
8
|
+
} from "./fetch-jxc39wgw.js";
|
|
7
9
|
import {
|
|
8
10
|
CorsConfig2,
|
|
9
11
|
isAllowedRequestOrigin2
|
|
10
|
-
} from "./
|
|
12
|
+
} from "./fetch-q4bn6dy8.js";
|
|
11
13
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./
|
|
14
|
+
Service4
|
|
15
|
+
} from "./fetch-n1svm92q.js";
|
|
14
16
|
import {
|
|
15
17
|
runPtySocket2
|
|
16
|
-
} from "./
|
|
18
|
+
} from "./fetch-hezj1jdf.js";
|
|
17
19
|
|
|
18
20
|
// src/handlers/pty.ts
|
|
19
21
|
import { Pty } from "@opencode/core/pty";
|
|
20
22
|
import { PtyProtocol } from "@opencode/core/pty/protocol";
|
|
21
23
|
import { PtyTicket } from "@opencode/core/pty/ticket";
|
|
22
24
|
import { Location } from "@opencode/core/location";
|
|
25
|
+
import { LocationServiceMap } from "@opencode/core/location-service-map";
|
|
23
26
|
import { Effect, Queue } from "effect";
|
|
24
27
|
import { HttpServerRequest, HttpServerResponse } from "effect/unstable/http";
|
|
25
28
|
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
@@ -35,9 +38,10 @@ var ticketScope = Effect.gen(function* () {
|
|
|
35
38
|
return { directory: location.directory, workspaceID: location.workspaceID };
|
|
36
39
|
});
|
|
37
40
|
var PtyHandler2 = HttpApiBuilder.group(Api2, "server.pty", (handlers) => Effect.gen(function* () {
|
|
41
|
+
const locations = yield* LocationServiceMap.Service;
|
|
38
42
|
const tickets = yield* PtyTicket.Service;
|
|
39
43
|
const cors = yield* CorsConfig2;
|
|
40
|
-
const environment = yield*
|
|
44
|
+
const environment = yield* Service4;
|
|
41
45
|
return handlers.handle("pty.list", Effect.fn(function* () {
|
|
42
46
|
const pty = yield* Pty.Service;
|
|
43
47
|
return yield* response2(pty.list());
|
|
@@ -87,52 +91,59 @@ var PtyHandler2 = HttpApiBuilder.group(Api2, "server.pty", (handlers) => Effect.
|
|
|
87
91
|
})));
|
|
88
92
|
return yield* response2(tickets.issue({ ptyID: ctx.params.ptyID, ...yield* ticketScope }));
|
|
89
93
|
})).handleRaw("pty.connect", Effect.fn("PtyHandler.connect")(function* (ctx) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return HttpServerResponse.empty({ status: 404 });
|
|
94
|
+
if (!isAllowedRequestOrigin2(ctx.request.headers.origin, ctx.request.headers.host, cors))
|
|
95
|
+
return HttpServerResponse.empty({ status: 403 });
|
|
96
|
+
const ref = LocationServiceMap.canonical(requestRef2(ctx.request));
|
|
94
97
|
const url = new URL(ctx.request.url, "http://localhost");
|
|
95
98
|
const ticket = url.searchParams.get(PTY_CONNECT_TICKET_QUERY);
|
|
96
|
-
if (ticket
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
if (ticket && !(yield* tickets.consume({
|
|
100
|
+
ticket,
|
|
101
|
+
ptyID: ctx.params.ptyID,
|
|
102
|
+
directory: ref.directory,
|
|
103
|
+
workspaceID: ref.workspaceID
|
|
104
|
+
})))
|
|
105
|
+
return HttpServerResponse.empty({ status: 403 });
|
|
106
|
+
return yield* Effect.gen(function* () {
|
|
107
|
+
const pty = yield* Pty.Service;
|
|
108
|
+
const exists = yield* pty.get(ctx.params.ptyID).pipe(Effect.as(true), Effect.catchTag("Pty.NotFoundError", () => Effect.succeed(false)));
|
|
109
|
+
if (!exists)
|
|
110
|
+
return HttpServerResponse.empty({ status: 404 });
|
|
111
|
+
const parsedCursor = url.searchParams.get("cursor");
|
|
112
|
+
const cursorNumber = parsedCursor === null ? undefined : Number(parsedCursor);
|
|
113
|
+
const cursor = cursorNumber !== undefined && Number.isSafeInteger(cursorNumber) && cursorNumber >= -1 ? cursorNumber : undefined;
|
|
114
|
+
const socket = yield* Effect.orDie(ctx.request.upgrade);
|
|
115
|
+
const write = yield* socket.writer;
|
|
116
|
+
const closeAccepted = (event) => socket.runRaw(() => Effect.void, { onOpen: write(event).pipe(Effect.catch(() => Effect.void)) }).pipe(Effect.timeout("1 second"), Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.catch(() => Effect.void));
|
|
117
|
+
const outbox = yield* Queue.unbounded();
|
|
118
|
+
const attachment = yield* pty.attach(ctx.params.ptyID, {
|
|
119
|
+
cursor,
|
|
120
|
+
onData: (chunk) => Queue.offerUnsafe(outbox, chunk),
|
|
121
|
+
onEnd: () => Queue.offerUnsafe(outbox, new Socket.CloseEvent(1000))
|
|
122
|
+
}).pipe(Effect.catchTags({
|
|
123
|
+
"Pty.NotFoundError": () => closeAccepted(new Socket.CloseEvent(4404, "session not found")).pipe(Effect.as(undefined)),
|
|
124
|
+
"Pty.ExitedError": () => closeAccepted(new Socket.CloseEvent(4404, "session exited")).pipe(Effect.as(undefined))
|
|
125
|
+
}));
|
|
126
|
+
if (!attachment)
|
|
127
|
+
return HttpServerResponse.empty();
|
|
128
|
+
for (const chunk of PtyProtocol.chunks(attachment.replay))
|
|
129
|
+
Queue.offerUnsafe(outbox, chunk);
|
|
130
|
+
Queue.offerUnsafe(outbox, PtyProtocol.metaFrame(attachment.cursor));
|
|
131
|
+
attachment.activate();
|
|
132
|
+
const drain = Effect.gen(function* () {
|
|
133
|
+
while (true) {
|
|
134
|
+
const item = yield* Queue.take(outbox);
|
|
135
|
+
yield* write(item);
|
|
136
|
+
if (item instanceof Socket.CloseEvent)
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
yield* runPtySocket2(drain, socket.runRaw((message) => {
|
|
141
|
+
const decoded = PtyProtocol.decodeInput(message);
|
|
142
|
+
if (decoded !== undefined)
|
|
143
|
+
attachment.write(decoded);
|
|
144
|
+
}), attachment.detach).pipe(Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.orDie);
|
|
117
145
|
return HttpServerResponse.empty();
|
|
118
|
-
|
|
119
|
-
Queue.offerUnsafe(outbox, chunk);
|
|
120
|
-
Queue.offerUnsafe(outbox, PtyProtocol.metaFrame(attachment.cursor));
|
|
121
|
-
attachment.activate();
|
|
122
|
-
const drain = Effect.gen(function* () {
|
|
123
|
-
while (true) {
|
|
124
|
-
const item = yield* Queue.take(outbox);
|
|
125
|
-
yield* write(item);
|
|
126
|
-
if (item instanceof Socket.CloseEvent)
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
yield* runPtySocket2(drain, socket.runRaw((message) => {
|
|
131
|
-
const decoded = PtyProtocol.decodeInput(message);
|
|
132
|
-
if (decoded !== undefined)
|
|
133
|
-
attachment.write(decoded);
|
|
134
|
-
}), attachment.detach).pipe(Effect.catchReason("SocketError", "SocketCloseError", () => Effect.void), Effect.orDie);
|
|
135
|
-
return HttpServerResponse.empty();
|
|
146
|
+
}).pipe(Effect.provide(locations.get(ref)), locationErrors2);
|
|
136
147
|
}));
|
|
137
148
|
}));
|
|
138
149
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
missingSession2,
|
|
3
3
|
failedMessageDecode2
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./fetch-smaf4a18.js";
|
|
5
5
|
import {
|
|
6
6
|
Api2
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./fetch-jxc39wgw.js";
|
|
8
8
|
|
|
9
9
|
// src/handlers/message.ts
|
|
10
10
|
import { SessionMessage } from "@opencode/core/session/message";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./fetch-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/server-info.ts
|
|
6
6
|
var exports_server_info = {};
|
|
@@ -24,12 +24,17 @@ function connectionURLs2(value, requestedHostname) {
|
|
|
24
24
|
const family = hostname === "0.0.0.0" ? "IPv4" : hostname === "::" || hostname === "[::]" ? "IPv6" : undefined;
|
|
25
25
|
if (family === undefined)
|
|
26
26
|
return [value];
|
|
27
|
+
const loopback = new URL(value);
|
|
28
|
+
loopback.hostname = family === "IPv6" ? "[::1]" : "127.0.0.1";
|
|
27
29
|
return [
|
|
28
|
-
...new Set(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
...new Set([
|
|
31
|
+
loopback.toString().replace(/\/$/, ""),
|
|
32
|
+
...Object.values(networkInterfaces()).flatMap((entries) => entries ?? []).filter((entry) => !entry.internal && entry.family === family).map((entry) => {
|
|
33
|
+
const result = new URL(value);
|
|
34
|
+
result.hostname = family === "IPv6" ? `[${entry.address}]` : entry.address;
|
|
35
|
+
return result.toString().replace(/\/$/, "");
|
|
36
|
+
})
|
|
37
|
+
])
|
|
33
38
|
];
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
missingMessage2,
|
|
4
4
|
failedMessageDecode2,
|
|
5
5
|
failedSnapshot2
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./fetch-smaf4a18.js";
|
|
7
7
|
import {
|
|
8
8
|
locationErrors2
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./fetch-acgs9zzk.js";
|
|
10
10
|
import {
|
|
11
11
|
Api2
|
|
12
|
-
} from "./
|
|
12
|
+
} from "./fetch-jxc39wgw.js";
|
|
13
13
|
|
|
14
14
|
// src/handlers/session.ts
|
|
15
15
|
import { Session } from "@opencode/core/session";
|