aws-runtime-bridge 1.7.33 → 1.7.34

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/dist/index.js CHANGED
@@ -18,6 +18,7 @@ import { mcpRouter } from "./routes/mcp.js";
18
18
  import { terminalRouter, sdkSessions } from "./routes/terminal.js";
19
19
  import { sessionsRouter } from "./routes/sessions.js";
20
20
  import { gitRouter } from "./routes/git.js";
21
+ import { memoryRouter } from "./routes/memory.js";
21
22
  import { fileBrowserRouter } from "./routes/file-browser.js";
22
23
  import { aiSourcesRouter } from "./routes/ai-sources.js";
23
24
  import { processesRouter } from "./routes/processes.js";
@@ -270,6 +271,7 @@ app.use("/runtime", sessionsRouter);
270
271
  app.use("/runtime", processesRouter);
271
272
  app.use("/runtime", systemMetricsRouter);
272
273
  app.use("/runtime", gitRouter);
274
+ app.use("/runtime", memoryRouter);
273
275
  app.use("/runtime", aiSourcesRouter);
274
276
  app.use("/pty", ptyRouter);
275
277
  app.use("/api/file-browser", fileBrowserRouter);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=memory-route-wiring.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-route-wiring.test.d.ts","sourceRoot":"","sources":["../../src/routes/memory-route-wiring.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { describe, expect, it } from "vitest";
