hammerkit 1.27.0-next.13 → 1.27.0-next.15
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/docker/item-network.js +13 -5
- package/dist/executer/docker-service.js +30 -8
- package/dist/harness/connect.js +19 -5
- package/dist/harness/mcp-command.js +22 -6
- package/dist/harness/mcp.js +62 -114
- package/dist/harness/opencode.js +151 -50
- package/dist/harness/pi.js +14 -0
- package/dist/harness/sandbox-client.js +81 -2
- package/dist/harness/service-tools.js +141 -0
- package/dist/harness/task-tools.js +210 -0
- package/dist/kubernetes/ensure-kubernetes-service-exists.js +2 -0
- package/dist/planner/utils/parse-work-port.js +4 -1
- package/dist/remote/remote-work-commands.js +98 -12
- package/dist/schema/work-scope-parser.js +6 -0
- package/dist/server/accounts-api.js +2 -1
- package/dist/server/approvals-api.js +1 -1
- package/dist/server/definitions-api.js +4 -2
- package/dist/server/endpoints.js +612 -0
- package/dist/server/executor.js +14 -1
- package/dist/server/kubernetes-backend.js +200 -33
- package/dist/server/plan.js +1 -0
- package/dist/server/policy.js +24 -2
- package/dist/server/repo-access.js +5 -0
- package/dist/server/run-plan.js +38 -4
- package/dist/server/run-request.js +44 -2
- package/dist/server/run-worker.js +130 -9
- package/dist/server/runs.js +317 -24
- package/dist/server/server-config.js +160 -9
- package/dist/server/server.js +210 -14
- package/dist/server/service-runs.js +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mayOpenEndpoints = exports.getRunRepo = exports.toRunEndpoints = exports.refuseEndpoints = exports.getEndpointHosts = exports.getServiceRunName = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const plan_1 = require("./plan");
|
|
6
|
+
const policy_1 = require("./policy");
|
|
7
|
+
const run_request_1 = require("./run-request");
|
|
8
|
+
// The name of a service run when the request names none: the branch it runs from, as a DNS
|
|
9
|
+
// label, so the runs of several branches stand side by side and each keeps its hosts.
|
|
10
|
+
function getServiceRunName(branch) {
|
|
11
|
+
const name = (branch ?? '')
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
14
|
+
.replace(/-+/g, '-')
|
|
15
|
+
.slice(0, 40)
|
|
16
|
+
.replace(/^-+|-+$/g, '');
|
|
17
|
+
return run_request_1.SERVICE_RUN_NAME_PATTERN.test(name) ? name : 'run';
|
|
18
|
+
}
|
|
19
|
+
exports.getServiceRunName = getServiceRunName;
|
|
20
|
+
/**
|
|
21
|
+
* The host labels of a run's endpoints: its name, the port and twelve hex digits of its
|
|
22
|
+
* owner (at most 40 + 5 + 2 + 12 and three dashes: a DNS label), so two callers with a branch of the same name get hosts of their own, and a run
|
|
23
|
+
* that replaces another of the same name takes over its hosts. Two endpoints on the same
|
|
24
|
+
* port (of two services) are told apart by their place.
|
|
25
|
+
*/
|
|
26
|
+
function getEndpointHosts(name, owner, endpoints) {
|
|
27
|
+
const of = (0, crypto_1.createHash)('sha256').update(`${owner.iss}\0${owner.sub}`).digest('hex').slice(0, 12);
|
|
28
|
+
return endpoints.map((endpoint, index) => endpoints.findIndex((other) => other.port === endpoint.port) === index
|
|
29
|
+
? `${name}-${endpoint.port}-${of}`
|
|
30
|
+
: `${name}-${endpoint.port}-${index}-${of}`);
|
|
31
|
+
}
|
|
32
|
+
exports.getEndpointHosts = getEndpointHosts;
|
|
33
|
+
// The container port of each `host:container` port of a planned service.
|
|
34
|
+
function containerPorts(plan) {
|
|
35
|
+
return plan.ports.map((port) => Number(port.split(':').pop()));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Why the endpoints of a service run can't be published, or null. Each is a port its
|
|
39
|
+
* service declares, of a service the run starts. Under a `runs.secretNetwork` below `open`
|
|
40
|
+
* a service behind an endpoint may not read a secret or a credential of the server: a page
|
|
41
|
+
* is a way out that no mask of the log covers.
|
|
42
|
+
*/
|
|
43
|
+
function refuseEndpoints(request, plan, secretNetworkOpen) {
|
|
44
|
+
for (const endpoint of request.endpoints) {
|
|
45
|
+
const item = plan[endpoint.service];
|
|
46
|
+
if (!item || item.kind !== 'service') {
|
|
47
|
+
return `the endpoint ${endpoint.service}:${endpoint.port} names no service the run starts`;
|
|
48
|
+
}
|
|
49
|
+
if (!containerPorts(item).includes(endpoint.port)) {
|
|
50
|
+
const ports = containerPorts(item);
|
|
51
|
+
return `${endpoint.service} has no port ${endpoint.port}${ports.length > 0 ? `, its ports are ${ports.join(', ')}` : ', it declares none'}`;
|
|
52
|
+
}
|
|
53
|
+
const reads = (0, plan_1.getCredentialReads)(item);
|
|
54
|
+
if (!secretNetworkOpen && reads.length > 0) {
|
|
55
|
+
return `${endpoint.service} reads ${reads.join(', ')}, it can not be behind an endpoint on this server (runs.secretNetwork): a page could show it`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
exports.refuseEndpoints = refuseEndpoints;
|
|
61
|
+
function toRunEndpoints(endpoints, hosts, url) {
|
|
62
|
+
return endpoints.map((endpoint, index) => ({
|
|
63
|
+
service: endpoint.service,
|
|
64
|
+
port: endpoint.port,
|
|
65
|
+
host: hosts[index],
|
|
66
|
+
url: url(hosts[index]),
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
exports.toRunEndpoints = toRunEndpoints;
|
|
70
|
+
// The repository of a run's source, which the endpoints grants are written for.
|
|
71
|
+
function getRunRepo(run) {
|
|
72
|
+
return run.source.type === 'upload' ? null : run.source.repo;
|
|
73
|
+
}
|
|
74
|
+
exports.getRunRepo = getRunRepo;
|
|
75
|
+
// Who may open the endpoints of a service run, and extend it, besides its owner: those
|
|
76
|
+
// with an `open` or `publish` level for its repository.
|
|
77
|
+
function mayOpenEndpoints(grant, run) {
|
|
78
|
+
const repo = getRunRepo(run);
|
|
79
|
+
return repo !== null && (0, policy_1.endpointLevel)(grant, repo) !== null;
|
|
80
|
+
}
|
|
81
|
+
exports.mayOpenEndpoints = mayOpenEndpoints;
|
|
82
|
+
//# sourceMappingURL=service-runs.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hammerkit",
|
|
3
3
|
"description": "Containerized build tool with incremental caching that runs the same build file locally, in Docker and on Kubernetes.",
|
|
4
|
-
"version": "1.27.0-next.
|
|
4
|
+
"version": "1.27.0-next.15",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
7
7
|
"build-tool",
|