@mastra/oracledb 0.4.2 → 0.5.1-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.
package/dist/index.js CHANGED
@@ -4295,6 +4295,10 @@ async function getObservationalMemoryHistory(ctx, threadId, resourceId, limit =
4295
4295
  lookupKey,
4296
4296
  limit
4297
4297
  };
4298
+ if (options?.recordId !== void 0) {
4299
+ conditions.push(`id = :recordId`);
4300
+ binds.recordId = options.recordId;
4301
+ }
4298
4302
  if (options?.from) {
4299
4303
  conditions.push(`${OM_CREATED_AT} >= :fromDate`);
4300
4304
  binds.fromDate = options.from;
@@ -4303,11 +4307,28 @@ async function getObservationalMemoryHistory(ctx, threadId, resourceId, limit =
4303
4307
  conditions.push(`${OM_CREATED_AT} <= :toDate`);
4304
4308
  binds.toDate = options.to;
4305
4309
  }
4310
+ if (options?.groupId !== void 0) {
4311
+ conditions.push(`(DBMS_LOB.INSTR(${OM_ACTIVE_OBSERVATIONS}, :groupPrefix) > 0 OR EXISTS (
4312
+ SELECT 1 FROM JSON_TABLE(${OM_BUFFERED_OBSERVATION_CHUNKS}, '$[*]'
4313
+ COLUMNS (observations CLOB PATH '$.observations')) chunk
4314
+ WHERE DBMS_LOB.INSTR(chunk.observations, :groupPrefix) > 0
4315
+ ))`);
4316
+ binds.groupPrefix = `<observation-group id="${options.groupId}"`;
4317
+ }
4318
+ if (options?.beforeGeneration !== void 0) {
4319
+ conditions.push(`${OM_GENERATION_COUNT} < :beforeGeneration`);
4320
+ binds.beforeGeneration = options.beforeGeneration;
4321
+ }
4322
+ if (options?.afterGeneration !== void 0) {
4323
+ conditions.push(`${OM_GENERATION_COUNT} > :afterGeneration`);
4324
+ binds.afterGeneration = options.afterGeneration;
4325
+ }
4326
+ const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
4306
4327
  if (options?.offset !== void 0) binds.offset = options.offset;
4307
4328
  return await ctx.db.withConnection(async (connection) => {
4308
4329
  return rows(await connection.execute(`${omSelect()} FROM ${table(ctx, TABLE_OBSERVATIONAL_MEMORY)}
4309
4330
  WHERE ${conditions.join(" AND ")}
4310
- ORDER BY ${OM_GENERATION_COUNT} DESC
4331
+ ORDER BY ${OM_GENERATION_COUNT} ${direction}, ${OM_CREATED_AT} ASC, "id" ASC
4311
4332
  OFFSET :offset ROWS FETCH NEXT :limit ROWS ONLY`, asBindParameters({
4312
4333
  offset: options?.offset ?? 0,
4313
4334
  ...binds
@@ -5370,6 +5391,7 @@ const DEFAULT_VECTOR_REGISTRY_TABLE$1 = "MASTRA_VECTOR_INDEXES";
5370
5391
  var MemoryOracle = class MemoryOracle extends MemoryStorage {
5371
5392
  supportsPartialThreadUpdate = true;
5372
5393
  supportsObservationalMemory = true;
5394
+ supportsObservationalMemoryHistorySearch = true;
5373
5395
  static MANAGED_TABLES = [
5374
5396
  TABLE_THREADS,
5375
5397
  TABLE_MESSAGES,
@@ -7953,7 +7975,7 @@ var WorkflowsOracle = class WorkflowsOracle extends WorkflowsStorage {
7953
7975
  async dangerouslyClearAll() {
7954
7976
  await this.db.clearTable(TABLE_WORKFLOW_SNAPSHOT);
7955
7977
  }
7956
- async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext }) {
7978
+ async updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, state }) {
7957
7979
  try {
7958
7980
  return await this.db.tx(async (client) => {
7959
7981
  await this.ensureWorkflowRunRow(client, workflowName, runId);
@@ -7963,6 +7985,7 @@ var WorkflowsOracle = class WorkflowsOracle extends WorkflowsStorage {
7963
7985
  });
7964
7986
  const snapshot = parseSnapshot(existing.snapshot);
7965
7987
  snapshot.context[stepId] = result;
7988
+ if (state !== void 0) snapshot.context.__state = state;
7966
7989
  snapshot.requestContext = {
7967
7990
  ...snapshot.requestContext ?? {},
7968
7991
  ...requestContext