@yielded/agent-storage-memory 0.1.0-beta.190 → 0.1.0-beta.192

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.
@@ -2,8 +2,8 @@ import { t as MemoryThreadStoreKernel } from "./MemoryThreadStoreKernel-a2vrXxZZ
2
2
  import * as Layer from "effect/Layer";
3
3
  import { ThreadImport } from "@yielded/agent/thread-import";
4
4
  import { ThreadReader, ThreadStore } from "@yielded/agent/thread-store";
5
- import * as Crypto from "effect/Crypto";
6
5
  import { StorageOwner } from "@yielded/agent/run-storage";
6
+ import * as CryptoDigest from "effect/crypto/Digest";
7
7
  declare namespace MemoryThreadStore_d_exports {
8
8
  export { MemoryThreadStoreLive, memoryThreadStoreLayer };
9
9
  }
@@ -13,11 +13,11 @@ declare namespace MemoryThreadStore_d_exports {
13
13
  * Importing admissions requires a MemorySubmissionLedger paired with this store.
14
14
  * Publishing canonical messages requires a paired MemoryMessageDeliveryStore.
15
15
  */
16
- export declare const MemoryThreadStoreLive: Layer.Layer<MemoryThreadStoreKernel | StorageOwner | ThreadImport | ThreadReader | ThreadStore, never, Crypto.Crypto>;
16
+ export declare const MemoryThreadStoreLive: Layer.Layer<MemoryThreadStoreKernel | StorageOwner | ThreadImport | ThreadReader | ThreadStore, never, CryptoDigest.Digest>;
17
17
  /** Configure a finite retained Thread capacity. Invalid construction options throw immediately. */
18
18
  export declare const memoryThreadStoreLayer: (options?: {
19
19
  readonly maxThreads?: number;
20
- }) => Layer.Layer<MemoryThreadStoreKernel | StorageOwner | ThreadImport | ThreadReader | ThreadStore, never, Crypto.Crypto>;
20
+ }) => Layer.Layer<MemoryThreadStoreKernel | StorageOwner | ThreadImport | ThreadReader | ThreadStore, never, CryptoDigest.Digest>;
21
21
  //#endregion
22
22
  export { MemoryThreadStore_d_exports as t };
23
23
  //# sourceMappingURL=MemoryThreadStore.d.mts.map
@@ -15,7 +15,6 @@ import * as Context from "effect/Context";
15
15
  import { canonicalJson, utf8ByteLength } from "@yielded/agent/digest";
16
16
  import { CURRENT_RECORD_FORMAT, CanonicalRecordEnvelope, CanonicalSequence, MAX_RUN_EVIDENCE_BYTES, MAX_RUN_EVIDENCE_RECORDS, MAX_RUN_RECOVERY_SUFFIX_BYTES, MAX_RUN_RECOVERY_SUFFIX_RECORDS, MAX_RUN_TERMINAL_BYTES, ObservationOffset, PromptRecord, RUN_TERMINAL_RESERVE_RECORDS, RecordEnvelope } from "@yielded/agent/records";
17
17
  import { runIdForSubmission, subagentLineageRecordId, toolCallSettledRecordId, workerInputRecordId, workerOriginRecordId } from "@yielded/agent/run-journal";
18
- import * as Crypto from "effect/Crypto";
19
18
  import * as Option from "effect/Option";
20
19
  import * as Stream from "effect/Stream";
21
20
  import { ExportBatch, ExportRecord, ExportedRecord, ReadRecord } from "@yielded/agent/record-format";
@@ -24,6 +23,7 @@ import { StorageOwner, makeStorageOwner } from "@yielded/agent/run-storage";
24
23
  import { MAX_ARCHIVE_RANGE_BYTES, MAX_ARCHIVE_RANGE_RECORDS, ThreadArchiveRange, ThreadArchiveRangePublish, ThreadArchiveRangeRead, ThreadArchiveRangeRequest, ThreadArchiveRangeSeal } from "@yielded/agent/thread-archive-range";
25
24
  import { verifyThreadInvariants } from "@yielded/agent/thread-invariants";
26
25
  import { ThreadExporterReader, checkExportSource, exportThreadPage } from "@yielded/agent/thread-transfer";
