@opengeni/core 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/core",
3
- "version": "6.7.0",
3
+ "version": "6.8.0",
4
4
  "description": "Opengeni framework-agnostic core: the domain, access, and billing layers (neutral access, off-HTTP V2 surface). Behavior-preserving extraction from apps/api — keeps Hono's HTTPException for error throwing (typed-errors cleanup deferred).",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -55,20 +55,20 @@
55
55
  "dependencies": {
56
56
  "@modelcontextprotocol/client": "2.3.1",
57
57
  "@modelcontextprotocol/sdk": "^1.29.0",
58
- "@opengeni/capabilities": "6.7.0",
59
- "@opengeni/codex": "6.7.0",
60
- "@opengeni/config": "6.7.0",
61
- "@opengeni/contracts": "6.7.0",
62
- "@opengeni/db": "6.7.0",
63
- "@opengeni/documents": "6.7.0",
64
- "@opengeni/events": "6.7.0",
65
- "@opengeni/network": "6.7.0",
66
- "@opengeni/observability": "6.7.0",
67
- "@opengeni/runtime": "6.7.0",
68
- "@opengeni/storage": "6.7.0",
69
- "@opengeni/tool-gateway": "6.7.0",
70
- "@opengeni/vaults": "6.7.0",
71
- "@opengeni/xai-subscription": "6.7.0",
58
+ "@opengeni/capabilities": "6.8.0",
59
+ "@opengeni/codex": "6.8.0",
60
+ "@opengeni/config": "6.8.0",
61
+ "@opengeni/contracts": "6.8.0",
62
+ "@opengeni/db": "6.8.0",
63
+ "@opengeni/documents": "6.8.0",
64
+ "@opengeni/events": "6.8.0",
65
+ "@opengeni/network": "6.8.0",
66
+ "@opengeni/observability": "6.8.0",
67
+ "@opengeni/runtime": "6.8.0",
68
+ "@opengeni/storage": "6.8.0",
69
+ "@opengeni/tool-gateway": "6.8.0",
70
+ "@opengeni/vaults": "6.8.0",
71
+ "@opengeni/xai-subscription": "6.8.0",
72
72
  "hono": "^4.12.18",
73
73
  "zod": "^4.2.1"
74
74
  },
@@ -40,6 +40,10 @@ export function secretRedactionReferenceLabel(reference: Pick<SecretReference, "
40
40
  * so a run with a one-character or all-blank "secret" can never rewrite
41
41
  * everything. Also null for a value holding marker-shaped text, which the
42
42
  * scrub could never find.
43
+ *
44
+ * A person asked for this value to be removed from stored history, so a
45
+ * weak value (a word, a host) is removed wherever it appears too, not only
46
+ * in credential positions as live masking does.
43
47
  */
44
48
  export function secretRedactionMatcherForValue(
45
49
  value: string,
@@ -49,7 +53,7 @@ export function secretRedactionMatcherForValue(
49
53
  if (containsSecretRedactionMarker(value)) return null;
50
54
  if (secretValueForms(value, { minChars: SECRET_VALUE_MASK_MIN_CHARS }).length === 0) return null;
51
55
  const marker = secretRedactionMarker(label);
52
- const masks = compileSecretValueMasks([{ value, label: marker }]);
56
+ const masks = compileSecretValueMasks([{ value, label: marker }], { weakValues: "anywhere" });
53
57
  return { marker, redact: (text) => maskSecretValuesInText(text, masks) };
54
58
  }
55
59
 
@@ -6,6 +6,7 @@ import {
6
6
  isDirectModelId,
7
7
  MESSAGE_TIME_ZONE_METADATA_KEY,
8
8
  messageSentByPerson,
9
+ ModelPolicyRefusedError,
9
10
  ModelUnavailableError,
10
11
  normalizeMessageTimeZone,
11
12
  } from "@opengeni/contracts";
@@ -1930,13 +1931,16 @@ export async function assertWorkspaceModelPolicyAllows(
1930
1931
  chargesCredits: policyChargesCreditsForModel(settings, canonicalModel),
1931
1932
  });
1932
1933
  if (!verdict.allowed) {
1934
+ const message =
1935
+ verdict.reason === "credits"
1936
+ ? `model "${canonicalModel}" uses credits, which are turned off in this workspace. Choose a model paid by a subscription or API key, or ask a workspace admin to turn credits back on`
1937
+ : verdict.reason === "provider"
1938
+ ? `model "${canonicalModel}" is not allowed by this workspace's model policy: provider "${providerId}" is not in the allowed providers`
1939
+ : `model "${canonicalModel}" is not allowed by this workspace's model policy`;
1940
+ // Typed, so a refused new chat can say which rule in words a person reads.
1933
1941
  throw new HTTPException(422, {
1934
- message:
1935
- verdict.reason === "credits"
1936
- ? `model "${canonicalModel}" uses credits, which are turned off in this workspace. Choose a model paid by a subscription or API key, or ask a workspace admin to turn credits back on`
1937
- : verdict.reason === "provider"
1938
- ? `model "${canonicalModel}" is not allowed by this workspace's model policy: provider "${providerId}" is not in the allowed providers`
1939
- : `model "${canonicalModel}" is not allowed by this workspace's model policy`,
1942
+ message,
1943
+ cause: new ModelPolicyRefusedError(canonicalModel, verdict.reason, message),
1940
1944
  });
1941
1945
  }
1942
1946
  }
