@cat-factory/server 0.311.3 → 0.314.0

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.
Files changed (31) hide show
  1. package/dist/agents/ContainerRepoBootstrapper.d.ts +120 -9
  2. package/dist/agents/ContainerRepoBootstrapper.d.ts.map +1 -1
  3. package/dist/agents/ContainerRepoBootstrapper.js +448 -177
  4. package/dist/agents/ContainerRepoBootstrapper.js.map +1 -1
  5. package/dist/agents/agentContextRecord.d.ts +25 -0
  6. package/dist/agents/agentContextRecord.d.ts.map +1 -1
  7. package/dist/agents/agentContextRecord.js +57 -0
  8. package/dist/agents/agentContextRecord.js.map +1 -1
  9. package/dist/app.d.ts.map +1 -1
  10. package/dist/app.js +2 -0
  11. package/dist/app.js.map +1 -1
  12. package/dist/modules/bugFishing/BugFishingController.d.ts +14 -0
  13. package/dist/modules/bugFishing/BugFishingController.d.ts.map +1 -0
  14. package/dist/modules/bugFishing/BugFishingController.js +56 -0
  15. package/dist/modules/bugFishing/BugFishingController.js.map +1 -0
  16. package/dist/modules/execution/ExecutionController.js +5 -0
  17. package/dist/modules/execution/ExecutionController.js.map +1 -1
  18. package/dist/modules/github/GitHubController.js +7 -0
  19. package/dist/modules/github/GitHubController.js.map +1 -1
  20. package/dist/modules/publicApi/PublicProvisioningController.d.ts.map +1 -1
  21. package/dist/modules/publicApi/PublicProvisioningController.js +1 -0
  22. package/dist/modules/publicApi/PublicProvisioningController.js.map +1 -1
  23. package/dist/modules/publicApi/openapiDocument.generated.d.ts +1 -1
  24. package/dist/modules/publicApi/openapiDocument.generated.d.ts.map +1 -1
  25. package/dist/modules/publicApi/openapiDocument.generated.js +1 -1
  26. package/dist/modules/publicApi/openapiDocument.generated.js.map +1 -1
  27. package/dist/persistence/mappers.d.ts +2 -0
  28. package/dist/persistence/mappers.d.ts.map +1 -1
  29. package/dist/persistence/mappers.js +5 -0
  30. package/dist/persistence/mappers.js.map +1 -1
  31. package/package.json +8 -8
@@ -1,9 +1,10 @@
1
- import type { BootstrapJobHandle, BootstrapJobRepository, BootstrapJobUpdate, BootstrapRepoOutcome, BootstrapRepoRequest, GitHubClient, MonorepoTargetRepo, GitHubInstallationRepository, GitHubRepo, GroupCacheHandle, ModelRef, RepoBootstrapper, RepoProjectionRepository } from '@cat-factory/kernel';
1
+ import type { AgentContextRecorder, BootstrapJobHandle, BootstrapJobRepository, BootstrapJobUpdate, BootstrapRepoOutcome, BootstrapRepoRequest, GitHubClient, MonorepoTargetRepo, GitHubInstallationRepository, GitHubRepo, GroupCacheHandle, ModelRef, RepoBootstrapper, RepoProjectionRepository } from '@cat-factory/kernel';
2
2
  import type { ContainerSessionService } from '../containers/ContainerSessionService.js';
3
+ import { type ToolTrajectoryDeps } from './toolTrajectory.js';
3
4
  import type { JobPackageRegistrySpec } from './ContainerAgentExecutor.js';
4
5
  import type { MintInstallationToken } from './repoTargeting.js';
5
6
  import { type ResolveRunnerTransport } from './RunnerJobClient.js';
