@danieltmn/tamnora 0.14.0 → 0.16.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/CHANGELOG.md +22 -0
- package/README.md +46 -2
- package/harness/packages/core/src/config/index.js +2 -0
- package/harness/packages/core/src/hooks/index.js +42 -0
- package/harness/packages/core/src/index.js +2 -0
- package/harness/packages/core/src/plugins/index.js +36 -0
- package/harness/packages/core/src/rules/index.js +9 -63
- package/harness/packages/core/src/tools/glob.js +64 -2
- package/harness/packages/core/test/hooks.test.js +29 -0
- package/harness/packages/core/test/plugins.test.js +25 -0
- package/harness/packages/server/public/app.js +27 -7
- package/harness/packages/server/public/index.html +16 -2
- package/harness/packages/server/src/lib/advisor.js +26 -6
- package/harness/packages/server/src/lib/agentRun.js +3 -1
- package/harness/packages/server/src/lib/channels/telegram.js +7 -1
- package/harness/packages/server/src/lib/compact.js +4 -0
- package/harness/packages/server/src/lib/hooks.js +45 -0
- package/harness/packages/server/src/lib/plugins.js +76 -0
- package/harness/packages/server/src/lib/scheduler.js +8 -1
- package/harness/packages/server/src/lib/ttsSettings.js +2 -2
- package/harness/packages/server/src/routes/advisor.js +5 -2
- package/harness/packages/server/src/routes/chat.js +40 -5
- package/harness/packages/server/src/routes/tts.js +1 -1
- package/harness/packages/server/src/server.js +16 -0
- package/harness/packages/server/test/advisor.test.js +103 -63
- package/harness/packages/server/test/server.test.js +66 -0
- package/harness/packages/server/test/tts.test.js +4 -1
- package/harness/tamnora.example.json +2 -0
- package/package.json +1 -1
|
@@ -1356,6 +1356,72 @@ test('rewind restores files and truncates the turn', async () => {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
});
|
|
1358
1358
|
|
|
1359
|
+
test('hooks observe tool events and plugins add custom tools', async () => {
|
|
1360
|
+
const cwd = await mkdtemp(path.join(tmpdir(), 'tamnora-hooks-plugins-'));
|
|
1361
|
+
await mkdir(path.join(cwd, '.tamnora', 'hooks'), { recursive: true });
|
|
1362
|
+
await mkdir(path.join(cwd, '.tamnora', 'plugins'), { recursive: true });
|
|
1363
|
+
await writeFile(
|
|
1364
|
+
path.join(cwd, '.tamnora', 'hooks', 'audit.mjs'),
|
|
1365
|
+
"import { appendFileSync } from 'node:fs';\nimport path from 'node:path';\n" +
|
|
1366
|
+
"export default { name: 'audit', events: { 'tool.after': (event, ctx) => { appendFileSync(path.join(ctx.cwd, 'hook.log'), `${event.type}:${event.name}\\n`); } } };\n"
|
|
1367
|
+
);
|
|
1368
|
+
await writeFile(
|
|
1369
|
+
path.join(cwd, '.tamnora', 'plugins', 'demo.mjs'),
|
|
1370
|
+
"export default { name: 'demo', tools: [{ name: 'saludar', description: 'saluda', parameters: { quien: { type: 'string' } }, handler: (args) => `Hola ${args.quien}` }] };\n"
|
|
1371
|
+
);
|
|
1372
|
+
await writeFile(path.join(cwd, 'tamnora.json'), JSON.stringify({ permissions: { plugin__demo__saludar: 'allow' } }));
|
|
1373
|
+
|
|
1374
|
+
let captured = null;
|
|
1375
|
+
const provider = {
|
|
1376
|
+
id: 'hp',
|
|
1377
|
+
async streamChat(_config, { messages }) {
|
|
1378
|
+
const toolMsg = messages.find((m) => m.role === 'tool' && String(m.name).startsWith('plugin__'));
|
|
1379
|
+
if (toolMsg) {
|
|
1380
|
+
captured = toolMsg.content;
|
|
1381
|
+
return { content: 'ok', reasoning: '', toolCalls: [] };
|
|
1382
|
+
}
|
|
1383
|
+
return {
|
|
1384
|
+
content: '',
|
|
1385
|
+
reasoning: '',
|
|
1386
|
+
toolCalls: [
|
|
1387
|
+
{
|
|
1388
|
+
id: 't1',
|
|
1389
|
+
type: 'function',
|
|
1390
|
+
function: { name: 'plugin__demo__saludar', arguments: JSON.stringify({ quien: 'mundo' }) },
|
|
1391
|
+
},
|
|
1392
|
+
],
|
|
1393
|
+
};
|
|
1394
|
+
},
|
|
1395
|
+
};
|
|
1396
|
+
const { instance, base } = await startServer({ cwd, resolveProvider: () => ({ provider, config: {} }) });
|
|
1397
|
+
const json = { 'Content-Type': 'application/json' };
|
|
1398
|
+
try {
|
|
1399
|
+
const hooks = await (await fetch(`${base}/api/hooks`)).json();
|
|
1400
|
+
assert.ok(hooks.hooks.some((h) => h.id === 'audit'));
|
|
1401
|
+
|
|
1402
|
+
const plugins = await (await fetch(`${base}/api/plugins`)).json();
|
|
1403
|
+
assert.ok(plugins.plugins.some((p) => p.name === 'plugin__demo__saludar'));
|
|
1404
|
+
|
|
1405
|
+
const created = await (
|
|
1406
|
+
await fetch(`${base}/api/sessions`, { method: 'POST', headers: json, body: JSON.stringify({ title: 't', model: 'm', cwd }) })
|
|
1407
|
+
).json();
|
|
1408
|
+
await (
|
|
1409
|
+
await fetch(`${base}/api/chat`, {
|
|
1410
|
+
method: 'POST',
|
|
1411
|
+
headers: json,
|
|
1412
|
+
body: JSON.stringify({ sessionId: created.session.id, model: 'm', input: 'saludá' }),
|
|
1413
|
+
})
|
|
1414
|
+
).text();
|
|
1415
|
+
assert.equal(captured, 'Hola mundo');
|
|
1416
|
+
|
|
1417
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
1418
|
+
const log = await readFile(path.join(cwd, 'hook.log'), 'utf8').catch(() => '');
|
|
1419
|
+
assert.match(log, /tool\.after:plugin__demo__saludar/);
|
|
1420
|
+
} finally {
|
|
1421
|
+
await instance.close();
|
|
1422
|
+
}
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1359
1425
|
test('skills: modo eager inyecta el body en el system prompt', async () => {
|
|
1360
1426
|
let captured = '';
|
|
1361
1427
|
const captureProvider = {
|
|
@@ -78,20 +78,23 @@ test('los ajustes de voz exponen defaults y sanitizan lo guardado', async () =>
|
|
|
78
78
|
assert.equal(initial.announce.start, true);
|
|
79
79
|
assert.equal(initial.announce.tools, true);
|
|
80
80
|
assert.equal(initial.announce.end, true);
|
|
81
|
+
assert.equal(initial.announce.summary, false);
|
|
81
82
|
|
|
82
83
|
const put = await fetch(`${base}/api/tts/settings`, {
|
|
83
84
|
method: 'PUT',
|
|
84
85
|
headers: { 'Content-Type': 'application/json' },
|
|
85
|
-
body: JSON.stringify({ enabled: true, voice: '<script>', rate: '150%' }),
|
|
86
|
+
body: JSON.stringify({ enabled: true, voice: '<script>', rate: '150%', announce: { summary: true } }),
|
|
86
87
|
});
|
|
87
88
|
const saved = await put.json();
|
|
88
89
|
assert.equal(saved.enabled, true);
|
|
89
90
|
assert.equal(saved.voice, 'es-AR-ElenaNeural');
|
|
90
91
|
assert.equal(saved.rate, '+100%');
|
|
92
|
+
assert.equal(saved.announce.summary, true);
|
|
91
93
|
|
|
92
94
|
const reread = await (await fetch(`${base}/api/tts/settings`)).json();
|
|
93
95
|
assert.equal(reread.enabled, true);
|
|
94
96
|
assert.equal(reread.rate, '+100%');
|
|
97
|
+
assert.equal(reread.announce.summary, true);
|
|
95
98
|
} finally {
|
|
96
99
|
global.WebSocket = original;
|
|
97
100
|
await instance.close();
|
package/package.json
CHANGED