@xandreed/plugin-session-files 0.17.1 → 0.18.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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @xandreed/plugin-session-files
2
2
 
3
- Efferent composable agent framework, 0.17.1. Node 24 or Bun.
3
+ Efferent composable agent framework, 0.18.0. Node 24 or Bun.
4
4
 
5
5
  Documentation: https://github.com/xandreeddev/efferent
@@ -4,7 +4,7 @@ import { SessionLogFilesLive } from "./session-log.adapter.js";
4
4
  import { SessionFilesConfig, sessionFilesDefaults } from "./session-files.entity.js";
5
5
  export const sessionLogFilesPlugin = definePlugin({
6
6
  id: "@xandreed/plugin-session-files/log",
7
- version: "0.17.1",
7
+ version: "0.18.0",
8
8
  scope: "runtime",
9
9
  config: SessionFilesConfig,
10
10
  defaults: sessionFilesDefaults,
@@ -12,7 +12,7 @@ export const sessionLogFilesPlugin = definePlugin({
12
12
  layer: ({ path, stallMs }) => SessionLogFilesLive(path, { stallMs })
13
13
  }), sessionFilesPlugin = definePlugin({
14
14
  id: "@xandreed/plugin-session-files",
15
- version: "0.17.1",
15
+ version: "0.18.0",
16
16
  scope: "runtime",
17
17
  config: SessionFilesConfig,
18
18
  defaults: sessionFilesDefaults,
@@ -207,7 +207,7 @@ export const makeSessionLogFiles = Effect.fnUntraced(function* (root, options) {
207
207
  return page(heads.flatMap(Option.toArray), query);
208
208
  }),
209
209
  read: Effect.fn("session_log.read")(function* (id, query) {
210
- const { header, tail } = yield* current(id), limit = Option.match(query.limit, { onNone: () => Number.POSITIVE_INFINITY, onSome: (value) => Math.max(0, value) }), wanted = (kind) => query.kinds.length === 0 || query.kinds.includes(kind), revisions = Array.from({ length: tail.revision }, (_, index) => index + 1), cached = Option.match(Option.filter(Option.fromNullishOr((yield* Ref.get(known)).get(id)), (entry) => entry.nonce === header.nonce), {
210
+ const { header, tail } = yield* current(id), limit = Option.match(query.limit, { onNone: () => Number.POSITIVE_INFINITY, onSome: (value) => Math.max(0, value) }), wanted = (kind) => query.kinds.length === 0 || query.kinds.includes(kind), latest = query.from === "end", revisions = Array.from({ length: tail.revision }, (_, index) => latest ? tail.revision - index : index + 1), cached = Option.match(Option.filter(Option.fromNullishOr((yield* Ref.get(known)).get(id)), (entry) => entry.nonce === header.nonce), {
211
211
  onNone: () => new Map,
212
212
  onSome: (entry) => entry.metas
213
213
  }), fresh = new Map, metaAt = (revision) => Option.match(Option.fromNullishOr(cached.get(revision)), {
@@ -216,10 +216,13 @@ export const makeSessionLogFiles = Effect.fnUntraced(function* (root, options) {
216
216
  }), events = yield* Effect.reduce(revisions, () => [], (events, revision) => {
217
217
  if (events.length >= limit)
218
218
  return Effect.succeed(events);
219
- return metaAt(revision).pipe(Effect.flatMap((meta) => meta.last <= query.after || query.through !== void 0 && meta.first > query.through || meta.first > meta.last || !meta.kinds.some(wanted) ? Effect.succeed(events) : wholeCommit(id, revision).pipe(Effect.map((record) => [
220
- ...events,
221
- ...record.events.filter((event) => event.seq > query.after && (query.through === void 0 || event.seq <= query.through) && wanted(event.kind)).map(eventOf(id, record.meta.at))
222
- ].slice(0, limit)))));
219
+ return metaAt(revision).pipe(Effect.flatMap((meta) => meta.last <= query.after || query.through !== void 0 && meta.first > query.through || meta.first > meta.last || !meta.kinds.some(wanted) ? Effect.succeed(events) : wholeCommit(id, revision).pipe(Effect.map((record) => {
220
+ const matched = record.events.filter((event) => event.seq > query.after && (query.through === void 0 || event.seq <= query.through) && wanted(event.kind)).map(eventOf(id, record.meta.at));
221
+ if (!latest)
222
+ return [...events, ...matched].slice(0, limit);
223
+ const joined = [...matched, ...events];
224
+ return joined.slice(Math.max(0, joined.length - limit));
225
+ }))));
223
226
  });
224
227
  if (fresh.size > 0)
225
228
  yield* Ref.update(known, (all) => Option.match(Option.filter(Option.fromNullishOr(all.get(id)), (entry) => entry.nonce === header.nonce), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xandreed/plugin-session-files",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "engines": {
5
5
  "node": ">=24",
6
6
  "bun": ">=1.3.0"
@@ -14,7 +14,7 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {},
17
- "gitHead": "1e0e4cc0fc5ecc4a08235cdb024324187a6a6430",
17
+ "gitHead": "de00c31cf6f697ab942020ced74661321c58554d",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "git+https://github.com/xandreeddev/efferent.git",
@@ -23,7 +23,7 @@
23
23
  "private": false,
24
24
  "types": "./dist/index.d.ts",
25
25
  "peerDependencies": {
26
- "@xandreed/core": "^0.17.1",
26
+ "@xandreed/core": "^0.18.0",
27
27
  "effect": "^4.0.7"
28
28
  },
29
29
  "files": [