@@ -3607,7 +3611,12 @@ async function createSessionForRequestInFileScope(
3607
3611
  : {}),
3608
3612
  });
3609
3613
  if (!admissibleWorkspaceModel(selections, model)) {
3610
- throw new HTTPException(422, { message: `model is not selectable: ${model}` });
3614
+ // Typed as unavailable (it is not selectable for this caller), so the
3615
+ // composer names it instead of showing this developer text.
3616
+ throw new HTTPException(422, {
3617
+ message: `model is not selectable: ${model}`,
3618
+ cause: new ModelUnavailableError(model),
3619
+ });
3611
3620
  }
3612
3621
  }
3613
3622
  });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The save-time nudge for plain fields (docs/secrets.md, Field kinds). A
3
+ * value that looks like a secret in a field that would be saved as `text`
4
+ * is saved as `concealed` when nobody chose the kind (a new field whose
5
+ * default is text), and kept as text with a note when `text` was asked for,
6
+ * the field already is text, or it is a standard text field of the item's
7
+ * type (a login's `username`). Only saves that report notes (the agent's
8
+ * `secret_save`) are nudged: without `notes` the kind is unchanged, so a
9
+ * kind never changes silently. Nothing here refuses a save.
10
+ */
11
+ import {
12
+ plainFieldSecretHint,
13
+ type SecretSaveFieldNote,
14
+ type VaultFieldKind,
15
+ } from "@opengeni/contracts";
16
+
17
+ export function plainFieldKind(
18
+ input: { name: string; value: string; kind: VaultFieldKind; chosen: boolean },
19
+ notes: SecretSaveFieldNote[] | undefined,
20
+ ): VaultFieldKind {
21
+ if (notes === undefined || input.kind !== "text") return input.kind;
22
+ const hint = plainFieldSecretHint(input.name, input.value);
23
+ if (!hint) return input.kind;
24
+ if (input.chosen) {
25
+ notes?.push({
26
+ field: input.name,
27
+ kind: "text",
28
+ reason: hint.reason,
29
+ message: `${hint.message} Kept as text; save it with kind "concealed" if it is a secret.`,
30
+ });
31
+ return "text";
32
+ }
33
+ notes?.push({
34
+ field: input.name,
35
+ kind: "concealed",
36
+ reason: hint.reason,
37
+ message: `${hint.message} Saved as concealed; save it with kind "text" if it is not a secret.`,
38
+ });
39
+ return "concealed";
40
+ }
@@ -4,6 +4,7 @@ import {
4
4
  isValidTotpInput,
5
5
  secretNameKey,
6
6
  VAULT_LIMITS,
7
+ type SecretSaveFieldNote,
7
8
  type VaultFieldInput,
8
9
  type VaultFieldKind,
9
10
  type VaultItemType,
@@ -33,6 +34,7 @@ import {
33
34
  storedProviderOperations,
34
35
  withoutProviderWrites,
35
36
  } from "./mapping";
37
+ import { plainFieldKind } from "./plain-field-hints";
36
38
  import { vaultErrorCodeForProvider } from "./provider-registry";
37
39
  import { syncLinkedProviderVault, type ProviderVaultSyncResult } from "./provider-sync";
38
40
  import { prepareTypedFields, standardFieldKind } from "./typed-fields";
@@ -329,9 +331,11 @@ function fileContent(input: ProviderFieldChange, current: VaultFieldRow | undefi
329
331
  }
330
332
 
331
333
  async function providerFieldValues(
334
+ type: VaultItemType,
332
335
  planned: readonly PlannedField[],
333
336
  resolveReference: (raw: string) => Promise<string>,
334
337
  generated: string[],
338
+ fieldNotes?: SecretSaveFieldNote[],
335
339
  ): Promise<ProviderWriteField[]> {
336
340
  const writes: ProviderWriteField[] = [];
337
341
  for (const { input, base, kind, current } of planned) {
@@ -360,7 +364,19 @@ async function providerFieldValues(
360
364
  }
361
365
  value = value.trim();
362
366
  }
363
- writes.push({ ...base, value });
367
+ const saved = plainFieldKind(
368
+ {
369
+ name: input.name,
370
+ value,
371
+ kind,
372
+ chosen:
373
+ input.kind !== undefined ||
374
+ current !== undefined ||
375
+ standardFieldKind(type, input.name) === "text",
376
+ },
377
+ fieldNotes,
378
+ );
379
+ writes.push({ ...base, kind: saved, value });
364
380
  }
365
381
  return writes;
366
382
  }