5
+ const currentDir = dirname(fileURLToPath(import.meta.url));
6
+ const srcDir = resolve(currentDir, "..");
7
+ describe("memory route wiring", () => {
8
+ it("mounts the authenticated memory list route under /runtime", () => {
9
+ const routeSource = readFileSync(resolve(currentDir, "./memory.ts"), "utf-8");
10
+ const indexSource = readFileSync(resolve(srcDir, "./index.ts"), "utf-8");
11
+ expect(routeSource).toMatch(/memoryRouter\.post\(\s*"\/memory\/list",\s*validateToken/);
12
+ expect(indexSource).toContain('import { memoryRouter } from "./routes/memory.js";');
13
+ expect(indexSource).toContain('app.use("/runtime", memoryRouter);');
14
+ });
15
+ });
@@ -0,0 +1,25 @@
1
+ export declare const memoryRouter: import("express-serve-static-core").Router;
2
+ type MemoryType = "task_list" | "recently_memory" | "memory";
3
+ interface MemoryRecord {
4
+ id: string;
5
+ uri: string;
6
+ domain: string;
7
+ path: string;
8
+ content: string;
9
+ memory_type: MemoryType;
10
+ createdAt: string;
11
+ updatedAt: string;
12
+ version: number;
13
+ }
14
+ /**
15
+ * 解析永久记忆目录。
16
+ * 主流程:使用请求中的 Agent 工作区路径,定位该工作区下 .agentswork/memory/memory 分域 JSON 文件。
17
+ */
18
+ export declare function resolvePermanentMemoryStorePath(workspacePath: string): string;
19
+ /**
20
+ * 读取工作区永久记忆。
21
+ * 主流程:遍历 domain JSON -> 规范化记录 -> 仅返回 memory 类型并按更新时间倒序展示。
22
+ */
23
+ export declare function listPermanentMemoriesFromWorkspace(workspacePath: string): Promise<MemoryRecord[]>;
24
+ export {};
25
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/routes/memory.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,4CAAW,CAAC;AAErC,KAAK,UAAU,GAAG,WAAW,GAAG,iBAAiB,GAAG,QAAQ,CAAC;AAE7D,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,UAAU,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAQD;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAY7E;AAgDD;;;GAGG;AACH,wBAAsB,kCAAkC,CACtD,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,YAAY,EAAE,CAAC,CAoCzB"}
@@ -0,0 +1,98 @@
1
+ import { Router } from "express";
2
+ import { promises as fs } from "node:fs";
3
+ import path from "node:path";
4
+ import { validateToken } from "../middleware/auth.js";
5
+ export const memoryRouter = Router();
6
+ const URI_PATTERN = /^([a-zA-Z_][a-zA-Z0-9_]*):\/\/(.*)$/;
7
+ /**
8
+ * 解析永久记忆目录。
9
+ * 主流程:使用请求中的 Agent 工作区路径,定位该工作区下 .agentswork/memory/memory 分域 JSON 文件。
10
+ */
11
+ export function resolvePermanentMemoryStorePath(workspacePath) {
12
+ const normalizedWorkspacePath = String(workspacePath || "").trim();
13
+ if (!normalizedWorkspacePath) {
14
+ throw new Error("workspacePath is required");
15
+ }
16
+ return path.join(path.normalize(normalizedWorkspacePath), ".agentswork", "memory", "memory");
17
+ }
18
+ function normalizeUri(input) {
19
+ const matched = URI_PATTERN.exec(String(input || "").trim());
20
+ if (!matched) {
21
+ throw new Error(`Invalid memory uri: ${input}`);
22
+ }
23
+ const domain = matched[1]?.toLowerCase();
24
+ const normalizedPath = (matched[2] || "").replace(/^\/+|\/+$/g, "");
25
+ if (!domain || !normalizedPath) {
26
+ throw new Error(`Invalid memory uri: ${input}`);
27
+ }
28
+ return {
29
+ uri: `${domain}://${normalizedPath}`,
30
+ domain,
31
+ path: normalizedPath,
32
+ };
33
+ }
34
+ function normalizeMemoryRecord(uri, record) {
35
+ const memoryType = record.memory_type || "memory";
36
+ if (memoryType !== "memory") {
37
+ return null;
38
+ }
39
+ const normalized = normalizeUri(record.uri || uri);
40
+ return {
41
+ id: String(record.id || normalized.uri),
42
+ uri: normalized.uri,
43
+ domain: normalized.domain,
44
+ path: normalized.path,
45
+ content: String(record.content || ""),
46
+ memory_type: "memory",
47
+ createdAt: String(record.createdAt || record.updatedAt || ""),
48
+ updatedAt: String(record.updatedAt || record.createdAt || ""),
49
+ version: typeof record.version === "number" ? record.version : 1,
50
+ };
51
+ }
52
+ /**
53
+ * 读取工作区永久记忆。
54
+ * 主流程:遍历 domain JSON -> 规范化记录 -> 仅返回 memory 类型并按更新时间倒序展示。
55
+ */
56
+ export async function listPermanentMemoriesFromWorkspace(workspacePath) {
57
+ const storePath = resolvePermanentMemoryStorePath(workspacePath);
58
+ let entries;
59
+ try {
60
+ entries = await fs.readdir(storePath);
61
+ }
62
+ catch (error) {
63
+ const err = error;
64
+ if (err.code === "ENOENT") {
65
+ return [];
66
+ }
67
+ throw new Error(`memory store is not accessible: ${storePath}${err.message ? ` (${err.message})` : ""}`);
68
+ }
69
+ const records = [];
70
+ for (const entry of entries) {
71
+ if (!entry.endsWith(".json")) {
72
+ continue;
73
+ }
74
+ const filePath = path.join(storePath, entry);
75
+ const raw = await fs.readFile(filePath, "utf-8");
76
+ const parsed = JSON.parse(raw);
77
+ const byUri = parsed.by_uri && typeof parsed.by_uri === "object" ? parsed.by_uri : {};
78
+ for (const [uri, record] of Object.entries(byUri)) {
79
+ const normalized = normalizeMemoryRecord(uri, record);
80
+ if (normalized) {
81
+ records.push(normalized);
82
+ }
83
+ }
84
+ }
85
+ records.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
86
+ return records;
87
+ }
88
+ memoryRouter.post("/memory/list", validateToken, async (req, res) => {
89
+ try {
90
+ const workspacePath = String(req.body?.workspacePath || "");
91
+ const records = await listPermanentMemoriesFromWorkspace(workspacePath);
92
+ res.json(records);
93
+ }
94
+ catch (error) {
95
+ const message = error instanceof Error ? error.message : String(error);
96
+ res.status(400).json({ error: message });
97
+ }
98
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=memory.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.test.d.ts","sourceRoot":"","sources":["../../src/routes/memory.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ import { mkdtemp, mkdir, writeFile } from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { describe, expect, it } from "vitest";
5
+ import { listPermanentMemoriesFromWorkspace, resolvePermanentMemoryStorePath, } from "./memory.js";
6
+ describe("runtime permanent memory route helpers", () => {
7
+ it("resolves permanent memory under the agent workspace", () => {
8
+ expect(resolvePermanentMemoryStorePath("/workspace/project").replace(/\\/g, "/")).toBe("/workspace/project/.agentswork/memory/memory");
9
+ });
10
+ it("lists only permanent memory records from workspace-local domain files", async () => {
11
+ const workspacePath = await mkdtemp(path.join(os.tmpdir(), "aws-memory-workspace-"));
12
+ const storePath = resolvePermanentMemoryStorePath(workspacePath);
13
+ await mkdir(storePath, { recursive: true });
14
+ await writeFile(path.join(storePath, "core.json"), JSON.stringify({
15
+ by_uri: {
16
+ "core://agent/profile": {
17
+ id: "m-1",
18
+ uri: "Core://agent/profile/",
19
+ content: "profile",
20
+ memory_type: "memory",
21
+ createdAt: "2026-01-01T00:00:00.000Z",
22
+ updatedAt: "2026-01-02T00:00:00.000Z",
23
+ version: 2,
24
+ },
25
+ "core://task/current": {
26
+ id: "t-1",
27
+ uri: "core://task/current",
28
+ content: "task",
29
+ memory_type: "task_list",
30
+ createdAt: "2026-01-01T00:00:00.000Z",
31
+ updatedAt: "2026-01-03T00:00:00.000Z",
32
+ version: 1,
33
+ },
34
+ },
35
+ }), "utf-8");
36
+ const records = await listPermanentMemoriesFromWorkspace(workspacePath);
37
+ expect(records).toHaveLength(1);
38
+ expect(records[0]).toMatchObject({
39
+ id: "m-1",
40
+ uri: "core://agent/profile",
41
+ domain: "core",
42
+ path: "agent/profile",
43
+ content: "profile",
44
+ memory_type: "memory",
45
+ version: 2,
46
+ });
47
+ });
48
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-runtime-bridge",
3
- "version": "1.7.33",
3
+ "version": "1.7.34",
4
4
  "description": "AgentsWorkStudio runtime bridge service for machine-level agent runtime integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",