@vercel/factory 0.0.21 → 0.0.23

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,21 @@
1
1
  # @vercel/factory
2
2
 
3
+ ## 0.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - c7bf541: add `readGitHubRepositoryFile` and `listGitHubRepositoryDirectory` to read repository files and directories at a ref, returning null when the path does not exist.
8
+
9
+ ## 0.0.22
10
+
11
+ ### Patch Changes
12
+
13
+ - 2b90bb3: Validate sandbox harness integration against the harness releases matching AI SDK 7.0.105 to avoid incompatible provider types in fresh installs.
14
+ - f8d68e2: Add `factory create --empty` for deploying an inert Factory host, including support for generating it inside an existing Git worktree.
15
+ - 59e4b10: Add exact-version repository event scripts with durable Task execution, scoped classification,
16
+ and idempotent GitHub issue comment and label actions.
17
+ - f69894b: Preserve delegated work during session refreshes and scaffold streaming worker command output.
18
+
3
19
  ## 0.0.21
4
20
 
5
21
  ### Patch Changes
@@ -8,7 +8,7 @@ interface BuildFactoryOptions<TConfig extends EveNextConfig = EveNextConfig> {
8
8
  nextConfig: EveNextConfigInput<TConfig>;
9
9
  root?: string;
10
10
  }
11
- /** Create an Eve Next.js configuration wrapper for the agents beneath a Factory project root. */
11
+ /** Create a Next.js configuration that mounts the Eve agents beneath a Factory project root. */
12
12
  declare function buildFactory<TConfig extends EveNextConfig>({ factoryConfig, nextConfig, root }: BuildFactoryOptions<TConfig>): EveNextConfigFunction<TConfig>;
13
13
  //#endregion
14
14
  export { BuildFactoryOptions, buildFactory };
