@hyperdreamer/pi-webui 1.10.2 → 1.10.4

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.
@@ -1,55 +0,0 @@
1
- // Generated from pi-webui-plugins/workspace-memory/memoryClient.ts. Do not edit directly.
2
- function isRecord(value) {
3
- return value !== null && typeof value === "object";
4
- }
5
- function parseMemoryEntry(value) {
6
- if (!isRecord(value))
7
- return undefined;
8
- const id = value["id"];
9
- const content = value["content"];
10
- if (typeof id !== "string" || typeof content !== "string")
11
- return undefined;
12
- const entry = { id, content };
13
- const category = value["category"];
14
- if (typeof category === "string")
15
- entry.category = category;
16
- const created = value["created"];
17
- if (typeof created === "string")
18
- entry.created = created;
19
- const last = value["last"];
20
- if (typeof last === "string")
21
- entry.last = last;
22
- const failureReason = value["failureReason"];
23
- if (typeof failureReason === "string")
24
- entry.failureReason = failureReason;
25
- return entry;
26
- }
27
- function parseEntries(data) {
28
- if (!isRecord(data))
29
- throw new Error("Invalid memory API response");
30
- const entries = data["entries"];
31
- if (!Array.isArray(entries))
32
- throw new Error("Invalid memory API response");
33
- const result = [];
34
- for (const raw of entries) {
35
- const parsed = parseMemoryEntry(raw);
36
- if (parsed !== undefined)
37
- result.push(parsed);
38
- }
39
- return result;
40
- }
41
- export async function fetchGlobalMemories() {
42
- const response = await fetch("api/agent-memory/global");
43
- if (!response.ok) {
44
- throw new Error("Failed to load global memories: " + String(response.status));
45
- }
46
- return parseEntries(await response.json());
47
- }
48
- export async function fetchProjectMemories(projectPath) {
49
- const params = new URLSearchParams({ projectPath });
50
- const response = await fetch("api/agent-memory/project?" + String(params));
51
- if (!response.ok) {
52
- throw new Error("Failed to load project memories: " + String(response.status));
53
- }
54
- return parseEntries(await response.json());
55
- }
@@ -1,54 +0,0 @@
1
- // Generated from pi-webui-plugins/workspace-memory/memoryLoadController.ts. Do not edit directly.
2
- const PROJECT_UNAVAILABLE_MESSAGE = "Project-specific memory could not be loaded.";
3
- /** Coordinates independently fetched memory scopes and suppresses superseded loads. */
4
- export class MemoryLoadController {
5
- fetchers;
6
- generation = 0;
7
- constructor(fetchers) {
8
- this.fetchers = fetchers;
9
- }
10
- async load(projectPath) {
11
- const loadGeneration = ++this.generation;
12
- const globalLoad = invokeFetcher(() => this.fetchers.fetchGlobalMemories());
13
- const projectLoad = invokeFetcher(() => this.fetchers.fetchProjectMemories(projectPath))
14
- .then((entries) => ({ kind: "available", entries }))
15
- .catch(() => ({ kind: "unavailable" }));
16
- let globalEntries;
17
- try {
18
- globalEntries = await globalLoad;
19
- }
20
- catch (error) {
21
- if (!this.isCurrent(loadGeneration))
22
- return undefined;
23
- return {
24
- kind: "global-error",
25
- message: error instanceof Error ? error.message : "Failed to load memories.",
26
- };
27
- }
28
- const projectOutcome = await projectLoad;
29
- if (!this.isCurrent(loadGeneration))
30
- return undefined;
31
- if (projectOutcome.kind === "unavailable") {
32
- return {
33
- kind: "loaded",
34
- globalEntries,
35
- projectEntries: [],
36
- projectUnavailableMessage: PROJECT_UNAVAILABLE_MESSAGE,
37
- };
38
- }
39
- return {
40
- kind: "loaded",
41
- globalEntries,
42
- projectEntries: projectOutcome.entries,
43
- };
44
- }
45
- invalidate() {
46
- this.generation += 1;
47
- }
48
- isCurrent(loadGeneration) {
49
- return this.generation === loadGeneration;
50
- }
51
- }
52
- async function invokeFetcher(fetcher) {
53
- return fetcher();
54
- }