6
- export interface ContainerRepoBootstrapperDependencies {
7
+ export interface ContainerRepoBootstrapperDependencies extends ToolTrajectoryDeps {
7
8
  /**
8
9
  * Resolve which runner backend (Cloudflare container or self-hosted pool) a
9
10
  * bootstrap job dispatches to — the same seam the implementation executor rides.
@@ -39,6 +40,12 @@ export interface ContainerRepoBootstrapperDependencies {
39
40
  githubApiBase?: string;
40
41
  /** Web base for building the created repo's URL (defaults to github.com). */
41
42
  webBaseUrl?: string;
43
+ /**
44
+ * Records the complete context each bootstrap dispatch handed its agent (best-effort, gated
45
+ * inside the recorder). Absent ⇒ a bootstrap's "Provided context" tab is empty, which is the
46
+ * shape every other agent run's would have if its executor skipped this call.
47
+ */
48
+ agentContextObservability?: AgentContextRecorder;
42
49
  /**
43
50
  * Resolve the workspace's private package-registry entries for the bootstrap
44
51
  * container (the scaffolder installs dependencies too). Same seam as
@@ -84,29 +91,120 @@ export declare class ContainerRepoBootstrapper implements RepoBootstrapper {
84
91
  * Pre-flight the target repo and dispatch the bootstrap container as a
85
92
  * background job (returns once accepted, like `/run`). Throws on a pre-flight
86
93
  * failure so the run fails fast before a board frame is created.
94
+ *
95
+ * THREE dispatch shapes, chosen by the target and the run's delivery. A new repository
96
+ * delivered by `direct_push` is the original one (adapt a clone, reinitialise, force-push);
97
+ * everything else is the ordinary coding shape (clone the writable target, template beside it
98
+ * read-only, work branch, pull request), because the target already holds a history nobody may
99
+ * reset: the monorepo's, or the initial commit a pull request has to be opened against.
87
100
  */
88
101
  startBootstrap(request: BootstrapRepoRequest): Promise<BootstrapJobHandle>;
102
+ /**
103
+ * Pre-flight the pre-created target repository of a NEW-REPO run: it exists, the App can
104
+ * write to it, and it holds no real content.
105
+ *
106
+ * The target repo is created up front: by the user via the host's new-repo page, or, for
107
+ * privileged-tier orgs (ADR 0005), programmatically via the create-repo endpoint behind the
108
+ * modal's "Create repository" button.
109
+ *
110
+ * The emptiness rule binds under both deliveries, because both WRITE a whole service into the
111
+ * repository: a force-push would clobber real content and a pull request would propose
112
+ * deleting it. What differs is the FLOOR: a pull request needs an initial commit to branch
113
+ * from, so that delivery also refuses a repository with none.
114
+ */
115
+ private preflightNewRepoTarget;
116
+ /**
117
+ * Dispatch a NEW-REPO run delivered as a pull request: the ordinary coding shape against the
118
+ * (already-initialised) target repository, with the reference template beside it as a
119
+ * READ-ONLY sibling checkout.
120
+ *
121
+ * Deliberately NOT the `bootstrap` spec, which is the whole reason this path exists
122
+ * separately: that spec reinitialises history and force-pushes, and a branch whose history
123
+ * shares no ancestor with the default branch is not something a pull request can be opened
124
+ * from. Here the target's own initial commit is the base, so the diff a reviewer reads is the
125
+ * service being added.
126
+ */
127
+ private startNewRepoPullRequest;
89
128
  /**
90
129
  * Dispatch a monorepo bootstrap's APPLY phase: an ordinary coding job on the monorepo, with
91
130
  * the reference template alongside it as a READ-ONLY sibling checkout.
92
131
  *
93
132
  * Deliberately the plain coding shape rather than a `bootstrap` spec, and that is the design:
94
- * the harness already knows how to clone a writable primary at a work branch, clone
95
- * `referenceRepos` beside it without ever branching or pushing them, and open one pull request
96
- * for the primary. A bespoke bootstrap mode here would be a second implementation of that with
97
- * one extra way to get the push wrong, against a repository that holds other people's code.
133
+ * the harness already knows how to clone a writable primary (at a work branch, or at the
134
+ * default branch it commits onto, per the run's delivery), clone `referenceRepos` beside it
135
+ * without ever branching or pushing them, and open one pull request for the primary when it
136
+ * was given one to open. A bespoke bootstrap mode here would be a second implementation of
137
+ * that with one extra way to get the push wrong, against a repository that holds other
138
+ * people's code.
98
139
  *
99
140
  * `repo.serviceDirectory` is what scopes the agent to the new subdirectory: the same field
100
141
  * every monorepo-service run rides, so the working-directory rule is stated in one place.
101
142
  *
102
143
  * Two pre-flights, both about the monorepo rather than about a new repo: the App must be able
103
144
  * to WRITE to it (a read-only grant reads fine and 403s on the push, after a board frame
104
- * exists), and the target directory must still be absent at dispatch time, because the orchestration
105
- * pre-flighted it before the survey, and a review can be settled days later.
145
+ * exists), and the target directory must still be absent at dispatch time, because the
146
+ * orchestration pre-flighted it before the survey and a review can be settled days later.
106
147
  */
107
148
  private startMonorepoBootstrap;
149
+ /**
150
+ * The dispatch both non-force-push shapes share: clone the writable target, fetch the
151
+ * reference template beside it read-only, and either open a work branch plus a pull request
152
+ * or commit onto the target's own default branch.
153
+ *
154
+ * ONE builder rather than one per target, because the delivery rule is the interesting part
155
+ * and a second copy of it is a second place for `newBranch` and `pr` to disagree: a body
156
+ * carrying a branch but no PR pushes work onto a branch nobody is told about.
157
+ */
158
+ private dispatchCodingShape;
159
+ /**
160
+ * Resolve the reference template a run reads from: its clone spec, plus the numeric id the
161
+ * run's installation token has to be scoped to.
162
+ *
163
+ * ONE resolution for both dispatch shapes, because both CLONE the template and both mint the
164
+ * token that clone runs on. Two copies is what left the force-push path granting only its push
165
+ * target while cloning the template with that same token, so a PRIVATE reference architecture
166
+ * 404s on clone under one delivery and works under the other, and what left it assuming the
167
+ * template's base branch was `main`.
168
+ *
169
+ * A template the installation cannot read resolves to no id and the conventional branch rather
170
+ * than refusing the run: the clone then fails inside the harness naming the repository, which
171
+ * is a better report than a pre-flight throw here, and the warning says which read failed.
172
+ */
173
+ private resolveReferenceTemplate;
174
+ /**
175
+ * The model-locked LLM-proxy session token a bootstrap container runs under.
176
+ *
177
+ * Keyed on the RUN, never on the drive: a monorepo run's apply phase is dispatched under its
178
+ * own container job id, so minting on that id files the apply's model calls under a key no
179
+ * run-scoped read asks for, and the run reports only what its survey spent.
180
+ */
181
+ private mintSessionToken;
182
+ /** The host's web base, trailing slashes stripped, for building clone URLs. */
183
+ private webBase;
108
184
  /** Poll a dispatched bootstrap job, mapping the runner job view into an update. */
109
185
  pollBootstrap(handle: BootstrapJobHandle): Promise<BootstrapJobUpdate>;
186
+ /**
187
+ * The dispatched container job as an {@link AgentJobHandle}, the shape the shared trajectory
188
+ * drain speaks. `runId` is the bootstrap RUN and `jobId` the container job it dispatched,
189
+ * which is the same split every execution step's handle carries.
190
+ */
191
+ private jobHandle;
192
+ /**
193
+ * The resolved model as every OTHER producer writes it: `provider:model`, which is the format
194
+ * `AgentJobHandle.model` and `agentContextSnapshotSchema.model` both document. A bare model id
195
+ * renders beside prefixed ones on the same panel and gives nothing to a reader that splits the
196
+ * field to recover the provider.
197
+ */
198
+ private resolvedModel;
199
+ /**
200
+ * File what this dispatch handed the agent, so a bootstrap's Provided-context tab answers the
201
+ * same question every other agent run's does.
202
+ *
203
+ * AWAITED for the reason `recordAgentContextSnapshot` states: it runs after the container has
204
+ * already been accepted, so it delays nothing but the handle's return, and an un-awaited insert
205
+ * is dropped outright on the Worker, where this runs inside a Workflow step.
206
+ */
207
+ private recordDispatchContext;
110
208
  /**
111
209
  * Best-effort: reclaim the per-run container for a job. Releases through the same
112
210
  * transport the run dispatched to (keyed by job id) — for the Cloudflare backend
@@ -125,7 +223,20 @@ export declare class ContainerRepoBootstrapper implements RepoBootstrapper {
125
223
  installationId: number;
126
224
  githubId: number;
127
225
  }>;
128
- /** Construct the success outcome from the installation + the recorded job's repo name. */
226
+ /**
227
+ * Construct the success outcome from the installation + the recorded job's repo name.
228
+ *
229
+ * `resultDefaultBranch` is what the HARNESS reported, and only the `bootstrap` spec reports one
230
+ * (it echoes back the branch it force-pushed, which it also created). The plain coding shape a
231
+ * `pull_request` run takes reports none, so the branch is READ off the target repository rather
232
+ * than defaulted to `main`: this field states which branch the work lands on, and a repository
233
+ * whose default is `master`, `trunk` or an org-wide choice would otherwise be recorded as a ref
234
+ * that does not exist. One read, on the terminal poll only. A failed read keeps the
235
+ * conventional fallback and says so in a warning, rather than failing a delivered run over the
236
+ * one field nothing reads back.
237
+ */
129
238
  private buildOutcome;
239
+ /** The run's stored row, which a poll addresses only by id. */
240
+ private requireRecord;
130
241
  }
131
242
  //# sourceMappingURL=ContainerRepoBootstrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerRepoBootstrapper.d.ts","sourceRoot":"","sources":["../../src/agents/ContainerRepoBootstrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EAEZ,kBAAkB,EAClB,4BAA4B,EAC5B,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,gBAAgB,EAEhB,wBAAwB,EACzB,MAAM,qBAAqB,CAAA;AAG5B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAA;AACvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAGnF,MAAM,WAAW,qCAAqC;IACpD;;;OAGG;IACH,gBAAgB,EAAE,sBAAsB,CAAA;IACxC,wEAAwE;IACxE,sBAAsB,EAAE,4BAA4B,CAAA;IACpD,sFAAsF;IACtF,sBAAsB,EAAE,sBAAsB,CAAA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