jinn-cli 0.6.0 → 0.7.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/dist/src/engines/mock.d.ts +16 -0
- package/dist/src/engines/mock.d.ts.map +1 -0
- package/dist/src/engines/mock.js +47 -0
- package/dist/src/engines/mock.js.map +1 -0
- package/dist/src/gateway/__tests__/costs.test.d.ts +2 -0
- package/dist/src/gateway/__tests__/costs.test.d.ts.map +1 -0
- package/dist/src/gateway/__tests__/costs.test.js +32 -0
- package/dist/src/gateway/__tests__/costs.test.js.map +1 -0
- package/dist/src/gateway/api.d.ts.map +1 -1
- package/dist/src/gateway/api.js +112 -1
- package/dist/src/gateway/api.js.map +1 -1
- package/dist/src/gateway/budgets.d.ts +16 -0
- package/dist/src/gateway/budgets.d.ts.map +1 -0
- package/dist/src/gateway/budgets.js +39 -0
- package/dist/src/gateway/budgets.js.map +1 -0
- package/dist/src/gateway/costs.d.ts +19 -0
- package/dist/src/gateway/costs.d.ts.map +1 -0
- package/dist/src/gateway/costs.js +39 -0
- package/dist/src/gateway/costs.js.map +1 -0
- package/dist/src/gateway/goals.d.ts +11 -0
- package/dist/src/gateway/goals.d.ts.map +1 -0
- package/dist/src/gateway/goals.js +72 -0
- package/dist/src/gateway/goals.js.map +1 -0
- package/dist/src/sessions/manager.d.ts.map +1 -1
- package/dist/src/sessions/manager.js +25 -0
- package/dist/src/sessions/manager.js.map +1 -1
- package/dist/src/sessions/registry.d.ts.map +1 -1
- package/dist/src/sessions/registry.js +26 -0
- package/dist/src/sessions/registry.js.map +1 -1
- package/dist/src/shared/types.d.ts +13 -0
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/1HnqYp-z0yEkKBQwXlWh1/_buildManifest.js +1 -0
- package/dist/web/_next/static/1HnqYp-z0yEkKBQwXlWh1/_ssgManifest.js +1 -0
- package/dist/web/_next/static/chunks/144-548cab85cf18301a.js +1 -0
- package/dist/web/_next/static/chunks/155-592ad81a5c00a38a.js +1 -0
- package/dist/web/_next/static/chunks/192-bd69b67fd03b9f3d.js +1 -0
- package/dist/web/_next/static/chunks/458-85ba1833ffcc2e6c.js +1 -0
- package/dist/web/_next/static/chunks/51-ea7256657692ba90.js +1 -0
- package/dist/web/_next/static/chunks/625-93dc90080662b8f4.js +1 -0
- package/dist/web/_next/static/chunks/6d25620b-d9f90746a7f2178c.js +1 -0
- package/dist/web/_next/static/chunks/7273c211.7ff69b7844551452.js +1 -0
- package/dist/web/_next/static/chunks/743.588b42b673795913.js +1 -0
- package/dist/web/_next/static/chunks/865-b4eb9a132b937321.js +1 -0
- package/dist/web/_next/static/chunks/943.1c6d37432bcad8e8.js +1 -0
- package/dist/web/_next/static/chunks/app/_not-found/page-22b69e9fb96ef3fc.js +1 -0
- package/dist/web/_next/static/chunks/app/chat/page-28df51d87ba7e82b.js +1 -0
- package/dist/web/_next/static/chunks/app/cron/page-4ede68bcdb3e76ca.js +1 -0
- package/dist/web/_next/static/chunks/app/kanban/page-0e1b2a66378b8a6b.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-ab9ba2b24a88513d.js +1 -0
- package/dist/web/_next/static/chunks/app/logs/page-b2ea0e6b92c54706.js +1 -0
- package/dist/web/_next/static/chunks/app/org/page-05c8d33b3bf07d3d.js +1 -0
- package/dist/web/_next/static/chunks/app/page-57dcf41f8ef011a7.js +1 -0
- package/dist/web/_next/static/chunks/app/sessions/page-17f8dfdb90a924a7.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-2903a5e9b8b0fc4a.js +1 -0
- package/dist/web/_next/static/chunks/app/skills/page-971feac69b3a1383.js +1 -0
- package/dist/web/_next/static/chunks/framework-33aa4529cc42a877.js +1 -0
- package/dist/web/_next/static/chunks/main-app-72a2d12a170701ef.js +1 -0
- package/dist/web/_next/static/chunks/main-c1296ca5f4362ccd.js +1 -0
- package/dist/web/_next/static/chunks/pages/_app-033e463982aa0ffc.js +1 -0
- package/dist/web/_next/static/chunks/pages/_error-de3b15b767c34e44.js +1 -0
- package/dist/web/_next/static/chunks/webpack-440561fa60ef8a8f.js +1 -0
- package/dist/web/_next/static/css/e79d77e53f783583.css +1 -0
- package/dist/web/chat.html +1 -1
- package/dist/web/chat.txt +12 -12
- package/dist/web/cron.html +1 -1
- package/dist/web/cron.txt +12 -12
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +12 -12
- package/dist/web/kanban.html +1 -1
- package/dist/web/kanban.txt +12 -12
- package/dist/web/logs.html +2 -2
- package/dist/web/logs.txt +12 -12
- package/dist/web/org.html +1 -1
- package/dist/web/org.txt +12 -12
- package/dist/web/sessions.html +1 -1
- package/dist/web/sessions.txt +10 -10
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +12 -12
- package/dist/web/skills.html +1 -1
- package/dist/web/skills.txt +12 -12
- package/dist/web.bak/404.html +1 -0
- package/dist/web.bak/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/dist/web.bak/chat.html +1 -0
- package/dist/web.bak/chat.txt +20 -0
- package/dist/web.bak/cron.html +1 -0
- package/dist/web.bak/cron.txt +20 -0
- package/dist/web.bak/index.html +1 -0
- package/dist/web.bak/index.txt +20 -0
- package/dist/web.bak/kanban.html +1 -0
- package/dist/web.bak/kanban.txt +20 -0
- package/dist/web.bak/logs.html +7 -0
- package/dist/web.bak/logs.txt +20 -0
- package/dist/web.bak/org.html +1 -0
- package/dist/web.bak/org.txt +20 -0
- package/dist/web.bak/sessions.html +1 -0
- package/dist/web.bak/sessions.txt +17 -0
- package/dist/web.bak/settings.html +1 -0
- package/dist/web.bak/settings.txt +20 -0
- package/dist/web.bak/skills.html +1 -0
- package/dist/web.bak/skills.txt +20 -0
- package/package.json +5 -3
- /package/dist/{web → web.bak}/_next/static/QrKxazgwMrykF2yLwDvUM/_buildManifest.js +0 -0
- /package/dist/{web → web.bak}/_next/static/QrKxazgwMrykF2yLwDvUM/_ssgManifest.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/184-5a617386af9a1dd3.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/198-fd91406a158c5c25.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/517.62389e8d3c929c43.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/534-17c49c944e0d0fe1.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/573-070537ec2452d03e.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/590-2c34156c7417317e.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/700-ad04a2a5b3c8880f.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/7273c211.06e3b6021d90b73f.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/743-5bb03adbb0e4ddec.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/874.97d5a27895061057.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/8e6518bb-c26e82767f1faf66.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/_not-found/page-7d43a486b7014af3.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/chat/page-36edb6fc1d1e880b.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/costs/page-6c5cd46a6b3cde21.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/cron/page-210d9d333a7eed94.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/kanban/page-c32370bcd6a7c841.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/layout-3ad6b73a0904c24b.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/logs/page-7322a6789e16dca4.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/org/page-02263c5702e0fd3e.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/page-b68dcf7b8802c704.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/sessions/page-bf7ad2fac281c7d6.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/settings/page-d3b89563c42be2e5.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/app/skills/page-194f4e97f29ab581.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/framework-077b27ad7787463c.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/main-app-0c65af8a0fd99888.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/main-f1c74cefd4965abf.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/pages/_app-77a85fe7d6bca671.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/pages/_error-68febf4b34900064.js +0 -0
- /package/dist/{web → web.bak}/_next/static/chunks/webpack-0f39b7e91dce9791.js +0 -0
- /package/dist/{web → web.bak}/_next/static/css/b809b6af2d241fc8.css +0 -0
- /package/dist/{web → web.bak}/costs.html +0 -0
- /package/dist/{web → web.bak}/costs.txt +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Engine, EngineRunOpts, EngineResult } from "../shared/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* MockEngine — a zero-cost engine for E2E and integration tests.
|
|
4
|
+
* Returns canned responses with simulated word-by-word streaming.
|
|
5
|
+
* Cost is fixed at $0.001 per run for budget tracking tests.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MockEngine implements Engine {
|
|
8
|
+
name: "mock";
|
|
9
|
+
private responseIndex;
|
|
10
|
+
private fixedResponse?;
|
|
11
|
+
constructor(opts?: {
|
|
12
|
+
fixedResponse?: string;
|
|
13
|
+
});
|
|
14
|
+
run(opts: EngineRunOpts): Promise<EngineResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/engines/mock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQ9E;;;;GAIG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,IAAI,EAAG,MAAM,CAAU;IAEvB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,aAAa,CAAC,CAAS;gBAEnB,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAIvC,GAAG,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAgCtD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
const CANNED_RESPONSES = [
|
|
3
|
+
"This is a mock engine response for testing purposes.",
|
|
4
|
+
"The mock engine returns canned responses to simulate real engine behavior.",
|
|
5
|
+
"Mock response: task completed successfully.",
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* MockEngine — a zero-cost engine for E2E and integration tests.
|
|
9
|
+
* Returns canned responses with simulated word-by-word streaming.
|
|
10
|
+
* Cost is fixed at $0.001 per run for budget tracking tests.
|
|
11
|
+
*/
|
|
12
|
+
export class MockEngine {
|
|
13
|
+
name = "mock";
|
|
14
|
+
responseIndex = 0;
|
|
15
|
+
fixedResponse;
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
this.fixedResponse = opts?.fixedResponse;
|
|
18
|
+
}
|
|
19
|
+
async run(opts) {
|
|
20
|
+
const startMs = Date.now();
|
|
21
|
+
const sessionId = opts.resumeSessionId || opts.sessionId || randomUUID();
|
|
22
|
+
// Pick the next canned response (cycles through the list)
|
|
23
|
+
const response = this.fixedResponse ??
|
|
24
|
+
CANNED_RESPONSES[this.responseIndex++ % CANNED_RESPONSES.length];
|
|
25
|
+
if (opts.onStream) {
|
|
26
|
+
// Simulate word-by-word streaming with small delays
|
|
27
|
+
const words = response.split(" ");
|
|
28
|
+
for (let i = 0; i < words.length; i++) {
|
|
29
|
+
const chunk = i === 0 ? words[i] : " " + words[i];
|
|
30
|
+
opts.onStream({ type: "text", content: chunk });
|
|
31
|
+
// Simulate network/processing delay between words
|
|
32
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
33
|
+
}
|
|
34
|
+
// Emit a final snapshot so clients can reconcile
|
|
35
|
+
opts.onStream({ type: "text_snapshot", content: response });
|
|
36
|
+
}
|
|
37
|
+
const durationMs = Date.now() - startMs;
|
|
38
|
+
return {
|
|
39
|
+
sessionId,
|
|
40
|
+
result: response,
|
|
41
|
+
cost: 0.001,
|
|
42
|
+
durationMs,
|
|
43
|
+
numTurns: 1,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../../src/engines/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,gBAAgB,GAAG;IACvB,sDAAsD;IACtD,4EAA4E;IAC5E,6CAA6C;CAC9C,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACrB,IAAI,GAAG,MAAe,CAAC;IAEf,aAAa,GAAG,CAAC,CAAC;IAClB,aAAa,CAAU;IAE/B,YAAY,IAAiC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,EAAE,aAAa,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAmB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;QAEzE,0DAA0D;QAC1D,MAAM,QAAQ,GACZ,IAAI,CAAC,aAAa;YAClB,gBAAgB,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,oDAAoD;YACpD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtC,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClD,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;gBAChD,kDAAkD;gBAClD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,iDAAiD;YACjD,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;QAExC,OAAO;YACL,SAAS;YACT,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,KAAK;YACX,UAAU;YACV,QAAQ,EAAE,CAAC;SACZ,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.test.d.ts","sourceRoot":"","sources":["../../../../src/gateway/__tests__/costs.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { mkdirSync } from 'node:fs';
|
|
5
|
+
// Point initDb to a temp directory so tests don't touch the real database
|
|
6
|
+
const tmpHome = path.join(os.tmpdir(), `jinn-test-${process.pid}`);
|
|
7
|
+
mkdirSync(path.join(tmpHome, 'sessions'), { recursive: true });
|
|
8
|
+
process.env.JINN_HOME = tmpHome;
|
|
9
|
+
import { getCostSummary, getCostsByEmployee } from '../costs.js';
|
|
10
|
+
describe('getCostSummary', () => {
|
|
11
|
+
it('returns zero total when no sessions exist', () => {
|
|
12
|
+
const result = getCostSummary('month');
|
|
13
|
+
expect(result.total).toBeGreaterThanOrEqual(0);
|
|
14
|
+
expect(Array.isArray(result.daily)).toBe(true);
|
|
15
|
+
expect(Array.isArray(result.byEmployee)).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
it('returns zero for day period', () => {
|
|
18
|
+
const result = getCostSummary('day');
|
|
19
|
+
expect(result.total).toBeGreaterThanOrEqual(0);
|
|
20
|
+
});
|
|
21
|
+
it('returns zero for week period', () => {
|
|
22
|
+
const result = getCostSummary('week');
|
|
23
|
+
expect(result.total).toBeGreaterThanOrEqual(0);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('getCostsByEmployee', () => {
|
|
27
|
+
it('returns an array', () => {
|
|
28
|
+
const result = getCostsByEmployee('month');
|
|
29
|
+
expect(Array.isArray(result)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=costs.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.test.js","sourceRoot":"","sources":["../../../../src/gateway/__tests__/costs.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,0EAA0E;AAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,aAAa,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AAClE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAC9D,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,OAAO,CAAA;AAE/B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhE,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QACtC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC9C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QACpC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAA;QACrC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC1B,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;QAC1C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/gateway/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMhF,OAAO,KAAK,EAAoC,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAExG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/gateway/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMhF,OAAO,KAAK,EAAoC,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAExG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA0C7D,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,UAAU,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,oBAAoB,EAAE,SAAS,CAAC,CAAC;CACjE;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAgCpE;AAyLD,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAkvCf"}
|
package/dist/src/gateway/api.js
CHANGED
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import yaml from "js-yaml";
|
|
6
6
|
import { isInterruptibleEngine } from "../shared/types.js";
|
|
7
7
|
import { buildContext } from "../sessions/context.js";
|
|
8
|
-
import { listSessions, getSession, createSession, updateSession, deleteSession, deleteSessions, insertMessage, getMessages, enqueueQueueItem, cancelQueueItem, getQueueItems, cancelAllPendingQueueItems, listAllPendingQueueItems, } from "../sessions/registry.js";
|
|
8
|
+
import { initDb, listSessions, getSession, createSession, updateSession, deleteSession, deleteSessions, insertMessage, getMessages, enqueueQueueItem, cancelQueueItem, getQueueItems, cancelAllPendingQueueItems, listAllPendingQueueItems, } from "../sessions/registry.js";
|
|
9
9
|
import { CONFIG_PATH, CRON_RUNS, ORG_DIR, SKILLS_DIR, LOGS_DIR, TMP_DIR, } from "../shared/paths.js";
|
|
10
10
|
import { logger } from "../shared/logger.js";
|
|
11
11
|
import { getSttStatus, downloadModel, transcribe as sttTranscribe, resolveLanguages, WHISPER_LANGUAGES } from "../stt/stt.js";
|
|
@@ -1310,6 +1310,117 @@ export async function handleApiRequest(req, res, context) {
|
|
|
1310
1310
|
if (handled)
|
|
1311
1311
|
return;
|
|
1312
1312
|
}
|
|
1313
|
+
// ── Goals ────────────────────────────────────────────────────────
|
|
1314
|
+
// GET /api/goals
|
|
1315
|
+
if (method === "GET" && pathname === "/api/goals") {
|
|
1316
|
+
const { listGoals } = await import("./goals.js");
|
|
1317
|
+
const db = initDb();
|
|
1318
|
+
return json(res, listGoals(db));
|
|
1319
|
+
}
|
|
1320
|
+
// GET /api/goals/tree
|
|
1321
|
+
if (method === "GET" && pathname === "/api/goals/tree") {
|
|
1322
|
+
const { getGoalTree } = await import("./goals.js");
|
|
1323
|
+
const db = initDb();
|
|
1324
|
+
return json(res, getGoalTree(db));
|
|
1325
|
+
}
|
|
1326
|
+
// POST /api/goals
|
|
1327
|
+
if (method === "POST" && pathname === "/api/goals") {
|
|
1328
|
+
const _parsed = await readJsonBody(req, res);
|
|
1329
|
+
if (!_parsed.ok)
|
|
1330
|
+
return;
|
|
1331
|
+
const { createGoal } = await import("./goals.js");
|
|
1332
|
+
const db = initDb();
|
|
1333
|
+
const goal = createGoal(db, _parsed.body);
|
|
1334
|
+
return json(res, goal, 201);
|
|
1335
|
+
}
|
|
1336
|
+
// GET /api/goals/:id
|
|
1337
|
+
params = matchRoute("/api/goals/:id", pathname);
|
|
1338
|
+
if (method === "GET" && params) {
|
|
1339
|
+
const { getGoal } = await import("./goals.js");
|
|
1340
|
+
const db = initDb();
|
|
1341
|
+
const goal = getGoal(db, params.id);
|
|
1342
|
+
if (!goal)
|
|
1343
|
+
return notFound(res);
|
|
1344
|
+
return json(res, goal);
|
|
1345
|
+
}
|
|
1346
|
+
// PUT /api/goals/:id
|
|
1347
|
+
params = matchRoute("/api/goals/:id", pathname);
|
|
1348
|
+
if (method === "PUT" && params) {
|
|
1349
|
+
const _parsed = await readJsonBody(req, res);
|
|
1350
|
+
if (!_parsed.ok)
|
|
1351
|
+
return;
|
|
1352
|
+
const { updateGoal } = await import("./goals.js");
|
|
1353
|
+
const db = initDb();
|
|
1354
|
+
const goal = updateGoal(db, params.id, _parsed.body);
|
|
1355
|
+
if (!goal)
|
|
1356
|
+
return notFound(res);
|
|
1357
|
+
return json(res, goal);
|
|
1358
|
+
}
|
|
1359
|
+
// DELETE /api/goals/:id
|
|
1360
|
+
params = matchRoute("/api/goals/:id", pathname);
|
|
1361
|
+
if (method === "DELETE" && params) {
|
|
1362
|
+
const { deleteGoal } = await import("./goals.js");
|
|
1363
|
+
const db = initDb();
|
|
1364
|
+
deleteGoal(db, params.id);
|
|
1365
|
+
return json(res, { status: "ok" });
|
|
1366
|
+
}
|
|
1367
|
+
// ── Costs ────────────────────────────────────────────────────────
|
|
1368
|
+
// GET /api/costs/summary
|
|
1369
|
+
if (method === "GET" && pathname === "/api/costs/summary") {
|
|
1370
|
+
const { getCostSummary } = await import("./costs.js");
|
|
1371
|
+
const rawPeriod = url.searchParams.get("period") ?? "month";
|
|
1372
|
+
const period = (rawPeriod === "day" || rawPeriod === "week" || rawPeriod === "month") ? rawPeriod : "month";
|
|
1373
|
+
return json(res, getCostSummary(period));
|
|
1374
|
+
}
|
|
1375
|
+
// GET /api/costs/by-employee
|
|
1376
|
+
if (method === "GET" && pathname === "/api/costs/by-employee") {
|
|
1377
|
+
const { getCostsByEmployee } = await import("./costs.js");
|
|
1378
|
+
const rawPeriod = url.searchParams.get("period") ?? "month";
|
|
1379
|
+
const period = (rawPeriod === "week") ? "week" : "month";
|
|
1380
|
+
return json(res, getCostsByEmployee(period));
|
|
1381
|
+
}
|
|
1382
|
+
// ── Budgets ──────────────────────────────────────────────────────
|
|
1383
|
+
// GET /api/budgets
|
|
1384
|
+
if (method === "GET" && pathname === "/api/budgets") {
|
|
1385
|
+
const { getBudgetStatus } = await import("./budgets.js");
|
|
1386
|
+
const config = context.getConfig();
|
|
1387
|
+
const budgetConfig = config.budgets?.employees ?? {};
|
|
1388
|
+
const employees = Object.keys(budgetConfig);
|
|
1389
|
+
const statuses = employees.map((emp) => ({
|
|
1390
|
+
employee: emp,
|
|
1391
|
+
...getBudgetStatus(emp, budgetConfig),
|
|
1392
|
+
}));
|
|
1393
|
+
return json(res, { employees: budgetConfig, statuses });
|
|
1394
|
+
}
|
|
1395
|
+
// PUT /api/budgets
|
|
1396
|
+
if (method === "PUT" && pathname === "/api/budgets") {
|
|
1397
|
+
const _parsed = await readJsonBody(req, res);
|
|
1398
|
+
if (!_parsed.ok)
|
|
1399
|
+
return;
|
|
1400
|
+
const body = _parsed.body;
|
|
1401
|
+
let existing = {};
|
|
1402
|
+
try {
|
|
1403
|
+
existing = yaml.load(fs.readFileSync(CONFIG_PATH, "utf-8")) || {};
|
|
1404
|
+
}
|
|
1405
|
+
catch { /* start fresh if unreadable */ }
|
|
1406
|
+
const merged = deepMerge(existing, { budgets: { employees: body } });
|
|
1407
|
+
fs.writeFileSync(CONFIG_PATH, yaml.dump(merged));
|
|
1408
|
+
logger.info("Budget limits updated via API");
|
|
1409
|
+
return json(res, { status: "ok" });
|
|
1410
|
+
}
|
|
1411
|
+
// POST /api/budgets/:employee/override
|
|
1412
|
+
params = matchRoute("/api/budgets/:employee/override", pathname);
|
|
1413
|
+
if (method === "POST" && params) {
|
|
1414
|
+
const { overrideBudget } = await import("./budgets.js");
|
|
1415
|
+
const config = context.getConfig();
|
|
1416
|
+
const budgetConfig = config.budgets?.employees ?? {};
|
|
1417
|
+
return json(res, overrideBudget(params.employee, budgetConfig));
|
|
1418
|
+
}
|
|
1419
|
+
// GET /api/budgets/events
|
|
1420
|
+
if (method === "GET" && pathname === "/api/budgets/events") {
|
|
1421
|
+
const { getBudgetEvents } = await import("./budgets.js");
|
|
1422
|
+
return json(res, getBudgetEvents());
|
|
1423
|
+
}
|
|
1313
1424
|
return notFound(res);
|
|
1314
1425
|
}
|
|
1315
1426
|
catch (err) {
|