@nex-ai/nex 0.1.61 → 0.1.63
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 +0 -0
- package/dist/lib/installers.js +1 -1
- package/dist/mcp/index.js +0 -0
- package/dist/plugin/auto-recall-worker.d.ts +2 -0
- package/dist/plugin/auto-recall-worker.js +74 -0
- package/dist/plugin/auto-recall-worker.js.map +1 -0
- package/dist/plugin/auto-recall.js +97 -20
- package/dist/plugin/auto-recall.js.map +1 -1
- package/dist/plugin/recall-cache.d.ts +41 -0
- package/dist/plugin/recall-cache.js +195 -0
- package/dist/plugin/recall-cache.js.map +1 -0
- package/package.json +3 -1
- package/dist/plugin/adapters/cline-capture.d.ts +0 -7
- package/dist/plugin/adapters/cline-capture.js +0 -25
- package/dist/plugin/adapters/cline-capture.js.map +0 -1
- package/dist/plugin/adapters/cline-recall.d.ts +0 -7
- package/dist/plugin/adapters/cline-recall.js +0 -30
- package/dist/plugin/adapters/cline-recall.js.map +0 -1
- package/dist/plugin/adapters/cline-task-start.d.ts +0 -7
- package/dist/plugin/adapters/cline-task-start.js +0 -30
- package/dist/plugin/adapters/cline-task-start.js.map +0 -1
- package/dist/plugin/adapters/cursor-recall.d.ts +0 -7
- package/dist/plugin/adapters/cursor-recall.js +0 -31
- package/dist/plugin/adapters/cursor-recall.js.map +0 -1
- package/dist/plugin/adapters/cursor-session-start.d.ts +0 -7
- package/dist/plugin/adapters/cursor-session-start.js +0 -30
- package/dist/plugin/adapters/cursor-session-start.js.map +0 -1
- package/dist/plugin/adapters/cursor-stop.d.ts +0 -7
- package/dist/plugin/adapters/cursor-stop.js +0 -25
- package/dist/plugin/adapters/cursor-stop.js.map +0 -1
- package/dist/plugin/adapters/windsurf-capture.d.ts +0 -7
- package/dist/plugin/adapters/windsurf-capture.js +0 -25
- package/dist/plugin/adapters/windsurf-capture.js.map +0 -1
- package/dist/plugin/adapters/windsurf-recall.d.ts +0 -7
- package/dist/plugin/adapters/windsurf-recall.js +0 -31
- package/dist/plugin/adapters/windsurf-recall.js.map +0 -1
- package/dist/plugin/shared.d.ts +0 -39
- package/dist/plugin/shared.js +0 -380
- package/dist/plugin/shared.js.map +0 -1
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/lib/installers.js
CHANGED
package/dist/mcp/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { loadConfig } from "./config.js";
|
|
3
|
+
import { formatNexContext } from "./context-format.js";
|
|
4
|
+
import { NexClient } from "./nex-client.js";
|
|
5
|
+
import { RecallCache } from "./recall-cache.js";
|
|
6
|
+
import { SessionStore } from "./session-store.js";
|
|
7
|
+
const sessions = new SessionStore();
|
|
8
|
+
const recallCache = new RecallCache();
|
|
9
|
+
function readTimeoutEnv(name, fallbackMs) {
|
|
10
|
+
const raw = process.env[name];
|
|
11
|
+
const parsed = Number.parseInt(raw ?? "", 10);
|
|
12
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallbackMs;
|
|
13
|
+
}
|
|
14
|
+
const BACKGROUND_RECALL_TIMEOUT_MS = readTimeoutEnv("NEX_RECALL_BACKGROUND_TIMEOUT_MS", 60_000);
|
|
15
|
+
const PENDING_CACHE_TTL_MS = readTimeoutEnv("NEX_RECALL_PENDING_TTL_MS", BACKGROUND_RECALL_TIMEOUT_MS + 30_000);
|
|
16
|
+
async function readInput() {
|
|
17
|
+
const chunks = [];
|
|
18
|
+
for await (const chunk of process.stdin) {
|
|
19
|
+
chunks.push(chunk);
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf-8"));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function main() {
|
|
29
|
+
let input = {};
|
|
30
|
+
try {
|
|
31
|
+
input = await readInput();
|
|
32
|
+
const prompt = input.prompt?.trim();
|
|
33
|
+
const promptHash = input.prompt_hash?.trim();
|
|
34
|
+
const sessionKey = input.session_id?.trim();
|
|
35
|
+
if (!prompt || !promptHash || !sessionKey) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!recallCache.hasPending(sessionKey, promptHash, PENDING_CACHE_TTL_MS)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const cfg = loadConfig();
|
|
42
|
+
const client = new NexClient(cfg.apiKey, cfg.baseUrl);
|
|
43
|
+
const nexSessionId = sessions.get(sessionKey);
|
|
44
|
+
const result = await client.ask(prompt, nexSessionId, BACKGROUND_RECALL_TIMEOUT_MS);
|
|
45
|
+
if (!result.answer) {
|
|
46
|
+
recallCache.clearPending(sessionKey, promptHash);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (result.session_id) {
|
|
50
|
+
sessions.set(sessionKey, result.session_id);
|
|
51
|
+
}
|
|
52
|
+
const context = formatNexContext({
|
|
53
|
+
answer: result.answer,
|
|
54
|
+
entityCount: result.entity_references?.length ?? 0,
|
|
55
|
+
sessionId: result.session_id,
|
|
56
|
+
});
|
|
57
|
+
if (!recallCache.hasPending(sessionKey, promptHash, PENDING_CACHE_TTL_MS)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
recallCache.setReady(sessionKey, {
|
|
61
|
+
promptHash,
|
|
62
|
+
context,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
const promptHash = input.prompt_hash?.trim();
|
|
67
|
+
const sessionKey = input.session_id?.trim();
|
|
68
|
+
if (promptHash && sessionKey) {
|
|
69
|
+
recallCache.clearPending(sessionKey, promptHash);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
main().then(() => process.exit(0)).catch(() => process.exit(0));
|
|
74
|
+
//# sourceMappingURL=auto-recall-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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C/B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,IAAI,CAAC;YAClD,SAAS,EAAE,MAAM,CAAC,UAAU;SAC7B,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,CAAC,EAAE,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC/B,UAAU;YACV,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;QAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;QAC5C,IAAI,UAAU,IAAI,UAAU,EAAE,CAAC;YAC7B,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -11,9 +11,57 @@
|
|
|
11
11
|
import { loadConfig, isHookEnabled } from "./config.js";
|
|
12
12
|
import { NexClient } from "./nex-client.js";
|
|
13
13
|
import { formatNexContext } from "./context-format.js";
|
|
14
|
+
import { RecallCache, hashPrompt } from "./recall-cache.js";
|
|
14
15
|
import { SessionStore } from "./session-store.js";
|
|
15
16
|
import { shouldRecall } from "./recall-filter.js";
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { dirname, join } from "node:path";
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
16
20
|
const sessions = new SessionStore();
|
|
21
|
+
const recallCache = new RecallCache();
|
|
22
|
+
const FAST_RECALL_BUDGET_MS = readTimeoutEnv("NEX_RECALL_SYNC_BUDGET_MS", 8_000);
|
|
23
|
+
const BACKGROUND_RECALL_TIMEOUT_MS = readTimeoutEnv("NEX_RECALL_BACKGROUND_TIMEOUT_MS", 60_000);
|
|
24
|
+
const READY_CACHE_TTL_MS = readTimeoutEnv("NEX_RECALL_READY_TTL_MS", 5 * 60_000);
|
|
25
|
+
const PENDING_CACHE_TTL_MS = readTimeoutEnv("NEX_RECALL_PENDING_TTL_MS", BACKGROUND_RECALL_TIMEOUT_MS + 30_000);
|
|
26
|
+
const WORKER_PATH = join(dirname(fileURLToPath(import.meta.url)), "auto-recall-worker.js");
|
|
27
|
+
function readTimeoutEnv(name, fallbackMs) {
|
|
28
|
+
const raw = process.env[name];
|
|
29
|
+
const parsed = Number.parseInt(raw ?? "", 10);
|
|
30
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallbackMs;
|
|
31
|
+
}
|
|
32
|
+
function writeHookContext(context) {
|
|
33
|
+
process.stdout.write(JSON.stringify({
|
|
34
|
+
hookSpecificOutput: {
|
|
35
|
+
hookEventName: "UserPromptSubmit",
|
|
36
|
+
additionalContext: context,
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
function isAbortError(error) {
|
|
41
|
+
return error instanceof Error && error.name === "AbortError";
|
|
42
|
+
}
|
|
43
|
+
function launchBackgroundRecall(prompt, sessionKey, promptHash) {
|
|
44
|
+
try {
|
|
45
|
+
const child = spawn(process.execPath, [WORKER_PATH], {
|
|
46
|
+
detached: true,
|
|
47
|
+
env: {
|
|
48
|
+
...process.env,
|
|
49
|
+
NEX_RECALL_BACKGROUND_TIMEOUT_MS: String(BACKGROUND_RECALL_TIMEOUT_MS),
|
|
50
|
+
NEX_RECALL_PENDING_TTL_MS: String(PENDING_CACHE_TTL_MS),
|
|
51
|
+
},
|
|
52
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
53
|
+
});
|
|
54
|
+
child.stdin.end(JSON.stringify({
|
|
55
|
+
prompt,
|
|
56
|
+
prompt_hash: promptHash,
|
|
57
|
+
session_id: sessionKey,
|
|
58
|
+
}));
|
|
59
|
+
child.unref();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
recallCache.clearPending(sessionKey, promptHash);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
17
65
|
/**
|
|
18
66
|
* Check if this is the first prompt for this session.
|
|
19
67
|
* A session with no stored Nex session ID is considered "first prompt"
|
|
@@ -75,30 +123,59 @@ async function main() {
|
|
|
75
123
|
const client = new NexClient(cfg.apiKey, cfg.baseUrl);
|
|
76
124
|
// Resolve session ID for multi-turn continuity
|
|
77
125
|
const sessionKey = input.session_id;
|
|
126
|
+
const promptHash = hashPrompt(prompt);
|
|
78
127
|
const nexSessionId = sessionKey ? sessions.get(sessionKey) : undefined;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
128
|
+
const cachedReady = sessionKey
|
|
129
|
+
? recallCache.getInjectable(sessionKey, READY_CACHE_TTL_MS)
|
|
130
|
+
: undefined;
|
|
131
|
+
if (sessionKey && cachedReady?.promptHash === promptHash) {
|
|
132
|
+
recallCache.markReadyDelivered(sessionKey);
|
|
133
|
+
writeHookContext(cachedReady.context);
|
|
82
134
|
return;
|
|
83
135
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
136
|
+
const hasPendingCurrent = sessionKey
|
|
137
|
+
? recallCache.hasPending(sessionKey, promptHash, PENDING_CACHE_TTL_MS)
|
|
138
|
+
: false;
|
|
139
|
+
let shouldStartBackground = false;
|
|
140
|
+
if (!hasPendingCurrent) {
|
|
141
|
+
try {
|
|
142
|
+
const result = await client.ask(prompt, nexSessionId, FAST_RECALL_BUDGET_MS);
|
|
143
|
+
if (result.answer) {
|
|
144
|
+
if (result.session_id && sessionKey) {
|
|
145
|
+
sessions.set(sessionKey, result.session_id);
|
|
146
|
+
}
|
|
147
|
+
const context = formatNexContext({
|
|
148
|
+
answer: result.answer,
|
|
149
|
+
entityCount: result.entity_references?.length ?? 0,
|
|
150
|
+
sessionId: result.session_id,
|
|
151
|
+
});
|
|
152
|
+
if (sessionKey) {
|
|
153
|
+
recallCache.setReady(sessionKey, { promptHash, context });
|
|
154
|
+
recallCache.markReadyDelivered(sessionKey);
|
|
155
|
+
}
|
|
156
|
+
writeHookContext(context);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (isAbortError(err)) {
|
|
162
|
+
shouldStartBackground = true;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
process.stderr.write(`[nex-recall] Fast-path error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
87
168
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
additionalContext: context,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
process.stdout.write(output);
|
|
169
|
+
if (sessionKey && shouldStartBackground && !hasPendingCurrent) {
|
|
170
|
+
recallCache.setPending(sessionKey, promptHash);
|
|
171
|
+
launchBackgroundRecall(prompt, sessionKey, promptHash);
|
|
172
|
+
}
|
|
173
|
+
if (sessionKey && cachedReady) {
|
|
174
|
+
recallCache.markReadyDelivered(sessionKey);
|
|
175
|
+
writeHookContext(cachedReady.context);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
process.stdout.write("{}");
|
|
102
179
|
}
|
|
103
180
|
catch (err) {
|
|
104
181
|
process.stderr.write(`[nex-recall] Unexpected error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-recall.js","sourceRoot":"","sources":["../../src/plugin/auto-recall.ts"],"names":[],"mappings":";AACA;;;;;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AAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface PendingRecallEntry {
|
|
2
|
+
promptHash: string;
|
|
3
|
+
createdAt: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ReadyRecallEntry {
|
|
6
|
+
promptHash: string;
|
|
7
|
+
context: string;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
deliveredAt?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface RecallSessionEntry {
|
|
12
|
+
pending?: PendingRecallEntry;
|
|
13
|
+
ready?: ReadyRecallEntry;
|
|
14
|
+
}
|
|
15
|
+
export interface RecallCacheConfig {
|
|
16
|
+
maxSize: number;
|
|
17
|
+
dataDir: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function hashPrompt(prompt: string): string;
|
|
20
|
+
export declare class RecallCache {
|
|
21
|
+
private filePath;
|
|
22
|
+
private maxSize;
|
|
23
|
+
constructor(config?: Partial<RecallCacheConfig>);
|
|
24
|
+
private readStore;
|
|
25
|
+
private writeStore;
|
|
26
|
+
private trimStore;
|
|
27
|
+
private pruneEmptyEntry;
|
|
28
|
+
get(sessionKey: string): RecallSessionEntry | undefined;
|
|
29
|
+
list(): Record<string, RecallSessionEntry>;
|
|
30
|
+
setPending(sessionKey: string, promptHash: string, now?: number): void;
|
|
31
|
+
hasPending(sessionKey: string, promptHash: string, maxAgeMs: number, now?: number): boolean;
|
|
32
|
+
clearPending(sessionKey: string, promptHash?: string): boolean;
|
|
33
|
+
setReady(sessionKey: string, ready: {
|
|
34
|
+
promptHash: string;
|
|
35
|
+
context: string;
|
|
36
|
+
}, now?: number): void;
|
|
37
|
+
getInjectable(sessionKey: string, maxAgeMs: number, now?: number): ReadyRecallEntry | undefined;
|
|
38
|
+
markReadyDelivered(sessionKey: string, now?: number): boolean;
|
|
39
|
+
delete(sessionKey: string): boolean;
|
|
40
|
+
clear(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { workspaceDataDir } from "./workspace-data-dir.js";
|
|
5
|
+
const DEFAULT_MAX = 100;
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function sanitizePending(value) {
|
|
10
|
+
if (!isRecord(value))
|
|
11
|
+
return undefined;
|
|
12
|
+
if (typeof value.promptHash !== "string")
|
|
13
|
+
return undefined;
|
|
14
|
+
if (typeof value.createdAt !== "number")
|
|
15
|
+
return undefined;
|
|
16
|
+
return {
|
|
17
|
+
promptHash: value.promptHash,
|
|
18
|
+
createdAt: value.createdAt,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function sanitizeReady(value) {
|
|
22
|
+
if (!isRecord(value))
|
|
23
|
+
return undefined;
|
|
24
|
+
if (typeof value.promptHash !== "string")
|
|
25
|
+
return undefined;
|
|
26
|
+
if (typeof value.context !== "string")
|
|
27
|
+
return undefined;
|
|
28
|
+
if (typeof value.createdAt !== "number")
|
|
29
|
+
return undefined;
|
|
30
|
+
if (value.deliveredAt !== undefined && typeof value.deliveredAt !== "number") {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
promptHash: value.promptHash,
|
|
35
|
+
context: value.context,
|
|
36
|
+
createdAt: value.createdAt,
|
|
37
|
+
deliveredAt: typeof value.deliveredAt === "number" ? value.deliveredAt : undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function sanitizeEntry(value) {
|
|
41
|
+
if (!isRecord(value))
|
|
42
|
+
return undefined;
|
|
43
|
+
const pending = sanitizePending(value.pending);
|
|
44
|
+
const ready = sanitizeReady(value.ready);
|
|
45
|
+
if (!pending && !ready)
|
|
46
|
+
return undefined;
|
|
47
|
+
return { pending, ready };
|
|
48
|
+
}
|
|
49
|
+
export function hashPrompt(prompt) {
|
|
50
|
+
return createHash("sha1").update(prompt).digest("hex");
|
|
51
|
+
}
|
|
52
|
+
export class RecallCache {
|
|
53
|
+
filePath;
|
|
54
|
+
maxSize;
|
|
55
|
+
constructor(config) {
|
|
56
|
+
const dataDir = config?.dataDir ?? workspaceDataDir();
|
|
57
|
+
this.maxSize = config?.maxSize ?? DEFAULT_MAX;
|
|
58
|
+
this.filePath = join(dataDir, "claude-recall-cache.json");
|
|
59
|
+
mkdirSync(dataDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
readStore() {
|
|
62
|
+
try {
|
|
63
|
+
const raw = readFileSync(this.filePath, "utf-8");
|
|
64
|
+
const parsed = JSON.parse(raw);
|
|
65
|
+
if (!isRecord(parsed))
|
|
66
|
+
return {};
|
|
67
|
+
const store = {};
|
|
68
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
69
|
+
const entry = sanitizeEntry(value);
|
|
70
|
+
if (entry)
|
|
71
|
+
store[key] = entry;
|
|
72
|
+
}
|
|
73
|
+
return store;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return {};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
writeStore(store) {
|
|
80
|
+
try {
|
|
81
|
+
writeFileSync(this.filePath, JSON.stringify(store), "utf-8");
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Best-effort — cache misses are acceptable.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
trimStore(store) {
|
|
88
|
+
const keys = Object.keys(store);
|
|
89
|
+
while (keys.length > this.maxSize) {
|
|
90
|
+
delete store[keys.shift()];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
pruneEmptyEntry(store, sessionKey) {
|
|
94
|
+
const entry = store[sessionKey];
|
|
95
|
+
if (!entry)
|
|
96
|
+
return;
|
|
97
|
+
if (!entry.pending && !entry.ready) {
|
|
98
|
+
delete store[sessionKey];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
get(sessionKey) {
|
|
102
|
+
return this.readStore()[sessionKey];
|
|
103
|
+
}
|
|
104
|
+
list() {
|
|
105
|
+
return this.readStore();
|
|
106
|
+
}
|
|
107
|
+
setPending(sessionKey, promptHash, now = Date.now()) {
|
|
108
|
+
const store = this.readStore();
|
|
109
|
+
const current = store[sessionKey] ?? {};
|
|
110
|
+
current.pending = { promptHash, createdAt: now };
|
|
111
|
+
store[sessionKey] = current;
|
|
112
|
+
this.trimStore(store);
|
|
113
|
+
this.writeStore(store);
|
|
114
|
+
}
|
|
115
|
+
hasPending(sessionKey, promptHash, maxAgeMs, now = Date.now()) {
|
|
116
|
+
const store = this.readStore();
|
|
117
|
+
const current = store[sessionKey];
|
|
118
|
+
const pending = current?.pending;
|
|
119
|
+
if (!pending)
|
|
120
|
+
return false;
|
|
121
|
+
if (now - pending.createdAt > maxAgeMs) {
|
|
122
|
+
delete current.pending;
|
|
123
|
+
this.pruneEmptyEntry(store, sessionKey);
|
|
124
|
+
this.writeStore(store);
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return pending.promptHash === promptHash;
|
|
128
|
+
}
|
|
129
|
+
clearPending(sessionKey, promptHash) {
|
|
130
|
+
const store = this.readStore();
|
|
131
|
+
const current = store[sessionKey];
|
|
132
|
+
if (!current?.pending)
|
|
133
|
+
return false;
|
|
134
|
+
if (promptHash && current.pending.promptHash !== promptHash) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
delete current.pending;
|
|
138
|
+
this.pruneEmptyEntry(store, sessionKey);
|
|
139
|
+
this.writeStore(store);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
setReady(sessionKey, ready, now = Date.now()) {
|
|
143
|
+
const store = this.readStore();
|
|
144
|
+
const current = store[sessionKey] ?? {};
|
|
145
|
+
current.ready = {
|
|
146
|
+
promptHash: ready.promptHash,
|
|
147
|
+
context: ready.context,
|
|
148
|
+
createdAt: now,
|
|
149
|
+
};
|
|
150
|
+
if (current.pending?.promptHash === ready.promptHash) {
|
|
151
|
+
delete current.pending;
|
|
152
|
+
}
|
|
153
|
+
store[sessionKey] = current;
|
|
154
|
+
this.trimStore(store);
|
|
155
|
+
this.writeStore(store);
|
|
156
|
+
}
|
|
157
|
+
getInjectable(sessionKey, maxAgeMs, now = Date.now()) {
|
|
158
|
+
const store = this.readStore();
|
|
159
|
+
const current = store[sessionKey];
|
|
160
|
+
const ready = current?.ready;
|
|
161
|
+
if (!ready)
|
|
162
|
+
return undefined;
|
|
163
|
+
if (ready.deliveredAt !== undefined)
|
|
164
|
+
return undefined;
|
|
165
|
+
if (now - ready.createdAt > maxAgeMs) {
|
|
166
|
+
delete current.ready;
|
|
167
|
+
this.pruneEmptyEntry(store, sessionKey);
|
|
168
|
+
this.writeStore(store);
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return ready;
|
|
172
|
+
}
|
|
173
|
+
markReadyDelivered(sessionKey, now = Date.now()) {
|
|
174
|
+
const store = this.readStore();
|
|
175
|
+
const current = store[sessionKey];
|
|
176
|
+
if (!current?.ready || current.ready.deliveredAt !== undefined) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
current.ready.deliveredAt = now;
|
|
180
|
+
this.writeStore(store);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
delete(sessionKey) {
|
|
184
|
+
const store = this.readStore();
|
|
185
|
+
if (!(sessionKey in store))
|
|
186
|
+
return false;
|
|
187
|
+
delete store[sessionKey];
|
|
188
|
+
this.writeStore(store);
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
clear() {
|
|
192
|
+
this.writeStore({});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+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AAE,OAAO,KAAK,CAAC;QACzC,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;QACzB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nex-ai/nex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
4
4
|
"description": "Nex CLI provides organizational context & memory to AI agents. Connect email, CRM, Slack, meetings, and 100+ tools into one knowledge graph.",
|
|
5
5
|
"mcpName": "io.github.nex-crm/nex",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"start": "bun dist/index.js",
|
|
41
41
|
"dev": "bun src/index.ts",
|
|
42
42
|
"test": "bun test",
|
|
43
|
+
"test:isolated": "bun test ./tests/tui/register-views-integration.test.isolated.ts && bun test ./tests/tui/slash-commands.test.isolated.ts",
|
|
44
|
+
"test:all": "bun test && bun test ./tests/tui/register-views-integration.test.isolated.ts && bun test ./tests/tui/slash-commands.test.isolated.ts",
|
|
43
45
|
"prepublishOnly": "bun run build"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Cline TaskComplete hook — auto-capture to Nex.
|
|
4
|
-
* Input: { taskComplete: { result: string } }
|
|
5
|
-
* Output: {}
|
|
6
|
-
*/
|
|
7
|
-
import { doCapture, readStdin } from "../shared.js";
|
|
8
|
-
async function main() {
|
|
9
|
-
try {
|
|
10
|
-
const raw = await readStdin();
|
|
11
|
-
let input = {};
|
|
12
|
-
try {
|
|
13
|
-
input = JSON.parse(raw);
|
|
14
|
-
}
|
|
15
|
-
catch { /* defaults */ }
|
|
16
|
-
await doCapture({ message: input.taskComplete?.result ?? "" });
|
|
17
|
-
process.stdout.write("{}");
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
process.stderr.write(`[nex-cline] Capture error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
21
|
-
process.stdout.write("{}");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
main().then(() => process.exit(0)).catch(() => process.exit(0));
|
|
25
|
-
//# sourceMappingURL=cline-capture.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cline-capture.js","sourceRoot":"","sources":["../../../src/plugin/adapters/cline-capture.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMpD,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,SAAS,EAAE,CAAC;QAC9B,IAAI,KAAK,GAAe,EAAE,CAAC;QAC3B,IAAI,CAAC;YAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;QAEzD,MAAM,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Cline UserPromptSubmit hook — auto-recall from Nex.
|
|
4
|
-
* Input: { userPromptSubmit: { prompt: string } }
|
|
5
|
-
* Output: { contextModification: "..." } or {}
|
|
6
|
-
*/
|
|
7
|
-
import { doRecall, readStdin } from "../shared.js";
|
|
8
|
-
async function main() {
|
|
9
|
-
try {
|
|
10
|
-
const raw = await readStdin();
|
|
11
|
-
let input = {};
|
|
12
|
-
try {
|
|
13
|
-
input = JSON.parse(raw);
|
|
14
|
-
}
|
|
15
|
-
catch { /* defaults */ }
|
|
16
|
-
const prompt = input.userPromptSubmit?.prompt ?? "";
|
|
17
|
-
const result = await doRecall(prompt, input.session_id);
|
|
18
|
-
if (!result) {
|
|
19
|
-
process.stdout.write("{}");
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
process.stdout.write(JSON.stringify({ contextModification: result.context }));
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
process.stderr.write(`[nex-cline] Recall error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
26
|
-
process.stdout.write("{}");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
main().then(() => process.exit(0)).catch(() => process.exit(0));
|
|
30
|
-
//# sourceMappingURL=cline-recall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cline-recall.js","sourceRoot":"","sources":["../../../src/plugin/adapters/cline-recall.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAOnD,KAAK,UAAU,IAAI;IACjB,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Input: { taskStart: { task: string } }
|
|
5
|
-
* Output: { contextModification: "..." } or {}
|
|
6
|
-
*/
|
|
7
|
-
import { doSessionStart, readStdin } from "../shared.js";
|
|
8
|
-
async function main() {
|
|
9
|
-
try {
|
|
10
|
-
const raw = await readStdin();
|
|
11
|
-
let input = {};
|
|
12
|
-
try {
|
|
13
|
-
input = JSON.parse(raw);
|
|
14
|
-
}
|
|
15
|
-
catch { /* defaults */ }
|
|
16
|
-
const result = await doSessionStart("startup", input.session_id);
|
|
17
|
-
if (!result) {
|
|
18
|
-
process.stdout.write("{}");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const context = result.registrationPrompt ?? result.context;
|
|
22
|
-
process.stdout.write(JSON.stringify({ contextModification: context }));
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
process.stderr.write(`[nex-cline] Task start error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
26
|
-
process.stdout.write("{}");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
main().then(() => process.exit(0)).catch(() => process.exit(0));
|
|
30
|
-
//# sourceMappingURL=cline-task-start.js.map
|