@opencode/server 0.0.0-dev-19795 → 0.0.0-dev-19812
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 +10 -9
- package/dist/auth.js +12 -17
- package/dist/chunks/process-172x6jgf.js +139 -0
- package/dist/chunks/process-18k6g42r.js +36 -0
- package/dist/chunks/process-1crq7hen.js +13 -0
- package/dist/chunks/process-27edjygf.js +33 -0
- package/dist/chunks/process-3esm6t0a.js +156 -0
- package/dist/chunks/process-3ra48t04.js +26 -0
- package/dist/chunks/process-8j6eh3dh.js +55 -0
- package/dist/chunks/process-910kejdj.js +37 -0
- package/dist/chunks/process-9rqn6x4v.js +16 -0
- package/dist/chunks/process-b0dj656z.js +13 -0
- package/dist/chunks/process-b4s3wxap.js +23 -0
- package/dist/chunks/process-c23ng5tp.js +17 -0
- package/dist/chunks/process-d0efjmp3.js +83 -0
- package/dist/chunks/process-d5nhwenp.js +22 -0
- package/dist/chunks/process-dhcrxjg3.js +163 -0
- package/dist/chunks/process-fa3dg36p.js +15 -0
- package/dist/chunks/process-gw2hwgqh.js +20 -0
- package/dist/chunks/process-h965rd83.js +25 -0
- package/dist/chunks/process-hezj1jdf.js +7 -0
- package/dist/chunks/process-j26nh0zz.js +40 -0
- package/dist/chunks/process-ja6yvede.js +22 -0
- package/dist/chunks/process-k319q0y1.js +39 -0
- package/dist/chunks/process-k8tgqrb7.js +61 -0
- package/dist/chunks/process-kadtbwy3.js +77 -0
- package/dist/chunks/process-kb9735wh.js +26 -0
- package/dist/chunks/process-kgbwhj3q.js +149 -0
- package/dist/chunks/process-kheky2r0.js +35 -0
- package/dist/chunks/process-knez9aqv.js +13 -0
- package/dist/chunks/process-ks9pc2xc.js +19 -0
- package/dist/chunks/process-m5dqr0xs.js +21 -0
- package/dist/chunks/process-m6wvgbfq.js +60 -0
- package/dist/chunks/process-m8y6333k.js +346 -0
- package/dist/chunks/process-mx2h5aqn.js +59 -0
- package/dist/chunks/process-prrj1pgd.js +42 -0
- package/dist/chunks/process-q4bn6dy8.js +39 -0
- package/dist/chunks/process-qc2xtz00.js +34 -0
- package/dist/chunks/process-qswqf30g.js +25 -0
- package/dist/chunks/process-rkdaz036.js +32 -0
- package/dist/chunks/process-smaf4a18.js +28 -0
- package/dist/chunks/process-t7k3q1ah.js +23 -0
- package/dist/chunks/process-t8yzmczr.js +18 -0
- package/dist/chunks/process-tp6dn9dc.js +99 -0
- package/dist/chunks/process-w0mvbrhx.js +22 -0
- package/dist/chunks/process-wt4btb09.js +13 -0
- package/dist/chunks/process-xettb16v.js +22 -0
- package/dist/chunks/process-xn1y01ws.js +29 -0
- package/dist/chunks/process-xsrtpxyd.js +23 -0
- package/dist/chunks/process-yc7nft6q.js +5 -0
- package/dist/chunks/process-zyv89x5n.js +30 -0
- package/dist/cors.js +10 -36
- package/dist/event-feed.js +20 -60
- package/dist/fetch.js +53 -11
- package/dist/handlers/agent.js +11 -17
- package/dist/handlers/command.js +11 -5
- package/dist/handlers/config.js +11 -16
- package/dist/handlers/credential.js +11 -14
- package/dist/handlers/debug.js +11 -11
- package/dist/handlers/event.js +12 -27
- package/dist/handlers/form.js +11 -9
- package/dist/handlers/fs.js +11 -22
- package/dist/handlers/generate.js +11 -15
- package/dist/handlers/integration.js +10 -142
- package/dist/handlers/location.js +11 -16
- package/dist/handlers/mcp.js +11 -31
- package/dist/handlers/message.js +10 -42
- package/dist/handlers/migration.js +11 -7
- package/dist/handlers/model.js +11 -14
- package/dist/handlers/permission.js +11 -57
- package/dist/handlers/persistent-pty.js +12 -135
- package/dist/handlers/plugin.js +11 -47
- package/dist/handlers/project.js +11 -9
- package/dist/handlers/provider.js +11 -20
- package/dist/handlers/pty-socket.js +6 -4
- package/dist/handlers/pty.js +13 -107
- package/dist/handlers/reference.js +11 -5
- package/dist/handlers/rpc.js +11 -15
- package/dist/handlers/server.js +12 -13
- package/dist/handlers/session-error.js +12 -26
- package/dist/handlers/session.js +10 -311
- package/dist/handlers/shell.js +11 -25
- package/dist/handlers/skill.js +11 -5
- package/dist/handlers/vcs.js +11 -19
- package/dist/handlers/websearch.js +11 -31
- package/dist/handlers/worktree.js +11 -37
- package/dist/handlers.js +46 -33
- package/dist/location.js +15 -49
- package/dist/middleware/authorization.js +11 -49
- package/dist/middleware/form-location.js +10 -25
- package/dist/middleware/schema-error.js +8 -15
- package/dist/middleware/session-location.js +10 -19
- package/dist/options.js +5 -1
- package/dist/process.js +108 -28
- package/dist/pty-environment.js +12 -9
- package/dist/request-tracing.js +6 -2
- package/dist/routes.js +52 -118
- package/dist/server-info.js +12 -22
- package/dist/service-status.js +8 -11
- package/dist/workerd.js +80 -12
- package/package.json +8 -8
package/dist/handlers/server.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})));
|
|
1
|
+
import {
|
|
2
|
+
ServerHandler2
|
|
3
|
+
} from "../chunks/process-m5dqr0xs.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
import"../chunks/process-18k6g42r.js";
|
|
10
|
+
export {
|
|
11
|
+
ServerHandler2 as ServerHandler
|
|
12
|
+
};
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
messageID: error.messageID,
|
|
14
|
-
message: `Message not found: ${error.messageID}`
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
export function failedMessageDecode(error) {
|
|
18
|
-
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
19
|
-
return Effect.logError("failed to decode session message").pipe(Effect.annotateLogs({ ref, sessionID: error.sessionID, messageID: error.messageID }), Effect.andThen(Effect.fail(new UnknownError({ message: "Unexpected server error. Check server logs for details.", ref }))));
|
|
20
|
-
}
|
|
21
|
-
export function failedSnapshot(operation, sessionID) {
|
|
22
|
-
return (error) => {
|
|
23
|
-
const ref = `err_${crypto.randomUUID().slice(0, 8)}`;
|
|
24
|
-
return Effect.logError(`failed to ${operation}`, { cause: error }).pipe(Effect.annotateLogs({ ref, sessionID }), Effect.andThen(Effect.fail(new UnknownError({ message: "Unexpected server error. Check server logs for details.", ref }))));
|
|
25
|
-
};
|
|
26
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
missingSession2,
|
|
3
|
+
missingMessage2,
|
|
4
|
+
failedMessageDecode2,
|
|
5
|
+
failedSnapshot2
|
|
6
|
+
} from "../chunks/process-smaf4a18.js";
|
|
7
|
+
export {
|
|
8
|
+
failedMessageDecode2 as failedMessageDecode,
|
|
9
|
+
failedSnapshot2 as failedSnapshot,
|
|
10
|
+
missingMessage2 as missingMessage,
|
|
11
|
+
missingSession2 as missingSession
|
|
12
|
+
};
|
package/dist/handlers/session.js
CHANGED
|
@@ -1,312 +1,11 @@
|
|
|
1
|
-
import { Session } from "@opencode/core/session";
|
|
2
|
-
import { SessionStats } from "@opencode/core/session/stats";
|
|
3
|
-
import { SessionTitle } from "@opencode/core/session/title";
|
|
4
|
-
import { SessionTransfer } from "@opencode/core/session/transfer";
|
|
5
|
-
import { InstructionEntry } from "@opencode/core/session/instruction-entry";
|
|
6
|
-
import { Form } from "@opencode/core/form";
|
|
7
|
-
import { DateTime, Effect, Stream } from "effect";
|
|
8
|
-
import { HttpApiBuilder, HttpApiSchema } from "effect/unstable/httpapi";
|
|
9
|
-
import { Api } from "../api";
|
|
10
|
-
import { SessionsCursor } from "@opencode/protocol/groups/session";
|
|
11
1
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
SessionBusyError,
|
|
23
|
-
SkillNotFoundError
|
|
24
|
-
} from "@opencode/protocol/errors";
|
|
25
|
-
import { AbsolutePath } from "@opencode/core/schema";
|
|
26
|
-
import { failedMessageDecode, failedSnapshot, missingMessage, missingSession } from "./session-error";
|
|
27
|
-
const DefaultSessionsLimit = 50;
|
|
28
|
-
function missingForm(id) {
|
|
29
|
-
return new FormNotFoundError({ id, message: `Form not found: ${id}` });
|
|
30
|
-
}
|
|
31
|
-
export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handlers) => Effect.gen(function* () {
|
|
32
|
-
const session = yield* Session.Service, transfer = yield* SessionTransfer.Service, requireOwnedForm = Effect.fnUntraced(function* (sessionID, formID) {
|
|
33
|
-
const form = yield* Form.Service, info = yield* form.get(formID).pipe(Effect.catchTag("Form.NotFoundError", () => missingForm(formID)));
|
|
34
|
-
if (info.sessionID !== sessionID)
|
|
35
|
-
return yield* missingForm(formID);
|
|
36
|
-
return { form, info };
|
|
37
|
-
}), busySession = (error) => new SessionBusyError({
|
|
38
|
-
sessionID: error.sessionID,
|
|
39
|
-
message: `Session is busy: ${error.sessionID}`
|
|
40
|
-
}), pendingMutation = (effect, conflict) => effect.pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.InboxConflictError", (error) => new ConflictError({ resource: error.inboxID, message: `${conflict}: ${error.inboxID}` })), Effect.as(HttpApiSchema.NoContent.make()));
|
|
41
|
-
return handlers.handle("session.list", Effect.fn(function* (ctx) {
|
|
42
|
-
const query = ctx.query.cursor !== void 0 ? yield* SessionsCursor.parse(ctx.query.cursor).pipe(Effect.mapError(() => new InvalidCursorError({ message: "Invalid cursor" }))) : ctx.query, sessions = (yield* session.list({
|
|
43
|
-
...query,
|
|
44
|
-
limit: ctx.query.limit ?? DefaultSessionsLimit
|
|
45
|
-
})).data, first = sessions[0], last = sessions.at(-1);
|
|
46
|
-
return {
|
|
47
|
-
data: sessions,
|
|
48
|
-
cursor: {
|
|
49
|
-
previous: first ? SessionsCursor.make({
|
|
50
|
-
...query,
|
|
51
|
-
anchor: {
|
|
52
|
-
id: first.id,
|
|
53
|
-
time: DateTime.toEpochMillis(first.time.updated),
|
|
54
|
-
direction: "previous"
|
|
55
|
-
}
|
|
56
|
-
}) : void 0,
|
|
57
|
-
next: last ? SessionsCursor.make({
|
|
58
|
-
...query,
|
|
59
|
-
anchor: {
|
|
60
|
-
id: last.id,
|
|
61
|
-
time: DateTime.toEpochMillis(last.time.updated),
|
|
62
|
-
direction: "next"
|
|
63
|
-
}
|
|
64
|
-
}) : void 0
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
})).handle("session.stats", Effect.fn(function* (ctx) {
|
|
68
|
-
const timezone = ctx.query.timezone ?? "UTC";
|
|
69
|
-
yield* Effect.try({
|
|
70
|
-
try: () => new Intl.DateTimeFormat("en-US", { timeZone: timezone }),
|
|
71
|
-
catch: () => new InvalidRequestError({ message: `Invalid time zone: ${timezone}` })
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
data: yield* SessionStats.get({
|
|
75
|
-
from: ctx.query.from,
|
|
76
|
-
to: ctx.query.to,
|
|
77
|
-
projectID: ctx.query.project,
|
|
78
|
-
timezone,
|
|
79
|
-
tools: ctx.query.tools
|
|
80
|
-
}).pipe(Effect.mapError(() => new InvalidRequestError({ message: "Stats range must end after it starts" })))
|
|
81
|
-
};
|
|
82
|
-
})).handle("session.create", Effect.fn(function* (ctx) {
|
|
83
|
-
return {
|
|
84
|
-
data: yield* session.create({
|
|
85
|
-
id: ctx.payload.id,
|
|
86
|
-
title: ctx.payload.title,
|
|
87
|
-
agent: ctx.payload.agent,
|
|
88
|
-
model: ctx.payload.model,
|
|
89
|
-
metadata: ctx.payload.metadata,
|
|
90
|
-
permissions: ctx.payload.permissions,
|
|
91
|
-
location: ctx.payload.location ?? { directory: AbsolutePath.make(process.cwd()) }
|
|
92
|
-
}).pipe(Effect.orDie)
|
|
93
|
-
};
|
|
94
|
-
})).handle("session.import", Effect.fn(function* (ctx) {
|
|
95
|
-
return {
|
|
96
|
-
data: yield* transfer.import({
|
|
97
|
-
data: { info: ctx.payload.info, messages: ctx.payload.messages },
|
|
98
|
-
location: ctx.payload.location ?? { directory: AbsolutePath.make(process.cwd()) }
|
|
99
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("SessionTransfer.ImportConflictError", (error) => new ConflictError({
|
|
100
|
-
message: `Session already exists: ${error.sessionID}`,
|
|
101
|
-
resource: error.sessionID
|
|
102
|
-
})))
|
|
103
|
-
};
|
|
104
|
-
})).handle("session.export", Effect.fn(function* (ctx) {
|
|
105
|
-
return {
|
|
106
|
-
data: yield* transfer.export({ sessionID: ctx.params.sessionID, sanitize: ctx.query.sanitize }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode))
|
|
107
|
-
};
|
|
108
|
-
})).handle("session.active", Effect.fn(function* () {
|
|
109
|
-
const active = yield* session.active;
|
|
110
|
-
return {
|
|
111
|
-
data: Object.fromEntries(Array.from(active, (sessionID) => [sessionID, { type: "running" }]))
|
|
112
|
-
};
|
|
113
|
-
})).handle("session.get", Effect.fn(function* (ctx) {
|
|
114
|
-
return {
|
|
115
|
-
data: yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession))
|
|
116
|
-
};
|
|
117
|
-
})).handle("session.view", Effect.fn(function* (ctx) {
|
|
118
|
-
yield* session.view({ sessionID: ctx.params.sessionID, idle: DateTime.toEpochMillis(ctx.payload.idle) }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
119
|
-
return HttpApiSchema.NoContent.make();
|
|
120
|
-
})).handle("session.remove", Effect.fn(function* (ctx) {
|
|
121
|
-
yield* session.remove(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
122
|
-
return HttpApiSchema.NoContent.make();
|
|
123
|
-
})).handle("session.environment", Effect.fn(function* (ctx) {
|
|
124
|
-
yield* session.environment({ sessionID: ctx.params.sessionID, variables: ctx.payload.variables }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
125
|
-
return HttpApiSchema.NoContent.make();
|
|
126
|
-
})).handle("session.fork", Effect.fn(function* (ctx) {
|
|
127
|
-
return {
|
|
128
|
-
data: yield* session.fork({ sessionID: ctx.params.sessionID, before: ctx.payload.before }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.ForkEmptyError", (error) => new InvalidRequestError({ message: error.message, kind: "empty_session" })))
|
|
129
|
-
};
|
|
130
|
-
})).handle("session.switchAgent", Effect.fn(function* (ctx) {
|
|
131
|
-
yield* session.switchAgent({ sessionID: ctx.params.sessionID, agent: ctx.payload.agent }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
132
|
-
return HttpApiSchema.NoContent.make();
|
|
133
|
-
})).handle("session.switchModel", Effect.fn(function* (ctx) {
|
|
134
|
-
yield* session.switchModel({ sessionID: ctx.params.sessionID, model: ctx.payload.model }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
135
|
-
return HttpApiSchema.NoContent.make();
|
|
136
|
-
})).handle("session.update", Effect.fn(function* (ctx) {
|
|
137
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
138
|
-
if (ctx.payload.title !== void 0)
|
|
139
|
-
if (ctx.payload.title)
|
|
140
|
-
yield* session.rename({ sessionID: ctx.params.sessionID, title: ctx.payload.title }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
141
|
-
else
|
|
142
|
-
yield* (yield* SessionTitle.Service).generate(ctx.params.sessionID);
|
|
143
|
-
if (ctx.payload.permissions !== void 0)
|
|
144
|
-
yield* session.setPermissions({ sessionID: ctx.params.sessionID, permissions: ctx.payload.permissions }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
145
|
-
return HttpApiSchema.NoContent.make();
|
|
146
|
-
})).handle("session.move", Effect.fn(function* (ctx) {
|
|
147
|
-
yield* session.move({
|
|
148
|
-
sessionID: ctx.params.sessionID,
|
|
149
|
-
directory: ctx.payload.directory,
|
|
150
|
-
delivery: ctx.payload.delivery
|
|
151
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.DestinationNotFoundError", (error) => Effect.fail(new InvalidRequestError({ message: `Directory does not exist: ${error.directory}` }))), Effect.catchTag("Session.DestinationNotDirectoryError", (error) => Effect.fail(new InvalidRequestError({ message: `Not a directory: ${error.directory}` }))), Effect.catchTag("Session.DestinationUnavailableError", (error) => Effect.fail(new InvalidRequestError({ message: `Directory is unavailable: ${error.directory}` }))));
|
|
152
|
-
return HttpApiSchema.NoContent.make();
|
|
153
|
-
})).handle("session.prompt", Effect.fn(function* (ctx) {
|
|
154
|
-
return {
|
|
155
|
-
data: yield* session.prompt({
|
|
156
|
-
sessionID: ctx.params.sessionID,
|
|
157
|
-
id: ctx.payload.id,
|
|
158
|
-
text: ctx.payload.text,
|
|
159
|
-
files: ctx.payload.files,
|
|
160
|
-
agents: ctx.payload.agents,
|
|
161
|
-
skills: ctx.payload.skills,
|
|
162
|
-
metadata: ctx.payload.metadata,
|
|
163
|
-
delivery: ctx.payload.delivery,
|
|
164
|
-
resume: ctx.payload.resume
|
|
165
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.PromptConflictError", (error) => Effect.fail(new ConflictError({
|
|
166
|
-
message: `Prompt message ID conflicts with an existing durable record: ${error.messageID}`,
|
|
167
|
-
resource: error.messageID
|
|
168
|
-
}))), Effect.catchTag("Session.AttachmentError", (error) => Effect.fail(new InvalidRequestError({ message: error.message, field: "files" }))), Effect.catchTag("Session.SkillNotFoundError", (error) => Effect.fail(new InvalidRequestError({ message: `Skill not found: ${error.skill}`, field: "skills" }))))
|
|
169
|
-
};
|
|
170
|
-
})).handle("session.command", Effect.fn(function* (ctx) {
|
|
171
|
-
yield* session.command({
|
|
172
|
-
sessionID: ctx.params.sessionID,
|
|
173
|
-
command: ctx.payload.name,
|
|
174
|
-
text: ctx.payload.text,
|
|
175
|
-
files: ctx.payload.files,
|
|
176
|
-
agents: ctx.payload.agents,
|
|
177
|
-
skills: ctx.payload.skills,
|
|
178
|
-
delivery: ctx.payload.delivery
|
|
179
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Command.NotFoundError", (error) => Effect.fail(new CommandNotFoundError({
|
|
180
|
-
command: error.command,
|
|
181
|
-
message: error.message
|
|
182
|
-
}))), Effect.catchTag("Command.ExecutionError", (error) => Effect.fail(new CommandExecutionError({
|
|
183
|
-
command: error.command,
|
|
184
|
-
message: error.message
|
|
185
|
-
}))));
|
|
186
|
-
return HttpApiSchema.NoContent.make();
|
|
187
|
-
})).handle("session.skill", Effect.fn(function* (ctx) {
|
|
188
|
-
yield* session.skill({
|
|
189
|
-
sessionID: ctx.params.sessionID,
|
|
190
|
-
skill: ctx.payload.id,
|
|
191
|
-
resume: ctx.payload.resume
|
|
192
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.SkillNotFoundError", (error) => Effect.fail(new SkillNotFoundError({ skill: error.skill, message: `Skill not found: ${error.skill}` }))));
|
|
193
|
-
return HttpApiSchema.NoContent.make();
|
|
194
|
-
})).handle("session.synthetic", Effect.fn(function* (ctx) {
|
|
195
|
-
return { data: yield* session.synthetic({
|
|
196
|
-
id: ctx.payload.id,
|
|
197
|
-
sessionID: ctx.params.sessionID,
|
|
198
|
-
text: ctx.payload.text,
|
|
199
|
-
description: ctx.payload.description,
|
|
200
|
-
metadata: ctx.payload.metadata,
|
|
201
|
-
delivery: ctx.payload.delivery,
|
|
202
|
-
resume: ctx.payload.resume
|
|
203
|
-
}).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.SyntheticConflictError", (error) => Effect.fail(new ConflictError({
|
|
204
|
-
message: `Synthetic input ID conflicts with an existing durable record: ${error.inputID}`,
|
|
205
|
-
resource: error.inputID
|
|
206
|
-
})))) };
|
|
207
|
-
})).handle("session.shell", Effect.fn(function* (ctx) {
|
|
208
|
-
yield* session.shell({ sessionID: ctx.params.sessionID, id: ctx.payload.id, command: ctx.payload.command }).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
209
|
-
return HttpApiSchema.NoContent.make();
|
|
210
|
-
})).handle("session.compact", Effect.fn(function* (ctx) {
|
|
211
|
-
return {
|
|
212
|
-
data: yield* session.compact({ sessionID: ctx.params.sessionID, id: ctx.payload.id, delivery: ctx.payload.delivery }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.CompactionConflictError", (error) => Effect.fail(new ConflictError({
|
|
213
|
-
message: `Compaction input ID conflicts with an existing durable record: ${error.inputID}`,
|
|
214
|
-
resource: error.inputID
|
|
215
|
-
}))))
|
|
216
|
-
};
|
|
217
|
-
})).handle("session.wait", Effect.fn(function* (ctx) {
|
|
218
|
-
yield* session.wait(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
219
|
-
return HttpApiSchema.NoContent.make();
|
|
220
|
-
})).handle("session.revert.stage", Effect.fn(function* (ctx) {
|
|
221
|
-
yield* Effect.log("session.revert.stage", {
|
|
222
|
-
sessionID: ctx.params.sessionID,
|
|
223
|
-
messageID: ctx.payload.messageID,
|
|
224
|
-
files: ctx.payload.files
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
data: yield* session.revert.stage({ ...ctx.params, ...ctx.payload }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.BusyError", busySession), Effect.catchTag("Snapshot.Error", failedSnapshot("stage session revert", ctx.params.sessionID)))
|
|
228
|
-
};
|
|
229
|
-
})).handle("session.revert.clear", Effect.fn(function* (ctx) {
|
|
230
|
-
yield* Effect.log("session.revert.clear", { sessionID: ctx.params.sessionID });
|
|
231
|
-
yield* session.revert.clear(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.BusyError", busySession), Effect.catchTag("Snapshot.Error", failedSnapshot("clear session revert", ctx.params.sessionID)));
|
|
232
|
-
return HttpApiSchema.NoContent.make();
|
|
233
|
-
})).handle("session.revert.commit", Effect.fn(function* (ctx) {
|
|
234
|
-
yield* Effect.log("session.revert.commit", { sessionID: ctx.params.sessionID });
|
|
235
|
-
yield* session.revert.commit(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.BusyError", busySession));
|
|
236
|
-
return HttpApiSchema.NoContent.make();
|
|
237
|
-
})).handle("session.context", Effect.fn(function* (ctx) {
|
|
238
|
-
return {
|
|
239
|
-
data: yield* session.context(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageDecodeError", failedMessageDecode))
|
|
240
|
-
};
|
|
241
|
-
})).handle("session.diff", Effect.fn(function* (ctx) {
|
|
242
|
-
return {
|
|
243
|
-
data: yield* session.diff({ sessionID: ctx.params.sessionID, ...ctx.query }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.MessageNotFoundError", missingMessage), Effect.catchTag("Session.TurnRangeError", (error) => new InvalidRequestError({ message: error.message, field: error.field })), Effect.catchTag("Snapshot.Error", failedSnapshot("diff session turn", ctx.params.sessionID)))
|
|
244
|
-
};
|
|
245
|
-
})).handle("session.inbox.list", Effect.fn(function* (ctx) {
|
|
246
|
-
return {
|
|
247
|
-
data: yield* session.inbox(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession))
|
|
248
|
-
};
|
|
249
|
-
})).handle("session.inbox.cancel", Effect.fn(function* (ctx) {
|
|
250
|
-
yield* session.cancelInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }).pipe(Effect.catchTag("Session.NotFoundError", missingSession), Effect.catchTag("Session.InboxConflictError", () => Effect.void));
|
|
251
|
-
return HttpApiSchema.NoContent.make();
|
|
252
|
-
})).handle("session.inbox.update", Effect.fn(function* (ctx) {
|
|
253
|
-
return yield* pendingMutation(ctx.payload.delivery === "steer" ? session.steerInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }) : session.queueInbox({ sessionID: ctx.params.sessionID, inboxID: ctx.params.inboxID }), `Pending input cannot change to ${ctx.payload.delivery}`);
|
|
254
|
-
})).handle("session.instructions.entry.list", Effect.fn(function* (ctx) {
|
|
255
|
-
return { data: yield* (yield* InstructionEntry.Service).list(ctx.params.sessionID) };
|
|
256
|
-
})).handle("session.instructions.entry.put", Effect.fn(function* (ctx) {
|
|
257
|
-
yield* (yield* InstructionEntry.Service).put({ sessionID: ctx.params.sessionID, key: ctx.params.key, value: ctx.payload.value });
|
|
258
|
-
return HttpApiSchema.NoContent.make();
|
|
259
|
-
})).handle("session.instructions.entry.remove", Effect.fn(function* (ctx) {
|
|
260
|
-
yield* (yield* InstructionEntry.Service).remove({ sessionID: ctx.params.sessionID, key: ctx.params.key });
|
|
261
|
-
return HttpApiSchema.NoContent.make();
|
|
262
|
-
})).handle("session.generate", Effect.fn(function* (ctx) {
|
|
263
|
-
return { data: { text: yield* session.generate({ sessionID: ctx.params.sessionID, prompt: ctx.payload.prompt }).pipe(Effect.mapError((error) => error._tag === "Session.NotFoundError" ? missingSession(error) : new ServiceUnavailableError({ message: error.message, service: "session generation" }))) } };
|
|
264
|
-
})).handle("session.log", Effect.fn(function* (ctx) {
|
|
265
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
266
|
-
return session.log({ sessionID: ctx.params.sessionID, after: ctx.query.after, follow: ctx.query.follow }).pipe(Stream.orDie);
|
|
267
|
-
})).handle("session.interrupt", Effect.fn(function* (ctx) {
|
|
268
|
-
return { interrupted: yield* session.interrupt(ctx.params.sessionID, { resume: ctx.query.resume }) };
|
|
269
|
-
})).handle("session.background", Effect.fn(function* (ctx) {
|
|
270
|
-
yield* session.background(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
271
|
-
return HttpApiSchema.NoContent.make();
|
|
272
|
-
})).handle("session.message", Effect.fn(function* (ctx) {
|
|
273
|
-
yield* session.get(ctx.params.sessionID).pipe(Effect.catchTag("Session.NotFoundError", missingSession));
|
|
274
|
-
const message = yield* session.message(ctx.params);
|
|
275
|
-
if (message)
|
|
276
|
-
return { data: message };
|
|
277
|
-
return yield* new MessageNotFoundError({
|
|
278
|
-
sessionID: ctx.params.sessionID,
|
|
279
|
-
messageID: ctx.params.messageID,
|
|
280
|
-
message: `Message not found: ${ctx.params.messageID}`
|
|
281
|
-
});
|
|
282
|
-
})).handle("session.form.list", Effect.fn(function* (ctx) {
|
|
283
|
-
return { data: yield* (yield* Form.Service).list({ sessionID: ctx.params.sessionID }) };
|
|
284
|
-
})).handle("session.form.create", Effect.fn(function* (ctx) {
|
|
285
|
-
return { data: yield* (yield* Form.Service).create({
|
|
286
|
-
id: ctx.payload.id,
|
|
287
|
-
sessionID: ctx.params.sessionID,
|
|
288
|
-
title: ctx.payload.title,
|
|
289
|
-
metadata: ctx.payload.metadata,
|
|
290
|
-
fields: ctx.payload.fields
|
|
291
|
-
}).pipe(Effect.catchTags({
|
|
292
|
-
"Form.AlreadyExistsError": (error) => new ConflictError({ resource: error.id, message: error.message }),
|
|
293
|
-
"Form.InvalidFormError": (error) => new InvalidRequestError({ message: error.message, field: "fields" })
|
|
294
|
-
})) };
|
|
295
|
-
})).handle("session.form.get", Effect.fn(function* (ctx) {
|
|
296
|
-
const owned = yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID), state = yield* owned.form.state(ctx.params.formID).pipe(Effect.catchTag("Form.NotFoundError", () => missingForm(ctx.params.formID)));
|
|
297
|
-
return { data: { ...owned.info, state } };
|
|
298
|
-
})).handle("session.form.reply", Effect.fn(function* (ctx) {
|
|
299
|
-
yield* (yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID)).form.reply({ id: ctx.params.formID, answer: ctx.payload.answer }).pipe(Effect.catchTags({
|
|
300
|
-
"Form.AlreadySettledError": (error) => new FormAlreadySettledError({ id: error.id, message: error.message }),
|
|
301
|
-
"Form.InvalidAnswerError": (error) => new FormInvalidAnswerError({ id: error.id, message: error.message }),
|
|
302
|
-
"Form.NotFoundError": () => missingForm(ctx.params.formID)
|
|
303
|
-
}));
|
|
304
|
-
return HttpApiSchema.NoContent.make();
|
|
305
|
-
})).handle("session.form.cancel", Effect.fn(function* (ctx) {
|
|
306
|
-
yield* (yield* requireOwnedForm(ctx.params.sessionID, ctx.params.formID)).form.cancel(ctx.params.formID).pipe(Effect.catchTags({
|
|
307
|
-
"Form.AlreadySettledError": (error) => new FormAlreadySettledError({ id: error.id, message: error.message }),
|
|
308
|
-
"Form.NotFoundError": () => missingForm(ctx.params.formID)
|
|
309
|
-
}));
|
|
310
|
-
return HttpApiSchema.NoContent.make();
|
|
311
|
-
}));
|
|
312
|
-
}));
|
|
2
|
+
SessionHandler2
|
|
3
|
+
} from "../chunks/process-m8y6333k.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
SessionHandler2 as SessionHandler
|
|
11
|
+
};
|
package/dist/handlers/shell.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})).handle("shell.create", Effect.fn(function* (ctx) {
|
|
13
|
-
const shell = yield* Shell.Service, location = yield* Location.Service;
|
|
14
|
-
return yield* response(shell.create({ ...ctx.payload, cwd: ctx.payload.cwd || location.directory }).pipe(Effect.orDie));
|
|
15
|
-
})).handle("shell.get", Effect.fn(function* (ctx) {
|
|
16
|
-
const shell = yield* Shell.Service;
|
|
17
|
-
return yield* response(shell.get(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
|
|
18
|
-
})).handle("shell.output", Effect.fn(function* (ctx) {
|
|
19
|
-
const shell = yield* Shell.Service;
|
|
20
|
-
return yield* response(shell.output(ctx.params.id, { cursor: ctx.query.cursor, limit: ctx.query.limit }).pipe(Effect.catchTag("Shell.NotFoundError", () => new ShellNotFoundError({ id: ctx.params.id, message: `Shell command not found: ${ctx.params.id}` }))));
|
|
21
|
-
})).handle("shell.remove", Effect.fn(function* (ctx) {
|
|
22
|
-
yield* (yield* Shell.Service).remove(ctx.params.id).pipe(Effect.catchTag("Shell.NotFoundError", () => Effect.void));
|
|
23
|
-
return HttpApiSchema.NoContent.make();
|
|
24
|
-
}));
|
|
25
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
ShellHandler2
|
|
3
|
+
} from "../chunks/process-kheky2r0.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
ShellHandler2 as ShellHandler
|
|
11
|
+
};
|
package/dist/handlers/skill.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
SkillHandler2
|
|
3
|
+
} from "../chunks/process-wt4btb09.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
SkillHandler2 as SkillHandler
|
|
11
|
+
};
|
package/dist/handlers/vcs.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}))).handle("vcs.status", () => response(Effect.gen(function* () {
|
|
13
|
-
return yield* (yield* Vcs.Service).status();
|
|
14
|
-
}))).handle("vcs.branch.list", (ctx) => response(Effect.gen(function* () {
|
|
15
|
-
return yield* (yield* Vcs.Service).branches({ search: ctx.query.search, limit: Math.min(ctx.query.limit ?? 50, 100) });
|
|
16
|
-
}))).handle("vcs.diff", (ctx) => response(Effect.gen(function* () {
|
|
17
|
-
return yield* (yield* Vcs.Service).diff(ctx.query.mode, { context: ctx.query.context, base: ctx.query.base }).pipe(Effect.mapError((error) => new ServiceUnavailableError({ service: "vcs", message: error.message })));
|
|
18
|
-
})));
|
|
19
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
VcsHandler2
|
|
3
|
+
} from "../chunks/process-rkdaz036.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
VcsHandler2 as VcsHandler
|
|
11
|
+
};
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const websearch = yield* WebSearch.Service;
|
|
13
|
-
return yield* response(websearch.query(request.payload).pipe(Effect.catchTags({
|
|
14
|
-
"WebSearch.ProviderRequired": () => new InvalidRequestError({
|
|
15
|
-
message: "Web search provider is required",
|
|
16
|
-
kind: "websearch_provider_required",
|
|
17
|
-
field: "providerID"
|
|
18
|
-
}),
|
|
19
|
-
"WebSearch.ProviderNotFound": (error) => new InvalidRequestError({
|
|
20
|
-
message: `Web search provider not found: ${error.providerID}`,
|
|
21
|
-
kind: "websearch_provider_not_found",
|
|
22
|
-
field: "providerID"
|
|
23
|
-
}),
|
|
24
|
-
"WebSearch.Disabled": () => new InvalidRequestError({ message: "Web search is disabled", kind: "websearch_disabled" }),
|
|
25
|
-
"WebSearch.Request": (error) => new ServiceUnavailableError({
|
|
26
|
-
message: `Web search request failed: ${error.providerID}`,
|
|
27
|
-
service: error.providerID
|
|
28
|
-
})
|
|
29
|
-
})));
|
|
30
|
-
}));
|
|
31
|
-
}));
|
|
1
|
+
import {
|
|
2
|
+
WebSearchHandler2
|
|
3
|
+
} from "../chunks/process-k319q0y1.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
WebSearchHandler2 as WebSearchHandler
|
|
11
|
+
};
|
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}));
|
|
13
|
-
function badRequest(effect) {
|
|
14
|
-
return effect.pipe(Effect.catchTag("Project.NotFoundError", missingProject), Effect.mapError((error) => error instanceof ProjectNotFoundError ? error : new WorktreeError({
|
|
15
|
-
name: "WorktreeError",
|
|
16
|
-
data: {
|
|
17
|
-
message: message(error),
|
|
18
|
-
forceRequired: error instanceof Git.WorktreeError || error instanceof Worktree.OperationError ? error.forceRequired : void 0
|
|
19
|
-
}
|
|
20
|
-
})));
|
|
21
|
-
}
|
|
22
|
-
function missingProject(error) {
|
|
23
|
-
return Effect.fail(new ProjectNotFoundError({ projectID: error.projectID, message: `Project not found: ${error.projectID}` }));
|
|
24
|
-
}
|
|
25
|
-
function message(error) {
|
|
26
|
-
if (error instanceof Worktree.SourceDirectoryNotFoundError)
|
|
27
|
-
return error.directory ? `Worktree source not found: ${error.directory}` : `Worktree source not found for project: ${error.projectID}`;
|
|
28
|
-
if (error instanceof Worktree.DestinationExistsError)
|
|
29
|
-
return `Worktree destination already exists: ${error.directory}`;
|
|
30
|
-
if (error instanceof Worktree.DirectoryUnavailableError)
|
|
31
|
-
return `Worktree directory unavailable: ${error.directory}`;
|
|
32
|
-
if (error instanceof Worktree.InvalidDirectoryError)
|
|
33
|
-
return `Invalid worktree directory: ${error.directory}`;
|
|
34
|
-
if (error instanceof Worktree.StrategyUnavailableError)
|
|
35
|
-
return `Worktree strategy unavailable: ${error.strategy}`;
|
|
36
|
-
return error.message;
|
|
37
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
WorktreeHandler2
|
|
3
|
+
} from "../chunks/process-prrj1pgd.js";
|
|
4
|
+
import"../chunks/process-ks9pc2xc.js";
|
|
5
|
+
import"../chunks/process-kb9735wh.js";
|
|
6
|
+
import"../chunks/process-27edjygf.js";
|
|
7
|
+
import"../chunks/process-8j6eh3dh.js";
|
|
8
|
+
import"../chunks/process-smaf4a18.js";
|
|
9
|
+
export {
|
|
10
|
+
WorktreeHandler2 as WorktreeHandler
|
|
11
|
+
};
|