@cat-factory/server 0.64.3 → 0.65.2
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/dist/agents/prompts.d.ts +8 -0
- package/dist/agents/prompts.d.ts.map +1 -1
- package/dist/agents/prompts.js +1 -1
- package/dist/agents/prompts.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -0
- package/dist/app.js.map +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +2 -2
- package/dist/auth/middleware.js.map +1 -1
- package/dist/auth/signing.d.ts +1 -0
- package/dist/auth/signing.d.ts.map +1 -1
- package/dist/auth/signing.js +14 -0
- package/dist/auth/signing.js.map +1 -1
- package/dist/auth/wsTicket.d.ts.map +1 -1
- package/dist/auth/wsTicket.js +3 -3
- package/dist/auth/wsTicket.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/persistence/PersistenceController.d.ts.map +1 -1
- package/dist/modules/persistence/PersistenceController.js +22 -8
- package/dist/modules/persistence/PersistenceController.js.map +1 -1
- package/dist/modules/preview/PreviewController.d.ts +9 -0
- package/dist/modules/preview/PreviewController.d.ts.map +1 -0
- package/dist/modules/preview/PreviewController.js +53 -0
- package/dist/modules/preview/PreviewController.js.map +1 -0
- package/dist/modules/workspaces/WorkspaceController.d.ts.map +1 -1
- package/dist/modules/workspaces/WorkspaceController.js +51 -55
- package/dist/modules/workspaces/WorkspaceController.js.map +1 -1
- package/dist/persistence/mappers.d.ts +4 -0
- package/dist/persistence/mappers.d.ts.map +1 -1
- package/dist/persistence/mappers.js +4 -0
- package/dist/persistence/mappers.js.map +1 -1
- package/dist/persistence/rpc.d.ts +14 -0
- package/dist/persistence/rpc.d.ts.map +1 -1
- package/dist/persistence/rpc.js +24 -0
- package/dist/persistence/rpc.js.map +1 -1
- package/dist/preview/previewJobBuilder.d.ts +36 -0
- package/dist/preview/previewJobBuilder.d.ts.map +1 -0
- package/dist/preview/previewJobBuilder.js +89 -0
- package/dist/preview/previewJobBuilder.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ConflictError, NotFoundError, PREVIEW_HARNESS_JOB_ID } from '@cat-factory/kernel';
|
|
2
|
+
import { boundServiceFrameIds, indexLiveServiceEnvUrls, resolveFrontendBindings, } from '@cat-factory/orchestration';
|
|
3
|
+
import { buildFrontendInfraSpec } from '../agents/prompts.js';
|
|
4
|
+
// Builds the harness `mode: 'preview'` job for a `frontend` frame — the server-layer half of
|
|
5
|
+
// slice 5c. It mirrors the slice of `ContainerAgentExecutor.buildJobBody` a preview needs
|
|
6
|
+
// (resolve the frame's repo + a GitHub token + a proxy session token, then the frontend infra
|
|
7
|
+
// spec) but runs NO agent, so it carries none of the model-routing / prompt machinery. The
|
|
8
|
+
// facade wires this next to where it builds the ContainerAgentExecutor (same seams); the
|
|
9
|
+
// runtime-neutral PreviewService drives the resulting plan through a PreviewTransport.
|
|
10
|
+
/** The git origin (clone URL + provider) for a preview's repo; defaults to github.com. */
|
|
11
|
+
const githubRepoOrigin = (repo) => ({
|
|
12
|
+
cloneUrl: `https://github.com/${repo.owner}/${repo.name}.git`,
|
|
13
|
+
provider: 'github',
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the branch a preview is built from (the `frontendConfig.branch`):
|
|
17
|
+
* - `default` / absent → the repo's default branch (the baseline).
|
|
18
|
+
* - `{ kind: 'task', fromTaskBlockId }` → that task's PR branch when it has one, else the
|
|
19
|
+
* repo default (the branch may not exist on the remote yet — never point the clone at a ref
|
|
20
|
+
* that isn't there).
|
|
21
|
+
*/
|
|
22
|
+
async function resolveBranch(branch, repo, workspaceId, blockRepository) {
|
|
23
|
+
if (!branch || branch.kind === 'default')
|
|
24
|
+
return repo.baseBranch;
|
|
25
|
+
const task = await blockRepository.get(workspaceId, branch.fromTaskBlockId);
|
|
26
|
+
return task?.pullRequest?.branch ?? repo.baseBranch;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the {@link BuildPreviewJob} seam for a facade. Throws a `NotFoundError` for an unknown
|
|
30
|
+
* frame, a `ConflictError` for a non-`frontend` frame / one without a `frontendConfig`, or a
|
|
31
|
+
* `ConflictError` when no repo is connected — all mapped to a clean 4xx by the controller.
|
|
32
|
+
*/
|
|
33
|
+
export function makePreviewJobBuilder(deps) {
|
|
34
|
+
return async ({ workspaceId, frameId }) => {
|
|
35
|
+
const frame = await deps.blockRepository.get(workspaceId, frameId);
|
|
36
|
+
if (!frame)
|
|
37
|
+
throw new NotFoundError('frame', frameId);
|
|
38
|
+
if (frame.level !== 'frame' || frame.type !== 'frontend' || !frame.frontendConfig) {
|
|
39
|
+
throw new ConflictError('A browsable preview is only available for a frontend frame with a frontend config.');
|
|
40
|
+
}
|
|
41
|
+
const config = frame.frontendConfig;
|
|
42
|
+
// Resolve each backend binding to a live service env URL (else WireMock) — the SAME
|
|
43
|
+
// frame-keyed, single-read resolution the UI-test flow uses (no per-binding point read).
|
|
44
|
+
const serviceFrameIds = boundServiceFrameIds(config);
|
|
45
|
+
const handles = deps.environmentRegistryRepository && serviceFrameIds.size > 0
|
|
46
|
+
? await deps.environmentRegistryRepository.listByWorkspace(workspaceId)
|
|
47
|
+
: [];
|
|
48
|
+
const bindings = resolveFrontendBindings(config, indexLiveServiceEnvUrls(handles, serviceFrameIds));
|
|
49
|
+
const infra = buildFrontendInfraSpec({ config, bindings });
|
|
50
|
+
const servePort = infra.servePort;
|
|
51
|
+
const repo = await deps.resolveRepoTarget(workspaceId, frameId);
|
|
52
|
+
if (!repo) {
|
|
53
|
+
throw new ConflictError('No connected GitHub repository was found for this frontend frame.');
|
|
54
|
+
}
|
|
55
|
+
const ghToken = await deps.mintInstallationToken(repo.installationId);
|
|
56
|
+
const origin = (deps.resolveRepoOrigin ?? githubRepoOrigin)(repo);
|
|
57
|
+
const branch = await resolveBranch(config.branch, repo, workspaceId, deps.blockRepository);
|
|
58
|
+
// A preview runs no agent, so the session is model-agnostic and never used for an LLM
|
|
59
|
+
// call — it exists only to satisfy the harness's auth parser (proxyBaseUrl + sessionToken).
|
|
60
|
+
const sessionToken = await deps.sessionService.mint({
|
|
61
|
+
workspaceId,
|
|
62
|
+
executionId: `preview-${frameId}`,
|
|
63
|
+
agentKind: 'preview',
|
|
64
|
+
provider: 'none',
|
|
65
|
+
model: 'none',
|
|
66
|
+
});
|
|
67
|
+
const spec = {
|
|
68
|
+
jobId: PREVIEW_HARNESS_JOB_ID,
|
|
69
|
+
mode: 'preview',
|
|
70
|
+
harness: 'pi',
|
|
71
|
+
proxyBaseUrl: deps.proxyBaseUrl,
|
|
72
|
+
sessionToken,
|
|
73
|
+
ghToken,
|
|
74
|
+
repo: {
|
|
75
|
+
owner: repo.owner,
|
|
76
|
+
name: repo.name,
|
|
77
|
+
baseBranch: repo.baseBranch,
|
|
78
|
+
cloneUrl: origin.cloneUrl,
|
|
79
|
+
provider: origin.provider,
|
|
80
|
+
...(repo.serviceDirectory ? { serviceDirectory: repo.serviceDirectory } : {}),
|
|
81
|
+
},
|
|
82
|
+
branch,
|
|
83
|
+
infra,
|
|
84
|
+
...(deps.githubApiBase ? { githubApiBase: deps.githubApiBase } : {}),
|
|
85
|
+
};
|
|
86
|
+
return { jobId: PREVIEW_HARNESS_JOB_ID, spec, servePort };
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=previewJobBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previewJobBuilder.js","sourceRoot":"","sources":["../../src/preview/previewJobBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAG1F,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,4BAA4B,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AM;SACd,CAAC,CAAA;QAEF,MAAM,IAAI,GAA4B;YACpC,KAAK,EAAE,sBAAsB;YAC7B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY;YACZ,OAAO;YACP,IAAI,EAAE;gBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9E;YACD,MAAM;YACN,KAAK;YACL,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrE,CAAA;QACD,OAAO,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC3D,CAAC,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.2",
|
|
4
4
|
"description": "Runtime-neutral HTTP layer for the Agent Architecture Board: the Hono controllers, middleware (auth/authz/CORS/error), request helpers and the gateway seams shared by every deployment facade (Cloudflare Worker, Node service).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"hono": "^4.12.27",
|
|
31
31
|
"pino": "^10.3.1",
|
|
32
32
|
"valibot": "^1.4.2",
|
|
33
|
-
"@cat-factory/
|
|
34
|
-
"@cat-factory/integrations": "0.
|
|
35
|
-
"@cat-factory/
|
|
36
|
-
"@cat-factory/
|
|
37
|
-
"@cat-factory/orchestration": "0.
|
|
38
|
-
"@cat-factory/
|
|
39
|
-
"@cat-factory/
|
|
33
|
+
"@cat-factory/agents": "0.26.4",
|
|
34
|
+
"@cat-factory/integrations": "0.53.2",
|
|
35
|
+
"@cat-factory/contracts": "0.80.1",
|
|
36
|
+
"@cat-factory/kernel": "0.69.2",
|
|
37
|
+
"@cat-factory/orchestration": "0.57.1",
|
|
38
|
+
"@cat-factory/prompt-fragments": "0.9.37",
|
|
39
|
+
"@cat-factory/spend": "0.10.67"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"typescript": "7.0.1-rc",
|