@mastra/oracledb 0.2.3-alpha.0 → 0.2.4-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-oracledb
3
3
  description: Documentation for @mastra/oracledb. Use when working with @mastra/oracledb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/oracledb"
6
- version: "0.2.3-alpha.0"
6
+ version: "0.2.4-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.3-alpha.0",
2
+ "version": "0.2.4-alpha.0",
3
3
  "package": "@mastra/oracledb",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -718,7 +718,7 @@ Buffered observations also include continuation hints, a suggested next response
718
718
 
719
719
  When message production outpaces the Observer, the `blockAfter` safety threshold allows activation to overshoot the retention target instead of using fewer chunks. Activation still uses no more chunks than needed to reach the target, and the default settings remain unaffected. A synchronous observation runs when the `messageTokens` threshold is reached and buffered activation didn't happen. Buffered activation usually preserves a minimum remaining context (the smaller of \~1k tokens or the configured retention floor), but a single buffered chunk that covers the whole pending window still activates and can leave less.
720
720
 
721
- Reflection works similarly, the Reflector runs in the background when observations reach a fraction of the reflection threshold.
721
+ Reflection works similarly: the Reflector runs in the background when observations reach a fraction of the reflection threshold.
722
722
 
723
723
  ### Settings
724
724
 
@@ -809,6 +809,46 @@ const memory = new Memory({
809
809
  - `previousObserverTokens: 0` → omit previous observations completely.
810
810
  - `previousObserverTokens: false` → disable truncation and keep full previous observations.
811
811
 
812
+ ## Hooks
813
+
814
+ OM exposes two kinds of config-level hooks on `observationalMemory.hooks`:
815
+
816
+ - **Lifecycle hooks** (`onObservationStart`, `onObservationEnd`, `onReflectionStart`, `onReflectionEnd`) are telemetry callbacks. They receive `threadId`, `resourceId`, and `trigger`, and the end hooks also receive the model call's `usage`, `providerMetadata`, and any `error`. They never change what OM stores.
817
+ - **Transform hooks** (`beforeObservation`, `afterObservation`, `beforeReflection`, `afterReflection`) intercept the data flowing through a cycle. Return `void` to pass the input through unchanged, or return a replacement to change what the Observer/Reflector sees or what gets persisted.
818
+
819
+ ```typescript
820
+ const memory = new Memory({
821
+ options: {
822
+ observationalMemory: {
823
+ model: 'google/gemini-2.5-flash',
824
+ hooks: {
825
+ // Drop or redact messages before the Observer sees them.
826
+ beforeObservation: ({ messages }) => ({
827
+ messages: messages.filter(m => !isSensitive(m)),
828
+ }),
829
+ // Rewrite observations before they are persisted.
830
+ afterObservation: ({ observations, threadId }) => ({
831
+ observations: redact(observations),
832
+ }),
833
+ // Rewrite the text the Reflector condenses, or its output.
834
+ beforeReflection: ({ observations }) => ({
835
+ observations: stripInternalNotes(observations),
836
+ }),
837
+ afterReflection: async ({ observations, resourceId }) => {
838
+ await syncToExternalStore(resourceId, observations)
839
+ },
840
+ },
841
+ },
842
+ },
843
+ })
844
+ ```
845
+
846
+ Transform hooks are always awaited, on every path (manual `observe()`/`reflect()`, turn-synchronous observation, and async buffering). If `beforeObservation` returns an empty `messages` array, the Observer model call is skipped and the filtered messages are still marked as observed. If a transform hook throws, the cycle fails before committing the transformed observation or reflection text. This doesn't roll back extractor callbacks or other side effects that have already run.
847
+
848
+ `afterObservation` and `afterReflection` replace only the observation or reflection text. They don't recompute or redact the separate structured extractor results stored in thread metadata. Reflection extraction and its callbacks run before `afterReflection`, so rewriting the reflection doesn't rerun those callbacks. Use extractor configuration and callbacks to control structured values. Don't treat an after hook as a redaction boundary for all cycle data.
849
+
850
+ Because hooks receive `threadId` and `resourceId`, you can also use them to update [working memory](https://mastra.ai/docs/memory/working-memory) via `memory.updateWorkingMemory()` during a cycle. These external updates aren't atomic with the OM text commit.
851
+
812
852
  ## Migrating existing threads
813
853
 
814
854
  No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
@@ -650,7 +650,7 @@ Key metadata considerations:
650
650
 
651
651
  ## Deleting vectors
652
652
 
653
- When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it straightforward to remove all embeddings associated with a specific document.
653
+ Use `deleteVectors` with a metadata filter to remove embeddings associated with a document. This is useful for cleaning up stale vectors after a document is deleted or updated.
654
654
 
655
655
  ### Delete by Metadata Filter
656
656
 
package/dist/index.cjs CHANGED
@@ -6106,6 +6106,34 @@ async function batchCreateScores(db, _schemaName, args) {
6106
6106
  throw storageError("BATCH_CREATE_SCORES", "FAILED", { count: args.scores.length }, error, _mastra_core_error.ErrorCategory.USER);
6107
6107
  }
6108
6108
  }
6109
+ /**
6110
+ * Delete scores by scoreId, optionally scoped to a tenant (`organizationId` /
6111
+ * `resourceId` are ANDed into the predicate so a scoped caller can never
6112
+ * delete another tenant's rows).
6113
+ */
6114
+ async function deleteScores(db, schemaName, args) {
6115
+ if (args.scoreIds.length === 0) return;
6116
+ const binds = {};
6117
+ const placeholders = args.scoreIds.map((scoreId, index) => {
6118
+ binds[`scoreId${index}`] = scoreId;
6119
+ return `:scoreId${index}`;
6120
+ });
6121
+ const conditions = [`${scoreQcol(void 0, "id")} IN (${placeholders.join(", ")})`];
6122
+ if (args.organizationId !== void 0) {
6123
+ binds.organizationId = args.organizationId;
6124
+ const organizationIdColumn = scoreQcol(void 0, "organizationId");
6125
+ conditions.push(`(${organizationIdColumn} = :organizationId OR (${organizationIdColumn} IS NULL AND JSON_VALUE(${scoreQcol(void 0, "metadata")}, '$.organizationId' RETURNING VARCHAR2(4000) NULL ON ERROR) = :organizationId))`);
6126
+ }
6127
+ if (args.resourceId !== void 0) {
6128
+ binds.resourceId = args.resourceId;
6129
+ conditions.push(`${scoreQcol(void 0, "resourceId")} = :resourceId`);
6130
+ }
6131
+ try {
6132
+ await db.none(`DELETE FROM ${qualifyName(_mastra_core_storage.TABLE_SCORERS, schemaName)} WHERE ${conditions.join(" AND ")}`, binds);
6133
+ } catch (error) {
6134
+ throw storageError("DELETE_SCORES", "FAILED", { count: args.scoreIds.length }, error, _mastra_core_error.ErrorCategory.USER);
6135
+ }
6136
+ }
6109
6137
  async function getScoreById(db, schemaName, scoreId) {
6110
6138
  try {
6111
6139
  const row = await db.oneOrNone(`${scoreSelect("s")} FROM ${qualifyName(_mastra_core_storage.TABLE_SCORERS, schemaName)} s WHERE ${scoreQcol("s", "id")} = :scoreId`, { scoreId });
@@ -6145,7 +6173,7 @@ function transformObservabilityScoreRow(row) {
6145
6173
  rootEntityId: optionalString$1(metadata?.rootEntityId),
6146
6174
  rootEntityName: optionalString$1(metadata?.rootEntityName),
6147
6175
  userId: optionalString$1(metadata?.userId),
6148
- organizationId: optionalString$1(metadata?.organizationId),
6176
+ organizationId: optionalString$1(row.organizationId) ?? optionalString$1(metadata?.organizationId),
6149
6177
  resourceId: optionalString$1(row.resourceId),
6150
6178
  runId: optionalString$1(row.runId),
6151
6179
  sessionId: optionalString$1(metadata?.sessionId),
@@ -6233,6 +6261,7 @@ function scoreRecordToTableRecord(score) {
6233
6261
  entityId: score.entityId,
6234
6262
  source,
6235
6263
  resourceId: score.resourceId,
6264
+ organizationId: score.organizationId,
6236
6265
  threadId: score.threadId,
6237
6266
  createdAt: timestamp,
6238
6267
  updatedAt: timestamp
@@ -6755,6 +6784,9 @@ var ObservabilityOracle = class ObservabilityOracle extends _mastra_core_storage
6755
6784
  async batchCreateScores(args) {
6756
6785
  return batchCreateScores(this.db, this.schemaName, args);
6757
6786
  }
6787
+ async deleteScores(args) {
6788
+ return deleteScores(this.db, this.schemaName, args);
6789
+ }
6758
6790
  async getScoreById(scoreId) {
6759
6791
  return getScoreById(this.db, this.schemaName, scoreId);
6760
6792
  }