lastlight-core 0.21.11 → 0.21.13
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/deploy/k8s/README.md +111 -34
- package/deploy/k8s/architecture.md +199 -0
- package/deploy/k8s/configmap.yaml +14 -3
- package/deploy/k8s/harness-deployment.yaml +111 -0
- package/deploy/k8s/kustomization.yaml +10 -8
- package/deploy/k8s/sandbox-namespace.yaml +14 -0
- package/deploy/k8s/sandbox-quota.yaml +37 -0
- package/deploy/k8s/sandbox-rbac.yaml +60 -0
- package/dist/admin/routes.js +66 -10
- package/dist/admin/routes.js.map +1 -1
- package/dist/config/config.d.ts +36 -0
- package/dist/config/config.js +101 -3
- package/dist/config/config.js.map +1 -1
- package/dist/cron/review-discovery.d.ts +54 -0
- package/dist/cron/review-discovery.js +70 -0
- package/dist/cron/review-discovery.js.map +1 -0
- package/dist/engine/executors/orchestrator.js +124 -58
- package/dist/engine/executors/orchestrator.js.map +1 -1
- package/dist/engine/github/github.d.ts +8 -0
- package/dist/engine/github/github.js +14 -0
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/profiles.d.ts +12 -1
- package/dist/engine/github/profiles.js +33 -1
- package/dist/engine/github/profiles.js.map +1 -1
- package/dist/index.js +55 -14
- package/dist/index.js.map +1 -1
- package/dist/sandbox/artifact-backend.d.ts +40 -0
- package/dist/sandbox/artifact-backend.js +67 -0
- package/dist/sandbox/artifact-backend.js.map +1 -0
- package/dist/sandbox/artifact-store.d.ts +55 -0
- package/dist/sandbox/artifact-store.js +203 -0
- package/dist/sandbox/artifact-store.js.map +1 -0
- package/dist/sandbox/docker.d.ts +2 -1
- package/dist/sandbox/docker.js +3 -3
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/sandbox/k8s/agent-context-registry.d.ts +25 -0
- package/dist/sandbox/k8s/agent-context-registry.js +45 -0
- package/dist/sandbox/k8s/agent-context-registry.js.map +1 -0
- package/dist/sandbox/k8s/agent-context-route.d.ts +13 -0
- package/dist/sandbox/k8s/agent-context-route.js +21 -0
- package/dist/sandbox/k8s/agent-context-route.js.map +1 -0
- package/dist/sandbox/k8s/artifact-upload-route.d.ts +12 -0
- package/dist/sandbox/k8s/artifact-upload-route.js +40 -0
- package/dist/sandbox/k8s/artifact-upload-route.js.map +1 -0
- package/dist/sandbox/k8s/client.d.ts +22 -0
- package/dist/sandbox/k8s/client.js +35 -0
- package/dist/sandbox/k8s/client.js.map +1 -0
- package/dist/sandbox/k8s/egress-apply.d.ts +14 -0
- package/dist/sandbox/k8s/egress-apply.js +44 -0
- package/dist/sandbox/k8s/egress-apply.js.map +1 -0
- package/dist/sandbox/k8s/egress-ensurer.d.ts +37 -0
- package/dist/sandbox/k8s/egress-ensurer.js +54 -0
- package/dist/sandbox/k8s/egress-ensurer.js.map +1 -0
- package/dist/sandbox/k8s/egress-policy.d.ts +112 -0
- package/dist/sandbox/k8s/egress-policy.js +118 -0
- package/dist/sandbox/k8s/egress-policy.js.map +1 -0
- package/dist/sandbox/k8s/init-agent-context.d.ts +20 -0
- package/dist/sandbox/k8s/init-agent-context.js +35 -0
- package/dist/sandbox/k8s/init-agent-context.js.map +1 -0
- package/dist/sandbox/k8s/init-clone.d.ts +53 -0
- package/dist/sandbox/k8s/init-clone.js +114 -0
- package/dist/sandbox/k8s/init-clone.js.map +1 -0
- package/dist/sandbox/k8s/init-skills.d.ts +13 -0
- package/dist/sandbox/k8s/init-skills.js +28 -0
- package/dist/sandbox/k8s/init-skills.js.map +1 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +179 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js +418 -0
- package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -0
- package/dist/sandbox/k8s/log-stream.d.ts +4 -0
- package/dist/sandbox/k8s/log-stream.js +43 -0
- package/dist/sandbox/k8s/log-stream.js.map +1 -0
- package/dist/sandbox/k8s/naming.d.ts +19 -0
- package/dist/sandbox/k8s/naming.js +35 -0
- package/dist/sandbox/k8s/naming.js.map +1 -0
- package/dist/sandbox/k8s/pod-lifecycle.d.ts +40 -0
- package/dist/sandbox/k8s/pod-lifecycle.js +151 -0
- package/dist/sandbox/k8s/pod-lifecycle.js.map +1 -0
- package/dist/sandbox/k8s/pod-status.d.ts +46 -0
- package/dist/sandbox/k8s/pod-status.js +83 -0
- package/dist/sandbox/k8s/pod-status.js.map +1 -0
- package/dist/sandbox/k8s/pod.d.ts +79 -0
- package/dist/sandbox/k8s/pod.js +115 -0
- package/dist/sandbox/k8s/pod.js.map +1 -0
- package/dist/sandbox/k8s/pvc.d.ts +20 -0
- package/dist/sandbox/k8s/pvc.js +26 -0
- package/dist/sandbox/k8s/pvc.js.map +1 -0
- package/dist/sandbox/k8s/quota.d.ts +34 -0
- package/dist/sandbox/k8s/quota.js +52 -0
- package/dist/sandbox/k8s/quota.js.map +1 -0
- package/dist/sandbox/k8s/reclaim.d.ts +50 -0
- package/dist/sandbox/k8s/reclaim.js +141 -0
- package/dist/sandbox/k8s/reclaim.js.map +1 -0
- package/dist/sandbox/k8s/resource-name.d.ts +33 -0
- package/dist/sandbox/k8s/resource-name.js +49 -0
- package/dist/sandbox/k8s/resource-name.js.map +1 -0
- package/dist/sandbox/k8s/run-agent-script.d.ts +60 -0
- package/dist/sandbox/k8s/run-agent-script.js +48 -0
- package/dist/sandbox/k8s/run-agent-script.js.map +1 -0
- package/dist/sandbox/k8s/run-id.d.ts +23 -0
- package/dist/sandbox/k8s/run-id.js +32 -0
- package/dist/sandbox/k8s/run-id.js.map +1 -0
- package/dist/sandbox/k8s/run-secrets.d.ts +75 -0
- package/dist/sandbox/k8s/run-secrets.js +115 -0
- package/dist/sandbox/k8s/run-secrets.js.map +1 -0
- package/dist/sandbox/k8s/secret.d.ts +20 -0
- package/dist/sandbox/k8s/secret.js +38 -0
- package/dist/sandbox/k8s/secret.js.map +1 -0
- package/dist/sandbox/k8s/skill-bundle-route.d.ts +10 -0
- package/dist/sandbox/k8s/skill-bundle-route.js +18 -0
- package/dist/sandbox/k8s/skill-bundle-route.js.map +1 -0
- package/dist/sandbox/k8s/skill-bundle.d.ts +36 -0
- package/dist/sandbox/k8s/skill-bundle.js +85 -0
- package/dist/sandbox/k8s/skill-bundle.js.map +1 -0
- package/dist/sandbox/k8s/sweep.d.ts +47 -0
- package/dist/sandbox/k8s/sweep.js +29 -0
- package/dist/sandbox/k8s/sweep.js.map +1 -0
- package/dist/sandbox/k8s/workspace-provisioner.d.ts +51 -0
- package/dist/sandbox/k8s/workspace-provisioner.js +64 -0
- package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -0
- package/dist/sandbox/sandbox.d.ts +20 -1
- package/dist/sandbox/sandbox.js +22 -1
- package/dist/sandbox/sandbox.js.map +1 -1
- package/dist/state/workflow-run-store.d.ts +11 -0
- package/dist/state/workflow-run-store.js +19 -0
- package/dist/state/workflow-run-store.js.map +1 -1
- package/dist/workflows/admission.d.ts +19 -0
- package/dist/workflows/admission.js +81 -13
- package/dist/workflows/admission.js.map +1 -1
- package/dist/workflows/handlers/post-review.d.ts +21 -0
- package/dist/workflows/handlers/post-review.js +56 -13
- package/dist/workflows/handlers/post-review.js.map +1 -1
- package/dist/workflows/resume.js +6 -0
- package/dist/workflows/resume.js.map +1 -1
- package/dist/workflows/runner.d.ts +11 -2
- package/dist/workflows/runner.js +73 -15
- package/dist/workflows/runner.js.map +1 -1
- package/dist/workflows/simple.d.ts +13 -1
- package/dist/workflows/simple.js +46 -4
- package/dist/workflows/simple.js.map +1 -1
- package/package.json +21 -20
- package/skills/issue-triage/SKILL.md +17 -0
- package/workflows/cron-review.yaml +14 -1
- package/workflows/dependabot-pr-merge.yaml +14 -9
- package/workflows/issue-triage.yaml +6 -0
- package/workflows/prompts/dependabot-pr-merge.md +53 -11
- package/deploy/k8s/deployment.yaml +0 -63
- package/deploy/k8s/generic-device-plugin.yaml +0 -63
- package/deploy/k8s/namespace.yaml +0 -10
- package/deploy/k8s/pvc.yaml +0 -13
- package/deploy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0 +1,20 @@
|
|
|
1
|
+
import type { V1PersistentVolumeClaim } from "@kubernetes/client-node";
|
|
2
|
+
import type { RunId } from "./run-id.js";
|
|
3
|
+
/** Stable per-(repo,PR) claim name — NO run/phase hash, so pods reuse it
|
|
4
|
+
* (unlike `podNameFor`, which appends one; see `naming.ts`). */
|
|
5
|
+
export declare function pvcNameFor(taskId: string): string;
|
|
6
|
+
export declare function buildPvcManifest(i: {
|
|
7
|
+
name: string;
|
|
8
|
+
namespace: string;
|
|
9
|
+
/** Empty/blank means "no preference" and is OMITTED from the manifest
|
|
10
|
+
* (never sent as `""`) so k8s falls back to the cluster's annotated
|
|
11
|
+
* default StorageClass — an explicit `storageClassName: ""` on a PVC is a
|
|
12
|
+
* k8s sentinel for "no class", which would instead disable dynamic
|
|
13
|
+
* provisioning entirely. */
|
|
14
|
+
storageClassName: string;
|
|
15
|
+
size: string;
|
|
16
|
+
/** Run identity (see `run-id.ts`); when set, its `matchLabels()` is
|
|
17
|
+
* stamped onto the PVC so `reclaimSandbox` (Plan 5) can select it back by
|
|
18
|
+
* the same label (F7 — stamp/select symmetry, enforced by `RunId`). */
|
|
19
|
+
runId?: RunId;
|
|
20
|
+
}): V1PersistentVolumeClaim;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Rfc1123Label } from "./resource-name.js";
|
|
2
|
+
/** Stable per-(repo,PR) claim name — NO run/phase hash, so pods reuse it
|
|
3
|
+
* (unlike `podNameFor`, which appends one; see `naming.ts`). */
|
|
4
|
+
export function pvcNameFor(taskId) {
|
|
5
|
+
return Rfc1123Label.slug(taskId, { prefix: "ws-" }).value;
|
|
6
|
+
}
|
|
7
|
+
export function buildPvcManifest(i) {
|
|
8
|
+
return {
|
|
9
|
+
apiVersion: "v1",
|
|
10
|
+
kind: "PersistentVolumeClaim",
|
|
11
|
+
metadata: {
|
|
12
|
+
name: i.name, namespace: i.namespace,
|
|
13
|
+
labels: {
|
|
14
|
+
"app.kubernetes.io/managed-by": "lastlight",
|
|
15
|
+
"lastlight.io/component": "workspace",
|
|
16
|
+
...(i.runId ? i.runId.matchLabels() : {}),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
spec: {
|
|
20
|
+
accessModes: ["ReadWriteOnce"],
|
|
21
|
+
...(i.storageClassName ? { storageClassName: i.storageClassName } : {}),
|
|
22
|
+
resources: { requests: { storage: i.size } },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=pvc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pvc.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/pvc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;iEACiE;AACjE,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAYhC;IACC,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,uBAAuB;QAC7B,QAAQ,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS;YACpC,MAAM,EAAE;gBACN,8BAA8B,EAAE,WAAW;gBAC3C,wBAAwB,EAAE,WAAW;gBACrC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC1C;SACF;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,CAAC,eAAe,CAAC;YAC9B,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;SAC7C;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by the pod-create path when the namespace `ResourceQuota` rejects the
|
|
3
|
+
* Pod (`403 ... exceeded quota ...`). Distinct from every other create failure
|
|
4
|
+
* so the orchestrator can stamp a `stopReason: "error_quota"` and the workflow
|
|
5
|
+
* layer can treat it as BACKPRESSURE (requeue + retry) instead of a hard fail.
|
|
6
|
+
* The cluster's quota is the concurrency authority (see the Concurrency section
|
|
7
|
+
* of `spec/09-sandbox.md`).
|
|
8
|
+
*/
|
|
9
|
+
export declare class QuotaExceededError extends Error {
|
|
10
|
+
readonly name = "QuotaExceededError";
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* True iff `err` is a k8s `403` produced by the ResourceQuota admission plugin.
|
|
15
|
+
* That plugin emits two phrasings, both of which are the quota rejecting the
|
|
16
|
+
* create and both of which we treat as backpressure:
|
|
17
|
+
* - over the limit — `... is forbidden: exceeded quota: <name>, requested: ...`
|
|
18
|
+
* - missing a metered field — `... is forbidden: failed quota: <name>: must
|
|
19
|
+
* specify requests.cpu, ...` (fires when a compute quota exists but the pod
|
|
20
|
+
* declares no request/limit for a tracked resource). Sandbox pods now set
|
|
21
|
+
* resource requests (`pod.ts`), so this form shouldn't originate from us —
|
|
22
|
+
* matching it is defence-in-depth so such a rejection re-queues (bounded by
|
|
23
|
+
* the queue TTL) rather than hard-failing the run.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isQuotaExceeded(err: unknown): boolean;
|
|
26
|
+
/** Extracts the human-readable rejection reason off a quota-rejecting error —
|
|
27
|
+
* the k8s Status body's `message` field, which is where the ResourceQuota
|
|
28
|
+
* admission plugin puts the useful detail (`isQuotaExceeded`'s docstring
|
|
29
|
+
* covers the two phrasings). Callers are expected to have already confirmed
|
|
30
|
+
* `isQuotaExceeded(err)`; this is the ONLY place that casts `.body.message`
|
|
31
|
+
* off the error, so a `QuotaExceededError` is always built from this. Falls
|
|
32
|
+
* back to a generic message when the body has none (or `err` isn't the
|
|
33
|
+
* `ApiException` shape at all). */
|
|
34
|
+
export declare function quotaMessage(err: unknown): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ApiException } from "@kubernetes/client-node";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by the pod-create path when the namespace `ResourceQuota` rejects the
|
|
4
|
+
* Pod (`403 ... exceeded quota ...`). Distinct from every other create failure
|
|
5
|
+
* so the orchestrator can stamp a `stopReason: "error_quota"` and the workflow
|
|
6
|
+
* layer can treat it as BACKPRESSURE (requeue + retry) instead of a hard fail.
|
|
7
|
+
* The cluster's quota is the concurrency authority (see the Concurrency section
|
|
8
|
+
* of `spec/09-sandbox.md`).
|
|
9
|
+
*/
|
|
10
|
+
export class QuotaExceededError extends Error {
|
|
11
|
+
name = "QuotaExceededError";
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* True iff `err` is a k8s `403` produced by the ResourceQuota admission plugin.
|
|
18
|
+
* That plugin emits two phrasings, both of which are the quota rejecting the
|
|
19
|
+
* create and both of which we treat as backpressure:
|
|
20
|
+
* - over the limit — `... is forbidden: exceeded quota: <name>, requested: ...`
|
|
21
|
+
* - missing a metered field — `... is forbidden: failed quota: <name>: must
|
|
22
|
+
* specify requests.cpu, ...` (fires when a compute quota exists but the pod
|
|
23
|
+
* declares no request/limit for a tracked resource). Sandbox pods now set
|
|
24
|
+
* resource requests (`pod.ts`), so this form shouldn't originate from us —
|
|
25
|
+
* matching it is defence-in-depth so such a rejection re-queues (bounded by
|
|
26
|
+
* the queue TTL) rather than hard-failing the run.
|
|
27
|
+
*/
|
|
28
|
+
export function isQuotaExceeded(err) {
|
|
29
|
+
if (!(err instanceof ApiException) || err.code !== 403)
|
|
30
|
+
return false;
|
|
31
|
+
const body = err.body;
|
|
32
|
+
const text = `${body?.message ?? ""} ${err.message ?? ""}`;
|
|
33
|
+
return /(?:exceeded|failed) quota/i.test(text);
|
|
34
|
+
}
|
|
35
|
+
/** Generic fallback used by {@link quotaMessage} when the rejecting error
|
|
36
|
+
* carries no body message to surface (e.g. a malformed/empty Status body). */
|
|
37
|
+
const GENERIC_QUOTA_MESSAGE = "pod create rejected by ResourceQuota";
|
|
38
|
+
/** Extracts the human-readable rejection reason off a quota-rejecting error —
|
|
39
|
+
* the k8s Status body's `message` field, which is where the ResourceQuota
|
|
40
|
+
* admission plugin puts the useful detail (`isQuotaExceeded`'s docstring
|
|
41
|
+
* covers the two phrasings). Callers are expected to have already confirmed
|
|
42
|
+
* `isQuotaExceeded(err)`; this is the ONLY place that casts `.body.message`
|
|
43
|
+
* off the error, so a `QuotaExceededError` is always built from this. Falls
|
|
44
|
+
* back to a generic message when the body has none (or `err` isn't the
|
|
45
|
+
* `ApiException` shape at all). */
|
|
46
|
+
export function quotaMessage(err) {
|
|
47
|
+
if (!(err instanceof ApiException))
|
|
48
|
+
return GENERIC_QUOTA_MESSAGE;
|
|
49
|
+
const body = err.body;
|
|
50
|
+
return body?.message ?? GENERIC_QUOTA_MESSAGE;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=quota.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/quota.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzB,IAAI,GAAG,oBAAoB,CAAC;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG;QAAE,OAAO,KAAK,CAAC;IACrE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAwC,CAAC;IAC1D,MAAM,IAAI,GAAG,GAAG,IAAI,EAAE,OAAO,IAAI,EAAE,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;IAC3D,OAAO,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;+EAC+E;AAC/E,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;AAErE;;;;;;;oCAOoC;AACpC,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,CAAC,CAAC,GAAG,YAAY,YAAY,CAAC;QAAE,OAAO,qBAAqB,CAAC;IACjE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAwC,CAAC;IAC1D,OAAO,IAAI,EAAE,OAAO,IAAI,qBAAqB,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { V1PersistentVolumeClaim, V1Pod } from "@kubernetes/client-node";
|
|
2
|
+
import type { K8sApis } from "./client.js";
|
|
3
|
+
import type { RunId } from "./run-id.js";
|
|
4
|
+
/** What to reclaim. `run` targets one run's own Pod + PVC (cancel/cleanup) —
|
|
5
|
+
* carrying a `RunId` (not a raw string) so the selector compares against
|
|
6
|
+
* exactly the label `pod.ts`/`pvc.ts` stamped (F7). `sweep` reclaims only
|
|
7
|
+
* idle PVCs (age + LRU cap), never a Pod. */
|
|
8
|
+
export type ReclaimSelector = {
|
|
9
|
+
kind: "run";
|
|
10
|
+
runId: RunId;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "sweep";
|
|
13
|
+
staleByHours: number;
|
|
14
|
+
maxIdlePVCs: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Claim names mounted by any LIVE pod (see {@link isLive}). Pure — plain
|
|
18
|
+
* arrays in, a `Set` out, no client — so the reclaim-selection logic is
|
|
19
|
+
* unit-testable without a fake `K8sApis`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function livePvcClaimNames(pods: V1Pod[]): Set<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Pure PVC selection for `reclaimSandbox`. NEVER returns a PVC whose name is
|
|
24
|
+
* in `live` — that invariant holds regardless of selector kind. For `run`,
|
|
25
|
+
* matches PVCs whose `RUN_ID_LABEL` equals `selector.runId.label`. For `sweep`,
|
|
26
|
+
* first selects PVCs older than `staleByHours` (by `creationTimestamp`), then
|
|
27
|
+
* — if more than `maxIdlePVCs` PVCs remain idle (not selected, not live) —
|
|
28
|
+
* LRU-evicts the oldest of those beyond the cap, keeping the newest
|
|
29
|
+
* `maxIdlePVCs`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function pvcsToReclaim(pvcs: V1PersistentVolumeClaim[], selector: ReclaimSelector, live: Set<string>, now: number): V1PersistentVolumeClaim[];
|
|
32
|
+
export interface ReclaimResult {
|
|
33
|
+
podsDeleted: number;
|
|
34
|
+
pvcsDeleted: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ReclaimOpts {
|
|
37
|
+
now?: number;
|
|
38
|
+
onWarn?: (message: string) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delete what `selector` matches, minus whatever is currently LIVE. The only
|
|
42
|
+
* code (besides a per-run `dispose`) that deletes sandbox Pods/PVCs — lists
|
|
43
|
+
* both (scoped to the managed-by label), computes the live set, then deletes
|
|
44
|
+
* matched pods (run selector only) before matched PVCs. Idempotent (a 404 on
|
|
45
|
+
* delete counts as success) and best-effort per object (a non-404 delete
|
|
46
|
+
* failure warns and moves on to the next object). A 403 on the initial list
|
|
47
|
+
* means the RBAC verb isn't granted yet (Plan 7) — warns once and no-ops,
|
|
48
|
+
* mirroring `egress-apply.ts`'s handling of the same case.
|
|
49
|
+
*/
|
|
50
|
+
export declare function reclaimSandbox(apis: K8sApis, namespace: string, selector: ReclaimSelector, opts?: ReclaimOpts): Promise<ReclaimResult>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ApiException } from "@kubernetes/client-node";
|
|
2
|
+
import { RUN_ID_LABEL } from "./pod.js";
|
|
3
|
+
/** Selects the label every sandbox Pod/PVC carries (`pod.ts` / `pvc.ts`) — the
|
|
4
|
+
* list-scope for `reclaimSandbox` so it never touches non-Last-Light objects. */
|
|
5
|
+
const MANAGED_BY_SELECTOR = "app.kubernetes.io/managed-by=lastlight";
|
|
6
|
+
const LIVE_PHASES = new Set(["Pending", "Running"]);
|
|
7
|
+
/** True when a pod is still using its volumes: phase is Pending/Running AND it
|
|
8
|
+
* has not been marked for deletion yet. Pure — no client. */
|
|
9
|
+
function isLive(pod) {
|
|
10
|
+
return LIVE_PHASES.has(pod.status?.phase ?? "") && pod.metadata?.deletionTimestamp === undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Claim names mounted by any LIVE pod (see {@link isLive}). Pure — plain
|
|
14
|
+
* arrays in, a `Set` out, no client — so the reclaim-selection logic is
|
|
15
|
+
* unit-testable without a fake `K8sApis`.
|
|
16
|
+
*/
|
|
17
|
+
export function livePvcClaimNames(pods) {
|
|
18
|
+
const claims = new Set();
|
|
19
|
+
for (const pod of pods) {
|
|
20
|
+
if (!isLive(pod))
|
|
21
|
+
continue;
|
|
22
|
+
for (const volume of pod.spec?.volumes ?? []) {
|
|
23
|
+
const claimName = volume.persistentVolumeClaim?.claimName;
|
|
24
|
+
if (claimName)
|
|
25
|
+
claims.add(claimName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return claims;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pure PVC selection for `reclaimSandbox`. NEVER returns a PVC whose name is
|
|
32
|
+
* in `live` — that invariant holds regardless of selector kind. For `run`,
|
|
33
|
+
* matches PVCs whose `RUN_ID_LABEL` equals `selector.runId.label`. For `sweep`,
|
|
34
|
+
* first selects PVCs older than `staleByHours` (by `creationTimestamp`), then
|
|
35
|
+
* — if more than `maxIdlePVCs` PVCs remain idle (not selected, not live) —
|
|
36
|
+
* LRU-evicts the oldest of those beyond the cap, keeping the newest
|
|
37
|
+
* `maxIdlePVCs`.
|
|
38
|
+
*/
|
|
39
|
+
export function pvcsToReclaim(pvcs, selector, live, now) {
|
|
40
|
+
const idle = pvcs.filter((p) => p.metadata?.name && !live.has(p.metadata.name));
|
|
41
|
+
if (selector.kind === "run") {
|
|
42
|
+
return idle.filter((p) => p.metadata?.labels?.[RUN_ID_LABEL] === selector.runId.label);
|
|
43
|
+
}
|
|
44
|
+
const maxAgeMs = selector.staleByHours * 3_600_000;
|
|
45
|
+
const ageOf = (p) => {
|
|
46
|
+
const created = p.metadata?.creationTimestamp;
|
|
47
|
+
return created ? now - new Date(created).getTime() : 0;
|
|
48
|
+
};
|
|
49
|
+
const stale = idle.filter((p) => ageOf(p) > maxAgeMs);
|
|
50
|
+
const staleNames = new Set(stale.map((p) => p.metadata?.name));
|
|
51
|
+
const survivors = idle.filter((p) => !staleNames.has(p.metadata?.name));
|
|
52
|
+
const evicted = [];
|
|
53
|
+
if (survivors.length > selector.maxIdlePVCs) {
|
|
54
|
+
// Newest first; keep the leading `maxIdlePVCs`, evict everything older.
|
|
55
|
+
const byAgeAsc = [...survivors].sort((a, b) => ageOf(a) - ageOf(b));
|
|
56
|
+
evicted.push(...byAgeAsc.slice(selector.maxIdlePVCs));
|
|
57
|
+
}
|
|
58
|
+
return [...stale, ...evicted];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Delete what `selector` matches, minus whatever is currently LIVE. The only
|
|
62
|
+
* code (besides a per-run `dispose`) that deletes sandbox Pods/PVCs — lists
|
|
63
|
+
* both (scoped to the managed-by label), computes the live set, then deletes
|
|
64
|
+
* matched pods (run selector only) before matched PVCs. Idempotent (a 404 on
|
|
65
|
+
* delete counts as success) and best-effort per object (a non-404 delete
|
|
66
|
+
* failure warns and moves on to the next object). A 403 on the initial list
|
|
67
|
+
* means the RBAC verb isn't granted yet (Plan 7) — warns once and no-ops,
|
|
68
|
+
* mirroring `egress-apply.ts`'s handling of the same case.
|
|
69
|
+
*/
|
|
70
|
+
export async function reclaimSandbox(apis, namespace, selector, opts) {
|
|
71
|
+
const warn = opts?.onWarn ?? console.warn;
|
|
72
|
+
const now = opts?.now ?? Date.now();
|
|
73
|
+
let pods;
|
|
74
|
+
let pvcs;
|
|
75
|
+
try {
|
|
76
|
+
const [podList, pvcList] = await Promise.all([
|
|
77
|
+
apis.core.listNamespacedPod({ namespace, labelSelector: MANAGED_BY_SELECTOR }),
|
|
78
|
+
apis.core.listNamespacedPersistentVolumeClaim({
|
|
79
|
+
namespace,
|
|
80
|
+
labelSelector: MANAGED_BY_SELECTOR,
|
|
81
|
+
}),
|
|
82
|
+
]);
|
|
83
|
+
pods = podList.items ?? [];
|
|
84
|
+
pvcs = pvcList.items ?? [];
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err instanceof ApiException && err.code === 403) {
|
|
88
|
+
warn(`[k8s] reclaimSandbox: RBAC for listing Pods/PVCs is not granted in ${namespace} ` +
|
|
89
|
+
`(Plan 7). Skipping reclaim.`);
|
|
90
|
+
return { podsDeleted: 0, pvcsDeleted: 0 };
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
const isSelectorPod = (p) => selector.kind === "run" && p.metadata?.labels?.[RUN_ID_LABEL] === selector.runId.label;
|
|
95
|
+
const matchedPods = pods.filter(isSelectorPod);
|
|
96
|
+
// A `run` reclaim targets the run's OWN objects — including a still-live
|
|
97
|
+
// pod racing its own teardown (e.g. a cancel). Exclude the selector's own
|
|
98
|
+
// pods from `live` before selecting PVCs, so this run's PVC isn't protected
|
|
99
|
+
// by the very pod we're about to delete. `sweep` uses the full live set —
|
|
100
|
+
// it must never reclaim a PVC any live pod (of any run) still mounts.
|
|
101
|
+
const liveForPvcs = selector.kind === "run"
|
|
102
|
+
? livePvcClaimNames(pods.filter((p) => !isSelectorPod(p)))
|
|
103
|
+
: livePvcClaimNames(pods);
|
|
104
|
+
const matchedPvcs = pvcsToReclaim(pvcs, selector, liveForPvcs, now);
|
|
105
|
+
let podsDeleted = 0;
|
|
106
|
+
for (const pod of matchedPods) {
|
|
107
|
+
const name = pod.metadata?.name;
|
|
108
|
+
if (!name)
|
|
109
|
+
continue;
|
|
110
|
+
const deleteOp = () => apis.core.deleteNamespacedPod({ name, namespace });
|
|
111
|
+
if (await deleteBestEffort(deleteOp, name, "Pod", warn)) {
|
|
112
|
+
podsDeleted += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let pvcsDeleted = 0;
|
|
116
|
+
for (const pvc of matchedPvcs) {
|
|
117
|
+
const name = pvc.metadata?.name;
|
|
118
|
+
if (!name)
|
|
119
|
+
continue;
|
|
120
|
+
if (await deleteBestEffort(() => apis.core.deleteNamespacedPersistentVolumeClaim({ name, namespace }), name, "PVC", warn)) {
|
|
121
|
+
pvcsDeleted += 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { podsDeleted, pvcsDeleted };
|
|
125
|
+
}
|
|
126
|
+
/** Delete one object: a 404 is success (already gone); any other error warns
|
|
127
|
+
* and returns false so the caller moves on instead of aborting the reclaim. */
|
|
128
|
+
async function deleteBestEffort(op, name, kind, warn) {
|
|
129
|
+
try {
|
|
130
|
+
await op();
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
if (err instanceof ApiException && err.code === 404)
|
|
135
|
+
return true;
|
|
136
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
137
|
+
warn(`[k8s] reclaimSandbox: failed to delete ${kind} ${name}: ${message}`);
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=reclaim.js.map
|
|
@@ -0,0 +1 @@
|
|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WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,IAAI,CAAC,IAAI;YAAE,SAAS;QACpB,IACE,MAAM,gBAAgB,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,qCAAqC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC1E,IAAI,EACJ,KAAK,EACL,IAAI,CACL,EACD,CAAC;YACD,WAAW,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtC,CAAC;AAED;gFACgF;AAChF,KAAK,UAAU,gBAAgB,CAC7B,EAA0B,EAC1B,IAAY,EACZ,IAAY,EACZ,IAA+B;IAE/B,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,YAAY,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QACjE,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,CAAC,0CAA0C,IAAI,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC-1123 label: lowercase `[a-z0-9]` + `-`, at most 63 chars. Kubernetes
|
|
3
|
+
* object names (and this label form of them) share this shape. Centralises
|
|
4
|
+
* the slug transform duplicated across `naming.ts` (`podNameFor`) and
|
|
5
|
+
* `pvc.ts` (`pvcNameFor`), and gives the "derived name stays within 63
|
|
6
|
+
* chars" contract a real runtime guard (F6) instead of the comment-only
|
|
7
|
+
* `SECRET_SUFFIX_BUDGET` reservation it replaces at the point of use
|
|
8
|
+
* (`secret.ts`'s `secretNameFor`).
|
|
9
|
+
*/
|
|
10
|
+
export declare class Rfc1123Label {
|
|
11
|
+
readonly value: string;
|
|
12
|
+
/** RFC-1123 label length cap shared by every k8s object name. */
|
|
13
|
+
static readonly MAX_LENGTH = 63;
|
|
14
|
+
private constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Lowercases `raw`, collapses every run of characters outside `[a-z0-9]`
|
|
17
|
+
* into a single `-`, and strips any leading/trailing `-` left behind.
|
|
18
|
+
* `opts.prefix` (e.g. `"ll-"`, `"ws-"`) is prepended before truncating to
|
|
19
|
+
* `opts.maxLength` (default {@link Rfc1123Label.MAX_LENGTH}); truncation
|
|
20
|
+
* can itself leave a dangling `-`, so it is stripped again after slicing.
|
|
21
|
+
*/
|
|
22
|
+
static slug(raw: string, opts?: {
|
|
23
|
+
prefix?: string;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
}): Rfc1123Label;
|
|
26
|
+
/**
|
|
27
|
+
* Appends `-<suffix>`, throwing if the result would exceed
|
|
28
|
+
* {@link Rfc1123Label.MAX_LENGTH} — the enforced form of the "derived name
|
|
29
|
+
* stays within budget" invariant that used to live only as a comment next
|
|
30
|
+
* to a hand-tuned reservation constant (F6).
|
|
31
|
+
*/
|
|
32
|
+
withSuffix(suffix: string): Rfc1123Label;
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC-1123 label: lowercase `[a-z0-9]` + `-`, at most 63 chars. Kubernetes
|
|
3
|
+
* object names (and this label form of them) share this shape. Centralises
|
|
4
|
+
* the slug transform duplicated across `naming.ts` (`podNameFor`) and
|
|
5
|
+
* `pvc.ts` (`pvcNameFor`), and gives the "derived name stays within 63
|
|
6
|
+
* chars" contract a real runtime guard (F6) instead of the comment-only
|
|
7
|
+
* `SECRET_SUFFIX_BUDGET` reservation it replaces at the point of use
|
|
8
|
+
* (`secret.ts`'s `secretNameFor`).
|
|
9
|
+
*/
|
|
10
|
+
export class Rfc1123Label {
|
|
11
|
+
value;
|
|
12
|
+
/** RFC-1123 label length cap shared by every k8s object name. */
|
|
13
|
+
static MAX_LENGTH = 63;
|
|
14
|
+
constructor(value) {
|
|
15
|
+
this.value = value;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Lowercases `raw`, collapses every run of characters outside `[a-z0-9]`
|
|
19
|
+
* into a single `-`, and strips any leading/trailing `-` left behind.
|
|
20
|
+
* `opts.prefix` (e.g. `"ll-"`, `"ws-"`) is prepended before truncating to
|
|
21
|
+
* `opts.maxLength` (default {@link Rfc1123Label.MAX_LENGTH}); truncation
|
|
22
|
+
* can itself leave a dangling `-`, so it is stripped again after slicing.
|
|
23
|
+
*/
|
|
24
|
+
static slug(raw, opts) {
|
|
25
|
+
const prefix = opts?.prefix ?? "";
|
|
26
|
+
const maxLength = opts?.maxLength ?? Rfc1123Label.MAX_LENGTH;
|
|
27
|
+
const cleaned = raw
|
|
28
|
+
.toLowerCase()
|
|
29
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
30
|
+
.replace(/^-+|-+$/g, "");
|
|
31
|
+
const value = `${prefix}${cleaned}`.slice(0, maxLength).replace(/-+$/g, "");
|
|
32
|
+
return new Rfc1123Label(value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Appends `-<suffix>`, throwing if the result would exceed
|
|
36
|
+
* {@link Rfc1123Label.MAX_LENGTH} — the enforced form of the "derived name
|
|
37
|
+
* stays within budget" invariant that used to live only as a comment next
|
|
38
|
+
* to a hand-tuned reservation constant (F6).
|
|
39
|
+
*/
|
|
40
|
+
withSuffix(suffix) {
|
|
41
|
+
const value = `${this.value}-${suffix}`;
|
|
42
|
+
if (value.length > Rfc1123Label.MAX_LENGTH) {
|
|
43
|
+
throw new Error(`Rfc1123Label.withSuffix: "${this.value}" + "-${suffix}" is ${value.length} chars, ` +
|
|
44
|
+
`over the ${Rfc1123Label.MAX_LENGTH}-char RFC-1123 label cap`);
|
|
45
|
+
}
|
|
46
|
+
return new Rfc1123Label(value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=resource-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-name.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/resource-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IAIM;IAH7B,iEAAiE;IACjE,MAAM,CAAU,UAAU,GAAG,EAAE,CAAC;IAEhC,YAA6B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE9C;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,CAAC,GAAW,EAAE,IAA8C;QACrE,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,YAAY,CAAC,UAAU,CAAC;QAC7D,MAAM,OAAO,GAAG,GAAG;aAChB,WAAW,EAAE;aACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;aAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC3B,MAAM,KAAK,GAAG,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5E,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,UAAU,CAAC,MAAc;QACvB,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC;QACxC,IAAI,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,CAAC,KAAK,SAAS,MAAM,QAAQ,KAAK,CAAC,MAAM,UAAU;gBAClF,YAAY,YAAY,CAAC,UAAU,0BAA0B,CAChE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which optional `agentic-pi run` flags to emit, and whether the best-effort
|
|
3
|
+
* artifact-upload block should run after the agent exits.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately absent: the actual model, harness endpoint, profile,
|
|
6
|
+
* thinking-level, and web-search-provider STRINGS. `runAgent`
|
|
7
|
+
* (`kubernetes-sandbox.ts`) validates each of those against a closed set,
|
|
8
|
+
* then execs the returned script as `sh -c SCRIPT sh $1 $2 $3 $4 $5` — model,
|
|
9
|
+
* harness endpoint, profile, thinking, web-search provider — binding each to
|
|
10
|
+
* its own positional arg at exec time. That's immune to quote-breaking
|
|
11
|
+
* regardless of characters (the same contract `init-clone.ts` uses for
|
|
12
|
+
* owner/repo/branch): since this builder's input has no field for the values
|
|
13
|
+
* themselves, there's no way for one to be spliced into the script text by
|
|
14
|
+
* mistake.
|
|
15
|
+
*/
|
|
16
|
+
export interface RunAgentScriptInput {
|
|
17
|
+
/** Append `--profile "$3"` — the profile string itself is bound to `$3`. */
|
|
18
|
+
readonly profile: boolean;
|
|
19
|
+
/** Absolute in-pod skill directories (`SKILLS_MOUNT_DIR/<name>`, already
|
|
20
|
+
* sanitized by `stageSkills` before this is called) — each becomes its
|
|
21
|
+
* own `--skill <dir>`. Safe to splice directly into the script text: not
|
|
22
|
+
* user input, already charset-restricted. */
|
|
23
|
+
readonly skillDirs: readonly string[];
|
|
24
|
+
/** Append `--thinking "$4"` — the level string itself is bound to `$4`. */
|
|
25
|
+
readonly thinking: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this run has web search enabled at all. False (the default)
|
|
28
|
+
* appends `--no-web-search` — REQUIRED, not cosmetic: agentic-pi
|
|
29
|
+
* auto-enables its web-search extension whenever any `*_API_KEY` env var
|
|
30
|
+
* is present in the container, so a phase that never opted in would
|
|
31
|
+
* otherwise get search anyway. Mirrors the docker backend (`docker.ts`,
|
|
32
|
+
* ~:358-373).
|
|
33
|
+
*/
|
|
34
|
+
readonly webSearch: boolean;
|
|
35
|
+
/** Append `--web-search-provider "$5"` — only takes effect when
|
|
36
|
+
* `webSearch` is also true; the provider string itself is bound to `$5`. */
|
|
37
|
+
readonly webSearchProvider: boolean;
|
|
38
|
+
/** Append the best-effort `.lastlight/` tar+curl upload block (see below).
|
|
39
|
+
* The artifact bearer token travels via env (`LASTLIGHT_ARTIFACT_TOKEN`,
|
|
40
|
+
* in the pod's creds Secret), never as an argv value. */
|
|
41
|
+
readonly artifactUpload: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Builds the in-pod shell script for a `runAgent` run.
|
|
45
|
+
*
|
|
46
|
+
* Fixed shape, independent of the input flags:
|
|
47
|
+
* 1. `agentic-pi run`, reading the prompt from stdin (`< PROMPT_FILE`, a
|
|
48
|
+
* mounted Secret file — never a CLI arg or inline env) with whichever
|
|
49
|
+
* flags {@link agentRunFlags} decided. Its real exit code is captured
|
|
50
|
+
* (`rc=$?`) rather than left to a bare `exec`, so step 2 can run
|
|
51
|
+
* afterwards without masking it. (The resolved agent-context reaches the
|
|
52
|
+
* workspace root as `AGENTS.md` via the agent-context initContainer —
|
|
53
|
+
* `init-agent-context.ts`, nearform#240 — not this script.)
|
|
54
|
+
* 2. When `artifactUpload` is set: a best-effort tar+upload of `.lastlight/`
|
|
55
|
+
* (`|| true` — a hiccup here must never turn a successful agent run into
|
|
56
|
+
* a reported failure) to the harness's `/internal/sandbox-artifacts`
|
|
57
|
+
* route, bearer-authed with `$LASTLIGHT_ARTIFACT_TOKEN` (env, not argv).
|
|
58
|
+
* 3. `exit $rc` — restores the agent's own result regardless of step 2.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildRunAgentScript(input: RunAgentScriptInput): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PROMPT_FILE } from "./pod.js";
|
|
2
|
+
function agentRunFlags(input) {
|
|
3
|
+
const webSearchFlag = input.webSearch
|
|
4
|
+
? input.webSearchProvider
|
|
5
|
+
? `--web-search-provider "$5"`
|
|
6
|
+
: ""
|
|
7
|
+
: "--no-web-search";
|
|
8
|
+
return [
|
|
9
|
+
input.profile ? `--profile "$3"` : "",
|
|
10
|
+
input.thinking ? `--thinking "$4"` : "",
|
|
11
|
+
webSearchFlag,
|
|
12
|
+
...input.skillDirs.map((dir) => `--skill ${dir}`),
|
|
13
|
+
]
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join(" ");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Builds the in-pod shell script for a `runAgent` run.
|
|
19
|
+
*
|
|
20
|
+
* Fixed shape, independent of the input flags:
|
|
21
|
+
* 1. `agentic-pi run`, reading the prompt from stdin (`< PROMPT_FILE`, a
|
|
22
|
+
* mounted Secret file — never a CLI arg or inline env) with whichever
|
|
23
|
+
* flags {@link agentRunFlags} decided. Its real exit code is captured
|
|
24
|
+
* (`rc=$?`) rather than left to a bare `exec`, so step 2 can run
|
|
25
|
+
* afterwards without masking it. (The resolved agent-context reaches the
|
|
26
|
+
* workspace root as `AGENTS.md` via the agent-context initContainer —
|
|
27
|
+
* `init-agent-context.ts`, nearform#240 — not this script.)
|
|
28
|
+
* 2. When `artifactUpload` is set: a best-effort tar+upload of `.lastlight/`
|
|
29
|
+
* (`|| true` — a hiccup here must never turn a successful agent run into
|
|
30
|
+
* a reported failure) to the harness's `/internal/sandbox-artifacts`
|
|
31
|
+
* route, bearer-authed with `$LASTLIGHT_ARTIFACT_TOKEN` (env, not argv).
|
|
32
|
+
* 3. `exit $rc` — restores the agent's own result regardless of step 2.
|
|
33
|
+
*/
|
|
34
|
+
export function buildRunAgentScript(input) {
|
|
35
|
+
const flags = agentRunFlags(input);
|
|
36
|
+
const runAgent = `agentic-pi run --model "$1" --sandbox none --no-session ${flags} ` +
|
|
37
|
+
`< ${PROMPT_FILE} ; rc=$?`;
|
|
38
|
+
const uploadBlock = input.artifactUpload
|
|
39
|
+
? "\n" +
|
|
40
|
+
`if [ -d .lastlight ]; then\n` +
|
|
41
|
+
` tar -czf - .lastlight | curl -sf -X POST ` +
|
|
42
|
+
`-H "Authorization: Bearer $LASTLIGHT_ARTIFACT_TOKEN" ` +
|
|
43
|
+
`--data-binary @- "$2/internal/sandbox-artifacts" || true\n` +
|
|
44
|
+
`fi`
|
|
45
|
+
: "";
|
|
46
|
+
return `${runAgent}${uploadBlock}\nexit $rc`;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=run-agent-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent-script.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/run-agent-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA6CvC,SAAS,aAAa,CAAC,KAA0B;IAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS;QACnC,CAAC,CAAC,KAAK,CAAC,iBAAiB;YACvB,CAAC,CAAC,4BAA4B;YAC9B,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,iBAAiB,CAAC;IACtB,OAAO;QACL,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE;QACrC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE;QACvC,aAAa;QACb,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC;KAClD;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA0B;IAC5D,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,QAAQ,GACZ,2DAA2D,KAAK,GAAG;QACnE,KAAK,WAAW,UAAU,CAAC;IAC7B,MAAM,WAAW,GAAG,KAAK,CAAC,cAAc;QACtC,CAAC,CAAC,IAAI;YACJ,8BAA8B;YAC9B,6CAA6C;YAC7C,uDAAuD;YACvD,4DAA4D;YAC5D,IAAI;QACN,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO,GAAG,QAAQ,GAAG,WAAW,YAAY,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sandbox run's identity, sanitized once at construction. Stamped
|
|
3
|
+
* identically onto the Pod (`pod.ts`) and the PVC (`pvc.ts`) via
|
|
4
|
+
* {@link RunId.matchLabels}, and compared back against that same label by
|
|
5
|
+
* the reclaim run-selector (`reclaim.ts`) — this type makes that "stamp
|
|
6
|
+
* exactly what you select on" rule structural instead of prose-only (F7):
|
|
7
|
+
* there is exactly one place a raw runId is turned into a label value
|
|
8
|
+
* (`RunId.from`), so a stamp call and a select call built from the same raw
|
|
9
|
+
* id can never drift apart.
|
|
10
|
+
*/
|
|
11
|
+
export declare class RunId {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
private constructor();
|
|
14
|
+
/** Sanitize `raw` via the existing `sanitizeLabelValue` (the RFC-1123
|
|
15
|
+
* label-VALUE rules) and wrap the result. Sanitizes once — every other
|
|
16
|
+
* use of the run id (stamping, selecting) reads `.label` off this
|
|
17
|
+
* instance instead of re-sanitizing. */
|
|
18
|
+
static from(raw: string): RunId;
|
|
19
|
+
/** The single `RUN_ID_LABEL` key/value pair to spread into a manifest's
|
|
20
|
+
* `metadata.labels` (stamping) or compare a listed object's labels
|
|
21
|
+
* against (selecting) — same shape either way. */
|
|
22
|
+
matchLabels(): Record<string, string>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RUN_ID_LABEL } from "./pod.js";
|
|
2
|
+
import { sanitizeLabelValue } from "./naming.js";
|
|
3
|
+
/**
|
|
4
|
+
* A sandbox run's identity, sanitized once at construction. Stamped
|
|
5
|
+
* identically onto the Pod (`pod.ts`) and the PVC (`pvc.ts`) via
|
|
6
|
+
* {@link RunId.matchLabels}, and compared back against that same label by
|
|
7
|
+
* the reclaim run-selector (`reclaim.ts`) — this type makes that "stamp
|
|
8
|
+
* exactly what you select on" rule structural instead of prose-only (F7):
|
|
9
|
+
* there is exactly one place a raw runId is turned into a label value
|
|
10
|
+
* (`RunId.from`), so a stamp call and a select call built from the same raw
|
|
11
|
+
* id can never drift apart.
|
|
12
|
+
*/
|
|
13
|
+
export class RunId {
|
|
14
|
+
label;
|
|
15
|
+
constructor(label) {
|
|
16
|
+
this.label = label;
|
|
17
|
+
}
|
|
18
|
+
/** Sanitize `raw` via the existing `sanitizeLabelValue` (the RFC-1123
|
|
19
|
+
* label-VALUE rules) and wrap the result. Sanitizes once — every other
|
|
20
|
+
* use of the run id (stamping, selecting) reads `.label` off this
|
|
21
|
+
* instance instead of re-sanitizing. */
|
|
22
|
+
static from(raw) {
|
|
23
|
+
return new RunId(sanitizeLabelValue(raw));
|
|
24
|
+
}
|
|
25
|
+
/** The single `RUN_ID_LABEL` key/value pair to spread into a manifest's
|
|
26
|
+
* `metadata.labels` (stamping) or compare a listed object's labels
|
|
27
|
+
* against (selecting) — same shape either way. */
|
|
28
|
+
matchLabels() {
|
|
29
|
+
return { [RUN_ID_LABEL]: this.label };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=run-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-id.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/run-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,OAAO,KAAK;IACa;IAA7B,YAA6B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE9C;;;6CAGyC;IACzC,MAAM,CAAC,IAAI,CAAC,GAAW;QACrB,OAAO,IAAI,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;uDAEmD;IACnD,WAAW;QACT,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACxC,CAAC;CACF"}
|