lastlight-core 0.21.10 → 0.21.12

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 (157) 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 +103 -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/agent-executor.js +11 -2
  18. package/dist/engine/agent-executor.js.map +1 -1
  19. package/dist/engine/executors/orchestrator.d.ts +2 -1
  20. package/dist/engine/executors/orchestrator.js +158 -62
  21. package/dist/engine/executors/orchestrator.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 +52 -13
  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/telemetry/index.d.ts +11 -0
  127. package/dist/telemetry/index.js +38 -1
  128. package/dist/telemetry/index.js.map +1 -1
  129. package/dist/telemetry/openinference.d.ts +70 -0
  130. package/dist/telemetry/openinference.js +81 -0
  131. package/dist/telemetry/openinference.js.map +1 -0
  132. package/dist/telemetry/pi-events.d.ts +30 -0
  133. package/dist/telemetry/pi-events.js +216 -2
  134. package/dist/telemetry/pi-events.js.map +1 -1
  135. package/dist/workflows/admission.d.ts +12 -0
  136. package/dist/workflows/admission.js +13 -2
  137. package/dist/workflows/admission.js.map +1 -1
  138. package/dist/workflows/handlers/post-review.d.ts +21 -0
  139. package/dist/workflows/handlers/post-review.js +56 -13
  140. package/dist/workflows/handlers/post-review.js.map +1 -1
  141. package/dist/workflows/resume.js +6 -0
  142. package/dist/workflows/resume.js.map +1 -1
  143. package/dist/workflows/runner.d.ts +3 -1
  144. package/dist/workflows/runner.js +73 -15
  145. package/dist/workflows/runner.js.map +1 -1
  146. package/dist/workflows/simple.d.ts +13 -1
  147. package/dist/workflows/simple.js +37 -4
  148. package/dist/workflows/simple.js.map +1 -1
  149. package/package.json +19 -18
  150. package/skills/issue-triage/SKILL.md +17 -0
  151. package/workflows/cron-review.yaml +14 -1
  152. package/workflows/issue-triage.yaml +6 -0
  153. package/deploy/k8s/deployment.yaml +0 -63
  154. package/deploy/k8s/generic-device-plugin.yaml +0 -63
  155. package/deploy/k8s/namespace.yaml +0 -10
  156. package/deploy/k8s/pvc.yaml +0 -13
  157. package/deploy/k8s/service.yaml +0 -12
