@useavalon/caelence-agent 0.2.3-canary.0 → 0.2.3-canary.2
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/README.md +7 -0
- package/desktop/src/App.tsx +9 -2919
- package/desktop/src/BubbleClip.tsx +1 -1
- package/desktop/src/ComposerAttach.tsx +2 -2
- package/desktop/src/DeskBoot.tsx +28 -0
- package/desktop/src/DeskChrome.tsx +360 -0
- package/desktop/src/DeskComposer.tsx +311 -0
- package/desktop/src/DeskSidebar.tsx +191 -0
- package/desktop/src/FilesPanel.tsx +104 -36
- package/desktop/src/FloatNotice.test.ts +12 -0
- package/desktop/src/FloatNotice.tsx +5 -2
- package/desktop/src/IntegrationsPanel.tsx +273 -0
- package/desktop/src/McpPanel.tsx +8 -8
- package/desktop/src/MemoryPanel.tsx +138 -0
- package/desktop/src/QueuePanel.tsx +123 -0
- package/desktop/src/SessionsPanel.tsx +174 -0
- package/desktop/src/SettingsPanel.tsx +181 -0
- package/desktop/src/SkillsPanel.tsx +28 -12
- package/desktop/src/TranscriptViews.tsx +637 -0
- package/desktop/src/api.ts +36 -0
- package/desktop/src/app.css +159 -11
- package/desktop/src/composer-files.ts +2 -2
- package/desktop/src/desk-keys.ts +45 -0
- package/desktop/src/desk-prefs.ts +29 -0
- package/desktop/src/desk-types.ts +92 -0
- package/desktop/src/desktop-turn.ts +271 -0
- package/desktop/src/preview-render.ts +322 -36
- package/desktop/src/queue.ts +1 -1
- package/desktop/src/session-search.test.ts +20 -0
- package/desktop/src/session-search.ts +13 -0
- package/desktop/src/session-select.test.ts +23 -0
- package/desktop/src/session-select.ts +32 -0
- package/desktop/src/useDeskDictation.ts +123 -0
- package/desktop/src/useDeskFiles.ts +180 -0
- package/desktop/src/useDeskNotice.ts +20 -0
- package/desktop/src/useDeskPicker.ts +189 -0
- package/desktop/src/useDeskPrefs.ts +30 -0
- package/desktop/src/useDeskRuntime.ts +109 -0
- package/desktop/src/useDeskSessions.ts +195 -0
- package/desktop/src/useDeskSlash.ts +31 -0
- package/desktop/src/useDeskTurns.ts +264 -0
- package/desktop/src/useDesktopApp.ts +286 -0
- package/desktop/src/user-display.ts +2 -2
- package/package.json +2 -2
- package/src/cli/openrouter-live.ts +30 -21
- package/src/cli/slash-dispatch.test.ts +25 -0
- package/src/cli/slash-dispatch.ts +41 -0
- package/src/cli/slash.ts +1 -0
- package/src/config.ts +10 -1
- package/src/core/run-turn.test.ts +3 -0
- package/src/core/run-turn.ts +74 -41
- package/src/desktop/bridge.test.ts +43 -0
- package/src/desktop/bridge.ts +91 -19
- package/src/desktop/uploads.test.ts +6 -0
- package/src/desktop/uploads.ts +178 -66
- package/src/index.ts +13 -0
- package/src/integrations/remote-mcp.ts +51 -21
- package/src/memory/extract.test.ts +81 -0
- package/src/memory/extract.ts +88 -0
- package/src/memory/prefs.test.ts +53 -0
- package/src/memory/prefs.ts +47 -0
- package/src/memory/prompt.ts +24 -0
- package/src/memory/store.test.ts +191 -0
- package/src/memory/store.ts +382 -0
- package/src/runtime.test.ts +37 -0
- package/src/runtime.ts +29 -1
- package/src/tools/local.ts +86 -39
package/src/runtime.ts
CHANGED
|
@@ -42,6 +42,10 @@ import { type ChatFn, createOpenRouterChat } from "./evals/runner.ts";
|
|
|
42
42
|
import { buildRemoteMcpTools } from "./integrations/remote-mcp.ts";
|
|
43
43
|
import { linkedMcpSources } from "./integrations/store.ts";
|
|
44
44
|
import { listUserMcpServers, userMcpToolPrefix } from "./mcp/user-servers.ts";
|
|
45
|
+
import { extractMemories } from "./memory/extract.ts";
|
|
46
|
+
import { isMemoryEnabled } from "./memory/prefs.ts";
|
|
47
|
+
import { formatRetrievedMemory } from "./memory/prompt.ts";
|
|
48
|
+
import { searchFacts } from "./memory/store.ts";
|
|
45
49
|
import { createObservability } from "./observability/create.ts";
|
|
46
50
|
import { noopObservability } from "./observability/noop.ts";
|
|
47
51
|
import { harnessPromptRecords, syncPrompts } from "./observability/prompts.ts";
|
|
@@ -491,10 +495,11 @@ export async function createHarness(options: CreateHarnessOptions): Promise<Harn
|
|
|
491
495
|
}),
|
|
492
496
|
);
|
|
493
497
|
}
|
|
498
|
+
const memoryOn = isMemoryEnabled({ configEnabled: config.memory?.enabled });
|
|
494
499
|
const deps: RunTurnDeps = {
|
|
495
500
|
cwd,
|
|
496
501
|
name: config.name,
|
|
497
|
-
systemPrompt,
|
|
502
|
+
systemPrompt: systemPromptWithMemory(systemPrompt, cwd, message, memoryOn),
|
|
498
503
|
tools,
|
|
499
504
|
approval,
|
|
500
505
|
store,
|
|
@@ -534,6 +539,7 @@ export async function createHarness(options: CreateHarnessOptions): Promise<Harn
|
|
|
534
539
|
{ signal: turnOptions?.signal },
|
|
535
540
|
);
|
|
536
541
|
if (session) runtime.activeSessionId = session.id;
|
|
542
|
+
scheduleMemoryExtract(memoryOn, cwd, session, provider);
|
|
537
543
|
return session;
|
|
538
544
|
},
|
|
539
545
|
close() {
|
|
@@ -543,3 +549,25 @@ export async function createHarness(options: CreateHarnessOptions): Promise<Harn
|
|
|
543
549
|
};
|
|
544
550
|
return runtime;
|
|
545
551
|
}
|
|
552
|
+
|
|
553
|
+
function systemPromptWithMemory(
|
|
554
|
+
base: string,
|
|
555
|
+
cwd: string,
|
|
556
|
+
message: string,
|
|
557
|
+
enabled: boolean,
|
|
558
|
+
): string {
|
|
559
|
+
if (!enabled) return base;
|
|
560
|
+
const block = formatRetrievedMemory(searchFacts(cwd, message));
|
|
561
|
+
if (!block) return base;
|
|
562
|
+
return `${base}\n\n## Memory\n${block}`;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function scheduleMemoryExtract(
|
|
566
|
+
enabled: boolean,
|
|
567
|
+
cwd: string,
|
|
568
|
+
session: Session | undefined,
|
|
569
|
+
provider: MainModelProvider,
|
|
570
|
+
): void {
|
|
571
|
+
if (!enabled || !session) return;
|
|
572
|
+
void extractMemories({ cwd, session, provider }).catch(() => undefined);
|
|
573
|
+
}
|
package/src/tools/local.ts
CHANGED
|
@@ -48,6 +48,80 @@ function resolveToolPath(cwd: string, rel: string, extra: ReadonlySet<string>):
|
|
|
48
48
|
return resolveUnderCwd(cwd, rel);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
function toolError(err: unknown): ReturnType<typeof errorResult> {
|
|
52
|
+
return errorResult(err instanceof Error ? err.message : String(err));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function skipsPath(rel: string): boolean {
|
|
56
|
+
return rel.split("/").some((part) => shouldSkipDir(part));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function globProjectFiles(
|
|
60
|
+
cwd: string,
|
|
61
|
+
pattern: string,
|
|
62
|
+
): Promise<{ matches: string[]; truncated: boolean }> {
|
|
63
|
+
const glob = new Glob(pattern);
|
|
64
|
+
const matches: string[] = [];
|
|
65
|
+
for await (const path of glob.scan({ cwd, onlyFiles: true, dot: false })) {
|
|
66
|
+
if (skipsPath(path)) continue;
|
|
67
|
+
matches.push(path);
|
|
68
|
+
if (matches.length >= 500) break;
|
|
69
|
+
}
|
|
70
|
+
matches.sort((left, right) => left.localeCompare(right));
|
|
71
|
+
return { matches, truncated: matches.length >= 500 };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function lineMatches(line: string, pattern: string, re: RegExp | null): boolean {
|
|
75
|
+
return re ? re.test(line) : line.includes(pattern);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function collectLineHits(
|
|
79
|
+
rel: string,
|
|
80
|
+
content: string,
|
|
81
|
+
pattern: string,
|
|
82
|
+
re: RegExp | null,
|
|
83
|
+
hits: Array<{ path: string; line: number; text: string }>,
|
|
84
|
+
maxMatches: number,
|
|
85
|
+
): boolean {
|
|
86
|
+
const lines = content.split("\n");
|
|
87
|
+
for (let i = 0; i < lines.length; i++) {
|
|
88
|
+
const line = lines[i] ?? "";
|
|
89
|
+
if (!lineMatches(line, pattern, re)) continue;
|
|
90
|
+
hits.push({ path: rel, line: i + 1, text: line.slice(0, 240) });
|
|
91
|
+
if (hits.length >= maxMatches) return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function readFileIfPresent(abs: string): Promise<string | undefined> {
|
|
97
|
+
try {
|
|
98
|
+
return await readFile(abs, "utf8");
|
|
99
|
+
} catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function grepProjectFiles(
|
|
105
|
+
cwd: string,
|
|
106
|
+
pattern: string,
|
|
107
|
+
fileGlob: string,
|
|
108
|
+
useRegex: boolean,
|
|
109
|
+
maxMatches: number,
|
|
110
|
+
): Promise<{ hits: Array<{ path: string; line: number; text: string }>; truncated: boolean }> {
|
|
111
|
+
const re = useRegex ? new RegExp(pattern) : null;
|
|
112
|
+
const hits: Array<{ path: string; line: number; text: string }> = [];
|
|
113
|
+
const glob = new Glob(fileGlob);
|
|
114
|
+
for await (const rel of glob.scan({ cwd, onlyFiles: true, dot: false })) {
|
|
115
|
+
if (skipsPath(rel)) continue;
|
|
116
|
+
const content = await readFileIfPresent(join(cwd, rel));
|
|
117
|
+
if (content === undefined) continue;
|
|
118
|
+
if (collectLineHits(rel, content, pattern, re, hits, maxMatches)) {
|
|
119
|
+
return { hits, truncated: true };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { hits, truncated: false };
|
|
123
|
+
}
|
|
124
|
+
|
|
51
125
|
export function createLocalTools(options: LocalToolsOptions): McpServer {
|
|
52
126
|
const cwd = options.cwd;
|
|
53
127
|
const extras = (): ReadonlySet<string> =>
|
|
@@ -185,18 +259,10 @@ export function createLocalTools(options: LocalToolsOptions): McpServer {
|
|
|
185
259
|
async handler(raw) {
|
|
186
260
|
try {
|
|
187
261
|
const pattern = asString(raw.pattern) || "**/*";
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
for await (const path of glob.scan({ cwd, onlyFiles: true, dot: false })) {
|
|
191
|
-
const parts = path.split("/");
|
|
192
|
-
if (parts.some((p) => shouldSkipDir(p))) continue;
|
|
193
|
-
matches.push(path);
|
|
194
|
-
if (matches.length >= 500) break;
|
|
195
|
-
}
|
|
196
|
-
matches.sort();
|
|
197
|
-
return jsonResult({ pattern, matches, truncated: matches.length >= 500 });
|
|
262
|
+
const found = await globProjectFiles(cwd, pattern);
|
|
263
|
+
return jsonResult({ pattern, matches: found.matches, truncated: found.truncated });
|
|
198
264
|
} catch (err) {
|
|
199
|
-
return
|
|
265
|
+
return toolError(err);
|
|
200
266
|
}
|
|
201
267
|
},
|
|
202
268
|
},
|
|
@@ -218,35 +284,16 @@ export function createLocalTools(options: LocalToolsOptions): McpServer {
|
|
|
218
284
|
try {
|
|
219
285
|
const pattern = asString(raw.pattern);
|
|
220
286
|
if (!pattern) return errorResult("pattern is empty");
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (parts.some((p) => shouldSkipDir(p))) continue;
|
|
230
|
-
let content: string;
|
|
231
|
-
try {
|
|
232
|
-
content = await readFile(join(cwd, rel), "utf8");
|
|
233
|
-
} catch {
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
const lines = content.split("\n");
|
|
237
|
-
for (let i = 0; i < lines.length; i++) {
|
|
238
|
-
const line = lines[i] ?? "";
|
|
239
|
-
const ok = re ? re.test(line) : line.includes(pattern);
|
|
240
|
-
if (!ok) continue;
|
|
241
|
-
hits.push({ path: rel, line: i + 1, text: line.slice(0, 240) });
|
|
242
|
-
if (hits.length >= maxMatches) {
|
|
243
|
-
return jsonResult({ pattern, hits, truncated: true });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return jsonResult({ pattern, hits, truncated: false });
|
|
287
|
+
const found = await grepProjectFiles(
|
|
288
|
+
cwd,
|
|
289
|
+
pattern,
|
|
290
|
+
asString(raw.glob) || "**/*",
|
|
291
|
+
raw.regex === true,
|
|
292
|
+
typeof raw.max_matches === "number" ? raw.max_matches : 100,
|
|
293
|
+
);
|
|
294
|
+
return jsonResult({ pattern, hits: found.hits, truncated: found.truncated });
|
|
248
295
|
} catch (err) {
|
|
249
|
-
return
|
|
296
|
+
return toolError(err);
|
|
250
297
|
}
|
|
251
298
|
},
|
|
252
299
|
},
|