@causyne/agent 1.20.86 → 1.20.90
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/package.json +1 -1
- package/src/agent/abortableDelay.js +37 -0
- package/src/agent/abortableDelay.ts +38 -0
- package/src/agent/providerFailure.js +30 -0
- package/src/agent/providerFailure.ts +33 -0
- package/src/agent/toolTurnIntegrity.js +139 -0
- package/src/agent/toolTurnIntegrity.ts +165 -0
- package/src/agent/workspaceBoundary.js +79 -0
- package/src/agent/workspaceBoundary.ts +83 -0
- package/src/agentLoop.js +97 -27
- package/src/agentLoop.ts +92 -25
- package/src/providers/acp.js +8 -2
- package/src/providers/acp.ts +8 -2
- package/src/sandbox.js +9 -43
- package/src/skills/skillResourceSafety.js +174 -0
- package/src/skills/skillResourceSafety.ts +174 -0
- package/src/skills/skillSearchSafety.js +31 -0
- package/src/skills/skillSearchSafety.ts +33 -0
- package/src/tools/deferredMcpSearch.js +11 -12
- package/src/tools/deferredMcpSearch.ts +11 -11
- package/src/tools/readNativeSkill.js +73 -35
- package/src/tools/readNativeSkill.ts +78 -0
- package/src/tools/toolDispatch.js +83 -119
- package/src/tools/toolDispatch.ts +142 -0
- package/src/tui/chatRenderer.js +19 -11
- package/src/tui/scrollInteraction.js +6 -4
- package/src/tui/scrollInteraction.ts +7 -4
- package/src/tui/skillAuthoring.js +0 -1
- package/src/tui/skillAuthoring.ts +1 -2
- package/src/tui/stageSurface.js +6 -4
- package/src/tui/transcript.js +16 -0
- package/src/tui/turnRail.js +21 -11
- package/src/tui/turnRail.ts +19 -11
- package/src/userSkills.d.ts +26 -0
- package/src/userSkills.js +21 -1
package/src/tui/turnRail.ts
CHANGED
|
@@ -432,11 +432,18 @@ export function overlayTurnPreviewCard(
|
|
|
432
432
|
if (x <= 6 && railX <= 4) {
|
|
433
433
|
const plainBase = stripAnsi(baseRow);
|
|
434
434
|
const dotChar = plainBase[railX] || ' ';
|
|
435
|
-
const isDot = dotChar === '●' || dotChar === '•' || dotChar === '·'
|
|
435
|
+
const isDot = dotChar === '●' || dotChar === '•' || dotChar === '·';
|
|
436
436
|
let dotCell = ' ';
|
|
437
437
|
if (isDot) {
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
if (dotChar === '●') {
|
|
439
|
+
dotCell = baseRow.includes('230;235;245m')
|
|
440
|
+
? '\x1b[1m\x1b[38;2;230;235;245m●\x1b[0m'
|
|
441
|
+
: '\x1b[1m\x1b[38;2;250;250;250m●\x1b[0m';
|
|
442
|
+
} else if (dotChar === '•') {
|
|
443
|
+
dotCell = '\x1b[38;2;115;115;120m•\x1b[0m';
|
|
444
|
+
} else {
|
|
445
|
+
dotCell = dotChar;
|
|
446
|
+
}
|
|
440
447
|
}
|
|
441
448
|
const leadingSpace = ' '.repeat(Math.max(0, railX));
|
|
442
449
|
const trailingSpace = ' '.repeat(Math.max(0, x - railX - 1));
|
|
@@ -447,11 +454,12 @@ export function overlayTurnPreviewCard(
|
|
|
447
454
|
|
|
448
455
|
let restOfRow = '';
|
|
449
456
|
if (x <= 6) {
|
|
450
|
-
// For left-placed turn cards,
|
|
451
|
-
const
|
|
452
|
-
const rightCell = sliceFromColumn(baseRow,
|
|
457
|
+
// For left-placed turn cards, preserve the right overview rail without severed text leaks
|
|
458
|
+
const rowLen = visibleWidth(baseRow);
|
|
459
|
+
const rightCell = rowLen > 0 ? sliceFromColumn(baseRow, rowLen - 1) : ' ';
|
|
453
460
|
const rightCellWidth = visibleWidth(rightCell);
|
|
454
|
-
const
|
|
461
|
+
const targetWidth = Math.max(screenWidth, rowLen);
|
|
462
|
+
const gap = Math.max(0, targetWidth - x - cardWidth - rightCellWidth);
|
|
455
463
|
restOfRow = `${' '.repeat(gap)}${rightCell}`;
|
|
456
464
|
} else {
|
|
457
465
|
restOfRow = sliceFromColumn(baseRow, x + cardWidth);
|
|
@@ -482,10 +490,10 @@ export function handleTurnRailMouse(
|
|
|
482
490
|
const stageTop = layout.stageTop ?? 0;
|
|
483
491
|
const relY = mouseY - stageTop;
|
|
484
492
|
|
|
485
|
-
// Rail hit box: if railX <=
|
|
486
|
-
const isRail = layout.railX <=
|
|
487
|
-
? (mouseX >= 0 && mouseX <= Math.max(
|
|
488
|
-
: (mouseX >= layout.railX -
|
|
493
|
+
// Rail hit box: if railX <= 4, check columns 0..5 (left margin); otherwise check [railX - 2, railX + 3]
|
|
494
|
+
const isRail = layout.railX <= 4
|
|
495
|
+
? (mouseX >= 0 && mouseX <= Math.max(5, layout.railX + 3))
|
|
496
|
+
: (mouseX >= layout.railX - 2 && mouseX <= layout.railX + 3);
|
|
489
497
|
|
|
490
498
|
// Check if currently showing a card and mouse is hovering over the card or bridge tunnel
|
|
491
499
|
const hasActiveCard = surface.hoveredTurnIndex !== null && surface.hoveredTurnIndex !== undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Types for the existing JavaScript user skill store during the TS migration. */
|
|
2
|
+
export interface UserSkill {
|
|
3
|
+
domain: string;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
content: string;
|
|
8
|
+
source: 'user';
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
export const MAX_USER_SKILLS: number;
|
|
12
|
+
export const MAX_SKILL_BYTES: number;
|
|
13
|
+
export const MAX_DESCRIPTION: number;
|
|
14
|
+
export function userSkillsRoot(): string;
|
|
15
|
+
export function validateSegment(value: unknown, what?: string): string | null;
|
|
16
|
+
export function parseSkillId(id: unknown):
|
|
17
|
+
| { domain: string; name: string; error?: never }
|
|
18
|
+
| { domain?: never; name?: never; error: string };
|
|
19
|
+
export function loadUserSkills(root?: string): { skills: UserSkill[]; problems: string[] };
|
|
20
|
+
export function skillTemplate(domain: string, name: string, description?: string): string;
|
|
21
|
+
export function writeUserSkill(input: {
|
|
22
|
+
domain: string; name: string; content: string; overwrite?: boolean;
|
|
23
|
+
}, root?: string): { ok: boolean; path?: string; error?: string };
|
|
24
|
+
export function deleteUserSkill(domain: string, name: string, root?: string): {
|
|
25
|
+
ok: boolean; path?: string; error?: string;
|
|
26
|
+
};
|
package/src/userSkills.js
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { causyneHome } from './utils/paths.js';
|
|
7
|
+
import { assertSkillTreeSafe } from './skills/skillResourceSafety.js';
|
|
7
8
|
|
|
8
9
|
// Bounds. Every one of these protects the context window, which is the resource
|
|
9
10
|
// a skill library actually spends.
|
|
@@ -137,6 +138,7 @@ export function loadUserSkills(root = userSkillsRoot()) {
|
|
|
137
138
|
const file = path.join(root, domain, name, 'SKILL.md');
|
|
138
139
|
let content;
|
|
139
140
|
try {
|
|
141
|
+
assertSkillTreeSafe(root, domain, name);
|
|
140
142
|
// Refuse a symlink outright: it is the one way a file inside this
|
|
141
143
|
// directory can point at something outside it.
|
|
142
144
|
const stat = fs.lstatSync(file);
|
|
@@ -237,8 +239,21 @@ export function writeUserSkill({ domain, name, content, overwrite = false }, roo
|
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
try {
|
|
242
|
+
// Causyne Skills Safety v1: lexical path checks do not stop an existing
|
|
243
|
+
// symlinked parent directory from redirecting a skill write elsewhere.
|
|
244
|
+
assertSkillTreeSafe(root, domain, name, true);
|
|
240
245
|
fs.mkdirSync(directory, { recursive: true });
|
|
241
|
-
|
|
246
|
+
assertSkillTreeSafe(root, domain, name);
|
|
247
|
+
const nofollow = typeof fs.constants.O_NOFOLLOW === 'number' ? fs.constants.O_NOFOLLOW : 0;
|
|
248
|
+
const flags = fs.constants.O_WRONLY | fs.constants.O_CREAT | nofollow
|
|
249
|
+
| (overwrite ? fs.constants.O_TRUNC : fs.constants.O_EXCL);
|
|
250
|
+
const fd = fs.openSync(file, flags, 0o600);
|
|
251
|
+
try {
|
|
252
|
+
if (!fs.fstatSync(fd).isFile()) throw new Error('SKILL.md must be a regular file');
|
|
253
|
+
fs.writeFileSync(fd, body, 'utf8');
|
|
254
|
+
} finally {
|
|
255
|
+
fs.closeSync(fd);
|
|
256
|
+
}
|
|
242
257
|
} catch (e) {
|
|
243
258
|
return { ok: false, error: `could not write ${file}: ${e.message}` };
|
|
244
259
|
}
|
|
@@ -257,6 +272,11 @@ export function deleteUserSkill(domain, name, root = userSkillsRoot()) {
|
|
|
257
272
|
return { ok: false, error: `${domain}/${name} is not a user skill` };
|
|
258
273
|
}
|
|
259
274
|
try {
|
|
275
|
+
assertSkillTreeSafe(root, domain, name);
|
|
276
|
+
const skillFile = fs.lstatSync(path.join(directory, 'SKILL.md'));
|
|
277
|
+
if (skillFile.isSymbolicLink() || !skillFile.isFile()) {
|
|
278
|
+
throw new Error('SKILL.md must be a regular file');
|
|
279
|
+
}
|
|
260
280
|
fs.rmSync(directory, { recursive: true, force: true });
|
|
261
281
|
} catch (e) {
|
|
262
282
|
return { ok: false, error: `could not remove ${directory}: ${e.message}` };
|