@@ -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;AAE1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ernetes/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>;
@@ -0,0 +1,43 @@
1
+ import { PassThrough } from "node:stream";
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 function streamPodLog(log, namespace, pod, container, onLine) {
5
+ return new Promise((resolve, reject) => {
6
+ const stream = new PassThrough();
7
+ let buf = "";
8
+ stream.setEncoding("utf-8");
9
+ stream.on("data", (chunk) => {
10
+ buf += chunk;
11
+ let nl;
12
+ while ((nl = buf.indexOf("\n")) >= 0) {
13
+ const line = buf.slice(0, nl);
14
+ buf = buf.slice(nl + 1);
15
+ if (line.length > 0) {
16
+ try {
17
+ onLine(line);
18
+ }
19
+ catch {
20
+ /* swallow listener errors */
21
+ }
22
+ }
23
+ }
24
+ });
25
+ stream.on("end", () => {
26
+ if (buf.length > 0) {
27
+ try {
28
+ onLine(buf);
29
+ }
30
+ catch {
31
+ /* swallow listener errors */
32
+ }
33
+ }
34
+ resolve();
35
+ });
36
+ stream.on("error", reject);
37
+ // follow: stream until the container terminates. log() resolves with an
38
+ // AbortController once the request is established; we don't need it here
39
+ // since resolution/rejection is driven by the stream's own end/error events.
40
+ log.log(namespace, pod, container, stream, { follow: true, pretty: false }).catch(reject);
41
+ });
42
+ }
43
+ //# sourceMappingURL=log-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-stream.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/log-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C;oFACoF;AACpF,MAAM,UAAU,YAAY,CAC1B,GAAQ,EACR,SAAiB,EACjB,GAAW,EACX,SAAiB,EACjB,MAA8B;IAE9B,OAAO,IA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,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Rfc1123Label } from "./resource-name.js";
2
+ /** RFC-1123 label: lowercase alnum + '-', ≤63 chars, starts/ends alnum.
3
+ * We slug the taskId and append a short stable hash to guarantee uniqueness
4
+ * after truncation. Budget also reserves room for the creds/prompt Secret
5
+ * name suffix (see `SECRET_SUFFIX_BUDGET`), so the derived Secret name stays
6
+ * a valid RFC-1123 label too. Returns the `Rfc1123Label` itself, not a bare
7
+ * string: `secretNameFor` (secret.ts) takes exactly this type, so "a Secret
8
+ * name is only ever derived from a pod name" is a compile-time fact (F6),
9
+ * not a comment callers can route around with an arbitrary string. Callers
10
+ * that need the raw pod name (manifests, log-stream calls, …) read
11
+ * `.value`. */
12
+ export declare function podNameFor(taskId: string, phaseSuffix?: string): Rfc1123Label;
13
+ /** RFC-1123 label VALUE: `[a-zA-Z0-9._-]`, ≤63 chars. Unlike `podNameFor`'s
14
+ * label NAME rules this allows uppercase and `.` — but we lowercase anyway so
15
+ * the pod and PVC (and later the reclaim run-selector) compare byte-for-byte
16
+ * regardless of the source runId's casing. Its character class differs from
17
+ * {@link Rfc1123Label}'s NAME rules (dots/underscores stay), so it keeps its
18
+ * own sanitizer rather than routing through the shared slug. */
19
+ export declare function sanitizeLabelValue(v: string): string;
@@ -0,0 +1,35 @@
1
+ import { createHash } from "node:crypto";
2
+ import { Rfc1123Label } from "./resource-name.js";
3
+ /** Longest suffix `secretNameFor` (secret.ts) appends to a pod name:
4
+ * "-prompt" (7 chars). Reserve room for it (+1 margin) so a pod name at the
5
+ * cap never produces an invalid (>63-char) Secret name. `secretNameFor`'s
6
+ * `Rfc1123Label.withSuffix` call (F6) is the runtime backstop if this
7
+ * budget is ever wrong — it throws instead of silently emitting a >63-char
8
+ * Secret name. */
9
+ const SECRET_SUFFIX_BUDGET = 8;
10
+ /** RFC-1123 label: lowercase alnum + '-', ≤63 chars, starts/ends alnum.
11
+ * We slug the taskId and append a short stable hash to guarantee uniqueness
12
+ * after truncation. Budget also reserves room for the creds/prompt Secret
13
+ * name suffix (see `SECRET_SUFFIX_BUDGET`), so the derived Secret name stays
14
+ * a valid RFC-1123 label too. Returns the `Rfc1123Label` itself, not a bare
15
+ * string: `secretNameFor` (secret.ts) takes exactly this type, so "a Secret
16
+ * name is only ever derived from a pod name" is a compile-time fact (F6),
17
+ * not a comment callers can route around with an arbitrary string. Callers
18
+ * that need the raw pod name (manifests, log-stream calls, …) read
19
+ * `.value`. */
20
+ export function podNameFor(taskId, phaseSuffix = "run") {
21
+ const hash = createHash("sha1").update(`${taskId}/${phaseSuffix}`).digest("hex").slice(0, 8);
22
+ const maxLength = Rfc1123Label.MAX_LENGTH - 1 - hash.length - SECRET_SUFFIX_BUDGET;
23
+ const base = Rfc1123Label.slug(`${taskId}-${phaseSuffix}`, { prefix: "ll-", maxLength });
24
+ return base.withSuffix(hash);
25
+ }
26
+ /** RFC-1123 label VALUE: `[a-zA-Z0-9._-]`, ≤63 chars. Unlike `podNameFor`'s
27
+ * label NAME rules this allows uppercase and `.` — but we lowercase anyway so
28
+ * the pod and PVC (and later the reclaim run-selector) compare byte-for-byte
29
+ * regardless of the source runId's casing. Its character class differs from
30
+ * {@link Rfc1123Label}'s NAME rules (dots/underscores stay), so it keeps its
31
+ * own sanitizer rather than routing through the shared slug. */
32
+ export function sanitizeLabelValue(v) {
33
+ return v.toLowerCase().replace(/[^a-z0-9._-]/g, "-").slice(0, Rfc1123Label.MAX_LENGTH);
34
+ }
35
+ //# sourceMappingURL=naming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../src/sandbox/k8s/naming.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;mBAKmB;AACnB,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAE/B;;;;;;;;;gBASgB;AAChB,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,WAAW,GAAG,KAAK;IAC5D,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7F,MAAM,SAAS,GAAG,YAAY,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC;IACnF,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACzF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;iEAKiE;AACjE,MAAM,UAAU,kBAAkB,CAAC,CAAS;IAC1C,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;AACzF,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { CoreV1Api } from "@kubernetes/client-node";
2
+ /**
3
+ * Resolve a finished pod to its real exit code + deadline flag. The log
4
+ * stream closing does not guarantee the API-visible status has left
5
+ * `Running` (kubelet status-sync lag), so we poll `readNamespacedPodStatus`
6
+ * until the pod is terminal (see {@link terminalResult}), then read the
7
+ * container's `terminated.exitCode`. The loop is bounded (~15 × 500ms ≈ 8s)
8
+ * so a stuck status never hangs the command; on exhaustion we fall back to
9
+ * the coarse phase-based result.
10
+ */
11
+ export declare function awaitPodResult(core: CoreV1Api, ns: string, name: string): Promise<{
12
+ exitCode: number;
13
+ timedOut: boolean;
14
+ }>;
15
+ /**
16
+ * Wait until the pod's container has started so the kubelet log endpoint is
17
+ * available. `Log.log(follow)` returns HTTP 400 while the container is still
18
+ * `waiting` (Pending / ContainerCreating / image pull), so streaming
19
+ * immediately after create races the scheduler. See {@link containerStartState}
20
+ * for what counts as "started" vs a fatal `waiting` reason — a terminal
21
+ * image/config error fails fast with its real reason rather than waiting out
22
+ * the budget, so the failure is debuggable instead of a cryptic 400. A failed
23
+ * clone initContainer is checked on every poll too (see
24
+ * {@link checkInitContainerFailure}) — otherwise the main container just sits
25
+ * at `PodInitializing` for the whole budget while the real `git clone`
26
+ * failure sits unreported in `initContainerStatuses`.
27
+ */
28
+ export declare function waitForContainerStart(core: CoreV1Api, ns: string, name: string): Promise<void>;
29
+ /**
30
+ * Poll after a successful pod delete until the API 404s it, so the RWO PVC
31
+ * (an RWO block/local StorageClass such as the cluster default allows only
32
+ * one attached node) is actually released before `dispose` returns — a
33
+ * sequential next-phase pod reusing the same PVC on a different node would
34
+ * otherwise race the still-attaching volume and hit Multi-Attach. A 404 on
35
+ * the very first poll (pod already gone)
36
+ * succeeds immediately. Best-effort like the delete above: any non-404
37
+ * read error is treated as "not yet confirmed gone" and just retried
38
+ * within the budget, never failing the caller's `dispose()`.
39
+ */
40
+ export declare function waitForPodGone(core: CoreV1Api, ns: string, name: string): Promise<void>;