@@ -474,6 +490,8 @@ export async function writeProviderVaultItemOutcome(
474
490
  change: ProviderItemChange;
475
491
  /** Receives the names of fields whose values were generated. */
476
492
  generated?: string[];
493
+ /** Receives a note for each plain field whose value looks like a secret. */
494
+ fieldNotes?: SecretSaveFieldNote[];
477
495
  },
478
496
  ): Promise<ProviderWriteOutcome> {
479
497
  const { vault, existing, change } = input;
@@ -531,7 +549,13 @@ export async function writeProviderVaultItemOutcome(
531
549
  ),
532
550
  existing?.fields ?? [],
533
551
  );
534
- const fields = await providerFieldValues(planned, deps.resolveReference, input.generated ?? []);
552
+ const fields = await providerFieldValues(
553
+ type,
554
+ planned,
555
+ deps.resolveReference,
556
+ input.generated ?? [],
557
+ input.fieldNotes,
558
+ );
535
559
  const name = change.name ?? existing?.name ?? "";
536
560
  const category = change.category !== undefined ? change.category : (existing?.category ?? null);
537
561
  let written;
@@ -29,6 +29,7 @@ import {
29
29
  type SecretMoveInput,
30
30
  type SecretMoveOutput,
31
31
  type SecretPrincipal,
32
+ type SecretSaveFieldNote,
32
33
  type SecretSaveInput,
33
34
  type SecretSaveOutput,
34
35
  type SecretSearchInput,
@@ -98,6 +99,7 @@ import {
98
99
  type VaultCallerAuthority,
99
100
  } from "./mapping";
100
101
  import { vaultErrorCodeForProvider } from "./provider-registry";
102
+ import { plainFieldKind } from "./plain-field-hints";
101
103
  import {
102
104
  LINKED_VAULT_OPEN_WAIT_MS,
103
105
  LINKED_VAULT_SEARCH_MAX_AGE_MS,
@@ -348,6 +350,7 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
348
350
  type: VaultItemType,
349
351
  resolveReference: (raw: string) => Promise<string>,
350
352
  generated: string[],
353
+ fieldNotes?: SecretSaveFieldNote[],
351
354
  ): Promise<VaultFieldWrite> {
352
355
  const current = existing?.fields.find(
353
356
  (field) =>
@@ -381,6 +384,18 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
381
384
  plaintext = input.value ?? "";
382
385
  size = utf8Size(plaintext);
383
386
  }
387
+ kind = plainFieldKind(
388
+ {
389
+ name: input.name,
390
+ value: plaintext,
391
+ kind,
392
+ chosen:
393
+ input.kind !== undefined ||
394
+ current !== undefined ||
395
+ standardFieldKind(type, input.name) === "text",
396
+ },
397
+ fieldNotes,
398
+ );
384
399
  if (kind === "totp") {
385
400
  if (!isValidTotpInput(plaintext)) {
386
401
  throw new VaultError(
@@ -461,6 +476,7 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
461
476
  resolveReference: (raw: string) => Promise<string>,
462
477
  createdBy: VaultVersionCreatedByKind,
463
478
  generated: string[] = [],
479
+ fieldNotes?: SecretSaveFieldNote[],
464
480
  ): Promise<VaultItemWrite> {
465
481
  const write: VaultItemWrite = { createdByKind: createdBy };
466
482
  if (req.name !== undefined) write.name = req.name;
@@ -474,7 +490,9 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
474
490
  const fields = await prepareTypedFields(type, req.fields, resolveReference, generated);
475
491
  write.fields = [];
476
492
  for (const field of fields) {
477
- write.fields.push(await fieldWrite(field, existing, type, resolveReference, generated));
493
+ write.fields.push(
494
+ await fieldWrite(field, existing, type, resolveReference, generated, fieldNotes),
495
+ );
478
496
  }
479
497
  }
480
498
  return write;
@@ -1414,6 +1432,8 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
1414
1432
  fields.unshift({ name: "username", kind: "text", value: input.username });
1415
1433
  }
1416
1434
  const generated: string[] = [];
1435
+ const fieldNotes: SecretSaveFieldNote[] = [];
1436
+ const notes = () => (fieldNotes.length > 0 ? { fieldNotes } : {});
1417
1437
  if (vault.source !== "opengeni") {
1418
1438
  // W5: secret_save into a read-write connected vault writes through its provider.
1419
1439
  const itemId = await writeProviderVaultItem(
@@ -1443,6 +1463,7 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
1443
1463
  fields,
1444
1464
  },
1445
1465
  generated,
1466
+ fieldNotes,
1446
1467
  },
1447
1468
  );
1448
1469
  const saved = await getVaultItem(deps.db, context, { itemId });
@@ -1450,6 +1471,7 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
1450
1471
  item: toVaultItemSummary(saved, key()),
1451
1472
  references: vaultItemReferences(saved),
1452
1473
  generatedFields: generated,
1474
+ ...notes(),
1453
1475
  };
1454
1476
  }
1455
1477
  const write = await itemWrite(
@@ -1463,6 +1485,7 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
1463
1485
  (raw) => resolveTextReference(principal, raw, "secret_save"),
1464
1486
  "agent",
1465
1487
  generated,
1488
+ fieldNotes,
1466
1489
  );
1467
1490
  const row = await upsertVaultItem(
1468
1491
  deps.db,
@@ -1472,7 +1495,12 @@ export function createVaultService(deps: VaultServiceDeps): VaultService {
1472
1495
  : { ...write, vaultId: vault.id, mode: "create" },
1473
1496
  );
1474
1497
  const summary = toVaultItemSummary(row, key());
1475
- return { item: summary, references: vaultItemReferences(row), generatedFields: generated };
1498
+ return {
1499
+ item: summary,
1500
+ references: vaultItemReferences(row),
1501
+ generatedFields: generated,
1502
+ ...notes(),
1503
+ };
1476
1504
  },
1477
1505
 
1478
1506
  async captureForAgent(principal, input) {