26
+ import * as CryptoDigest from "effect/crypto/Digest";
27
27
  import * as Base64 from "effect/encoding/Base64";
28
28
  import * as PubSub from "effect/PubSub";
29
29
  import * as Semaphore from "effect/Semaphore";
@@ -333,7 +333,7 @@ const findThread = Effect.fnUntraced(function* (state, threadId) {
333
333
  });
334
334
  const makeThreadStore = Effect.gen(function* () {
335
335
  const maxThreads = yield* ThreadCapacity;
336
- const crypto = yield* Crypto.Crypto;
336
+ const crypto = yield* CryptoDigest.Digest;
337
337
  const state = yield* Ref.make({ threads: /* @__PURE__ */ new Map() });
338
338
  const gate = yield* Semaphore.make(1);
339
339
  const owner = yield* makeStorageOwner(gate.withPermits(1));
@@ -380,7 +380,7 @@ const makeThreadStore = Effect.gen(function* () {
380
380
  })),
381
381
  page: (unvalidated) => withMutation(Effect.gen(function* () {
382
382
  const request = yield* validate(ThreadWorkRequest, "work page", unvalidated);
383
- const cursor = yield* decodeWorkCursor(request).pipe(Effect.provideService(Crypto.Crypto, crypto));
383
+ const cursor = yield* decodeWorkCursor(request).pipe(Effect.provideService(CryptoDigest.Digest, crypto));
384
384
  const thread = (yield* Ref.get(state)).threads.get(request.threadId);
385
385
  const index = yield* readyIndex(request.threadId, thread?.tailSequence ?? 0);
386
386
  if (cursor.source === "canonical") {
@@ -449,7 +449,7 @@ const makeThreadStore = Effect.gen(function* () {
449
449
  records.push(record);
450
450
  }
451
451
  if (index.through < tail && records.length === 0) return yield* storeError("rebuild work", "Canonical rebuild cannot advance within its byte bound");
452
- const commitWork = yield* prepareWork(index, records).pipe(Effect.provideService(Crypto.Crypto, crypto));
452
+ const commitWork = yield* prepareWork(index, records).pipe(Effect.provideService(CryptoDigest.Digest, crypto));
453
453
  const next = yield* Effect.sync(() => {
454
454
  const native = prepareIndexes(rebuildingIndexes, records);
455
455
  const rebuilt = commitWork();
@@ -540,7 +540,7 @@ const makeThreadStore = Effect.gen(function* () {
540
540
  return {
541
541
  request,
542
542
  batchJson,
543
- deliveries: yield* prepareCanonicalMessageDeliveries(request.threadId, request.batch.records).pipe(Effect.provideService(Crypto.Crypto, crypto), Effect.mapError((cause) => deliveryError("Invalid canonical delivery", cause)))
543
+ deliveries: yield* prepareCanonicalMessageDeliveries(request.threadId, request.batch.records).pipe(Effect.provideService(CryptoDigest.Digest, crypto), Effect.mapError((cause) => deliveryError("Invalid canonical delivery", cause)))
544
544
  };
545
545
  });
546
546
  const appendPrepared = Effect.fnUntraced(function* ({ request, batchJson, deliveries }) {
@@ -578,7 +578,7 @@ const makeThreadStore = Effect.gen(function* () {
578
578
  }));
579
579
  }
580
580
  const currentWork = (yield* Ref.get(workState)).get(request.threadId);
581
- const preparedWork = thread !== void 0 && thread.tailSequence === request.expectedTailSequence && !thread.batches.has(request.batch.batchId) && latestIntent === void 0 && currentWork?.version === WORK_INDEX_VERSION && currentWork.state === "ready" && currentWork.through === thread.tailSequence && currentWork.entryCount === currentWork.entries.size ? yield* prepareWork(currentWork, batchEnvelopes(request.threadId, request.batch, decodeCanonicalSequence(thread.tailSequence + 1))).pipe(Effect.provideService(Crypto.Crypto, crypto)) : void 0;
581
+ const preparedWork = thread !== void 0 && thread.tailSequence === request.expectedTailSequence && !thread.batches.has(request.batch.batchId) && latestIntent === void 0 && currentWork?.version === WORK_INDEX_VERSION && currentWork.state === "ready" && currentWork.through === thread.tailSequence && currentWork.entryCount === currentWork.entries.size ? yield* prepareWork(currentWork, batchEnvelopes(request.threadId, request.batch, decodeCanonicalSequence(thread.tailSequence + 1))).pipe(Effect.provideService(CryptoDigest.Digest, crypto)) : void 0;
582
582
  let commitDeliveries;
583
583
  if (deliveries.length > 0) {
584
584
  if (deliveryWriter === void 0) return yield* deliveryError("Canonical messages require a paired MemoryMessageDeliveryStore", MessageDeliveryError.make({
@@ -1047,7 +1047,7 @@ const makeThreadStore = Effect.gen(function* () {
1047
1047
  let stagedDelivery;
1048
1048
  let existing;
1049
1049
  yield* Stream.runForEach(captured, (input) => Effect.gen(function* () {
1050
- const page = yield* prepareImportPage(progress, input).pipe(Effect.provideService(Crypto.Crypto, crypto));
1050
+ const page = yield* prepareImportPage(progress, input).pipe(Effect.provideService(CryptoDigest.Digest, crypto));
1051
1051
  const id = page.archive.threadId;
1052
1052
  if (staged === void 0) {
1053
1053
  existing = MutableRef.get(state.ref).threads.get(id);
@@ -1090,7 +1090,7 @@ const makeThreadStore = Effect.gen(function* () {
1090
1090
  }));
1091
1091
  for (const entry of records) if (staged.byId.has(entry.record.recordId)) return yield* invalidThreadArchive("Duplicate canonical record identity", id);
1092
1092
  const native = prepareIndexes(staged, records);
1093
- const commitWork = yield* prepareWork(stagedWork, records).pipe(Effect.provideService(Crypto.Crypto, crypto));
1093
+ const commitWork = yield* prepareWork(stagedWork, records).pipe(Effect.provideService(CryptoDigest.Digest, crypto));
1094
1094
  retainRecords(staged, records);
1095
1095
  native.commit();
1096
1096
  staged = {
@@ -1169,7 +1169,7 @@ const makeThreadStore = Effect.gen(function* () {
1169
1169
  admission: (threadId, sid) => threadId === id ? reader.admission(sid) : ledgerTransfer?.admission(threadId, sid) ?? Effect.as(Effect.void, void 0),
1170
1170
  record: (threadId, recordId) => Effect.succeed(threadId === id ? restoredThread.byId.get(recordId)?.record : MutableRef.get(state.ref).threads.get(threadId)?.byId.get(recordId)?.record)
1171
1171
  }));
1172
- }).pipe(Effect.provideService(Crypto.Crypto, crypto))));
1172
+ }).pipe(Effect.provideService(CryptoDigest.Digest, crypto))));
1173
1173
  const inspectTail = Effect.fnUntraced(function* (unvalidated) {
1174
1174
  const request = yield* validate(ThreadTailRequest, "inspectTail", unvalidated);
1175
1175
  const thread = yield* Ref.get(state).pipe(Effect.flatMap((current) => findThread(current, request.threadId)));
@@ -1349,7 +1349,7 @@ const makeThreadStore = Effect.gen(function* () {
1349
1349
  submissions: submissions(),
1350
1350
  pages: streamExport({ threadId: id }).pipe(Stream.provideService(ThreadExportSource, { export: verificationPage }), Stream.mapError((cause) => Schema.is(ThreadExportRejected)(cause) ? storeError("verify Thread", "Internal verification snapshot changed") : cause)),
1351
1351
  ...request.requireAllSettled === void 0 ? {} : { requireAllSettled: request.requireAllSettled }
1352
- }).pipe(Effect.provide(ThreadImportReader.layer(reader)), Effect.provideService(Crypto.Crypto, crypto));
1352
+ }).pipe(Effect.provide(ThreadImportReader.layer(reader)), Effect.provideService(CryptoDigest.Digest, crypto));
1353
1353
  })) },
1354
1354
  readWorkerCapacity,
1355
1355
  readIdentity,