@vercel/factory 0.0.24 → 0.0.25
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @vercel/factory
|
|
2
2
|
|
|
3
|
+
## 0.0.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a0e8c40: `checkoutGitHubRepository` can also fetch a pull request's head (including forks) to `origin/pr/<number>`, and Foreman's `inspect_repository` accepts a `pullRequestNumber`.
|
|
8
|
+
|
|
3
9
|
## 0.0.24
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -157,6 +157,8 @@ interface CheckoutGitHubRepositoryBaseInput {
|
|
|
157
157
|
sandbox: GitTransferSandbox;
|
|
158
158
|
repositorySlug: RepositorySlug;
|
|
159
159
|
transport: GitHubGitTransport;
|
|
160
|
+
/** Also fetch this pull request's head, including forks, to `refs/remotes/origin/pr/<number>`. */
|
|
161
|
+
pullRequestNumber?: number;
|
|
160
162
|
}
|
|
161
163
|
/** Authorized repository checkout with recovery options that require a branch to resume. */
|
|
162
164
|
type CheckoutGitHubRepositoryInput = CheckoutGitHubRepositoryBaseInput & ({
|
|
@@ -227,9 +227,12 @@ async function checkoutGitHubRepository(input) {
|
|
|
227
227
|
if (existingOrigin !== "" && existingOrigin.toLowerCase() !== expectedOrigin) throw new GitHubCheckoutConflictError(existingOrigin, expectedOrigin);
|
|
228
228
|
const resume = input.resumeBranch;
|
|
229
229
|
if (resume !== void 0 && !isSafeGitRef(resume)) throw new Error(`refusing to resume unsafe branch name: ${resume}`);
|
|
230
|
+
const pullRequestNumber = input.pullRequestNumber;
|
|
231
|
+
if (pullRequestNumber !== void 0 && (!Number.isSafeInteger(pullRequestNumber) || pullRequestNumber < 1)) throw new Error("pullRequestNumber must be a positive integer");
|
|
232
|
+
const pullRequestRef = pullRequestNumber === void 0 ? void 0 : `refs/pull/${pullRequestNumber}/head`;
|
|
230
233
|
await input.transport.fetch({
|
|
231
234
|
repository: slug,
|
|
232
|
-
refs: []
|
|
235
|
+
refs: pullRequestRef === void 0 ? [] : [pullRequestRef]
|
|
233
236
|
}, async (bundle) => {
|
|
234
237
|
await withSandboxGitBundle({
|
|
235
238
|
sandbox: input.sandbox,
|
|
@@ -285,6 +288,14 @@ async function checkoutGitHubRepository(input) {
|
|
|
285
288
|
"origin/HEAD"
|
|
286
289
|
]);
|
|
287
290
|
}
|
|
291
|
+
if (pullRequestRef !== void 0) await runSandboxCommand(input.sandbox, [
|
|
292
|
+
"git",
|
|
293
|
+
"-C",
|
|
294
|
+
"repo",
|
|
295
|
+
"fetch",
|
|
296
|
+
path,
|
|
297
|
+
`+${pullRequestRef}:refs/remotes/origin/pr/${pullRequestNumber}`
|
|
298
|
+
]);
|
|
288
299
|
if (resume === void 0) return;
|
|
289
300
|
if ((await input.sandbox.run({ command: [
|
|
290
301
|
"git",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-publication.mjs","names":[],"sources":["../src/github-publication.ts"],"sourcesContent":["import {\n withSandboxGitBundle,\n quoteShellArgument,\n runSandboxCommand,\n type GitHubGitTransport,\n type GitTransferSandbox,\n} from \"./github-transfer\";\nimport type { TaskId } from \"./schema/id\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\nimport { agentSessionIdSchema, type AgentSessionId } from \"./schema/session\";\nimport { z } from \"zod\";\n\n/** Minimal sandbox command boundary required by Git checkout and publication helpers. */\nexport interface SandboxGit {\n run(options: SandboxGitCommandInput): PromiseLike<SandboxGitCommandResult>;\n}\n\n/** Shell command submitted through the minimal Git sandbox boundary. */\nexport interface SandboxGitCommandInput {\n command: string;\n}\n\n/** Captured output and optional exit status from a sandbox Git command. */\nexport interface SandboxGitCommandResult {\n stdout: string;\n stderr?: string;\n exitCode?: number;\n}\n\n/** Bounds applied while translating committed workspace changes into GitHub tree entries. */\nexport interface GitHubPublicationLimits {\n maxChangedFiles?: number;\n maxFileBytes?: number;\n}\n\n/** Repository-scoped credentials and transport for the GitHub publication client. */\nexport interface GitHubPublicationClientOptions {\n repository: RepositorySlug;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Pull-request snapshot used to reconcile idempotent publication effects. */\nexport interface GitHubPublicationPullRequest {\n pullRequestNumber: number;\n pullRequestUrl: string;\n nodeId: string;\n title: string;\n body: string | null;\n state: \"open\" | \"closed\";\n draft: boolean;\n head: {\n branch: string;\n sha: string;\n repository: RepositorySlug | null;\n };\n}\n\n/** Git Data and pull-request operations needed by supplied publication workflows. */\nexport interface GitHubPublicationClient {\n commit(input: ReadGitHubCommitInput): Promise<GitHubCommit>;\n branchHead(input: ReadGitHubBranchHeadInput): Promise<string | null>;\n createTree(input: CreateGitHubTreeInput): Promise<string>;\n createCommit(input: CreateGitHubCommitInput): Promise<string>;\n createBranch(input: CreateGitHubBranchInput): Promise<void>;\n updateBranch(input: UpdateGitHubBranchInput): Promise<void>;\n createPullRequest(\n input: CreateGitHubPublicationPullRequestInput,\n ): Promise<CreatedGitHubPublicationPullRequest>;\n pullRequest(input: ReadGitHubPullRequestInput): Promise<GitHubPublicationPullRequest>;\n pullRequests(\n input: ListGitHubPublicationPullRequestsInput,\n ): Promise<readonly GitHubPublicationPullRequest[]>;\n markReady(input: MarkGitHubPullRequestReadyInput): Promise<void>;\n}\n\n/** Exact commit requested from GitHub's Git Data API. */\nexport interface ReadGitHubCommitInput {\n sha: string;\n}\n\n/** Tree and parents recorded for one GitHub commit. */\nexport interface GitHubCommit {\n treeSha: string;\n parentShas: readonly string[];\n}\n\n/** Exact branch whose current GitHub head should be read. */\nexport interface ReadGitHubBranchHeadInput {\n branch: string;\n}\n\n/** Base tree and exclusive file operations used to create a GitHub tree. */\nexport interface CreateGitHubTreeInput {\n baseTreeSha: string;\n entries: readonly GitHubTreeEntry[];\n}\n\n/** Commit content and parent identities used to create a GitHub commit. */\nexport interface CreateGitHubCommitInput {\n message: string;\n treeSha: string;\n parentShas: readonly string[];\n}\n\n/** Branch and commit identity used to create a GitHub branch. */\nexport interface CreateGitHubBranchInput {\n branch: string;\n sha: string;\n}\n\n/** Branch update and force policy used to move a GitHub branch. */\nexport interface UpdateGitHubBranchInput extends CreateGitHubBranchInput {\n force: boolean;\n}\n\n/** Provider-owned pull-request number to read. */\nexport interface ReadGitHubPullRequestInput {\n pullRequestNumber: number;\n}\n\n/** Provider GraphQL node identity of a draft pull request to mark ready. */\nexport interface MarkGitHubPullRequestReadyInput {\n nodeId: string;\n}\n\n/** Pull-request presentation and branch inputs used during GitHub publication. */\nexport interface CreateGitHubPublicationPullRequestInput {\n title: string;\n body: string;\n head: string;\n base: string;\n draft: boolean;\n}\n\n/** Provider identity and draft state returned after creating a pull request. */\nexport interface CreatedGitHubPublicationPullRequest {\n pullRequestNumber: number;\n pullRequestUrl: string;\n draft: boolean;\n}\n\n/** State and optional exact head filter used to list publication pull requests. */\nexport interface ListGitHubPublicationPullRequestsInput {\n state: \"open\" | \"all\";\n head?: string;\n}\n\n/** GitHub publication failure that preserves the provider HTTP status. */\nexport class GitHubPublicationApiError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(`GitHub API request failed (${status}): ${message}`);\n this.name = \"GitHubPublicationApiError\";\n }\n}\n\ninterface GitHubTreeEntryBase {\n path: string;\n mode: \"100644\" | \"100755\";\n type: \"blob\";\n}\n\n/** File content uploaded through GitHub's Git Data API. */\nexport interface GitHubTreeUpsert extends GitHubTreeEntryBase {\n content: string;\n sha?: never;\n}\n\n/** Existing file removed through GitHub's Git Data API. */\nexport interface GitHubTreeDeletion extends GitHubTreeEntryBase {\n sha: null;\n content?: never;\n}\n\n/** Exclusive bounded file upsert or deletion accepted by GitHub's Git Data API. */\nexport type GitHubTreeEntry = GitHubTreeUpsert | GitHubTreeDeletion;\n\n/** Committed workspace delta represented against a specific base commit. */\nexport interface CommittedGitChange {\n base: string;\n commitMessage: string;\n tree: readonly GitHubTreeEntry[];\n changedFiles: number;\n}\n\n/** Sandbox, repository, and bounds for reading a committed workspace delta. */\nexport interface ReadCommittedGitChangeInput extends GitHubPublicationLimits {\n sandbox: SandboxGit;\n repositorySlug: RepositorySlug;\n baseRef?: string;\n allowEmpty?: boolean;\n}\n\n/** Common dependencies for an authorized repository checkout. */\ninterface CheckoutGitHubRepositoryBaseInput {\n sandbox: GitTransferSandbox;\n repositorySlug: RepositorySlug;\n transport: GitHubGitTransport;\n}\n\n/** Authorized repository checkout with recovery options that require a branch to resume. */\nexport type CheckoutGitHubRepositoryInput = CheckoutGitHubRepositoryBaseInput &\n (\n | {\n resumeBranch?: never;\n rememberPublishedHead?: never;\n }\n | {\n /** Resume this remote branch when it exists after refreshing the default branch. */\n resumeBranch: string;\n /** Remember the resumed remote head for later publication reconciliation. */\n rememberPublishedHead?: true;\n }\n );\n\n/** Refusal raised when an existing sandbox checkout points at another repository. */\nexport class GitHubCheckoutConflictError extends Error {\n constructor(\n readonly existingOrigin: string,\n readonly expectedOrigin: string,\n ) {\n super(`sandbox checkout ${existingOrigin} does not match ${expectedOrigin}`);\n this.name = \"GitHubCheckoutConflictError\";\n }\n}\n\nconst safePathPattern = /^[A-Za-z0-9.][A-Za-z0-9._/-]*$/u;\nconst safeRefPattern = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/u;\nconst allowedModes = new Set([\"100644\", \"100755\"]);\nconst gitHubApiUrl = \"https://api.github.com\";\n\nconst shaSchema = z.string().min(1);\nconst pullRequestSchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n node_id: z.string().min(1),\n title: z.string(),\n body: z.string().nullable(),\n state: z.enum([\"open\", \"closed\"]),\n draft: z.boolean(),\n head: z.object({\n ref: z.string().min(1),\n sha: shaSchema,\n repo: z.object({ full_name: z.string().min(1) }).nullable(),\n }),\n});\n\n/** GitHub Git Data and pull-request operations used by publication workflows. */\nexport function createGitHubPublicationClient(\n options: GitHubPublicationClientOptions,\n): GitHubPublicationClient {\n const repository = repositorySlugSchema.parse(options.repository.toLowerCase());\n const request = async (path: string, init: RequestInit = {}): Promise<unknown> => {\n let response: Response;\n try {\n response = await (options.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${repository}${path}`,\n {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n ...init.headers,\n },\n },\n );\n } catch (error) {\n throw new Error(\"GitHub API request failed\", { cause: error });\n }\n const body: unknown = await response.json().catch(() => null);\n if (!response.ok) {\n const parsed = z.object({ message: z.string() }).safeParse(body);\n throw new GitHubPublicationApiError(\n response.status,\n parsed.success ? parsed.data.message : response.statusText,\n );\n }\n return body;\n };\n const graphql = async (query: string, variables: Record<string, unknown>): Promise<void> => {\n let response: Response;\n try {\n response = await (options.fetch ?? globalThis.fetch)(`${gitHubApiUrl}/graphql`, {\n method: \"POST\",\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n body: JSON.stringify({ query, variables }),\n });\n } catch (error) {\n throw new Error(\"GitHub GraphQL request failed\", { cause: error });\n }\n const body: unknown = await response.json().catch(() => null);\n const parsed = z\n .object({ errors: z.array(z.object({ message: z.string() })).optional() })\n .safeParse(body);\n if (!response.ok || (parsed.success && parsed.data.errors?.length)) {\n throw new GitHubPublicationApiError(\n response.status,\n parsed.success && parsed.data.errors?.[0] !== undefined\n ? parsed.data.errors[0].message\n : response.statusText,\n );\n }\n };\n const parsePullRequest = (value: unknown): GitHubPublicationPullRequest => {\n const pull = pullRequestSchema.parse(value);\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n nodeId: pull.node_id,\n title: pull.title,\n body: pull.body,\n state: pull.state,\n draft: pull.draft,\n head: {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository:\n pull.head.repo === null\n ? null\n : repositorySlugSchema.parse(pull.head.repo.full_name.toLowerCase()),\n },\n };\n };\n const branchPath = (branch: string): string => {\n if (!isSafeGitRef(branch)) throw new Error(`refusing to use unsafe branch name: ${branch}`);\n return branch;\n };\n\n return {\n async commit(input) {\n const commit = z\n .object({\n tree: z.object({ sha: shaSchema }),\n parents: z.array(z.object({ sha: shaSchema })),\n })\n .parse(await request(`/git/commits/${encodeURIComponent(input.sha)}`));\n return { treeSha: commit.tree.sha, parentShas: commit.parents.map((parent) => parent.sha) };\n },\n async branchHead(input) {\n try {\n const ref = z\n .object({ object: z.object({ sha: shaSchema }) })\n .parse(await request(`/git/ref/heads/${branchPath(input.branch)}`));\n return ref.object.sha;\n } catch (error) {\n if (error instanceof GitHubPublicationApiError && error.status === 404) return null;\n throw error;\n }\n },\n async createTree(input) {\n return z.object({ sha: shaSchema }).parse(\n await request(\"/git/trees\", {\n method: \"POST\",\n body: JSON.stringify({ base_tree: input.baseTreeSha, tree: input.entries }),\n }),\n ).sha;\n },\n async createCommit(input) {\n return z.object({ sha: shaSchema }).parse(\n await request(\"/git/commits\", {\n method: \"POST\",\n body: JSON.stringify({\n message: input.message,\n tree: input.treeSha,\n parents: input.parentShas,\n }),\n }),\n ).sha;\n },\n async createBranch(input) {\n await request(\"/git/refs\", {\n method: \"POST\",\n body: JSON.stringify({\n ref: `refs/heads/${branchPath(input.branch)}`,\n sha: input.sha,\n }),\n });\n },\n async updateBranch(input) {\n await request(`/git/refs/heads/${branchPath(input.branch)}`, {\n method: \"PATCH\",\n body: JSON.stringify({ sha: input.sha, force: input.force }),\n });\n },\n async createPullRequest(input) {\n const pull = z\n .object({\n number: z.number().int().positive(),\n html_url: z.url(),\n draft: z.boolean(),\n })\n .parse(\n await request(\"/pulls\", {\n method: \"POST\",\n body: JSON.stringify(input),\n }),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n draft: pull.draft,\n };\n },\n async pullRequest(input) {\n return parsePullRequest(await request(`/pulls/${input.pullRequestNumber}`));\n },\n async pullRequests(input) {\n const query = new URLSearchParams({ state: input.state, per_page: \"100\" });\n if (input.head !== undefined) query.set(\"head\", input.head);\n return z\n .array(pullRequestSchema)\n .parse(await request(`/pulls?${query.toString()}`))\n .map(parsePullRequest);\n },\n async markReady(input) {\n await graphql(\n \"mutation($id: ID!) { markPullRequestReadyForReview(input: { pullRequestId: $id }) { clientMutationId } }\",\n { id: input.nodeId },\n );\n },\n };\n}\n\n/** Derive the deterministic publication branch owned by a durable Task. */\nexport function factoryTaskBranch(taskId: TaskId): string {\n return `factory/${taskId}`;\n}\n\n/** Derive the deterministic publication branch owned by an operator session. */\nexport function factorySessionBranch(sessionId: AgentSessionId): string {\n return `factory/${agentSessionIdSchema.parse(sessionId)}`;\n}\n\n/** Check whether a Git reference is safe to interpolate into supplied Git commands. */\nexport function isSafeGitRef(ref: string): boolean {\n return safeRefPattern.test(ref) && !ref.includes(\"..\");\n}\n\n/** Clone or refresh one authorized GitHub repository without retaining credentials. */\nexport async function checkoutGitHubRepository(\n input: CheckoutGitHubRepositoryInput,\n): Promise<void> {\n const slug = repositorySlugSchema.parse(input.repositorySlug.toLowerCase());\n const expectedOrigin = `https://github.com/${slug}.git`;\n const checkout = await input.sandbox.run({ command: \"test -d repo/.git\" });\n const existingOrigin =\n checkout.exitCode === undefined || checkout.exitCode === 0\n ? (\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"remote\",\n \"get-url\",\n \"origin\",\n ])\n ).trim()\n : \"\";\n if (existingOrigin !== \"\" && existingOrigin.toLowerCase() !== expectedOrigin) {\n throw new GitHubCheckoutConflictError(existingOrigin, expectedOrigin);\n }\n\n const resume = input.resumeBranch;\n if (resume !== undefined && !isSafeGitRef(resume)) {\n throw new Error(`refusing to resume unsafe branch name: ${resume}`);\n }\n await input.transport.fetch({ repository: slug, refs: [] }, async (bundle) => {\n await withSandboxGitBundle({\n sandbox: input.sandbox,\n bundle,\n async use(path) {\n if (existingOrigin === \"\") {\n await runSandboxCommand(input.sandbox, [\"git\", \"clone\", path, \"repo\"]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"remote\",\n \"set-url\",\n \"origin\",\n expectedOrigin,\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"user.name\",\n \"factory\",\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"user.email\",\n \"factory@localhost\",\n ]);\n } else {\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"fetch\",\n path,\n \"+refs/heads/*:refs/remotes/origin/*\",\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"reset\",\n \"--hard\",\n \"origin/HEAD\",\n ]);\n }\n if (resume === undefined) return;\n const exists = await input.sandbox.run({\n command: [\n \"git\",\n \"-C\",\n \"repo\",\n \"show-ref\",\n \"--verify\",\n \"--quiet\",\n `refs/remotes/origin/${resume}`,\n ]\n .map(quoteShellArgument)\n .join(\" \"),\n });\n if (exists.exitCode !== 0) return;\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"checkout\",\n \"-B\",\n resume,\n `refs/remotes/origin/${resume}`,\n ]);\n if (input.rememberPublishedHead === true) {\n const head = (\n await runSandboxCommand(input.sandbox, [\"git\", \"-C\", \"repo\", \"rev-parse\", \"HEAD\"])\n ).trim();\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"factory.publishedHead\",\n head,\n ]);\n }\n },\n });\n });\n}\n\n/** Sandbox and argument vector for one Git command in a repository checkout. */\nexport interface RunSandboxGitInput {\n sandbox: SandboxGit;\n args: readonly string[];\n repositoryPath?: string;\n}\n\n/** Run a Git argument vector in a sandbox repository and reject nonzero exits. */\nexport function runSandboxGit(input: RunSandboxGitInput): Promise<string> {\n return runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n input.repositoryPath ?? \"repo\",\n ...input.args,\n ]);\n}\n\n/** Read committed sandbox changes as a bounded GitHub Git Data API tree. */\nexport async function readCommittedGitChange(\n input: ReadCommittedGitChangeInput,\n): Promise<CommittedGitChange> {\n const repositorySlug = repositorySlugSchema.parse(input.repositorySlug.toLowerCase());\n const baseRef = input.baseRef ?? \"origin/HEAD\";\n if (!isSafeGitRef(baseRef)) {\n throw new Error(`refusing to read unsafe base ref: ${baseRef}`);\n }\n const maxChangedFiles = input.maxChangedFiles ?? 25;\n const maxFileBytes = input.maxFileBytes ?? 200_000;\n if (!Number.isSafeInteger(maxChangedFiles) || maxChangedFiles < 1) {\n throw new Error(\"maxChangedFiles must be a positive integer\");\n }\n if (!Number.isSafeInteger(maxFileBytes) || maxFileBytes < 1) {\n throw new Error(\"maxFileBytes must be a positive integer\");\n }\n const origin = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"remote\", \"get-url\", \"origin\"] })\n ).trim();\n if (origin !== `https://github.com/${repositorySlug}.git`) {\n throw new Error(`sandbox checkout does not match task repository ${repositorySlug}`);\n }\n const head = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"rev-parse\", \"HEAD\"] })\n ).trim();\n const base = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"rev-parse\", baseRef] })\n ).trim();\n if (head === base && input.allowEmpty !== true) {\n throw new Error(\"no local commits to publish; commit your changes in the repo first\");\n }\n const commitMessage = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"log\", \"-1\", \"--format=%B\", \"HEAD\"] })\n ).trimEnd();\n if (commitMessage.length === 0) throw new Error(\"the committed change has no commit message\");\n if (Buffer.byteLength(commitMessage, \"utf8\") > 65_536) {\n throw new Error(\"the committed change message exceeds the publication limit\");\n }\n\n const nameStatus = (\n await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"diff\", \"--name-status\", base, head],\n })\n ).trim();\n const upserts: string[] = [];\n const deletions: string[] = [];\n for (const line of nameStatus.split(\"\\n\").filter(Boolean)) {\n const fields = line.split(\"\\t\");\n const status = fields[0] ?? \"\";\n if (status === \"A\" || status === \"M\" || status === \"T\") {\n upserts.push(requireSafePath(fields[1]));\n } else if (status === \"D\") {\n deletions.push(requireSafePath(fields[1]));\n } else if (status.startsWith(\"R\") || status.startsWith(\"C\")) {\n if (status.startsWith(\"R\")) deletions.push(requireSafePath(fields[1]));\n upserts.push(requireSafePath(fields[2]));\n } else {\n throw new Error(`unsupported change status \"${status}\" in ${line}`);\n }\n }\n const changedFiles = upserts.length + deletions.length;\n if (changedFiles === 0 && input.allowEmpty !== true) {\n throw new Error(\"the local commits contain no file changes\");\n }\n if (changedFiles > maxChangedFiles) {\n throw new Error(`too many changed files (${changedFiles} > ${maxChangedFiles})`);\n }\n\n const tree: GitHubTreeEntry[] = [];\n for (const path of upserts) {\n const mode = (\n await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"ls-tree\", head, \"--\", path],\n })\n )\n .trim()\n .split(\" \")[0];\n if (mode === undefined || !allowedModes.has(mode)) {\n throw new Error(`unsupported file mode ${mode || \"(none)\"} for ${path}`);\n }\n const content = await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"show\", `${head}:${path}`],\n });\n if (Buffer.byteLength(content, \"utf8\") > maxFileBytes) {\n throw new Error(`${path} exceeds the ${maxFileBytes} byte publication limit`);\n }\n tree.push({ path, mode: mode as \"100644\" | \"100755\", type: \"blob\", content });\n }\n for (const path of deletions) {\n tree.push({ path, mode: \"100644\", type: \"blob\", sha: null });\n }\n return { base, commitMessage, tree, changedFiles };\n}\n\nfunction requireSafePath(path: string | undefined): string {\n if (path === undefined || path === \"\" || !safePathPattern.test(path) || path.includes(\"..\")) {\n throw new Error(`refusing to publish unsafe path: ${path ?? \"(missing)\"}`);\n }\n return path;\n}\n"],"mappings":";;;;;;AAqJA,IAAa,4BAAb,cAA+C,MAAM;CAExC;CADX,YACE,QACA,SACA;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AK,eAAe,aAAa,wBAAwB;EAE9E,KAAK,KAAK;GAAE;GAAY;GAA6B,MAAM;GAAQ;EAAQ,CAAC;CAC9E;CACA,KAAK,MAAM,QAAQ,WACjB,KAAK,KAAK;EAAE;EAAM,MAAM;EAAU,MAAM;EAAQ,KAAK;CAAK,CAAC;CAE7D,OAAO;EAAE;EAAM;EAAe;EAAM;CAAa;AACnD;AAEA,SAAS,gBAAgB,MAAkC;CACzD,IAAI,SAAS,KAAA,KAAa,SAAS,MAAM,CAAC,gBAAgB,KAAK,IAAI,KAAK,KAAK,SAAS,IAAI,GACxF,MAAM,IAAI,MAAM,oCAAoC,QAAQ,aAAa;CAE3E,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"github-publication.mjs","names":[],"sources":["../src/github-publication.ts"],"sourcesContent":["import {\n withSandboxGitBundle,\n quoteShellArgument,\n runSandboxCommand,\n type GitHubGitTransport,\n type GitTransferSandbox,\n} from \"./github-transfer\";\nimport type { TaskId } from \"./schema/id\";\nimport { repositorySlugSchema, type RepositorySlug } from \"./schema/repository\";\nimport { agentSessionIdSchema, type AgentSessionId } from \"./schema/session\";\nimport { z } from \"zod\";\n\n/** Minimal sandbox command boundary required by Git checkout and publication helpers. */\nexport interface SandboxGit {\n run(options: SandboxGitCommandInput): PromiseLike<SandboxGitCommandResult>;\n}\n\n/** Shell command submitted through the minimal Git sandbox boundary. */\nexport interface SandboxGitCommandInput {\n command: string;\n}\n\n/** Captured output and optional exit status from a sandbox Git command. */\nexport interface SandboxGitCommandResult {\n stdout: string;\n stderr?: string;\n exitCode?: number;\n}\n\n/** Bounds applied while translating committed workspace changes into GitHub tree entries. */\nexport interface GitHubPublicationLimits {\n maxChangedFiles?: number;\n maxFileBytes?: number;\n}\n\n/** Repository-scoped credentials and transport for the GitHub publication client. */\nexport interface GitHubPublicationClientOptions {\n repository: RepositorySlug;\n token: string;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Pull-request snapshot used to reconcile idempotent publication effects. */\nexport interface GitHubPublicationPullRequest {\n pullRequestNumber: number;\n pullRequestUrl: string;\n nodeId: string;\n title: string;\n body: string | null;\n state: \"open\" | \"closed\";\n draft: boolean;\n head: {\n branch: string;\n sha: string;\n repository: RepositorySlug | null;\n };\n}\n\n/** Git Data and pull-request operations needed by supplied publication workflows. */\nexport interface GitHubPublicationClient {\n commit(input: ReadGitHubCommitInput): Promise<GitHubCommit>;\n branchHead(input: ReadGitHubBranchHeadInput): Promise<string | null>;\n createTree(input: CreateGitHubTreeInput): Promise<string>;\n createCommit(input: CreateGitHubCommitInput): Promise<string>;\n createBranch(input: CreateGitHubBranchInput): Promise<void>;\n updateBranch(input: UpdateGitHubBranchInput): Promise<void>;\n createPullRequest(\n input: CreateGitHubPublicationPullRequestInput,\n ): Promise<CreatedGitHubPublicationPullRequest>;\n pullRequest(input: ReadGitHubPullRequestInput): Promise<GitHubPublicationPullRequest>;\n pullRequests(\n input: ListGitHubPublicationPullRequestsInput,\n ): Promise<readonly GitHubPublicationPullRequest[]>;\n markReady(input: MarkGitHubPullRequestReadyInput): Promise<void>;\n}\n\n/** Exact commit requested from GitHub's Git Data API. */\nexport interface ReadGitHubCommitInput {\n sha: string;\n}\n\n/** Tree and parents recorded for one GitHub commit. */\nexport interface GitHubCommit {\n treeSha: string;\n parentShas: readonly string[];\n}\n\n/** Exact branch whose current GitHub head should be read. */\nexport interface ReadGitHubBranchHeadInput {\n branch: string;\n}\n\n/** Base tree and exclusive file operations used to create a GitHub tree. */\nexport interface CreateGitHubTreeInput {\n baseTreeSha: string;\n entries: readonly GitHubTreeEntry[];\n}\n\n/** Commit content and parent identities used to create a GitHub commit. */\nexport interface CreateGitHubCommitInput {\n message: string;\n treeSha: string;\n parentShas: readonly string[];\n}\n\n/** Branch and commit identity used to create a GitHub branch. */\nexport interface CreateGitHubBranchInput {\n branch: string;\n sha: string;\n}\n\n/** Branch update and force policy used to move a GitHub branch. */\nexport interface UpdateGitHubBranchInput extends CreateGitHubBranchInput {\n force: boolean;\n}\n\n/** Provider-owned pull-request number to read. */\nexport interface ReadGitHubPullRequestInput {\n pullRequestNumber: number;\n}\n\n/** Provider GraphQL node identity of a draft pull request to mark ready. */\nexport interface MarkGitHubPullRequestReadyInput {\n nodeId: string;\n}\n\n/** Pull-request presentation and branch inputs used during GitHub publication. */\nexport interface CreateGitHubPublicationPullRequestInput {\n title: string;\n body: string;\n head: string;\n base: string;\n draft: boolean;\n}\n\n/** Provider identity and draft state returned after creating a pull request. */\nexport interface CreatedGitHubPublicationPullRequest {\n pullRequestNumber: number;\n pullRequestUrl: string;\n draft: boolean;\n}\n\n/** State and optional exact head filter used to list publication pull requests. */\nexport interface ListGitHubPublicationPullRequestsInput {\n state: \"open\" | \"all\";\n head?: string;\n}\n\n/** GitHub publication failure that preserves the provider HTTP status. */\nexport class GitHubPublicationApiError extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(`GitHub API request failed (${status}): ${message}`);\n this.name = \"GitHubPublicationApiError\";\n }\n}\n\ninterface GitHubTreeEntryBase {\n path: string;\n mode: \"100644\" | \"100755\";\n type: \"blob\";\n}\n\n/** File content uploaded through GitHub's Git Data API. */\nexport interface GitHubTreeUpsert extends GitHubTreeEntryBase {\n content: string;\n sha?: never;\n}\n\n/** Existing file removed through GitHub's Git Data API. */\nexport interface GitHubTreeDeletion extends GitHubTreeEntryBase {\n sha: null;\n content?: never;\n}\n\n/** Exclusive bounded file upsert or deletion accepted by GitHub's Git Data API. */\nexport type GitHubTreeEntry = GitHubTreeUpsert | GitHubTreeDeletion;\n\n/** Committed workspace delta represented against a specific base commit. */\nexport interface CommittedGitChange {\n base: string;\n commitMessage: string;\n tree: readonly GitHubTreeEntry[];\n changedFiles: number;\n}\n\n/** Sandbox, repository, and bounds for reading a committed workspace delta. */\nexport interface ReadCommittedGitChangeInput extends GitHubPublicationLimits {\n sandbox: SandboxGit;\n repositorySlug: RepositorySlug;\n baseRef?: string;\n allowEmpty?: boolean;\n}\n\n/** Common dependencies for an authorized repository checkout. */\ninterface CheckoutGitHubRepositoryBaseInput {\n sandbox: GitTransferSandbox;\n repositorySlug: RepositorySlug;\n transport: GitHubGitTransport;\n /** Also fetch this pull request's head, including forks, to `refs/remotes/origin/pr/<number>`. */\n pullRequestNumber?: number;\n}\n\n/** Authorized repository checkout with recovery options that require a branch to resume. */\nexport type CheckoutGitHubRepositoryInput = CheckoutGitHubRepositoryBaseInput &\n (\n | {\n resumeBranch?: never;\n rememberPublishedHead?: never;\n }\n | {\n /** Resume this remote branch when it exists after refreshing the default branch. */\n resumeBranch: string;\n /** Remember the resumed remote head for later publication reconciliation. */\n rememberPublishedHead?: true;\n }\n );\n\n/** Refusal raised when an existing sandbox checkout points at another repository. */\nexport class GitHubCheckoutConflictError extends Error {\n constructor(\n readonly existingOrigin: string,\n readonly expectedOrigin: string,\n ) {\n super(`sandbox checkout ${existingOrigin} does not match ${expectedOrigin}`);\n this.name = \"GitHubCheckoutConflictError\";\n }\n}\n\nconst safePathPattern = /^[A-Za-z0-9.][A-Za-z0-9._/-]*$/u;\nconst safeRefPattern = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/u;\nconst allowedModes = new Set([\"100644\", \"100755\"]);\nconst gitHubApiUrl = \"https://api.github.com\";\n\nconst shaSchema = z.string().min(1);\nconst pullRequestSchema = z.object({\n number: z.number().int().positive(),\n html_url: z.url(),\n node_id: z.string().min(1),\n title: z.string(),\n body: z.string().nullable(),\n state: z.enum([\"open\", \"closed\"]),\n draft: z.boolean(),\n head: z.object({\n ref: z.string().min(1),\n sha: shaSchema,\n repo: z.object({ full_name: z.string().min(1) }).nullable(),\n }),\n});\n\n/** GitHub Git Data and pull-request operations used by publication workflows. */\nexport function createGitHubPublicationClient(\n options: GitHubPublicationClientOptions,\n): GitHubPublicationClient {\n const repository = repositorySlugSchema.parse(options.repository.toLowerCase());\n const request = async (path: string, init: RequestInit = {}): Promise<unknown> => {\n let response: Response;\n try {\n response = await (options.fetch ?? globalThis.fetch)(\n `${gitHubApiUrl}/repos/${repository}${path}`,\n {\n ...init,\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n ...init.headers,\n },\n },\n );\n } catch (error) {\n throw new Error(\"GitHub API request failed\", { cause: error });\n }\n const body: unknown = await response.json().catch(() => null);\n if (!response.ok) {\n const parsed = z.object({ message: z.string() }).safeParse(body);\n throw new GitHubPublicationApiError(\n response.status,\n parsed.success ? parsed.data.message : response.statusText,\n );\n }\n return body;\n };\n const graphql = async (query: string, variables: Record<string, unknown>): Promise<void> => {\n let response: Response;\n try {\n response = await (options.fetch ?? globalThis.fetch)(`${gitHubApiUrl}/graphql`, {\n method: \"POST\",\n headers: {\n Accept: \"application/vnd.github+json\",\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n },\n body: JSON.stringify({ query, variables }),\n });\n } catch (error) {\n throw new Error(\"GitHub GraphQL request failed\", { cause: error });\n }\n const body: unknown = await response.json().catch(() => null);\n const parsed = z\n .object({ errors: z.array(z.object({ message: z.string() })).optional() })\n .safeParse(body);\n if (!response.ok || (parsed.success && parsed.data.errors?.length)) {\n throw new GitHubPublicationApiError(\n response.status,\n parsed.success && parsed.data.errors?.[0] !== undefined\n ? parsed.data.errors[0].message\n : response.statusText,\n );\n }\n };\n const parsePullRequest = (value: unknown): GitHubPublicationPullRequest => {\n const pull = pullRequestSchema.parse(value);\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n nodeId: pull.node_id,\n title: pull.title,\n body: pull.body,\n state: pull.state,\n draft: pull.draft,\n head: {\n branch: pull.head.ref,\n sha: pull.head.sha,\n repository:\n pull.head.repo === null\n ? null\n : repositorySlugSchema.parse(pull.head.repo.full_name.toLowerCase()),\n },\n };\n };\n const branchPath = (branch: string): string => {\n if (!isSafeGitRef(branch)) throw new Error(`refusing to use unsafe branch name: ${branch}`);\n return branch;\n };\n\n return {\n async commit(input) {\n const commit = z\n .object({\n tree: z.object({ sha: shaSchema }),\n parents: z.array(z.object({ sha: shaSchema })),\n })\n .parse(await request(`/git/commits/${encodeURIComponent(input.sha)}`));\n return { treeSha: commit.tree.sha, parentShas: commit.parents.map((parent) => parent.sha) };\n },\n async branchHead(input) {\n try {\n const ref = z\n .object({ object: z.object({ sha: shaSchema }) })\n .parse(await request(`/git/ref/heads/${branchPath(input.branch)}`));\n return ref.object.sha;\n } catch (error) {\n if (error instanceof GitHubPublicationApiError && error.status === 404) return null;\n throw error;\n }\n },\n async createTree(input) {\n return z.object({ sha: shaSchema }).parse(\n await request(\"/git/trees\", {\n method: \"POST\",\n body: JSON.stringify({ base_tree: input.baseTreeSha, tree: input.entries }),\n }),\n ).sha;\n },\n async createCommit(input) {\n return z.object({ sha: shaSchema }).parse(\n await request(\"/git/commits\", {\n method: \"POST\",\n body: JSON.stringify({\n message: input.message,\n tree: input.treeSha,\n parents: input.parentShas,\n }),\n }),\n ).sha;\n },\n async createBranch(input) {\n await request(\"/git/refs\", {\n method: \"POST\",\n body: JSON.stringify({\n ref: `refs/heads/${branchPath(input.branch)}`,\n sha: input.sha,\n }),\n });\n },\n async updateBranch(input) {\n await request(`/git/refs/heads/${branchPath(input.branch)}`, {\n method: \"PATCH\",\n body: JSON.stringify({ sha: input.sha, force: input.force }),\n });\n },\n async createPullRequest(input) {\n const pull = z\n .object({\n number: z.number().int().positive(),\n html_url: z.url(),\n draft: z.boolean(),\n })\n .parse(\n await request(\"/pulls\", {\n method: \"POST\",\n body: JSON.stringify(input),\n }),\n );\n return {\n pullRequestNumber: pull.number,\n pullRequestUrl: pull.html_url,\n draft: pull.draft,\n };\n },\n async pullRequest(input) {\n return parsePullRequest(await request(`/pulls/${input.pullRequestNumber}`));\n },\n async pullRequests(input) {\n const query = new URLSearchParams({ state: input.state, per_page: \"100\" });\n if (input.head !== undefined) query.set(\"head\", input.head);\n return z\n .array(pullRequestSchema)\n .parse(await request(`/pulls?${query.toString()}`))\n .map(parsePullRequest);\n },\n async markReady(input) {\n await graphql(\n \"mutation($id: ID!) { markPullRequestReadyForReview(input: { pullRequestId: $id }) { clientMutationId } }\",\n { id: input.nodeId },\n );\n },\n };\n}\n\n/** Derive the deterministic publication branch owned by a durable Task. */\nexport function factoryTaskBranch(taskId: TaskId): string {\n return `factory/${taskId}`;\n}\n\n/** Derive the deterministic publication branch owned by an operator session. */\nexport function factorySessionBranch(sessionId: AgentSessionId): string {\n return `factory/${agentSessionIdSchema.parse(sessionId)}`;\n}\n\n/** Check whether a Git reference is safe to interpolate into supplied Git commands. */\nexport function isSafeGitRef(ref: string): boolean {\n return safeRefPattern.test(ref) && !ref.includes(\"..\");\n}\n\n/** Clone or refresh one authorized GitHub repository without retaining credentials. */\nexport async function checkoutGitHubRepository(\n input: CheckoutGitHubRepositoryInput,\n): Promise<void> {\n const slug = repositorySlugSchema.parse(input.repositorySlug.toLowerCase());\n const expectedOrigin = `https://github.com/${slug}.git`;\n const checkout = await input.sandbox.run({ command: \"test -d repo/.git\" });\n const existingOrigin =\n checkout.exitCode === undefined || checkout.exitCode === 0\n ? (\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"remote\",\n \"get-url\",\n \"origin\",\n ])\n ).trim()\n : \"\";\n if (existingOrigin !== \"\" && existingOrigin.toLowerCase() !== expectedOrigin) {\n throw new GitHubCheckoutConflictError(existingOrigin, expectedOrigin);\n }\n\n const resume = input.resumeBranch;\n if (resume !== undefined && !isSafeGitRef(resume)) {\n throw new Error(`refusing to resume unsafe branch name: ${resume}`);\n }\n const pullRequestNumber = input.pullRequestNumber;\n if (\n pullRequestNumber !== undefined &&\n (!Number.isSafeInteger(pullRequestNumber) || pullRequestNumber < 1)\n ) {\n throw new Error(\"pullRequestNumber must be a positive integer\");\n }\n const pullRequestRef =\n pullRequestNumber === undefined ? undefined : `refs/pull/${pullRequestNumber}/head`;\n await input.transport.fetch(\n { repository: slug, refs: pullRequestRef === undefined ? [] : [pullRequestRef] },\n async (bundle) => {\n await withSandboxGitBundle({\n sandbox: input.sandbox,\n bundle,\n async use(path) {\n if (existingOrigin === \"\") {\n await runSandboxCommand(input.sandbox, [\"git\", \"clone\", path, \"repo\"]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"remote\",\n \"set-url\",\n \"origin\",\n expectedOrigin,\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"user.name\",\n \"factory\",\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"user.email\",\n \"factory@localhost\",\n ]);\n } else {\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"fetch\",\n path,\n \"+refs/heads/*:refs/remotes/origin/*\",\n ]);\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"reset\",\n \"--hard\",\n \"origin/HEAD\",\n ]);\n }\n if (pullRequestRef !== undefined)\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"fetch\",\n path,\n `+${pullRequestRef}:refs/remotes/origin/pr/${pullRequestNumber}`,\n ]);\n if (resume === undefined) return;\n const exists = await input.sandbox.run({\n command: [\n \"git\",\n \"-C\",\n \"repo\",\n \"show-ref\",\n \"--verify\",\n \"--quiet\",\n `refs/remotes/origin/${resume}`,\n ]\n .map(quoteShellArgument)\n .join(\" \"),\n });\n if (exists.exitCode !== 0) return;\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"checkout\",\n \"-B\",\n resume,\n `refs/remotes/origin/${resume}`,\n ]);\n if (input.rememberPublishedHead === true) {\n const head = (\n await runSandboxCommand(input.sandbox, [\"git\", \"-C\", \"repo\", \"rev-parse\", \"HEAD\"])\n ).trim();\n await runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n \"repo\",\n \"config\",\n \"factory.publishedHead\",\n head,\n ]);\n }\n },\n });\n },\n );\n}\n\n/** Sandbox and argument vector for one Git command in a repository checkout. */\nexport interface RunSandboxGitInput {\n sandbox: SandboxGit;\n args: readonly string[];\n repositoryPath?: string;\n}\n\n/** Run a Git argument vector in a sandbox repository and reject nonzero exits. */\nexport function runSandboxGit(input: RunSandboxGitInput): Promise<string> {\n return runSandboxCommand(input.sandbox, [\n \"git\",\n \"-C\",\n input.repositoryPath ?? \"repo\",\n ...input.args,\n ]);\n}\n\n/** Read committed sandbox changes as a bounded GitHub Git Data API tree. */\nexport async function readCommittedGitChange(\n input: ReadCommittedGitChangeInput,\n): Promise<CommittedGitChange> {\n const repositorySlug = repositorySlugSchema.parse(input.repositorySlug.toLowerCase());\n const baseRef = input.baseRef ?? \"origin/HEAD\";\n if (!isSafeGitRef(baseRef)) {\n throw new Error(`refusing to read unsafe base ref: ${baseRef}`);\n }\n const maxChangedFiles = input.maxChangedFiles ?? 25;\n const maxFileBytes = input.maxFileBytes ?? 200_000;\n if (!Number.isSafeInteger(maxChangedFiles) || maxChangedFiles < 1) {\n throw new Error(\"maxChangedFiles must be a positive integer\");\n }\n if (!Number.isSafeInteger(maxFileBytes) || maxFileBytes < 1) {\n throw new Error(\"maxFileBytes must be a positive integer\");\n }\n const origin = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"remote\", \"get-url\", \"origin\"] })\n ).trim();\n if (origin !== `https://github.com/${repositorySlug}.git`) {\n throw new Error(`sandbox checkout does not match task repository ${repositorySlug}`);\n }\n const head = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"rev-parse\", \"HEAD\"] })\n ).trim();\n const base = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"rev-parse\", baseRef] })\n ).trim();\n if (head === base && input.allowEmpty !== true) {\n throw new Error(\"no local commits to publish; commit your changes in the repo first\");\n }\n const commitMessage = (\n await runSandboxGit({ sandbox: input.sandbox, args: [\"log\", \"-1\", \"--format=%B\", \"HEAD\"] })\n ).trimEnd();\n if (commitMessage.length === 0) throw new Error(\"the committed change has no commit message\");\n if (Buffer.byteLength(commitMessage, \"utf8\") > 65_536) {\n throw new Error(\"the committed change message exceeds the publication limit\");\n }\n\n const nameStatus = (\n await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"diff\", \"--name-status\", base, head],\n })\n ).trim();\n const upserts: string[] = [];\n const deletions: string[] = [];\n for (const line of nameStatus.split(\"\\n\").filter(Boolean)) {\n const fields = line.split(\"\\t\");\n const status = fields[0] ?? \"\";\n if (status === \"A\" || status === \"M\" || status === \"T\") {\n upserts.push(requireSafePath(fields[1]));\n } else if (status === \"D\") {\n deletions.push(requireSafePath(fields[1]));\n } else if (status.startsWith(\"R\") || status.startsWith(\"C\")) {\n if (status.startsWith(\"R\")) deletions.push(requireSafePath(fields[1]));\n upserts.push(requireSafePath(fields[2]));\n } else {\n throw new Error(`unsupported change status \"${status}\" in ${line}`);\n }\n }\n const changedFiles = upserts.length + deletions.length;\n if (changedFiles === 0 && input.allowEmpty !== true) {\n throw new Error(\"the local commits contain no file changes\");\n }\n if (changedFiles > maxChangedFiles) {\n throw new Error(`too many changed files (${changedFiles} > ${maxChangedFiles})`);\n }\n\n const tree: GitHubTreeEntry[] = [];\n for (const path of upserts) {\n const mode = (\n await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"ls-tree\", head, \"--\", path],\n })\n )\n .trim()\n .split(\" \")[0];\n if (mode === undefined || !allowedModes.has(mode)) {\n throw new Error(`unsupported file mode ${mode || \"(none)\"} for ${path}`);\n }\n const content = await runSandboxGit({\n sandbox: input.sandbox,\n args: [\"show\", `${head}:${path}`],\n });\n if (Buffer.byteLength(content, \"utf8\") > maxFileBytes) {\n throw new Error(`${path} exceeds the ${maxFileBytes} byte publication limit`);\n }\n tree.push({ path, mode: mode as \"100644\" | \"100755\", type: \"blob\", content });\n }\n for (const path of deletions) {\n tree.push({ path, mode: \"100644\", type: \"blob\", sha: null });\n }\n return { base, commitMessage, tree, changedFiles };\n}\n\nfunction requireSafePath(path: string | undefined): string {\n if (path === undefined || path === \"\" || !safePathPattern.test(path) || path.includes(\"..\")) {\n throw new Error(`refusing to publish unsafe path: ${path ?? \"(missing)\"}`);\n }\n return path;\n}\n"],"mappings":";;;;;;AAqJA,IAAa,4BAAb,cAA+C,MAAM;CAExC;CADX,YACE,QACA,SACA;EACA,MAAM,8BAA8B,OAAO,KAAK,SAAS;EAHhD,KAAA,SAAA;EAIT,KAAK,OAAO;CACd;AACF;;AAgEA,IAAa,8BAAb,cAAiD,MAAM;CAE1C;CACA;CAFX,YACE,gBACA,gBACA;EACA,MAAM,oBAAoB,eAAe,kBAAkB,gBAAgB;EAHlE,KAAA,iBAAA;EACA,KAAA,iBAAA;EAGT,KAAK,OAAO;CACd;AACF;AAEA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AACvB,MAAM,+BAAe,IAAI,IAAI,CAAC,UAAU,QAAQ,CAAC;AACjD,MAAM,eAAe;AAErB,MAAM,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAClC,MAAM,oBAAoB,EAAE,OAAO;CACjC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAClC,UAAU,EAAE,IAAI;CAChB,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACzB,OAAO,EAAE,OAAO;CAChB,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,OAAO,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAAC;CAChC,OAAO,EAAE,QAAQ;CACjB,MAAM,EAAE,OAAO;EACb,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;EACrB,KAAK;EACL,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;CAC5D,CAAC;AACH,CAAC;;AAGD,SAAgB,8BACd,SACyB;CACzB,MAA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AAI,MAAM,2CAA2C;CAE7D,IAAI,eAAe,iBACjB,MAAM,IAAI,MAAM,2BAA2B,aAAa,KAAK,gBAAgB,EAAE;CAGjF,MAAM,OAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,SAAS;EAC1B,MAAM,QACJ,MAAM,cAAc;GAClB,SAAS,MAAM;GACf,MAAM;IAAC;IAAW;IAAM;IAAM;GAAI;EACpC,CAAC,EAAA,CAEA,KAAK,CAAC,CACN,MAAM,GAAG,CAAC,CAAC;EACd,IAAI,SAAS,KAAA,KAAa,CAAC,aAAa,IAAI,IAAI,GAC9C,MAAM,IAAI,MAAM,yBAAyB,QAAQ,SAAS,OAAO,MAAM;EAEzE,MAAM,UAAU,MAAM,cAAc;GAClC,SAAS,MAAM;GACf,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,MAAM;EAClC,CAAC;EACD,IAAI,OAAO,WAAW,SAAS,MAAM,IAAI,cACvC,MAAM,IAAI,MAAM,GAAG,KAAK,eAAe,aAAa,wBAAwB;EAE9E,KAAK,KAAK;GAAE;GAAY;GAA6B,MAAM;GAAQ;EAAQ,CAAC;CAC9E;CACA,KAAK,MAAM,QAAQ,WACjB,KAAK,KAAK;EAAE;EAAM,MAAM;EAAU,MAAM;EAAQ,KAAK;CAAK,CAAC;CAE7D,OAAO;EAAE;EAAM;EAAe;EAAM;CAAa;AACnD;AAEA,SAAS,gBAAgB,MAAkC;CACzD,IAAI,SAAS,KAAA,KAAa,SAAS,MAAM,CAAC,gBAAgB,KAAK,IAAI,KAAK,KAAK,SAAS,IAAI,GACxF,MAAM,IAAI,MAAM,oCAAoC,QAAQ,aAAa;CAE3E,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/factory",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "Schema, state machines, and kernel primitives for Agent Factory.",
|
|
5
5
|
"homepage": "https://github.com/vercel-labs/agent-factory/tree/main/packages/factory",
|
|
6
6
|
"bugs": "https://github.com/vercel-labs/agent-factory/issues",
|