+36
![github-actions[bot]](/assets/img/avatar_default.png)








Julius Marminge
maria-rcks
Bilal Bakr
shivam
Vitalii Yehorov
Jake Leventhal
Claude Opus 5
Alex Southwell
github-actions[bot]
Nicholas Wasmiller
PB
Exotic
Yash Singh
Devin
Theo Browne
Gabriel De Andrade
Dara Adedeji
scratchyone
Dominic Roy
chukfinley
Primož Ajdišek
benthecarman
NaveDanan
aaditagrawal
Aditya Garud
Nick Anisimov
MacKinley Smith
Yordis Prieto
t3-code[bot]
AKolenda
Guillermo Casanova
Otavio Salvador
Shirish Pothi
Ishaan Kothari
Bob Fowler
Anton Bezdenezhnykh
ValeraZSD
Ephraim
Ryan Ilano
Alex
maco
Cursor
Tristan Knight
PR Batch Tester
oliver
kamkm
de34391427
Co-authored-by: maria-rcks <[email protected]> Co-authored-by: Bilal Bakr <[email protected]> Co-authored-by: shivam <[email protected]> Co-authored-by: Vitalii Yehorov <[email protected]> Co-authored-by: Jake Leventhal <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: Alex Southwell <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Nicholas Wasmiller <[email protected]> Co-authored-by: PB <[email protected]> Co-authored-by: Exotic <[email protected]> Co-authored-by: Yash Singh <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Theo Browne <[email protected]> Co-authored-by: Gabriel De Andrade <[email protected]> Co-authored-by: Dara Adedeji <[email protected]> Co-authored-by: scratchyone <[email protected]> Co-authored-by: Dominic Roy <[email protected]> Co-authored-by: chukfinley <[email protected]> Co-authored-by: Primož Ajdišek <[email protected]> Co-authored-by: benthecarman <[email protected]> Co-authored-by: NaveDanan <[email protected]> Co-authored-by: aaditagrawal <[email protected]> Co-authored-by: Aditya Garud <[email protected]> Co-authored-by: Nick Anisimov <[email protected]> Co-authored-by: MacKinley Smith <[email protected]> Co-authored-by: Yordis Prieto <[email protected]> Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com> Co-authored-by: AKolenda <[email protected]> Co-authored-by: Guillermo Casanova <[email protected]> Co-authored-by: Otavio Salvador <[email protected]> Co-authored-by: Shirish Pothi <[email protected]> Co-authored-by: Ishaan Kothari <[email protected]> Co-authored-by: Bob Fowler <[email protected]> Co-authored-by: Anton Bezdenezhnykh <[email protected]> Co-authored-by: ValeraZSD <[email protected]> Co-authored-by: Ephraim <[email protected]> Co-authored-by: Ryan Ilano <[email protected]> Co-authored-by: Alex <[email protected]> Co-authored-by: maco <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Tristan Knight <[email protected]> Co-authored-by: PR Batch Tester <[email protected]> Co-authored-by: oliver <[email protected]> Co-authored-by: kamkm <[email protected]> Signed-off-by: Yordis Prieto <[email protected]>
123 lines
4.2 KiB
TypeScript
123 lines
4.2 KiB
TypeScript
import * as Schema from "effect/Schema";
|
|
|
|
import {
|
|
CommandId,
|
|
IsoDateTime,
|
|
NonNegativeInt,
|
|
PositiveInt,
|
|
ThreadId,
|
|
TrimmedNonEmptyString,
|
|
} from "./baseSchemas.ts";
|
|
import { ThreadLinkedPullRequest } from "./threadPullRequest.ts";
|
|
import { ThreadTitleRegeneration } from "./threadTitle.ts";
|
|
|
|
function hasOnlyPairedSurrogates(value: string): boolean {
|
|
for (let index = 0; index < value.length; index += 1) {
|
|
const codeUnit = value.charCodeAt(index);
|
|
if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {
|
|
const nextCodeUnit = value.charCodeAt(index + 1);
|
|
if (index + 1 >= value.length || nextCodeUnit < 0xdc00 || nextCodeUnit > 0xdfff) {
|
|
return false;
|
|
}
|
|
index += 1;
|
|
} else if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function isHttpUrl(value: string): boolean {
|
|
try {
|
|
const url = new URL(value);
|
|
return url.protocol === "http:" || url.protocol === "https:";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
const ThreadMetadataTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
|
|
description: "New concise display title. Required only when action is rename.",
|
|
});
|
|
|
|
const ThreadMetadataClientRequestId = TrimmedNonEmptyString.check(Schema.isMaxLength(256))
|
|
.check(
|
|
Schema.makeFilter((value) =>
|
|
hasOnlyPairedSurrogates(value)
|
|
? true
|
|
: "clientRequestId must contain valid paired Unicode surrogates.",
|
|
),
|
|
)
|
|
.annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
|
|
|
|
const ThreadMetadataMcpPullRequestUrl = TrimmedNonEmptyString.check(
|
|
Schema.makeFilter((value) =>
|
|
isHttpUrl(value) ? true : "Pull request URL must be a well-formed HTTP(S) URL.",
|
|
),
|
|
).annotate({
|
|
description: "Canonical HTTP(S) pull request URL, including self-hosted repository URLs.",
|
|
});
|
|
|
|
export const ThreadMetadataMcpAction = Schema.Literals([
|
|
"rename",
|
|
"regenerate_title",
|
|
"link_pull_request",
|
|
"unlink_pull_request",
|
|
]).annotate({
|
|
description:
|
|
"Metadata mutation: rename, regenerate_title, link_pull_request, or unlink_pull_request.",
|
|
});
|
|
export type ThreadMetadataMcpAction = typeof ThreadMetadataMcpAction.Type;
|
|
|
|
export const ThreadMetadataMcpPullRequest = Schema.Struct({
|
|
repository: TrimmedNonEmptyString.annotate({
|
|
description: "Repository name as owner/name.",
|
|
}),
|
|
number: PositiveInt.annotate({ description: "Pull request number." }),
|
|
url: ThreadMetadataMcpPullRequestUrl,
|
|
});
|
|
export type ThreadMetadataMcpPullRequest = typeof ThreadMetadataMcpPullRequest.Type;
|
|
|
|
export const ThreadMetadataMcpUpdateInput = Schema.Struct({
|
|
threadId: Schema.optional(ThreadId).annotate({
|
|
description: "Thread in the calling project. Omit to update the calling thread.",
|
|
}),
|
|
action: ThreadMetadataMcpAction,
|
|
title: Schema.optional(ThreadMetadataTitle),
|
|
pullRequest: Schema.optional(ThreadMetadataMcpPullRequest).annotate({
|
|
description: "Pull request to link. Required only when action is link_pull_request.",
|
|
}),
|
|
clientRequestId: Schema.optional(ThreadMetadataClientRequestId),
|
|
}).check(
|
|
Schema.makeFilter((input) => {
|
|
switch (input.action) {
|
|
case "rename":
|
|
return input.title !== undefined && input.pullRequest === undefined
|
|
? true
|
|
: "rename requires title and does not accept pullRequest.";
|
|
case "link_pull_request":
|
|
return input.pullRequest !== undefined && input.title === undefined
|
|
? true
|
|
: "link_pull_request requires pullRequest and does not accept title.";
|
|
case "regenerate_title":
|
|
case "unlink_pull_request":
|
|
return input.title === undefined && input.pullRequest === undefined
|
|
? true
|
|
: `${input.action} does not accept title or pullRequest.`;
|
|
}
|
|
}),
|
|
);
|
|
export type ThreadMetadataMcpUpdateInput = typeof ThreadMetadataMcpUpdateInput.Type;
|
|
|
|
export const ThreadMetadataMcpUpdateResult = Schema.Struct({
|
|
threadId: ThreadId,
|
|
action: ThreadMetadataMcpAction,
|
|
commandId: CommandId,
|
|
sequence: NonNegativeInt,
|
|
title: Schema.String,
|
|
titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
|
|
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
|
|
updatedAt: IsoDateTime,
|
|
});
|
|
export type ThreadMetadataMcpUpdateResult = typeof ThreadMetadataMcpUpdateResult.Type;
|