@cat-factory/local-server 0.6.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.
- package/LICENSE +21 -0
- package/dist/LocalDockerRunnerTransport.d.ts +95 -0
- package/dist/LocalDockerRunnerTransport.d.ts.map +1 -0
- package/dist/LocalDockerRunnerTransport.js +342 -0
- package/dist/LocalDockerRunnerTransport.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/config.js.map +1 -0
- package/dist/container.d.ts +4 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/container.js +84 -0
- package/dist/container.js.map +1 -0
- package/dist/github.d.ts +36 -0
- package/dist/github.d.ts.map +1 -0
- package/dist/github.js +174 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/installations.d.ts +31 -0
- package/dist/installations.d.ts.map +1 -0
- package/dist/installations.js +76 -0
- package/dist/installations.js.map +1 -0
- package/dist/link-repo.d.ts +2 -0
- package/dist/link-repo.d.ts.map +1 -0
- package/dist/link-repo.js +21 -0
- package/dist/link-repo.js.map +1 -0
- package/dist/linkRepo.d.ts +31 -0
- package/dist/linkRepo.d.ts.map +1 -0
- package/dist/linkRepo.js +113 -0
- package/dist/linkRepo.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +10 -0
- package/dist/main.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +50 -0
- package/dist/server.js.map +1 -0
- package/package.json +46 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { start } from '@cat-factory/node-server';
|
|
2
|
+
import { logger } from '@cat-factory/server';
|
|
3
|
+
import { applyLocalDefaults } from './config.js';
|
|
4
|
+
import { buildLocalContainer } from './container.js';
|
|
5
|
+
import { githubPatCreationUrl } from './github.js';
|
|
6
|
+
import { createLocalDockerTransportFromEnv } from './LocalDockerRunnerTransport.js';
|
|
7
|
+
// Boot the local-mode service. It reuses the Node facade's `start()` — Postgres +
|
|
8
|
+
// pg-boss + the execution worker + sweepers, served over @hono/node-server — passing
|
|
9
|
+
// the local composition root so agent jobs run in local Docker containers and GitHub
|
|
10
|
+
// is reached via a PAT. Requires DATABASE_URL (point it at the local Postgres); set
|
|
11
|
+
// LOCAL_HARNESS_IMAGE to run repo-operating agent jobs (without it the board still
|
|
12
|
+
// serves and only container kinds fail, loudly).
|
|
13
|
+
export async function startLocal(options = {}) {
|
|
14
|
+
const env = options.env ?? process.env;
|
|
15
|
+
// Best-effort: reap per-job containers a previous run orphaned (a crash or hard kill
|
|
16
|
+
// can leave exited `cat-factory.managed=local-docker` containers behind, since their
|
|
17
|
+
// `release()` never ran). Skipped when no image is configured (nothing to reap).
|
|
18
|
+
if (env.LOCAL_HARNESS_IMAGE?.trim()) {
|
|
19
|
+
try {
|
|
20
|
+
const reaped = await createLocalDockerTransportFromEnv(env).reapExited();
|
|
21
|
+
if (reaped > 0)
|
|
22
|
+
logger.info({ reaped }, 'reaped orphaned local job containers');
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
logger.warn({ err: err instanceof Error ? err.message : String(err) }, 'could not reap orphaned local job containers');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// The auth gate defaults OPEN in local mode and the listener binds to all interfaces
|
|
29
|
+
// (so on native Linux Docker the agent containers can reach the LLM proxy via the
|
|
30
|
+
// bridge gateway). That combination means anyone on your network can reach the API —
|
|
31
|
+
// surface it so it is a choice, not a surprise. Lock it down with AUTH_DEV_OPEN=false,
|
|
32
|
+
// or HOST=127.0.0.1 on Docker Desktop (where host.docker.internal still resolves).
|
|
33
|
+
const localized = applyLocalDefaults(env);
|
|
34
|
+
// GitHub is reached via a PAT in local mode (there is no GitHub-App connect flow). Without
|
|
35
|
+
// one the board still serves, but every repo-operating agent step — clone, push, open PR,
|
|
36
|
+
// the CI gate, the real merge — fails. Surface it at boot with a click-through URL that
|
|
37
|
+
// pre-selects the scopes, so it is a one-step fix rather than a runtime surprise.
|
|
38
|
+
if (!localized.GITHUB_PAT?.trim()) {
|
|
39
|
+
logger.warn(`local mode: GITHUB_PAT is not set — agent steps that clone, push, open PRs, gate on ` +
|
|
40
|
+
`CI or merge will fail. Create a token (scopes pre-selected) at ${githubPatCreationUrl()} ` +
|
|
41
|
+
`then set GITHUB_PAT and restart.`);
|
|
42
|
+
}
|
|
43
|
+
if (localized.AUTH_DEV_OPEN !== 'false' && !env.HOST?.trim()) {
|
|
44
|
+
logger.warn('local mode: the auth gate is OPEN and the server binds to all interfaces — anyone ' +
|
|
45
|
+
'on your network can reach the API. Set AUTH_DEV_OPEN=false, or HOST=127.0.0.1 on ' +
|
|
46
|
+
'Docker Desktop, to restrict it.');
|
|
47
|
+
}
|
|
48
|
+
return start({ env, buildContainer: buildLocalContainer });
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,iCAAiC,EAAE,MAAM,iCAAiC,CAAA;AAEnF,kFAAkF;AAClF,qFAAqF;AACrF,qFAAqF;AACrF,oFAAoF;AACpF,mFAAmF;AACnF,iDAAiD;AACjD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OA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EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC,CAAA;AAC5D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cat-factory/local-server",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Local-mode runtime facade for the Agent Architecture Board: the @cat-factory/node-server stack with agent jobs run as local Docker/Podman containers and GitHub accessed via a personal access token — a developer can run the whole product on their own machine.",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"drizzle-orm": "1.0.0-rc.3",
|
|
23
|
+
"@cat-factory/agents": "0.6.0",
|
|
24
|
+
"@cat-factory/contracts": "0.6.0",
|
|
25
|
+
"@cat-factory/kernel": "0.6.0",
|
|
26
|
+
"@cat-factory/orchestration": "0.6.0",
|
|
27
|
+
"@cat-factory/node-server": "0.6.0",
|
|
28
|
+
"@cat-factory/server": "0.6.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^24.13.2",
|
|
32
|
+
"typescript": "7.0.1-rc",
|
|
33
|
+
"vitest": "^4.1.9",
|
|
34
|
+
"@cat-factory/conformance": "0.6.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -b tsconfig.build.json",
|
|
38
|
+
"build:watch": "tsc -b tsconfig.build.json --watch",
|
|
39
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
40
|
+
"start": "node dist/main.js",
|
|
41
|
+
"dev": "node --watch dist/main.js",
|
|
42
|
+
"link:repo": "node dist/link-repo.js",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:run": "vitest run"
|
|
45
|
+
}
|
|
46
|
+
}
|