@glassly/miniapp 0.4.3-dev.1200 → 0.4.3-dev.1206

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 (69) hide show
  1. package/dist/display/index.d.ts +2 -1
  2. package/dist/display/index.d.ts.map +1 -1
  3. package/dist/display/index.js +1 -1
  4. package/dist/display/index.js.map +1 -1
  5. package/dist/display/profiles/index.d.ts +2 -0
  6. package/dist/display/profiles/index.d.ts.map +1 -1
  7. package/dist/display/profiles/index.js +1 -0
  8. package/dist/display/profiles/index.js.map +1 -1
  9. package/dist/display/profiles/textProfile.d.ts +24 -0
  10. package/dist/display/profiles/textProfile.d.ts.map +1 -0
  11. package/dist/display/profiles/textProfile.js +52 -0
  12. package/dist/display/profiles/textProfile.js.map +1 -0
  13. package/dist/display/scene/process.d.ts.map +1 -1
  14. package/dist/display/scene/process.js +2 -3
  15. package/dist/display/scene/process.js.map +1 -1
  16. package/dist/host/actionInvoke.d.ts +44 -0
  17. package/dist/host/actionInvoke.d.ts.map +1 -0
  18. package/dist/host/actionInvoke.js +87 -0
  19. package/dist/host/actionInvoke.js.map +1 -0
  20. package/dist/host/gestureClaims.d.ts +37 -0
  21. package/dist/host/gestureClaims.d.ts.map +1 -0
  22. package/dist/host/gestureClaims.js +45 -0
  23. package/dist/host/gestureClaims.js.map +1 -0
  24. package/dist/host/index.d.ts +8 -0
  25. package/dist/host/index.d.ts.map +1 -1
  26. package/dist/host/index.js +9 -0
  27. package/dist/host/index.js.map +1 -1
  28. package/dist/host/manifestActions.d.ts +69 -0
  29. package/dist/host/manifestActions.d.ts.map +1 -0
  30. package/dist/host/manifestActions.js +89 -0
  31. package/dist/host/manifestActions.js.map +1 -0
  32. package/dist/host/memory/MemoryStore.d.ts +178 -0
  33. package/dist/host/memory/MemoryStore.d.ts.map +1 -0
  34. package/dist/host/memory/MemoryStore.js +615 -0
  35. package/dist/host/memory/MemoryStore.js.map +1 -0
  36. package/dist/host/memory/search.d.ts +72 -0
  37. package/dist/host/memory/search.d.ts.map +1 -0
  38. package/dist/host/memory/search.js +188 -0
  39. package/dist/host/memory/search.js.map +1 -0
  40. package/dist/host/miniappPermissions.d.ts +16 -0
  41. package/dist/host/miniappPermissions.d.ts.map +1 -0
  42. package/dist/host/miniappPermissions.js +7 -0
  43. package/dist/host/miniappPermissions.js.map +1 -0
  44. package/dist/host/settingsBridge.d.ts +49 -0
  45. package/dist/host/settingsBridge.d.ts.map +1 -0
  46. package/dist/host/settingsBridge.js +110 -0
  47. package/dist/host/settingsBridge.js.map +1 -0
  48. package/dist/host/widgetPlacements.d.ts +44 -0
  49. package/dist/host/widgetPlacements.d.ts.map +1 -0
  50. package/dist/host/widgetPlacements.js +84 -0
  51. package/dist/host/widgetPlacements.js.map +1 -0
  52. package/dist/session.d.ts +6 -0
  53. package/dist/session.d.ts.map +1 -1
  54. package/dist/session.js.map +1 -1
  55. package/package.json +2 -2
  56. package/src/display/index.ts +3 -0
  57. package/src/display/profiles/index.ts +3 -0
  58. package/src/display/profiles/textProfile.ts +66 -0
  59. package/src/display/scene/process.ts +2 -3
  60. package/src/host/actionInvoke.ts +110 -0
  61. package/src/host/gestureClaims.ts +77 -0
  62. package/src/host/index.ts +10 -0
  63. package/src/host/manifestActions.ts +152 -0
  64. package/src/host/memory/MemoryStore.ts +704 -0
  65. package/src/host/memory/search.ts +214 -0
  66. package/src/host/miniappPermissions.ts +19 -0
  67. package/src/host/settingsBridge.ts +119 -0
  68. package/src/host/widgetPlacements.ts +135 -0
  69. package/src/session.ts +6 -0
