memax-cli 0.1.0-alpha.9 → 0.1.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/assets/skills/memax-memory/SKILL.md +173 -0
- package/dist/commands/agent-configs.d.ts +41 -0
- package/dist/commands/agent-configs.d.ts.map +1 -0
- package/dist/commands/agent-configs.js +1290 -0
- package/dist/commands/agent-configs.js.map +1 -0
- package/dist/commands/agent-configs.test.d.ts +2 -0
- package/dist/commands/agent-configs.test.d.ts.map +1 -0
- package/dist/commands/agent-configs.test.js +122 -0
- package/dist/commands/agent-configs.test.js.map +1 -0
- package/dist/commands/agent-sessions.d.ts +74 -0
- package/dist/commands/agent-sessions.d.ts.map +1 -0
- package/dist/commands/agent-sessions.js +1513 -0
- package/dist/commands/agent-sessions.js.map +1 -0
- package/dist/commands/agent-sessions.test.d.ts +2 -0
- package/dist/commands/agent-sessions.test.d.ts.map +1 -0
- package/dist/commands/agent-sessions.test.js +255 -0
- package/dist/commands/agent-sessions.test.js.map +1 -0
- package/dist/commands/agents.d.ts +3 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +36 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/ask.d.ts +15 -0
- package/dist/commands/ask.d.ts.map +1 -0
- package/dist/commands/ask.js +483 -0
- package/dist/commands/ask.js.map +1 -0
- package/dist/commands/auth.d.ts +7 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +103 -8
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/capture.d.ts +19 -0
- package/dist/commands/capture.d.ts.map +1 -0
- package/dist/commands/capture.js +69 -0
- package/dist/commands/capture.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +13 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -0
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +15 -18
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/dreams.d.ts +22 -0
- package/dist/commands/dreams.d.ts.map +1 -0
- package/dist/commands/dreams.js +251 -0
- package/dist/commands/dreams.js.map +1 -0
- package/dist/commands/dreams.test.d.ts +2 -0
- package/dist/commands/dreams.test.d.ts.map +1 -0
- package/dist/commands/dreams.test.js +39 -0
- package/dist/commands/dreams.test.js.map +1 -0
- package/dist/commands/hook.d.ts +2 -0
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +25 -103
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/hub.d.ts +37 -0
- package/dist/commands/hub.d.ts.map +1 -0
- package/dist/commands/hub.js +347 -0
- package/dist/commands/hub.js.map +1 -0
- package/dist/commands/hub.test.d.ts +2 -0
- package/dist/commands/hub.test.d.ts.map +1 -0
- package/dist/commands/hub.test.js +62 -0
- package/dist/commands/hub.test.js.map +1 -0
- package/dist/commands/import.d.ts +13 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +257 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/import.test.d.ts +2 -0
- package/dist/commands/import.test.d.ts.map +1 -0
- package/dist/commands/import.test.js +11 -0
- package/dist/commands/import.test.js.map +1 -0
- package/dist/commands/list.d.ts +9 -2
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +118 -9
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/list.test.d.ts +2 -0
- package/dist/commands/list.test.d.ts.map +1 -0
- package/dist/commands/list.test.js +20 -0
- package/dist/commands/list.test.js.map +1 -0
- package/dist/commands/login.d.ts +7 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +81 -20
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +386 -65
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/push.d.ts +6 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +42 -8
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/recall.d.ts +11 -1
- package/dist/commands/recall.d.ts.map +1 -1
- package/dist/commands/recall.js +228 -41
- package/dist/commands/recall.js.map +1 -1
- package/dist/commands/recall.test.d.ts +2 -0
- package/dist/commands/recall.test.d.ts.map +1 -0
- package/dist/commands/recall.test.js +31 -0
- package/dist/commands/recall.test.js.map +1 -0
- package/dist/commands/setup-hooks.d.ts +13 -0
- package/dist/commands/setup-hooks.d.ts.map +1 -0
- package/dist/commands/setup-hooks.js +193 -0
- package/dist/commands/setup-hooks.js.map +1 -0
- package/dist/commands/setup-instructions.d.ts +21 -0
- package/dist/commands/setup-instructions.d.ts.map +1 -0
- package/dist/commands/setup-instructions.js +172 -0
- package/dist/commands/setup-instructions.js.map +1 -0
- package/dist/commands/setup-mcp.d.ts +40 -0
- package/dist/commands/setup-mcp.d.ts.map +1 -0
- package/dist/commands/setup-mcp.js +414 -0
- package/dist/commands/setup-mcp.js.map +1 -0
- package/dist/commands/setup-types.d.ts +33 -0
- package/dist/commands/setup-types.d.ts.map +1 -0
- package/dist/commands/setup-types.js +60 -0
- package/dist/commands/setup-types.js.map +1 -0
- package/dist/commands/setup.d.ts +10 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +216 -534
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/show.d.ts +5 -1
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +36 -14
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/topic.d.ts +32 -0
- package/dist/commands/topic.d.ts.map +1 -0
- package/dist/commands/topic.js +265 -0
- package/dist/commands/topic.js.map +1 -0
- package/dist/commands/topic.test.d.ts +2 -0
- package/dist/commands/topic.test.d.ts.map +1 -0
- package/dist/commands/topic.test.js +114 -0
- package/dist/commands/topic.test.js.map +1 -0
- package/dist/index.js +35 -144
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +10 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +104 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/client.test.d.ts +2 -0
- package/dist/lib/client.test.d.ts.map +1 -0
- package/dist/lib/client.test.js +44 -0
- package/dist/lib/client.test.js.map +1 -0
- package/dist/lib/config.d.ts +43 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +72 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/credentials.d.ts +3 -0
- package/dist/lib/credentials.d.ts.map +1 -1
- package/dist/lib/credentials.js +24 -2
- package/dist/lib/credentials.js.map +1 -1
- package/dist/lib/hubs.d.ts +7 -0
- package/dist/lib/hubs.d.ts.map +1 -0
- package/dist/lib/hubs.js +33 -0
- package/dist/lib/hubs.js.map +1 -0
- package/dist/lib/hubs.test.d.ts +2 -0
- package/dist/lib/hubs.test.d.ts.map +1 -0
- package/dist/lib/hubs.test.js +58 -0
- package/dist/lib/hubs.test.js.map +1 -0
- package/dist/lib/project-context.d.ts +56 -0
- package/dist/lib/project-context.d.ts.map +1 -0
- package/dist/lib/project-context.js +225 -0
- package/dist/lib/project-context.js.map +1 -0
- package/dist/lib/project-context.test.d.ts +2 -0
- package/dist/lib/project-context.test.d.ts.map +1 -0
- package/dist/lib/project-context.test.js +75 -0
- package/dist/lib/project-context.test.js.map +1 -0
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/prompt.js +41 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/trash.d.ts +6 -0
- package/dist/lib/trash.d.ts.map +1 -0
- package/dist/lib/trash.js +28 -0
- package/dist/lib/trash.js.map +1 -0
- package/package.json +17 -13
- package/.vscode/mcp.json +0 -8
- package/dist/commands/sync.d.ts +0 -12
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js +0 -414
- package/dist/commands/sync.js.map +0 -1
- package/dist/lib/api.d.ts +0 -4
- package/dist/lib/api.d.ts.map +0 -1
- package/dist/lib/api.js +0 -95
- package/dist/lib/api.js.map +0 -1
- package/src/commands/auth.ts +0 -92
- package/src/commands/config.ts +0 -27
- package/src/commands/delete.ts +0 -58
- package/src/commands/hook.ts +0 -243
- package/src/commands/list.ts +0 -38
- package/src/commands/login.ts +0 -164
- package/src/commands/mcp.ts +0 -405
- package/src/commands/push.ts +0 -137
- package/src/commands/recall.ts +0 -163
- package/src/commands/setup.ts +0 -1077
- package/src/commands/show.ts +0 -35
- package/src/commands/sync.ts +0 -506
- package/src/index.ts +0 -213
- package/src/lib/api.ts +0 -110
- package/src/lib/config.ts +0 -61
- package/src/lib/credentials.ts +0 -42
- package/tsconfig.json +0 -9
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildTopicPathMap, flattenTopics, resolveTopicReference, topicDisplayCount, topicDisplayID, } from "./topic.js";
|
|
3
|
+
describe("topicDisplayCount", () => {
|
|
4
|
+
it("prefers subtree totals over direct counts", () => {
|
|
5
|
+
expect(topicDisplayCount({ memory_count: 0, total_memory_count: 7 })).toBe(7);
|
|
6
|
+
});
|
|
7
|
+
it("falls back to direct count when subtree total is zero", () => {
|
|
8
|
+
expect(topicDisplayCount({ memory_count: 3, total_memory_count: 0 })).toBe(0);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe("buildTopicPathMap", () => {
|
|
12
|
+
it("builds slash-delimited topic paths from the tree", () => {
|
|
13
|
+
const map = buildTopicPathMap([
|
|
14
|
+
{
|
|
15
|
+
id: "root",
|
|
16
|
+
owner_id: "u1",
|
|
17
|
+
hub_id: "h1",
|
|
18
|
+
parent_id: null,
|
|
19
|
+
name: "Engineering",
|
|
20
|
+
description: "",
|
|
21
|
+
icon: "folder",
|
|
22
|
+
position: 0,
|
|
23
|
+
pinned: false,
|
|
24
|
+
user_modified: false,
|
|
25
|
+
created_at: "",
|
|
26
|
+
updated_at: "",
|
|
27
|
+
memory_count: 1,
|
|
28
|
+
total_memory_count: 2,
|
|
29
|
+
kind_dots: [],
|
|
30
|
+
children: [
|
|
31
|
+
{
|
|
32
|
+
id: "child",
|
|
33
|
+
owner_id: "u1",
|
|
34
|
+
hub_id: "h1",
|
|
35
|
+
parent_id: "root",
|
|
36
|
+
name: "Caching",
|
|
37
|
+
description: "",
|
|
38
|
+
icon: "folder",
|
|
39
|
+
position: 0,
|
|
40
|
+
pinned: false,
|
|
41
|
+
user_modified: false,
|
|
42
|
+
created_at: "",
|
|
43
|
+
updated_at: "",
|
|
44
|
+
memory_count: 1,
|
|
45
|
+
total_memory_count: 1,
|
|
46
|
+
kind_dots: [],
|
|
47
|
+
children: [],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
expect(map.get("root")).toBe("Engineering");
|
|
53
|
+
expect(map.get("child")).toBe("Engineering / Caching");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe("topicDisplayID", () => {
|
|
57
|
+
it("shortens IDs by default", () => {
|
|
58
|
+
expect(topicDisplayID("12345678-1234-1234-1234-123456789abc")).toBe("12345678");
|
|
59
|
+
});
|
|
60
|
+
it("shows full IDs in verbose mode", () => {
|
|
61
|
+
expect(topicDisplayID("12345678-1234-1234-1234-123456789abc", true)).toBe("12345678-1234-1234-1234-123456789abc");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe("resolveTopicReference", () => {
|
|
65
|
+
const topics = [
|
|
66
|
+
{
|
|
67
|
+
id: "12345678-1234-1234-1234-123456789abc",
|
|
68
|
+
owner_id: "u1",
|
|
69
|
+
hub_id: "h1",
|
|
70
|
+
parent_id: null,
|
|
71
|
+
name: "Engineering",
|
|
72
|
+
description: "",
|
|
73
|
+
icon: "folder",
|
|
74
|
+
position: 0,
|
|
75
|
+
pinned: false,
|
|
76
|
+
user_modified: false,
|
|
77
|
+
created_at: "",
|
|
78
|
+
updated_at: "",
|
|
79
|
+
memory_count: 1,
|
|
80
|
+
total_memory_count: 2,
|
|
81
|
+
kind_dots: [],
|
|
82
|
+
children: [
|
|
83
|
+
{
|
|
84
|
+
id: "abcdef12-1234-1234-1234-123456789abc",
|
|
85
|
+
owner_id: "u1",
|
|
86
|
+
hub_id: "h1",
|
|
87
|
+
parent_id: "12345678-1234-1234-1234-123456789abc",
|
|
88
|
+
name: "Caching",
|
|
89
|
+
description: "",
|
|
90
|
+
icon: "folder",
|
|
91
|
+
position: 0,
|
|
92
|
+
pinned: false,
|
|
93
|
+
user_modified: false,
|
|
94
|
+
created_at: "",
|
|
95
|
+
updated_at: "",
|
|
96
|
+
memory_count: 1,
|
|
97
|
+
total_memory_count: 1,
|
|
98
|
+
kind_dots: [],
|
|
99
|
+
children: [],
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
it("resolves exact IDs", () => {
|
|
105
|
+
expect(resolveTopicReference(topics, "12345678-1234-1234-1234-123456789abc")).toBe("12345678-1234-1234-1234-123456789abc");
|
|
106
|
+
});
|
|
107
|
+
it("resolves unique ID prefixes", () => {
|
|
108
|
+
expect(resolveTopicReference(topics, "abcdef12")).toBe("abcdef12-1234-1234-1234-123456789abc");
|
|
109
|
+
});
|
|
110
|
+
it("flattens nested topics for resolution", () => {
|
|
111
|
+
expect(flattenTopics(topics)).toHaveLength(2);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=topic.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topic.test.js","sourceRoot":"","sources":["../../src/commands/topic.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC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ACb,QAAQ,EAAE;gBACR;oBACE,EAAE,EAAE,sCAAsC;oBAC1C,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAI;oBACZ,SAAS,EAAE,sCAAsC;oBACjD,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,EAAE;oBACf,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,CAAC;oBACX,MAAM,EAAE,KAAK;oBACb,aAAa,EAAE,KAAK;oBACpB,UAAU,EAAE,EAAE;oBACd,UAAU,EAAE,EAAE;oBACd,YAAY,EAAE,CAAC;oBACf,kBAAkB,EAAE,CAAC;oBACrB,SAAS,EAAE,EAAE;oBACb,QAAQ,EAAE,EAAE;iBACb;aACF;SACF;KACF,CAAC;IAEF,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAC5B,MAAM,CACJ,qBAAqB,CAAC,MAAM,EAAE,sCAAsC,CAAC,CACtE,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CACpD,sCAAsC,CACvC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,18 +3,24 @@ import { Command } from "commander";
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { join, dirname } from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
6
|
+
import { registerPushCommand } from "./commands/push.js";
|
|
7
|
+
import { registerRecallCommand } from "./commands/recall.js";
|
|
8
|
+
import { registerAskCommand } from "./commands/ask.js";
|
|
9
|
+
import { registerListCommand } from "./commands/list.js";
|
|
10
|
+
import { registerShowCommand } from "./commands/show.js";
|
|
11
|
+
import { registerDeleteCommand } from "./commands/delete.js";
|
|
12
|
+
import { registerImportCommand } from "./commands/import.js";
|
|
13
|
+
import { registerAgentsCommands } from "./commands/agents.js";
|
|
14
|
+
import { registerHookCommand } from "./commands/hook.js";
|
|
15
|
+
import { registerConfigCommand } from "./commands/config.js";
|
|
16
|
+
import { registerLoginCommands } from "./commands/login.js";
|
|
17
|
+
import { registerAuthCommand } from "./commands/auth.js";
|
|
16
18
|
import { registerMcpCommand } from "./commands/mcp.js";
|
|
17
|
-
import {
|
|
19
|
+
import { registerSetupCommands } from "./commands/setup.js";
|
|
20
|
+
import { registerHubCommands } from "./commands/hub.js";
|
|
21
|
+
import { registerTopicCommands } from "./commands/topic.js";
|
|
22
|
+
import { registerCaptureSessionCommand } from "./commands/capture.js";
|
|
23
|
+
import { registerDreamsCommands } from "./commands/dreams.js";
|
|
18
24
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
25
|
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
20
26
|
const program = new Command();
|
|
@@ -22,139 +28,24 @@ program
|
|
|
22
28
|
.name("memax")
|
|
23
29
|
.description("Universal context & memory hub for AI agents")
|
|
24
30
|
.version(pkg.version);
|
|
25
|
-
// ---
|
|
26
|
-
program
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
program
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.option("-t, --tags <tags>", "Filter by tags")
|
|
41
|
-
.option("-l, --limit <n>", "Max results", "5")
|
|
42
|
-
.option("--format <format>", "Output format: text, json", "text")
|
|
43
|
-
.option("--hook", "Output in agent-injectable format")
|
|
44
|
-
.option("--max-tokens <number>", "Maximum tokens to output (approximate)")
|
|
45
|
-
.option("--include-archived", "Include archived notes")
|
|
46
|
-
.action(recallCommand);
|
|
47
|
-
program
|
|
48
|
-
.command("list")
|
|
49
|
-
.description("List your knowledge notes")
|
|
50
|
-
.option("-c, --category <category>", "Filter by category")
|
|
51
|
-
.option("--state <state>", "Filter by state: active, cooling, archived")
|
|
52
|
-
.option("-l, --limit <n>", "Max results", "20")
|
|
53
|
-
.action(listCommand);
|
|
54
|
-
program
|
|
55
|
-
.command("show <id>")
|
|
56
|
-
.description("Show a specific note")
|
|
57
|
-
.action(showCommand);
|
|
58
|
-
program
|
|
59
|
-
.command("delete <id>")
|
|
60
|
-
.description("Delete a note")
|
|
61
|
-
.option("-y, --yes", "Skip confirmation")
|
|
62
|
-
.action(deleteCommand);
|
|
63
|
-
// Aliases
|
|
64
|
-
program
|
|
65
|
-
.command("remember [content]")
|
|
66
|
-
.description("Alias for push — save knowledge to your Memax workspace")
|
|
67
|
-
.option("-f, --file <path>", "File to push")
|
|
68
|
-
.option("-c, --category <category>", "Category (auto-detected if omitted)")
|
|
69
|
-
.option("-t, --tags <tags>", "Comma-separated tags")
|
|
70
|
-
.option("--title <title>", "Note title")
|
|
71
|
-
.option("--stdin", "Read content from stdin")
|
|
72
|
-
.action(pushCommand);
|
|
73
|
-
program
|
|
74
|
-
.command("forget <id>")
|
|
75
|
-
.description("Alias for delete — remove a note from your workspace")
|
|
76
|
-
.option("-y, --yes", "Skip confirmation")
|
|
77
|
-
.action(deleteCommand);
|
|
78
|
-
// --- Sync ---
|
|
79
|
-
const syncCmd = program
|
|
80
|
-
.command("sync [directory]")
|
|
81
|
-
.description("Sync a directory or agent memory to your Memax workspace")
|
|
82
|
-
.option("-w, --watch", "Watch for changes (coming soon)")
|
|
83
|
-
.option("-b, --boundary <level>", "Visibility level: private, team, org", "private")
|
|
84
|
-
.option("-c, --category <category>", "Default category (auto-detected if omitted)")
|
|
85
|
-
.option("--ignore <patterns>", "Comma-separated directories to ignore")
|
|
86
|
-
.option("--agent-memory", "Sync native AI agent memory files (Claude Code, Cursor, Codex)")
|
|
87
|
-
.option("-y, --yes", "Skip confirmation for large syncs")
|
|
88
|
-
.action(syncCommand);
|
|
89
|
-
syncCmd
|
|
90
|
-
.command("agents")
|
|
91
|
-
.description("Sync native AI agent memory files to Memax")
|
|
92
|
-
.action(syncAgentMemoryCommand);
|
|
93
|
-
// --- Agent integration setup ---
|
|
94
|
-
program
|
|
95
|
-
.command("setup")
|
|
96
|
-
.description("Set up AI agent integrations (auto-detects installed agents)")
|
|
97
|
-
.option("--mcp", "Enable MCP server (agent tools)")
|
|
98
|
-
.option("--hooks", "Enable context injection hooks")
|
|
99
|
-
.option("--instructions", "Inject memax instructions into agent config files")
|
|
100
|
-
.option("--all", "Enable MCP + hooks + instructions")
|
|
101
|
-
.option("--local", "Use local stdio MCP instead of remote server")
|
|
102
|
-
.option("--print", "Print MCP config JSON to copy/paste (no changes made)")
|
|
103
|
-
.option("--only <agents>", "Only configure these agents (comma-separated)")
|
|
104
|
-
.option("--skip <agents>", "Skip these agents (comma-separated)")
|
|
105
|
-
.action(setupCommand);
|
|
106
|
-
program
|
|
107
|
-
.command("teardown")
|
|
108
|
-
.description("Remove Memax integrations from agents")
|
|
109
|
-
.option("--only <agents>", "Only remove from these agents (comma-separated)")
|
|
110
|
-
.action(teardownCommand);
|
|
111
|
-
program
|
|
112
|
-
.command("hook <action> <agent>")
|
|
113
|
-
.description("Manage agent hooks (install/uninstall claude-code)")
|
|
114
|
-
.action(hookCommand);
|
|
115
|
-
// --- Auth ---
|
|
116
|
-
program
|
|
117
|
-
.command("login")
|
|
118
|
-
.description("Log in to Memax via GitHub")
|
|
119
|
-
.action(loginCommand);
|
|
120
|
-
program
|
|
121
|
-
.command("logout")
|
|
122
|
-
.description("Clear saved credentials")
|
|
123
|
-
.action(logoutCommand);
|
|
124
|
-
program
|
|
125
|
-
.command("whoami")
|
|
126
|
-
.description("Show current user")
|
|
127
|
-
.action(whoamiCommand);
|
|
128
|
-
// --- API Keys ---
|
|
129
|
-
const authCmd = program
|
|
130
|
-
.command("auth")
|
|
131
|
-
.description("Manage authentication and API keys");
|
|
132
|
-
authCmd
|
|
133
|
-
.command("create-key <name>")
|
|
134
|
-
.description("Create an API key for CI/CD or non-interactive use")
|
|
135
|
-
.option("--expires <days>", "Expire after N days (default: never)")
|
|
136
|
-
.action(createKeyCommand);
|
|
137
|
-
authCmd
|
|
138
|
-
.command("list-keys")
|
|
139
|
-
.description("List your API keys")
|
|
140
|
-
.action(listKeysCommand);
|
|
141
|
-
authCmd
|
|
142
|
-
.command("revoke-key <id>")
|
|
143
|
-
.description("Revoke an API key")
|
|
144
|
-
.action(revokeKeyCommand);
|
|
145
|
-
// --- MCP Server ---
|
|
31
|
+
// --- Command registration (order defines help layout) ---
|
|
32
|
+
registerPushCommand(program);
|
|
33
|
+
registerRecallCommand(program);
|
|
34
|
+
registerAskCommand(program);
|
|
35
|
+
registerListCommand(program);
|
|
36
|
+
registerShowCommand(program);
|
|
37
|
+
registerDeleteCommand(program);
|
|
38
|
+
registerCaptureSessionCommand(program);
|
|
39
|
+
registerTopicCommands(program);
|
|
40
|
+
registerDreamsCommands(program);
|
|
41
|
+
registerHubCommands(program);
|
|
42
|
+
registerAgentsCommands(program);
|
|
43
|
+
registerImportCommand(program);
|
|
44
|
+
registerSetupCommands(program);
|
|
45
|
+
registerHookCommand(program);
|
|
146
46
|
registerMcpCommand(program);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.description("Manage Memax configuration");
|
|
151
|
-
configCmd
|
|
152
|
-
.command("get [key]")
|
|
153
|
-
.description("Get config value (or all values)")
|
|
154
|
-
.action(configGetCommand);
|
|
155
|
-
configCmd
|
|
156
|
-
.command("set <key> <value>")
|
|
157
|
-
.description("Set a config value")
|
|
158
|
-
.action(configSetCommand);
|
|
47
|
+
registerLoginCommands(program);
|
|
48
|
+
registerAuthCommand(program);
|
|
49
|
+
registerConfigCommand(program);
|
|
159
50
|
program.parse();
|
|
160
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAA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C,CAAC;AACvC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC5B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC/B,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC7B,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAE/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Memax } from "memax-sdk";
|
|
2
|
+
/** Get the shared SDK client instance (lazily created) */
|
|
3
|
+
export declare function getClient(): Memax;
|
|
4
|
+
/** Get an unauthenticated SDK client for auth bootstrap/refresh flows */
|
|
5
|
+
export declare function getPublicClient(): Memax;
|
|
6
|
+
/** Reset the cached client (useful after login/logout) */
|
|
7
|
+
export declare function resetClient(): void;
|
|
8
|
+
export declare function setClientAgent(agentID?: string): void;
|
|
9
|
+
export declare function getAuthHeaders(): Promise<Record<string, string>>;
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAelC,0DAA0D;AAC1D,wBAAgB,SAAS,IAAI,KAAK,CAUjC;AAED,yEAAyE;AACzE,wBAAgB,eAAe,IAAI,KAAK,CAQvC;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAGrD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEtE"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// CLI API client — configures memax-sdk with CLI-specific auth
|
|
3
|
+
//
|
|
4
|
+
// All CLI commands should use `getClient()` instead of raw fetch.
|
|
5
|
+
// Auth flow: MEMAX_API_KEY env var → stored credentials (with auto-refresh).
|
|
6
|
+
// =============================================================================
|
|
7
|
+
import { Memax } from "memax-sdk";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import { loadConfig } from "./config.js";
|
|
10
|
+
import { loadCredentials, saveCredentials, isTokenExpired, getLocalAgentKey, } from "./credentials.js";
|
|
11
|
+
let instance = null;
|
|
12
|
+
let publicInstance = null;
|
|
13
|
+
const seenWarnings = new Set();
|
|
14
|
+
let scopedAgentID = "";
|
|
15
|
+
/** Get the shared SDK client instance (lazily created) */
|
|
16
|
+
export function getClient() {
|
|
17
|
+
if (!instance) {
|
|
18
|
+
const config = loadConfig();
|
|
19
|
+
instance = new Memax({
|
|
20
|
+
apiUrl: config.api_url,
|
|
21
|
+
auth: cliAuthProvider,
|
|
22
|
+
onWarning: printApiWarning,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return instance;
|
|
26
|
+
}
|
|
27
|
+
/** Get an unauthenticated SDK client for auth bootstrap/refresh flows */
|
|
28
|
+
export function getPublicClient() {
|
|
29
|
+
if (!publicInstance) {
|
|
30
|
+
const config = loadConfig();
|
|
31
|
+
publicInstance = new Memax({
|
|
32
|
+
apiUrl: config.api_url,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return publicInstance;
|
|
36
|
+
}
|
|
37
|
+
/** Reset the cached client (useful after login/logout) */
|
|
38
|
+
export function resetClient() {
|
|
39
|
+
instance = null;
|
|
40
|
+
publicInstance = null;
|
|
41
|
+
seenWarnings.clear();
|
|
42
|
+
}
|
|
43
|
+
export function setClientAgent(agentID) {
|
|
44
|
+
scopedAgentID = agentID?.trim() ?? "";
|
|
45
|
+
resetClient();
|
|
46
|
+
}
|
|
47
|
+
export async function getAuthHeaders() {
|
|
48
|
+
return cliAuthProvider();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* CLI auth provider — resolves authorization headers.
|
|
52
|
+
*
|
|
53
|
+
* Priority:
|
|
54
|
+
* 1. MEMAX_API_KEY env var (CI/CD, non-interactive)
|
|
55
|
+
* 2. Stored credentials with automatic token refresh
|
|
56
|
+
*/
|
|
57
|
+
async function cliAuthProvider() {
|
|
58
|
+
// 1. Env var takes priority
|
|
59
|
+
const envKey = process.env.MEMAX_API_KEY;
|
|
60
|
+
if (envKey) {
|
|
61
|
+
return { Authorization: `Bearer ${envKey}` };
|
|
62
|
+
}
|
|
63
|
+
// 2. Agent-scoped local key for local MCP/hooks/capture flows
|
|
64
|
+
if (scopedAgentID) {
|
|
65
|
+
const agentKey = getLocalAgentKey(scopedAgentID);
|
|
66
|
+
if (agentKey) {
|
|
67
|
+
return { Authorization: `Bearer ${agentKey}` };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// 3. Stored user credentials
|
|
71
|
+
const creds = loadCredentials();
|
|
72
|
+
if (!creds?.access_token)
|
|
73
|
+
return {};
|
|
74
|
+
// Auto-refresh if expired
|
|
75
|
+
if (isTokenExpired() && creds.refresh_token) {
|
|
76
|
+
try {
|
|
77
|
+
const tokens = await getPublicClient().auth.refresh(creds.refresh_token);
|
|
78
|
+
if (tokens.access_token) {
|
|
79
|
+
saveCredentials({
|
|
80
|
+
access_token: tokens.access_token,
|
|
81
|
+
refresh_token: tokens.refresh_token,
|
|
82
|
+
expires_at: Date.now() + tokens.expires_in * 1000,
|
|
83
|
+
});
|
|
84
|
+
return { Authorization: `Bearer ${tokens.access_token}` };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Refresh failed — fall through to stale token
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { Authorization: `Bearer ${creds.access_token}` };
|
|
92
|
+
}
|
|
93
|
+
function printApiWarning(warning) {
|
|
94
|
+
if (!warning || seenWarnings.has(warning)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
seenWarnings.add(warning);
|
|
98
|
+
if (warning === "agent_identity_claim_rejected") {
|
|
99
|
+
console.error(chalk.yellow(" Warning: agent attribution was rejected for this write; the memory was saved as you instead."));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
console.error(chalk.yellow(` Warning: ${warning}`));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+DAA+D;AAC/D,EAAE;AACF,kEAAkE;AAClE,6EAA6E;AAC7E,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,IAAI,QAAQ,GAAiB,IAAI,CAAC;AAClC,IAAI,cAAc,GAAiB,IAAI,CAAC;AACxC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;AACvC,IAAI,aAAa,GAAG,EAAE,CAAC;AAEvB,0DAA0D;AAC1D,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,QAAQ,GAAG,IAAI,KAAK,CAAC;YACnB,MAAM,EAAE,MAAM,CAAC,OAAO;YACtB,IAAI,EAAE,eAAe;YACrB,SAAS,EA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
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
const state = vi.hoisted(() => ({
|
|
3
|
+
accessToken: "user-token",
|
|
4
|
+
refreshToken: "refresh-token",
|
|
5
|
+
expiresAt: undefined,
|
|
6
|
+
localAgentKeys: {},
|
|
7
|
+
}));
|
|
8
|
+
vi.mock("./config.js", () => ({
|
|
9
|
+
loadConfig: () => ({ api_url: "http://localhost:8080" }),
|
|
10
|
+
}));
|
|
11
|
+
vi.mock("./credentials.js", () => ({
|
|
12
|
+
loadCredentials: () => ({
|
|
13
|
+
access_token: state.accessToken,
|
|
14
|
+
refresh_token: state.refreshToken,
|
|
15
|
+
expires_at: state.expiresAt,
|
|
16
|
+
local_agent_keys: state.localAgentKeys,
|
|
17
|
+
}),
|
|
18
|
+
saveCredentials: vi.fn(),
|
|
19
|
+
isTokenExpired: () => false,
|
|
20
|
+
getLocalAgentKey: (agentID) => state.localAgentKeys[agentID],
|
|
21
|
+
}));
|
|
22
|
+
import { getAuthHeaders, resetClient, setClientAgent } from "./client.js";
|
|
23
|
+
describe("client auth selection", () => {
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
state.accessToken = "user-token";
|
|
26
|
+
state.refreshToken = "refresh-token";
|
|
27
|
+
state.expiresAt = undefined;
|
|
28
|
+
state.localAgentKeys = {};
|
|
29
|
+
setClientAgent(undefined);
|
|
30
|
+
resetClient();
|
|
31
|
+
});
|
|
32
|
+
it("prefers a stored local agent key when an agent-scoped CLI flow is active", async () => {
|
|
33
|
+
state.localAgentKeys["claude-code"] = "mxk_agent_key";
|
|
34
|
+
setClientAgent("claude-code");
|
|
35
|
+
const headers = await getAuthHeaders();
|
|
36
|
+
expect(headers.Authorization).toBe("Bearer mxk_agent_key");
|
|
37
|
+
});
|
|
38
|
+
it("falls back to the user token when no local agent key exists", async () => {
|
|
39
|
+
setClientAgent("claude-code");
|
|
40
|
+
const headers = await getAuthHeaders();
|
|
41
|
+
expect(headers.Authorization).toBe("Bearer user-token");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=client.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.test.js","sourceRoot":"","sources":["../../src/lib/client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9D,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9B,WAAW,EAAE,YAAY;IACzB,YAAY,EAAE,eAAe;IAC7B,SAAS,EAAE,SAA+B;IAC1C,cAAc,EAAE,EAA4B;CAC7C,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;CACzD,CAAC,CAAC,CAAC;AAEJ,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;IACjC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;QACtB,YAAY,EAAE,KAAK,CAAC,WAAW;QAC/B,aAAa,EAAE,KAAK,CAAC,YAAY;QACjC,UAAU,EAAE,KAAK,CAAC,SAAS;QAC3B,gBAAgB,EAAE,KAAK,CAAC,cAAc;KACvC,CAAC;IACF,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;IACxB,cAAc,EAAE,GAAG,EAAE,CAAC,KAAK;IAC3B,gBAAgB,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;CACrE,CAAC,CAAC,CAAC;AAEJ,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1E,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,UAAU,CAAC,GAAG,EAAE;QACd,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC;QACjC,KAAK,CAAC,YAAY,GAAG,eAAe,CAAC;QACrC,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC;QAC1B,cAAc,CAAC,SAAS,CAAC,CAAC;QAC1B,WAAW,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;QACxF,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC;QAEtD,cAAc,CAAC,aAAa,CAAC,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,CAAC;QAEvC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,cAAc,CAAC,aAAa,CAAC,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,CAAC;QAEvC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
export interface MemaxConfig {
|
|
2
2
|
api_url: string;
|
|
3
3
|
default_hub: string;
|
|
4
|
+
active_hub_id?: string;
|
|
4
5
|
default_boundary: string;
|
|
5
6
|
auto_categorize: boolean;
|
|
7
|
+
device_id?: string;
|
|
8
|
+
sync_sources?: SyncSourceState[];
|
|
9
|
+
agent_session_roots?: AgentSessionRoot[];
|
|
10
|
+
}
|
|
11
|
+
export interface AgentSessionRoot {
|
|
12
|
+
id?: string;
|
|
13
|
+
agent: string;
|
|
14
|
+
root_path: string;
|
|
15
|
+
scope: string;
|
|
16
|
+
session_type?: string;
|
|
17
|
+
include_extensions?: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface SyncSourceState {
|
|
20
|
+
id: string;
|
|
21
|
+
root_path: string;
|
|
22
|
+
kind: "directory";
|
|
23
|
+
ignore_patterns: string[];
|
|
24
|
+
default_boundary?: string;
|
|
25
|
+
deletion_policy: "retain";
|
|
26
|
+
last_sync_at?: string;
|
|
27
|
+
last_mode?: "manual" | "watch";
|
|
28
|
+
last_scan_count?: number;
|
|
29
|
+
last_pushed?: number;
|
|
30
|
+
last_skipped?: number;
|
|
31
|
+
last_errors?: number;
|
|
6
32
|
}
|
|
7
33
|
export declare function getConfigDir(): string;
|
|
8
34
|
export declare function loadConfig(): MemaxConfig;
|
|
9
35
|
export declare function saveConfig(config: Partial<MemaxConfig>): void;
|
|
36
|
+
export declare function getActiveHubID(): string;
|
|
37
|
+
export declare function setActiveHubID(hubID: string): void;
|
|
38
|
+
export declare function getOrCreateDeviceID(): string;
|
|
39
|
+
export declare function makeSyncSourceID(rootPath: string): string;
|
|
40
|
+
export declare function listSyncSources(): SyncSourceState[];
|
|
41
|
+
export declare function upsertSyncSource(source: Omit<SyncSourceState, "id"> & {
|
|
42
|
+
id?: string;
|
|
43
|
+
}): SyncSourceState;
|
|
44
|
+
export declare function updateSyncSourceRun(rootPath: string, update: {
|
|
45
|
+
ignorePatterns: string[];
|
|
46
|
+
defaultBoundary?: string;
|
|
47
|
+
mode: "manual" | "watch";
|
|
48
|
+
scanCount: number;
|
|
49
|
+
pushed: number;
|
|
50
|
+
skipped: number;
|
|
51
|
+
errors: number;
|
|
52
|
+
}): SyncSourceState;
|
|
10
53
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{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