@@ -2,11 +2,12 @@ import { defineFactory } from "./schema/factory-config.mjs";
2
2
  import { readdirSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  //#region src/build-factory.ts
5
- /** Create an Eve Next.js configuration wrapper for the agents beneath a Factory project root. */
5
+ /** Create a Next.js configuration that mounts the Eve agents beneath a Factory project root. */
6
6
  function buildFactory({ factoryConfig, nextConfig, root = process.cwd() }) {
7
7
  defineFactory(factoryConfig);
8
8
  const agentDefinitions = Object.fromEntries(readdirSync(path.join(root, "agents"), { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => [entry.name, path.join(root, "agents", entry.name)]));
9
9
  return async (phase, context) => {
10
+ if (Object.keys(agentDefinitions).length === 0) return typeof nextConfig === "function" ? nextConfig(phase, context) : nextConfig;
10
11
  const { withEve } = await import("eve/next");
11
12
  return withEve(nextConfig, { agents: agentDefinitions })(phase, context);
12
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-factory.mjs","names":[],"sources":["../src/build-factory.ts"],"sourcesContent":["import { readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n type EveNextConfig,\n type EveNextConfigFunction,\n type EveNextConfigInput,\n type WithEveAgentsConfig,\n} from \"eve/next\";\nimport { defineFactory, type FactoryConfigInput } from \"./schema/factory-config\";\n\n/** Inputs for validating a Factory configuration and discovering its Eve agents at build time. */\nexport interface BuildFactoryOptions<TConfig extends EveNextConfig = EveNextConfig> {\n factoryConfig: FactoryConfigInput;\n nextConfig: EveNextConfigInput<TConfig>;\n root?: string;\n}\n\n/** Create an Eve Next.js configuration wrapper for the agents beneath a Factory project root. */\nexport function buildFactory<TConfig extends EveNextConfig>({\n factoryConfig,\n nextConfig,\n root = process.cwd(),\n}: BuildFactoryOptions<TConfig>): EveNextConfigFunction<TConfig> {\n defineFactory(factoryConfig);\n const agentDefinitions: WithEveAgentsConfig = Object.fromEntries(\n readdirSync(path.join(root, \"agents\"), { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => [entry.name, path.join(root, \"agents\", entry.name)]),\n );\n return async (phase, context) => {\n const { withEve } = await import(\"eve/next\");\n return withEve(nextConfig, { agents: agentDefinitions })(phase, context);\n };\n}\n"],"mappings":";;;;;AAkBA,SAAgB,aAA4C,EAC1D,eACA,YACA,OAAO,QAAQ,IAAI,KAC4C;CAC/D,cAAc,aAAa;CAC3B,MAAM,mBAAwC,OAAO,YACnD,YAAY,KAAK,KAAK,MAAM,QAAQ,GAAG,EAAE,eAAe,KAAK,CAAC,CAAC,CAC5D,QAAQ,UAAU,MAAM,YAAY,CAAC,CAAC,CACtC,KAAK,UAAU,CAAC,MAAM,MAAM,KAAK,KAAK,MAAM,UAAU,MAAM,IAAI,CAAC,CAAC,CACvE;CACA,OAAO,OAAO,OAAO,YAAY;EAC/B,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ,YAAY,EAAE,QAAQ,iBAAiB,CAAC,CAAC,CAAC,OAAO,OAAO;CACzE;AACF"}
1
+ {"version":3,"file":"build-factory.mjs","names":[],"sources":["../src/build-factory.ts"],"sourcesContent":["import { readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n type EveNextConfig,\n type EveNextConfigFunction,\n type EveNextConfigInput,\n type WithEveAgentsConfig,\n} from \"eve/next\";\nimport { defineFactory, type FactoryConfigInput } from \"./schema/factory-config\";\n\n/** Inputs for validating a Factory configuration and discovering its Eve agents at build time. */\nexport interface BuildFactoryOptions<TConfig extends EveNextConfig = EveNextConfig> {\n factoryConfig: FactoryConfigInput;\n nextConfig: EveNextConfigInput<TConfig>;\n root?: string;\n}\n\n/** Create a Next.js configuration that mounts the Eve agents beneath a Factory project root. */\nexport function buildFactory<TConfig extends EveNextConfig>({\n factoryConfig,\n nextConfig,\n root = process.cwd(),\n}: BuildFactoryOptions<TConfig>): EveNextConfigFunction<TConfig> {\n defineFactory(factoryConfig);\n const agentDefinitions: WithEveAgentsConfig = Object.fromEntries(\n readdirSync(path.join(root, \"agents\"), { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => [entry.name, path.join(root, \"agents\", entry.name)]),\n );\n return async (phase, context) => {\n if (Object.keys(agentDefinitions).length === 0) {\n return typeof nextConfig === \"function\" ? nextConfig(phase, context) : nextConfig;\n }\n const { withEve } = await import(\"eve/next\");\n return withEve(nextConfig, { agents: agentDefinitions })(phase, context);\n };\n}\n"],"mappings":";;;;;AAkBA,SAAgB,aAA4C,EAC1D,eACA,YACA,OAAO,QAAQ,IAAI,KAC4C;CAC/D,cAAc,aAAa;CAC3B,MAAM,mBAAwC,OAAO,YACnD,YAAY,KAAK,KAAK,MAAM,QAAQ,GAAG,EAAE,eAAe,KAAK,CAAC,CAAC,CAC5D,QAAQ,UAAU,MAAM,YAAY,CAAC,CAAC,CACtC,KAAK,UAAU,CAAC,MAAM,MAAM,KAAK,KAAK,MAAM,UAAU,MAAM,IAAI,CAAC,CAAC,CACvE;CACA,OAAO,OAAO,OAAO,YAAY;EAC/B,IAAI,OAAO,KAAK,gBAAgB,CAAC,CAAC,WAAW,GAC3C,OAAO,OAAO,eAAe,aAAa,WAAW,OAAO,OAAO,IAAI;EAEzE,MAAM,EAAE,YAAY,MAAM,OAAO;EACjC,OAAO,QAAQ,YAAY,EAAE,QAAQ,iBAAiB,CAAC,CAAC,CAAC,OAAO,OAAO;CACzE;AACF"}
package/dist/client.d.mts CHANGED
@@ -153,11 +153,11 @@ declare class FactoryClient {
153
153
  limit?: number;
154
154
  }): Promise<{
155
155
  items: {
156
+ deliveryId: string;
156
157
  id: `sig_${string}`;
157
158
  schemaVersion: 1;
158
159
  repositoryId: `repo_${string}`;
159
160
  source: SignalSource;
160
- deliveryId: string;
161
161
  replyTo: {
162
162
  channel: string;
163
163
  address: string;
@@ -166,6 +166,7 @@ declare class FactoryClient {
166
166
  outcome: "pending" | "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored";
167
167
  repository: string;
168
168
  taskIds: `task_${string}`[];
169
+ reason?: string | undefined;
169
170
  triage?: {
170
171
  attempt: number;
171
172
  state: "running" | "blocked" | "uncertain";
@@ -176,7 +177,6 @@ declare class FactoryClient {
176
177
  failure?: "cancelled" | "billing_verification_required" | "provider_failed" | "no_decision" | "launch_unconfirmed" | undefined;
177
178
  } | undefined;
178
179
  detail?: string | undefined;
179
- reason?: string | undefined;
180
180
  decidedAt?: string | undefined;
181
181
  tasksNextCursor?: string | null | undefined;
182
182
  }[];
@@ -184,11 +184,11 @@ declare class FactoryClient {
184
184
  }>;
185
185
  /** Retry only the observed stopped attempt; concurrent or stale retries conflict. */
186
186
  retryIntake(id: string, expectedAttempt: number): Promise<{
187
+ deliveryId: string;
187
188
  id: `sig_${string}`;
188
189
  schemaVersion: 1;
189
190
  repositoryId: `repo_${string}`;
190
191
  source: SignalSource;
191
- deliveryId: string;
192
192
  replyTo: {
193
193
  channel: string;
194
194
  address: string;
@@ -197,6 +197,7 @@ declare class FactoryClient {
197
197
  outcome: "pending" | "accepted" | "duplicate" | "unactionable" | "low_confidence" | "ignored";
198
198
  repository: string;
199
199
  taskIds: `task_${string}`[];
200
+ reason?: string | undefined;
200
201
  triage?: {
201
202
  attempt: number;
202
203
  state: "running" | "blocked" | "uncertain";
@@ -207,7 +208,6 @@ declare class FactoryClient {
207
208
  failure?: "cancelled" | "billing_verification_required" | "provider_failed" | "no_decision" | "launch_unconfirmed" | undefined;
208
209
  } | undefined;
209
210
  detail?: string | undefined;
210
- reason?: string | undefined;
211
211
  decidedAt?: string | undefined;
212
212
  tasksNextCursor?: string | null | undefined;
213
213
  }>;
@@ -60,6 +60,10 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
60
60
  session: Pick<SessionContext["session"], "id" | "auth">;
61
61
  }, requestedTaskId: TaskId): Promise<({
62
62
  id: `task_${string}`;
63
+ origin: {
64
+ signalId?: `sig_${string}` | undefined;
65
+ operator?: string | undefined;
66
+ };
63
67
  schemaVersion: 1;
64
68
  replyTo: {
65
69
  channel: string;
@@ -73,10 +77,6 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
73
77
  model?: string | undefined;
74
78
  area?: string | undefined;
75
79
  approval?: "required" | "granted" | "denied" | undefined;
76
- origin: {
77
- signalId?: `sig_${string}` | undefined;
78
- operator?: string | undefined;
79
- };
80
80
  work: {
81
81
  title: string;
82
82
  input: JsonValue;
@@ -136,6 +136,10 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
136
136
  parentTaskId?: `task_${string}`;
137
137
  }) | ({
138
138
  id: `task_${string}`;
139
+ origin: {
140
+ signalId?: `sig_${string}` | undefined;
141
+ operator?: string | undefined;
142
+ };
139
143
  schemaVersion: 1;
140
144
  replyTo: {
141
145
  channel: string;
@@ -149,10 +153,6 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
149
153
  model?: string | undefined;
150
154
  area?: string | undefined;
151
155
  approval?: "required" | "granted" | "denied" | undefined;
152
- origin: {
153
- signalId?: `sig_${string}` | undefined;
154
- operator?: string | undefined;
155
- };
156
156
  work: {
157
157
  title: string;
158
158
  input: JsonValue;
@@ -218,6 +218,10 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
218
218
  parentTaskId?: `task_${string}`;
219
219
  }) | ({
220
220
  id: `task_${string}`;
221
+ origin: {
222
+ signalId?: `sig_${string}` | undefined;
223
+ operator?: string | undefined;
224
+ };
221
225
  schemaVersion: 1;
222
226
  replyTo: {
223
227
  channel: string;
@@ -231,10 +235,6 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
231
235
  model?: string | undefined;
232
236
  area?: string | undefined;
233
237
  approval?: "required" | "granted" | "denied" | undefined;
234
- origin: {
235
- signalId?: `sig_${string}` | undefined;
236
- operator?: string | undefined;
237
- };
238
238
  work: {
239
239
  title: string;
240
240
  input: JsonValue;
@@ -300,6 +300,10 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
300
300
  parentTaskId: `task_${string}`;
301
301
  }) | ({
302
302
  id: `task_${string}`;
303
+ origin: {
304
+ signalId?: `sig_${string}` | undefined;
305
+ operator?: string | undefined;
306
+ };
303
307
  schemaVersion: 1;
304
308
  replyTo: {
305
309
  channel: string;
@@ -313,10 +317,6 @@ declare function requireTaskExecution(stores: Pick<FactoryStores, "tasks">, ctx:
313
317
  model?: string | undefined;
314
318
  area?: string | undefined;
315
319
  approval?: "required" | "granted" | "denied" | undefined;
316
- origin: {
317
- signalId?: `sig_${string}` | undefined;
318
- operator?: string | undefined;
319
- };
320
320
  work: {
321
321
  title: string;
322
322
  input: JsonValue;
package/dist/github.d.mts CHANGED
@@ -65,6 +65,10 @@ interface GitHubRepositoryRequest {
65
65
  interface GitHubPullRequestTarget extends GitHubRepositoryRequest {
66
66
  pullRequestNumber: number;
67
67
  }
68
+ /** Repository-scoped identity of one GitHub issue. */
69
+ interface GitHubIssueTarget extends GitHubRepositoryRequest {
70
+ issueNumber: number;
71
+ }
68
72
  /** Provider-owned number and URL that identify one GitHub pull request. */
69
73
  interface GitHubPullRequestReference {
70
74
  pullRequestNumber: number;
@@ -190,6 +194,12 @@ type ListPullRequestCommentsInput = GitHubPullRequestTarget;
190
194
  interface CreatePullRequestCommentInput extends ListPullRequestCommentsInput {
191
195
  body: string;
192
196
  }
197
+ /** Repository issue whose comments should be listed. */
198
+ type ListIssueCommentsInput = GitHubIssueTarget;
199
+ /** Repository issue and body for a new comment. */
200
+ interface CreateIssueCommentInput extends GitHubIssueTarget {
201
+ body: string;
202
+ }
193
203
  /** Existing issue-style comment and replacement body to persist. */
194
204
  interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {
195
205
  commentId: number;
@@ -199,6 +209,10 @@ interface UpdatePullRequestCommentInput extends GitHubRepositoryRequest {
199
209
  interface PullRequestLabelInput extends GitHubPullRequestTarget {
200
210
  label: string;
201
211
  }
212
+ /** Repository issue and label targeted by a metadata-only label operation. */
213
+ interface IssueLabelInput extends GitHubIssueTarget {
214
+ label: string;
215
+ }
202
216
  /** Repository label to create when absent, retaining any existing color and description. */
203
217
  interface EnsureGitHubLabelInput extends GitHubRepositoryRequest {
204
218
  name: string;
@@ -320,10 +334,14 @@ declare function updateCheckRun(input: UpdateCheckRunInput): Promise<GitHubCheck
320
334
  declare function listCheckRunsForRef(input: ListCheckRunsForRefInput): Promise<readonly GitHubCheckRun[]>;
321
335
  /** List every issue-style comment in a pull request conversation. */
322
336
  declare function listPullRequestComments(input: ListPullRequestCommentsInput): Promise<readonly GitHubIssueComment[]>;
337
+ /** List issue comments with a ten-page bound so reconciliation never scans without limit. */
338
+ declare function listIssueComments(input: ListIssueCommentsInput): Promise<readonly GitHubIssueComment[]>;
323
339
  /** Read a page of all PR discussion types without treating any author's text as authorization. */
324
340
  declare function listPullRequestDiscussion(input: ListPullRequestDiscussionInput): Promise<GitHubPullRequestDiscussionPage>;
325
341
  /** Add one issue-style comment to a pull request conversation. */
326
342
  declare function createPullRequestComment(input: CreatePullRequestCommentInput): Promise<GitHubIssueComment>;
343
+ /** Add one issue comment and return GitHub's persisted identity. */
344
+ declare function createIssueComment(input: CreateIssueCommentInput): Promise<GitHubIssueComment>;
327
345
  /** Edit one issue-style pull request comment. */
328
346
  declare function updatePullRequestComment(input: UpdatePullRequestCommentInput): Promise<GitHubIssueComment>;
329
347
  /** One issue comment as GitHub reports it, with the issue it belongs to. */
@@ -344,6 +362,39 @@ declare function readReviewComment(input: ReadReviewCommentInput): Promise<GitHu
344
362
  declare function answerReviewComment(input: AnswerReviewCommentInput): Promise<GitHubReviewComment>;
345
363
  /** Submit a summary and optional inline comments against a reviewed pull request commit. */
346
364
  declare function submitPullRequestReview(input: SubmitPullRequestReviewInput): Promise<SubmittedPullRequestReview>;
365
+ /** Input for reading one text file from a repository branch, tag, or commit. */
366
+ interface ReadGitHubRepositoryFileInput extends GitHubRepositoryRequest {
367
+ /** Repository-relative file path, such as `.factory/config.yml`. */
368
+ path: string;
369
+ /** Branch, tag, or commit to read. Defaults to the repository's default branch. */
370
+ ref?: string;
371
+ /** Largest accepted file size in bytes. Default: 65,536. */
372
+ maxBytes?: number;
373
+ }
374
+ /** One text file read from a repository, with the blob SHA GitHub reports for it. */
375
+ interface GitHubRepositoryFile {
376
+ sha: string;
377
+ text: string;
378
+ }
379
+ /** Read one text file from a repository ref, or return null when the path does not exist. */
380
+ declare function readGitHubRepositoryFile(input: ReadGitHubRepositoryFileInput): Promise<GitHubRepositoryFile | null>;
381
+ /** Input for listing the entries directly inside one repository directory. */
382
+ interface ListGitHubRepositoryDirectoryInput extends GitHubRepositoryRequest {
383
+ /** Repository-relative directory path, such as `.factory/flows`. */
384
+ path: string;
385
+ /** Branch, tag, or commit to read. Defaults to the repository's default branch. */
386
+ ref?: string;
387
+ }
388
+ /** One entry directly inside a repository directory. */
389
+ interface GitHubRepositoryDirectoryEntry {
390
+ name: string;
391
+ path: string;
392
+ type: "file" | "dir" | "symlink" | "submodule";
393
+ sha: string;
394
+ size: number;
395
+ }
396
+ /** List the entries directly inside one repository directory, or return null when it does not exist. */
397
+ declare function listGitHubRepositoryDirectory(input: ListGitHubRepositoryDirectoryInput): Promise<GitHubRepositoryDirectoryEntry[] | null>;
347
398
  /** Read the current head branch and commit of a pull request. */
348
399
  declare function readPullRequestHead(input: GitHubPullRequestTarget): Promise<GitHubPullRequestHead>;
349
400
  /** Read the provider-owned identity and lifecycle of one pull request. */
@@ -358,6 +409,8 @@ declare function listOpenPullRequests(input: ListOpenPullRequestsInput): Promise
358
409
  declare function ensureGitHubLabel(input: EnsureGitHubLabelInput): Promise<void>;
359
410
  /** Add one label to a pull request. */
360
411
  declare function addLabel(input: PullRequestLabelInput): Promise<readonly string[]>;
412
+ /** Add one existing repository label to an issue. */
413
+ declare function addIssueLabel(input: IssueLabelInput): Promise<readonly string[]>;
361
414
  /** Remove one label from a pull request. */
362
415
  declare function removeLabel(input: PullRequestLabelInput): Promise<readonly string[]>;
363
416
  /** Raw payload, shared secret, and provider signature used for webhook verification. */
@@ -450,5 +503,5 @@ declare function normalizeGitHubPullRequestClosed(options: WebhookEvent): GitHub
450
503
  /** Normalize a completed, unsuccessful GitHub Actions run into a CI failure signal. */
451
504
  declare function normalizeGitHubWorkflowRunFailure(options: WebhookEvent): GitHubCiFailureSignal | null;
452
505
  //#endregion
453
- export { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunFields, CheckRunOutput, CheckRunProgressStatus, type CheckoutGitHubRepositoryInput, type CommittedGitChange, CompletedCheckRunFields, ConfiguredEventRepositoryInput, ConflictedGitHubPullRequest, CreateCheckRunInput, type CreateGitHubBranchInput, type CreateGitHubCommitInput, type CreateGitHubPublicationPullRequestInput, type CreateGitHubTreeInput, CreatePullRequestCommentInput, CreatePullRequestInput, type CreatedGitHubPublicationPullRequest, CreatedGitHubPullRequest, EnsureGitHubLabelInput, FactoryMentionOptions, FactoryQuestionReply, FactoryReviewComment, type FetchGitHubBundleInput, type FetchGitHubRefsInput, type GitHubAppFactoryInput, type GitHubAppInstallationToken, type GitHubAppLike, type GitHubAppPermissions, GitHubCheckRun, GitHubCheckoutConflictError, GitHubCiFailureSignal, type GitHubCommit, GitHubDefaultBranchPush, type GitHubGitTransport, GitHubIssueComment, GitHubIssueCommentRecord, GitHubIssueSignal, GitHubPublicationApiError, type GitHubPublicationClient, type GitHubPublicationClientOptions, type GitHubPublicationLimits, type GitHubPublicationPullRequest, GitHubPullRequest, GitHubPullRequestClosed, GitHubPullRequestDiscussionComment, GitHubPullRequestDiscussionPage, GitHubPullRequestDiscussionReview, GitHubPullRequestHead, GitHubPullRequestReference, GitHubPullRequestSignal, GitHubPullRequestTarget, type GitHubRefMapping, GitHubRepositoryAuthorRequest, type GitHubRepositoryBundle, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, type GitHubTreeDeletion, type GitHubTreeEntry, type GitHubTreeUpsert, type GitTransferSandbox, IncompleteCheckRunFields, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, type ListGitHubPublicationPullRequestsInput, ListOpenPullRequestsInput, ListPullRequestCommentsInput, ListPullRequestDiscussionInput, type MarkGitHubPullRequestReadyInput, type MintGitHubAppInstallationTokenInput, NormalizeFactoryCommentInput, NormalizeFactoryReviewCommentInput, ObservedCheckRunStatus, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, type PushGitHubBundleInput, type PushGitHubHeadInput, type ReadCommittedGitChangeInput, type ReadGitHubBranchHeadInput, type ReadGitHubCommitInput, type ReadGitHubPullRequestInput, type ReadGitTransferFileInput, ReadReviewCommentInput, ReviewCommentAuthorPolicy, type RunSandboxGitInput, type SandboxGit, type SandboxGitCommandInput, type SandboxGitCommandResult, StalePullRequestHeadError, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, type UpdateGitHubBranchInput, UpdatePullRequestCommentInput, VerifyGitHubSignatureInput, type WithSandboxGitBundleInput, type WriteGitTransferFileInput, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubPublicationClient, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readCommittedGitChange, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
506
+ export { AnswerReviewCommentInput, CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunFields, CheckRunOutput, CheckRunProgressStatus, type CheckoutGitHubRepositoryInput, type CommittedGitChange, CompletedCheckRunFields, ConfiguredEventRepositoryInput, ConflictedGitHubPullRequest, CreateCheckRunInput, type CreateGitHubBranchInput, type CreateGitHubCommitInput, type CreateGitHubPublicationPullRequestInput, type CreateGitHubTreeInput, CreateIssueCommentInput, CreatePullRequestCommentInput, CreatePullRequestInput, type CreatedGitHubPublicationPullRequest, CreatedGitHubPullRequest, EnsureGitHubLabelInput, FactoryMentionOptions, FactoryQuestionReply, FactoryReviewComment, type FetchGitHubBundleInput, type FetchGitHubRefsInput, type GitHubAppFactoryInput, type GitHubAppInstallationToken, type GitHubAppLike, type GitHubAppPermissions, GitHubCheckRun, GitHubCheckoutConflictError, GitHubCiFailureSignal, type GitHubCommit, GitHubDefaultBranchPush, type GitHubGitTransport, GitHubIssueComment, GitHubIssueCommentRecord, GitHubIssueSignal, GitHubIssueTarget, GitHubPublicationApiError, type GitHubPublicationClient, type GitHubPublicationClientOptions, type GitHubPublicationLimits, type GitHubPublicationPullRequest, GitHubPullRequest, GitHubPullRequestClosed, GitHubPullRequestDiscussionComment, GitHubPullRequestDiscussionPage, GitHubPullRequestDiscussionReview, GitHubPullRequestHead, GitHubPullRequestReference, GitHubPullRequestSignal, GitHubPullRequestTarget, type GitHubRefMapping, GitHubRepositoryAuthorRequest, type GitHubRepositoryBundle, GitHubRepositoryDirectoryEntry, GitHubRepositoryFile, GitHubRepositoryRequest, GitHubReviewComment, GitHubReviewCommentAuthorError, type GitHubTreeDeletion, type GitHubTreeEntry, type GitHubTreeUpsert, type GitTransferSandbox, IncompleteCheckRunFields, IssueLabelInput, ListCheckRunsForRefInput, ListConflictedPullRequestsInput, type ListGitHubPublicationPullRequestsInput, ListGitHubRepositoryDirectoryInput, ListIssueCommentsInput, ListOpenPullRequestsInput, ListPullRequestCommentsInput, ListPullRequestDiscussionInput, type MarkGitHubPullRequestReadyInput, type MintGitHubAppInstallationTokenInput, NormalizeFactoryCommentInput, NormalizeFactoryReviewCommentInput, ObservedCheckRunStatus, PullRequestLabelInput, PullRequestReviewComment, PullRequestReviewEvent, type PushGitHubBundleInput, type PushGitHubHeadInput, type ReadCommittedGitChangeInput, type ReadGitHubBranchHeadInput, type ReadGitHubCommitInput, type ReadGitHubPullRequestInput, ReadGitHubRepositoryFileInput, type ReadGitTransferFileInput, ReadReviewCommentInput, ReviewCommentAuthorPolicy, type RunSandboxGitInput, type SandboxGit, type SandboxGitCommandInput, type SandboxGitCommandResult, StalePullRequestHeadError, SubmitPullRequestReviewInput, SubmittedPullRequestReview, UpdateCheckRunInput, type UpdateGitHubBranchInput, UpdatePullRequestCommentInput, VerifyGitHubSignatureInput, type WithSandboxGitBundleInput, type WriteGitTransferFileInput, addIssueLabel, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubPublicationClient, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readCommittedGitChange, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
454
507
  //# sourceMappingURL=github.d.mts.map
package/dist/github.mjs CHANGED
@@ -311,6 +311,16 @@ async function listPullRequestComments(input) {
311
311
  if (response.length < 100) return comments;
312
312
  }
313
313
  }
314
+ /** List issue comments with a ten-page bound so reconciliation never scans without limit. */
315
+ async function listIssueComments(input) {
316
+ const comments = [];
317
+ for (let page = 1; page <= 10; page += 1) {
318
+ const response = z.array(issueCommentSchema).max(100).parse(await gitHubRequest(input, `/issues/${positiveInteger(input.issueNumber, "issueNumber")}/comments?per_page=100&page=${page}`));
319
+ comments.push(...response.map(parseIssueComment));
320
+ if (response.length < 100) return comments;
321
+ }
322
+ throw new Error("Issue comment lookup is incomplete after ten pages");
323
+ }
314
324
  /** Read a page of all PR discussion types without treating any author's text as authorization. */
315
325
  async function listPullRequestDiscussion(input) {
316
326
  const page = z.number().int().positive().parse(input.page ?? 1);
@@ -363,6 +373,13 @@ async function createPullRequestComment(input) {
363
373
  body: JSON.stringify({ body: input.body })
364
374
  }));
365
375
  }
376
+ /** Add one issue comment and return GitHub's persisted identity. */
377
+ async function createIssueComment(input) {
378
+ return parseIssueComment(await gitHubRequest(input, `/issues/${positiveInteger(input.issueNumber, "issueNumber")}/comments`, {
379
+ method: "POST",
380
+ body: JSON.stringify({ body: input.body })
381
+ }));
382
+ }
366
383
  /** Edit one issue-style pull request comment. */
367
384
  async function updatePullRequestComment(input) {
368
385
  return parseIssueComment(await gitHubRequest(input, `/issues/comments/${positiveInteger(input.commentId, "commentId")}`, {
@@ -447,6 +464,57 @@ async function submitPullRequestReview(input) {
447
464
  state: review.state
448
465
  };
449
466
  }
467
+ const repositoryFileSchema = z.object({
468
+ type: z.literal("file"),
469
+ sha: z.string().min(1),
470
+ size: z.number().int().nonnegative(),
471
+ encoding: z.literal("base64"),
472
+ content: z.string()
473
+ });
474
+ /** Read one text file from a repository ref, or return null when the path does not exist. */
475
+ async function readGitHubRepositoryFile(input) {
476
+ const path = repositoryContentsPath(input.path, input.ref);
477
+ const maxBytes = positiveInteger(input.maxBytes ?? 65536, "maxBytes");
478
+ const body = await readRepositoryContents(input, path);
479
+ if (body === null) return null;
480
+ const file = repositoryFileSchema.parse(body);
481
+ if (file.size > maxBytes) throw new Error(`${input.path} is ${file.size} bytes, above the ${maxBytes}-byte limit`);
482
+ return {
483
+ sha: file.sha,
484
+ text: Buffer.from(file.content, "base64").toString("utf8")
485
+ };
486
+ }
487
+ const repositoryDirectorySchema = z.array(z.object({
488
+ name: z.string().min(1),
489
+ path: z.string().min(1),
490
+ type: z.enum([
491
+ "file",
492
+ "dir",
493
+ "symlink",
494
+ "submodule"
495
+ ]),
496
+ sha: z.string().min(1),
497
+ size: z.number().int().nonnegative()
498
+ }));
499
+ function repositoryContentsPath(path, ref) {
500
+ const segments = path.split("/");
501
+ if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) throw new Error("path must be a repository-relative file path");
502
+ const query = ref === void 0 ? "" : `?ref=${encodeURIComponent(ref)}`;
503
+ return `/contents/${segments.map(encodeURIComponent).join("/")}${query}`;
504
+ }
505
+ async function readRepositoryContents(input, path) {
506
+ try {
507
+ return await gitHubRequest(input, path);
508
+ } catch (error) {
509
+ if (error instanceof GitHubRequestError && error.status === 404) return null;
510
+ throw error;
511
+ }
512
+ }
513
+ /** List the entries directly inside one repository directory, or return null when it does not exist. */
514
+ async function listGitHubRepositoryDirectory(input) {
515
+ const body = await readRepositoryContents(input, repositoryContentsPath(input.path, input.ref));
516
+ return body === null ? null : repositoryDirectorySchema.parse(body);
517
+ }
450
518
  /** Read the current head branch and commit of a pull request. */
451
519
  async function readPullRequestHead(input) {
452
520
  const pull = pullRequestHeadSchema.parse(await gitHubRequest(input, `/pulls/${positiveInteger(input.pullRequestNumber, "pullRequestNumber")}`));
@@ -557,6 +625,13 @@ async function addLabel(input) {
557
625
  body: JSON.stringify({ labels: [input.label] })
558
626
  }));
559
627
  }
628
+ /** Add one existing repository label to an issue. */
629
+ async function addIssueLabel(input) {
630
+ return parseLabels(await gitHubRequest(input, `/issues/${positiveInteger(input.issueNumber, "issueNumber")}/labels`, {
631
+ method: "POST",
632
+ body: JSON.stringify({ labels: [input.label] })
633
+ }));
634
+ }
560
635
  /** Remove one label from a pull request. */
561
636
  async function removeLabel(input) {
562
637
  return parseLabels(await gitHubRequest(input, `/issues/${positiveInteger(input.pullRequestNumber, "pullRequestNumber")}/labels/${encodeURIComponent(input.label)}`, { method: "DELETE" }));
@@ -902,6 +977,6 @@ function normalizeGitHubWorkflowRunFailure(options) {
902
977
  };
903
978
  }
904
979
  //#endregion
905
- export { GitHubCheckoutConflictError, GitHubPublicationApiError, GitHubReviewCommentAuthorError, StalePullRequestHeadError, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubPublicationClient, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readCommittedGitChange, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
980
+ export { GitHubCheckoutConflictError, GitHubPublicationApiError, GitHubReviewCommentAuthorError, StalePullRequestHeadError, addIssueLabel, addLabel, answerReviewComment, checkoutGitHubRepository, closePullRequest, configuredEventRepositorySlug, createCheckRun, createGitHubPublicationClient, createIssueComment, createPullRequest, createPullRequestComment, ensureGitHubLabel, factorySessionBranch, factoryTaskBranch, hasGitHubRepositoryWriteAccess, isSafeGitRef, listCheckRunsForRef, listConflictedPullRequests, listGitHubRepositoryDirectory, listIssueComments, listOpenPullRequests, listPullRequestComments, listPullRequestDiscussion, mintGitHubAppInstallationToken, normalizeFactoryQuestionReply, normalizeFactoryReviewComment, normalizeGitHubDefaultBranchPush, normalizeGitHubIssueOpened, normalizeGitHubPullRequest, normalizeGitHubPullRequestClosed, normalizeGitHubWorkflowRunFailure, readCommittedGitChange, readGitHubRepositoryFile, readIssueComment, readPullRequest, readPullRequestHead, readReviewComment, removeLabel, runSandboxGit, stripFactoryQuestionMention, submitPullRequestReview, updateCheckRun, updatePullRequestComment, verifyGitHubSignature };
906
981
 
907
982
  //# sourceMappingURL=github.mjs.map