@@ -0,0 +1,69 @@
1
+ /**
2
+ * A manifest-declared action a miniapp exposes for other miniapps to invoke
3
+ * via `session.actions`. Populated from `miniapp.json`'s `actions` field.
4
+ * Shape maps 1:1 onto an MCP tool (id→name, description, parameters→inputSchema).
5
+ */
6
+ export interface DeclaredAction {
7
+ id: string;
8
+ description: string;
9
+ /** JSON-Schema input descriptor (MCP-compatible subset). */
10
+ parameters?: Record<string, unknown>;
11
+ /** JSON-Schema descriptor for the action's structured result. */
12
+ outputSchema?: Record<string, unknown>;
13
+ /**
14
+ * Who may invoke the action: "public" (default — any installed miniapp) or
15
+ * "system" (system miniapps such as the AI assistant only).
16
+ */
17
+ visibility?: "public" | "system";
18
+ }
19
+ export type DeclaredWidgetSize = "XS" | "XSM" | "SM" | "MD" | "LG";
20
+ /** A dashboard widget a miniapp declares in `miniapp.json` and serves through `session.widgets`. */
21
+ export interface DeclaredWidget {
22
+ id: string;
23
+ name: string;
24
+ sizes: DeclaredWidgetSize[];
25
+ defaultSize: DeclaredWidgetSize;
26
+ /** Lists the `EX` size: a tap on the selected widget can expand it to the full screen. */
27
+ expandable: boolean;
28
+ /** A tap expands it rather than activating the card: expandable, and the wearer left expansion on. */
29
+ expandOnTap: boolean;
30
+ }
31
+ /** The subset of ClientApp that action-listing needs (structural, no cycle on applet types). */
32
+ export interface ActionListApp {
33
+ packageName: string;
34
+ name: string;
35
+ actions?: DeclaredAction[];
36
+ compatibility?: {
37
+ isCompatible: boolean;
38
+ };
39
+ }
40
+ /** One row of `session.actions.list` — a flat, MCP-tool-shaped descriptor. */
41
+ export interface ActionListRow {
42
+ packageName: string;
43
+ appName: string;
44
+ id: string;
45
+ description: string;
46
+ parameters?: Record<string, unknown>;
47
+ outputSchema?: Record<string, unknown>;
48
+ }
49
+ /**
50
+ * Project the installed-app set into the caller's invokable-action rows:
51
+ * excludes the caller's own actions, incompatible apps, and placeholder
52
+ * packages; `visibility: "system"` actions only surface for system callers.
53
+ */
54
+ export declare function visibleActionRows(apps: ActionListApp[], callerPackageName: string, callerIsSystem: boolean): ActionListRow[];
55
+ /**
56
+ * Normalize manifest actions defensively for installed and dev-sideloaded
57
+ * bundles. Input and output schemas are passed through as opaque JSON Schema.
58
+ */
59
+ export declare function normalizeManifestActions(raw: unknown): DeclaredAction[];
60
+ /**
61
+ * Normalize manifest widgets for installed and dev-sideloaded bundles: an
62
+ * entry without an id, a name or a usable card size is dropped, repeats of a
63
+ * size are folded, and a default size the widget does not offer becomes
64
+ * its first size. Listing `EX` makes a widget expandable; it is not a card
65
+ * size. Taps expand it until the wearer turns that off (AppRegistry applies
66
+ * the choice).
67
+ */
68
+ export declare function normalizeManifestWidgets(raw: unknown): DeclaredWidget[];
69
+ //# sourceMappingURL=manifestActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestActions.d.ts","sourceRoot":"","sources":["../../src/host/manifestActions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CACjC;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAElE,oGAAoG;AACpG,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,kBAAkB,EAAE,CAAA;IAC3B,WAAW,EAAE,kBAAkB,CAAA;IAC/B,0FAA0F;IAC1F,UAAU,EAAE,OAAO,CAAA;IACnB,sGAAsG;IACtG,WAAW,EAAE,OAAO,CAAA;CACrB;AAED,gGAAgG;AAChG,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,cAAc,EAAE,CAAA;IAC1B,aAAa,CAAC,EAAE;QAAC,YAAY,EAAE,OAAO,CAAA;KAAC,CAAA;CACxC;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,aAAa,EAAE,EACrB,iBAAiB,EAAE,MAAM,EACzB,cAAc,EAAE,OAAO,GACtB,aAAa,EAAE,CAkBjB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,EAAE,CA0BvE;AAMD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,EAAE,CA2BvE"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Project the installed-app set into the caller's invokable-action rows:
3
+ * excludes the caller's own actions, incompatible apps, and placeholder
4
+ * packages; `visibility: "system"` actions only surface for system callers.
5
+ */
6
+ export function visibleActionRows(apps, callerPackageName, callerIsSystem) {
7
+ const rows = [];
8
+ for (const app of apps) {
9
+ if (!app.packageName || app.packageName === callerPackageName || app.packageName.includes("@empty"))
10
+ continue;
11
+ if (app.compatibility?.isCompatible === false)
12
+ continue;
13
+ for (const action of app.actions ?? []) {
14
+ if (action.visibility === "system" && !callerIsSystem)
15
+ continue;
16
+ rows.push({
17
+ packageName: app.packageName,
18
+ appName: app.name,
19
+ id: action.id,
20
+ description: action.description,
21
+ ...(action.parameters ? { parameters: action.parameters } : {}),
22
+ ...(action.outputSchema ? { outputSchema: action.outputSchema } : {}),
23
+ });
24
+ }
25
+ }
26
+ return rows;
27
+ }
28
+ /**
29
+ * Normalize manifest actions defensively for installed and dev-sideloaded
30
+ * bundles. Input and output schemas are passed through as opaque JSON Schema.
31
+ */
32
+ export function normalizeManifestActions(raw) {
33
+ if (!Array.isArray(raw))
34
+ return [];
35
+ const out = [];
36
+ for (const a of raw) {
37
+ if (a && typeof a.id === "string" && typeof a.description === "string") {
38
+ out.push({
39
+ id: a.id,
40
+ description: a.description,
41
+ ...(a.parameters && typeof a.parameters === "object" && !Array.isArray(a.parameters)
42
+ ? { parameters: a.parameters }
43
+ : {}),
44
+ ...(a.outputSchema && typeof a.outputSchema === "object" && !Array.isArray(a.outputSchema)
45
+ ? { outputSchema: a.outputSchema }
46
+ : {}),
47
+ // Unknown/absent values fall back to the default ("public") by omission.
48
+ ...(a.visibility === "system" || a.visibility === "public" ? { visibility: a.visibility } : {}),
49
+ });
50
+ }
51
+ }
52
+ return out;
53
+ }
54
+ const WIDGET_SIZES = ["XS", "XSM", "SM", "MD", "LG"];
55
+ const isWidgetSize = (value) => WIDGET_SIZES.includes(value);
56
+ /**
57
+ * Normalize manifest widgets for installed and dev-sideloaded bundles: an
58
+ * entry without an id, a name or a usable card size is dropped, repeats of a
59
+ * size are folded, and a default size the widget does not offer becomes
60
+ * its first size. Listing `EX` makes a widget expandable; it is not a card
61
+ * size. Taps expand it until the wearer turns that off (AppRegistry applies
62
+ * the choice).
63
+ */
64
+ export function normalizeManifestWidgets(raw) {
65
+ if (!Array.isArray(raw))
66
+ return [];
67
+ const out = [];
68
+ const seen = new Set();
69
+ for (const w of raw) {
70
+ if (!w || typeof w.id !== "string" || !w.id || typeof w.name !== "string" || !w.name || seen.has(w.id))
71
+ continue;
72
+ const sizes = Array.isArray(w.sizes) ? Array.from(new Set(w.sizes.filter(isWidgetSize))) : [];
73
+ if (sizes.length === 0)
74
+ continue;
75
+ seen.add(w.id);
76
+ // `expandable: true` is how bundles from before `EX` said the same.
77
+ const expandable = (Array.isArray(w.sizes) && w.sizes.includes("EX")) || w.expandable === true;
78
+ out.push({
79
+ id: w.id,
80
+ name: w.name,
81
+ sizes,
82
+ defaultSize: isWidgetSize(w.defaultSize) && sizes.includes(w.defaultSize) ? w.defaultSize : sizes[0],
83
+ expandable,
84
+ expandOnTap: expandable,
85
+ });
86
+ }
87
+ return out;
88
+ }
89
+ //# sourceMappingURL=manifestActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestActions.js","sourceRoot":"","sources":["../../src/host/manifestActions.ts"],"names":[],"mappings":"AAmDA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAqB,EACrB,iBAAyB,EACzB,cAAuB;IAEvB,MAAM,IAAI,GAAoB,EAAE,CAAA;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,KAAK,iBAAiB,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,SAAQ;QAC7G,IAAI,GAAG,CAAC,aAAa,EAAE,YAAY,KAAK,KAAK;YAAE,SAAQ;QACvD,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACvC,IAAI,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,cAAc;gBAAE,SAAQ;YAC/D,IAAI,CAAC,IAAI,CAAC;gBACR,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,OAAO,EAAE,GAAG,CAAC,IAAI;gBACjB,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7D,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,MAAM,CAAC,YAAY,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACpE,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO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;YACP,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,KAAK;YACL,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACpG,UAAU;YACV,WAAW,EAAE,UAAU;SACxB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * MemoryStore — the user's shared, phone-local memory timeline.
3
+ *
4
+ * One unified per-hour stream of what happened around the user — spoken
5
+ * transcript lines AND notes (manual, voice, auto) in one timeline — plus the
6
+ * hourly conversation summary that heads each session. Scoped to the Glassly
7
+ * USER (not to a miniapp): every miniapp that declares the MEMORY manifest
8
+ * permission reads and writes the same store through LocalMiniappRuntime's
9
+ * MEMORY_* handlers, and Settings > Memory manages it via engine.memory.
10
+ *
11
+ * A "session" is one clock hour that has entries, derived from entry
12
+ * timestamps at read time — nothing is stored per-session, so there is no
13
+ * session id to keep in sync.
14
+ *
15
+ * The store began life inside the Assist miniapp (its SessionStore); on first
16
+ * load it migrates Assist's per-app storage namespace into the shared
17
+ * user-scoped keys so existing history survives the move.
18
+ */
19
+ import type { MemoryBackup, MemoryEntry, MemoryImportResult, MemoryNoteSource, MemorySession, MemorySummary } from "../../modules/memory";
20
+ /**
21
+ * Physical bounds. There is no age cap: the timeline stays until the user
22
+ * deletes it (clear()/removeScope). The entry cap bounds the write cost —
23
+ * every persist re-serializes the whole timeline, so it is a perf ceiling as
24
+ * much as a product number — and the summary cap keeps one row per hour for
25
+ * about half a year of round-the-clock use, far longer at a normal pace.
26
+ */
27
+ export declare const MEMORY_BOUNDS: {
28
+ maxEntries: number;
29
+ maxSummaries: number;
30
+ };
31
+ export interface MemoryStoreBackend {
32
+ get(key: string): unknown | null;
33
+ set(key: string, value: unknown): void;
34
+ remove(key: string): void;
35
+ }
36
+ export interface MemoryStoreHooks {
37
+ getUserId: () => Promise<string>;
38
+ backend: MemoryStoreBackend;
39
+ /**
40
+ * Debounce window for transcript-line writes, in ms. Appends coalesce into
41
+ * one serialization instead of re-stringifying the whole timeline per
42
+ * utterance. Set to 0 to persist synchronously (tests).
43
+ */
44
+ writeDebounceMs?: number;
45
+ timers?: MemoryStoreTimers;
46
+ }
47
+ /** The host's background-safe timer (the Glassly App's BgTimer); global timers when absent. */
48
+ export interface MemoryStoreTimers {
49
+ setTimeout(cb: () => void, ms: number): unknown;
50
+ clearTimeout(id: unknown): void;
51
+ }
52
+ export interface MemoryStats {
53
+ entryCount: number;
54
+ lineCount: number;
55
+ noteCount: number;
56
+ summaryCount: number;
57
+ /** Epoch ms of the oldest entry, or null when empty. */
58
+ oldestAt: number | null;
59
+ }
60
+ /** Thrown by importBackup for anything that isn't a backup this build can read. */
61
+ export declare class MemoryBackupError extends Error {
62
+ constructor(message: string);
63
+ }
64
+ export declare function hourStartOf(ms: number): number;
65
+ export declare function dayStartOf(ms: number): number;
66
+ export declare class MemoryStore {
67
+ private readonly hooks;
68
+ private entries;
69
+ private summaries;
70
+ /** User the in-memory cache was loaded for; reload when identity changes. */
71
+ private loadedUserId;
72
+ private loadPromise;
73
+ private readonly changeListeners;
74
+ /** Pending debounced log write (transcript appends), if any. */
75
+ private logFlushTimer;
76
+ private logDirty;
77
+ constructor(hooks: MemoryStoreHooks);
78
+ private get timers();
79
+ /**
80
+ * Write any debounced changes out now. Call before the app backgrounds or
81
+ * terminates so a crash can't lose the coalesced tail of the timeline.
82
+ */
83
+ flush(): Promise<void>;
84
+ /** Subscribe to mutations (adds, edits, deletes, clears). */
85
+ onChanged(listener: () => void): () => void;
86
+ appendLine(input: {
87
+ text: string;
88
+ speakerId: string | null;
89
+ /** Resolved enrolled-speaker name (on-device speaker ID), when known. */
90
+ resolvedSpeakerName?: string | null;
91
+ language: string | null;
92
+ at: number;
93
+ }): Promise<void>;
94
+ /**
95
+ * Add a note. `at` targets the hour it belongs to — pass a timestamp inside
96
+ * a past hour to append to that session. Dedupes on normalized text within
97
+ * the same hour (auto-notes re-extract); resolves null on duplicate/empty.
98
+ */
99
+ addNote(text: string, source: MemoryNoteSource, at?: number): Promise<MemoryEntry | null>;
100
+ /** Rewrite a note's text in place (Settings > Memory edit). */
101
+ updateNote(id: string, text: string): Promise<boolean>;
102
+ removeEntry(id: string): Promise<boolean>;
103
+ /** Delete every entry (and summary) in an hour, or a whole day of hours. */
104
+ removeScope(scope: "session" | "day", at: number): Promise<void>;
105
+ /** Drop the entire timeline: every entry and every summary. */
106
+ clear(): Promise<void>;
107
+ addSummary(summary: MemorySummary): Promise<void>;
108
+ /** Entries in [sinceMs, untilMs), newest last. */
109
+ window(sinceMs: number, untilMs?: number): Promise<MemoryEntry[]>;
110
+ /** All note entries, newest first (Settings > Memory list). */
111
+ notes(): Promise<MemoryEntry[]>;
112
+ stats(): Promise<MemoryStats>;
113
+ /** All sessions (hours with entries), newest hour first. */
114
+ sessionList(): Promise<MemorySession[]>;
115
+ /**
116
+ * Query the FULL store by absolute-time window and keyword — the executor
117
+ * behind LLM history-search tools. Newest last, so the limit keeps the most
118
+ * recent matches. `contains` is an exact substring; `terms` is fuzzy any-of
119
+ * matching (mistranscribed-name tolerant) — see search.ts.
120
+ */
121
+ query(q: {
122
+ sinceMs?: number;
123
+ untilMs?: number;
124
+ contains?: string;
125
+ terms?: string[];
126
+ limit?: number;
127
+ }): Promise<MemoryEntry[]>;
128
+ /**
129
+ * query() plus `windowCount` — how many entries the TIME window held before
130
+ * keyword filtering, so an LLM caller can distinguish "keyword matched
131
+ * nothing" from "history doesn't reach that far back" without a retry.
132
+ */
133
+ search(q: {
134
+ sinceMs?: number;
135
+ untilMs?: number;
136
+ contains?: string;
137
+ terms?: string[];
138
+ limit?: number;
139
+ }): Promise<{
140
+ entries: MemoryEntry[];
141
+ windowCount: number;
142
+ }>;
143
+ summaryList(): Promise<MemorySummary[]>;
144
+ /** Most recent COMPLETED hour with lines but no summary, or null. */
145
+ pendingSummaryHour(nowMs?: number): Promise<number | null>;
146
+ /** The whole timeline as a backup file body (Settings > Memory, session.memory.exportFile). */
147
+ exportBackup(): Promise<MemoryBackup>;
148
+ /**
149
+ * Merge a backup into the timeline. Skips entries whose id is stored, notes
150
+ * whose text is already in the same hour, and hours that already have a
151
+ * summary. Throws MemoryBackupError when `data` isn't a memory backup.
152
+ */
153
+ importBackup(data: unknown): Promise<MemoryImportResult>;
154
+ /** Plain-text export of a scope, for the OS share sheet. */
155
+ exportText(scope: "session" | "day" | "all", at?: number): Promise<string>;
156
+ private ensureLoaded;
157
+ private loadFor;
158
+ /**
159
+ * One-time migration: fold the Assist miniapp's per-app store (the previous
160
+ * home of this timeline) into the shared user-scoped keys. Assist's old keys
161
+ * are left in place; its new build reads through the memory bridge instead.
162
+ */
163
+ private migrateFromAssist;
164
+ /** Keep the newest MEMORY_BOUNDS.maxEntries; nothing goes for age — deleting is the user's call. */
165
+ private prune;
166
+ private key;
167
+ /**
168
+ * Mark the log dirty and arm the debounce timer. Repeated appends inside the
169
+ * window collapse into a single serialization; the first append after a
170
+ * flush starts a fresh window (trailing-edge, so a steady stream of speech
171
+ * still lands on disk every `writeDebounceMs`).
172
+ */
173
+ private schedulePersistLog;
174
+ private persistLog;
175
+ private persistSummaries;
176
+ private emitChanged;
177
+ }
178
+ //# sourceMappingURL=MemoryStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../../src/host/memory/MemoryStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,sBAAsB,CAAA;AAwB7B;;;;;;GAMG;AACH,eAAO,MAAM,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