Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

commands.ts

1,310 lines44.6 KB

1import { msg } from "gt-i18n";
2import { translatableMessage } from "../errors/translatable.ts";
3import { remapComposerContextAttachments } from "@t3tools/shared/composerContextReferences";
4import {
5 type ThreadLinkedPullRequest,
6 CommandId,
7 CheckpointId,
8 CheckpointScopeId,
9 ORCHESTRATION_V2_WS_METHODS,
10 OrchestrationV2CheckpointUnavailableError,
11 WS_METHODS,
12 type ChatAttachment,
13 MessageId,
14 type ModelSelection,
15 type NodeId,
16 type OrchestrationV2Command,
17 type OrchestrationV2CreationSource,
18 type PlanId,
19 type ProjectId,
20 type ProjectIconOverride,
21 type ProjectScript,
22 type ProjectTrackedFolder,
23 type ProviderApprovalDecision,
24 type ProviderInteractionMode,
25 type ProviderUserInputAnswers,
26 type RunId,
27 type RuntimeMode,
28 type RuntimeRequestId,
29 type ThreadId,
30 type ThreadEnvMode,
31 type UploadChatAttachment,
32 type GuestMessageId,
33} from "@t3tools/contracts";
34import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
35import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
36import * as SecureRandom from "effect/crypto/SecureRandom";
37import * as Cause from "effect/Cause";
38import * as Effect from "effect/Effect";
39import * as Exit from "effect/Exit";
40import * as Option from "effect/Option";
41import * as Stream from "effect/Stream";
42import * as SubscriptionRef from "effect/SubscriptionRef";
43​
44import * as EnvironmentSupervisor from "../connection/supervisor.ts";
45import {
46 EnvironmentRpcUnavailableError,
47 getInitialServerConfig,
48 isRpcClientError,
49 request,
50} from "../rpc/client.ts";
51import { repositoryCheckpointScopeIds } from "../state/threadRepositories.ts";
52​
53interface CommandMetadata {
54 readonly commandId?: CommandId;
55 readonly createdAt?: string;
56 readonly creationSource?: OrchestrationV2CreationSource;
58​
59export interface CreateProjectInput extends CommandMetadata {
60 readonly projectId: ProjectId;
61 readonly title: string;
62 readonly workspaceRoot: string;
63 readonly createWorkspaceRootIfMissing?: boolean;
64 readonly defaultModelSelection?: ModelSelection | null;
65 readonly scripts?: ReadonlyArray<ProjectScript>;
66 readonly trackedFolders?: ReadonlyArray<ProjectTrackedFolder>;
68​
69export interface UpdateProjectInput extends CommandMetadata {
70 readonly projectId: ProjectId;
71 readonly title?: string;
72 readonly workspaceRoot?: string;
73 readonly defaultModelSelection?: ModelSelection | null;
74 readonly autoPull?: boolean;
75 readonly projectIcon?: ProjectIconOverride | null;
76 readonly faviconPath?: string | null;
77 readonly defaultThreadEnvMode?: ThreadEnvMode | null;
78 readonly scripts?: ReadonlyArray<ProjectScript>;
79 /** Replaces the whole list. Paths only mean something on the project's own environment. */
80 readonly trackedFolders?: ReadonlyArray<ProjectTrackedFolder>;
81 /** Added to, and removed by path from, the list as the server has it. */
82 readonly trackFolders?: ReadonlyArray<ProjectTrackedFolder>;
83 readonly untrackFolders?: ReadonlyArray<string>;
84 readonly pinned?: boolean;
85 readonly archived?: boolean;
87​
88export interface DeleteProjectInput extends CommandMetadata {
89 readonly projectId: ProjectId;
90 readonly force?: boolean;
92​
93export interface CreateThreadInput extends CommandMetadata {
94 readonly threadId: ThreadId;
95 readonly projectId: ProjectId;
96 readonly title: string;
97 readonly modelSelection: ModelSelection;
98 readonly runtimeMode: RuntimeMode;
99 readonly interactionMode: ProviderInteractionMode;
100 readonly branch: string | null;
101 readonly worktreePath: string | null;
103​
104export interface ThreadCommandInput extends CommandMetadata {
105 readonly threadId: ThreadId;
107​
108export interface DeleteThreadInput extends ThreadCommandInput {
109 /** The server deletes only a thread with no runs and no messages. */
110 readonly onlyIfUnused?: boolean;
112export type ArchiveThreadInput = ThreadCommandInput;
113export type UnarchiveThreadInput = ThreadCommandInput;
114export type SettleThreadInput = ThreadCommandInput;
115​
116export interface UnsettleThreadInput extends ThreadCommandInput {
117 readonly reason: "user";
118 readonly restoreUnsettledAt?: string | null;
120​
121export interface PinThreadInput extends ThreadCommandInput {
122 readonly orderKey?: string;
124export type UnpinThreadInput = ThreadCommandInput;
125​
126export interface ReorderPinnedThreadInput extends ThreadCommandInput {
127 readonly orderKey: string;
129​
130export interface ReorderActiveThreadInput extends ThreadCommandInput {
131 readonly orderKey: string;
133​
134export interface SnoozeThreadInput extends ThreadCommandInput {
135 readonly snoozedUntil: string;
137​
138export interface UnsnoozeThreadInput extends ThreadCommandInput {
139 readonly reason: "user";
141​
142export interface VisitThreadInput extends ThreadCommandInput {
143 readonly visitedAt: string;
144 /** Counts toward search frecency; `searchQuery` is the palette query that picked it. */
145 readonly opened?: boolean;
146 readonly searchQuery?: string;
148​
149export type MarkThreadUnreadInput = ThreadCommandInput;
150​
151export interface UpdateThreadMetadataInput extends ThreadCommandInput {
152 readonly limitRecovery?: import("@t3tools/contracts").OrchestrationV2LimitRecoveryUpdate | null;
153 readonly title?: string;
154 readonly modelSelection?: ModelSelection;
155 readonly branch?: string | null;
156 readonly worktreePath?: string | null;
157 readonly regenerateTitle?: boolean;
158 readonly linkedPullRequest?: ThreadLinkedPullRequest | null;
159 readonly expectedEmpty?: boolean;
161​
162export interface SetThreadRuntimeModeInput extends ThreadCommandInput {
163 readonly runtimeMode: RuntimeMode;
165​
166export interface SetThreadInteractionModeInput extends ThreadCommandInput {
167 readonly interactionMode: ProviderInteractionMode;
169​
170interface StartThreadBootstrap {
171 readonly createThread?: {
172 readonly projectId: ProjectId;
173 readonly title: string;
174 readonly modelSelection: ModelSelection;
175 readonly runtimeMode: RuntimeMode;
176 readonly interactionMode: ProviderInteractionMode;
177 readonly branch: string | null;
178 readonly worktreePath: string | null;
179 readonly createdAt: string;
180 };
181 readonly prepareWorktree?: {
182 readonly requireWorktree?: boolean;
183 readonly projectCwd: string;
184 readonly baseBranch: string;
185 readonly branch?: string;
186 readonly startFromOrigin?: boolean;
187 /** Tracked repositories to give a worktree; absent leaves the choice to the server. */
188 readonly repositories?: ReadonlyArray<{ readonly path: string }>;
189 };
190 readonly runSetupScript?: boolean;
192​
193export interface StartThreadTurnInput extends ThreadCommandInput {
194 readonly manualContinuationOfRunId?: RunId;
195 readonly message: {
196 readonly messageId: MessageId;
197 readonly role: "user";
198 readonly text: string;
199 readonly attachments: ReadonlyArray<ChatAttachment | UploadChatAttachment>;
200 readonly context?: import("@t3tools/contracts").OrchestrationMessageContext;
201 readonly idleCompaction?: import("@t3tools/contracts").OrchestrationV2IdleCompaction;
202 };
203 readonly modelSelection?: ModelSelection;
204 readonly titleSeed?: string;
205 readonly runtimeMode: RuntimeMode;
206 readonly interactionMode: ProviderInteractionMode;
207 readonly bootstrap?: StartThreadBootstrap;
208 readonly sourceProposedPlan?: { readonly threadId: ThreadId; readonly planId: PlanId };
209 readonly dispatchMode?: "auto" | "queue" | "steer" | "restart" | "start";
210 /** Start a new provider session; needs the server's `freshContext` capability. */
211 readonly freshContext?: boolean;
212 /** Defaults to true. Callers with their own retry queue opt out so a dead socket fails fast. */
213 readonly resendAfterSocketLoss?: boolean;
215​
216export interface InterruptThreadTurnInput extends ThreadCommandInput {
217 readonly runId?: RunId;
218 readonly subagentId?: NodeId;
219 readonly turnId?: string;
221​
222export interface RespondToThreadApprovalInput extends ThreadCommandInput {
223 readonly requestId: RuntimeRequestId;
224 readonly decision: ProviderApprovalDecision;
225 readonly feedback?: string;
227​
228export interface RespondToThreadUserInputInput extends ThreadCommandInput {
229 readonly requestId: RuntimeRequestId;
230 readonly answers: ProviderUserInputAnswers;
231 readonly attachmentsByQuestionId?: import("@t3tools/contracts").UserInputAttachments;
233​
234export interface DismissThreadUserInputInput extends ThreadCommandInput {
235 readonly requestId: RuntimeRequestId;
237​
238export interface RevertThreadCheckpointInput extends ThreadCommandInput {
239 readonly restoreFiles?: boolean;
240 readonly checkpointId?: string;
241 readonly scopeId?: string;
242 readonly turnCount?: number;
244​
245export type StopThreadSessionInput = ThreadCommandInput;
246​
247export interface ForkThreadFromRunInput extends CommandMetadata {
248 readonly sourceThreadId: ThreadId;
249 readonly targetThreadId: ThreadId;
250 readonly runId: RunId;
251 readonly title?: string;
253​
254export interface ForkSideChatInput extends CommandMetadata {
255 readonly sourceThreadId: ThreadId;
256 readonly targetThreadId: ThreadId;
257 readonly title?: string;
259​
260export interface MergeThreadBackInput extends CommandMetadata {
261 readonly sourceThreadId: ThreadId;
262 readonly targetThreadId: ThreadId;
263 readonly runId: RunId;
265​
266export interface ResumeThreadQueueInput extends ThreadCommandInput {
267 readonly runId?: RunId;
269​
270export interface PromoteQueuedRunInput extends ThreadCommandInput {
271 readonly queuedRunId: RunId;
272 readonly targetRunId: RunId;
274​
275export interface CancelQueuedRunInput extends ThreadCommandInput {
276 readonly runId: RunId;
278​
279export interface RetryWorkspacePreparationInput extends ThreadCommandInput {
280 readonly runId: RunId;
282​
283export interface EditQueuedRunInput extends ThreadCommandInput {
284 readonly runId: RunId;
285 readonly text: string;
286 /**
287 * Full replacement attachment list for the queued message. Omitted =
288 * text-only edit that leaves attachments untouched.
289 */
290 readonly edit?: {
291 readonly messageId: MessageId;
292 readonly attachments: ReadonlyArray<ChatAttachment | UploadChatAttachment>;
293 readonly context?: import("@t3tools/contracts").OrchestrationMessageContext;
294 };
296​
297const allocateCommandId = Effect.fn("EnvironmentCommands.allocateCommandId")(function* (
298 input: CommandMetadata,
299) {
300 if (input.commandId !== undefined) return input.commandId;
301 const random = yield* SecureRandom.SecureRandom;
302 return CommandId.make(yield* random.uuidV4());
303});
304​
305const dispatch = (command: OrchestrationV2Command) =>
306 request(ORCHESTRATION_V2_WS_METHODS.dispatchCommand, command);
307​
308// The socket can close after the server accepted the frame but before it answered.
309// The server replays an accepted commandId from its receipt, so the same command
310// waits out reconnect backoff until the supervisor stops trying. The resend cap
311// stops a frame that kills the socket from looping.
312const MAX_LOST_TRANSPORT_RESENDS = 2;
313​
314// A live socket can still carry a command the host never answers; the heartbeat
315// alone would leave the send pending forever.
316const MESSAGE_DISPATCH_TIMEOUT = "60 seconds";
317​
318const resendAfterSocketLoss = Effect.fn("EnvironmentCommands.resendAfterSocketLoss")(function* <
319 A,
320 E,
321 R,
322>(attempt: Effect.Effect<A, E, R>) {
323 const supervisor = yield* EnvironmentSupervisor.EnvironmentSupervisor;
324 for (let resends = 0; ; resends += 1) {
325 const attemptSession = yield* SubscriptionRef.get(supervisor.session);
326 const exit = yield* Effect.exit(attempt);
327 if (Exit.isSuccess(exit)) return exit.value;
328 // Closing the session interrupts the request, which can beat the protocol error.
329 const lostTransport =
330 Cause.hasInterruptsOnly(exit.cause) ||
331 exit.cause.reasons.some((reason) => reason._tag === "Fail" && isRpcClientError(reason.error));
332 if (!lostTransport || resends >= MAX_LOST_TRANSPORT_RESENDS) return yield* exit;
333 const replacement = yield* Effect.raceFirst(
334 SubscriptionRef.changes(supervisor.session).pipe(
335 Stream.filter(
336 (session) =>
337 Option.isSome(session) &&
338 !(Option.isSome(attemptSession) && session.value === attemptSession.value),
339 ),
340 Stream.runHead,
341 ),
342 SubscriptionRef.changes(supervisor.state).pipe(
343 Stream.filter((state) => state.phase === "available" || state.phase === "blocked"),
344 Stream.runHead,
345 Effect.as(Option.none()),
346 ),
347 );
348 if (Option.isNone(replacement)) return yield* exit;
349 }
350});
351​
352const dispatchMessage = Effect.fn("EnvironmentCommands.dispatchMessage")(function* (
353 command: Extract<OrchestrationV2Command, { type: "message.dispatch" }>,
354 resend: boolean,
355) {
356 const supervisor = yield* EnvironmentSupervisor.EnvironmentSupervisor;
357 const attempt = dispatch(command).pipe(
358 Effect.timeoutOrElse({
359 duration: MESSAGE_DISPATCH_TIMEOUT,
360 orElse: () =>
361 Effect.fail(
362 new EnvironmentRpcUnavailableError({
363 environmentId: supervisor.target.environmentId,
364 ...translatableMessage(
365 msg("{host} did not confirm the message within 60 seconds.", {
366 host: supervisor.target.label,
367 }),
368 ),
369 }),
370 ),
371 }),
372 );
373 return yield* resend ? resendAfterSocketLoss(attempt) : attempt;
374});
375​
376const getProjection = (threadId: ThreadId) =>
377 request(ORCHESTRATION_V2_WS_METHODS.getThreadProjection, { threadId });
378​
379const persistAttachments = Effect.fn("EnvironmentCommands.persistAttachments")(function* (
380 threadId: ThreadId,
381 messageId: MessageId,
382 attachments: ReadonlyArray<ChatAttachment | UploadChatAttachment>,
383) {
384 const stored = attachments.filter(
385 (attachment): attachment is ChatAttachment => !("dataUrl" in attachment),
386 );
387 const uploads = attachments.filter(
388 (attachment): attachment is UploadChatAttachment => "dataUrl" in attachment,
389 );
390 if (uploads.length === 0) return stored;
391 const result = yield* request(WS_METHODS.assetsPersistChatAttachments, {
392 threadId,
393 messageId,
394 attachments: uploads,
395 });
396 if (stored.length === 0) return result.attachments;
397 const byUpload = new Map(
398 uploads.map((attachment, index) => [attachment, result.attachments[index]]),
399 );
400 return attachments.flatMap((attachment) => {
401 if (!("dataUrl" in attachment)) return [attachment];
402 const persisted = byUpload.get(attachment);
403 return persisted === undefined ? [] : [persisted];
404 });
405});
406​
407const mutateProject = Effect.fn("EnvironmentCommands.mutateProject")(function* (
408 mutation:
409 | {
410 readonly type: "project.create";
411 readonly commandId: CommandId;
412 readonly projectId: ProjectId;
413 readonly title: string;
414 readonly workspaceRoot: string;
415 readonly createWorkspaceRootIfMissing?: boolean;
416 readonly defaultModelSelection?: ModelSelection | null;
417 readonly scripts?: ReadonlyArray<ProjectScript>;
418 readonly trackedFolders?: ReadonlyArray<ProjectTrackedFolder>;
419 }
420 | {
421 readonly type: "project.update";
422 readonly commandId: CommandId;
423 readonly projectId: ProjectId;
424 readonly title?: string;
425 readonly workspaceRoot?: string;
426 readonly defaultModelSelection?: ModelSelection | null;
427 readonly scripts?: ReadonlyArray<ProjectScript>;
428 readonly trackedFolders?: ReadonlyArray<ProjectTrackedFolder>;
429 readonly trackFolders?: ReadonlyArray<ProjectTrackedFolder>;
430 readonly untrackFolders?: ReadonlyArray<string>;
431 }
432 | {
433 readonly type: "project.delete";
434 readonly commandId: CommandId;
435 readonly projectId: ProjectId;
436 readonly force?: boolean;
437 },
438) {
439 return yield* request(WS_METHODS.projectsMutate, mutation);
440});
441​
442export const createProject = Effect.fn("EnvironmentCommands.createProject")(function* (
443 input: CreateProjectInput,
444) {
445 return yield* mutateProject({
446 type: "project.create",
447 commandId: yield* allocateCommandId(input),
448 projectId: input.projectId,
449 title: input.title,
450 workspaceRoot: input.workspaceRoot,
451 ...(input.createWorkspaceRootIfMissing === undefined
452 ? {}
453 : { createWorkspaceRootIfMissing: input.createWorkspaceRootIfMissing }),
454 ...(input.defaultModelSelection === undefined
455 ? {}
456 : { defaultModelSelection: input.defaultModelSelection }),
457 ...(input.scripts === undefined ? {} : { scripts: input.scripts }),
458 ...(input.trackedFolders === undefined ? {} : { trackedFolders: input.trackedFolders }),
459 });
460});
461​
462export const updateProject = Effect.fn("EnvironmentCommands.updateProject")(function* (
463 input: UpdateProjectInput,
464) {
465 return yield* mutateProject({
466 type: "project.update",
467 commandId: yield* allocateCommandId(input),
468 projectId: input.projectId,
469 ...(input.title === undefined ? {} : { title: input.title }),
470 ...(input.workspaceRoot === undefined ? {} : { workspaceRoot: input.workspaceRoot }),
471 ...(input.defaultModelSelection === undefined
472 ? {}
473 : { defaultModelSelection: input.defaultModelSelection }),
474 ...(input.autoPull === undefined ? {} : { autoPull: input.autoPull }),
475 ...(input.projectIcon === undefined ? {} : { projectIcon: input.projectIcon }),
476 ...(input.faviconPath === undefined ? {} : { faviconPath: input.faviconPath }),
477 ...(input.defaultThreadEnvMode === undefined
478 ? {}
479 : { defaultThreadEnvMode: input.defaultThreadEnvMode }),
480 ...(input.scripts === undefined ? {} : { scripts: input.scripts }),
481 ...(input.trackedFolders === undefined ? {} : { trackedFolders: input.trackedFolders }),
482 ...(input.trackFolders === undefined ? {} : { trackFolders: input.trackFolders }),
483 ...(input.untrackFolders === undefined ? {} : { untrackFolders: input.untrackFolders }),
484 ...(input.pinned === undefined ? {} : { pinned: input.pinned }),
485 ...(input.archived === undefined ? {} : { archived: input.archived }),
486 });
487});
488​
489export const deleteProject = Effect.fn("EnvironmentCommands.deleteProject")(function* (
490 input: DeleteProjectInput,
491) {
492 return yield* mutateProject({
493 type: "project.delete",
494 commandId: yield* allocateCommandId(input),
495 projectId: input.projectId,
496 ...(input.force === undefined ? {} : { force: input.force }),
497 });
498});
499​
500export const createThread = Effect.fn("EnvironmentCommands.createThread")(function* (
501 input: CreateThreadInput,
502) {
503 return yield* dispatch({
504 type: "thread.create",
505 commandId: yield* allocateCommandId(input),
506 createdBy: "user",
507 creationSource: input.creationSource ?? "web",
508 threadId: input.threadId,
509 projectId: input.projectId,
510 title: input.title,
511 modelSelection: input.modelSelection,
512 runtimeMode: input.runtimeMode,
513 interactionMode: input.interactionMode,
514 branch: input.branch,
515 worktreePath: input.worktreePath,
516 });
517});
518​
519function simpleThreadCommand(
520 type:
521 | "thread.archive"
522 | "thread.unarchive"
523 | "thread.settle"
524 | "thread.pin"
525 | "thread.unpin"
526 | "thread.guest-share.close",
527 input: ThreadCommandInput,
528) {
529 return allocateCommandId(input).pipe(
530 Effect.flatMap((commandId) => dispatch({ type, commandId, threadId: input.threadId })),
531 );
533​
534export const deleteThread = Effect.fn("EnvironmentCommands.deleteThread")(function* (
535 input: DeleteThreadInput,
536) {
537 return yield* dispatch({
538 type: "thread.delete",
539 commandId: yield* allocateCommandId(input),
540 threadId: input.threadId,
541 ...(input.onlyIfUnused === undefined ? {} : { onlyIfUnused: input.onlyIfUnused }),
542 });
543});
544​
545export type CloseGuestShareInput = ThreadCommandInput;
546export const closeGuestShare = Effect.fn("EnvironmentCommands.closeGuestShare")(function* (
547 input: CloseGuestShareInput,
548) {
549 return yield* simpleThreadCommand("thread.guest-share.close", input);
550});
551​
552export interface ResolveGuestMessageInput extends ThreadCommandInput {
553 readonly guestMessageId: GuestMessageId;
554 readonly decision: "send" | "dismiss";
555 readonly creationSource?: "web" | "mobile";
557/** Send runs the guest's text as a normal turn; the server supplies the text, not the client. */
558export const resolveGuestMessage = Effect.fn("EnvironmentCommands.resolveGuestMessage")(function* (
559 input: ResolveGuestMessageInput,
560) {
561 const commandId = yield* allocateCommandId(input);
562 if (input.decision === "dismiss") {
563 return yield* dispatch({
564 type: "thread.guest-message.dismiss",
565 commandId,
566 threadId: input.threadId,
567 guestMessageId: input.guestMessageId,
568 });
569 }
570 return yield* dispatch({
571 type: "message.dispatch",
572 commandId,
573 threadId: input.threadId,
574 messageId: MessageId.make(commandId),
575 guestMessageId: input.guestMessageId,
576 text: "",
577 attachments: [],
578 dispatchMode: { type: "queue_after_active" },
579 createdBy: "user",
580 creationSource: input.creationSource ?? "web",
581 });
582});
583​
584export const archiveThread = Effect.fn("EnvironmentCommands.archiveThread")(function* (
585 input: ArchiveThreadInput,
586) {
587 return yield* simpleThreadCommand("thread.archive", input);
588});
589​
590export const unarchiveThread = Effect.fn("EnvironmentCommands.unarchiveThread")(function* (
591 input: UnarchiveThreadInput,
592) {
593 return yield* simpleThreadCommand("thread.unarchive", input);
594});
595​
596export const settleThread = Effect.fn("EnvironmentCommands.settleThread")(function* (
597 input: SettleThreadInput,
598) {
599 return yield* simpleThreadCommand("thread.settle", input);
600});
601​
602export const pinThread = Effect.fn("EnvironmentCommands.pinThread")(function* (
603 input: PinThreadInput,
604) {
605 const commandId = yield* allocateCommandId(input);
606 return yield* dispatch({
607 type: "thread.pin",
608 commandId,
609 threadId: input.threadId,
610 ...(input.orderKey === undefined ? {} : { orderKey: input.orderKey }),
611 });
612});
613​
614export interface SetThreadAutoSettleInput extends ThreadCommandInput {
615 readonly enabled: boolean;
617export const setThreadAutoSettle = Effect.fn("EnvironmentCommands.setThreadAutoSettle")(function* (
618 input: SetThreadAutoSettleInput,
619) {
620 return yield* dispatch({
621 type: "thread.auto-settle.set",
622 commandId: yield* allocateCommandId(input),
623 threadId: input.threadId,
624 enabled: input.enabled,
625 });
626});
627​
628export const reorderPinnedThread = Effect.fn("EnvironmentCommands.reorderPinnedThread")(function* (
629 input: ReorderPinnedThreadInput,
630) {
631 const commandId = yield* allocateCommandId(input);
632 return yield* dispatch({
633 type: "thread.pin.reorder",
634 commandId,
635 threadId: input.threadId,
636 orderKey: input.orderKey,
637 });
638});
639​
640export const reorderActiveThread = Effect.fn("EnvironmentCommands.reorderActiveThread")(function* (
641 input: ReorderActiveThreadInput,
642) {
643 return yield* dispatch({
644 type: "thread.active.reorder",
645 commandId: yield* allocateCommandId(input),
646 threadId: input.threadId,
647 orderKey: input.orderKey,
648 });
649});
650​
651export const unpinThread = Effect.fn("EnvironmentCommands.unpinThread")(function* (
652 input: UnpinThreadInput,
653) {
654 return yield* simpleThreadCommand("thread.unpin", input);
655});
656​
657export const unsettleThread = Effect.fn("EnvironmentCommands.unsettleThread")(function* (
658 input: UnsettleThreadInput,
659) {
660 return yield* dispatch({
661 type: "thread.unsettle",
662 commandId: yield* allocateCommandId(input),
663 threadId: input.threadId,
664 reason: input.reason,
665 ...(input.restoreUnsettledAt === undefined
666 ? {}
667 : { restoreUnsettledAt: input.restoreUnsettledAt }),
668 });
669});
670​
671export const snoozeThread = Effect.fn("EnvironmentCommands.snoozeThread")(function* (
672 input: SnoozeThreadInput,
673) {
674 return yield* dispatch({
675 type: "thread.snooze",
676 commandId: yield* allocateCommandId(input),
677 threadId: input.threadId,
678 snoozedUntil: input.snoozedUntil,
679 });
680});
681​
682export const unsnoozeThread = Effect.fn("EnvironmentCommands.unsnoozeThread")(function* (
683 input: UnsnoozeThreadInput,
684) {
685 return yield* dispatch({
686 type: "thread.unsnooze",
687 commandId: yield* allocateCommandId(input),
688 threadId: input.threadId,
689 reason: input.reason,
690 });
691});
692​
693export const visitThread = Effect.fn("EnvironmentCommands.visitThread")(function* (
694 input: VisitThreadInput,
695) {
696 return yield* dispatch({
697 type: "thread.visit",
698 commandId: yield* allocateCommandId(input),
699 threadId: input.threadId,
700 visitedAt: input.visitedAt,
701 ...(input.opened ? { opened: true } : {}),
702 ...(input.searchQuery ? { searchQuery: input.searchQuery } : {}),
703 });
704});
705​
706export const markThreadUnread = Effect.fn("EnvironmentCommands.markThreadUnread")(function* (
707 input: MarkThreadUnreadInput,
708) {
709 return yield* dispatch({
710 type: "thread.mark-unread",
711 commandId: yield* allocateCommandId(input),
712 threadId: input.threadId,
713 });
714});
715​
716export const updateThreadMetadata = Effect.fn("EnvironmentCommands.updateThreadMetadata")(
717 function* (input: UpdateThreadMetadataInput) {
718 const commandId = yield* allocateCommandId(input);
719 let result = null;
720 if (
721 input.title !== undefined ||
722 input.branch !== undefined ||
723 input.worktreePath !== undefined ||
724 input.regenerateTitle !== undefined ||
725 input.linkedPullRequest !== undefined ||
726 input.limitRecovery !== undefined
727 ) {
728 result = yield* dispatch({
729 type: "thread.metadata.update",
730 ...(input.limitRecovery === undefined ? {} : { limitRecovery: input.limitRecovery }),
731 commandId,
732 threadId: input.threadId,
733 ...(input.title === undefined ? {} : { title: input.title }),
734 ...(input.branch === undefined ? {} : { branch: input.branch }),
735 ...(input.worktreePath === undefined ? {} : { worktreePath: input.worktreePath }),
736 ...(input.expectedEmpty === true ? { expectedEmpty: true } : {}),
737 ...(input.regenerateTitle === undefined ? {} : { regenerateTitle: input.regenerateTitle }),
738 ...(input.linkedPullRequest === undefined
739 ? {}
740 : { linkedPullRequest: input.linkedPullRequest }),
741 });
742 }
743 if (input.modelSelection !== undefined) {
744 result = yield* dispatch({
745 type: "thread.model-selection.set",
746 commandId: result === null ? commandId : CommandId.make(`${commandId}:model-selection`),
747 threadId: input.threadId,
748 modelSelection: input.modelSelection,
749 });
750 }
751 return result ?? { sequence: 0 };
752 },
753);
754​
755export const setThreadRuntimeMode = Effect.fn("EnvironmentCommands.setThreadRuntimeMode")(
756 function* (input: SetThreadRuntimeModeInput) {
757 return yield* dispatch({
758 type: "thread.runtime-mode.set",
759 commandId: yield* allocateCommandId(input),
760 threadId: input.threadId,
761 runtimeMode: input.runtimeMode,
762 });
763 },
764);
765​
766export const setThreadInteractionMode = Effect.fn("EnvironmentCommands.setThreadInteractionMode")(
767 function* (input: SetThreadInteractionModeInput) {
768 return yield* dispatch({
769 type: "thread.interaction-mode.set",
770 commandId: yield* allocateCommandId(input),
771 threadId: input.threadId,
772 interactionMode: input.interactionMode,
773 });
774 },
775);
776​
777// Servers without native resume dispatch command.text verbatim; newer ones clear
778// it when manualContinuationOfRunId is set.
779const MANUAL_CONTINUATION_FALLBACK_TEXT = "Continue where you left off.";
780​
781export const startThreadTurn = Effect.fn("EnvironmentCommands.startThreadTurn")(function* (
782 input: StartThreadTurnInput,
783) {
784 const commandId = yield* allocateCommandId(input);
785 const attachments = yield* persistAttachments(
786 input.threadId,
787 input.message.messageId,
788 input.message.attachments,
789 );
790 const context = remapComposerContextAttachments(
791 input.message.context,
792 input.message.attachments,
793 attachments,
794 );
795 const resend = input.resendAfterSocketLoss ?? true;
796 const bootstrap = input.bootstrap?.createThread;
797 const prepareWorktree = input.bootstrap?.prepareWorktree;
798 if (bootstrap !== undefined || prepareWorktree !== undefined) {
799 const existingProjection =
800 bootstrap === undefined ? yield* getProjection(input.threadId) : null;
801 const thread = bootstrap ?? existingProjection!.thread;
802 const workspaceStrategy =
803 prepareWorktree !== undefined
804 ? {
805 type: "worktree" as const,
806 baseRef: prepareWorktree.baseBranch,
807 ...(prepareWorktree.branch === undefined ? {} : { branch: prepareWorktree.branch }),
808 ...(prepareWorktree.startFromOrigin === undefined
809 ? {}
810 : { startFromOrigin: prepareWorktree.startFromOrigin }),
811 ...(prepareWorktree.repositories === undefined
812 ? {}
813 : { repositories: prepareWorktree.repositories }),
814 }
815 : bootstrap?.worktreePath
816 ? {
817 type: "existing_worktree" as const,
818 worktreePath: bootstrap.worktreePath,
819 ...(bootstrap.branch === null ? {} : { branch: bootstrap.branch }),
820 }
821 : {
822 type: "root" as const,
823 ...(bootstrap?.branch === null || bootstrap?.branch === undefined
824 ? {}
825 : { branch: bootstrap.branch }),
826 };
827 const launch = request(ORCHESTRATION_V2_WS_METHODS.launchThread, {
828 commandId,
829 creationSource: input.creationSource ?? "web",
830 threadId: input.threadId,
831 ...(bootstrap === undefined ? { reuseExistingThread: true } : {}),
832 projectId: thread.projectId,
833 title: input.titleSeed ?? thread.title,
834 generateTitle: input.titleSeed !== undefined,
835 modelSelection: input.modelSelection ?? thread.modelSelection,
836 runtimeMode: input.runtimeMode,
837 interactionMode: input.interactionMode,
838 workspaceStrategy,
839 initialMessage: {
840 messageId: input.message.messageId,
841 text: input.message.text,
842 ...(context ? { context } : {}),
843 attachments,
844 },
845 });
846 return yield* resend ? resendAfterSocketLoss(launch) : launch;
847 }
848​
849 const requestedMode = input.dispatchMode ?? "auto";
850 if (requestedMode === "start") {
851 return yield* dispatchMessage(
852 {
853 type: "message.dispatch",
854 commandId,
855 createdBy: "user",
856 creationSource: input.creationSource ?? "web",
857 threadId: input.threadId,
858 messageId: input.message.messageId,
859 ...(input.manualContinuationOfRunId === undefined
860 ? {}
861 : { manualContinuationOfRunId: input.manualContinuationOfRunId }),
862 text:
863 input.manualContinuationOfRunId !== undefined &&
864 input.message.text.trim().length === 0 &&
865 attachments.length === 0
866 ? MANUAL_CONTINUATION_FALLBACK_TEXT
867 : input.message.text,
868 ...(context ? { context } : {}),
869 ...(input.message.idleCompaction === undefined
870 ? {}
871 : { idleCompaction: input.message.idleCompaction }),
872 attachments,
873 ...(input.modelSelection === undefined ? {} : { modelSelection: input.modelSelection }),
874 ...(input.sourceProposedPlan === undefined
875 ? {}
876 : { sourcePlanRef: input.sourceProposedPlan }),
877 ...(input.freshContext ? { freshContext: true } : {}),
878 dispatchMode: { type: "start_immediately" },
879 },
880 resend,
881 );
882 }
883​
884 const dispatchMode =
885 requestedMode === "queue"
886 ? ({ type: "queue_after_active" } as const)
887 : ({ type: "start_immediately" } as const);
888 return yield* dispatchMessage(
889 {
890 type: "message.dispatch",
891 commandId,
892 createdBy: "user",
893 creationSource: input.creationSource ?? "web",
894 threadId: input.threadId,
895 messageId: input.message.messageId,
896 text: input.message.text,
897 ...(context ? { context } : {}),
898 ...(input.message.idleCompaction === undefined
899 ? {}
900 : { idleCompaction: input.message.idleCompaction }),
901 attachments,
902 ...(input.titleSeed === undefined ? {} : { titleSeed: input.titleSeed }),
903 ...(input.modelSelection === undefined ? {} : { modelSelection: input.modelSelection }),
904 ...(input.sourceProposedPlan === undefined
905 ? {}
906 : { sourcePlanRef: input.sourceProposedPlan }),
907 ...(input.freshContext ? { freshContext: true } : {}),
908 ...(requestedMode !== "queue" ? { deliveryIntent: requestedMode } : {}),
909 dispatchMode,
910 },
911 resend,
912 );
913});
914​
915export const interruptThreadTurn = Effect.fn("EnvironmentCommands.interruptThreadTurn")(function* (
916 input: InterruptThreadTurnInput,
917) {
918 let threadId = input.threadId;
919 if (input.subagentId !== undefined) {
920 const projection = yield* getProjection(input.threadId);
921 const subagent = projection.subagents.find((agent) => agent.id === input.subagentId);
922 if (subagent?.origin === "app_owned" && subagent.childThreadId !== null) {
923 // The parent ends the task even when its child lost track of it. Older
924 // servers reject this for app-owned tasks, so the child stop below still runs.
925 if (subagent.runId !== null) {
926 yield* dispatch({
927 type: "subagent.stop",
928 commandId: yield* allocateCommandId({}),
929 threadId: input.threadId,
930 runId: subagent.runId,
931 subagentId: subagent.id,
932 }).pipe(Effect.ignore);
933 }
934 threadId = subagent.childThreadId;
935 } else {
936 if (subagent?.runId == null) return { sequence: 0 };
937 return yield* dispatch({
938 type: "subagent.stop",
939 commandId: yield* allocateCommandId(input),
940 threadId: input.threadId,
941 runId: subagent.runId,
942 subagentId: subagent.id,
943 });
944 }
945 }
946 // A run named by the caller belongs to the parent, not the rerouted child.
947 let runId =
948 threadId === input.threadId ? (input.runId ?? (input.turnId as RunId | undefined)) : undefined;
949 if (runId === undefined) {
950 const config = yield* getInitialServerConfig();
951 if (config.environment.capabilities.threadStop === true) {
952 // A paginated projection can omit commands still running from earlier turns.
953 return yield* dispatch({
954 type: "thread.stop",
955 commandId: yield* allocateCommandId(input),
956 threadId,
957 });
958 }
959 }
960 if (runId === undefined) {
961 const projection = yield* getProjection(threadId);
962 runId = projection.runs.findLast(
963 (run) =>
964 run.status === "preparing" ||
965 run.status === "starting" ||
966 run.status === "running" ||
967 run.status === "waiting",
968 )?.id;
969 if (runId === undefined) {
970 const latestRun = projection.runs.at(-1);
971 if (
972 derivePendingBackgroundWork({
973 latestRun,
974 providerThreads: projection.providerThreads,
975 turnItems: projection.turnItems,
976 activeProviderThreadId: projection.thread.activeProviderThreadId,
977 runs: projection.runs,
978 }).length > 0
979 ) {
980 runId = latestRun?.id;
981 }
982 }
983 if (runId === undefined) {
984 let result = { sequence: 0 };
985 for (const link of visibleThreadPullRequests(projection.thread.pullRequests ?? [])) {
986 if (link.watch === undefined) continue;
987 result = yield* dispatch({
988 type: "thread.pull-request.watch",
989 commandId: yield* allocateCommandId(result.sequence === 0 ? input : {}),
990 threadId,
991 host: link.host,
992 repository: link.repository,
993 number: link.number,
994 watching: false,
995 });
996 }
997 return result;
998 }
999 }
1000 if (runId === undefined) return { sequence: 0 };
1001 return yield* dispatch({
1002 type: "run.interrupt",
1003 commandId: yield* allocateCommandId(input),
1004 threadId,
1005 runId,
1006 holdQueue: true,
1007 });
1008});
1009​
1010export const respondToThreadApproval = Effect.fn("EnvironmentCommands.respondToThreadApproval")(
1011 function* (input: RespondToThreadApprovalInput) {
1012 return yield* dispatch({
1013 type: "runtime-request.respond",
1014 commandId: yield* allocateCommandId(input),
1015 threadId: input.threadId,
1016 requestId: input.requestId,
1017 decision: input.decision,
1018 ...(input.feedback === undefined ? {} : { feedback: input.feedback }),
1019 });
1020 },
1022​
1023export const respondToThreadUserInput = Effect.fn("EnvironmentCommands.respondToThreadUserInput")(
1024 function* (input: RespondToThreadUserInputInput) {
1025 return yield* dispatch({
1026 type: "runtime-request.respond",
1027 commandId: yield* allocateCommandId(input),
1028 threadId: input.threadId,
1029 requestId: input.requestId,
1030 answers: input.answers,
1031 ...(input.attachmentsByQuestionId === undefined
1032 ? {}
1033 : { attachmentsByQuestionId: input.attachmentsByQuestionId }),
1034 });
1035 },
1037​
1038export const dismissThreadUserInput = Effect.fn("EnvironmentCommands.dismissThreadUserInput")(
1039 function* (input: DismissThreadUserInputInput) {
1040 return yield* dispatch({
1041 type: "thread.user-input.dismiss",
1042 commandId: yield* allocateCommandId(input),
1043 threadId: input.threadId,
1044 requestId: input.requestId,
1045 });
1046 },
1048​
1049export const revertThreadCheckpoint = Effect.fn("EnvironmentCommands.revertThreadCheckpoint")(
1050 function* (input: RevertThreadCheckpointInput) {
1051 if (input.checkpointId !== undefined && input.scopeId !== undefined) {
1052 return yield* dispatch({
1053 type: "checkpoint.rollback",
1054 ...(input.restoreFiles === undefined ? {} : { restoreFiles: input.restoreFiles }),
1055 commandId: yield* allocateCommandId(input),
1056 threadId: input.threadId,
1057 scopeId: CheckpointScopeId.make(input.scopeId),
1058 checkpointId: CheckpointId.make(input.checkpointId),
1059 });
1061 const projection = yield* getProjection(input.threadId);
1062 // A tracked repository's baseline also sits at ordinal zero; it follows the thread's rewind.
1063 const repositoryScopeIds = repositoryCheckpointScopeIds(projection.checkpointScopes);
1064 const checkpoint =
1065 projection.checkpoints.find(
1066 (candidate) => candidate.id === input.checkpointId && candidate.scopeId === input.scopeId,
1067 ) ??
1068 projection.checkpoints.findLast(
1069 (candidate) =>
1070 !repositoryScopeIds.has(candidate.scopeId) &&
1071 (input.turnCount === 0
1072 ? candidate.ordinalWithinScope === 0 && candidate.appRunOrdinal === null
1073 : candidate.appRunOrdinal === input.turnCount),
1074 );
1075 if (
1076 checkpoint === undefined ||
1077 // Missing or failed snapshots support conversation rewind only.
1078 (checkpoint.status !== "ready" &&
1079 !(input.restoreFiles === false && checkpoint.status !== "stale"))
1080 ) {
1081 const target =
1082 input.checkpointId === undefined
1083 ? `run ordinal ${input.turnCount ?? "unknown"}`
1084 : `checkpoint ${input.checkpointId}`;
1085 return yield* new OrchestrationV2CheckpointUnavailableError({
1086 threadId: input.threadId,
1087 target,
1088 });
1090 return yield* dispatch({
1091 type: "checkpoint.rollback",
1092 ...(input.restoreFiles === undefined ? {} : { restoreFiles: input.restoreFiles }),
1093 commandId: yield* allocateCommandId(input),
1094 threadId: input.threadId,
1095 scopeId: checkpoint.scopeId,
1096 checkpointId: checkpoint.id,
1097 });
1098 },
1100​
1101export const stopThreadSession = Effect.fn("EnvironmentCommands.stopThreadSession")(function* (
1102 input: StopThreadSessionInput,
1103) {
1104 const projection = yield* getProjection(input.threadId);
1105 const commandId = yield* allocateCommandId(input);
1106 let result = { sequence: 0 };
1107 for (const session of projection.providerSessions) {
1108 result = yield* dispatch({
1109 type: "provider-session.detach",
1110 commandId: CommandId.make(`${commandId}:detach:${session.id}`),
1111 threadId: input.threadId,
1112 providerSessionId: session.id,
1113 reason: "client-requested",
1114 });
1116 return result;
1117});
1118​
1119export const forkThreadFromRun = Effect.fn("EnvironmentCommands.forkThreadFromRun")(function* (
1120 input: ForkThreadFromRunInput,
1121) {
1122 return yield* dispatch({
1123 type: "thread.fork",
1124 commandId: yield* allocateCommandId(input),
1125 createdBy: "user",
1126 creationSource: input.creationSource ?? "web",
1127 sourceThreadId: input.sourceThreadId,
1128 targetThreadId: input.targetThreadId,
1129 sourcePoint: { type: "run", runId: input.runId },
1130 ...(input.title === undefined ? {} : { title: input.title }),
1131 });
1132});
1133​
1134/** Forks the thread's latest stable point into a hidden side chat; works while it runs. */
1135export const forkSideChat = Effect.fn("EnvironmentCommands.forkSideChat")(function* (
1136 input: ForkSideChatInput,
1137) {
1138 return yield* dispatch({
1139 type: "thread.fork",
1140 commandId: yield* allocateCommandId(input),
1141 createdBy: "user",
1142 creationSource: input.creationSource ?? "web",
1143 sourceThreadId: input.sourceThreadId,
1144 targetThreadId: input.targetThreadId,
1145 sourcePoint: { type: "latest_stable" },
1146 sideChat: true,
1147 ...(input.title === undefined ? {} : { title: input.title }),
1148 });
1149});
1150​
1151export const mergeThreadBack = Effect.fn("EnvironmentCommands.mergeThreadBack")(function* (
1152 input: MergeThreadBackInput,
1153) {
1154 return yield* dispatch({
1155 type: "thread.merge_back",
1156 commandId: yield* allocateCommandId(input),
1157 createdBy: "user",
1158 creationSource: input.creationSource ?? "web",
1159 sourceThreadId: input.sourceThreadId,
1160 targetThreadId: input.targetThreadId,
1161 sourcePoint: { type: "run", runId: input.runId },
1162 });
1163});
1164​
1165export const resumeThreadQueue = Effect.fn("EnvironmentCommands.resumeThreadQueue")(function* (
1166 input: ResumeThreadQueueInput,
1167) {
1168 return yield* resendAfterSocketLoss(
1169 dispatch({
1170 ...(input.runId === undefined
1171 ? { type: "queue.resume" as const }
1172 : { type: "queued-run.start" as const, runId: input.runId }),
1173 commandId: yield* allocateCommandId(input),
1174 threadId: input.threadId,
1175 }),
1176 );
1177});
1178​
1179export const promoteQueuedRun = Effect.fn("EnvironmentCommands.promoteQueuedRun")(function* (
1180 input: PromoteQueuedRunInput,
1181) {
1182 return yield* resendAfterSocketLoss(
1183 dispatch({
1184 type: "queued-message.promote-to-steer",
1185 commandId: yield* allocateCommandId(input),
1186 threadId: input.threadId,
1187 queuedRunId: input.queuedRunId,
1188 targetRunId: input.targetRunId,
1189 }),
1190 );
1191});
1192​
1193export const cancelQueuedRun = Effect.fn("EnvironmentCommands.cancelQueuedRun")(function* (
1194 input: CancelQueuedRunInput,
1195) {
1196 return yield* dispatch({
1197 type: "queued-run.cancel",
1198 commandId: yield* allocateCommandId(input),
1199 threadId: input.threadId,
1200 runId: input.runId,
1201 });
1202});
1203​
1204export const retryWorkspacePreparation = Effect.fn("EnvironmentCommands.retryWorkspacePreparation")(
1205 function* (input: RetryWorkspacePreparationInput) {
1206 return yield* dispatch({
1207 type: "prepared-run.retry",
1208 commandId: yield* allocateCommandId(input),
1209 threadId: input.threadId,
1210 runId: input.runId,
1211 });
1212 },
1214​
1215export const editQueuedRun = Effect.fn("EnvironmentCommands.editQueuedRun")(function* (
1216 input: EditQueuedRunInput,
1217) {
1218 const attachments =
1219 input.edit === undefined
1220 ? undefined
1221 : yield* persistAttachments(input.threadId, input.edit.messageId, input.edit.attachments);
1222 return yield* dispatch({
1223 type: "queued-run.edit",
1224 commandId: yield* allocateCommandId(input),
1225 threadId: input.threadId,
1226 runId: input.runId,
1227 text: input.text,
1228 ...(attachments === undefined ? {} : { attachments }),
1229 ...(input.edit?.context && attachments
1230 ? {
1231 context: remapComposerContextAttachments(
1232 input.edit.context,
1233 input.edit.attachments,
1234 attachments,
1235 ),
1237 : {}),
1238 });
1239});
1240​
1241export type LinkThreadPullRequestInput = Omit<
1242 Extract<OrchestrationV2Command, { type: "thread.pull-request.link" }>,
1243 "type" | "commandId"
1244> &
1245 CommandMetadata;
1246export type UnlinkThreadPullRequestInput = Omit<
1247 Extract<OrchestrationV2Command, { type: "thread.pull-request.unlink" }>,
1248 "type" | "commandId"
1249> &
1250 CommandMetadata;
1251export const linkThreadPullRequest = Effect.fn("EnvironmentCommands.linkThreadPullRequest")(
1252 function* (input: LinkThreadPullRequestInput) {
1253 return yield* dispatch({
1254 ...input,
1255 type: "thread.pull-request.link",
1256 commandId: yield* allocateCommandId(input),
1257 });
1258 },
1260export type LinkThreadIssueInput = Omit<
1261 Extract<OrchestrationV2Command, { type: "thread.issue.link" }>,
1262 "type" | "commandId"
1263> &
1264 CommandMetadata;
1265export type UnlinkThreadIssueInput = Omit<
1266 Extract<OrchestrationV2Command, { type: "thread.issue.unlink" }>,
1267 "type" | "commandId"
1268> &
1269 CommandMetadata;
1270export const linkThreadIssue = Effect.fn("EnvironmentCommands.linkThreadIssue")(function* (
1271 input: LinkThreadIssueInput,
1272) {
1273 return yield* dispatch({
1274 ...input,
1275 type: "thread.issue.link",
1276 commandId: yield* allocateCommandId(input),
1277 });
1278});
1279export const unlinkThreadIssue = Effect.fn("EnvironmentCommands.unlinkThreadIssue")(function* (
1280 input: UnlinkThreadIssueInput,
1281) {
1282 return yield* dispatch({
1283 ...input,
1284 type: "thread.issue.unlink",
1285 commandId: yield* allocateCommandId(input),
1286 });
1287});
1288export type WatchThreadPullRequestInput = Omit<
1289 Extract<OrchestrationV2Command, { type: "thread.pull-request.watch" }>,
1290 "type" | "commandId"
1291> &
1292 CommandMetadata;
1293export const watchThreadPullRequest = Effect.fn("EnvironmentCommands.watchThreadPullRequest")(
1294 function* (input: WatchThreadPullRequestInput) {
1295 return yield* dispatch({
1296 ...input,
1297 type: "thread.pull-request.watch",
1298 commandId: yield* allocateCommandId(input),
1299 });
1300 },
1302export const unlinkThreadPullRequest = Effect.fn("EnvironmentCommands.unlinkThreadPullRequest")(
1303 function* (input: UnlinkThreadPullRequestInput) {
1304 return yield* dispatch({
1305 ...input,
1306 type: "thread.pull-request.unlink",
1307 commandId: yield* allocateCommandId(input),
1308 });
1309 },