@opengeni/worker-bundle 6.7.0 → 6.8.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.
@@ -20,6 +20,21 @@ import { SecretValueMemory, type SecretPrincipal, type SecretResolver } from "@o
20
20
  import { type Database } from "@opengeni/db";
21
21
  type DiagnosticSink = {
22
22
  warn(message: string, attributes?: Record<string, unknown>): void;
23
+ incrementCounter?(input: {
24
+ name: string;
25
+ help?: string;
26
+ labels?: Record<string, string>;
27
+ amount?: number;
28
+ }): void;
29
+ };
30
+ /**
31
+ * Occurrences of known secret values, by outcome (masked, or kept because a
32
+ * weak value was outside a credential position), value strength, entropy
33
+ * bucket and position. Metrics only: never the value or the text.
34
+ */
35
+ export declare const SECRET_MASK_MATCHES_METRIC: {
36
+ readonly name: "opengeni_secret_mask_matches_total";
37
+ readonly help: "Known secret value occurrences in masked text, by outcome, value strength, entropy bucket and position.";
23
38
  };
24
39
  export declare function createAttemptSecretValueMemory(observability?: DiagnosticSink | null): SecretValueMemory;
25
40
  /**
@@ -20,7 +20,7 @@ import {
20
20
  withFirstPartyTools,
21
21
  workflowIdForSession,
22
22
  writeSessionUsageReceipts
23
- } from "./chunk-Q4KXCK36.js";
23
+ } from "./chunk-ZEGN4DC4.js";
24
24
  import "./chunk-5E7CLEQM.js";
25
25
  import {
26
26
  createSiteAuthMaintenanceActivities
@@ -28,13 +28,13 @@ import {
28
28
  import {
29
29
  createBrowserDeadlineCheckpointActivities,
30
30
  createSandboxLeaseActivities
31
- } from "./chunk-C5RYXGXF.js";
32
- import "./chunk-XTG32O4Q.js";
31
+ } from "./chunk-WLNVZWDL.js";
32
+ import "./chunk-YJDTWP6V.js";
33
33
  import "./chunk-BKPKTXFV.js";
34
34
  import {
35
35
  recordTurnsQueuedGauge,
36
36
  recordWorkerDeathRecoveryMetrics
37
- } from "./chunk-W2IHRF7L.js";
37
+ } from "./chunk-UQAMEFZB.js";
38
38
  import {
39
39
  deliverFailedChildTurnToParent,
40
40
  notifyParentOfChildIdle,
@@ -8961,4 +8961,4 @@ export {
8961
8961
  createControlActivities,
8962
8962
  createControlActivitiesFromServices
8963
8963
  };
8964
- //# sourceMappingURL=activities-control-LJVIL5FP.js.map
8964
+ //# sourceMappingURL=activities-control-6HEEWPLL.js.map
@@ -120,7 +120,7 @@ import {
120
120
  wakeSubscriptionCoreWaitersAndDeliver,
121
121
  withFirstPartyTools,
122
122
  withModelRoutePresentation
123
- } from "./chunk-Q4KXCK36.js";
123
+ } from "./chunk-ZEGN4DC4.js";
124
124
  import "./chunk-5E7CLEQM.js";
125
125
  import {
126
126
  agentBackgroundCommandDeps,
@@ -134,7 +134,7 @@ import {
134
134
  waitForWarmSnapshot,
135
135
  wrapLazyTurnBoxWithRouting,
136
136
  wrapTurnBoxWithRouting
137
- } from "./chunk-XTG32O4Q.js";
137
+ } from "./chunk-YJDTWP6V.js";
138
138
  import {
139
139
  StreamTimingMetrics,
140
140
  codexRequestTransportLabel,
@@ -173,7 +173,7 @@ import {
173
173
  runtimeMetricsHooksForObservability,
174
174
  sandboxAutomaticRecoveryOutcome,
175
175
  turnLifecycleMetricsFor
176
- } from "./chunk-W2IHRF7L.js";
176
+ } from "./chunk-UQAMEFZB.js";
177
177
  import {
178
178
  deliverChildRequiresActionToParent,
179
179
  deliverFailedChildTurnToParent
@@ -216,13 +216,36 @@ import {
216
216
  import {
217
217
  rememberingSecretResolver,
218
218
  SecretValueMemory,
219
+ credentialNameMayHoldSecret,
219
220
  secretCredentialMaskLabel
220
221
  } from "@opengeni/contracts";
221
222
  import { createTaskVaultSecretCapturer, loadSessionTreeSecretValues } from "@opengeni/core";
222
223
  import { withSecretValueMasking } from "@opengeni/db";
223
224
  import { activeAttemptSecretValues, withAttemptSecretValues } from "@opengeni/runtime";
225
+ var SECRET_MASK_MATCHES_METRIC = {
226
+ name: "opengeni_secret_mask_matches_total",
227
+ help: "Known secret value occurrences in masked text, by outcome, value strength, entropy bucket and position."
228
+ };
229
+ function recordMaskMatch(observability) {
230
+ return (event) => {
231
+ try {
232
+ observability?.incrementCounter?.({
233
+ ...SECRET_MASK_MATCHES_METRIC,
234
+ labels: {
235
+ outcome: event.outcome,
236
+ strength: event.strength,
237
+ entropy: event.entropy,
238
+ position: event.position
239
+ },
240
+ amount: event.count
241
+ });
242
+ } catch {
243
+ }
244
+ };
245
+ }
224
246
  function createAttemptSecretValueMemory(observability) {
225
247
  return new SecretValueMemory({
248
+ ...observability?.incrementCounter ? { onMatch: recordMaskMatch(observability) } : {},
226
249
  onDiagnostic: (diagnostic) => {
227
250
  try {
228
251
  observability?.warn("secret value masking failed; text kept as written", {
@@ -253,16 +276,14 @@ function rememberAttemptCredential(memory, value, kind) {
253
276
  function rememberingAttemptSecretResolver(resolver, memory) {
254
277
  return rememberingSecretResolver(resolver, () => memory ?? currentAttemptSecretValues());
255
278
  }
256
- var SECRET_ENVIRONMENT_NAME = /TOKEN|SECRET|PASSW|PWD|KEY|CREDENTIAL|AUTH|SESSION|COOKIE|BEARER|PRIVATE|SIGNATURE/iu;
257
279
  var CREDENTIAL_LOCATION_NAME = /(?:_FILE|_PATH|_DIR|_URL|_ENDPOINT)$|^GOOGLE_APPLICATION_CREDENTIALS$/iu;
258
280
  var PATH_VALUE = /^(?:\/|\.{1,2}\/|~\/|[A-Za-z]:\\)[^\s]*$/u;
259
- var SECRET_HEADER_NAME = /^(?:authorization|proxy-authorization|cookie)$|token|key|secret|auth|passw|session|signature/iu;
260
281
  var RUN_CREDENTIAL_MIN_CHARS = 12;
261
282
  function rememberRunCredentialMaterial(memory, material) {
262
283
  if (!memory || !material) return;
263
284
  try {
264
285
  for (const [name, value] of Object.entries(material.environment ?? {})) {
265
- if (typeof value === "string" && value.length >= RUN_CREDENTIAL_MIN_CHARS && SECRET_ENVIRONMENT_NAME.test(name) && !CREDENTIAL_LOCATION_NAME.test(name) && !PATH_VALUE.test(value)) {
286
+ if (typeof value === "string" && value.length >= RUN_CREDENTIAL_MIN_CHARS && credentialNameMayHoldSecret(name) && !CREDENTIAL_LOCATION_NAME.test(name) && !PATH_VALUE.test(value)) {
266
287
  rememberAttemptCredential(memory, value, `run credential ${name}`);
267
288
  }
268
289
  }
@@ -274,7 +295,7 @@ function rememberRunCredentialMaterial(memory, material) {
274
295
  }
275
296
  for (const entry of material.mcp ?? []) {
276
297
  for (const [name, value] of Object.entries(entry?.headers ?? {})) {
277
- if (typeof value === "string" && value.length >= RUN_CREDENTIAL_MIN_CHARS && SECRET_HEADER_NAME.test(name)) {
298
+ if (typeof value === "string" && value.length >= RUN_CREDENTIAL_MIN_CHARS && credentialNameMayHoldSecret(name)) {
278
299
  rememberAttemptCredential(memory, value, "mcp header");
279
300
  }
280
301
  }
@@ -34836,6 +34857,7 @@ async function establishTurnSandbox(deps) {
34836
34857
  onOp: machineOpObserver.observer,
34837
34858
  onSandboxOperation: sandboxOperationObserver,
34838
34859
  onSandboxCaptureWait: sandboxCaptureWaitMetricObserver(observability),
34860
+ observability,
34839
34861
  opJournal
34840
34862
  },
34841
34863
  {
@@ -34903,6 +34925,7 @@ async function establishTurnSandbox(deps) {
34903
34925
  onOp: machineOpObserver.observer,
34904
34926
  onSandboxOperation: sandboxOperationObserver,
34905
34927
  onSandboxCaptureWait: sandboxCaptureWaitMetricObserver(observability),
34928
+ observability,
34906
34929
  onHomeSandboxRebound,
34907
34930
  ...runtimeCancellationSignal ? { waitSignal: runtimeCancellationSignal } : {}
34908
34931
  },
@@ -34929,17 +34952,7 @@ async function establishTurnSandbox(deps) {
34929
34952
  pinnedSelfhosted: {
34930
34953
  sandboxId: activeSandboxPointer.activeSandboxId,
34931
34954
  epoch: activeSandboxPointer.activeEpoch
34932
- },
34933
- // HOME semantics for a mid-turn clear-to-null: only a genuine
34934
- // machine-HOME session (its home IS this machine, session.sandboxBackend
34935
- // === "selfhosted") resolves null back to the pinned machine. A Modal-HOME
34936
- // session merely PINNED to a machine this turn never established its group
34937
- // box, so defaultIsHome:false makes a clear-to-null fail typed
34938
- // (`home_unavailable_this_turn`) rather than silently serving the machine.
34939
- // Failure settlement checkpoints the completed detach and continues the same
34940
- // logical turn in a fresh home-primary attempt; it never serves this machine
34941
- // after the pointer changed and never invents a cloud lease for machine-only work.
34942
- defaultIsHome: session.sandboxBackend === "selfhosted"
34955
+ }
34943
34956
  },
34944
34957
  established
34945
34958
  ),
@@ -35136,6 +35149,7 @@ async function establishTurnSandbox(deps) {
35136
35149
  opJournal,
35137
35150
  onSandboxOperation: sandboxOperationObserver,
35138
35151
  onSandboxCaptureWait: sandboxCaptureWaitMetricObserver(observability),
35152
+ observability,
35139
35153
  onHomeSandboxLost: publishSandboxLost,
35140
35154
  onHomeSandboxRebound,
35141
35155
  ...runtimeCancellationSignal ? { waitSignal: runtimeCancellationSignal } : {}
@@ -35495,6 +35509,7 @@ async function bindLazySandboxProvisioner(deps) {
35495
35509
  onOp: machineOpObserver.observer,
35496
35510
  onSandboxOperation: sandboxOperationObserver,
35497
35511
  onSandboxCaptureWait: sandboxCaptureWaitMetricObserver(observability),
35512
+ observability,
35498
35513
  onHomeSandboxLost: publishSandboxLost,
35499
35514
  onHomeSandboxRebound,
35500
35515
  ...runtimeCancellationSignal ? { waitSignal: runtimeCancellationSignal } : {}
@@ -46756,4 +46771,4 @@ export {
46756
46771
  createTurnActivities,
46757
46772
  createTurnActivitiesFromServices
46758
46773
  };
46759
- //# sourceMappingURL=activities-turn-GTZPMF6T.js.map
46774
+ //# sourceMappingURL=activities-turn-E6VP3XVJ.js.map