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.
Files changed (150) hide show
  1. package/deploy/k8s/README.md +111 -34
  2. package/deploy/k8s/architecture.md +199 -0
  3. package/deploy/k8s/configmap.yaml +14 -3
  4. package/deploy/k8s/harness-deployment.yaml +111 -0
  5. package/deploy/k8s/kustomization.yaml +10 -8
  6. package/deploy/k8s/sandbox-namespace.yaml +14 -0
  7. package/deploy/k8s/sandbox-quota.yaml +37 -0
  8. package/deploy/k8s/sandbox-rbac.yaml +60 -0
  9. package/dist/admin/routes.js +66 -10
  10. package/dist/admin/routes.js.map +1 -1
  11. package/dist/config/config.d.ts +36 -0
  12. package/dist/config/config.js +101 -3
  13. package/dist/config/config.js.map +1 -1
  14. package/dist/cron/review-discovery.d.ts +54 -0
  15. package/dist/cron/review-discovery.js +70 -0
  16. package/dist/cron/review-discovery.js.map +1 -0
  17. package/dist/engine/executors/orchestrator.js +124 -58
  18. package/dist/engine/executors/orchestrator.js.map +1 -1
  19. package/dist/engine/github/github.d.ts +8 -0
  20. package/dist/engine/github/github.js +14 -0
  21. package/dist/engine/github/github.js.map +1 -1
  22. package/dist/engine/github/profiles.d.ts +12 -1
  23. package/dist/engine/github/profiles.js +33 -1
  24. package/dist/engine/github/profiles.js.map +1 -1
  25. package/dist/index.js +55 -14
  26. package/dist/index.js.map +1 -1
  27. package/dist/sandbox/artifact-backend.d.ts +40 -0
  28. package/dist/sandbox/artifact-backend.js +67 -0
  29. package/dist/sandbox/artifact-backend.js.map +1 -0
  30. package/dist/sandbox/artifact-store.d.ts +55 -0
  31. package/dist/sandbox/artifact-store.js +203 -0
  32. package/dist/sandbox/artifact-store.js.map +1 -0
  33. package/dist/sandbox/docker.d.ts +2 -1
  34. package/dist/sandbox/docker.js +3 -3
  35. package/dist/sandbox/docker.js.map +1 -1
  36. package/dist/sandbox/k8s/agent-context-registry.d.ts +25 -0
  37. package/dist/sandbox/k8s/agent-context-registry.js +45 -0
  38. package/dist/sandbox/k8s/agent-context-registry.js.map +1 -0
  39. package/dist/sandbox/k8s/agent-context-route.d.ts +13 -0
  40. package/dist/sandbox/k8s/agent-context-route.js +21 -0
  41. package/dist/sandbox/k8s/agent-context-route.js.map +1 -0
  42. package/dist/sandbox/k8s/artifact-upload-route.d.ts +12 -0
  43. package/dist/sandbox/k8s/artifact-upload-route.js +40 -0
  44. package/dist/sandbox/k8s/artifact-upload-route.js.map +1 -0
  45. package/dist/sandbox/k8s/client.d.ts +22 -0
  46. package/dist/sandbox/k8s/client.js +35 -0
  47. package/dist/sandbox/k8s/client.js.map +1 -0
  48. package/dist/sandbox/k8s/egress-apply.d.ts +14 -0
  49. package/dist/sandbox/k8s/egress-apply.js +44 -0
  50. package/dist/sandbox/k8s/egress-apply.js.map +1 -0
  51. package/dist/sandbox/k8s/egress-ensurer.d.ts +37 -0
  52. package/dist/sandbox/k8s/egress-ensurer.js +54 -0
  53. package/dist/sandbox/k8s/egress-ensurer.js.map +1 -0
  54. package/dist/sandbox/k8s/egress-policy.d.ts +112 -0
  55. package/dist/sandbox/k8s/egress-policy.js +118 -0
  56. package/dist/sandbox/k8s/egress-policy.js.map +1 -0
  57. package/dist/sandbox/k8s/init-agent-context.d.ts +20 -0
  58. package/dist/sandbox/k8s/init-agent-context.js +35 -0
  59. package/dist/sandbox/k8s/init-agent-context.js.map +1 -0
  60. package/dist/sandbox/k8s/init-clone.d.ts +53 -0
  61. package/dist/sandbox/k8s/init-clone.js +114 -0
  62. package/dist/sandbox/k8s/init-clone.js.map +1 -0
  63. package/dist/sandbox/k8s/init-skills.d.ts +13 -0
  64. package/dist/sandbox/k8s/init-skills.js +28 -0
  65. package/dist/sandbox/k8s/init-skills.js.map +1 -0
  66. package/dist/sandbox/k8s/kubernetes-sandbox.d.ts +179 -0
  67. package/dist/sandbox/k8s/kubernetes-sandbox.js +418 -0
  68. package/dist/sandbox/k8s/kubernetes-sandbox.js.map +1 -0
  69. package/dist/sandbox/k8s/log-stream.d.ts +4 -0
  70. package/dist/sandbox/k8s/log-stream.js +43 -0
  71. package/dist/sandbox/k8s/log-stream.js.map +1 -0
  72. package/dist/sandbox/k8s/naming.d.ts +19 -0
  73. package/dist/sandbox/k8s/naming.js +35 -0
  74. package/dist/sandbox/k8s/naming.js.map +1 -0
  75. package/dist/sandbox/k8s/pod-lifecycle.d.ts +40 -0
  76. package/dist/sandbox/k8s/pod-lifecycle.js +151 -0
  77. package/dist/sandbox/k8s/pod-lifecycle.js.map +1 -0
  78. package/dist/sandbox/k8s/pod-status.d.ts +46 -0
  79. package/dist/sandbox/k8s/pod-status.js +83 -0
  80. package/dist/sandbox/k8s/pod-status.js.map +1 -0
  81. package/dist/sandbox/k8s/pod.d.ts +79 -0
  82. package/dist/sandbox/k8s/pod.js +115 -0
  83. package/dist/sandbox/k8s/pod.js.map +1 -0
  84. package/dist/sandbox/k8s/pvc.d.ts +20 -0
  85. package/dist/sandbox/k8s/pvc.js +26 -0
  86. package/dist/sandbox/k8s/pvc.js.map +1 -0
  87. package/dist/sandbox/k8s/quota.d.ts +34 -0
  88. package/dist/sandbox/k8s/quota.js +52 -0
  89. package/dist/sandbox/k8s/quota.js.map +1 -0
  90. package/dist/sandbox/k8s/reclaim.d.ts +50 -0
  91. package/dist/sandbox/k8s/reclaim.js +141 -0
  92. package/dist/sandbox/k8s/reclaim.js.map +1 -0
  93. package/dist/sandbox/k8s/resource-name.d.ts +33 -0
  94. package/dist/sandbox/k8s/resource-name.js +49 -0
  95. package/dist/sandbox/k8s/resource-name.js.map +1 -0
  96. package/dist/sandbox/k8s/run-agent-script.d.ts +60 -0
  97. package/dist/sandbox/k8s/run-agent-script.js +48 -0
  98. package/dist/sandbox/k8s/run-agent-script.js.map +1 -0
  99. package/dist/sandbox/k8s/run-id.d.ts +23 -0
  100. package/dist/sandbox/k8s/run-id.js +32 -0
  101. package/dist/sandbox/k8s/run-id.js.map +1 -0
  102. package/dist/sandbox/k8s/run-secrets.d.ts +75 -0
  103. package/dist/sandbox/k8s/run-secrets.js +115 -0
  104. package/dist/sandbox/k8s/run-secrets.js.map +1 -0
  105. package/dist/sandbox/k8s/secret.d.ts +20 -0
  106. package/dist/sandbox/k8s/secret.js +38 -0
  107. package/dist/sandbox/k8s/secret.js.map +1 -0
  108. package/dist/sandbox/k8s/skill-bundle-route.d.ts +10 -0
  109. package/dist/sandbox/k8s/skill-bundle-route.js +18 -0
  110. package/dist/sandbox/k8s/skill-bundle-route.js.map +1 -0
  111. package/dist/sandbox/k8s/skill-bundle.d.ts +36 -0
  112. package/dist/sandbox/k8s/skill-bundle.js +85 -0
  113. package/dist/sandbox/k8s/skill-bundle.js.map +1 -0
  114. package/dist/sandbox/k8s/sweep.d.ts +47 -0
  115. package/dist/sandbox/k8s/sweep.js +29 -0
  116. package/dist/sandbox/k8s/sweep.js.map +1 -0
  117. package/dist/sandbox/k8s/workspace-provisioner.d.ts +51 -0
  118. package/dist/sandbox/k8s/workspace-provisioner.js +64 -0
  119. package/dist/sandbox/k8s/workspace-provisioner.js.map +1 -0
  120. package/dist/sandbox/sandbox.d.ts +20 -1
  121. package/dist/sandbox/sandbox.js +22 -1
  122. package/dist/sandbox/sandbox.js.map +1 -1
  123. package/dist/state/workflow-run-store.d.ts +11 -0
  124. package/dist/state/workflow-run-store.js +19 -0
  125. package/dist/state/workflow-run-store.js.map +1 -1
  126. package/dist/workflows/admission.d.ts +19 -0
  127. package/dist/workflows/admission.js +81 -13
  128. package/dist/workflows/admission.js.map +1 -1
  129. package/dist/workflows/handlers/post-review.d.ts +21 -0
  130. package/dist/workflows/handlers/post-review.js +56 -13
  131. package/dist/workflows/handlers/post-review.js.map +1 -1
  132. package/dist/workflows/resume.js +6 -0
  133. package/dist/workflows/resume.js.map +1 -1
  134. package/dist/workflows/runner.d.ts +11 -2
  135. package/dist/workflows/runner.js +73 -15
  136. package/dist/workflows/runner.js.map +1 -1
  137. package/dist/workflows/simple.d.ts +13 -1
  138. package/dist/workflows/simple.js +46 -4
  139. package/dist/workflows/simple.js.map +1 -1
  140. package/package.json +21 -20
  141. package/skills/issue-triage/SKILL.md +17 -0
  142. package/workflows/cron-review.yaml +14 -1
  143. package/workflows/dependabot-pr-merge.yaml +14 -9
  144. package/workflows/issue-triage.yaml +6 -0
  145. package/workflows/prompts/dependabot-pr-merge.md +53 -11
  146. package/deploy/k8s/deployment.yaml +0 -63
  147. package/deploy/k8s/generic-device-plugin.yaml +0 -63
  148. package/deploy/k8s/namespace.yaml +0 -10
  149. package/deploy/k8s/pvc.yaml +0 -13
  150. package/deploy/k8s/service.yaml +0 -12
