@getpaseo/server 0.1.97 → 0.1.99
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/server/server/agent/agent-manager.d.ts +11 -3
- package/dist/server/server/agent/agent-manager.js +96 -24
- package/dist/server/server/agent/agent-prompt.d.ts +1 -1
- package/dist/server/server/agent/agent-prompt.js +3 -10
- package/dist/server/server/agent/agent-sdk-types.d.ts +20 -9
- package/dist/server/server/agent/create-agent/create.d.ts +2 -0
- package/dist/server/server/agent/create-agent/create.js +8 -7
- package/dist/server/server/agent/lifecycle-command.d.ts +15 -1
- package/dist/server/server/agent/lifecycle-command.js +9 -2
- package/dist/server/server/agent/mcp-server.js +254 -115
- package/dist/server/server/agent/provider-notices.d.ts +3 -0
- package/dist/server/server/agent/provider-notices.js +5 -0
- package/dist/server/server/agent/provider-registry.d.ts +8 -3
- package/dist/server/server/agent/provider-registry.js +58 -25
- package/dist/server/server/agent/provider-snapshot-manager.d.ts +3 -0
- package/dist/server/server/agent/provider-snapshot-manager.js +37 -16
- package/dist/server/server/agent/providers/acp-agent.d.ts +5 -3
- package/dist/server/server/agent/providers/acp-agent.js +32 -19
- package/dist/server/server/agent/providers/claude/agent.d.ts +2 -2
- package/dist/server/server/agent/providers/claude/agent.js +261 -167
- package/dist/server/server/agent/providers/claude/models.js +7 -3
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts +6 -4
- package/dist/server/server/agent/providers/codex-app-server-agent.js +48 -25
- package/dist/server/server/agent/providers/copilot-acp-agent.js +4 -31
- package/dist/server/server/agent/providers/diagnostic-utils.d.ts +9 -0
- package/dist/server/server/agent/providers/diagnostic-utils.js +188 -0
- package/dist/server/server/agent/providers/generic-acp-agent.d.ts +0 -1
- package/dist/server/server/agent/providers/generic-acp-agent.js +2 -108
- package/dist/server/server/agent/providers/mock-load-test-agent.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-load-test-agent.js +5 -5
- package/dist/server/server/agent/providers/mock-slow-provider.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-slow-provider.js +3 -6
- package/dist/server/server/agent/providers/opencode/server-manager.d.ts +29 -2
- package/dist/server/server/agent/providers/opencode/server-manager.js +83 -17
- package/dist/server/server/agent/providers/opencode-agent.d.ts +6 -3
- package/dist/server/server/agent/providers/opencode-agent.js +61 -107
- package/dist/server/server/agent/providers/pi/agent.d.ts +2 -3
- package/dist/server/server/agent/providers/pi/agent.js +11 -63
- package/dist/server/server/agent/providers/pi/cli-runtime.js +2 -2
- package/dist/server/server/agent/providers/pi/runtime.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.js +1 -1
- package/dist/server/server/bootstrap.d.ts +2 -0
- package/dist/server/server/bootstrap.js +32 -2
- package/dist/server/server/managed-processes/managed-processes.d.ts +76 -0
- package/dist/server/server/managed-processes/managed-processes.js +326 -0
- package/dist/server/server/resolve-worktree-creation-intent.d.ts +3 -0
- package/dist/server/server/resolve-worktree-creation-intent.js +3 -3
- package/dist/server/server/session/agent-config/agent-config-session.d.ts +50 -0
- package/dist/server/server/session/agent-config/agent-config-session.js +98 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.d.ts +120 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.js +489 -0
- package/dist/server/server/session/checkout/checkout-session.d.ts +142 -0
- package/dist/server/server/session/checkout/checkout-session.js +925 -0
- package/dist/server/server/session/daemon/daemon-session.d.ts +50 -0
- package/dist/server/server/session/daemon/daemon-session.js +98 -0
- package/dist/server/server/session/files/workspace-files-session.d.ts +43 -0
- package/dist/server/server/session/files/workspace-files-session.js +218 -0
- package/dist/server/server/session/project-config/project-config-session.d.ts +34 -0
- package/dist/server/server/session/project-config/project-config-session.js +125 -0
- package/dist/server/server/session/provider/provider-catalog-session.d.ts +74 -0
- package/dist/server/server/session/provider/provider-catalog-session.js +339 -0
- package/dist/server/server/session/voice/voice-session.d.ts +166 -0
- package/dist/server/server/session/voice/voice-session.js +893 -0
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.d.ts +2 -2
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.js +2 -2
- package/dist/server/server/session.d.ts +23 -207
- package/dist/server/server/session.js +2319 -5102
- package/dist/server/server/speech/providers/openai/runtime.js +3 -4
- package/dist/server/server/websocket-server.d.ts +1 -0
- package/dist/server/server/websocket-server.js +11 -0
- package/dist/server/server/workspace-archive-service.js +2 -3
- package/dist/server/server/workspace-directory.js +5 -5
- package/dist/server/server/workspace-reconciliation-service.js +2 -2
- package/dist/server/server/worktree-core.d.ts +1 -0
- package/dist/server/server/worktree-core.js +5 -1
- package/dist/server/services/quota-fetcher/manifest.d.ts +4 -0
- package/dist/server/services/quota-fetcher/manifest.js +47 -0
- package/dist/server/services/quota-fetcher/provider.d.ts +17 -0
- package/dist/server/services/quota-fetcher/provider.js +2 -0
- package/dist/server/services/quota-fetcher/providers/claude.d.ts +26 -0
- package/dist/server/services/quota-fetcher/providers/claude.js +217 -0
- package/dist/server/services/quota-fetcher/providers/codex.d.ts +23 -0
- package/dist/server/services/quota-fetcher/providers/codex.js +211 -0
- package/dist/server/services/quota-fetcher/providers/copilot.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/copilot.js +75 -0
- package/dist/server/services/quota-fetcher/providers/cursor.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/cursor.js +123 -0
- package/dist/server/services/quota-fetcher/providers/grok.d.ts +18 -0
- package/dist/server/services/quota-fetcher/providers/grok.js +89 -0
- package/dist/server/services/quota-fetcher/providers/kimi.d.ts +20 -0
- package/dist/server/services/quota-fetcher/providers/kimi.js +89 -0
- package/dist/server/services/quota-fetcher/providers/zai.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/zai.js +58 -0
- package/dist/server/services/quota-fetcher/service.d.ts +28 -0
- package/dist/server/services/quota-fetcher/service.js +58 -0
- package/dist/server/services/quota-fetcher/usage.d.ts +22 -0
- package/dist/server/services/quota-fetcher/usage.js +49 -0
- package/dist/server/utils/checkout-git.d.ts +6 -0
- package/dist/server/utils/directory-suggestions.js +98 -2
- package/package.json +5 -5
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { ChatServiceError, parseMentionAgentIds, } from "../../chat/chat-service.js";
|
|
2
|
+
import { notifyChatMentions, prepareChatMentionFanout } from "../../chat/chat-mentions.js";
|
|
3
|
+
/**
|
|
4
|
+
* A client's chat, schedule, and loop request surface. The three families are the
|
|
5
|
+
* least-coupled in the session: each is a stateless request/response over its own
|
|
6
|
+
* service (chat rooms, cron routines, autonomous loops), with no shared observer,
|
|
7
|
+
* git, or voice state and no subscriptions to tear down. They live in one subsystem
|
|
8
|
+
* because they are dispatched together — schedule/* was historically reached through
|
|
9
|
+
* the chat dispatcher's fall-through arm. The three rpc-error emitters stay separate:
|
|
10
|
+
* they differ by default code, and only the chat one reads ChatServiceError.code.
|
|
11
|
+
*/
|
|
12
|
+
export class ChatScheduleLoopSession {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.host = options.host;
|
|
15
|
+
this.chatService = options.chatService;
|
|
16
|
+
this.scheduleService = options.scheduleService;
|
|
17
|
+
this.loopService = options.loopService;
|
|
18
|
+
this.clientId = options.clientId;
|
|
19
|
+
this.logger = options.logger;
|
|
20
|
+
}
|
|
21
|
+
emitChatRpcError(request, error) {
|
|
22
|
+
const message = error instanceof Error ? error.message : "Chat request failed";
|
|
23
|
+
const code = error instanceof ChatServiceError ? error.code : "chat_request_failed";
|
|
24
|
+
this.logger.error({ err: error, requestType: request.type }, "Chat request failed");
|
|
25
|
+
this.host.emit({
|
|
26
|
+
type: "rpc_error",
|
|
27
|
+
payload: {
|
|
28
|
+
requestId: request.requestId,
|
|
29
|
+
requestType: request.type,
|
|
30
|
+
error: message,
|
|
31
|
+
code,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async handleChatCreateRequest(request) {
|
|
36
|
+
try {
|
|
37
|
+
const room = await this.chatService.createRoom({
|
|
38
|
+
name: request.name,
|
|
39
|
+
purpose: request.purpose,
|
|
40
|
+
});
|
|
41
|
+
this.host.emit({
|
|
42
|
+
type: "chat/create/response",
|
|
43
|
+
payload: {
|
|
44
|
+
requestId: request.requestId,
|
|
45
|
+
room,
|
|
46
|
+
error: null,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
this.emitChatRpcError(request, error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async handleChatListRequest(request) {
|
|
55
|
+
try {
|
|
56
|
+
const rooms = await this.chatService.listRooms();
|
|
57
|
+
this.host.emit({
|
|
58
|
+
type: "chat/list/response",
|
|
59
|
+
payload: {
|
|
60
|
+
requestId: request.requestId,
|
|
61
|
+
rooms,
|
|
62
|
+
error: null,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
this.emitChatRpcError(request, error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async handleChatInspectRequest(request) {
|
|
71
|
+
try {
|
|
72
|
+
const result = await this.chatService.inspectRoom({
|
|
73
|
+
room: request.room,
|
|
74
|
+
});
|
|
75
|
+
this.host.emit({
|
|
76
|
+
type: "chat/inspect/response",
|
|
77
|
+
payload: {
|
|
78
|
+
requestId: request.requestId,
|
|
79
|
+
room: result.room,
|
|
80
|
+
error: null,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
this.emitChatRpcError(request, error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async handleChatDeleteRequest(request) {
|
|
89
|
+
try {
|
|
90
|
+
const result = await this.chatService.deleteRoom({
|
|
91
|
+
room: request.room,
|
|
92
|
+
});
|
|
93
|
+
this.host.emit({
|
|
94
|
+
type: "chat/delete/response",
|
|
95
|
+
payload: {
|
|
96
|
+
requestId: request.requestId,
|
|
97
|
+
room: result.room,
|
|
98
|
+
error: null,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.emitChatRpcError(request, error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async handleChatPostRequest(request) {
|
|
107
|
+
try {
|
|
108
|
+
const authorAgentId = request.authorAgentId?.trim() || this.clientId;
|
|
109
|
+
const mentionAgentIds = parseMentionAgentIds(request.body);
|
|
110
|
+
const storedAgents = await this.host.listStoredAgents();
|
|
111
|
+
const liveAgents = this.host.listLiveAgents();
|
|
112
|
+
const fanout = await prepareChatMentionFanout({
|
|
113
|
+
authorAgentId,
|
|
114
|
+
mentionAgentIds,
|
|
115
|
+
storedAgents,
|
|
116
|
+
liveAgents,
|
|
117
|
+
listRoomPosterAgentIds: () => this.chatService.listRoomPosterAgentIds({ room: request.room }),
|
|
118
|
+
});
|
|
119
|
+
if (!fanout.ok) {
|
|
120
|
+
throw new ChatServiceError("chat_mention_fanout_limit_exceeded", fanout.error);
|
|
121
|
+
}
|
|
122
|
+
const message = await this.chatService.dispatchMessage({
|
|
123
|
+
room: request.room,
|
|
124
|
+
authorAgentId,
|
|
125
|
+
body: request.body,
|
|
126
|
+
replyToMessageId: request.replyToMessageId,
|
|
127
|
+
});
|
|
128
|
+
this.host.emit({
|
|
129
|
+
type: "chat/post/response",
|
|
130
|
+
payload: {
|
|
131
|
+
requestId: request.requestId,
|
|
132
|
+
message,
|
|
133
|
+
error: null,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
void notifyChatMentions({
|
|
137
|
+
room: request.room,
|
|
138
|
+
authorAgentId,
|
|
139
|
+
body: request.body,
|
|
140
|
+
mentionAgentIds: message.mentionAgentIds,
|
|
141
|
+
logger: this.logger,
|
|
142
|
+
storedAgents,
|
|
143
|
+
liveAgents,
|
|
144
|
+
prepared: fanout.prepared,
|
|
145
|
+
resolveAgentIdentifier: (identifier) => this.host.resolveAgentIdentifier(identifier),
|
|
146
|
+
sendAgentMessage: (agentId, text) => this.host.sendAgentMessage(agentId, text),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
this.emitChatRpcError(request, error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async handleChatReadRequest(request) {
|
|
154
|
+
try {
|
|
155
|
+
const messages = await this.chatService.readMessages({
|
|
156
|
+
room: request.room,
|
|
157
|
+
limit: request.limit,
|
|
158
|
+
since: request.since,
|
|
159
|
+
authorAgentId: request.authorAgentId,
|
|
160
|
+
});
|
|
161
|
+
this.host.emit({
|
|
162
|
+
type: "chat/read/response",
|
|
163
|
+
payload: {
|
|
164
|
+
requestId: request.requestId,
|
|
165
|
+
messages,
|
|
166
|
+
error: null,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
this.emitChatRpcError(request, error);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async handleChatWaitRequest(request) {
|
|
175
|
+
try {
|
|
176
|
+
const messages = await this.chatService.waitForMessages({
|
|
177
|
+
room: request.room,
|
|
178
|
+
afterMessageId: request.afterMessageId,
|
|
179
|
+
timeoutMs: request.timeoutMs,
|
|
180
|
+
});
|
|
181
|
+
this.host.emit({
|
|
182
|
+
type: "chat/wait/response",
|
|
183
|
+
payload: {
|
|
184
|
+
requestId: request.requestId,
|
|
185
|
+
messages,
|
|
186
|
+
timedOut: messages.length === 0,
|
|
187
|
+
error: null,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
this.emitChatRpcError(request, error);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
toScheduleSummary(schedule) {
|
|
196
|
+
const { runs: _runs, ...summary } = schedule;
|
|
197
|
+
return summary;
|
|
198
|
+
}
|
|
199
|
+
emitScheduleRpcError(request, error) {
|
|
200
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
201
|
+
this.logger.error({ err: error, requestType: request.type }, "Schedule request failed");
|
|
202
|
+
this.host.emit({
|
|
203
|
+
type: "rpc_error",
|
|
204
|
+
payload: {
|
|
205
|
+
requestId: request.requestId,
|
|
206
|
+
requestType: request.type,
|
|
207
|
+
error: message,
|
|
208
|
+
code: "schedule_request_failed",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async handleScheduleCreateRequest(request) {
|
|
213
|
+
try {
|
|
214
|
+
const target = request.target.type === "self"
|
|
215
|
+
? { type: "agent", agentId: request.target.agentId }
|
|
216
|
+
: request.target;
|
|
217
|
+
const schedule = await this.scheduleService.create({
|
|
218
|
+
prompt: request.prompt,
|
|
219
|
+
name: request.name,
|
|
220
|
+
cadence: request.cadence,
|
|
221
|
+
target,
|
|
222
|
+
maxRuns: request.maxRuns,
|
|
223
|
+
expiresAt: request.expiresAt,
|
|
224
|
+
runOnCreate: request.runOnCreate,
|
|
225
|
+
});
|
|
226
|
+
this.host.emit({
|
|
227
|
+
type: "schedule/create/response",
|
|
228
|
+
payload: {
|
|
229
|
+
requestId: request.requestId,
|
|
230
|
+
schedule: this.toScheduleSummary(schedule),
|
|
231
|
+
error: null,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
this.emitScheduleRpcError(request, error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async handleScheduleListRequest(request) {
|
|
240
|
+
try {
|
|
241
|
+
const schedules = await this.scheduleService.list();
|
|
242
|
+
this.host.emit({
|
|
243
|
+
type: "schedule/list/response",
|
|
244
|
+
payload: {
|
|
245
|
+
requestId: request.requestId,
|
|
246
|
+
schedules: schedules.map((schedule) => this.toScheduleSummary(schedule)),
|
|
247
|
+
error: null,
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
this.emitScheduleRpcError(request, error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async handleScheduleInspectRequest(request) {
|
|
256
|
+
try {
|
|
257
|
+
const schedule = await this.scheduleService.inspect(request.scheduleId);
|
|
258
|
+
this.host.emit({
|
|
259
|
+
type: "schedule/inspect/response",
|
|
260
|
+
payload: {
|
|
261
|
+
requestId: request.requestId,
|
|
262
|
+
schedule,
|
|
263
|
+
error: null,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
this.emitScheduleRpcError(request, error);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async handleScheduleLogsRequest(request) {
|
|
272
|
+
try {
|
|
273
|
+
const runs = await this.scheduleService.logs(request.scheduleId);
|
|
274
|
+
this.host.emit({
|
|
275
|
+
type: "schedule/logs/response",
|
|
276
|
+
payload: {
|
|
277
|
+
requestId: request.requestId,
|
|
278
|
+
runs,
|
|
279
|
+
error: null,
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
this.emitScheduleRpcError(request, error);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async handleSchedulePauseRequest(request) {
|
|
288
|
+
try {
|
|
289
|
+
const schedule = await this.scheduleService.pause(request.scheduleId);
|
|
290
|
+
this.host.emit({
|
|
291
|
+
type: "schedule/pause/response",
|
|
292
|
+
payload: {
|
|
293
|
+
requestId: request.requestId,
|
|
294
|
+
schedule: this.toScheduleSummary(schedule),
|
|
295
|
+
error: null,
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
this.emitScheduleRpcError(request, error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async handleScheduleResumeRequest(request) {
|
|
304
|
+
try {
|
|
305
|
+
const schedule = await this.scheduleService.resume(request.scheduleId);
|
|
306
|
+
this.host.emit({
|
|
307
|
+
type: "schedule/resume/response",
|
|
308
|
+
payload: {
|
|
309
|
+
requestId: request.requestId,
|
|
310
|
+
schedule: this.toScheduleSummary(schedule),
|
|
311
|
+
error: null,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
this.emitScheduleRpcError(request, error);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async handleScheduleDeleteRequest(request) {
|
|
320
|
+
try {
|
|
321
|
+
await this.scheduleService.delete(request.scheduleId);
|
|
322
|
+
this.host.emit({
|
|
323
|
+
type: "schedule/delete/response",
|
|
324
|
+
payload: {
|
|
325
|
+
requestId: request.requestId,
|
|
326
|
+
scheduleId: request.scheduleId,
|
|
327
|
+
error: null,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
this.emitScheduleRpcError(request, error);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async handleScheduleRunOnceRequest(request) {
|
|
336
|
+
try {
|
|
337
|
+
const schedule = await this.scheduleService.runOnce(request.scheduleId);
|
|
338
|
+
this.host.emit({
|
|
339
|
+
type: "schedule/run-once/response",
|
|
340
|
+
payload: {
|
|
341
|
+
requestId: request.requestId,
|
|
342
|
+
schedule,
|
|
343
|
+
error: null,
|
|
344
|
+
},
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
this.emitScheduleRpcError(request, error);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async handleScheduleUpdateRequest(request) {
|
|
352
|
+
try {
|
|
353
|
+
const schedule = await this.scheduleService.update({
|
|
354
|
+
id: request.scheduleId,
|
|
355
|
+
...(request.name !== undefined ? { name: request.name } : {}),
|
|
356
|
+
...(request.prompt !== undefined ? { prompt: request.prompt } : {}),
|
|
357
|
+
...(request.cadence !== undefined ? { cadence: request.cadence } : {}),
|
|
358
|
+
...(request.newAgentConfig !== undefined ? { newAgentConfig: request.newAgentConfig } : {}),
|
|
359
|
+
...(request.maxRuns !== undefined ? { maxRuns: request.maxRuns } : {}),
|
|
360
|
+
...(request.expiresAt !== undefined ? { expiresAt: request.expiresAt } : {}),
|
|
361
|
+
});
|
|
362
|
+
this.host.emit({
|
|
363
|
+
type: "schedule/update/response",
|
|
364
|
+
payload: {
|
|
365
|
+
requestId: request.requestId,
|
|
366
|
+
schedule,
|
|
367
|
+
error: null,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
this.emitScheduleRpcError(request, error);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
emitLoopRpcError(request, error) {
|
|
376
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
377
|
+
this.logger.error({ err: error, requestType: request.type }, "Loop request failed");
|
|
378
|
+
this.host.emit({
|
|
379
|
+
type: "rpc_error",
|
|
380
|
+
payload: {
|
|
381
|
+
requestId: request.requestId,
|
|
382
|
+
requestType: request.type,
|
|
383
|
+
error: message,
|
|
384
|
+
code: "loop_request_failed",
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async handleLoopRunRequest(request) {
|
|
389
|
+
try {
|
|
390
|
+
const loop = await this.loopService.runLoop({
|
|
391
|
+
prompt: request.prompt,
|
|
392
|
+
cwd: request.cwd,
|
|
393
|
+
provider: request.provider,
|
|
394
|
+
model: request.model,
|
|
395
|
+
modeId: request.modeId,
|
|
396
|
+
workerProvider: request.workerProvider,
|
|
397
|
+
workerModel: request.workerModel,
|
|
398
|
+
verifierProvider: request.verifierProvider,
|
|
399
|
+
verifierModel: request.verifierModel,
|
|
400
|
+
verifierModeId: request.verifierModeId,
|
|
401
|
+
verifyPrompt: request.verifyPrompt,
|
|
402
|
+
verifyChecks: request.verifyChecks,
|
|
403
|
+
archive: request.archive,
|
|
404
|
+
name: request.name,
|
|
405
|
+
sleepMs: request.sleepMs,
|
|
406
|
+
maxIterations: request.maxIterations,
|
|
407
|
+
maxTimeMs: request.maxTimeMs,
|
|
408
|
+
});
|
|
409
|
+
this.host.emit({
|
|
410
|
+
type: "loop/run/response",
|
|
411
|
+
payload: {
|
|
412
|
+
requestId: request.requestId,
|
|
413
|
+
loop,
|
|
414
|
+
error: null,
|
|
415
|
+
},
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
this.emitLoopRpcError(request, error);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
async handleLoopListRequest(request) {
|
|
423
|
+
try {
|
|
424
|
+
const loops = await this.loopService.listLoops();
|
|
425
|
+
this.host.emit({
|
|
426
|
+
type: "loop/list/response",
|
|
427
|
+
payload: {
|
|
428
|
+
requestId: request.requestId,
|
|
429
|
+
loops,
|
|
430
|
+
error: null,
|
|
431
|
+
},
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
this.emitLoopRpcError(request, error);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
async handleLoopInspectRequest(request) {
|
|
439
|
+
try {
|
|
440
|
+
const loop = await this.loopService.inspectLoop(request.id);
|
|
441
|
+
this.host.emit({
|
|
442
|
+
type: "loop/inspect/response",
|
|
443
|
+
payload: {
|
|
444
|
+
requestId: request.requestId,
|
|
445
|
+
loop,
|
|
446
|
+
error: null,
|
|
447
|
+
},
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
451
|
+
this.emitLoopRpcError(request, error);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
async handleLoopLogsRequest(request) {
|
|
455
|
+
try {
|
|
456
|
+
const result = await this.loopService.getLoopLogs(request.id, request.afterSeq ?? 0);
|
|
457
|
+
this.host.emit({
|
|
458
|
+
type: "loop/logs/response",
|
|
459
|
+
payload: {
|
|
460
|
+
requestId: request.requestId,
|
|
461
|
+
loop: result.loop,
|
|
462
|
+
entries: result.entries,
|
|
463
|
+
nextCursor: result.nextCursor,
|
|
464
|
+
error: null,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
this.emitLoopRpcError(request, error);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async handleLoopStopRequest(request) {
|
|
473
|
+
try {
|
|
474
|
+
const loop = await this.loopService.stopLoop(request.id);
|
|
475
|
+
this.host.emit({
|
|
476
|
+
type: "loop/stop/response",
|
|
477
|
+
payload: {
|
|
478
|
+
requestId: request.requestId,
|
|
479
|
+
loop,
|
|
480
|
+
error: null,
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
this.emitLoopRpcError(request, error);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
//# sourceMappingURL=chat-schedule-loop-session.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type pino from "pino";
|
|
2
|
+
import type { BranchSuggestionsRequest, CheckoutRefreshRequest, CheckoutRenameBranchRequest, CheckoutStatusRequest, SessionInboundMessage, SessionOutboundMessage, SubscribeCheckoutDiffRequest, UnsubscribeCheckoutDiffRequest, ValidateBranchRequest } from "../../messages.js";
|
|
3
|
+
import type { CheckoutDiffCompareInput, CheckoutDiffSnapshotPayload } from "../../checkout-diff-manager.js";
|
|
4
|
+
import type { WorkspaceGitRuntimeSnapshot, WorkspaceGitService } from "../../workspace-git-service.js";
|
|
5
|
+
import { type GitHubService } from "../../../services/github-service.js";
|
|
6
|
+
import { type CheckoutExistingBranchResult, type GitMutationRefreshReason } from "../../../utils/checkout-git.js";
|
|
7
|
+
/**
|
|
8
|
+
* The collaborators a checkout command reaches that are NOT part of the checkout
|
|
9
|
+
* domain: the git-mutation refresh primitive and workspace-update emitters owned
|
|
10
|
+
* by the Session shell (also used by worktree/workspace creation), the injected
|
|
11
|
+
* branch operations, and the LLM-backed commit/PR text generators. CheckoutSession
|
|
12
|
+
* orchestrates them but does not own them.
|
|
13
|
+
*/
|
|
14
|
+
export interface CheckoutSessionHost {
|
|
15
|
+
emit(msg: SessionOutboundMessage): void;
|
|
16
|
+
notifyGitMutation(cwd: string, reason: GitMutationRefreshReason, options?: {
|
|
17
|
+
invalidateGithub?: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
emitWorkspaceUpdateForCwd(cwd: string): Promise<void>;
|
|
20
|
+
handleWorkspaceGitBranchSnapshot(cwd: string, branchName: string | null): void;
|
|
21
|
+
renameCurrentBranch(cwd: string, branch: string): Promise<{
|
|
22
|
+
previousBranch: string | null;
|
|
23
|
+
currentBranch: string | null;
|
|
24
|
+
}>;
|
|
25
|
+
checkoutExistingBranch(cwd: string, branch: string): Promise<CheckoutExistingBranchResult>;
|
|
26
|
+
generateCommitMessage(cwd: string): Promise<string>;
|
|
27
|
+
generatePullRequestText(cwd: string, baseRef?: string): Promise<{
|
|
28
|
+
title: string;
|
|
29
|
+
body: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The slice of CheckoutDiffManager that CheckoutSession needs: open a live diff
|
|
34
|
+
* subscription, and nudge open subscriptions to recompute after a mutation. The
|
|
35
|
+
* real CheckoutDiffManager satisfies this structurally; tests supply a fake.
|
|
36
|
+
*/
|
|
37
|
+
export interface CheckoutDiffSubscriber {
|
|
38
|
+
subscribe(params: {
|
|
39
|
+
cwd: string;
|
|
40
|
+
compare: CheckoutDiffCompareInput;
|
|
41
|
+
}, listener: (snapshot: CheckoutDiffSnapshotPayload) => void): Promise<{
|
|
42
|
+
initial: CheckoutDiffSnapshotPayload;
|
|
43
|
+
unsubscribe: () => void;
|
|
44
|
+
}>;
|
|
45
|
+
scheduleRefreshForCwd(cwd: string): void;
|
|
46
|
+
}
|
|
47
|
+
export interface CheckoutSessionOptions {
|
|
48
|
+
host: CheckoutSessionHost;
|
|
49
|
+
workspaceGitService: WorkspaceGitService;
|
|
50
|
+
github: GitHubService;
|
|
51
|
+
checkoutDiffManager: CheckoutDiffSubscriber;
|
|
52
|
+
paseoHome: string;
|
|
53
|
+
worktreesRoot: string | undefined;
|
|
54
|
+
logger: pino.Logger;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A client's checkout view, both sides: the read & live-stream side (status
|
|
58
|
+
* queries, branch validation/suggestions, manual refresh, live git-diff and
|
|
59
|
+
* checkout-status subscriptions) and the command side (switch/rename/commit/
|
|
60
|
+
* merge/pull/push/stash and the GitHub-PR operations).
|
|
61
|
+
*
|
|
62
|
+
* Command operations keep the live diff in sync by calling scheduleDiffRefresh()
|
|
63
|
+
* and refresh the workspace git snapshot through host.notifyGitMutation(); the
|
|
64
|
+
* workspace git observer streams branch changes through emitStatusUpdate().
|
|
65
|
+
*/
|
|
66
|
+
export declare class CheckoutSession {
|
|
67
|
+
private static readonly PASEO_STASH_PREFIX;
|
|
68
|
+
private readonly host;
|
|
69
|
+
private readonly workspaceGitService;
|
|
70
|
+
private readonly github;
|
|
71
|
+
private readonly checkoutDiffManager;
|
|
72
|
+
private readonly paseoHome;
|
|
73
|
+
private readonly worktreesRoot;
|
|
74
|
+
private readonly logger;
|
|
75
|
+
private readonly diffSubscriptions;
|
|
76
|
+
constructor(options: CheckoutSessionOptions);
|
|
77
|
+
handleStatusRequest(msg: CheckoutStatusRequest): Promise<void>;
|
|
78
|
+
handleValidateBranchRequest(msg: ValidateBranchRequest): Promise<void>;
|
|
79
|
+
handleBranchSuggestionsRequest(msg: BranchSuggestionsRequest): Promise<void>;
|
|
80
|
+
handleSubscribeDiffRequest(msg: SubscribeCheckoutDiffRequest): Promise<void>;
|
|
81
|
+
handleUnsubscribeDiffRequest(msg: UnsubscribeCheckoutDiffRequest): void;
|
|
82
|
+
handleRefreshRequest(msg: CheckoutRefreshRequest): Promise<void>;
|
|
83
|
+
emitStatusUpdate(cwd: string, snapshot: WorkspaceGitRuntimeSnapshot): void;
|
|
84
|
+
/**
|
|
85
|
+
* Notify the live diff subscriptions that the working tree at `cwd` changed.
|
|
86
|
+
* Called by the command handlers below after they mutate the repository.
|
|
87
|
+
*/
|
|
88
|
+
private scheduleDiffRefresh;
|
|
89
|
+
handleCheckoutSwitchBranchRequest(msg: Extract<SessionInboundMessage, {
|
|
90
|
+
type: "checkout_switch_branch_request";
|
|
91
|
+
}>): Promise<void>;
|
|
92
|
+
handleCheckoutRenameBranchRequest(msg: CheckoutRenameBranchRequest): Promise<void>;
|
|
93
|
+
handleStashSaveRequest(msg: Extract<SessionInboundMessage, {
|
|
94
|
+
type: "stash_save_request";
|
|
95
|
+
}>): Promise<void>;
|
|
96
|
+
handleStashPopRequest(msg: Extract<SessionInboundMessage, {
|
|
97
|
+
type: "stash_pop_request";
|
|
98
|
+
}>): Promise<void>;
|
|
99
|
+
handleStashListRequest(msg: Extract<SessionInboundMessage, {
|
|
100
|
+
type: "stash_list_request";
|
|
101
|
+
}>): Promise<void>;
|
|
102
|
+
handleCheckoutCommitRequest(msg: Extract<SessionInboundMessage, {
|
|
103
|
+
type: "checkout_commit_request";
|
|
104
|
+
}>): Promise<void>;
|
|
105
|
+
handleCheckoutMergeRequest(msg: Extract<SessionInboundMessage, {
|
|
106
|
+
type: "checkout_merge_request";
|
|
107
|
+
}>): Promise<void>;
|
|
108
|
+
handleCheckoutMergeFromBaseRequest(msg: Extract<SessionInboundMessage, {
|
|
109
|
+
type: "checkout_merge_from_base_request";
|
|
110
|
+
}>): Promise<void>;
|
|
111
|
+
handleCheckoutPullRequest(msg: Extract<SessionInboundMessage, {
|
|
112
|
+
type: "checkout_pull_request";
|
|
113
|
+
}>): Promise<void>;
|
|
114
|
+
handleCheckoutPushRequest(msg: Extract<SessionInboundMessage, {
|
|
115
|
+
type: "checkout_push_request";
|
|
116
|
+
}>): Promise<void>;
|
|
117
|
+
handleCheckoutPrCreateRequest(msg: Extract<SessionInboundMessage, {
|
|
118
|
+
type: "checkout_pr_create_request";
|
|
119
|
+
}>): Promise<void>;
|
|
120
|
+
handleCheckoutPrMergeRequest(msg: Extract<SessionInboundMessage, {
|
|
121
|
+
type: "checkout_pr_merge_request";
|
|
122
|
+
}>): Promise<void>;
|
|
123
|
+
private assertCurrentPullRequestHasGithubMergeFacts;
|
|
124
|
+
handleCheckoutGithubSetAutoMergeRequest(msg: Extract<SessionInboundMessage, {
|
|
125
|
+
type: "checkout.github.set_auto_merge.request";
|
|
126
|
+
}>): Promise<void>;
|
|
127
|
+
private resolveCurrentPullRequest;
|
|
128
|
+
handleCheckoutPrStatusRequest(msg: Extract<SessionInboundMessage, {
|
|
129
|
+
type: "checkout_pr_status_request";
|
|
130
|
+
}>): Promise<void>;
|
|
131
|
+
handlePullRequestTimelineRequest(msg: Extract<SessionInboundMessage, {
|
|
132
|
+
type: "pull_request_timeline_request";
|
|
133
|
+
}>): Promise<void>;
|
|
134
|
+
handleCheckoutGithubGetCheckDetailsRequest(msg: Extract<SessionInboundMessage, {
|
|
135
|
+
type: "checkout.github.get_check_details.request";
|
|
136
|
+
}>): Promise<void>;
|
|
137
|
+
handleGitHubSearchRequest(msg: Extract<SessionInboundMessage, {
|
|
138
|
+
type: "github_search_request";
|
|
139
|
+
}>): Promise<void>;
|
|
140
|
+
cleanup(): void;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=checkout-session.d.ts.map
|