@hyperdrive.bot/fleet-server 0.3.147 → 0.3.149

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 (33) hide show
  1. package/dist/server/server/agent/mcp-server.js +64 -2
  2. package/dist/server/server/agent/session-digest-generator.js +33 -2
  3. package/dist/server/server/agent/session-digest.d.ts +71 -0
  4. package/dist/server/server/agent/session-digest.js +117 -1
  5. package/dist/server/server/agent/tools/paseo-tools.d.ts +9 -0
  6. package/dist/server/server/agent/tools/paseo-tools.js +76 -1
  7. package/dist/server/server/agent/tools/read-only-surface.d.ts +7 -0
  8. package/dist/server/server/agent/tools/read-only-surface.js +8 -0
  9. package/dist/server/server/bootstrap.js +71 -1
  10. package/dist/server/server/exports.d.ts +2 -0
  11. package/dist/server/server/exports.js +6 -0
  12. package/dist/server/server/ingestion/subscriptions/notification-prompt.d.ts +83 -0
  13. package/dist/server/server/ingestion/subscriptions/notification-prompt.js +96 -0
  14. package/dist/server/server/ingestion/subscriptions/notifier.d.ts +96 -0
  15. package/dist/server/server/ingestion/subscriptions/notifier.js +209 -0
  16. package/dist/server/server/ingestion/subscriptions/pending-store.d.ts +111 -0
  17. package/dist/server/server/ingestion/subscriptions/pending-store.js +254 -0
  18. package/dist/server/server/ingestion/subscriptions/poller.d.ts +73 -0
  19. package/dist/server/server/ingestion/subscriptions/poller.js +168 -0
  20. package/dist/server/server/ingestion/subscriptions/reader.d.ts +39 -0
  21. package/dist/server/server/ingestion/subscriptions/reader.js +30 -0
  22. package/dist/server/server/ingestion/subscriptions/store.d.ts +35 -0
  23. package/dist/server/server/ingestion/subscriptions/store.js +82 -0
  24. package/dist/server/web-ui/_expo/static/js/web/{index-837630304edbf229f37aaa1d262c40d5.js → index-8747c529e5cb02149fe51570f7cb697b.js} +13 -13
  25. package/dist/server/web-ui/_expo/static/js/web/index-8747c529e5cb02149fe51570f7cb697b.js.br +0 -0
  26. package/dist/server/web-ui/_expo/static/js/web/{index-837630304edbf229f37aaa1d262c40d5.js.gz → index-8747c529e5cb02149fe51570f7cb697b.js.gz} +0 -0
  27. package/dist/server/web-ui/_expo/static/js/web/{index-837630304edbf229f37aaa1d262c40d5.js.map.br → index-8747c529e5cb02149fe51570f7cb697b.js.map.br} +0 -0
  28. package/dist/server/web-ui/_expo/static/js/web/{index-837630304edbf229f37aaa1d262c40d5.js.map.gz → index-8747c529e5cb02149fe51570f7cb697b.js.map.gz} +0 -0
  29. package/dist/server/web-ui/index.html +1 -1
  30. package/dist/server/web-ui/index.html.br +0 -0
  31. package/dist/server/web-ui/index.html.gz +0 -0
  32. package/package.json +6 -6
  33. package/dist/server/web-ui/_expo/static/js/web/index-837630304edbf229f37aaa1d262c40d5.js.br +0 -0
@@ -0,0 +1,82 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { mkdir, readFile, readdir, rm } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { StoredSubscriptionSchema, } from "@hyperdrive.bot/fleet-protocol/ingestion/subscription-types";
5
+ import { writeJsonFileAtomic } from "../../atomic-file.js";
6
+ function generateSubscriptionId() {
7
+ return randomBytes(4).toString("hex");
8
+ }
9
+ /**
10
+ * File-backed persistence for session subscriptions, one JSON file per
11
+ * subscription under `dir` (the caller supplies `join(paseoHome, "subscriptions")`).
12
+ *
13
+ * Structurally identical to `SourceStore` and `ScheduleStore`, deliberately: a
14
+ * third shape here would be a third set of atomicity and parse bugs to find.
15
+ *
16
+ * `StoredSubscriptionSchema` is strict and `list()` is readdir + Promise.all, so
17
+ * ONE unparseable file rejects the whole array. That is the same trade the
18
+ * source store makes, and it carries the same obligation: every field added to
19
+ * the schema later must carry `.default(...)`, or records written before it
20
+ * existed stop parsing and every subscription silently disappears. There is no
21
+ * migration step. `accountLabel` on `StoredSourceSchema` is the precedent.
22
+ */
23
+ export class SubscriptionStore {
24
+ constructor(dir) {
25
+ this.dir = dir;
26
+ }
27
+ filePath(id) {
28
+ return join(this.dir, `${id}.json`);
29
+ }
30
+ async ensureDir() {
31
+ await mkdir(this.dir, { recursive: true });
32
+ }
33
+ async list() {
34
+ await this.ensureDir();
35
+ const entries = await readdir(this.dir, { withFileTypes: true });
36
+ const subscriptions = await Promise.all(entries
37
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
38
+ .map(async (entry) => {
39
+ const content = await readFile(join(this.dir, entry.name), "utf-8");
40
+ return StoredSubscriptionSchema.parse(JSON.parse(content));
41
+ }));
42
+ return subscriptions.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
43
+ }
44
+ async get(id) {
45
+ await this.ensureDir();
46
+ try {
47
+ const content = await readFile(this.filePath(id), "utf-8");
48
+ return StoredSubscriptionSchema.parse(JSON.parse(content));
49
+ }
50
+ catch (error) {
51
+ if (error.code === "ENOENT") {
52
+ return null;
53
+ }
54
+ throw error;
55
+ }
56
+ }
57
+ /**
58
+ * Every armed subscription pointing at `filterId`.
59
+ *
60
+ * The fan-out read. A filter with three armed subscribers returns three
61
+ * records here, and each one is notified on its own budget: this is the
62
+ * function that makes one filter serve many sessions.
63
+ */
64
+ async listArmedForFilter(filterId) {
65
+ const all = await this.list();
66
+ return all.filter((subscription) => subscription.filterId === filterId && subscription.status === "armed");
67
+ }
68
+ async create(subscription) {
69
+ const created = { ...subscription, id: generateSubscriptionId() };
70
+ await this.put(created);
71
+ return created;
72
+ }
73
+ async put(subscription) {
74
+ await this.ensureDir();
75
+ await writeJsonFileAtomic(this.filePath(subscription.id), subscription);
76
+ }
77
+ async delete(id) {
78
+ await this.ensureDir();
79
+ await rm(this.filePath(id), { force: true });
80
+ }
81
+ }
82
+ //# sourceMappingURL=store.js.map