@opengeni/runtime 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,6 +144,28 @@ export interface SelfhostedImageOutput {
144
144
  * (the turn pauses + retries); it is NOT a hard failure. */
145
145
  export const SELFHOSTED_DEFAULT_TIMEOUT_MS = 30_000;
146
146
 
147
+ /**
148
+ * The ONLY manifest-environment keys exported into a selfhosted machine's exec
149
+ * shell. The manifest env is otherwise NOT consumed by selfhosted exec — the
150
+ * machine owns its own environment, and pushing HOME, GIT_ vars, and the like
151
+ * onto a real computer would clobber it. The toolspace pointers are the exception:
152
+ * `ogtool` (and the token-seed hook) need the non-secret programmatic-calling URL
153
+ * and the token-FILE PATH to reach the tool surface. The token VALUE never rides
154
+ * here — it is seeded to that file off-manifest over the same exec channel.
155
+ */
156
+ const SELFHOSTED_EXEC_ENV_ALLOWLIST = ["OPENGENI_TOOLSPACE_URL", "OPENGENI_TOOLSPACE_TOKEN_FILE"] as const;
157
+
158
+ function selfhostedExecEnv(environment: Record<string, string>): Record<string, string> {
159
+ const env: Record<string, string> = {};
160
+ for (const key of SELFHOSTED_EXEC_ENV_ALLOWLIST) {
161
+ const value = environment[key];
162
+ if (value) {
163
+ env[key] = value;
164
+ }
165
+ }
166
+ return env;
167
+ }
168
+
147
169
  /** The relay-URL shape config the session needs to build a stream endpoint. M8b
148
170
  * wires the real relay deployment behind THIS seam so `buildStreamUrl` works
149
171
  * unchanged behind `resolveExposedPort`. */
@@ -181,9 +203,11 @@ export interface SelfhostedSessionDeps {
181
203
  * session delta; `validateNoEnvironmentDelta` throws "Live sandbox sessions cannot
182
204
  * change manifest environment variables" on ANY env mismatch. So `state.manifest`'s
183
205
  * `environment` MUST EQUAL the turn's environment for the delta to be empty. The
184
- * selfhosted exec routes over NATS and does NOT consume the env, but the manifest
185
- * must carry it for parity. Omitted → `{}` (the negotiation-only / test path,
186
- * which never applies a turn manifest, so there is no delta to validate).
206
+ * selfhosted exec routes over NATS and does NOT consume this env wholesale (the
207
+ * machine owns its own shell), EXCEPT the allowlisted toolspace pointers it
208
+ * exports per exec so `ogtool` works — see SELFHOSTED_EXEC_ENV_ALLOWLIST. The
209
+ * manifest carries the full env for parity. Omitted → `{}` (the negotiation-only
210
+ * / test path, which never applies a turn manifest, so there is no delta).
187
211
  */
188
212
  environment?: Record<string, string>;
189
213
  /**
@@ -340,7 +364,11 @@ export class SelfhostedSession {
340
364
  // SELFHOSTED_VIRTUAL_ROOT). Empty → the session workingDir (itself "" by
341
365
  // default ⇒ the agent runs in its workspace_root).
342
366
  cwd: toMachinePath(args.workdir, this.workingDir),
343
- env: {},
367
+ // The machine owns its own shell environment; the manifest env is NOT
368
+ // exported here. The ONE exception is the non-secret toolspace pointers
369
+ // (URL + token-file path), so a programmatic `ogtool` call and the token-
370
+ // seed hook can find the tool surface. See SELFHOSTED_EXEC_ENV_ALLOWLIST.
371
+ env: selfhostedExecEnv(this.state.environment),
344
372
  stdin: new Uint8Array(0),
345
373
  timeoutMs: 0,
346
374
  };