@@ -0,0 +1,179 @@
1
+ import type { RunResult } from "agentic-pi";
2
+ import type { Sandbox, SandboxFactoryOpts, PrePopulateSpec, ProvisionResult, RunAgentOpts, RunCommandOpts, RawCommandResult, SandboxEvent } from "../sandbox.js";
3
+ import type { SandboxBackend } from "../../config/config.js";
4
+ import { type ArtifactStore } from "../artifact-store.js";
5
+ import { type K8sApis } from "./client.js";
6
+ import { type AgentContextRegistry } from "./agent-context-registry.js";
7
+ import { EgressEnsurer } from "./egress-ensurer.js";
8
+ import { type SkillBundleRegistry } from "./skill-bundle.js";
9
+ /** Config the adapter needs. `storageClassName` / `workspaceSize` size and
10
+ * class the per-(repo,PR) PVC (Task 5); `runAsUser` is the pod and
11
+ * initContainer security-context UID. `harnessEndpoint` / `harnessNamespace`
12
+ * / `harnessPodLabels` locate the harness Pod the skills-init fetches the
13
+ * bundle from (Task 3/6). The factory (`sandbox.ts`) resolves and passes all
14
+ * of these via `resolveKubernetesConfig()`. */
15
+ export interface K8sAdapterConfig {
16
+ namespace: string;
17
+ image: string;
18
+ storageClassName: string;
19
+ workspaceSize: string;
20
+ runAsUser: number;
21
+ harnessEndpoint: string;
22
+ harnessNamespace: string;
23
+ harnessPodLabels: Record<string, string>;
24
+ /** Injectable fake `K8sApis` for tests; defaults to the real client. */
25
+ apis?: K8sApis;
26
+ /** Injectable registry for tests; defaults to the module singleton skillBundleRegistry. */
27
+ skillRegistry?: SkillBundleRegistry;
28
+ /** Injectable registry for tests; defaults to the module singleton agentContextRegistry. */
29
+ agentContextRegistry?: AgentContextRegistry;
30
+ /** Injectable artifact store (tests only). Defaults to the module-wide
31
+ * `artifactStore` singleton (`../artifact-store.js`) — the same instance
32
+ * the `/internal/sandbox-artifacts` route resolves tokens against, so a
33
+ * token this adapter registers is always resolvable by that route. */
34
+ artifactStore?: ArtifactStore;
35
+ /** Injectable egress-policy applier (tests only). Defaults to the module-wide
36
+ * `egressEnsurer` singleton (`./egress-ensurer.js`) so production keeps
37
+ * ensure-once-per-namespace-per-process behaviour. A test can inject a
38
+ * fresh `EgressEnsurer` for isolation instead of needing a unique
39
+ * namespace per test. */
40
+ egressEnsurer?: EgressEnsurer;
41
+ }
42
+ /**
43
+ * The `kubernetes` {@link Sandbox} adapter — one pod per `runAgent`/
44
+ * `runCommand` call. A thin orchestrator (F1): it wires the collaborators that
45
+ * own the real work — {@link WorkspaceProvisioner} (emptyDir vs per-(repo,PR)
46
+ * PVC), {@link RunSecrets} (creds/prompt Secret create + ownerRef patch +
47
+ * best-effort delete), {@link EgressEnsurer} (the CiliumNetworkPolicy pair),
48
+ * and the free pod-lifecycle functions (`pod-lifecycle.ts`) — behind the
49
+ * unchanged `Sandbox` port.
50
+ *
51
+ * `provision` hands back a {@link Provisioned} the orchestrator holds until
52
+ * `dispose` (the sequence provision→runPod is provision-scoped, and the port
53
+ * gives no channel to thread it per call); `runPod` threads a
54
+ * {@link RunHandles} out explicitly for `runCommand`'s result poll and for
55
+ * `dispose` to reap, rather than stashing loose `activePod`/`activeCredsSecret`
56
+ * mutable fields mid-call. The only other fields that outlive a call are the
57
+ * skill/agent-context/artifact tokens, kept solely so `dispose` can evict them.
58
+ *
59
+ * `runAgent` delivers the prompt via a per-run prompt Secret mounted into the
60
+ * pod and piped to the agent's stdin; the resolved agent-context (persona/hard
61
+ * rules) is delivered over its own HTTP init-fetch channel (nearform#240),
62
+ * mirroring skills: `runAgent` registers the resolved text with the (injectable)
63
+ * agent-context registry, carries the fetch token into the creds Secret, and
64
+ * adds an agent-context initContainer that pulls it from the harness's
65
+ * `/internal/agent-context` route and writes it to `<WORKSPACE_DIR>/AGENTS.md`.
66
+ * A dedicated route (not the skills bundle) because agent-context is
67
+ * per-run-constant and a no-skills phase must still receive `AGENTS.md`.
68
+ * `stageSkills` tars the resolved skill dirs and registers the bundle with the
69
+ * (injectable) skill registry; `runPod` then carries the fetch token into the
70
+ * creds Secret and adds a skills initContainer that pulls it from the harness's
71
+ * `/internal/skill-bundle` route. `runAgent` additionally mints a per-run token
72
+ * from the (injectable) artifact store and carries it into the same creds
73
+ * Secret; the in-pod script tars `.lastlight/` after the agent finishes and
74
+ * uploads it to the harness's `/internal/sandbox-artifacts` route, best-effort
75
+ * so an upload hiccup never masks the agent's real exit code — `dispose` evicts
76
+ * the token afterward.
77
+ */
78
+ export declare class KubernetesSandbox implements Sandbox {
79
+ private readonly opts;
80
+ readonly backend: SandboxBackend;
81
+ private readonly apis;
82
+ private readonly ns;
83
+ private readonly image;
84
+ private readonly runAsUser;
85
+ private readonly harnessEndpoint;
86
+ private readonly harnessNamespace;
87
+ private readonly harnessPodLabels;
88
+ private readonly skillRegistry;
89
+ private readonly agentContextRegistry;
90
+ private readonly artifactStore;
91
+ private readonly egressEnsurer;
92
+ private readonly provisioner;
93
+ private readonly runSecrets;
94
+ /** Result of the last `provision()` call — the workspace descriptor + pre-clone
95
+ * coordinates `runPod` reads to shape the pod (PVC/emptyDir volume, clone
96
+ * init, run-id stamp). Set once per sandbox lifecycle, before any run. */
97
+ private provisioned?;
98
+ /** Pod + Secrets for the last run, held for `dispose` to reap. */
99
+ private handles?;
100
+ /** Fetch token for the bundle staged by the last `stageSkills()` call, if
101
+ * any — `runPod` carries it into the creds Secret + skills-init; `dispose`
102
+ * evicts it from the registry. */
103
+ private skillToken?;
104
+ /** Fetch token for the resolved agent-context registered by the last
105
+ * `runAgent()` call, if any — `runPod` carries it into the creds Secret +
106
+ * agent-context-init; `dispose` evicts it from the registry. Never minted
107
+ * for `runCommand` (no agent, no AGENTS.md), nor when the context is empty. */
108
+ private agentContextToken?;
109
+ /** Artifact-upload token minted by the last `runAgent()` call, if any —
110
+ * `runPod` carries it into the creds Secret; the in-pod script reads it back
111
+ * via env to authenticate the `.lastlight/` upload; `dispose` evicts it from
112
+ * the store. Never minted for `runCommand` (nothing to upload). */
113
+ private artifactToken?;
114
+ constructor(opts: SandboxFactoryOpts, cfg: K8sAdapterConfig);
115
+ provision(pre?: PrePopulateSpec): Promise<ProvisionResult>;
116
+ /**
117
+ * Package `skillPaths` into a tar, register it in the (injectable) skill
118
+ * registry, and return the in-pod dirs the agent should `--skill` against.
119
+ * The returned token is stashed on `this.skillToken` so `runPod` can wire the
120
+ * creds Secret + skills-init and `dispose` can evict it; the orchestrator also
121
+ * threads the returned dirs back in as `opts.skillDirs` for the `runAgent`
122
+ * command (Task 6 brief). Deduped: `buildSkillTar` doesn't dedupe
123
+ * sanitized-name collisions (two skill dirs whose basenames sanitize equal
124
+ * merge in the tar), so a `Set` here at least keeps the returned `--skill`
125
+ * list free of repeats.
126
+ */
127
+ stageSkills(_phaseKey: string, skillPaths: string[] | undefined): string[] | undefined;
128
+ /** Hosts the strict policy allows — the shared allowlist plus OTEL collector
129
+ * hosts when sandbox OTEL forwarding is on (mirrors `egressPolicyFor`). */
130
+ private strictHosts;
131
+ /** Apply the egress policy pair once per namespace, via the injected
132
+ * {@link EgressEnsurer} (`this.egressEnsurer`). Best-effort in Plan 3: a
133
+ * 403 means the CiliumNetworkPolicy RBAC verb isn't granted yet (Plan 6),
134
+ * so it warns ONCE and runs on Cilium's default-allow — no regression to
135
+ * the validated flows; the same code enforces the moment RBAC lands. */
136
+ private ensureEgress;
137
+ sandboxPathFor(relPath: string): string;
138
+ /** The provisioned pre-clone descriptor's `runId` wrapped as a {@link RunId}
139
+ * — stamped identically onto the Pod (`runPod`) and the PVC
140
+ * (`WorkspaceProvisioner`) so the reclaim run-selector (Plan 5) matches both
141
+ * (F7). Undefined when `provision()` had no pre-clone descriptor, or the
142
+ * descriptor carried no runId. */
143
+ private currentRunId;
144
+ runAgent(taskId: string, prompt: string, opts: RunAgentOpts, onEvent: (record: SandboxEvent) => void): Promise<RunResult | undefined>;
145
+ /** Guard the free-form `runAgent` options against their closed sets so an
146
+ * unexpected value fails loudly here rather than reaching the CLI. Profile
147
+ * enables agentic-pi's github_* extension per access profile; web-search
148
+ * defaults OFF (agentic-pi auto-enables it whenever any `*_API_KEY` is
149
+ * present, so a phase that never opted in actively suppresses it via the
150
+ * script's `--no-web-search`). */
151
+ private assertValidRunAgentOpts;
152
+ runCommand(taskId: string, command: string, opts: RunCommandOpts): Promise<RawCommandResult>;
153
+ /** Delegates to {@link awaitPodResult} (`pod-lifecycle.ts`) — see there for
154
+ * the poll/fallback rationale. */
155
+ private awaitPodResult;
156
+ private runPod;
157
+ /** The init containers this run needs: the minimal clone (locked decision #2)
158
+ * only when the run has a PVC workspace AND a pre-clone descriptor (an
159
+ * ephemeral emptyDir run has nothing to clone into), the skills-init whenever
160
+ * `stageSkills` staged a bundle, and the agent-context-init whenever
161
+ * `runAgent` registered a non-empty context (fetches `AGENTS.md` into the
162
+ * workspace root). All coexist, and `buildPodManifest` attaches the creds
163
+ * Secret's `envFrom` to each. */
164
+ private buildInitContainers;
165
+ /** Create the Pod; on failure, best-effort delete the Secret(s) already
166
+ * created for it (they exist before the Pod per the ordering rule), so a
167
+ * failed create doesn't orphan them — then rethrow. A ResourceQuota rejection
168
+ * is backpressure, not a failure: rethrow a typed error so the orchestrator
169
+ * stamps `error_quota` and the run requeues (see the Concurrency section of
170
+ * `spec/09-sandbox.md`). */
171
+ private createPodOrCleanupSecrets;
172
+ /** Delegates to {@link waitForContainerStart} (`pod-lifecycle.ts`) — see
173
+ * there for the started/fatal/init-container-check rationale. */
174
+ private waitForContainerStart;
175
+ /** Delegates to {@link waitForPodGone} (`pod-lifecycle.ts`) — see there for
176
+ * the RWO Multi-Attach rationale. */
177
+ private waitForPodGone;
178
+ dispose(): Promise<void>;
179
+ }
@@ -0,0 +1,418 @@
1
+ import { parseLine } from "../sandbox.js";
2
+ import { artifactStore } from "../artifact-store.js";
3
+ import { loadAgentContext } from "../../workflows/loader.js";
4
+ import { makeK8sApis } from "./client.js";
5
+ import { buildPodManifest, WORKSPACE_DIR } from "./pod.js";
6
+ import { buildRunAgentScript } from "./run-agent-script.js";
7
+ import { podNameFor } from "./naming.js";
8
+ import { RunId } from "./run-id.js";
9
+ import { streamPodLog } from "./log-stream.js";
10
+ import { awaitPodResult, waitForContainerStart, waitForPodGone } from "./pod-lifecycle.js";
11
+ import { buildCloneInitContainer } from "./init-clone.js";
12
+ import { buildSkillsInitContainer } from "./init-skills.js";
13
+ import { buildAgentContextInitContainer } from "./init-agent-context.js";
14
+ import { agentContextRegistry } from "./agent-context-registry.js";
15
+ import { DEFAULT_ALLOWLIST, mergeAllowlist } from "../egress-allowlist.js";
16
+ import { egressModeFor } from "./egress-policy.js";
17
+ import { egressEnsurer } from "./egress-ensurer.js";
18
+ import { buildSkillTar, skillBundleRegistry, SKILLS_MOUNT_DIR, } from "./skill-bundle.js";
19
+ import { QuotaExceededError, isQuotaExceeded, quotaMessage } from "./quota.js";
20
+ import { WorkspaceProvisioner } from "./workspace-provisioner.js";
21
+ import { RunSecrets } from "./run-secrets.js";
22
+ import { AGENTIC_PROFILES } from "../../engine/github/profiles.js";
23
+ /** Valid `--thinking` reasoning-effort levels. Mirrors the docker backend's
24
+ * guard (`docker.ts`) — a shared-set consolidation (the same move F8 made
25
+ * for `profile`) is a later task. */
26
+ const THINKING_LEVELS = new Set(["off", "minimal", "low", "medium", "high", "xhigh"]);
27
+ /** Valid `--web-search-provider` values. Mirrors the docker backend's guard. */
28
+ const WEB_SEARCH_PROVIDERS = new Set(["tavily", "brave", "exa"]);
29
+ /**
30
+ * The `kubernetes` {@link Sandbox} adapter — one pod per `runAgent`/
31
+ * `runCommand` call. A thin orchestrator (F1): it wires the collaborators that
32
+ * own the real work — {@link WorkspaceProvisioner} (emptyDir vs per-(repo,PR)
33
+ * PVC), {@link RunSecrets} (creds/prompt Secret create + ownerRef patch +
34
+ * best-effort delete), {@link EgressEnsurer} (the CiliumNetworkPolicy pair),
35
+ * and the free pod-lifecycle functions (`pod-lifecycle.ts`) — behind the
36
+ * unchanged `Sandbox` port.
37
+ *
38
+ * `provision` hands back a {@link Provisioned} the orchestrator holds until
39
+ * `dispose` (the sequence provision→runPod is provision-scoped, and the port
40
+ * gives no channel to thread it per call); `runPod` threads a
41
+ * {@link RunHandles} out explicitly for `runCommand`'s result poll and for
42
+ * `dispose` to reap, rather than stashing loose `activePod`/`activeCredsSecret`
43
+ * mutable fields mid-call. The only other fields that outlive a call are the
44
+ * skill/agent-context/artifact tokens, kept solely so `dispose` can evict them.
45
+ *
46
+ * `runAgent` delivers the prompt via a per-run prompt Secret mounted into the
47
+ * pod and piped to the agent's stdin; the resolved agent-context (persona/hard
48
+ * rules) is delivered over its own HTTP init-fetch channel (nearform#240),
49
+ * mirroring skills: `runAgent` registers the resolved text with the (injectable)
50
+ * agent-context registry, carries the fetch token into the creds Secret, and
51
+ * adds an agent-context initContainer that pulls it from the harness's
52
+ * `/internal/agent-context` route and writes it to `<WORKSPACE_DIR>/AGENTS.md`.
53
+ * A dedicated route (not the skills bundle) because agent-context is
54
+ * per-run-constant and a no-skills phase must still receive `AGENTS.md`.
55
+ * `stageSkills` tars the resolved skill dirs and registers the bundle with the
56
+ * (injectable) skill registry; `runPod` then carries the fetch token into the
57
+ * creds Secret and adds a skills initContainer that pulls it from the harness's
58
+ * `/internal/skill-bundle` route. `runAgent` additionally mints a per-run token
59
+ * from the (injectable) artifact store and carries it into the same creds
60
+ * Secret; the in-pod script tars `.lastlight/` after the agent finishes and
61
+ * uploads it to the harness's `/internal/sandbox-artifacts` route, best-effort
62
+ * so an upload hiccup never masks the agent's real exit code — `dispose` evicts
63
+ * the token afterward.
64
+ */
65
+ export class KubernetesSandbox {
66
+ opts;
67
+ backend = "kubernetes";
68
+ apis;
69
+ ns;
70
+ image;
71
+ runAsUser;
72
+ harnessEndpoint;
73
+ harnessNamespace;
74
+ harnessPodLabels;
75
+ skillRegistry;
76
+ agentContextRegistry;
77
+ artifactStore;
78
+ egressEnsurer;
79
+ provisioner;
80
+ runSecrets;
81
+ /** Result of the last `provision()` call — the workspace descriptor + pre-clone
82
+ * coordinates `runPod` reads to shape the pod (PVC/emptyDir volume, clone
83
+ * init, run-id stamp). Set once per sandbox lifecycle, before any run. */
84
+ provisioned;
85
+ /** Pod + Secrets for the last run, held for `dispose` to reap. */
86
+ handles;
87
+ /** Fetch token for the bundle staged by the last `stageSkills()` call, if
88
+ * any — `runPod` carries it into the creds Secret + skills-init; `dispose`
89
+ * evicts it from the registry. */
90
+ skillToken;
91
+ /** Fetch token for the resolved agent-context registered by the last
92
+ * `runAgent()` call, if any — `runPod` carries it into the creds Secret +
93
+ * agent-context-init; `dispose` evicts it from the registry. Never minted
94
+ * for `runCommand` (no agent, no AGENTS.md), nor when the context is empty. */
95
+ agentContextToken;
96
+ /** Artifact-upload token minted by the last `runAgent()` call, if any —
97
+ * `runPod` carries it into the creds Secret; the in-pod script reads it back
98
+ * via env to authenticate the `.lastlight/` upload; `dispose` evicts it from
99
+ * the store. Never minted for `runCommand` (nothing to upload). */
100
+ artifactToken;
101
+ constructor(opts, cfg) {
102
+ this.opts = opts;
103
+ this.apis = cfg.apis ?? makeK8sApis();
104
+ this.ns = cfg.namespace;
105
+ this.image = opts.imageName ?? cfg.image;
106
+ this.runAsUser = cfg.runAsUser;
107
+ this.harnessEndpoint = cfg.harnessEndpoint;
108
+ this.harnessNamespace = cfg.harnessNamespace;
109
+ this.harnessPodLabels = cfg.harnessPodLabels;
110
+ this.skillRegistry = cfg.skillRegistry ?? skillBundleRegistry;
111
+ this.agentContextRegistry = cfg.agentContextRegistry ?? agentContextRegistry;
112
+ this.artifactStore = cfg.artifactStore ?? artifactStore;
113
+ this.egressEnsurer = cfg.egressEnsurer ?? egressEnsurer;
114
+ this.provisioner = new WorkspaceProvisioner(this.apis.core, {
115
+ namespace: cfg.namespace,
116
+ storageClassName: cfg.storageClassName,
117
+ workspaceSize: cfg.workspaceSize,
118
+ taskId: opts.taskId,
119
+ });
120
+ this.runSecrets = new RunSecrets(this.apis.core, cfg.namespace);
121
+ }
122
+ async provision(pre) {
123
+ this.provisioned = await this.provisioner.provision(pre);
124
+ return this.provisioned.result;
125
+ }
126
+ /**
127
+ * Package `skillPaths` into a tar, register it in the (injectable) skill
128
+ * registry, and return the in-pod dirs the agent should `--skill` against.
129
+ * The returned token is stashed on `this.skillToken` so `runPod` can wire the
130
+ * creds Secret + skills-init and `dispose` can evict it; the orchestrator also
131
+ * threads the returned dirs back in as `opts.skillDirs` for the `runAgent`
132
+ * command (Task 6 brief). Deduped: `buildSkillTar` doesn't dedupe
133
+ * sanitized-name collisions (two skill dirs whose basenames sanitize equal
134
+ * merge in the tar), so a `Set` here at least keeps the returned `--skill`
135
+ * list free of repeats.
136
+ */
137
+ stageSkills(_phaseKey, skillPaths) {
138
+ const { tar, names } = buildSkillTar(skillPaths ?? []);
139
+ if (!names.length)
140
+ return undefined;
141
+ this.skillToken = this.skillRegistry.register(tar);
142
+ return [...new Set(names)].map((n) => `${SKILLS_MOUNT_DIR}/${n}`);
143
+ }
144
+ /** Hosts the strict policy allows — the shared allowlist plus OTEL collector
145
+ * hosts when sandbox OTEL forwarding is on (mirrors `egressPolicyFor`). */
146
+ strictHosts() {
147
+ const otel = this.opts.otel;
148
+ const extra = otel?.enabled && otel.forwardToSandbox ? otel.collectorHosts : [];
149
+ return mergeAllowlist(DEFAULT_ALLOWLIST, extra);
150
+ }
151
+ /** Apply the egress policy pair once per namespace, via the injected
152
+ * {@link EgressEnsurer} (`this.egressEnsurer`). Best-effort in Plan 3: a
153
+ * 403 means the CiliumNetworkPolicy RBAC verb isn't granted yet (Plan 6),
154
+ * so it warns ONCE and runs on Cilium's default-allow — no regression to
155
+ * the validated flows; the same code enforces the moment RBAC lands. */
156
+ ensureEgress() {
157
+ const port = Number(new URL(this.harnessEndpoint).port) || 8644;
158
+ const harness = {
159
+ namespace: this.harnessNamespace,
160
+ labels: this.harnessPodLabels,
161
+ port,
162
+ };
163
+ return this.egressEnsurer.ensure(this.apis.custom, this.ns, this.strictHosts(), harness);
164
+ }
165
+ sandboxPathFor(relPath) {
166
+ return `${WORKSPACE_DIR}/${relPath}`;
167
+ }
168
+ /** The provisioned pre-clone descriptor's `runId` wrapped as a {@link RunId}
169
+ * — stamped identically onto the Pod (`runPod`) and the PVC
170
+ * (`WorkspaceProvisioner`) so the reclaim run-selector (Plan 5) matches both
171
+ * (F7). Undefined when `provision()` had no pre-clone descriptor, or the
172
+ * descriptor carried no runId. */
173
+ currentRunId() {
174
+ const runId = this.provisioned?.pre?.runId;
175
+ return runId ? RunId.from(runId) : undefined;
176
+ }
177
+ async runAgent(taskId, prompt, opts, onEvent) {
178
+ // The prompt reaches the container via a mounted Secret file (see
179
+ // `RunSecrets`), piped to stdin by the generated script — never as a CLI
180
+ // arg (`ps`-visible) or inline env. AGENTS.md (nearform#240): the harness
181
+ // has no host-shared workspace to write it into on k8s (`writeAgentsMd` is
182
+ // skipped for this backend — see orchestrator.ts), so the resolved
183
+ // agent-context is served over a dedicated authenticated HTTP init-fetch
184
+ // channel (mirroring skills): register the text, mint a token, and an
185
+ // agent-context initContainer pulls it into `<WORKSPACE_DIR>/AGENTS.md`
186
+ // before the agent runs. Empty context ⇒ no token, no init container.
187
+ this.artifactToken = this.artifactStore.register(this.opts.taskId);
188
+ const agentContext = loadAgentContext();
189
+ if (agentContext)
190
+ this.agentContextToken = this.agentContextRegistry.register(agentContext);
191
+ // Untrusted / free-form values (model, harness endpoint, profile, thinking
192
+ // level, web-search provider) never get spliced into the script TEXT — each
193
+ // is validated against a closed set (where one applies) then bound to its
194
+ // own `sh` positional arg (`$1`..`$5`) below, immune to quote-breaking
195
+ // regardless of characters (the same contract `init-clone.ts` uses).
196
+ // `buildRunAgentScript` only ever sees booleans deciding whether a flag
197
+ // appears, never the values.
198
+ this.assertValidRunAgentOpts(opts);
199
+ const script = buildRunAgentScript({
200
+ profile: Boolean(opts.profile),
201
+ skillDirs: opts.skillDirs ?? [],
202
+ thinking: Boolean(opts.thinking),
203
+ webSearch: opts.webSearch === true,
204
+ webSearchProvider: opts.webSearch === true && Boolean(opts.webSearchProvider),
205
+ artifactUpload: Boolean(this.artifactToken),
206
+ });
207
+ // `runPod` stashes the resulting `RunHandles` on `this.handles` for
208
+ // `dispose`; `runAgent` has no further use for them (the orchestrator
209
+ // reconstructs the result from the streamed events), so the return is
210
+ // ignored here — unlike `runCommand`, which threads them into its poll.
211
+ await this.runPod({
212
+ taskId,
213
+ command: [
214
+ "sh",
215
+ "-c",
216
+ script,
217
+ "sh",
218
+ opts.model,
219
+ this.harnessEndpoint,
220
+ opts.profile ?? "",
221
+ opts.thinking ?? "",
222
+ opts.webSearchProvider ?? "",
223
+ ],
224
+ env: { ...this.opts.env, ...opts.sandboxEnv },
225
+ cwd: opts.agentCwd,
226
+ onLine: parseLine(onEvent),
227
+ promptText: prompt,
228
+ });
229
+ return undefined; // orchestrator reconstructs the result from the streamed events
230
+ }
231
+ /** Guard the free-form `runAgent` options against their closed sets so an
232
+ * unexpected value fails loudly here rather than reaching the CLI. Profile
233
+ * enables agentic-pi's github_* extension per access profile; web-search
234
+ * defaults OFF (agentic-pi auto-enables it whenever any `*_API_KEY` is
235
+ * present, so a phase that never opted in actively suppresses it via the
236
+ * script's `--no-web-search`). */
237
+ assertValidRunAgentOpts(opts) {
238
+ if (opts.profile && !AGENTIC_PROFILES.has(opts.profile)) {
239
+ throw new Error(`Refusing to pass profile "${opts.profile}" — must be one of ` +
240
+ `${[...AGENTIC_PROFILES].join("|")}`);
241
+ }
242
+ if (opts.thinking && !THINKING_LEVELS.has(opts.thinking)) {
243
+ throw new Error(`Refusing to pass thinking "${opts.thinking}" — must be one of ` +
244
+ `${[...THINKING_LEVELS].join("|")}`);
245
+ }
246
+ if (opts.webSearch === true && opts.webSearchProvider) {
247
+ if (!WEB_SEARCH_PROVIDERS.has(opts.webSearchProvider)) {
248
+ throw new Error(`Refusing to pass web-search-provider "${opts.webSearchProvider}" — must be one of ` +
249
+ `${[...WEB_SEARCH_PROVIDERS].join("|")}`);
250
+ }
251
+ }
252
+ }
253
+ async runCommand(taskId, command, opts) {
254
+ let stdout = "";
255
+ const handles = await this.runPod({
256
+ taskId,
257
+ command: ["sh", "-c", command],
258
+ env: { ...this.opts.env, ...opts.sandboxEnv },
259
+ cwd: opts.cwd,
260
+ onLine: (line) => {
261
+ stdout += line + "\n";
262
+ },
263
+ timeoutSeconds: opts.timeoutSeconds,
264
+ });
265
+ const { exitCode, timedOut } = await this.awaitPodResult(handles.pod);
266
+ return { exitCode, stdout, stderr: "", timedOut };
267
+ }
268
+ /** Delegates to {@link awaitPodResult} (`pod-lifecycle.ts`) — see there for
269
+ * the poll/fallback rationale. */
270
+ awaitPodResult(name) {
271
+ return awaitPodResult(this.apis.core, this.ns, name);
272
+ }
273
+ async runPod(input) {
274
+ const { taskId, command, env, cwd, onLine, timeoutSeconds, promptText } = input;
275
+ // `Rfc1123Label`, not a raw string: threading the type through is what makes
276
+ // "a Secret name is only ever derived from a pod name" a compile-time fact
277
+ // (F6) — `RunSecrets` takes this label directly, so a raw string can't reach
278
+ // it.
279
+ const podLabel = podNameFor(taskId, "run");
280
+ await this.ensureEgress();
281
+ const secrets = await this.runSecrets.create({
282
+ podLabel,
283
+ env,
284
+ skillToken: this.skillToken,
285
+ agentContextToken: this.agentContextToken,
286
+ artifactToken: this.artifactToken,
287
+ promptText,
288
+ });
289
+ // Handle set the moment the Secrets exist and the pod name is fixed — so
290
+ // `dispose` can reap the pod + Secrets even if a later step (pod create,
291
+ // start wait, log stream) throws, mirroring the old early `activePod`
292
+ // assignment (the input channel is gone; disposal state is not).
293
+ const handles = { pod: podLabel.value, ...secrets };
294
+ this.handles = handles;
295
+ // Wall-clock cap: activeDeadlineSeconds kills the pod at the per-call budget
296
+ // (runCommand threads its RunCommandOpts.timeoutSeconds; runAgent falls
297
+ // through to the factory timeout). streamPodLog resolves once the pod (and
298
+ // its log stream) terminates, so no separate timeout is needed here.
299
+ const manifest = buildPodManifest({
300
+ name: podLabel.value,
301
+ namespace: this.ns,
302
+ image: this.image,
303
+ command,
304
+ envFromSecret: secrets.credsSecret,
305
+ promptSecret: secrets.promptSecret,
306
+ cwd,
307
+ activeDeadlineSeconds: timeoutSeconds ?? this.opts.timeoutSeconds ?? 1800,
308
+ runAsUser: this.runAsUser,
309
+ workspace: this.provisioned?.workspace ?? { kind: "emptyDir" },
310
+ initContainers: this.buildInitContainers(),
311
+ egressPolicy: egressModeFor(this.opts.egress),
312
+ skillsMount: this.skillToken !== undefined,
313
+ runId: this.currentRunId(),
314
+ });
315
+ const created = await this.createPodOrCleanupSecrets(manifest, secrets);
316
+ await this.runSecrets.patchOwnerRefs(created, podLabel.value, secrets);
317
+ await this.waitForContainerStart(podLabel.value);
318
+ await streamPodLog(this.apis.log, this.ns, podLabel.value, "agent", onLine);
319
+ return handles;
320
+ }
321
+ /** The init containers this run needs: the minimal clone (locked decision #2)
322
+ * only when the run has a PVC workspace AND a pre-clone descriptor (an
323
+ * ephemeral emptyDir run has nothing to clone into), the skills-init whenever
324
+ * `stageSkills` staged a bundle, and the agent-context-init whenever
325
+ * `runAgent` registered a non-empty context (fetches `AGENTS.md` into the
326
+ * workspace root). All coexist, and `buildPodManifest` attaches the creds
327
+ * Secret's `envFrom` to each. */
328
+ buildInitContainers() {
329
+ const initContainers = [];
330
+ const pre = this.provisioned?.pre;
331
+ if (this.provisioned?.workspace.kind === "pvc" && pre) {
332
+ initContainers.push(buildCloneInitContainer(this.image, {
333
+ owner: pre.owner,
334
+ repo: pre.repo,
335
+ branch: pre.branch,
336
+ cwd: WORKSPACE_DIR,
337
+ runAsUser: this.runAsUser,
338
+ baseBranch: pre.baseBranch,
339
+ runId: pre.runId,
340
+ recreateFromBase: pre.recreateFromBase,
341
+ }));
342
+ }
343
+ if (this.skillToken) {
344
+ initContainers.push(buildSkillsInitContainer(this.image, {
345
+ endpoint: this.harnessEndpoint,
346
+ runAsUser: this.runAsUser,
347
+ }));
348
+ }
349
+ if (this.agentContextToken) {
350
+ initContainers.push(buildAgentContextInitContainer(this.image, {
351
+ endpoint: this.harnessEndpoint,
352
+ runAsUser: this.runAsUser,
353
+ }));
354
+ }
355
+ return initContainers;
356
+ }
357
+ /** Create the Pod; on failure, best-effort delete the Secret(s) already
358
+ * created for it (they exist before the Pod per the ordering rule), so a
359
+ * failed create doesn't orphan them — then rethrow. A ResourceQuota rejection
360
+ * is backpressure, not a failure: rethrow a typed error so the orchestrator
361
+ * stamps `error_quota` and the run requeues (see the Concurrency section of
362
+ * `spec/09-sandbox.md`). */
363
+ async createPodOrCleanupSecrets(manifest, secrets) {
364
+ try {
365
+ return await this.apis.core.createNamespacedPod({ namespace: this.ns, body: manifest });
366
+ }
367
+ catch (err) {
368
+ await this.runSecrets.deleteBestEffort(secrets.credsSecret);
369
+ if (secrets.promptSecret)
370
+ await this.runSecrets.deleteBestEffort(secrets.promptSecret);
371
+ if (isQuotaExceeded(err))
372
+ throw new QuotaExceededError(quotaMessage(err));
373
+ throw err;
374
+ }
375
+ }
376
+ /** Delegates to {@link waitForContainerStart} (`pod-lifecycle.ts`) — see
377
+ * there for the started/fatal/init-container-check rationale. */
378
+ waitForContainerStart(name) {
379
+ return waitForContainerStart(this.apis.core, this.ns, name);
380
+ }
381
+ /** Delegates to {@link waitForPodGone} (`pod-lifecycle.ts`) — see there for
382
+ * the RWO Multi-Attach rationale. */
383
+ waitForPodGone(name) {
384
+ return waitForPodGone(this.apis.core, this.ns, name);
385
+ }
386
+ async dispose() {
387
+ const handles = this.handles;
388
+ if (handles) {
389
+ this.handles = undefined;
390
+ let deleteSucceeded = false;
391
+ try {
392
+ await this.apis.core.deleteNamespacedPod({ name: handles.pod, namespace: this.ns });
393
+ deleteSucceeded = true;
394
+ }
395
+ catch {
396
+ /* already gone — the reclaim sweep (Plan 4) is the backstop */
397
+ }
398
+ if (deleteSucceeded)
399
+ await this.waitForPodGone(handles.pod);
400
+ await this.runSecrets.deleteBestEffort(handles.credsSecret);
401
+ if (handles.promptSecret)
402
+ await this.runSecrets.deleteBestEffort(handles.promptSecret);
403
+ }
404
+ if (this.skillToken) {
405
+ this.skillRegistry.evict(this.skillToken);
406
+ this.skillToken = undefined;
407
+ }
408
+ if (this.agentContextToken) {
409
+ this.agentContextRegistry.evict(this.agentContextToken);
410
+ this.agentContextToken = undefined;
411
+ }
412
+ if (this.artifactToken) {
413
+ this.artifactStore.evict(this.artifactToken);
414
+ this.artifactToken = undefined;
415
+ }
416
+ }
417
+ }
418
+ //# sourceMappingURL=kubernetes-sandbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kubernetes-sandbox.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/kubernetes-sandbox.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EA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AAC,CAAC;YAC5D,IAAI,OAAO,CAAC,YAAY;gBAAE,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACxD,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACrC,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7C,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { Log } from "@kubernetes/client-node";
2
+ /** Stream a pod's stdout (follow) and forward complete lines. Resolves when the
3
+ * log stream closes (pod terminated). Mirrors the docker adapter's line buffer. */
4
+ export declare function streamPodLog(log: Log, namespace: string, pod: string, container: string, onLine: (line: string) => void): Promise<void>;