mindoodb 0.0.76 → 0.0.78

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 (37) hide show
  1. package/dist/browser/index.mjs +2 -0
  2. package/dist/core/BaseMindooTenant.d.ts +1 -1
  3. package/dist/core/BaseMindooTenant.d.ts.map +1 -1
  4. package/dist/core/BaseMindooTenant.js +16 -5
  5. package/dist/core/BaseMindooTenant.js.map +1 -1
  6. package/dist/core/BaseMindooTenantDirectory.d.ts +28 -1
  7. package/dist/core/BaseMindooTenantDirectory.d.ts.map +1 -1
  8. package/dist/core/BaseMindooTenantDirectory.js +53 -0
  9. package/dist/core/BaseMindooTenantDirectory.js.map +1 -1
  10. package/dist/core/accesscontrol/directoryProjection.d.ts +7 -1
  11. package/dist/core/accesscontrol/directoryProjection.d.ts.map +1 -1
  12. package/dist/core/accesscontrol/directoryProjection.js +27 -0
  13. package/dist/core/accesscontrol/directoryProjection.js.map +1 -1
  14. package/dist/core/accesscontrol/evaluate.d.ts +15 -0
  15. package/dist/core/accesscontrol/evaluate.d.ts.map +1 -1
  16. package/dist/core/accesscontrol/evaluate.js +31 -0
  17. package/dist/core/accesscontrol/evaluate.js.map +1 -1
  18. package/dist/core/accesscontrol/types.d.ts +52 -5
  19. package/dist/core/accesscontrol/types.d.ts.map +1 -1
  20. package/dist/core/accesscontrol/types.js +73 -1
  21. package/dist/core/accesscontrol/types.js.map +1 -1
  22. package/dist/core/cache/EncryptedLocalCacheStore.d.ts +20 -9
  23. package/dist/core/cache/EncryptedLocalCacheStore.d.ts.map +1 -1
  24. package/dist/core/cache/EncryptedLocalCacheStore.js +33 -27
  25. package/dist/core/cache/EncryptedLocalCacheStore.js.map +1 -1
  26. package/dist/core/index.d.ts +1 -1
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/core/index.js +7 -5
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/indexing/summary/extractSummaryFields.d.ts +2 -3
  31. package/dist/core/indexing/summary/extractSummaryFields.d.ts.map +1 -1
  32. package/dist/core/indexing/summary/extractSummaryFields.js +7 -4
  33. package/dist/core/indexing/summary/extractSummaryFields.js.map +1 -1
  34. package/dist/core/types.d.ts +22 -1
  35. package/dist/core/types.d.ts.map +1 -1
  36. package/dist/core/types.js.map +1 -1
  37. package/package.json +1 -1
@@ -1131,6 +1131,56 @@ class BaseMindooTenantDirectory {
1131
1131
  allowedDbIds: Array.isArray(policy.allowedDbIds) ? [...policy.allowedDbIds] : [],
1132
1132
  };
1133
1133
  }
1134
+ /**
1135
+ * The tenant's language-model endpoint policy (`llm` in `acl_defaultpolicy`)
1136
+ * at the current head state, or `null` when there is no default policy or no
1137
+ * `llm` block. Tenant-level only, never layered per-db.
1138
+ *
1139
+ * Like `requireMetadataSignatureSince` it does not follow the master switch
1140
+ * `disableAllAccessChecksAndPolicies`: that switch turns off access *checks*,
1141
+ * and new tenants are created with it on (only the storage-format floor
1142
+ * active), so honoring it here would make the setting inert in most tenants.
1143
+ *
1144
+ * The directory only accepts admin-signed entries, so the result is what the
1145
+ * tenant admin wrote. Enforcing it is the client's job (it decides where it
1146
+ * sends data); see {@link LlmEndpointPolicy}.
1147
+ */
1148
+ async getLlmEndpointPolicy() {
1149
+ const head = await this.getDirectoryStateHead();
1150
+ const policy = head.defaultPolicy;
1151
+ if (policy === null || !policy.llm) {
1152
+ return null;
1153
+ }
1154
+ return {
1155
+ ...(policy.llm.allowedEndpoints ? { allowedEndpoints: [...policy.llm.allowedEndpoints] } : {}),
1156
+ ...(policy.llm.defaultEndpoint ? { defaultEndpoint: policy.llm.defaultEndpoint } : {}),
1157
+ ...(policy.llm.denyUse !== undefined ? { denyUse: policy.llm.denyUse } : {}),
1158
+ };
1159
+ }
1160
+ /**
1161
+ * Whether the current user may use a client's AI assistant with this
1162
+ * tenant's data (`llm_use`, §6.9), at the directory head. The baseline is
1163
+ * `llm.denyUse`; `llm_use` allow/deny rules target users and groups like any
1164
+ * other rule. Independent of the master switch, like
1165
+ * {@link getLlmEndpointPolicy}. The tenant admin is always allowed.
1166
+ *
1167
+ * Client-enforced: a client that gets `allowed: false` must not send any of
1168
+ * this tenant's data to a language model, while it may still use the
1169
+ * assistant with other tenants' data.
1170
+ */
1171
+ async canUseLlm() {
1172
+ const currentUser = await this.tenant.getCurrentUserId();
1173
+ const adminKey = this.tenant.getAdministrationPublicKey();
1174
+ if (currentUser.userSigningPublicKey === adminKey) {
1175
+ return { allowed: true, reason: "tenant admin", tier: "tier1" };
1176
+ }
1177
+ // Head selector, NOT Date.now() — see canDo.
1178
+ const node = await this.getDirectoryStateAt(Number.MAX_SAFE_INTEGER);
1179
+ const identity = await this.identitySetForSigningKey(currentUser.userSigningPublicKey, node, {
1180
+ isAuthor: false,
1181
+ });
1182
+ return (0, evaluate_1.evaluateLlmUse)({ identity, node });
1183
+ }
1134
1184
  /**
1135
1185
  * The tenant-wide storage-format floor (`requireMetadataSignatureSince`): the
1136
1186
  * trusted-time cutoff at/after which entries must carry the v2 metadata-binding
@@ -1267,6 +1317,9 @@ class BaseMindooTenantDirectory {
1267
1317
  */
1268
1318
  async setDatabaseAccessPolicy(dbid, policy, administrationPrivateKey, administrationPrivateKeyPassword) {
1269
1319
  (0, types_3.validateAccessPolicy)(policy);
1320
+ if (policy.llm !== undefined) {
1321
+ throw new Error("llm is a tenant-level setting; set it on the default policy");
1322
+ }
1270
1323
  await this.writePolicyDoc((0, types_3.aclDbPolicyDocId)(dbid), policy, administrationPrivateKey, administrationPrivateKeyPassword);
1271
1324
  }
1272
1325
  /** Shared writer for default / per-db policy documents. */