@ulpi/cli 0.1.5 → 0.1.7
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 +143 -214
- package/dist/{auth-PN7TMQHV-2W4ICG64.js → auth-FWM7MM4Q-VZC3U2XZ.js} +1 -1
- package/dist/{auth-BFFBUJUC.js → auth-HDK7ECJL.js} +2 -1
- package/dist/{chunk-RJIRWQJD.js → chunk-3BCW6ABU.js} +402 -142
- package/dist/{chunk-L3PWNHSA.js → chunk-3WB5CXH4.js} +180 -5
- package/dist/{chunk-K4OVPFY2.js → chunk-4UCJIAOU.js} +2 -2
- package/dist/chunk-4XTHZVDS.js +109 -0
- package/dist/chunk-4ZPOZULQ.js +6522 -0
- package/dist/{chunk-SIAQVRKG.js → chunk-5MI5GIXM.js} +48 -2
- package/dist/{chunk-KLEASXUR.js → chunk-6ZL6NXMV.js} +1 -1
- package/dist/{chunk-AV5RB3N2.js → chunk-76D3BYJD.js} +48 -0
- package/dist/{chunk-DOIKS6C5.js → chunk-AWOSRA5F.js} +1 -1
- package/dist/{chunk-UCMT5OKP.js → chunk-BFEKZZHM.js} +274 -57
- package/dist/chunk-C7CLUQI6.js +1286 -0
- package/dist/{chunk-ELTGWMDE.js → chunk-E3B5NROU.js} +7 -7
- package/dist/chunk-EJ7TW77N.js +1418 -0
- package/dist/{chunk-P2RESJRN.js → chunk-EWLYVXQ4.js} +2 -2
- package/dist/{chunk-6OURRFP7.js → chunk-IV6MWETF.js} +383 -168
- package/dist/chunk-IZPJHSPX.js +1478 -0
- package/dist/chunk-JLHNLM3C.js +228 -0
- package/dist/chunk-PO4NUZUU.js +147 -0
- package/dist/chunk-S6ANCSYO.js +1271 -0
- package/dist/chunk-SEU7WWNQ.js +1251 -0
- package/dist/chunk-SNQ7NAIS.js +453 -0
- package/dist/{ulpi-RMMCUAGP-EWYUE7RU.js → chunk-TSLDGT5O.js} +73 -35
- package/dist/{chunk-EIWYSP3A.js → chunk-UXHCHOWQ.js} +83 -62
- package/dist/chunk-WED4LM5N.js +322 -0
- package/dist/chunk-WVOZE25N.js +6757 -0
- package/dist/{chunk-5SCG7UYM.js → chunk-XKF4DPUM.js} +7 -7
- package/dist/{chunk-74WVVWJ4.js → chunk-YOKL7RB5.js} +184 -15
- package/dist/chunk-Z53CAR7G.js +298 -0
- package/dist/{ci-JQ56YIKC.js → ci-COZRTPGQ.js} +124 -26
- package/dist/cloud-2F3NLVHN.js +274 -0
- package/dist/{codemap-HMYBXJL2.js → codemap-XNGMAF3F.js} +37 -37
- package/dist/codex-MB5YTMRT.js +132 -0
- package/dist/{config-YYWEN7U2.js → config-OOELBYTH.js} +1 -1
- package/dist/dist-2BJYR5EI.js +59 -0
- package/dist/dist-3EIQTZHT.js +1380 -0
- package/dist/{dist-WAMAQVPK.js → dist-4U5L2X2C.js} +2 -2
- package/dist/{dist-4XTJ6HLM.js → dist-54KAMNLO.js} +16 -15
- package/dist/dist-6M4MZWZW.js +58 -0
- package/dist/dist-6X576SU2.js +27 -0
- package/dist/dist-7QOEYLFX.js +103 -0
- package/dist/dist-AYBGHEDY.js +2541 -0
- package/dist/dist-EK45QNEM.js +45 -0
- package/dist/{dist-U7ZIJMZD.js → dist-FKFEJRPX.js} +16 -15
- package/dist/dist-GTEJUBBT.js +66 -0
- package/dist/dist-HA74OKJZ.js +40 -0
- package/dist/{dist-XG2GG5SD.js → dist-HU5RZAON.js} +14 -2
- package/dist/dist-IYE3OBRB.js +374 -0
- package/dist/{dist-7WLLPWWB.js → dist-JLU26AB6.js} +12 -9
- package/dist/{dist-6G7JC2RA.js → dist-KUCI6JFE.js} +49 -9
- package/dist/dist-NUEMFZFL.js +33 -0
- package/dist/{dist-GWGTAHNM.js → dist-NUXMDXZ3.js} +31 -3
- package/dist/{dist-5R4RYNQO.js → dist-YCNWHSLN.js} +15 -5
- package/dist/{dist-6MFVWIFF.js → dist-YFFG2ZD6.js} +9 -16
- package/dist/dist-ZG4OKCSR.js +15 -0
- package/dist/doctor-FKYSIHER.js +345 -0
- package/dist/{export-import-4A5MWLIA.js → export-import-JFQH4KSJ.js} +1 -1
- package/dist/{history-RNUWO4JZ.js → history-UMGQNQQ7.js} +7 -7
- package/dist/{hooks-installer-K2JXEBNN.js → hooks-installer-YEYTYA6Q.js} +2 -2
- package/dist/index.js +398 -622
- package/dist/{init-NQWFZPKO.js → init-TJYW5ROZ.js} +78 -12
- package/dist/job-HIDMAFW2.js +376 -0
- package/dist/jobs.memory-PLMMSFHB-VBECCTHN.js +33 -0
- package/dist/kiro-VMUHDFGK.js +153 -0
- package/dist/{launchd-OYXUAVW6.js → launchd-U3MSWBRH.js} +9 -17
- package/dist/mcp-PDUD7SGP.js +249 -0
- package/dist/mcp-installer-PQU3XOGO.js +259 -0
- package/dist/mcp-setup-OA7IB3H3.js +263 -0
- package/dist/{memory-D6ZFFCI2.js → memory-ZNAEAK3B.js} +17 -17
- package/dist/{ollama-3XCUZMZT-FYKHW4TZ.js → ollama-3XCUZMZT-4JMH6B7P.js} +1 -1
- package/dist/{openai-E7G2YAHU-IG33BFYF.js → openai-E7G2YAHU-T3HMBPH7.js} +2 -2
- package/dist/portal-JYWVHXDU.js +210 -0
- package/dist/prd-Q4J5NVAR.js +408 -0
- package/dist/repos-WWZXNN3P.js +271 -0
- package/dist/review-integration-RQE4KMAV.js +14 -0
- package/dist/{rules-3OFGWHP4.js → rules-Y4VSOY5Y.js} +3 -3
- package/dist/run-VPNXEIBY.js +687 -0
- package/dist/server-COL4AXKU-P7S7NNF6.js +11 -0
- package/dist/server-U7PQ6FTS-MG4MJPTS.js +20 -0
- package/dist/{skills-GY2CTPWN.js → skills-QEYU2N27.js} +4 -2
- package/dist/start-IJKY5RVT.js +303 -0
- package/dist/{status-SE43TIFJ.js → status-BHQYYGAL.js} +2 -2
- package/dist/{templates-O2XDKB5R.js → templates-CBRUJ66V.js} +6 -5
- package/dist/tui-DP7736EX.js +61 -0
- package/dist/ulpi-5EN6JCAS-LFE3WSL4.js +10 -0
- package/dist/{uninstall-KWGSGZTI.js → uninstall-BX6FOV77.js} +3 -3
- package/dist/{update-QYZA4D23.js → update-AQKTHFVQ.js} +3 -3
- package/dist/{version-checker-MVB74DEX.js → version-checker-5L5PUOEX.js} +2 -2
- package/package.json +13 -4
- package/dist/chunk-26LLDX2T.js +0 -553
- package/dist/chunk-DDRLI6JU.js +0 -331
- package/dist/chunk-IFATANHR.js +0 -453
- package/dist/chunk-JWUUVXIV.js +0 -13694
- package/dist/chunk-LD52XG3X.js +0 -4273
- package/dist/chunk-MIAQVCFW.js +0 -39
- package/dist/chunk-YYZOFYS6.js +0 -415
- package/dist/dist-XD4YI27T.js +0 -26
- package/dist/mcp-installer-TOYDP77X.js +0 -124
- package/dist/projects-COUJP4ZC.js +0 -271
- package/dist/review-KMGP2S25.js +0 -152
- package/dist/server-USLHY6GH-F4JSXCWA.js +0 -18
- package/dist/server-X5P6WH2M-ULZF5WHZ.js +0 -11
- package/dist/ui-4SM2SUI6.js +0 -167
- package/dist/ui.html +0 -698
- /package/dist/skills/{ulpi-generate-guardian → ulpi-generate-guards}/SKILL.md +0 -0
- /package/dist/skills/{ulpi-generate-guardian → ulpi-generate-guards}/references/framework-rules.md +0 -0
- /package/dist/skills/{ulpi-generate-guardian → ulpi-generate-guards}/references/language-rules.md +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JsonSessionStore,
|
|
3
3
|
readEvents
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SEU7WWNQ.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_AI_MODEL,
|
|
7
7
|
REVIEWS_DIR,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getHistoryBranch,
|
|
10
10
|
projectGuardsFile,
|
|
11
11
|
projectGuardsFileAlt
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-C7CLUQI6.js";
|
|
13
13
|
|
|
14
14
|
// ../../packages/history-engine/dist/index.js
|
|
15
15
|
import { execFileSync } from "child_process";
|
|
@@ -1591,10 +1591,9 @@ fi
|
|
|
1591
1591
|
${HOOK_MARKER_END}`;
|
|
1592
1592
|
}
|
|
1593
1593
|
function generatePostCommit(binaryPath) {
|
|
1594
|
-
const cmd = binaryPath.includes(" ") ? binaryPath : `"${binaryPath}"`;
|
|
1595
1594
|
return `${HOOK_MARKER_START}
|
|
1596
1595
|
# Trigger on-commit history capture (fail-open)
|
|
1597
|
-
${
|
|
1596
|
+
"${binaryPath}" history capture HEAD 2>/dev/null || true
|
|
1598
1597
|
${HOOK_MARKER_END}`;
|
|
1599
1598
|
}
|
|
1600
1599
|
function generatePrePush() {
|
|
@@ -1606,6 +1605,177 @@ if git rev-parse --verify ulpi/history >/dev/null 2>&1; then
|
|
|
1606
1605
|
fi
|
|
1607
1606
|
${HOOK_MARKER_END}`;
|
|
1608
1607
|
}
|
|
1608
|
+
async function writeIterationEntry(projectDir, sessionId, iteration, branchName) {
|
|
1609
|
+
branchName ??= getHistoryBranch();
|
|
1610
|
+
if (!historyBranchExists(projectDir, branchName)) return;
|
|
1611
|
+
const entry = {
|
|
1612
|
+
iterationId: iteration.id,
|
|
1613
|
+
sessionId,
|
|
1614
|
+
taskId: iteration.taskId,
|
|
1615
|
+
agentType: iteration.agentType,
|
|
1616
|
+
agentModel: iteration.agentModel,
|
|
1617
|
+
duration: iteration.duration,
|
|
1618
|
+
outputSummary: iteration.outputSummary,
|
|
1619
|
+
filesChanged: iteration.filesChanged ?? [],
|
|
1620
|
+
commitSha: iteration.commitSha,
|
|
1621
|
+
status: mapStatus(iteration.status),
|
|
1622
|
+
tokenUsage: iteration.tokenUsage,
|
|
1623
|
+
startedAt: iteration.startedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
1624
|
+
completedAt: iteration.completedAt,
|
|
1625
|
+
error: iteration.error,
|
|
1626
|
+
projectDir,
|
|
1627
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1628
|
+
};
|
|
1629
|
+
await withWorktree(projectDir, branchName, (worktreeDir) => {
|
|
1630
|
+
const iterPath = `iterations/${sessionId}/${iteration.id}.json`;
|
|
1631
|
+
writeAndStage(worktreeDir, iterPath, JSON.stringify(entry, null, 2));
|
|
1632
|
+
updateTaskIndex(worktreeDir, projectDir, entry, branchName);
|
|
1633
|
+
commitInWorktree(
|
|
1634
|
+
worktreeDir,
|
|
1635
|
+
`chore(history): iteration ${iteration.id} for task ${iteration.taskId}`
|
|
1636
|
+
);
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
function readIterationsForSession(projectDir, sessionId, branchName) {
|
|
1640
|
+
branchName ??= getHistoryBranch();
|
|
1641
|
+
if (!historyBranchExists(projectDir, branchName)) return [];
|
|
1642
|
+
const dir = `iterations/${sessionId}`;
|
|
1643
|
+
const files = listBranchDir(projectDir, dir, branchName);
|
|
1644
|
+
const entries = [];
|
|
1645
|
+
for (const file of files) {
|
|
1646
|
+
if (!file.endsWith(".json")) continue;
|
|
1647
|
+
const raw = readFromBranch(projectDir, `${dir}/${file}`, branchName);
|
|
1648
|
+
if (!raw) continue;
|
|
1649
|
+
try {
|
|
1650
|
+
entries.push(JSON.parse(raw));
|
|
1651
|
+
} catch {
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
entries.sort(
|
|
1655
|
+
(a, b) => new Date(a.startedAt).getTime() - new Date(b.startedAt).getTime()
|
|
1656
|
+
);
|
|
1657
|
+
return entries;
|
|
1658
|
+
}
|
|
1659
|
+
function readIterationsForTask(projectDir, taskId, branchName) {
|
|
1660
|
+
branchName ??= getHistoryBranch();
|
|
1661
|
+
if (!historyBranchExists(projectDir, branchName)) return [];
|
|
1662
|
+
const indexRaw = readFromBranch(
|
|
1663
|
+
projectDir,
|
|
1664
|
+
`iterations/tasks/${taskId}.json`,
|
|
1665
|
+
branchName
|
|
1666
|
+
);
|
|
1667
|
+
if (!indexRaw) return [];
|
|
1668
|
+
let index;
|
|
1669
|
+
try {
|
|
1670
|
+
index = JSON.parse(indexRaw);
|
|
1671
|
+
} catch {
|
|
1672
|
+
return [];
|
|
1673
|
+
}
|
|
1674
|
+
const entries = [];
|
|
1675
|
+
for (let i = 0; i < index.sessionIds.length; i++) {
|
|
1676
|
+
const sessionId = index.sessionIds[i];
|
|
1677
|
+
const iterationId = index.iterationIds[i];
|
|
1678
|
+
if (!sessionId || !iterationId) continue;
|
|
1679
|
+
const raw = readFromBranch(
|
|
1680
|
+
projectDir,
|
|
1681
|
+
`iterations/${sessionId}/${iterationId}.json`,
|
|
1682
|
+
branchName
|
|
1683
|
+
);
|
|
1684
|
+
if (!raw) continue;
|
|
1685
|
+
try {
|
|
1686
|
+
entries.push(JSON.parse(raw));
|
|
1687
|
+
} catch {
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
entries.sort(
|
|
1691
|
+
(a, b) => new Date(a.startedAt).getTime() - new Date(b.startedAt).getTime()
|
|
1692
|
+
);
|
|
1693
|
+
return entries;
|
|
1694
|
+
}
|
|
1695
|
+
function linkTaskAcrossSessions(projectDir, taskId, branchName) {
|
|
1696
|
+
branchName ??= getHistoryBranch();
|
|
1697
|
+
if (!historyBranchExists(projectDir, branchName)) return null;
|
|
1698
|
+
const raw = readFromBranch(
|
|
1699
|
+
projectDir,
|
|
1700
|
+
`iterations/tasks/${taskId}.json`,
|
|
1701
|
+
branchName
|
|
1702
|
+
);
|
|
1703
|
+
if (!raw) return null;
|
|
1704
|
+
try {
|
|
1705
|
+
return JSON.parse(raw);
|
|
1706
|
+
} catch {
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
function getTaskHistory(projectDir, taskId, branchName) {
|
|
1711
|
+
branchName ??= getHistoryBranch();
|
|
1712
|
+
const iterations = readIterationsForTask(projectDir, taskId, branchName);
|
|
1713
|
+
const sessions = [...new Set(iterations.map((it) => it.sessionId))];
|
|
1714
|
+
return {
|
|
1715
|
+
taskId,
|
|
1716
|
+
totalIterations: iterations.length,
|
|
1717
|
+
sessions,
|
|
1718
|
+
iterations
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
function mapStatus(status) {
|
|
1722
|
+
switch (status) {
|
|
1723
|
+
case "completed":
|
|
1724
|
+
return "completed";
|
|
1725
|
+
case "failed":
|
|
1726
|
+
return "failed";
|
|
1727
|
+
case "skipped":
|
|
1728
|
+
return "skipped";
|
|
1729
|
+
default:
|
|
1730
|
+
return "failed";
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
function updateTaskIndex(worktreeDir, projectDir, entry, branchName) {
|
|
1734
|
+
const indexPath = `iterations/tasks/${entry.taskId}.json`;
|
|
1735
|
+
let index;
|
|
1736
|
+
const existingRaw = readFromBranch(projectDir, indexPath, branchName);
|
|
1737
|
+
if (existingRaw) {
|
|
1738
|
+
try {
|
|
1739
|
+
index = JSON.parse(existingRaw);
|
|
1740
|
+
} catch {
|
|
1741
|
+
index = createEmptyIndex(entry.taskId);
|
|
1742
|
+
}
|
|
1743
|
+
} else {
|
|
1744
|
+
index = createEmptyIndex(entry.taskId);
|
|
1745
|
+
}
|
|
1746
|
+
if (!index.iterationIds.includes(entry.iterationId)) {
|
|
1747
|
+
index.iterationIds.push(entry.iterationId);
|
|
1748
|
+
if (!index.sessionIds.includes(entry.sessionId)) {
|
|
1749
|
+
index.sessionIds.push(entry.sessionId);
|
|
1750
|
+
}
|
|
1751
|
+
const sessionMap = /* @__PURE__ */ new Map();
|
|
1752
|
+
for (let i = 0; i < index.iterationIds.length - 1; i++) {
|
|
1753
|
+
const itId = index.iterationIds[i];
|
|
1754
|
+
if (i < index.sessionIds.length) {
|
|
1755
|
+
sessionMap.set(itId, index.sessionIds[i]);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
sessionMap.set(entry.iterationId, entry.sessionId);
|
|
1759
|
+
const iterationIds = [];
|
|
1760
|
+
const sessionIds = [];
|
|
1761
|
+
for (const itId of index.iterationIds) {
|
|
1762
|
+
iterationIds.push(itId);
|
|
1763
|
+
sessionIds.push(sessionMap.get(itId) ?? entry.sessionId);
|
|
1764
|
+
}
|
|
1765
|
+
index.iterationIds = iterationIds;
|
|
1766
|
+
index.sessionIds = sessionIds;
|
|
1767
|
+
}
|
|
1768
|
+
index.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1769
|
+
writeAndStage(worktreeDir, indexPath, JSON.stringify(index, null, 2));
|
|
1770
|
+
}
|
|
1771
|
+
function createEmptyIndex(taskId) {
|
|
1772
|
+
return {
|
|
1773
|
+
taskId,
|
|
1774
|
+
sessionIds: [],
|
|
1775
|
+
iterationIds: [],
|
|
1776
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1609
1779
|
|
|
1610
1780
|
export {
|
|
1611
1781
|
historyBranchExists,
|
|
@@ -1648,5 +1818,10 @@ export {
|
|
|
1648
1818
|
readTranscript,
|
|
1649
1819
|
getTranscriptSize,
|
|
1650
1820
|
installGitHooks,
|
|
1651
|
-
uninstallGitHooks
|
|
1821
|
+
uninstallGitHooks,
|
|
1822
|
+
writeIterationEntry,
|
|
1823
|
+
readIterationsForSession,
|
|
1824
|
+
readIterationsForTask,
|
|
1825
|
+
linkTaskAcrossSessions,
|
|
1826
|
+
getTaskHistory
|
|
1652
1827
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveApiKey
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C7CLUQI6.js";
|
|
4
4
|
|
|
5
|
-
// ../../packages/
|
|
5
|
+
// ../../packages/embed-engine/dist/chunk-ZW4DV263.js
|
|
6
6
|
var OPENAI_EMBEDDINGS_URL = "https://api.openai.com/v1/embeddings";
|
|
7
7
|
var MAX_RETRIES = 3;
|
|
8
8
|
var RETRY_BASE_MS = 1e3;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ULPI_GLOBAL_DIR
|
|
3
|
+
} from "./chunk-C7CLUQI6.js";
|
|
4
|
+
|
|
5
|
+
// ../api/dist/chunk-AZQGVTXK.js
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
var JOBS_DIR = path.join(ULPI_GLOBAL_DIR, "jobs");
|
|
9
|
+
function ensureJobsDir() {
|
|
10
|
+
if (!fs.existsSync(JOBS_DIR)) {
|
|
11
|
+
fs.mkdirSync(JOBS_DIR, { recursive: true });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function saveJob(job) {
|
|
15
|
+
ensureJobsDir();
|
|
16
|
+
const filePath = path.join(JOBS_DIR, `${job.id}.json`);
|
|
17
|
+
fs.writeFileSync(filePath, JSON.stringify(job, null, 2), "utf-8");
|
|
18
|
+
}
|
|
19
|
+
function loadJob(jobId) {
|
|
20
|
+
const filePath = path.join(JOBS_DIR, `${jobId}.json`);
|
|
21
|
+
try {
|
|
22
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
23
|
+
return JSON.parse(content);
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function listJobs() {
|
|
29
|
+
ensureJobsDir();
|
|
30
|
+
try {
|
|
31
|
+
const files = fs.readdirSync(JOBS_DIR).filter((f) => f.endsWith(".json"));
|
|
32
|
+
const jobs = [];
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
try {
|
|
35
|
+
const content = fs.readFileSync(path.join(JOBS_DIR, file), "utf-8");
|
|
36
|
+
jobs.push(JSON.parse(content));
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
jobs.sort(
|
|
41
|
+
(a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
|
42
|
+
);
|
|
43
|
+
return jobs;
|
|
44
|
+
} catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function appendJobLog(job, level, message) {
|
|
49
|
+
if (!job.logs) job.logs = [];
|
|
50
|
+
job.logs.push({
|
|
51
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
52
|
+
level,
|
|
53
|
+
message
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function deleteJob(jobId) {
|
|
57
|
+
const filePath = path.join(JOBS_DIR, `${jobId}.json`);
|
|
58
|
+
const eventsPath = path.join(JOBS_DIR, `${jobId}.events.jsonl`);
|
|
59
|
+
try {
|
|
60
|
+
fs.unlinkSync(filePath);
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
fs.unlinkSync(eventsPath);
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function appendEventLog(jobId, event) {
|
|
70
|
+
ensureJobsDir();
|
|
71
|
+
const filePath = path.join(JOBS_DIR, `${jobId}.events.jsonl`);
|
|
72
|
+
try {
|
|
73
|
+
fs.appendFileSync(filePath, JSON.stringify(event) + "\n", "utf-8");
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function readEventLogs(jobId) {
|
|
78
|
+
const filePath = path.join(JOBS_DIR, `${jobId}.events.jsonl`);
|
|
79
|
+
try {
|
|
80
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
81
|
+
const events = [];
|
|
82
|
+
for (const line of content.split("\n")) {
|
|
83
|
+
if (!line.trim()) continue;
|
|
84
|
+
try {
|
|
85
|
+
events.push(JSON.parse(line));
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return events;
|
|
90
|
+
} catch {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function generateJobId() {
|
|
95
|
+
return `job-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
96
|
+
}
|
|
97
|
+
var activeJobs = /* @__PURE__ */ new Map();
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
saveJob,
|
|
101
|
+
loadJob,
|
|
102
|
+
listJobs,
|
|
103
|
+
appendJobLog,
|
|
104
|
+
deleteJob,
|
|
105
|
+
appendEventLog,
|
|
106
|
+
readEventLogs,
|
|
107
|
+
generateJobId,
|
|
108
|
+
activeJobs
|
|
109
|
+
};
|