@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/core/run-turn.ts
CHANGED
|
@@ -74,7 +74,7 @@ export async function runTurn(
|
|
|
74
74
|
if (!session) throw new Error("No session to edit.");
|
|
75
75
|
session = await deps.store.save(replaceUserTurn(session, req.editUserTurn, req.message));
|
|
76
76
|
} else {
|
|
77
|
-
|
|
77
|
+
session ??= await deps.store.create(deps.systemPrompt, req.model);
|
|
78
78
|
session = await deps.store.append(session, {
|
|
79
79
|
kind: "turn",
|
|
80
80
|
role: "user",
|
|
@@ -340,6 +340,68 @@ async function invokeGuarded(
|
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
async function blockedByPreTool(
|
|
344
|
+
def: McpToolDefinition,
|
|
345
|
+
input: Record<string, unknown>,
|
|
346
|
+
hooks?: HookRunner,
|
|
347
|
+
): Promise<string | undefined> {
|
|
348
|
+
const hook = await hooks?.preTool(def.name, input);
|
|
349
|
+
if (hook && !hook.allow) {
|
|
350
|
+
return hook.reason ?? `Tool call "${def.name}" was blocked by a pre_tool hook.`;
|
|
351
|
+
}
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async function approvalGranted(
|
|
356
|
+
def: McpToolDefinition,
|
|
357
|
+
approval: ApprovalGate,
|
|
358
|
+
callId: string,
|
|
359
|
+
input: Record<string, unknown>,
|
|
360
|
+
): Promise<boolean> {
|
|
361
|
+
if (!isRiskyToolCall(def.name) && !isFileWriteTool(def.name)) return true;
|
|
362
|
+
return approval.request({ callId, toolName: def.name, input });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function runToolHandler(
|
|
366
|
+
def: McpToolDefinition,
|
|
367
|
+
input: Record<string, unknown>,
|
|
368
|
+
): Promise<{ result: ToolResult; success: boolean; errorText?: string }> {
|
|
369
|
+
try {
|
|
370
|
+
const handlerResult = await def.handler(input);
|
|
371
|
+
if (handlerResult.isError) {
|
|
372
|
+
return {
|
|
373
|
+
result: handlerResult,
|
|
374
|
+
success: false,
|
|
375
|
+
errorText: toolResultText(handlerResult),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return { result: handlerResult, success: true };
|
|
379
|
+
} catch (handlerErr) {
|
|
380
|
+
const errorText = errorMessage(handlerErr);
|
|
381
|
+
return { result: errorResult(errorText), success: false, errorText };
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function isTodoItem(item: unknown): item is { id: string; content: string; status: string } {
|
|
386
|
+
if (!item || typeof item !== "object") return false;
|
|
387
|
+
const row = item as { id?: unknown; content?: unknown; status?: unknown };
|
|
388
|
+
return (
|
|
389
|
+
typeof row.id === "string" && typeof row.content === "string" && typeof row.status === "string"
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function emitTodosIfNeeded(
|
|
394
|
+
def: McpToolDefinition,
|
|
395
|
+
result: ToolResult,
|
|
396
|
+
emit: AgentEventEmitter,
|
|
397
|
+
success: boolean,
|
|
398
|
+
): void {
|
|
399
|
+
if (!success || def.name !== "todo_write") return;
|
|
400
|
+
const items = (result.structuredContent as { items?: unknown } | undefined)?.items;
|
|
401
|
+
if (!Array.isArray(items)) return;
|
|
402
|
+
emit({ kind: "todos", items: items.filter(isTodoItem) });
|
|
403
|
+
}
|
|
404
|
+
|
|
343
405
|
async function invokeGuardedBody(
|
|
344
406
|
def: McpToolDefinition,
|
|
345
407
|
approval: ApprovalGate,
|
|
@@ -354,34 +416,18 @@ async function invokeGuardedBody(
|
|
|
354
416
|
|
|
355
417
|
try {
|
|
356
418
|
emit({ kind: "tool_call_start", toolName: def.name, callId, input });
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
errorText =
|
|
419
|
+
const blocked = await blockedByPreTool(def, input, hooks);
|
|
420
|
+
if (blocked) {
|
|
421
|
+
errorText = blocked;
|
|
360
422
|
result = errorResult(errorText);
|
|
361
|
-
}
|
|
362
|
-
let approved = true;
|
|
363
|
-
if (!result && (isRiskyToolCall(def.name) || isFileWriteTool(def.name))) {
|
|
364
|
-
approved = await approval.request({ callId, toolName: def.name, input });
|
|
365
|
-
}
|
|
366
|
-
if (result) {
|
|
367
|
-
// hook already denied
|
|
368
|
-
} else if (!approved) {
|
|
423
|
+
} else if (!(await approvalGranted(def, approval, callId, input))) {
|
|
369
424
|
errorText = `Tool call "${def.name}" ${REJECTED_TOOL_MESSAGE}.`;
|
|
370
425
|
result = errorResult(errorText);
|
|
371
426
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
result = handlerResult;
|
|
377
|
-
} else {
|
|
378
|
-
result = handlerResult;
|
|
379
|
-
success = true;
|
|
380
|
-
}
|
|
381
|
-
} catch (handlerErr) {
|
|
382
|
-
errorText = errorMessage(handlerErr);
|
|
383
|
-
result = errorResult(errorText);
|
|
384
|
-
}
|
|
427
|
+
const ran = await runToolHandler(def, input);
|
|
428
|
+
result = ran.result;
|
|
429
|
+
success = ran.success;
|
|
430
|
+
errorText = ran.errorText;
|
|
385
431
|
}
|
|
386
432
|
} catch (dispatchErr) {
|
|
387
433
|
errorText = errorMessage(dispatchErr);
|
|
@@ -390,22 +436,7 @@ async function invokeGuardedBody(
|
|
|
390
436
|
|
|
391
437
|
const finalResult = result ?? errorResult("tool produced no result");
|
|
392
438
|
void hooks?.postTool(def.name, input, success);
|
|
393
|
-
|
|
394
|
-
const items = (finalResult.structuredContent as { items?: unknown } | undefined)?.items;
|
|
395
|
-
if (Array.isArray(items)) {
|
|
396
|
-
emit({
|
|
397
|
-
kind: "todos",
|
|
398
|
-
items: items.filter(
|
|
399
|
-
(item): item is { id: string; content: string; status: string } =>
|
|
400
|
-
!!item &&
|
|
401
|
-
typeof item === "object" &&
|
|
402
|
-
typeof (item as { id?: unknown }).id === "string" &&
|
|
403
|
-
typeof (item as { content?: unknown }).content === "string" &&
|
|
404
|
-
typeof (item as { status?: unknown }).status === "string",
|
|
405
|
-
),
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
439
|
+
emitTodosIfNeeded(def, finalResult, emit, success);
|
|
409
440
|
emit({
|
|
410
441
|
kind: "tool_call_end",
|
|
411
442
|
toolName: def.name,
|
|
@@ -440,6 +471,7 @@ export function buildSystemPrompt(input: {
|
|
|
440
471
|
userInstructions?: string;
|
|
441
472
|
projectInstructions?: string;
|
|
442
473
|
skillCatalog?: string;
|
|
474
|
+
memory?: string;
|
|
443
475
|
mode?: AgentMode;
|
|
444
476
|
}): string {
|
|
445
477
|
const parts = [
|
|
@@ -464,6 +496,7 @@ export function buildSystemPrompt(input: {
|
|
|
464
496
|
} else if (input.instructions?.trim()) {
|
|
465
497
|
parts.push("## Instructions", input.instructions.trim());
|
|
466
498
|
}
|
|
499
|
+
if (input.memory?.trim()) parts.push("## Memory", input.memory.trim());
|
|
467
500
|
if (input.skillCatalog?.trim()) parts.push(input.skillCatalog.trim());
|
|
468
501
|
return parts.join("\n\n");
|
|
469
502
|
}
|
|
@@ -167,6 +167,36 @@ describe("desktop bridge", () => {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
+
test("memory is off until enabled and can store a fact", async () => {
|
|
171
|
+
const ctx = await withBridge();
|
|
172
|
+
try {
|
|
173
|
+
const before = await fetch(`${ctx.ready.url}/memory`, { headers: ctx.headers });
|
|
174
|
+
const empty = (await before.json()) as { enabled: boolean; facts: unknown[] };
|
|
175
|
+
expect(empty.enabled).toBe(false);
|
|
176
|
+
expect(empty.facts).toEqual([]);
|
|
177
|
+
|
|
178
|
+
const { addFacts } = await import("../memory/store.ts");
|
|
179
|
+
addFacts(ctx.cwd, [{ text: "Prefer bun over npm for installs", scope: "user" }]);
|
|
180
|
+
const on = await fetch(`${ctx.ready.url}/memory`, {
|
|
181
|
+
method: "POST",
|
|
182
|
+
headers: ctx.headers,
|
|
183
|
+
body: JSON.stringify({ enabled: true }),
|
|
184
|
+
});
|
|
185
|
+
const body = (await on.json()) as {
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
facts: Array<{ text: string }>;
|
|
188
|
+
};
|
|
189
|
+
expect(body.enabled).toBe(true);
|
|
190
|
+
expect(body.facts.some((fact) => fact.text.includes("Prefer bun"))).toBe(true);
|
|
191
|
+
|
|
192
|
+
const settings = await fetch(`${ctx.ready.url}/settings`, { headers: ctx.headers });
|
|
193
|
+
const saved = (await settings.json()) as { memoryEnabled: boolean };
|
|
194
|
+
expect(saved.memoryEnabled).toBe(true);
|
|
195
|
+
} finally {
|
|
196
|
+
await ctx.close();
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
170
200
|
test("slash help stays off the model", async () => {
|
|
171
201
|
const ctx = await withBridge();
|
|
172
202
|
try {
|
|
@@ -430,6 +460,19 @@ describe("desktop bridge", () => {
|
|
|
430
460
|
expect(await readFile(join(ctx.cwd, ".harness", "uploads", file ?? ""), "utf8")).toBe(
|
|
431
461
|
"from the composer",
|
|
432
462
|
);
|
|
463
|
+
const state = (await (
|
|
464
|
+
await fetch(`${ctx.ready.url}/state`, { headers: ctx.headers })
|
|
465
|
+
).json()) as { uploads: Array<{ rel: string }> };
|
|
466
|
+
const rel = state.uploads[0]?.rel ?? "";
|
|
467
|
+
expect(rel).toContain("note.txt");
|
|
468
|
+
const removed = await fetch(`${ctx.ready.url}/uploads/delete`, {
|
|
469
|
+
method: "POST",
|
|
470
|
+
headers: ctx.headers,
|
|
471
|
+
body: JSON.stringify({ rels: [rel] }),
|
|
472
|
+
});
|
|
473
|
+
expect(removed.ok).toBe(true);
|
|
474
|
+
const after = (await removed.json()) as { state: { uploads: unknown[] } };
|
|
475
|
+
expect(after.state.uploads).toEqual([]);
|
|
433
476
|
} finally {
|
|
434
477
|
await ctx.close();
|
|
435
478
|
}
|
package/src/desktop/bridge.ts
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
} from "../mcp/user-servers.ts";
|
|
36
36
|
import { transcribeAudio } from "../media/openrouter-generate.ts";
|
|
37
37
|
import { readMediaPrefs } from "../media/prefs.ts";
|
|
38
|
+
import { isMemoryEnabled, writeMemoryPrefs } from "../memory/prefs.ts";
|
|
39
|
+
import { deleteFact, isFactPinned, listFacts, pinFact, unpinFact } from "../memory/store.ts";
|
|
38
40
|
import { PRODUCT_NAME } from "../product.ts";
|
|
39
41
|
import { createHarness, type HarnessRuntime } from "../runtime.ts";
|
|
40
42
|
import {
|
|
@@ -56,7 +58,13 @@ import { openResolvedPath, resolveLocalPath } from "./open-local.ts";
|
|
|
56
58
|
import { readPreviewCache, writePreviewCache } from "./preview-cache.ts";
|
|
57
59
|
import { filePreviewKind, filePreviewMime } from "./preview-kind.ts";
|
|
58
60
|
import { applyStoredOpenRouterKey, maskSecret, writeOpenRouterKey } from "./secrets.ts";
|
|
59
|
-
import {
|
|
61
|
+
import {
|
|
62
|
+
composeUploadMessage,
|
|
63
|
+
deleteUploads,
|
|
64
|
+
listUploads,
|
|
65
|
+
parseIncomingUploads,
|
|
66
|
+
saveUploads,
|
|
67
|
+
} from "./uploads.ts";
|
|
60
68
|
|
|
61
69
|
export interface DesktopState {
|
|
62
70
|
name: string;
|
|
@@ -136,6 +144,20 @@ function settingsPayload(harness: HarnessRuntime) {
|
|
|
136
144
|
googleOAuthHint: google?.clientId ? maskSecret(google.clientId) : "",
|
|
137
145
|
hasMicrosoftOAuth: Boolean(microsoft?.clientId),
|
|
138
146
|
microsoftOAuthHint: microsoft?.clientId ? maskSecret(microsoft.clientId) : "",
|
|
147
|
+
memoryEnabled: isMemoryEnabled({ configEnabled: harness.config.memory?.enabled }),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function memoryPayload(harness: HarnessRuntime) {
|
|
152
|
+
return {
|
|
153
|
+
enabled: isMemoryEnabled({ configEnabled: harness.config.memory?.enabled }),
|
|
154
|
+
facts: listFacts(harness.cwd).map((fact) => ({
|
|
155
|
+
id: fact.id,
|
|
156
|
+
text: fact.text,
|
|
157
|
+
scope: fact.scope,
|
|
158
|
+
createdAt: fact.createdAt,
|
|
159
|
+
pinned: isFactPinned(harness.cwd, fact, harness.config.instructionsFile),
|
|
160
|
+
})),
|
|
139
161
|
};
|
|
140
162
|
}
|
|
141
163
|
|
|
@@ -253,6 +275,30 @@ async function readJson(req: Request): Promise<Record<string, unknown>> {
|
|
|
253
275
|
return parsed && typeof parsed === "object" ? (parsed as Record<string, unknown>) : {};
|
|
254
276
|
}
|
|
255
277
|
|
|
278
|
+
function applyApprovalDecision(req: ApprovalRequest, decision: string): boolean {
|
|
279
|
+
if (
|
|
280
|
+
decision === "original" &&
|
|
281
|
+
typeof req.input.originalPath === "string" &&
|
|
282
|
+
req.input.originalPath.trim()
|
|
283
|
+
) {
|
|
284
|
+
req.input.path = req.input.originalPath;
|
|
285
|
+
}
|
|
286
|
+
return (
|
|
287
|
+
decision === "yes" || decision === "always" || decision === "copy" || decision === "original"
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function waitForApproval(
|
|
292
|
+
pending: Map<string, (decision: string) => void>,
|
|
293
|
+
req: ApprovalRequest,
|
|
294
|
+
): Promise<boolean> {
|
|
295
|
+
return new Promise((resolve) => {
|
|
296
|
+
pending.set(req.callId, (decision) => {
|
|
297
|
+
resolve(applyApprovalDecision(req, decision));
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
256
302
|
function snapshot(harness: HarnessRuntime, busy: boolean, title: string): DesktopState {
|
|
257
303
|
const live = cachedLiveTargetNames();
|
|
258
304
|
const target = prettyLiveModelName(live.get(harness.modelId) ?? "").trim();
|
|
@@ -650,6 +696,9 @@ export async function startDesktopBridge(options: StartDesktopBridgeOptions): Pr
|
|
|
650
696
|
}
|
|
651
697
|
saveProviderOAuth(body, "google");
|
|
652
698
|
saveProviderOAuth(body, "microsoft");
|
|
699
|
+
if (typeof body.memoryEnabled === "boolean") {
|
|
700
|
+
writeMemoryPrefs({ enabled: body.memoryEnabled });
|
|
701
|
+
}
|
|
653
702
|
return json({
|
|
654
703
|
ok: true,
|
|
655
704
|
...settingsPayload(harness),
|
|
@@ -657,6 +706,43 @@ export async function startDesktopBridge(options: StartDesktopBridgeOptions): Pr
|
|
|
657
706
|
});
|
|
658
707
|
};
|
|
659
708
|
|
|
709
|
+
const route_get_memory = async (_req: Request, _url: URL): Promise<Response> => {
|
|
710
|
+
return json(memoryPayload(harness));
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
const route_post_memory = async (req: Request, _url: URL): Promise<Response> => {
|
|
714
|
+
const body = await readJson(req);
|
|
715
|
+
if (typeof body.enabled === "boolean") {
|
|
716
|
+
writeMemoryPrefs({ enabled: body.enabled });
|
|
717
|
+
}
|
|
718
|
+
if (typeof body.delete === "string") {
|
|
719
|
+
const removed = deleteFact(harness.cwd, body.delete);
|
|
720
|
+
if (!removed) return json({ error: "No memory matches." }, 404);
|
|
721
|
+
const unpinned = unpinFact(harness.cwd, removed, harness.config.instructionsFile);
|
|
722
|
+
if ("error" in unpinned) return json({ error: unpinned.error }, 500);
|
|
723
|
+
}
|
|
724
|
+
if (typeof body.pin === "string") {
|
|
725
|
+
const fact = listFacts(harness.cwd).find((item) => item.id === body.pin);
|
|
726
|
+
if (!fact) return json({ error: "No memory matches." }, 404);
|
|
727
|
+
const pinned = pinFact(harness.cwd, fact, harness.config.instructionsFile);
|
|
728
|
+
if ("error" in pinned) return json({ error: pinned.error }, 500);
|
|
729
|
+
return json({ ok: true, path: pinned.path, ...memoryPayload(harness) });
|
|
730
|
+
}
|
|
731
|
+
return json({ ok: true, ...memoryPayload(harness) });
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
const route_post_uploads_delete = async (req: Request, _url: URL): Promise<Response> => {
|
|
735
|
+
const body = await readJson(req);
|
|
736
|
+
let rels: string[] = [];
|
|
737
|
+
if (Array.isArray(body.rels)) {
|
|
738
|
+
rels = body.rels.filter((item): item is string => typeof item === "string");
|
|
739
|
+
} else if (typeof body.rel === "string") {
|
|
740
|
+
rels = [body.rel];
|
|
741
|
+
}
|
|
742
|
+
deleteUploads(harness.cwd, rels);
|
|
743
|
+
return json({ ok: true, state: snapshot(harness, busy, title) });
|
|
744
|
+
};
|
|
745
|
+
|
|
660
746
|
const route_get_slash = async (_req: Request, url: URL): Promise<Response> => {
|
|
661
747
|
const { filterSlashCommands } = await import("../cli/slash.ts");
|
|
662
748
|
return json({ items: filterSlashCommands(url.searchParams.get("q") ?? "/") });
|
|
@@ -847,24 +933,7 @@ export async function startDesktopBridge(options: StartDesktopBridgeOptions): Pr
|
|
|
847
933
|
void harness
|
|
848
934
|
.runTurn(message, send, {
|
|
849
935
|
signal: abort?.signal,
|
|
850
|
-
approvalAsk: (req: ApprovalRequest) =>
|
|
851
|
-
new Promise<boolean>((resolve) => {
|
|
852
|
-
pending.set(req.callId, (decision) => {
|
|
853
|
-
if (
|
|
854
|
-
decision === "original" &&
|
|
855
|
-
typeof req.input.originalPath === "string" &&
|
|
856
|
-
req.input.originalPath.trim()
|
|
857
|
-
) {
|
|
858
|
-
req.input.path = req.input.originalPath;
|
|
859
|
-
}
|
|
860
|
-
resolve(
|
|
861
|
-
decision === "yes" ||
|
|
862
|
-
decision === "always" ||
|
|
863
|
-
decision === "copy" ||
|
|
864
|
-
decision === "original",
|
|
865
|
-
);
|
|
866
|
-
});
|
|
867
|
-
}),
|
|
936
|
+
approvalAsk: (req: ApprovalRequest) => waitForApproval(pending, req),
|
|
868
937
|
...(editUserTurn !== undefined ? { editUserTurn } : {}),
|
|
869
938
|
})
|
|
870
939
|
.catch((err) => {
|
|
@@ -922,6 +991,9 @@ export async function startDesktopBridge(options: StartDesktopBridgeOptions): Pr
|
|
|
922
991
|
"POST /embed": route_post_embed,
|
|
923
992
|
"GET /embed": route_get_embed,
|
|
924
993
|
"POST /transcribe": route_post_transcribe,
|
|
994
|
+
"GET /memory": route_get_memory,
|
|
995
|
+
"POST /memory": route_post_memory,
|
|
996
|
+
"POST /uploads/delete": route_post_uploads_delete,
|
|
925
997
|
"POST /settings": route_post_settings,
|
|
926
998
|
"GET /slash": route_get_slash,
|
|
927
999
|
"POST /session": route_post_session,
|
|
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import {
|
|
6
6
|
composeUploadMessage,
|
|
7
|
+
deleteUploads,
|
|
7
8
|
isTextUpload,
|
|
8
9
|
listUploads,
|
|
9
10
|
matchUploadEdit,
|
|
@@ -58,6 +59,11 @@ describe("uploads", () => {
|
|
|
58
59
|
expect(composeUploadMessage("look", saved)).toContain("```\nhello\n```");
|
|
59
60
|
expect(composeUploadMessage("", saved)).toContain(saved[1]?.rel ?? "");
|
|
60
61
|
expect(listUploads(cwd).map((item) => item.name)).toEqual(["shot.png", "note.txt"]);
|
|
62
|
+
const noteRel = saved[0]?.rel ?? "";
|
|
63
|
+
expect(deleteUploads(cwd, [noteRel, "../secret"]).map((item) => item.name)).toEqual([
|
|
64
|
+
"shot.png",
|
|
65
|
+
]);
|
|
66
|
+
expect(listUploads(cwd).map((item) => item.name)).toEqual(["shot.png"]);
|
|
61
67
|
} finally {
|
|
62
68
|
await rm(cwd, { recursive: true, force: true });
|
|
63
69
|
}
|